Skip to content

Commit

Permalink
Fix server crash when trying to execute activate_node_snapshot() on a…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Green-Chan authored and emelsimsek committed Mar 11, 2024
1 parent 34883d6 commit 93c0ec1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/distributed/test/metadata_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ activate_node_snapshot(PG_FUNCTION_ARGS)
* so we are using first primary worker node just for test purposes.
*/
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.
Expand Down

0 comments on commit 93c0ec1

Please sign in to comment.