Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b14937d

Browse files
committed
Merge branch 'master' into rel_future_beta
2 parents 955c8e8 + 6494216 commit b14937d

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

expected/pathman_bgw.out

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,38 @@ ROLLBACK;
181181
/* Wait until it finises */
182182
DO $$
183183
DECLARE
184-
ops int8;
184+
ops int8;
185+
rows int8;
186+
rows_old int8 := 0;
187+
i int4 := 0; -- protect from endless loop
185188
BEGIN
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;
198217
END
199218
$$ LANGUAGE plpgsql;

sql/pathman_bgw.sql

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,38 @@ ROLLBACK;
9595
/* Wait until it finises */
9696
DO $$
9797
DECLARE
98-
ops int8;
98+
ops int8;
99+
rows int8;
100+
rows_old int8 := 0;
101+
i int4 := 0; -- protect from endless loop
99102
BEGIN
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;
112131
END
113132
$$ LANGUAGE plpgsql;

src/pathman_workers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ bgw_main_spawn_partitions(Datum main_arg)
432432
static void
433433
free_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
}

0 commit comments

Comments
 (0)