Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9693f19

Browse files
author
Amit Kapila
committed
Fix cleanup lock acquisition in SPLIT_ALLOCATE_PAGE replay.
During XLOG_HASH_SPLIT_ALLOCATE_PAGE replay, we were checking for acleanup lock on the new bucket page after acquiring an exclusive lock onit and raising a PANIC error on failure. However, it is quite possiblethat checkpointer can acquire the pin on the same page before acquiring alock on it, and then the replay will lead to an error. So instead, directlyacquire the cleanup lock on the new bucket page duringXLOG_HASH_SPLIT_ALLOCATE_PAGE replay operation.Reported-by: Andres FreundAuthor: Robert HaasReviewed-By: Amit Kapila, Andres Freund, Vignesh CBackpatch-through: 11Discussion:https://postgr.es/m/20220810022617.fvjkjiauaykwrbse@awork3.anarazel.de
1 parentf893af4 commit9693f19

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

‎src/backend/access/hash/hash_xlog.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,10 @@ hash_xlog_split_allocate_page(XLogReaderState *record)
352352
}
353353

354354
/* replay the record for new bucket */
355-
newbuf=XLogInitBufferForRedo(record,1);
355+
XLogReadBufferForRedoExtended(record,1,RBM_ZERO_AND_CLEANUP_LOCK, true,
356+
&newbuf);
356357
_hash_initbuf(newbuf,xlrec->new_bucket,xlrec->new_bucket,
357358
xlrec->new_bucket_flag, true);
358-
if (!IsBufferCleanupOK(newbuf))
359-
elog(PANIC,"hash_xlog_split_allocate_page: failed to acquire cleanup lock");
360359
MarkBufferDirty(newbuf);
361360
PageSetLSN(BufferGetPage(newbuf),lsn);
362361

‎src/backend/access/hash/hashpage.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,13 @@ _hash_expandtable(Relation rel, Buffer metabuf)
804804
/*
805805
* Physically allocate the new bucket's primary page. We want to do this
806806
* before changing the metapage's mapping info, in case we can't get the
807-
* disk space. Ideally, we don't need to check for cleanup lock on new
808-
* bucket as no other backend could find this bucket unless meta page is
809-
* updated. However, it is good to be consistent with old bucket locking.
807+
* disk space.
808+
*
809+
* XXX It doesn't make sense to call _hash_getnewbuf first, zeroing the
810+
* buffer, and then only afterwards check whether we have a cleanup lock.
811+
* However, since no scan can be accessing the buffer yet, any concurrent
812+
* accesses will just be from processes like the bgwriter or checkpointer
813+
* which don't care about its contents, so it doesn't really matter.
810814
*/
811815
buf_nblkno=_hash_getnewbuf(rel,start_nblkno,MAIN_FORKNUM);
812816
if (!IsBufferCleanupOK(buf_nblkno))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp