Don't collect stats when there is a version mismatch. (#1712)

The following scenario can cause an Assert() crash if we don't do this:
- Install Citus v7.0-15
- Restart server & run a query to start maintenanced.
- Install Citus v7.1
- Restart server & run a query. This will tell user to upgrade.
- Type "UPDATE EXTENSION c" & press tab. maintenanced will start and crash
  with Assert(CitusHasBeenLoaded() && CheckCitusVersion(WARNING));

This change checks Citus version before calling metadata functions so the
crash doesn't happen.
pull/1724/head
Hadi Moshayedi 2017-10-17 14:01:14 -04:00 committed by GitHub
parent e4072a3dbb
commit 86bcd93a4a
1 changed files with 11 additions and 0 deletions

View File

@ -65,6 +65,17 @@ CollectBasicUsageStatistics(void)
memset(&unameData, 0, sizeof(unameData));
StartTransactionCommand();
/*
* If there is a version mismatch between loaded version and available
* version, metadata functions will fail. We return early to avoid crashing.
* This can happen when updating the Citus extension.
*/
if (!CheckCitusVersion(LOG_SERVER_ONLY))
{
CommitTransactionCommand();
return false;
}
distributedTables = DistributedTableList();
roundedDistTableCount = NextPow2(list_length(distributedTables));
roundedClusterSize = NextPow2(ClusterSize(distributedTables));