It would appear that the prefaulter does not start up correctly if the database is not available initially. When run as an SMF service, it fails fast this way a few times and then the service goes into maintenance:
...
unable to start agent: unable to initialize db connection pool: unable to create a new DB connection pool: dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory
[ Sep 13 03:18:10 Stopping because all processes in service exited. ]
[ Sep 13 03:18:10 Executing stop method (:kill). ]
[ Sep 13 03:18:10 Executing start method ("/opt/pg_prefaulter/pg_prefaulter run --config=/opt/pg_prefaulter/pg_prefaulter.toml &"). ]
[ Sep 13 03:18:10 Method "start" exited with status 0. ]
{"time":"2017-09-13T03:18:10.84142588Z","level":"debug","config-file":"/opt/pg_prefaulter/pg_prefaulter.toml"}
{"time":"2017-09-13T03:18:10.841509168Z","level":"debug","message":"args: []"}
{"time":"2017-09-13T03:18:10.841778917Z","level":"debug","message":"starting gops(1) agent"}
{"time":"2017-09-13T03:18:10.841794234Z","level":"debug","postgresql.pgdata":"/manatee/pg/data","postgresql.host":"/tmp","postgresql.port":5432,"postgresql.user":"postgres","postgresql.xlog.mode":"pg","postgresql.xlog.pg_xlogdump-path":"/opt/postgresql/current/bin/pg_xlogdump","postgresql.poll-interval":1000,"message":"flags"}
{"time":"2017-09-13T03:18:10.842199269Z","level":"info","message":"Starting pg_prefaulter"}
{"time":"2017-09-13T03:18:10.842205727Z","level":"info","message":"Stopped pg_prefaulter"}
Error: unable to start agent: unable to initialize db connection pool: unable to create a new DB connection pool: dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory
Usage:
pg_prefaulter run [flags]
Flags:
-h, --help help for run
-m, --mode string Mode of operation of the database: "auto", "primary", "follower" (default "auto")
-N, --num-io-threads uint Number of IO threads to spawn for IOs
-i, --poll-interval string Interval to poll the database for state change (default "1s")
-n, --wal-readahead uint Number of WAL entries to perform read-ahead into (default 4)
-X, --xlog-mode string pg_xlogdump(1) variant: "xlog" or "pg" (default "pg")
-x, --xlogdump-bin string Path to pg_xlogdump(1) (default "/usr/local/bin/pg_xlogdump")
Global Flags:
-a, --circonus-api-key string Circonus API token
--circonus-api-url string Circonus API URL (default "https://api.circonus.com/v2")
--circonus-broker-id string Circonus Broker ID
--circonus-broker-max-response-time string Circonus Broker Max Response Time (default "500ms")
--circonus-broker-select-tag string Circonus Broker Select Tag
--circonus-check-display-name string Circonus Check Display Name (default "pg_prefaulter")
--circonus-check-force-metric-activation string Circonus Check Force Metric Activation (default "false")
--circonus-check-id string Circonus Check ID
--circonus-check-instance-id string Circonus Check Instance ID (default "4042552b-5fe0-45c4-9df4-f21eca88464d:pg_prefaulter")
--circonus-check-max-url-age string Circonus Check Max URL Age (default "5m")
--circonus-check-search-tag string Circonus Check Search Tag (default "app:pg_prefaulter,host:4042552b-5fe0-45c4-9df4-f21eca88464d")
--circonus-check-secret string Circonus Check Secret
--circonus-check-tags string Circonus Check Tags (default "app:pg_prefaulter")
--circonus-check-target-host string Circonus Check Target Host (default "4042552b-5fe0-45c4-9df4-f21eca88464d")
--circonus-debug Enable Circonus Debug
--circonus-enable-metrics Enable Circonus metrics (default true)
--circonus-submission-url string Circonus Check Submission URL
--config string config file (default "pg_prefaulter.toml")
-d, --database string postgres (default "postgres")
--enable-agent Enable the gops(1) agent interface (default true)
-H, --hostname string Hostname to connect to PostgreSQL (default "/tmp")
-l, --log-level string Log level (default "INFO")
-D, --pgdata string Path to PGDATA (default "pgdata")
-p, --port uint Hostname to connect to PostgreSQL (default 5432)
-U, --username string Username to connect to PostgreSQL (default "postgres")
unable to start agent: unable to initialize db connection pool: unable to create a new DB connection pool: dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory
[ Sep 13 03:18:10 Stopping because all processes in service exited. ]
[ Sep 13 03:18:10 Executing stop method (:kill). ]
[ Sep 13 03:18:10 Restarting too quickly, changing state to maintenance. ]
Once the database is running, I can clear the maintenance status and the service appears to start correctly:
It would appear that the prefaulter does not start up correctly if the database is not available initially. When run as an SMF service, it fails fast this way a few times and then the service goes into maintenance:
Once the database is running, I can clear the maintenance status and the service appears to start correctly: