Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira indexing script not working

Hemanth Rajagopal Nagarajan July 13, 2020

We have the following crontab expression executing on our Jira instance every Friday night:

00 03 * * 5 bash /root/rebuild_jira_index.sh >>/root/rebuild_jira_index.log 2>&1

The /root/rebuild_jira_index.sh script performs the following steps:

  1. stop the Jira application service;
  2. delete the Jira index files;
  3. start the Jira application service;
  4. sleep until Jira is in status=RUNNING;
  5. issue a full re-index request via the Jira REST API.

It appears that the re-index command is not succeeding.

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
July 13, 2020

What is your reindex command? Did you try the one mentioned on this page? https://confluence.atlassian.com/jirakb/reindex-jira-server-using-rest-api-via-curl-command-663617587.html

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
July 13, 2020

You definitelly need to authenticate user (jira-administrator) to invoke this endpoint

Hemanth Rajagopal Nagarajan July 13, 2020

Thanks Martin,

 

I will definitely try that and get back.

Hemanth Rajagopal Nagarajan July 13, 2020

But Martin, 

 

It was able to execute the script without any credentials in curl command previously. Is this a new update ?

Hemanth Rajagopal Nagarajan July 13, 2020

The script : 

 

# shut down jira service
while [[ $(pgrep java) ]]
do
sudo service jira stop
sleep 30
done

# remove index files
# https://confluence.atlassian.com/jirakb/unable-to-rebuild-jira-application-indexes-228623566.html
sudo rm -rf /var/atlassian/application-data/jira/caches/indexesV1/

# start up jira service
sudo service jira start

# wait until jira is ready to serve
# https://jira.atlassian.com/browse/JRASERVER-63928
# https://confluence.atlassian.com/enterprise/confluence-data-center-technical-overview-612959401.html
while [[ ! $(curl -s https://jira.xxxxxxx.com/status | grep RUNNING) ]]
do
sleep 600
done

# trigger full foreground re-index
curl -n -X POST https://jira.xxxxxxxxx.com/rest/api/2/reindex?type=FOREGROUND

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
July 13, 2020

Hm that's weird, documentation says that you need to have Admin permission to execute this endpoint. If there is no authentication, there is no permission. Your script also removes index files so I guess FOREGROUND reindex should not work. Can you try to rebuilt index manually after startup? Is foreground reindex option available?

Hemanth Rajagopal Nagarajan July 13, 2020

Yes i am able to do foreground re index manually. 

 

Also i am running this script from the instance instance itself as root.

Suggest an answer

Log in or Sign up to answer