"System service user does not exist" error in Bitbucket Data Center
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
When starting up Bitbucket Data Center, you may encounter the error "System service user does not exist". This issue occurs when the service user is not successfully created by the Bitbucket database during the upgrade on the sta_service_user
table.
Environment
Tested on Bitbucket Data Center 7.7+
Applies to Bitbucket Data Center 8.x
Diagnosis
We would see the below stack trace in the <Bitbucket-home>/log/atlassian-bitbucket.log
file:
1
2
3
4
5
6
7
8
9
10
11
12
2023-03-17 08:16:55,299 ERROR [AtlassianEvent::thread-7] user1 *XDI1E2x496x616830x1 yxddxt 3.xxx.xxx.xx "POST /rest/api/latest/projects/TEST/repos/test/pull-requests HTTP/1.1" c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.stash.internal.pull.AnalyticsPullRequestOpenedEvent[source=com.atlassian.stash.internal.pull.DefaultPullRequestService@595df7bb]' for the invoker 'com.atlassian.event.internal.ComparableListenerInvoker@1ed585a1'
java.lang.RuntimeException: System service user does not exist.. Listener: com.atlassian.bitbucket.internal.defaulttasks.service.DefaultRequiredTaskService event: com.atlassian.stash.internal.pull.AnalyticsPullRequestOpenedEvent
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:53)
at com.atlassian.stash.internal.event.EventThreadFactory.lambda$createThread$0(EventThreadFactory.java:35)
at java.base/java.lang.Thread.run(Thread.java:829)
... 1 frame trimmed
Caused by: java.lang.IllegalStateException: System service user does not exist.
at com.atlassian.stash.internal.user.DefaultUserService.getSystemServiceUser(DefaultUserService.java:300)
at jdk.internal.reflect.GeneratedMethodAccessor3491.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:42)
... 10 common frames omitted
Cause
Starting from Bitbucket 7.7.x, a System upgrade task runs on startup to check if the system user has already been created. If not, it creates the user on the sta_service_user
table. However, during the upgrade from Bitbucket 7.6 or earlier to 7.7, the core-system-user
file is sometimes created under the "<BITBUCKET_SHARED>/config/upgrades"
directory, but the system user itself is not actually created in the database. This leaves the system in a state where Bitbucket does not run the upgrade task because it already has the core-system-user
file on the file system, but the user itself is not in the database. Whenever Bitbucket starts up, it tries to perform the Autodecline job to decline older pull requests, which is done using the system user. When Bitbucket tries to do that, it reports that the system user is missing. This issue can also be noticed when creating the Default Tasks option on pull requests. These default tasks are also created using the system user, so if the system service user is not found, it throws an error.
There is also an open bug to fix this issue BSERV-13728 - System service user does not exist error on Bitbucket Server logs.
Solution
To fix this issue, you need to create the system service user.
To do so, remove the
core-system-user
file from the "<BITBUCKET_SHARED>/config/upgrades"
directory and restart the Bitbucket service.As Bitbucket starts up, it will look for the
core-system-user
file, and since it is not found, it will attempt to create the system service user in the database. The error should no longer occur.To check if the system service user has been created, you can look for the following log entry in the
<Bitbucket-home>/log/
atlassian-bitbucket.log
file:
1
2023-03-20 14:18:23,438 INFO [spring-startup] c.a.s.i.u.u.CreateSystemUserUpgradeTask Successfully created system service user
Was this helpful?