Skip to content

Commit 9f63eb5

Browse files
author
Maksim Milyutin
committed
Fix module to prevent sigfault crash error
1 parent bbca818 commit 9f63eb5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

contrib/pg_query_state/pg_query_state.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,16 @@ pg_query_state(PG_FUNCTION_ARGS)
540540
buffers,
541541
triggers,
542542
format);
543-
msg = (shm_mq_msg *) linitial(msgs);
544543

545544
funcctx = SRF_FIRSTCALL_INIT();
545+
if (list_length(msgs) == 0)
546+
{
547+
elog(WARNING, "backend does not reply");
548+
LockRelease(&tag, ExclusiveLock, false);
549+
SRF_RETURN_DONE(funcctx);
550+
}
551+
552+
msg = (shm_mq_msg *) linitial(msgs);
546553
switch (msg->result_code)
547554
{
548555
case QUERY_NOT_RUNNING:
@@ -946,7 +953,7 @@ GetRemoteBackendQueryStates(List *procs,
946953
mq_receive_result = shm_mq_receive_with_timeout(mqh,
947954
&len,
948955
(void **) &msg,
949-
MIN_TIMEOUT);
956+
2 * MIN_TIMEOUT);
950957
if (mq_receive_result != SHM_MQ_SUCCESS)
951958
/* counterpart is died, not consider it */
952959
continue;

0 commit comments

Comments
 (0)