【bugfix】 尝试修复failover时,两阶段事务卡住的问题
This commit is contained in:
@ -1033,6 +1033,8 @@ bool SSCanFetchLocalSnapshotTxnRelatedInfo()
|
||||
bool snap_available = xmin_info->snapshot_available;
|
||||
SpinLockRelease(&xmin_info->snapshot_available_lock);
|
||||
return snap_available;
|
||||
} else if (SS_STANDBY_FAILOVER && t_thrd.role == STARTUP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -127,6 +127,7 @@
|
||||
#endif
|
||||
#include "instruments/instr_statement.h"
|
||||
#include "storage/file/fio_device.h"
|
||||
#include "ddes/dms/ss_reform_common.h"
|
||||
|
||||
/*
|
||||
* Directory where Two-phase commit files reside within PGDATA
|
||||
@ -2182,7 +2183,12 @@ static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
|
||||
char *errormsg = NULL;
|
||||
errno_t rc = 0;
|
||||
|
||||
xlogreader = XLogReaderAllocate(&read_local_xlog_page, NULL);
|
||||
if (ENABLE_DMS) {
|
||||
xlogreader = SSXLogReaderAllocate(&read_local_xlog_page, NULL, ALIGNOF_BUFFER);
|
||||
} else {
|
||||
xlogreader = XLogReaderAllocate(&read_local_xlog_page, NULL);
|
||||
}
|
||||
|
||||
if (xlogreader == NULL) {
|
||||
ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"),
|
||||
errdetail("Failed while allocating an XLog reading processor.")));
|
||||
|
||||
@ -1644,10 +1644,18 @@ static void XLogRead(char *buf, TimeLineID tli, XLogRecPtr startptr, Size count)
|
||||
|
||||
XLByteToSeg(recptr, t_thrd.xlog_cxt.sendSegNo);
|
||||
|
||||
errorno = snprintf_s(path, MAXPGPATH, MAXPGPATH - 1, "%s/%08X%08X%08X", SS_XLOGDIR, tli,
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) / XLogSegmentsPerXLogId),
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) % XLogSegmentsPerXLogId));
|
||||
securec_check_ss(errorno, "", "");
|
||||
/* in shard storage mode, read xlog from recovery_xlog_dir during recovery */
|
||||
if (SS_STANDBY_FAILOVER) {
|
||||
errorno = snprintf_s(path, MAXPGPATH, MAXPGPATH - 1, "%s/%08X%08X%08X", g_instance.dms_cxt.SSRecoveryInfo.recovery_xlog_dir, tli,
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) / XLogSegmentsPerXLogId),
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) % XLogSegmentsPerXLogId));
|
||||
securec_check_ss(errorno, "", "");
|
||||
} else {
|
||||
errorno = snprintf_s(path, MAXPGPATH, MAXPGPATH - 1, "%s/%08X%08X%08X", SS_XLOGDIR, tli,
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) / XLogSegmentsPerXLogId),
|
||||
(uint32)((t_thrd.xlog_cxt.sendSegNo) % XLogSegmentsPerXLogId));
|
||||
securec_check_ss(errorno, "", "");
|
||||
}
|
||||
|
||||
t_thrd.xlog_cxt.sendFile = BasicOpenFile(path, O_RDONLY | PG_BINARY, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user