fix archive slot could not flush lsn

Offering: openGaussDev

More detail: Modify slot advance part

Match-id-3060b2f1218e72eb5ffc28d1742fbc15360ef534
This commit is contained in:
openGaussDev 2022-03-08 12:10:28 +08:00 committed by yanghao
parent 704eed3368
commit 1062a1c1f6
1 changed files with 5 additions and 1 deletions

View File

@ -2172,18 +2172,22 @@ void AdvanceArchiveSlot(XLogRecPtr restart_pos)
ReplicationSlot *slot = &t_thrd.slot_cxt.ReplicationSlotCtl->replication_slots[*slot_idx];
SpinLockAcquire(&slot->mutex);
if (slot->in_use == true && slot->archive_config != NULL) {
t_thrd.slot_cxt.MyReplicationSlot = slot;
slot->data.restart_lsn = restart_pos;
extra_content = slot->extra_content;
SpinLockRelease(&slot->mutex);
} else {
SpinLockRelease(&slot->mutex);
ereport(WARNING,
(errcode_for_file_access(), errmsg("slot idx not valid, obs slot %X/%X not advance ",
(uint32)(restart_pos >> 32), (uint32)(restart_pos))));
}
SpinLockRelease(&slot->mutex);
if (extra_content == NULL) {
ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("archive thread could not get slot extra content when advance slot.")));
}
ReplicationSlotMarkDirty();
log_slot_advance(&slot->data, extra_content);
}
}