Postgres-XC Wiki

XC_Watchdog why?

To monitor if each XC component is running, psql is not sufficient because it does not check gtm/gtm_proxy/datanode. Also, psql detection may take time. As discussed in the cluster summit (, watchdog time will be nice for this purpose.

Here's a design of watchdog timer:

  • Have separate shared memory for each component,
  • Postmaster and gtm/gtm_proxy server main loop increment each watchdog timer,
  • ( Timer will be detected by separate command to report any fault

For this purpose, need some GUC and GTM/GTM-Proxy configuration parameters to specify

  • If watchdog time is on
  • Timer increment interval (maybe in milliseconds)

Shmid for each component will be kept in pg_control, gtm.control and gtm_proxy.control files.

API to attach shared memory for watchdog and read the timer value will be provided too.


  1. Add GUC
    1. xc_watchdog onoff
    2. xc_watchdog_interval (in millisecond)
  2. Add gtm.opt option
    1. xc_watchdog on/off
    2. xc_watchdog_interval in millisecond
  3. Add gtm_proxy.opt option
    1. xc_watchdog on/off
    2. xc_watchdog_interval in millisecond
  4. Write the following
    1. watchdog structure definition
    2. function to get, initialize and attach watchdog memory
      1. Check the magic and node category (coord/datanode/gtm/gtm_proxy)
    3. function to imcrement the watchdog timer
    4. Individual functions for coord/datanode/gtm/gtm_proxy to do the following:
      1. Initialize pointer to the watchdog structure
      2. Set interval
      3. Increment the timer (in each server loop)
      4. Handle status file.

When status file is first read, check shmid of the watchdog structure. If set, try to attach this and check if it is valid. If not set or not valid, then shmget, attach and initialize it, and then write back the status file.

?? When watchdog structure can be removed? ---> When each component terminate gracefully, then the structure can be removed.

  1. Watchdog detector
    1. API for
      1. watchdog detector application to attach and monitor.
      2. (maybe) some asynchronous means to notify the target failure
      3. Detect XC cluster configuration and build XC cluster configuration structure.
      4. various supporting API for c)
    2. Command to
      1. Detect a failurem
      2. Report to external entities --> could be smnp trap, could be pacemaker monitoring tool, could be any others.
      3. Collect XC cluster configuration and advice what to do when any failure occurs --> Split brain handling will be important here.