Unable to establish a connection to Elasticsearch during index synchronisation

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

BItbucket logs report the following error when connecting to Elasticsearch:

1 2020-03-02 15:17:13,933 WARN [Caesium-1-3] c.a.b.i.s.i.IndexingSynchronizationService Unable to establish a connection to Elasticsearch during index synchronisation.

There is no other apparent error in the logs.

However, looking at elasticsearch log, bitbucket-search.log for embedded Elasticsearch, has the following error:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [2020-03-02T07:55:44,546][ERROR][o.e.g.GatewayMetaState ] [bitbucket_bundled]failed to read local state, exiting... java.lang.IllegalStateException: index and alias names need to be unique, but the following duplicates were found [bitbucket-search (alias of [bitbucket-search-v1/Q0X8oUSNT9GiVCILGg6iXw])] at org.elasticsearch.cluster.metadata.MetaData$Builder.build(MetaData.java:1111) ~[elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.gateway.MetaStateService.loadFullState(MetaStateService.java:72) ~[elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.gateway.GatewayMetaState.<init>(GatewayMetaState.java:86) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.node.Node.<init>(Node.java:499) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.node.Node.<init>(Node.java:265) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.5.3.jar:6.5.3] at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) [elasticsearch-6.5.3.jar:6.5.3] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) [elasticsearch-6.5.3.jar:6.5.3] [2020-03-02T07:55:44,559][ERROR][o.e.b.Bootstrap ] [bitbucket_bundled]Exception

Diagnosis

The error in elasticsearch logs points to an alias, which, in the above example, is due to an earlier index name, bitbucket-search-v1, that Bitbucket Server used.

Cause

As the error indicates, index and alias names must be unique.

Solution

Resolution

  1. Stop Bitbucket Server (this will also stop embedded Elasticsearch)

  2. Remove the alias folder, <bitbucket-home>/shared/search/data/node/0/indices/Q0X8oUSNT9GiVCILGg6iXw in the above example

  3. Restart Bitbucket Server

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.