aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2023-11-13 14:08:26 +0530
committerAmit Kapila <akapila@postgresql.org>2023-11-13 14:08:26 +0530
commit861f86beea1c241943a3ef000e789f18bbc8b7e8 (patch)
tree5462f024e866ed91ad878321f8c4793c27f0ab35 /src/backend
parent7606175991f8ed5ae36eecf6951cb89dcfb2156e (diff)
downloadpostgresql-861f86beea1c241943a3ef000e789f18bbc8b7e8.tar.gz
postgresql-861f86beea1c241943a3ef000e789f18bbc8b7e8.zip
Use REGBUF_NO_CHANGE at one more place in the hash index.
Commit 00d7fb5e2e started to use REGBUF_NO_CHANGE at a few places in the code where we register the buffer before marking it dirty but missed updating one of the code flows in the hash index where we free the overflow page without any live tuples on it. Author: Amit Kapila and Hayato Kuroda Discussion: http://postgr.es/m/f045c8f7-ee24-ead6-3679-c04a43d21351@gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/hash/hash_xlog.c5
-rw-r--r--src/backend/access/hash/hashovfl.c19
2 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index e8e06c62a95..40debf40288 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -655,7 +655,10 @@ hash_xlog_squeeze_page(XLogReaderState *record)
*/
(void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
- action = XLogReadBufferForRedo(record, 1, &writebuf);
+ if (xldata->ntups > 0 || xldata->is_prev_bucket_same_wrt)
+ action = XLogReadBufferForRedo(record, 1, &writebuf);
+ else
+ action = BLK_NOTFOUND;
}
/* replay the record for adding entries in overflow buffer */
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index 9d1ff20b922..2bd4432265c 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -668,14 +668,31 @@ _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf,
XLogRegisterBuffer(0, bucketbuf, flags);
}
- XLogRegisterBuffer(1, wbuf, REGBUF_STANDARD);
if (xlrec.ntups > 0)
{
+ XLogRegisterBuffer(1, wbuf, REGBUF_STANDARD);
XLogRegisterBufData(1, (char *) itup_offsets,
nitups * sizeof(OffsetNumber));
for (i = 0; i < nitups; i++)
XLogRegisterBufData(1, (char *) itups[i], tups_size[i]);
}
+ else if (xlrec.is_prim_bucket_same_wrt || xlrec.is_prev_bucket_same_wrt)
+ {
+ uint8 wbuf_flags;
+
+ /*
+ * A write buffer needs to be registered even if no tuples are
+ * added to it to ensure that we can acquire a cleanup lock on it
+ * if it is the same as primary bucket buffer or update the
+ * nextblkno if it is same as the previous bucket buffer.
+ */
+ Assert(xlrec.ntups == 0);
+
+ wbuf_flags = REGBUF_STANDARD;
+ if (!xlrec.is_prev_bucket_same_wrt)
+ wbuf_flags |= REGBUF_NO_CHANGE;
+ XLogRegisterBuffer(1, wbuf, wbuf_flags);
+ }
XLogRegisterBuffer(2, ovflbuf, REGBUF_STANDARD);