fix switchover hang during getting CSN

This commit is contained in:
bowenliu
2022-12-13 23:00:49 +08:00
parent 25eba6cc8e
commit e1da7bcc48

View File

@ -117,6 +117,10 @@ CommitSeqNo SSTransactionIdGetCommitSeqNo(TransactionId transactionId, bool isCo
dms_txn_info.snapshotxmin = InvalidTransactionId;
}
if (SS_IN_REFORM && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SSTransactionIdGetCommitSeqNo failed during reform, xid=%lu.", transactionId)));
}
do {
if (SSTransactionIdGetCSN(&dms_txn_info, &xid_csn_result) == DMS_SUCCESS) {
csn = xid_csn_result.csn;
@ -132,9 +136,10 @@ CommitSeqNo SSTransactionIdGetCommitSeqNo(TransactionId transactionId, bool isCo
} else {
ereport(DEBUG1, (errmsg("SS get txn info success, snapshot is NULL")));
}
break;
} else {
if (SS_IN_FAILOVER && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SS get CSN by TransactionId failed during failover, xid=%lu", transactionId)));
if (SS_IN_REFORM && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SSTransactionIdGetCommitSeqNo failed during reform, xid=%lu.", transactionId)));
}
pg_usleep(USECS_PER_SEC);
continue;
@ -196,6 +201,9 @@ bool SSTransactionIdDidCommit(TransactionId transactionId)
transactionId, did_commit)));
break;
} else {
if (SS_IN_REFORM && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SSTransactionIdDidCommit failed during reform, xid=%lu.", transactionId)));
}
pg_usleep(USECS_PER_SEC);
continue;
}
@ -229,6 +237,9 @@ bool SSTransactionIdIsInProgress(TransactionId transactionId)
transactionId, in_progress)));
break;
} else {
if (SS_IN_REFORM && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SSTransactionIdIsInProgress failed during reform, xid=%lu.", transactionId)));
}
pg_usleep(USECS_PER_SEC);
continue;
}
@ -251,6 +262,9 @@ TransactionId SSMultiXactIdGetUpdateXid(TransactionId xmax, uint16 t_infomask, u
ereport(DEBUG1, (errmsg("SS get update xid success, multixact xid=%lu, uxid=%lu.", xmax, update_xid)));
break;
} else {
if (SS_IN_REFORM && (t_thrd.role == WORKER || t_thrd.role == THREADPOOL_WORKER)) {
ereport(FATAL, (errmsg("SSMultiXactIdGetUpdateXid failed during reform, xid=%lu.", xmax)));
}
pg_usleep(USECS_PER_SEC);
continue;
}