!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;
}
if (buf != bucket_buf) {
MarkBufferDirty(bucket_buf);
}
MarkBufferDirty(buf);
/* 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
* page
* page, except the primary bucket page
*/
if (retain_pin)
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
else
if (!retain_pin)
_hash_relbuf(rel, buf);
buf = next_buf;
}
/*
* 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
* lock on bucket page.
* Lock the bucket page to clear the garbage flag and squeeze the bucket.
* We already have lock on bucket page in the previous step, so release
* the overflow pages is enough.
*/
if (buf != bucket_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) {
action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &deletebuf);
} else {
/*
* we don't care for return value as the purpose of reading bucketbuf
* is to ensure a cleanup lock on primary bucket page.
*/
(void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
PageSetLSN(bucketbuf.pageinfo.page, lsn);
/* read bucketbuf for a cleanup lock on primary bucket page */
if (XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf) == BLK_NEEDS_REDO) {
PageSetLSN(bucketbuf.pageinfo.page, lsn);
MarkBufferDirty(bucketbuf.buf);
}
action = XLogReadBufferForRedo(record, 1, &deletebuf);
}

View File

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