提交 49a50cfe 编写于 作者: G Gang Xiong

Improve retry logic of create gang.

When create gang failed and all segment DB are alive,
we could retry when any of the following conditions is met:
1) This is the writer gang.
2) This is the first reader gang and the writer gang is healthy.
3) All failed connections are due to segment recovery.
上级 5b61b15a
......@@ -135,6 +135,7 @@ static CdbComponentDatabaseInfo *findDatabaseInfoBySegIndex(
CdbComponentDatabases *cdbs, int segIndex);
static void addGangToAllocated(Gang *gp);
static Gang *getAvailableGang(GangType type, int size, int content);
static bool readerGangsExist(void);
/*
* Create a reader gang.
......@@ -466,27 +467,26 @@ create_gang_retry:
goto exit;
}
disconnectAndDestroyGang(newGangDefinition);
newGangDefinition = NULL;
/* Writer gang is created before reader gangs. */
if (type == GANGTYPE_PRIMARY_WRITER)
Insist(!gangsExist());
/* We could do some retry here */
if (successful_connections + in_recovery_mode_count == size &&
gp_gang_creation_retry_count &&
create_gang_retry_counter++ < gp_gang_creation_retry_count)
/*
* Retry when any of the following condition is met:
* 1) This is the writer gang.
* 2) This is the first reader gang.
* 3) All failed segments are in recovery mode.
*/
if(gp_gang_creation_retry_count &&
create_gang_retry_counter++ < gp_gang_creation_retry_count &&
(type == GANGTYPE_PRIMARY_WRITER ||
!readerGangsExist() ||
successful_connections + in_recovery_mode_count == size))
{
LOG_GANG_DEBUG(LOG, "createGang: gang creation failed, but retryable.");
disconnectAndDestroyGang(newGangDefinition);
newGangDefinition = NULL;
/*
* On the first retry, we want to verify that we are
* using the most current version of the
* configuration.
*/
if (create_gang_retry_counter == 0)
FtsNotifyProber();
LOG_GANG_DEBUG(LOG, "createGang: gang creation failed, but retryable.");
CHECK_FOR_INTERRUPTS();
pg_usleep(gp_gang_creation_retry_timer * 1000);
......@@ -2209,6 +2209,14 @@ bool gangsExist(void)
availableReaderGangs1 != NIL);
}
static bool readerGangsExist(void)
{
return (allocatedReaderGangsN != NIL ||
availableReaderGangsN != NIL ||
allocatedReaderGangs1 != NIL||
availableReaderGangs1 != NIL);
}
int largestGangsize(void)
{
return largest_gangsize;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册