Skip to content

Commit 7aec84e

Browse files
committed
Release lock after encountering bogs row in vac_truncate_clog()
When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session / autovacuum worker hangs in an uncancellable way. Similarly, other sessions will hang waiting for the lock. However, if the backend holding the lock exited or errored out for some reason, the lock was released. The bug was introduced as a side effect of 566372b. It is interesting that there are no production reports of this problem. That is likely due to a mix of bugs leading to bogus values having gotten less common, process exit releasing locks and instances of hangs being hard to debug for "normal" users. Discussion: https://postgr.es/m/20230621221208.vhsqgduwfpzwxnpg@awork3.anarazel.de
1 parent 8d8f371 commit 7aec84e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/commands/vacuum.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,12 +1590,16 @@ vac_truncate_clog(TransactionId frozenXID,
15901590
ereport(WARNING,
15911591
(errmsg("some databases have not been vacuumed in over 2 billion transactions"),
15921592
errdetail("You might have already suffered transaction-wraparound data loss.")));
1593+
LWLockRelease(WrapLimitsVacuumLock);
15931594
return;
15941595
}
15951596

15961597
/* chicken out if data is bogus in any other way */
15971598
if (bogus)
1599+
{
1600+
LWLockRelease(WrapLimitsVacuumLock);
15981601
return;
1602+
}
15991603

16001604
/*
16011605
* Advance the oldest value for commit timestamps before truncating, so

0 commit comments

Comments
 (0)