1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-28 11:44:57 +03:00

Improve test case stability

Given unlucky timing, some of the new tests added by commit bc32a12e0d
can fail spuriously.  We haven't seen such failures yet in buildfarm,
but allegedly we can prevent them with this tweak.

While at it, remove an unused injection point I (Álvaro) added.

Author: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Discussion: https://postgr.es/m/CADzfLwUc=jtSUEaQCtyt8zTeOJ-gHZ8=w_KJsVjDOYSLqaY9Lg@mail.gmail.com
Discussion: https://postgr.es/m/CADzfLwV5oQq-Vg_VmG_o4SdL6yHjDoNO4T4pMtgJLzYGmYf74g@mail.gmail.com
This commit is contained in:
Álvaro Herrera
2025-11-25 18:20:06 +01:00
parent 7169c0b96b
commit 417ac9c1ee
6 changed files with 45 additions and 22 deletions

View File

@@ -945,9 +945,7 @@ retry:
ExecDropSingleTupleTableSlot(existing_slot); ExecDropSingleTupleTableSlot(existing_slot);
#ifdef USE_INJECTION_POINTS #ifdef USE_INJECTION_POINTS
if (conflict) if (!conflict)
INJECTION_POINT("check-exclusion-or-unique-constraint-conflict", NULL);
else
INJECTION_POINT("check-exclusion-or-unique-constraint-no-conflict", NULL); INJECTION_POINT("check-exclusion-or-unique-constraint-no-conflict", NULL);
#endif #endif

View File

@@ -459,6 +459,7 @@ InvalidateCatalogSnapshot(void)
pairingheap_remove(&RegisteredSnapshots, &CatalogSnapshot->ph_node); pairingheap_remove(&RegisteredSnapshots, &CatalogSnapshot->ph_node);
CatalogSnapshot = NULL; CatalogSnapshot = NULL;
SnapshotResetXmin(); SnapshotResetXmin();
INJECTION_POINT("pre-invalidate-catalog-snapshot-end", NULL);
INJECTION_POINT("invalidate-catalog-snapshot-end", NULL); INJECTION_POINT("invalidate-catalog-snapshot-end", NULL);
} }
} }

View File

@@ -1,6 +1,6 @@
Parsed test spec with 4 sessions Parsed test spec with 5 sessions
starting permutation: s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s4_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 starting permutation: s5_noop s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1
injection_points_attach injection_points_attach
----------------------- -----------------------
@@ -16,12 +16,16 @@ injection_points_attach
(1 row) (1 row)
step s5_noop:
<waiting ...>
step s3_start_create_index: step s3_start_create_index:
CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_special_duplicate ON test.tbl(abs(i)) WHERE i < 10000; CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_special_duplicate ON test.tbl(abs(i)) WHERE i < 10000;
<waiting ...> <waiting ...>
s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end
step s1_start_upsert: step s1_start_upsert:
INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now(); INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now();
<waiting ...> <waiting ...>
step s5_noop: <... completed>
step s4_wakeup_define_index_before_set_valid: step s4_wakeup_define_index_before_set_valid:
SELECT injection_points_detach('define-index-before-set-valid'); SELECT injection_points_detach('define-index-before-set-valid');
SELECT injection_points_wakeup('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid');
@@ -39,7 +43,7 @@ injection_points_wakeup
step s2_start_upsert: step s2_start_upsert:
INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now(); INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now();
<waiting ...> <waiting ...>
step s4_wakeup_s1_from_invalidate_catalog_snapshot: step s5_wakeup_s1_from_invalidate_catalog_snapshot:
SELECT injection_points_detach('invalidate-catalog-snapshot-end'); SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
@@ -81,6 +85,7 @@ injection_points_wakeup
(1 row) (1 row)
s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end
step s1_start_upsert: <... completed> step s1_start_upsert: <... completed>
step s2_start_upsert: <... completed> step s2_start_upsert: <... completed>
step s3_start_create_index: <... completed> step s3_start_create_index: <... completed>

View File

@@ -1,6 +1,6 @@
Parsed test spec with 4 sessions Parsed test spec with 5 sessions
starting permutation: s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s4_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 starting permutation: s5_noop s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1
injection_points_attach injection_points_attach
----------------------- -----------------------
@@ -16,12 +16,16 @@ injection_points_attach
(1 row) (1 row)
step s5_noop:
<waiting ...>
step s3_start_create_index: step s3_start_create_index:
CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_duplicate ON test.tbl(i); CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_duplicate ON test.tbl(i);
<waiting ...> <waiting ...>
s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end
step s1_start_upsert: step s1_start_upsert:
INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now(); INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now();
<waiting ...> <waiting ...>
step s5_noop: <... completed>
step s4_wakeup_define_index_before_set_valid: step s4_wakeup_define_index_before_set_valid:
SELECT injection_points_detach('define-index-before-set-valid'); SELECT injection_points_detach('define-index-before-set-valid');
SELECT injection_points_wakeup('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid');
@@ -39,7 +43,7 @@ injection_points_wakeup
step s2_start_upsert: step s2_start_upsert:
INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now(); INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now();
<waiting ...> <waiting ...>
step s4_wakeup_s1_from_invalidate_catalog_snapshot: step s5_wakeup_s1_from_invalidate_catalog_snapshot:
SELECT injection_points_detach('invalidate-catalog-snapshot-end'); SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
@@ -81,6 +85,7 @@ injection_points_wakeup
(1 row) (1 row)
s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end
step s1_start_upsert: <... completed> step s1_start_upsert: <... completed>
step s2_start_upsert: <... completed> step s2_start_upsert: <... completed>
step s3_start_create_index: <... completed> step s3_start_create_index: <... completed>

View File

@@ -5,7 +5,7 @@
# - s2: UPSERT the same tuple # - s2: UPSERT the same tuple
# - s3: CREATE UNIQUE INDEX CONCURRENTLY (with a predicate) # - s3: CREATE UNIQUE INDEX CONCURRENTLY (with a predicate)
# #
# - s4: control concurrency via injection points # - s4 and s5: control concurrency via injection points
setup setup
{ {
@@ -27,6 +27,7 @@ setup
{ {
SELECT injection_points_set_local(); SELECT injection_points_set_local();
SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait'); SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait');
SELECT injection_points_attach('pre-invalidate-catalog-snapshot-end', 'notice');
SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait'); SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait');
} }
step s1_start_upsert step s1_start_upsert
@@ -62,11 +63,6 @@ step s4_wakeup_s1
SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict');
SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict');
} }
step s4_wakeup_s1_from_invalidate_catalog_snapshot
{
SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
}
step s4_wakeup_s2 step s4_wakeup_s2
{ {
SELECT injection_points_detach('exec-insert-before-insert-speculative'); SELECT injection_points_detach('exec-insert-before-insert-speculative');
@@ -78,11 +74,22 @@ step s4_wakeup_define_index_before_set_valid
SELECT injection_points_wakeup('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid');
} }
session s5
step s5_noop
{
}
step s5_wakeup_s1_from_invalidate_catalog_snapshot
{
SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
}
permutation permutation
s5_noop(s1_start_upsert notices 1)
s3_start_create_index(s1_start_upsert, s2_start_upsert) s3_start_create_index(s1_start_upsert, s2_start_upsert)
s1_start_upsert s1_start_upsert
s4_wakeup_define_index_before_set_valid s4_wakeup_define_index_before_set_valid
s2_start_upsert(s1_start_upsert) s2_start_upsert(s1_start_upsert)
s4_wakeup_s1_from_invalidate_catalog_snapshot s5_wakeup_s1_from_invalidate_catalog_snapshot
s4_wakeup_s2 s4_wakeup_s2
s4_wakeup_s1 s4_wakeup_s1

View File

@@ -26,6 +26,7 @@ setup
{ {
SELECT injection_points_set_local(); SELECT injection_points_set_local();
SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait'); SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait');
SELECT injection_points_attach('pre-invalidate-catalog-snapshot-end', 'notice');
SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait'); SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait');
} }
step s1_start_upsert step s1_start_upsert
@@ -61,11 +62,6 @@ step s4_wakeup_s1
SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict');
SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict');
} }
step s4_wakeup_s1_from_invalidate_catalog_snapshot
{
SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
}
step s4_wakeup_s2 step s4_wakeup_s2
{ {
SELECT injection_points_detach('exec-insert-before-insert-speculative'); SELECT injection_points_detach('exec-insert-before-insert-speculative');
@@ -77,11 +73,22 @@ step s4_wakeup_define_index_before_set_valid
SELECT injection_points_wakeup('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid');
} }
session s5
step s5_noop
{
}
step s5_wakeup_s1_from_invalidate_catalog_snapshot
{
SELECT injection_points_detach('invalidate-catalog-snapshot-end');
SELECT injection_points_wakeup('invalidate-catalog-snapshot-end');
}
permutation permutation
s5_noop(s1_start_upsert notices 1)
s3_start_create_index(s1_start_upsert, s2_start_upsert) s3_start_create_index(s1_start_upsert, s2_start_upsert)
s1_start_upsert s1_start_upsert
s4_wakeup_define_index_before_set_valid s4_wakeup_define_index_before_set_valid
s2_start_upsert(s1_start_upsert) s2_start_upsert(s1_start_upsert)
s4_wakeup_s1_from_invalidate_catalog_snapshot s5_wakeup_s1_from_invalidate_catalog_snapshot
s4_wakeup_s2 s4_wakeup_s2
s4_wakeup_s1 s4_wakeup_s1