!1789 修复hash index回放时未判断返回值引发的core问题

Merge pull request !1789 from 陈栋/hash_bugfix
This commit is contained in:
opengauss-bot
2022-06-07 13:41:24 +00:00
committed by Gitee
3 changed files with 17 additions and 16 deletions

View File

@ -827,6 +827,9 @@ void hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
clear_dead_marking = true; clear_dead_marking = true;
} }
if (buf != bucket_buf) {
MarkBufferDirty(bucket_buf);
}
MarkBufferDirty(buf); MarkBufferDirty(buf);
/* XLOG stuff */ /* XLOG stuff */
@ -871,24 +874,21 @@ void hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
/* /*
* release the lock on previous page after acquiring the lock on next * release the lock on previous page after acquiring the lock on next
* page * page, except the primary bucket page
*/ */
if (retain_pin) if (!retain_pin)
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
else
_hash_relbuf(rel, buf); _hash_relbuf(rel, buf);
buf = next_buf; buf = next_buf;
} }
/* /*
* lock the bucket page to clear the garbage flag and squeeze the bucket. * Lock the bucket page to clear the garbage flag and squeeze the bucket.
* if the current buffer is same as bucket buffer, then we already have * We already have lock on bucket page in the previous step, so release
* lock on bucket page. * the overflow pages is enough.
*/ */
if (buf != bucket_buf) { if (buf != bucket_buf) {
_hash_relbuf(rel, buf); _hash_relbuf(rel, buf);
LockBuffer(bucket_buf, BUFFER_LOCK_EXCLUSIVE);
} }
/* /*

View File

@ -545,13 +545,11 @@ static void hash_xlog_delete(XLogReaderState *record)
if (xldata->is_primary_bucket_page) { if (xldata->is_primary_bucket_page) {
action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &deletebuf); action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &deletebuf);
} else { } else {
/* /* read bucketbuf for a cleanup lock on primary bucket page */
* we don't care for return value as the purpose of reading bucketbuf if (XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf) == BLK_NEEDS_REDO) {
* is to ensure a cleanup lock on primary bucket page. PageSetLSN(bucketbuf.pageinfo.page, lsn);
*/ MarkBufferDirty(bucketbuf.buf);
(void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf); }
PageSetLSN(bucketbuf.pageinfo.page, lsn);
action = XLogReadBufferForRedo(record, 1, &deletebuf); action = XLogReadBufferForRedo(record, 1, &deletebuf);
} }

View File

@ -1244,7 +1244,10 @@ static void HashXlogDeleteBlock(XLogBlockHead *blockhead, XLogBlockDataParse *bl
MakeRedoBufferDirty(bufferinfo); MakeRedoBufferDirty(bufferinfo);
} }
} else { } else {
PageSetLSN(bufferinfo->pageinfo.page, bufferinfo->lsn); if (action == BLK_NEEDS_REDO) {
PageSetLSN(bufferinfo->pageinfo.page, bufferinfo->lsn);
MakeRedoBufferDirty(bufferinfo);
}
} }
} }