When upgrading Bitbucket Server with bundled Elasticsearch from 5.16.x straight to 7.1.x or newer, Elasticsearch indexes may need to be nuked and rebuilt from scratch because Elasticsearch will fail to upgradade them, which blocks Elasticsearch from starting up.
Elasticsearch logs report the following issue:
- As can be seen, this turns out to be a bug or limitation in Elasticsearch, not in Bitbucket Server. Bitbucket Server itself is upgraded without any problems.
- The message suggests the index needs to be rebuilt by an Elasticsearch version 6.x before they can be upgraded to 7.5.2.
- Performing an intermediary upgrade of Bitbucket from 5.16.11 to 6.10 (which bundles Elasticsearch 6.8.6) does not help because Elasticsearch 6.8.6 will not upgrade the index from 5.5.3. As the message suggests, the index needs to be rebuilt in Elasticsearch 6.x.
- This issue does not affect customers whose first version of Bitbucket ever installed bundled Elasticsearch 6.x or later.
- In a Windows machine, install Bitbucket Server version is 5.16.11, which bundles Elasticsearch 5.5.3, both of them starting up as Windows Service.
- Add a repository and let Elasticsearch finish indexing it.
- Shutdown Bitbucket Server and Elasticsearch services.
- Upgrade that Bitbucket instance to 7.1.1, which bundles Elasticsearch 7.5.2
- The upgrade scripts will update both Windows services as expected.
- Notice that only the Bitbucket service will start automatically. Elasticsearch service will be stopped, won't start at all.
- Take a look at the Elasticsearch logs and see that error message mentioned above.
- When upgrading from a Bitbucket Server version whose bundled Elasticsearch version is lower than 6.x, the Bitbucket installer should nuke the Elasticsearch caches before finishing the installation, so that in the last installer step when the services are started, both services do get started.
- We should make it clear in our upgrade guide that Elasticsearch caches may need to be nuked, and that rebuilding the index may take several hours, possibly resulting in some overhead on the server and search functionality showing incomplete results in the meantime.
- The bundled Elasticsearch 7.5.2 fails to start when after being upgraded from 5.5.3.
- Elasticsearch logs report the issue mentioned above.
Manually delete the index by performing the following steps:
- Stop Bitbucket Server and Elasticsearch services
- Delete the contents of <bitbucket-home>/shared/search/data/nodes directory
- Start Bitbucket Server and Elasticsearch services
- Wait until the index is completely rebuilt for obtaining complete search results.