!1344 修复归档槽的bug

Merge pull request !1344 from Cross-罗/my_new_2
This commit is contained in:
opengauss-bot 2021-11-08 07:24:14 +00:00 committed by Gitee
commit 2e6a0bd5e6
2 changed files with 13 additions and 3 deletions

View File

@ -1260,7 +1260,7 @@ static void SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
SpinLockRelease(&slot->mutex);
COMP_CRC32C(cp.checksum, (char *)(&cp) + ReplicationSlotOnDiskConstantSize, ReplicationSlotOnDiskDynamicSize);
if (GET_SLOT_EXTRA_DATA_LENGTH(cp.slotdata) > 0) {
if (slot->extra_content && strlen(slot->extra_content) != 0 && GET_SLOT_EXTRA_DATA_LENGTH(cp.slotdata) > 0) {
COMP_CRC32C(cp.checksum, slot->extra_content, GET_SLOT_EXTRA_DATA_LENGTH(cp.slotdata));
}
FIN_CRC32C(cp.checksum);

View File

@ -86,6 +86,10 @@ void log_slot_advance(const ReplicationSlotPersistentData *slotInfo)
XLogBeginInsert();
XLogRegisterData((char *)&xlrec, ReplicationSlotPersistentDataConstSize);
char* extra_content = t_thrd.slot_cxt.MyReplicationSlot->extra_content;
if (extra_content != NULL && strlen(extra_content) != 0) {
XLogRegisterData(extra_content, strlen(extra_content) + 1);
}
Ptr = XLogInsert(RM_SLOT_ID, XLOG_SLOT_ADVANCE);
XLogWaitFlush(Ptr);
@ -969,8 +973,14 @@ void slot_redo(XLogReaderState *record)
case XLOG_SLOT_ADVANCE:
if (ReplicationSlotFind(xlrec->name.data))
redo_slot_advance(xlrec);
else
redo_slot_create(xlrec);
else {
char* extra_content = NULL;
if (GET_SLOT_EXTRA_DATA_LENGTH(*xlrec) != 0) {
extra_content = (char*)XLogRecGetData(record) + ReplicationSlotPersistentDataConstSize;
Assert(strlen(extra_content) == (uint32)(GET_SLOT_EXTRA_DATA_LENGTH(*xlrec)));
}
redo_slot_create(xlrec, extra_content);
}
break;
case XLOG_SLOT_DROP:
if (ReplicationSlotFind(xlrec->name.data))