Skip to content

Commit eb3bd24

Browse files
committed
Another fix to relmapper race condition.
In previous commit, I missed that relmap_redo() was also not acquiring the RelationMappingLock. Thanks to Thomas Munro for pointing that out. Backpatch-through: 9.6, like previous commit. Discussion: https://www.postgresql.org/message-id/CA%2BhUKGLev%3DPpOSaL3WRZgOvgk217et%2BbxeJcRr4eR-NttP1F6Q%40mail.gmail.com
1 parent c78bb32 commit eb3bd24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/utils/cache/relmapper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,12 +949,13 @@ relmap_redo(XLogReaderState *record)
949949
* preserve files, either.
950950
*
951951
* There shouldn't be anyone else updating relmaps during WAL replay,
952-
* so we don't bother to take the RelationMappingLock. We would need
953-
* to do so if load_relmap_file needed to interlock against writers.
952+
* but grab the lock to interlock against load_relmap_file().
954953
*/
954+
LWLockAcquire(RelationMappingLock, LW_EXCLUSIVE);
955955
write_relmap_file((xlrec->dbid == InvalidOid), &newmap,
956956
false, true, false,
957957
xlrec->dbid, xlrec->tsid, dbpath);
958+
LWLockRelease(RelationMappingLock);
958959

959960
pfree(dbpath);
960961
}

0 commit comments

Comments
 (0)