Bitbucket Data Center fails to start with a 'Lock file .../shared/.lock cannot be created in home directory' error

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

要約

Bitbucket Data Center fails to start. The following appears in the atlassian-bitbucket.log:

Lock file .../shared/.lock cannot be created in home directory...

環境

This article is meant for a clustered Bitbucket Data Center implementation that has a shared home mounted via NFS, but could also possibly impact a Bitbucket Server instance using a mounted network location for other reasons.

診断

Attempt to perform a locked file operation (such as a mv) against a file in the shared Bitbucket home using flock or another similar command. 

原因

Cause 1:

A common reason for this error is that your NFS lock service is disabled or misconfigured. This can happen because the portmap and dbus services (at least, in Ubuntu Linux) are not always enabled by default.

Bitbucket Server and Bitbucket Server Data Center will create the following lock files:

  • ${BITBUCKET_HOME}/.lock
  • ${BITBUCKET_HOME}/shared/.lock

Bitbucket Server acquires an exclusive lock on both directories, preventing any other instances of Bitbucket Server (Server or Data Center) from using them.

Bitbucket Data Center acquires an exclusive lock on ${BITBUCKET_HOME} (preventing any other Bitbucket Server instances from using it) and a shared lock on${BITBUCKET_HOME}/shared (allowing it to be shared with other Bitbucket Data Center cluster nodes but not Bitbucket Server instances).

The two lock files exist so that two Bitbucket Server instances can not use the same Bitbucket Server home directory or shared folder at the same time.  This ensures that there is no data loss events from this type of misconfiguration.

原因 2:

If you see the following as part of the stack trace, it is likely that the statd service is disabled on the NFS server, preventing it from creating lock files within the shared Bitbucket home:

Caused by: java.io.IOException: No locks available

原因 3:

This can also be caused on the client side, when the services rpcbind and rpc-statd are not running. 

The stack trace would also report:

java.io.IOException: No locks available
	at java.base/sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
	at java.base/sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:96)
	at java.base/sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1161)
	at com.atlassian.stash.internal.home.HomeLock.acquireLock(HomeLock.java:112)
	at com.atlassian.stash.internal.home.HomeLock.lock(HomeLock.java:98)
	at com.atlassian.stash.internal.home.HomeLockAcquirer.lock(HomeLockAcquirer.java:58)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at java.base/java.lang.Thread.run(Thread.java:829)
	... 37 frames trimmed


ソリューション


原因 1:

Make sure the lockdportmap, and dbus services are all running on your NFS server, and restart Bitbucket Server. See Installing Bitbucket Data Center for more information.

If you still have one or more leftover .lock files after shutting down all your instances of Bitbucket Server, it's safe to delete them and start over.  

原因 2:

Enable and start the rpc-statd  service on the NFS server in order to allow the NFS server to create locks within ${BITBUCKET_HOME}/shared.

Ex:

sudo systemctl enable rpc-statd 
sudo systemctl start rpc-statd  

原因 3:

Enable and start rpcbind and rpc-statd. This should be done on the server hosting each Bitbucket node. 

sudo systemctl enable rpc-statd 
sudo systemctl start rpc-statd  

sudo systemctl enable rpcbind 
sudo systemctl start rpcbind 



In the event that the issue persists after either of these steps, it may also help to attempt completely restarting the NFS server and then restarting the Bitbucket nodes once more.

  • This may force a restart of other needed NFS server services that are specific to your NFS server which differ from the targeted restarts mentioned above.

It's also recommended to review the system logs of your associated NFS server for understanding any recent errors/service stoppages that could be related to the problem being experienced.

最終更新日 2022 年 8 月 11 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.