Skip to content

Commit 429d225

Browse files
committed
GUC: DMQ Heartbeat timeout
1 parent 0810e1f commit 429d225

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

contrib/pg_exchange/dmq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static shmem_startup_hook_type PreviousShmemStartupHook;
129129
dmq_receiver_hook_type dmq_receiver_start_hook;
130130
dmq_receiver_hook_type dmq_receiver_stop_hook;
131131

132+
int dmq_heartbeat_timeout;
132133
void dmq_sender_main(Datum main_arg);
133134

134135
PG_FUNCTION_INFO_V1(dmq_receiver_loop);
@@ -1138,9 +1139,9 @@ dmq_receiver_loop(PG_FUNCTION_ARGS)
11381139
// XXX: is it enough?
11391140
CHECK_FOR_INTERRUPTS();
11401141

1141-
if (dmq_now() - last_message_at > 2000)
1142+
if (dmq_now() - last_message_at > dmq_heartbeat_timeout)
11421143
{
1143-
mtm_log(ERROR, "[DMQ] exit receiver due to heatbeat timeout");
1144+
mtm_log(ERROR, "[DMQ] exit receiver due to heartbeat timeout");
11441145
}
11451146

11461147
}

contrib/pg_exchange/dmq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ typedef int8 DmqSenderId;
1919
#define DMQ_MAX_DESTINATIONS 127
2020
#define DMQ_MAX_RECEIVERS 100
2121

22+
extern int dmq_heartbeat_timeout;
23+
2224
extern void dmq_init(const char *library_name);
2325

2426
extern DmqDestinationId dmq_destination_add(char *connstr,

contrib/pg_exchange/pg_exchange.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ _PG_init(void)
8080
NULL,
8181
NULL);
8282

83+
DefineCustomIntVariable("dmq_heartbeat_timeout",
84+
"Max timeout between heartbeat messages",
85+
NULL,
86+
&dmq_heartbeat_timeout,
87+
20000,
88+
1, INT_MAX,
89+
PGC_USERSET,
90+
GUC_UNIT_MS,
91+
NULL,
92+
NULL,
93+
NULL);
94+
8395
EXCHANGE_Init_methods();
8496
DUMMYSCAN_Init_methods();
8597
EXEC_Hooks_init();

0 commit comments

Comments
 (0)