File tree 3 files changed +49
-11
lines changed
3 files changed +49
-11
lines changed Original file line number Diff line number Diff line change @@ -181,19 +181,38 @@ ROLLBACK;
181
181
/* Wait until it finises */
182
182
DO $$
183
183
DECLARE
184
- ops int8;
184
+ ops int8;
185
+ rows int8;
186
+ rows_old int8 := 0;
187
+ i int4 := 0; -- protect from endless loop
185
188
BEGIN
186
189
LOOP
187
- SELECT count(*)
190
+ SELECT processed
188
191
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;
191
197
192
198
IF ops > 0 THEN
193
199
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;
194
206
ELSE
195
- EXIT;
207
+ EXIT; -- exit loop
196
208
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;
197
216
END LOOP;
198
217
END
199
218
$$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change @@ -95,19 +95,38 @@ ROLLBACK;
95
95
/* Wait until it finises */
96
96
DO $$
97
97
DECLARE
98
- ops int8;
98
+ ops int8;
99
+ rows int8;
100
+ rows_old int8 := 0 ;
101
+ i int4 := 0 ; -- protect from endless loop
99
102
BEGIN
100
103
LOOP
101
- SELECT count ( * )
104
+ SELECT processed
102
105
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;
105
111
106
112
IF ops > 0 THEN
107
113
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;
108
120
ELSE
109
- EXIT;
121
+ EXIT; -- exit loop
110
122
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;
111
130
END LOOP;
112
131
END
113
132
$$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change @@ -432,7 +432,7 @@ bgw_main_spawn_partitions(Datum main_arg)
432
432
static void
433
433
free_cps_slot (int code , Datum arg )
434
434
{
435
- ConcurrentPartSlot * part_slot = (ConcurrentPartSlot * ) DatumGetPointer (arg );
435
+ ConcurrentPartSlot * part_slot = (ConcurrentPartSlot * ) DatumGetPointer (arg );
436
436
437
437
cps_set_status (part_slot , CPS_FREE );
438
438
}
You can’t perform that action at this time.
0 commit comments