Fix last status changed timestamp is not set.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 26 Feb 2020 01:31:37 +0000 (10:31 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 26 Feb 2020 01:41:22 +0000 (10:41 +0900)
If there's no status file or -D is specified when starting up
Pgpool-II, the last status changed timestamp was not set and
pcp_node_info command for example did not show the proper timestamp,
rather showed 1970/1/1, which is the Unix timestamp epoch.

Note that correct timestamp is set once clients connect to Pgpool-II
because at that time the status is changed from "waiting" to "up". So
the phenomena is only observed before any client connects to the
server.

src/main/pgpool_main.c

index 5dc2da02230bc2987b101a9a6f1ea9dad0723265..3f97dcf89aaf0763ab6c1f62ee7c964d34b36218 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2019     PgPool Global Development Group
+ * Copyright (c) 2003-2020     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -3313,6 +3313,15 @@ static int read_status_file(bool discard_status)
        bool someone_wakeup = false;
        bool is_old_format;
 
+       /*
+        * Set backend status changed timestamp so that it is set even if there's
+        * no status file or discard status option is specified.
+        */
+       for (i = 0; i < MAX_NUM_BACKENDS; i++)
+       {
+               pool_set_backend_status_changed_time(i);
+       }
+
        snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", pool_config->logdir, STATUS_FILE_NAME);
        fd = fopen(fnamebuf, "r");
        if (!fd)