How to enable logging for the duration of Git commands and the number of concurrent Git commands available
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
There are limitations in executing Git commands in order to save the server resource of Bitbucket Server (formally Stash). See Stash is reaching resource limits for more detail
The maximum number of concurrent requests using git commands using the UI or REST services (e.g. git diff via the UI), which is configurable at throttle.resource.scm-command of stash-config.properties. Default value is 25.
The maximum number of concurrent requests using "hosting" commands (e.g. git clone, push, pull), which is configurable at throttle.resource.scm-hosting of stash-config.properties. Default value is 1.5*cpu (1.5 times the number of available cpus/cores).
You may need to know how long your Git commands take and the number of concurrent Git commands available, in order for resource tuning purposes.
Solution
The following steps will enable Bitbucket Server to log the timestamp and the number of concurrent Git commands available when a Git commands is start/finish executing:
Insert the following line into <configuration> tab block of <BBS_INSTALL_DIR>/atlassian-bitbucket/WEB-INF/classes/logback.xml (<STASH_INSTALL_DIR>/atlassian-stash/WEB-INF/classes/logback.xml for Stash)
1
<logger name="com.atlassian.stash.internal.throttle.SemaphoreThrottleService" level="TRACE"/>
Restart Bitbucket Server
You will see logs similar to this in <BBS_HOME_DIR>/log/atlassian-bitbucket.log (<STASH_HOME_DIR>/log/atlassian-stash.log for Stash)
1 2
2015-10-19 09:47:15,225 TRACE [http-nio-7990-exec-9] admin @1VAGN69x587x115x0 0:0:0:0:0:0:0:1 "POST /scm/proj/a-repository.git/git-receive-pack HTTP/1.1" c.a.s.i.t.SemaphoreThrottleService Acquired [scm-hosting] ticket (11/12) 2015-10-19 09:48:00,416 TRACE [http-nio-7990-exec-9] admin @1VAGN69x587x115x0 0:0:0:0:0:0:0:1 "POST /scm/proj/a-repository.git/git-receive-pack HTTP/1.1" c.a.s.i.t.SemaphoreThrottleService Released [scm-hosting] ticket (12/12)
In this example, the Git hosting command took 45 seconds (= 09:48:00 - 09:47:15) and 11 more Git hosting commands were available when the command was executed.
Was this helpful?