@@ -92,6 +92,7 @@ static int CdbComponentDatabaseInfoCompare(const void *p1, const void *p2);
9292
9393static GpSegConfigEntry * readGpSegConfigFromCatalog (int * total_dbs );
9494static GpSegConfigEntry * readGpSegConfigFromFTSFiles (int * total_dbs );
95+ static GpSegConfigEntry * readGpSegConfigFromFiles (int * total_dbs );
9596
9697static void getAddressesForDBid (GpSegConfigEntry * c , int elevel );
9798static HTAB * hostPrimaryCountHashTableInit (void );
@@ -131,6 +132,15 @@ typedef struct HostPrimaryCountEntry
131132 */
132133static GpSegConfigEntry *
133134readGpSegConfigFromFTSFiles (int * total_dbs )
135+ {
136+ Assert (!IsTransactionState () && !IS_HOT_DR_CLUSTER ());
137+ /* notify and wait FTS to finish a probe and update the dump file */
138+ FtsNotifyProber ();
139+ return readGpSegConfigFromFiles (total_dbs );
140+ }
141+
142+ static GpSegConfigEntry *
143+ readGpSegConfigFromFiles (int * total_dbs )
134144{
135145 FILE * fd ;
136146 int idx = 0 ;
@@ -142,11 +152,6 @@ readGpSegConfigFromFTSFiles(int *total_dbs)
142152 char address [MAXHOSTNAMELEN ];
143153 char buf [MAXHOSTNAMELEN * 2 + 32 ];
144154
145- Assert (!IsTransactionState ());
146-
147- /* notify and wait FTS to finish a probe and update the dump file */
148- FtsNotifyProber ();
149-
150155 fd = AllocateFile (GPSEGCONFIGDUMPFILE , "r" );
151156
152157 if (!fd )
@@ -188,6 +193,18 @@ readGpSegConfigFromFTSFiles(int *total_dbs)
188193 return configs ;
189194}
190195
196+ bool
197+ checkGpSegConfigFtsFiles ()
198+ {
199+ FILE * fd = AllocateFile (GPSEGCONFIGDUMPFILE , "r" );
200+
201+ if (!fd )
202+ return false;
203+
204+ FreeFile (fd );
205+ return true;
206+ }
207+
191208/*
192209 * writeGpSegConfigToFTSFiles() dump gp_segment_configuration to the file
193210 * GPSEGCONFIGDUMPFILE, in $PGDATA, only FTS process can use this function.
@@ -372,10 +389,17 @@ getCdbComponentInfo(void)
372389
373390 HTAB * hostPrimaryCountHash = hostPrimaryCountHashTableInit ();
374391
375- if (IsTransactionState ())
376- configs = readGpSegConfigFromCatalog (& total_dbs );
392+ if (EnableHotDR )
393+ {
394+ configs = readGpSegConfigFromFiles (& total_dbs );
395+ }
377396 else
378- configs = readGpSegConfigFromFTSFiles (& total_dbs );
397+ {
398+ if (IsTransactionState ())
399+ configs = readGpSegConfigFromCatalog (& total_dbs );
400+ else
401+ configs = readGpSegConfigFromFTSFiles (& total_dbs );
402+ }
379403
380404 component_databases = palloc0 (sizeof (CdbComponentDatabases ));
381405
0 commit comments