postgres.git / summary / log / commit / refs
commit fbbc48995d056d54a7feb701a77707a6202b267a
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Thu Jun 24 08:19:03 2021 +0000
First released in: 14.0, 9.6.23, 10.18, 11.13, 12.8, 13.4
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
src/backend/utils/cache/relmapper.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index e837c409e4c..5ff8dfd1143 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -948,12 +948,13 @@ relmap_redo(XLogReaderState *record)
* preserve files, either.
*
* There shouldn't be anyone else updating relmaps during WAL replay,
- * so we don't bother to take the RelationMappingLock. We would need
- * to do so if load_relmap_file needed to interlock against writers.
+ * but grab the lock to interlock against load_relmap_file().
*/
+ LWLockAcquire(RelationMappingLock, LW_EXCLUSIVE);
write_relmap_file((xlrec->dbid == InvalidOid), &newmap,
false, true, false,
xlrec->dbid, xlrec->tsid, dbpath);
+ LWLockRelease(RelationMappingLock);
pfree(dbpath);
}
[parent: a5eacd86b715]