大网数据广告活动
服务器运维问答

TeamCity upgrade fails with "Can't take exclusive lock when db lock is not held"

· 52CE 我爱测

When upgrading to TeamCity 2023.05 (using the Docker image), I received the error "Can't take exclusive lock when db lock is not held" and the detailed instruction: <pre>java.lang.IllegalStateException: Can't take an exclusive lo…

问题原文

原帖链接 · vpetersson · CC BY-SA 4.0

When upgrading to TeamCity 2023.05 (using the Docker image), I received the error "Can't take exclusive lock when db lock is not held" and the detailed instruction:


<pre>java.lang.IllegalStateException: Can't take an exclusive lock when db lock is not held
    at jetbrains.buildServer.serverSide.db.Heartbeat.tryGetExclusiveLock(Heartbeat.java:726)
    at jetbrains.buildServer.serverSide.db.TeamCityDatabaseManager.tryGetExclusiveLock(TeamCityDatabaseManager.java:857)
    at jetbrains.buildServer.maintenance.StartupProcessor.lockDatabaseExclusively(StartupProcessor.java:860)
    at jetbrains.buildServer.maintenance.StartupProcessor.doUpgradeRequired(StartupProcessor.java:773)
    at jetbrains.buildServer.maintenance.StartupProcessor.checkUpgradeRequired(StartupProcessor.java:826)
    at jetbrains.buildServer.maintenance.StartupProcessor.doDatabaseChecking(StartupProcessor.java:1377)
    at jetbrains.buildServer.maintenance.StartupProcessor.access$1000(StartupProcessor.java:1410)
    at jetbrains.buildServer.maintenance.StartupProcessor$3.call(StartupProcessor.java:12)
    at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:91)
    at jetbrains.buildServer.maintenance.StartupProcessor.processConcreteStage(StartupProcessor.java:779)
    at jetbrains.buildServer.maintenance.StartupProcessor.processConcreteStageSafe(StartupProcessor.java:1165)
    at jetbrains.buildServer.maintenance.StartupProcessor.processTeamCityLifecycle(StartupProcessor.java:1100)
    at jetbrains.buildServer.maintenance.StartupProcessor.access$000(StartupProcessor.java:1120)
    at jetbrains.buildServer.maintenance.StartupProcessor$1.run(StartupProcessor.java:3)
    at java.base/java.lang.Thread.run(Thread.java:833)
</pre>

I spent a lot of time trying to get to the bottom of this, as I initially thought it was something wrong with the actual database, but could not find any locks.

已采纳解答

原帖链接 · vpetersson · CC BY-SA 4.0

The solution was to drop the records in the db_heartbeat table in the teamcity database.

Check if there are any records:

select * from db_heartbeat;
[...]

Remove all records:

TRUNCATE TABLE db_heartbeat;

Verify that they were dropped:

select * from db_heartbeat;
[...]

Once done, you should be able to restart TeamCity and redo the migration.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-06-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。