Fix server crash when trying to execute activate_node_snapshot() on a single-node cluster (#7552)

This fixes #7551 reported by Egor Chindyaskin

Function activate_node_snapshot() is not meant to be called on a cluster
without worker nodes. This commit adds ERROR report for such case to
prevent server crash.
pull/6876/merge
Karina 2024-03-07 13:08:19 +03:00 committed by GitHub
parent edcdbe67b1
commit f0043b64a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -50,6 +50,13 @@ activate_node_snapshot(PG_FUNCTION_ARGS)
* so we are using first primary worker node just for test purposes. * so we are using first primary worker node just for test purposes.
*/ */
WorkerNode *dummyWorkerNode = GetFirstPrimaryWorkerNode(); WorkerNode *dummyWorkerNode = GetFirstPrimaryWorkerNode();
if (dummyWorkerNode == NULL)
{
ereport(ERROR, (errmsg("no worker nodes found"),
errdetail("Function activate_node_snapshot is meant to be "
"used when running tests on a multi-node cluster "
"with workers.")));
}
/* /*
* Create MetadataSyncContext which is used throughout nodes' activation. * Create MetadataSyncContext which is used throughout nodes' activation.