Search not working in Bitbucket Server when starting Elasticsearch as a Windows service
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
Elasticsearch is not up and running after Bitbucket upgrade and search is not working.
Environment
Operating System: Windows
Bitbucket version: 7.6.8
Diagnosis
Check whether Bitbucket is using bundled Elasticsearch or on a separate node. Here we're discussing bundled Elasticsearch.
In the Bitbucket application logs, you'll see the following errors:
atlassian-bitbucket.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ERROR [Caesium-1-1] c.a.b.i.s.i.IndexingSynchronizationService An error was encountered while checking or creating the mapping in Elasticsearch
com.atlassian.bitbucket.internal.search.indexing.exceptions.IndexException: Unable to check whether a valid mapping exists in Elasticsearch
at com.atlassian.bitbucket.internal.search.indexing.IndexingSynchronizationService.lambda$isMappingPresent$9(IndexingSynchronizationService.java:288)
at io.atlassian.fugue.Either$Left.fold(Either.java:586)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at com.atlassian.bitbucket.internal.search.indexing.util.Observables.consume(Observables.java:64)
at com.atlassian.bitbucket.internal.search.indexing.util.Observables.consumeSingle(Observables.java:92)
... 16 common frames omitted
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at java.base/sun.security.ssl.SSLEngineInputRecord.bytesInCompletePacket(SSLEngineInputRecord.java:146)
at java.base/sun.security.ssl.SSLEngineInputRecord.bytesInCompletePacket(SSLEngineInputRecord.java:64)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
... 1 common frames omitted
The "javax.net
.ssl.SSLException: Unrecognized SSL message, plaintext connection?"
normally occurs when Bitbucket is trying to connect to an application via SSL but that application is not configured with SSL.
From the application.xml
you may see that Elasticsearch is being accessed on an https
URL and CONNECTION_ERROR
message:
application.xml
1
2
3
4
5
6
<Elasticsearch>
<base-url>https://localhost:7992</base-url>
<username>bitbucket</username>
<hasPassword>true</hasPassword>
<connection-result>CONNECTION_ERROR</connection-result>
</Elasticsearch>
Change this to http
. So the Elasticsearch base URL should be http://localhost:7992 instead. Check your buckler.yml
file, it should look like this:
1
2
3
4
auth.basic.http.enabled: "true"
auth.basic.password:Sanitized by Support Utility
auth.basic.tcp.enabled: "true"
auth.basic.username: "bitbucket"
Notice the quotes (""). You should now be able to able to start bundled Elasticsearch when Bitbucket is started, but while starting Elasticsearch from the Windows service manager you'll be getting an error.
Cause
This is a bug in the Bitbucket 7.6.8 while using JAVA 11, because of which in Windows environment, the Elasticsearch service does not start. Below is the bug ticket:
Solution
The bug ticket mentions the below workaround:
Workaround
Remove the following entries from the Java Options section of the Java tab in the Elasticsearch Windows Service configuration window:
1
2
3
4
5
6
7
8
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:<PATH_TO_GC_LOGS>
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=32
-XX:GCLogFileSize=64m

Adding back the following options will retain the ability to log GC activity:
-Xlog:safepoint,gc*,gc+age*=trace:file=<PATH_TO_GC_LOGS>:time:filecount=32,filesize=64m
Was this helpful?