mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Assert in init_toast_snapshot() that some snapshot registered or active.
Commit <FIXME> fixed the bug that RemoveTempRelationsCallback() did not push/register a snapshot. That only went unnoticed because often a valid catalog snapshot exists and is returned by GetOldestSnapshot(). But due to invalidation processing that is not reliable. Thus assert in init_toast_snapshot() that there is a registered or active snapshot, using the new HaveRegisteredOrActiveSnapshot(). Author: Andres Freund Discussion: https://postgr.es/m/20220219180002.6tubjq7iw7m52bgd@alap3.anarazel.de
This commit is contained in:
@@ -1625,6 +1625,32 @@ ThereAreNoPriorRegisteredSnapshots(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* HaveRegisteredOrActiveSnapshots
|
||||
* Is there any registered or active snapshot?
|
||||
*
|
||||
* NB: Unless pushed or active, the cached catalog snapshot will not cause
|
||||
* this function to return true. That allows this function to be used in
|
||||
* checks enforcing a longer-lived snapshot.
|
||||
*/
|
||||
bool
|
||||
HaveRegisteredOrActiveSnapshot(void)
|
||||
{
|
||||
if (ActiveSnapshot != NULL)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* The catalog snapshot is in RegisteredSnapshots when valid, but can be
|
||||
* removed at any time due to invalidation processing. If explicitly
|
||||
* registered more than one snapshot has to be in RegisteredSnapshots.
|
||||
*/
|
||||
if (pairingheap_is_empty(&RegisteredSnapshots) ||
|
||||
!pairingheap_is_singular(&RegisteredSnapshots))
|
||||
return false;
|
||||
|
||||
return CatalogSnapshot == NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a timestamp that is exactly on a minute boundary.
|
||||
|
||||
Reference in New Issue
Block a user