Bitbucket Server Backup Client fails with "File $BITBUCKET_HOME\bitbucket_search\nodes\0\indices\bitbucket-search-v1\0\index\write.lock cannot be read"
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
Problem
Taking a backup of Bitbucket Server using the Bitbucket Server Backup Client fails.
One of the following appears in the backup client log (atlassian-
sbc-YYYY-MM-DD-HHMM.log):
ERROR (87%) Error writing tar file entry: The process cannot access the file because another process has locked a portion of the file java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.FileDispatcherImpl.read(Unknown Source)
... 25 more frames available in the log file
ERROR (87%) File $BITBUCKET_HOME\bitbucket_search\nodes\0\indices\bitbucket-search-v1\0\index\write.lock cannot be read
ERROR (50%) Error writing tar file entry: The process cannot access the file because another process has locked a portion of the file
java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.FileDispatcherImpl.read(Unknown Source)
... 25 more frames available in the log file
ERROR (50%) File $BITBUCKET_HOME\index\stash-codesearch\nodes\0\node.lock cannot be read
Diagnosis
Environment
- Windows Operating System (while this could happen on Linux based Operating Systems as well, we have only seen this error on Windows so far)
Diagnostic Steps
- The Smarter Search for Bitbucket (Stash) is installed (note that the
bitbucket_search
folder is used to store the Elasticsearch indexes of this app and not the ones of the Code search feature)
Cause
The lock files are temporary files and, while they are available when the listing of the files is performed, they have already been removed when the backup tries to collect them.
Resolution
Add one of the following exclusion options to the backup-config.properties
file.
Recommended This configuration will only exclude the lock files in the index/stash-codesearch folder, which is the one where the data of the "Smarter Search" app saves its data:
bitbucket.home.excludes=index/stash-codesearch/**/*.lock
This second option would exclude every file (not just the lock ones). We can use this once it is confirmed that the index will be regenerated in case of a restore:
bitbucket.home.excludes=index/stash-codesearch/**
This option will exclude every lock file in every subfolder of the $BITBUCKET_HOME directory. While this will allow the creation of the backup, it may exclude other files outside of the app directory without any error:
bitbucket.home.excludes=**/*.lock
In case, after a restore, any issues are observed in the data indexed by the app, a "Save and Reindex" option is available on the app Global Settings page.
The page can be accessed at this URL:
<Bitbucket URL>/plugins/servlet/codesearch/globalsettings