File tree Expand file tree Collapse file tree 3 files changed +49
-11
lines changed Expand file tree Collapse file tree 3 files changed +49
-11
lines changed Original file line number Diff line number Diff line change @@ -181,19 +181,38 @@ ROLLBACK;
181181/* Wait until it finises */
182182DO $$
183183DECLARE
184- ops int8;
184+ ops int8;
185+ rows int8;
186+ rows_old int8 := 0;
187+ i int4 := 0; -- protect from endless loop
185188BEGIN
186189 LOOP
187- SELECT count(*)
190+ SELECT processed
188191 FROM pathman_concurrent_part_tasks
189- WHERE processed < 500 -- protect from endless loops
190- INTO ops;
192+ WHERE relid = 'test_bgw.conc_part'::regclass
193+ INTO rows;
194+
195+ -- get number of partitioning tasks
196+ GET DIAGNOSTICS ops = ROW_COUNT;
191197
192198 IF ops > 0 THEN
193199 PERFORM pg_sleep(0.2);
200+
201+ ASSERT rows IS NOT NULL;
202+
203+ IF rows_old = rows THEN
204+ i = i + 1;
205+ END IF;
194206 ELSE
195- EXIT;
207+ EXIT; -- exit loop
196208 END IF;
209+
210+ IF i > 50 THEN
211+ RAISE WARNING 'looks like partitioning bgw is stuck!';
212+ EXIT; -- exit loop
213+ END IF;
214+
215+ rows_old = rows;
197216 END LOOP;
198217END
199218$$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change @@ -95,19 +95,38 @@ ROLLBACK;
9595/* Wait until it finises */
9696DO $$
9797DECLARE
98- ops int8;
98+ ops int8;
99+ rows int8;
100+ rows_old int8 := 0 ;
101+ i int4 := 0 ; -- protect from endless loop
99102BEGIN
100103 LOOP
101- SELECT count ( * )
104+ SELECT processed
102105 FROM pathman_concurrent_part_tasks
103- WHERE processed < 500 -- protect from endless loops
104- INTO ops;
106+ WHERE relid = ' test_bgw.conc_part' ::regclass
107+ INTO rows;
108+
109+ -- get number of partitioning tasks
110+ GET DIAGNOSTICS ops = ROW_COUNT;
105111
106112 IF ops > 0 THEN
107113 PERFORM pg_sleep(0 .2 );
114+
115+ ASSERT rows IS NOT NULL ;
116+
117+ IF rows_old = rows THEN
118+ i = i + 1 ;
119+ END IF;
108120 ELSE
109- EXIT;
121+ EXIT; -- exit loop
110122 END IF;
123+
124+ IF i > 50 THEN
125+ RAISE WARNING ' looks like partitioning bgw is stuck!' ;
126+ EXIT; -- exit loop
127+ END IF;
128+
129+ rows_old = rows;
111130 END LOOP;
112131END
113132$$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change @@ -432,7 +432,7 @@ bgw_main_spawn_partitions(Datum main_arg)
432432static void
433433free_cps_slot (int code , Datum arg )
434434{
435- ConcurrentPartSlot * part_slot = (ConcurrentPartSlot * ) DatumGetPointer (arg );
435+ ConcurrentPartSlot * part_slot = (ConcurrentPartSlot * ) DatumGetPointer (arg );
436436
437437 cps_set_status (part_slot , CPS_FREE );
438438}
You can’t perform that action at this time.
0 commit comments