提交 d5ee49ac 编写于 作者: P Pengzhou Tang 提交者: Tang Pengzhou

Use am_ftsprobe to determine the DNSLookupAsError

Fts probe didn't report an error if it failed to resolve the DNS, so fts probe
can mark those segments as down. Previously, DNSLookupAsError was only set to
false in readCdbComponentInfoAndUpdateStatus(), however, codes keep coming and
evolving, fts probe may set DNSLookupAsError to true in other code paths.

To avoiding fts probe report a DNS error unexpectedly, use am_ftsprobe only to
determine it and hide the DNSLookupAsError from callers.
上级 0ddd60eb
......@@ -71,7 +71,7 @@ gp_pgdatabase__(PG_FUNCTION_ARGS)
mystatus = (Working_State *) palloc(sizeof(Working_State));
funcctx->user_fctx = (void *) mystatus;
mystatus->cdb_component_dbs = cdbcomponent_getCdbComponents(true);
mystatus->cdb_component_dbs = cdbcomponent_getCdbComponents();
mystatus->currIdx = 0;
MemoryContextSwitchTo(oldcontext);
......
......@@ -67,7 +67,7 @@ static CdbComponentDatabases *cdb_component_dbs = NULL;
/*
* Helper Functions
*/
static CdbComponentDatabases *getCdbComponentInfo(bool DnsLookupFailureIsError);
static CdbComponentDatabases *getCdbComponentInfo(void);
static void cleanupComponentIdleQEs(CdbComponentDatabaseInfo *cdi, bool includeWriter);
static int CdbComponentDatabaseInfoCompare(const void *p1, const void *p2);
......@@ -97,7 +97,7 @@ typedef struct HostSegsEntry
* Internal function to initialize each component info
*/
static CdbComponentDatabases *
getCdbComponentInfo(bool DNSLookupAsError)
getCdbComponentInfo(void)
{
MemoryContext oldContext;
CdbComponentDatabaseInfo *pOld = NULL;
......@@ -138,6 +138,7 @@ getCdbComponentInfo(bool DNSLookupAsError)
bool found;
HostSegsEntry *hsEntry;
bool DNSLookupAsError = !am_ftsprobe;
if (!CdbComponentsContext)
CdbComponentsContext = AllocSetContextCreate(TopMemoryContext, "cdb components Context",
......@@ -553,7 +554,7 @@ cdbcomponent_updateCdbComponents(void)
{
if (cdb_component_dbs == NULL)
{
cdb_component_dbs = getCdbComponentInfo(true);
cdb_component_dbs = getCdbComponentInfo();
cdb_component_dbs->fts_version = ftsVersion;
cdb_component_dbs->expand_version = GetGpExpandVersion();
}
......@@ -571,7 +572,7 @@ cdbcomponent_updateCdbComponents(void)
{
ELOG_DISPATCHER_DEBUG("FTS rescanned, get new component databases info.");
cdbcomponent_destroyCdbComponents();
cdb_component_dbs = getCdbComponentInfo(true);
cdb_component_dbs = getCdbComponentInfo();
cdb_component_dbs->fts_version = ftsVersion;
cdb_component_dbs->expand_version = expandVersion;
}
......@@ -596,13 +597,13 @@ cdbcomponent_updateCdbComponents(void)
* structures are allocated from the caller's context.
*/
CdbComponentDatabases *
cdbcomponent_getCdbComponents(bool DNSLookupAsError)
cdbcomponent_getCdbComponents()
{
PG_TRY();
{
if (cdb_component_dbs == NULL)
{
cdb_component_dbs = getCdbComponentInfo(DNSLookupAsError);
cdb_component_dbs = getCdbComponentInfo();
cdb_component_dbs->fts_version = getFtsVersion();
cdb_component_dbs->expand_version = GetGpExpandVersion();
}
......@@ -846,7 +847,7 @@ cdbcomponent_getComponentInfo(int contentId)
CdbComponentDatabaseInfo *cdbInfo = NULL;
CdbComponentDatabases *cdbs;
cdbs = cdbcomponent_getCdbComponents(true);
cdbs = cdbcomponent_getCdbComponents();
if (contentId < -1 || contentId >= cdbs->total_segments)
ereport(FATAL,
......@@ -1516,7 +1517,7 @@ cdbcomponent_getCdbComponentsList(void)
List *segments = NIL;
int i;
cdbs = cdbcomponent_getCdbComponents(true);
cdbs = cdbcomponent_getCdbComponents();
for (i = 0; i < cdbs->total_segments; i++)
{
......@@ -1537,7 +1538,7 @@ getgpsegmentCount(void)
int32 numsegments = 1;
if (Gp_role == GP_ROLE_DISPATCH)
numsegments = cdbcomponent_getCdbComponents(true)->total_segments;
numsegments = cdbcomponent_getCdbComponents()->total_segments;
else if (Gp_role == GP_ROLE_EXECUTE)
numsegments = numsegmentsFromQD;
/*
......@@ -1552,7 +1553,7 @@ getgpsegmentCount(void)
IsBinaryUpgrade &&
IS_QUERY_DISPATCHER())
{
numsegments = cdbcomponent_getCdbComponents(true)->total_segments;
numsegments = cdbcomponent_getCdbComponents()->total_segments;
}
return numsegments;
......
......@@ -1485,7 +1485,7 @@ formIdleSegmentIdList(void)
List *segments = NIL;
int i, j;
cdbs = cdbcomponent_getCdbComponents(true);
cdbs = cdbcomponent_getCdbComponents();
if (cdbs->segment_db_info != NULL)
{
......
......@@ -348,7 +348,7 @@ static
CdbComponentDatabases *readCdbComponentInfoAndUpdateStatus(MemoryContext probeContext)
{
int i;
CdbComponentDatabases *cdbs = cdbcomponent_getCdbComponents(false);
CdbComponentDatabases *cdbs = cdbcomponent_getCdbComponents();
for (i=0; i < cdbs->total_segment_dbs; i++)
{
......
......@@ -2661,7 +2661,7 @@ gpdb::GetComponentDatabases(void)
GP_WRAP_START;
{
/* catalog tables: gp_segment_config */
return cdbcomponent_getCdbComponents(true);
return cdbcomponent_getCdbComponents();
}
GP_WRAP_END;
return NULL;
......
......@@ -1499,7 +1499,7 @@ create_external_scan_uri_list(ExtTableEntry *ext, bool *ismasteronly)
}
/* get the total valid primary segdb count */
db_info = cdbcomponent_getCdbComponents(true);
db_info = cdbcomponent_getCdbComponents();
total_primaries = 0;
for (i = 0; i < db_info->total_segment_dbs; i++)
{
......
......@@ -154,7 +154,7 @@ gp_expand_protect_catalog_changes(Relation relation)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("gpexpand in progress, catalog changes are disallowed.")));
oldVersion = cdbcomponent_getCdbComponents(true)->expand_version;
oldVersion = cdbcomponent_getCdbComponents()->expand_version;
newVersion = GetGpExpandVersion();
if (oldVersion != newVersion)
ereport(FATAL,
......
......@@ -140,7 +140,7 @@ extern void cdb_cleanup(int code, Datum arg __attribute__((unused)) );
* The same is true for pointer-based values in CdbComponentDatabaseInfo. The caller is responsible
* for setting the current storage context and releasing the storage occupied the returned values.
*/
CdbComponentDatabases * cdbcomponent_getCdbComponents(bool DNSLookupAsError);
CdbComponentDatabases * cdbcomponent_getCdbComponents(void);
void cdbcomponent_destroyCdbComponents(void);
void cdbcomponent_updateCdbComponents(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册