/* recovery.c */
extern void start_recovery(int recovery_node);
extern void finish_recovery(void);
-extern int wait_connection_closed(void);
+extern int wait_connection_closed(void);
+extern int ensure_conn_counter_validity(void);
/* child.c */
extern void cancel_request(CancelPacket * sp);
} while (i++ < WAIT_RETRY_COUNT);
ereport(LOG,
(errmsg("wait_connection_closed: existing connections did not close in %d sec.", pool_config->recovery_timeout)));
+ return ensure_conn_counter_validity();
+}
+int ensure_conn_counter_validity(void)
+{
/*
* recovery_timeout was expired. Before returning with failure status,
* let's check if this is caused by the malformed conn_counter. If a child
}
else if (pool_config->recovery_timeout <= 0)
{
- reply_with_minimal_message(wdNode, WD_REJECT_MESSAGE, pkt);
+ if (ensure_conn_counter_validity() == 0)
+ reply_with_minimal_message(wdNode, WD_ACCEPT_MESSAGE, pkt);
+ else
+ reply_with_minimal_message(wdNode, WD_REJECT_MESSAGE, pkt);
}
else
{
WDPacketData emptyPkt;
emptyPkt.command_id = wd_func_command->commandID;
- reply_with_minimal_message(wd_func_command->wdNode, WD_REJECT_MESSAGE, &emptyPkt);
+
+ if (ensure_conn_counter_validity() == 0)
+ reply_with_minimal_message(wd_func_command->wdNode, WD_ACCEPT_MESSAGE, &emptyPkt);
+ else
+ reply_with_minimal_message(wd_func_command->wdNode, WD_REJECT_MESSAGE, &emptyPkt);
return true;
}
return false;
shared_key ? *shared_key : 0, pool_config->wd_authkey);
WDIPCCmdResult *result = issue_command_to_watchdog(WD_IPC_ONLINE_RECOVERY_COMMAND,
- pool_config->recovery_timeout,
+ pool_config->recovery_timeout + WD_DEFAULT_IPC_COMMAND_TIMEOUT,
func, strlen(func), true);
pfree(func);
char *json_data = get_wd_failover_state_json(start);
WDIPCCmdResult *result = issue_command_to_watchdog(WD_FAILOVER_INDICATION
- ,pool_config->recovery_timeout,
+ ,WD_DEFAULT_IPC_COMMAND_TIMEOUT,
json_data, strlen(json_data), true);
pfree(json_data);