Fix assert in debug wait points

Need to ensure that we should try to take a lock only if a valid
transaction is around. Otherwise assert is hit due to an error within
an error.

Fixes #5917
This commit is contained in:
Nikhil Sontakke 2023-08-04 14:08:03 +05:30 committed by Nikhil
parent 2eb0a3883b
commit 592da23633

View File

@ -11,6 +11,7 @@
#include <fmgr.h>
#include <access/hash.h>
#include <access/xact.h>
#include <storage/ipc.h>
#include <storage/lock.h>
#include <miscadmin.h>
@ -177,6 +178,10 @@ ts_debug_point_wait(const char *name, bool blocking)
LockAcquireResult lock_acquire_result pg_attribute_unused();
bool lock_release_result pg_attribute_unused();
/* Ensure that we are in a transaction before trying for locks */
if (!IsTransactionState())
return;
debug_point_init(&point, name);
ereport(DEBUG3, (errmsg("waiting on debug point '%s'", point.name)));