Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6494216

Browse files
committed
fix race conditions in tests in pathman_bgw
1 parent485f025 commit6494216

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+
opsint8;
185+
rowsint8;
186+
rows_oldint8 := 0;
187+
iint4 := 0; -- protect from endless loop
185188
BEGIN
186189
LOOP
187-
SELECTcount(*)
190+
SELECTprocessed
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+
opsint8;
99+
rowsint8;
100+
rows_oldint8 :=0;
101+
iint4 :=0;-- protect from endless loop
99102
BEGIN
100103
LOOP
101-
SELECTcount(*)
104+
SELECTprocessed
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 rowsIS 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
staticvoid
433433
free_cps_slot(intcode,Datumarg)
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)

[8]ページ先頭

©2009-2025 Movatter.jp