summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2012-01-10 21:38:30 +0000
committerMarko Kreen2012-01-10 21:38:30 +0000
commit6363a0954d27815c10462f2b25c49d0dc8a5ed6c (patch)
tree6b959f156d5fc27394b593989c51e2f81e361c1f
parent6d3000ef4b52ead1f60dfee273f5e86ce8547d19 (diff)
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.
-rw-r--r--sql/pgq/functions/pgq.maint_operations.sql6
1 files changed, 6 insertions, 0 deletions
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;