Bitbucket code search intermittently fails with java.net.SocketTimeoutException error
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
Searching for code in Bitbucket intermittently times out with java.net.SocketTimeoutException error
Environment
Bitbucket Server/Datacenter 6.10.2
Bundled or remote Elasticsearch instance
Diagnosis
During investigation the following entries are found in the application logs.
2020-10-20 12:10:18,120 DEBUG [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.b.i.s.s.DefaultSearchService [77562] Search query: {
"bool": {
"must": {
"bool": {
"should": [
{
"match": {
"content": {
"query": "test",
"operator": "and"
}
}
},
{
"match": {
"path": {
"query": "test",
"operator": "and"
...
2020-10-20 12:10:23,140 ERROR [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.b.i.s.search.rest.SearchResource Failed to process search request 'RestSearchRequest{entities={code=PagingInfo{start=0, limit=0}}, limits=Limits{primary=25, secondary=10}, query='project:~TEST_PROJ repo:testrepo test'}' - error: java.net.SocketTimeoutException
2020-10-20 12:10:23,141 DEBUG [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.atlassian.bitbucket.search.timing Timing: Search request execution took 5.076 s [5076 ms] for query '~TEST_PROJ repo:testrepo test'
2020-10-20 12:10:23,144 ERROR [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "POST /rest/search/latest/search HTTP/1.0"
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.net.SocketTimeoutException
Cause
Due to a slowness to produce results from Elasticsearch, the request took longer than Bitbucket was expecting and it timed out the request. By default, Bitbucket sets a 5 seconds time out for waiting results from Elasticsearch.
Solution
Increase the code search timeout:
Edit <BITBUCKET_HOME>/shared/bitbucket.properties adding the following parameter:
plugin.search.search.http.socket.timeout=10
In this example we raised the timeout to 10 seconds. However this may vary accordingly to the size of your instance.
- Restart Bitbucket.