Skip to content

Commit 97ff2a5

Browse files
committed
Don't MultiXactIdIsRunning when in recovery
In 9.1 and earlier, it is possible for index_getnext() to try to examine a heap buffer for possible HOT-prune when in recovery; this causes a problem when a multixact is found in a tuple's Xmax, because GetMultiXactIdMembers refuses to run when in recovery, raising an error: ERROR: cannot GetMultiXactIdMembers() during recovery This can be solved easily by having MultiXactIdIsRunning always return false when in recovery, which is reasonable because a HOT standby cannot acquire further tuple locks nor update/delete tuples. (Note: it doesn't look like this specific code path has a problem in 9.2, because instead of doing HeapTupleSatisfiesUpdate directly, heap_hot_search_buffer uses HeapTupleIsSurelyDead instead. Still, there may be other paths affected by the same bug, for instance in pgrowlocks, and the multixact code hasn't changed; so apply the same fix throughout.) Apply this fix to 9.0 through 9.2. In 9.3 the multixact code has been changed completely and is no longer subject to this problem. Per report from Marko Tiikkaja, https://www.postgresql.org/message-id/[email protected] Analysis by Andres Freund
1 parent 520fecf commit 97ff2a5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/backend/access/transam/multixact.c

+15
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,21 @@ MultiXactIdIsRunning(MultiXactId multi)
382382

383383
debug_elog3(DEBUG2, "IsRunning %u?", multi);
384384

385+
/*
386+
* During recovery, all multixacts can be considered not running: in
387+
* effect, tuple locks are not held in standby servers, which is fine
388+
* because the standby cannot acquire further tuple locks nor update/delete
389+
* tuples.
390+
*
391+
* We need to do this first, because GetMultiXactIdMembers complains if
392+
* called on recovery.
393+
*/
394+
if (RecoveryInProgress())
395+
{
396+
debug_elog2(DEBUG2, "IsRunning: in recovery");
397+
return false;
398+
}
399+
385400
nmembers = GetMultiXactIdMembers(multi, &members);
386401

387402
if (nmembers < 0)

0 commit comments

Comments
 (0)