Don't auto-restart per-database autoprewarm workers.
authorRobert Haas <[email protected]>
Mon, 18 Mar 2019 19:21:09 +0000 (15:21 -0400)
committerRobert Haas <[email protected]>
Mon, 18 Mar 2019 19:22:42 +0000 (15:22 -0400)
We should try to prewarm each database only once.  Otherwise, if
prewarming fails for some reason, it will just keep retrying in an
infnite loop.  This can happen if, for example, the database has been
dropped.  The existing code was intended to implement the try-once
behavior, but failed to do so because it neglected to set
worker.bgw_restart_time to BGW_NEVER_RESTART.

Mithun Cy, per a report from Hans Buschmann

Discussion: http://postgr.es/m/CA+hUKGKpQJCWcgyy3QTC9vdn6uKAR_8r__A-MMm2GYfj45caag@mail.gmail.com

contrib/pg_prewarm/autoprewarm.c

index 9cc4b2dc83724fc1368e03cc9fb795f9d3eaaf8f..5378ff0141d08045fe09ffee1fa0b5dc4a666734 100644 (file)
@@ -840,6 +840,7 @@ apw_start_database_worker(void)
    worker.bgw_flags =
        BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION;
    worker.bgw_start_time = BgWorkerStart_ConsistentState;
+   worker.bgw_restart_time = BGW_NEVER_RESTART;
    strcpy(worker.bgw_library_name, "pg_prewarm");
    strcpy(worker.bgw_function_name, "autoprewarm_database_main");
    strcpy(worker.bgw_name, "autoprewarm worker");