Bitbucket Windows installer hangs on extracting files during upgrade
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
When upgrading the application via the Bitbucket installer on Windows, the application "hangs" on extracting files and can take excessive time to complete.
Environment
Applies to Bitbucket Server 7.3+ installations on a Windows environment.
Diagnosis
- Retrieve the Bitbucket installation log file from the <$BITBUCKET_INSTALL>\.install4j or the %TEMP% path. The naming of the file should be installation.log — this file is the installer log file and contains options selected during the upgrade/install and its status.
- Use the following tools to identify the currently running processes in Windows. Check with your Windows administrator for the availability of such tools.
Cause
Many steps are performed regarding the file system when installing or upgrading Bitbucket, such as extracting files and correcting permissions.
The issue here is caused by the installer trying to setup the correct permission for the atlbitbucket user for the Bitbucket install and the home directory. The permissions for the Bitbucket installation directory would be setup in a few seconds as the directory itself is not that huge. However, setting up the correct permission for the Bitbucket Home Directory depends on the directory size. So if the Bitbucket Home directory is enormous, then the chances are there are a lot of loose git objects and loose ref directories, and setting up the permissions for those files might take longer, hence the delay for the Bitbucket installer to complete.
The disk speed can also impact the installer's time to finish setting up the permission, so it's recommended to have the Bitbucket home folder as a local disk rather than a Network mount.
Cause #1 - The installer takes a long time to update the permission of BITBUCKET_HOME
[INFO] com.install4j.runtime.beans.actions.files.AddWindowsFileRightsAction [ID 73417]: Execute action
Property files: [C:\Atlassian\ApplicationData\Bitbucket]
Property group: SID or Account Name
Property sidOrAccountName: atlbitbucket
Property all: true
Property execute: true
Property read: true
Property rollbackSupported: false
Property write: true
Execute action successful after 5814259 ms
Cause #2 - The installer takes a long time to reduce the permissions of BITBUCKET_HOME and BITBUCKET_INST
This issue happens only when the option "Install as service" is chosen on the installer.
[INFO] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 72232]: Execute action
Property arguments: null
Property environmentVariables: {BITBUCKET_INST=${installer:sys.installationDir}, BITBUCKET_HOME=${installer:app.bitbucketHome}}
Property executable: setup_permissions.bat
Property returnCodeVariable:
Property rollbackArguments: null
Property rollbackExecutable: null
Property rollbackWorkingDirectory: null
Property stderrFile: null
Property stderrRedirectionMode: No redirection
Property stderrVariableName:
Property stdinFile: null
Property stdinRedirectionMode: No redirection
Property stdinString:
Property stdoutFile: null
Property stdoutRedirectionMode: No redirection
Property stdoutVariableName:
Property timeout: 0
Property workingDirectory: .
Property failOnStderrFileError: false
Property failOnStdinFileError: false
Property failOnStdoutFileError: false
Property includeParentEnvironmentVariables: true
Property keepConsoleWindow: false
Property logArguments: true
Property rollbackSupported: false
Property showWindowsConsole: false
Property useRollbackExecutable: false
Property wait: true
Property waitForStreams: true
used working dir: C:\Atlassian\Bitbucket\7.20.0\.
execute using batch file
Execute action successful after 3658903 ms
Below are the contents of setup_permissions.bat. The installer will consistently execute the setup_permissions.bat checkup when selecting to install the service. Since 7.3.0, the installer has run setup_permissions.bat, which turns off permission inheritance on the installation and home directories and removes access for "Authenticated Users" and "Users" groups.
@echo off
rem ---------------------------------------------------------------------------
rem Directory permissions script for Bitbucket, reducing permissions for regular users on the machine.
icacls "<BITBUCKET_INST>" /inheritance:d
icacls "<BITBUCKET_INST>" /remove "Users"
icacls "<BITBUCKET_INST>" /remove "Authenticated Users"
icacls "<BITBUCKET_HOME>" /inheritance:d
icacls "<BITBUCKET_HOME>" /remove "Users"
icacls "<BITBUCKET_HOME>" /remove "Authenticated Users"
Cause #3 - The installer takes a long time to update the permission of the current working directory and BITBUCKET_HOME
[INFO] com.install4j.runtime.beans.actions.files.AddWindowsFileRightsAction [ID 66035]: Execute action
Property files: [., D:\Stashhome]
Property group: Original User
Property sidOrAccountName: null
Property all: true
Property execute: false
Property read: true
Property rollbackSupported: false
Property write: true
Solution
There is no workaround for all the mentioned causes above, and waiting for the installation to complete is recommended.