Remote OpenSearch instance fails to create indexes for Bitbucket Data Center.
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
The OpenSearch instance, which is configured remotely, is experiencing issues with creating indexes for the Bitbucket Data Center. Although the remote instance has been set up successfully and has established a connection with Bitbucket, the process of creating indexes has failed. Consequently, search functionality within Bitbucket Data Center remains unavailable.
Environment
- Bitbucket Data Center 7.21.x +
- External OpenSearch instance.
Diagnosis
The below error is seen in Bitbucket logs:
023-02-22 15:51:36,119 ERROR [search-indexing:thread-1] c.a.b.i.s.i.e.DefaultIndexEventWorker Indexing - Failed for repository PRJ/repo (id: 285) with error: Indexing for repository with id 285 failed and should be retried
com.atlassian.bitbucket.internal.search.indexing.exceptions.IndexException: Indexing for repository with id 285 failed and should be retried
at com.atlassian.bitbucket.internal.search.indexing.indexer.DefaultIndexService.lambda$updateIndexStateForError$26(DefaultIndexService.java:457)
...
Caused by: java.lang.IllegalStateException: Object content expected to have '_type' field, but was not present; present fields: _index, _id, _version, result, _shards, _seq_no, _primary_term, status
at com.atlassian.elasticsearch.client.content.ObjectContent.lambda$getOrThrow$5(ObjectContent.java:110)
Cause
Based on the error message, it appears that OpenSearch is expecting a specific field named '_type' that is not present in the payload sent by Bitbucket. This results in the java.lang.IllegalStateException and fails the index creation. In summary, it appears that there is an incompatibility issue between the version of OpenSearch being used and Bitbucket.
Solution
We recommend double-checking the supported platforms documentation for the version of Bitbucket that you are currently using. It is essential to ensure that you are using the compatible version of OpenSearch that aligns with the Bitbucket version. If the version is not compatible, we suggest upgrading or reinstalling the appropriate version of OpenSearch on your remote instance and reconnecting it with Bitbucket.
If the indexes have been migrated from Elastcisearch to OpenSearch and such issue happened, you can proceed with deleting and rebuilding the search index.