!6657 【SS】修复stmt线程备机failover时的core问题
Merge pull request !6657 from 胡正超/master
This commit is contained in:
@ -147,7 +147,10 @@ static void CleanStbyStmtHistory();
|
||||
/* in standby, We record slow-sql and other queries separately, this is different from the primary. */
|
||||
static void StartStbyStmtHistory()
|
||||
{
|
||||
if (!(pmState == PM_HOT_STANDBY || SS_STANDBY_MODE) || STBYSTMTHIST_IS_READY) {
|
||||
if (STBYSTMTHIST_IS_READY) {
|
||||
return;
|
||||
}
|
||||
if (pmState != PM_HOT_STANDBY && !SS_STANDBY_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -192,7 +195,10 @@ static void ShutdownStbyStmtHistory()
|
||||
|
||||
static void AssignStbyStmtHistoryConf()
|
||||
{
|
||||
if (pmState != PM_HOT_STANDBY || !STBYSTMTHIST_IS_READY) {
|
||||
if (!STBYSTMTHIST_IS_READY) {
|
||||
return;
|
||||
}
|
||||
if (pmState != PM_HOT_STANDBY && !SS_STANDBY_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -210,7 +216,7 @@ static void AssignStbyStmtHistoryConf()
|
||||
|
||||
static void CleanStbyStmtHistory()
|
||||
{
|
||||
if (pmState != PM_HOT_STANDBY && STBYSTMTHIST_IS_READY) {
|
||||
if (STBYSTMTHIST_IS_READY && pmState != PM_HOT_STANDBY && !SS_STANDBY_MODE) {
|
||||
ShutdownStbyStmtHistory();
|
||||
return;
|
||||
}
|
||||
@ -736,7 +742,7 @@ static void StartCleanWorker(int* count)
|
||||
}
|
||||
|
||||
/* We do clean work by starting clean worker in primary mode, do it ourself in standby mode. */
|
||||
if (pmState == PM_RUN) {
|
||||
if (pmState == PM_RUN && (!ENABLE_DMS || SS_PRIMARY_MODE)) {
|
||||
if (g_instance.stat_cxt.instr_stmt_is_cleaning) {
|
||||
return;
|
||||
}
|
||||
@ -752,6 +758,7 @@ static void StartCleanWorker(int* count)
|
||||
|
||||
*count = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The statement_history table should be cleaned up twice
|
||||
* In the first time, all records less than minStatementTimestamp are cleared,
|
||||
@ -815,6 +822,11 @@ static void FlushStatementToTableOrMFChain(StatementStatContext* suspendList, co
|
||||
bool isSlow = false;
|
||||
MemFileChain* target = NULL;
|
||||
while (flushItem != NULL) {
|
||||
if (SS_IN_REFORM) {
|
||||
ereport(WARNING, (errmsg("Can not flush statement while ss in reform.")));
|
||||
break;
|
||||
}
|
||||
|
||||
tuple = GetStatementTuple(rel, flushItem, statementCxt, &isSlow);
|
||||
if (pmState == PM_HOT_STANDBY || SS_STANDBY_MODE) {
|
||||
/*
|
||||
|
||||
@ -8803,7 +8803,7 @@ static void PostmasterStateMachine(void)
|
||||
}
|
||||
|
||||
if (SS_IN_FAILOVER && !g_instance.dms_cxt.SSRecoveryInfo.no_backend_left) {
|
||||
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_AUTOVAC) == 0) {
|
||||
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_AUTOVAC) == 0 && g_instance.pid_cxt.StatementPID == 0) {
|
||||
g_instance.dms_cxt.SSRecoveryInfo.no_backend_left = true;
|
||||
}
|
||||
}
|
||||
@ -10725,9 +10725,14 @@ static void sigusr1_handler(SIGNAL_ARGS)
|
||||
}
|
||||
/* shut down all backends and autovac workers */
|
||||
(void)SignalSomeChildren(SIGTERM, BACKEND_TYPE_NORMAL | BACKEND_TYPE_AUTOVAC);
|
||||
|
||||
/* statement flush thread alse involves reading page */
|
||||
if (g_instance.pid_cxt.StatementPID != 0)
|
||||
signal_child(g_instance.pid_cxt.StatementPID, SIGTERM);
|
||||
|
||||
//active check once
|
||||
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_AUTOVAC) == 0) {
|
||||
if (CountChildren(BACKEND_TYPE_NORMAL | BACKEND_TYPE_AUTOVAC) == 0 &&
|
||||
g_instance.pid_cxt.StatementPID == 0) {
|
||||
g_instance.dms_cxt.SSRecoveryInfo.no_backend_left = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user