升级到 TeamCity 2023.05(使用 Docker 映像)时,我收到错误“Can't take Exclusive lock when db lock is notheld”,详细说明如下:
<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>
我花了很多时间试图弄清楚这一点,因为我最初认为实际数据库出了问题,但找不到任何锁。
db_heartbeat
解决方案是删除teamcity 数据库中表中的记录。检查是否有记录:
删除所有记录:
验证它们是否已被丢弃:
完成后,您应该能够重新启动 TeamCity 并重做迁移。