From 6363a0954d27815c10462f2b25c49d0dc8a5ed6c Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Tue, 10 Jan 2012 22:38:30 +0100 Subject: pgq.maint_operations: re-check the need for step2 Previously the need for step2 was decided by need for step1. But if pgqd stops/crashed after step1 but before step2, the step2 will not be run anymore. Fix this by rechecking if no step1 was needed. --- sql/pgq/functions/pgq.maint_operations.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sql/pgq/functions/pgq.maint_operations.sql b/sql/pgq/functions/pgq.maint_operations.sql index bb72b12f..31c44ba3 100644 --- a/sql/pgq/functions/pgq.maint_operations.sql +++ b/sql/pgq/functions/pgq.maint_operations.sql @@ -34,6 +34,12 @@ begin end loop; -- rotate step 2 + if nrot = 0 then + select count(1) from pgq.queue + where queue_rotation_period is not null + and queue_switch_step2 is null + into nrot; + end if; if nrot > 0 then func_name := 'pgq.maint_rotate_tables_step2'; func_arg := NULL; -- cgit v1.2.3