diff --git a/contrib/gp_replica_check/gp_replica_check.c b/contrib/gp_replica_check/gp_replica_check.c index df5d25680aa34d9e5592f6e3a2a2171790426448..690965e88bbc11135fbce54155c75a69d55387cf 100644 --- a/contrib/gp_replica_check/gp_replica_check.c +++ b/contrib/gp_replica_check/gp_replica_check.c @@ -258,6 +258,18 @@ compare_files(char *primaryfilepath, char *mirrorfilepath, RelfilenodeEntry *ren retry: CHECK_FOR_INTERRUPTS(); + /* If the files were still open from previous attempt, close them first. */ + if (primaryFile != -1) + { + FileClose(primaryFile); + primaryFile = -1; + } + if (mirrorFile != -1) + { + FileClose(mirrorFile); + mirrorFile = -1; + } + if (attempts == NUM_RETRIES) { ereport(WARNING, @@ -279,18 +291,6 @@ retry: return false; } - /* If the files were still open from previous attempt, close them first. */ - if (primaryFile != -1) - { - FileClose(primaryFile); - primaryFile = -1; - } - if (mirrorFile != -1) - { - FileClose(mirrorFile); - mirrorFile = -1; - } - /* * Attempt to open both files. */