Commit 9fa6fe46 authored by Tom Lane's avatar Tom Lane

Rethink blocking annotations in detach-partition-concurrently-[34].

In 741d7f10, I tried to make the reports from canceled steps come out
after the pg_cancel_backend() steps, since that was the most common
ordering before.  However, that doesn't ensure that a canceled step
doesn't report even later, as shown in a recent failure on buildfarm
member idiacanthus.  Rather than complicating things even more with
additional annotations, let's just force the cancel's effect to be
reported first.  It's not *that* unnatural-looking.

Back-patch to v14 where these test cases appeared.

Report: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=idiacanthus&dt=2021-07-02%2001%3A40%3A04
parent 1479c5af
...@@ -11,14 +11,15 @@ a ...@@ -11,14 +11,15 @@ a
(2 rows) (2 rows)
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1insert: insert into d4_fk values (1); step s1insert: insert into d4_fk values (1);
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey" ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
step s1c: commit; step s1c: commit;
...@@ -50,14 +51,15 @@ a ...@@ -50,14 +51,15 @@ a
(2 rows) (2 rows)
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1insert: insert into d4_fk values (1); step s1insert: insert into d4_fk values (1);
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey" ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
step s1c: commit; step s1c: commit;
...@@ -83,14 +85,15 @@ step s2snitch: insert into d4_pid select pg_backend_pid(); ...@@ -83,14 +85,15 @@ step s2snitch: insert into d4_pid select pg_backend_pid();
step s1b: begin; step s1b: begin;
step s1declare: declare f cursor for select * from d4_primary; step s1declare: declare f cursor for select * from d4_primary;
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1fetchall: fetch all from f; step s1fetchall: fetch all from f;
a a
- -
...@@ -124,14 +127,15 @@ step s2snitch: insert into d4_pid select pg_backend_pid(); ...@@ -124,14 +127,15 @@ step s2snitch: insert into d4_pid select pg_backend_pid();
step s1b: begin; step s1b: begin;
step s1declare: declare f cursor for select * from d4_primary; step s1declare: declare f cursor for select * from d4_primary;
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1svpt: savepoint f; step s1svpt: savepoint f;
step s1insert: insert into d4_fk values (1); step s1insert: insert into d4_fk values (1);
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey" ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
...@@ -251,14 +255,15 @@ a ...@@ -251,14 +255,15 @@ a
(1 row) (1 row)
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1updcur: update d4_fk set a = 1 where current of f; step s1updcur: update d4_fk set a = 1 where current of f;
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey" ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
step s1c: commit; step s1c: commit;
...@@ -326,14 +331,15 @@ step s3brr: begin isolation level repeatable read; ...@@ -326,14 +331,15 @@ step s3brr: begin isolation level repeatable read;
step s3insert: insert into d4_fk values (1); step s3insert: insert into d4_fk values (1);
ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey" ERROR: insert or update on table "d4_fk" violates foreign key constraint "d4_fk_a_fkey"
step s3commit: commit; step s3commit: commit;
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1c: commit; step s1c: commit;
starting permutation: s2snitch s1b s1s s2detach s3brr s3insert s3commit s1c starting permutation: s2snitch s1b s1s s2detach s3brr s3insert s3commit s1c
...@@ -365,14 +371,15 @@ a ...@@ -365,14 +371,15 @@ a
(2 rows) (2 rows)
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1noop: step s1noop:
step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits; step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits;
step s1s: select * from d4_primary; step s1s: select * from d4_primary;
...@@ -397,14 +404,15 @@ a ...@@ -397,14 +404,15 @@ a
(2 rows) (2 rows)
step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...> step s2detach: alter table d4_primary detach partition d4_primary1 concurrently; <waiting ...>
step s1cancel: select pg_cancel_backend(pid) from d4_pid; step s1cancel: select pg_cancel_backend(pid) from d4_pid; <waiting ...>
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1cancel: <... completed>
pg_cancel_backend pg_cancel_backend
----------------- -----------------
t t
(1 row) (1 row)
step s2detach: <... completed>
ERROR: canceling statement due to user request
step s1noop: step s1noop:
step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits; step s3vacfreeze: vacuum freeze pg_catalog.pg_inherits;
step s1s: select * from d4_primary; step s1s: select * from d4_primary;
......
# Try various things to happen to a partition with an incomplete detach # Try various things to happen to a partition with an incomplete detach
# #
# Note: When using "s1cancel", mark the target step (the one to be canceled) # Note: When using "s1cancel", mark the target step (the one to be canceled)
# as being blocked by "s1cancel". This ensures consistent reporting regardless # as blocking "s1cancel". This ensures consistent reporting regardless of
# of whether "s1cancel" returns before or after the other step reports failure. # whether "s1cancel" finishes before or after the other step reports failure.
# Also, ensure the step after "s1cancel" is also an s1 step (use "s1noop" if # Also, ensure the step after "s1cancel" is also an s1 step (use "s1noop" if
# necessary). This ensures we won't move on to the next step until the cancel # necessary). This ensures we won't move on to the next step until the cancel
# is complete. # is complete.
...@@ -50,37 +50,37 @@ step s2commit { COMMIT; } ...@@ -50,37 +50,37 @@ step s2commit { COMMIT; }
# Try various things while the partition is in "being detached" state, with # Try various things while the partition is in "being detached" state, with
# no session waiting. # no session waiting.
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1describe s1alter permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1describe s1alter
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1insert s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1insert s1c
permutation s2snitch s1brr s1s s2detach(s1cancel) s1cancel s1insert s1c s1spart permutation s2snitch s1brr s1s s2detach s1cancel(s2detach) s1insert s1c s1spart
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1insertpart permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1insertpart
# Test partition descriptor caching # Test partition descriptor caching
permutation s2snitch s1b s1s s2detach2(s1cancel) s1cancel s1c s1brr s1insert s1s s1insert s1c permutation s2snitch s1b s1s s2detach2 s1cancel(s2detach2) s1c s1brr s1insert s1s s1insert s1c
permutation s2snitch s1b s1s s2detach2(s1cancel) s1cancel s1c s1brr s1s s1insert s1s s1c permutation s2snitch s1b s1s s2detach2 s1cancel(s2detach2) s1c s1brr s1s s1insert s1s s1c
# "drop" here does both tables # "drop" here does both tables
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1drop s1list permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1drop s1list
# "truncate" only does parent, not partition # "truncate" only does parent, not partition
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1trunc s1spart permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1trunc s1spart
# If a partition pending detach exists, we cannot drop another one # If a partition pending detach exists, we cannot drop another one
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1noop s2detach2 s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1noop s2detach2 s1c
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1noop s2detachfinal s1c s2detach2 permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1noop s2detachfinal s1c s2detach2
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1droppart s2detach2 permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1droppart s2detach2
# When a partition with incomplete detach is dropped, we grab lock on parent too. # When a partition with incomplete detach is dropped, we grab lock on parent too.
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s2begin s2drop s1s s2commit permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s2begin s2drop s1s s2commit
# Partially detach, then select and try to complete the detach. Reading # Partially detach, then select and try to complete the detach. Reading
# from partition blocks (AEL is required on partition); reading from parent # from partition blocks (AEL is required on partition); reading from parent
# does not block. # does not block.
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1b s1spart s2detachfinal s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1b s1spart s2detachfinal s1c
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1b s1s s2detachfinal s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1b s1s s2detachfinal s1c
# DETACH FINALIZE in a transaction block. No insert/select on the partition # DETACH FINALIZE in a transaction block. No insert/select on the partition
# is allowed concurrently with that. # is allowed concurrently with that.
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s1b s1spart s2detachfinal s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s1b s1spart s2detachfinal s1c
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s2begin s2detachfinal s2commit permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s2begin s2detachfinal s2commit
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s2begin s2detachfinal s1spart s2commit permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s2begin s2detachfinal s1spart s2commit
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1c s2begin s2detachfinal s1insertpart s2commit permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1c s2begin s2detachfinal s1insertpart s2commit
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
# that keeping both variants adds any extra coverage.) # that keeping both variants adds any extra coverage.)
# #
# Note: When using "s1cancel", mark the target step (the one to be canceled) # Note: When using "s1cancel", mark the target step (the one to be canceled)
# as being blocked by "s1cancel". This ensures consistent reporting regardless # as blocking "s1cancel". This ensures consistent reporting regardless of
# of whether "s1cancel" returns before or after the other step reports failure. # whether "s1cancel" finishes before or after the other step reports failure.
# Also, ensure the step after "s1cancel" is also an s1 step (use "s1noop" if # Also, ensure the step after "s1cancel" is also an s1 step (use "s1noop" if
# necessary). This ensures we won't move on to the next step until the cancel # necessary). This ensures we won't move on to the next step until the cancel
# is complete. # is complete.
...@@ -50,34 +50,34 @@ step s3commit { commit; } ...@@ -50,34 +50,34 @@ step s3commit { commit; }
step s3vacfreeze { vacuum freeze pg_catalog.pg_inherits; } step s3vacfreeze { vacuum freeze pg_catalog.pg_inherits; }
# Trying to insert into a partially detached partition is rejected # Trying to insert into a partially detached partition is rejected
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1insert s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1insert s1c
permutation s2snitch s1b s1s s2detach s1insert s1c permutation s2snitch s1b s1s s2detach s1insert s1c
# ... even under REPEATABLE READ mode. # ... even under REPEATABLE READ mode.
permutation s2snitch s1brr s1s s2detach(s1cancel) s1cancel s1insert s1c permutation s2snitch s1brr s1s s2detach s1cancel(s2detach) s1insert s1c
permutation s2snitch s1brr s1s s2detach s1insert s1c permutation s2snitch s1brr s1s s2detach s1insert s1c
# If you read the referenced table using a cursor, you can see a row that the # If you read the referenced table using a cursor, you can see a row that the
# RI query does not see. # RI query does not see.
permutation s2snitch s1b s1declare s2detach(s1cancel) s1cancel s1fetchall s1insert s1c permutation s2snitch s1b s1declare s2detach s1cancel(s2detach) s1fetchall s1insert s1c
permutation s2snitch s1b s1declare s2detach s1fetchall s1insert s1c permutation s2snitch s1b s1declare s2detach s1fetchall s1insert s1c
permutation s2snitch s1b s1declare s2detach(s1cancel) s1cancel s1svpt s1insert s1rollback s1fetchall s1c permutation s2snitch s1b s1declare s2detach s1cancel(s2detach) s1svpt s1insert s1rollback s1fetchall s1c
permutation s2snitch s1b s1declare s2detach s1svpt s1insert s1rollback s1fetchall s1c permutation s2snitch s1b s1declare s2detach s1svpt s1insert s1rollback s1fetchall s1c
permutation s2snitch s1b s2detach(s1cancel) s1declare s1cancel s1fetchall s1insert s1c permutation s2snitch s1b s2detach s1declare s1cancel(s2detach) s1fetchall s1insert s1c
permutation s2snitch s1b s2detach s1declare s1fetchall s1insert s1c permutation s2snitch s1b s2detach s1declare s1fetchall s1insert s1c
permutation s2snitch s1b s2detach(s1cancel) s1declare s1cancel s1svpt s1insert s1rollback s1fetchall s1c permutation s2snitch s1b s2detach s1declare s1cancel(s2detach) s1svpt s1insert s1rollback s1fetchall s1c
permutation s2snitch s1b s2detach s1declare s1svpt s1insert s1rollback s1fetchall s1c permutation s2snitch s1b s2detach s1declare s1svpt s1insert s1rollback s1fetchall s1c
# Creating the referencing row using a cursor # Creating the referencing row using a cursor
permutation s2snitch s1brr s1declare2 s1fetchone s2detach(s1cancel) s1cancel s1updcur s1c permutation s2snitch s1brr s1declare2 s1fetchone s2detach s1cancel(s2detach) s1updcur s1c
permutation s2snitch s1brr s1declare2 s1fetchone s2detach s1updcur s1c permutation s2snitch s1brr s1declare2 s1fetchone s2detach s1updcur s1c
permutation s2snitch s1brr s1declare2 s1fetchone s1updcur s2detach s1c permutation s2snitch s1brr s1declare2 s1fetchone s1updcur s2detach s1c
# Try reading the table from an independent session. # Try reading the table from an independent session.
permutation s2snitch s1b s1s s2detach s3insert s1c permutation s2snitch s1b s1s s2detach s3insert s1c
permutation s2snitch s1b s1s s2detach(s1cancel) s3brr s3insert s3commit s1cancel s1c permutation s2snitch s1b s1s s2detach s3brr s3insert s3commit s1cancel(s2detach) s1c
permutation s2snitch s1b s1s s2detach s3brr s3insert s3commit s1c permutation s2snitch s1b s1s s2detach s3brr s3insert s3commit s1c
# Try one where we VACUUM FREEZE pg_inherits (to verify that xmin change is # Try one where we VACUUM FREEZE pg_inherits (to verify that xmin change is
# handled correctly). # handled correctly).
permutation s2snitch s1brr s1s s2detach(s1cancel) s1cancel s1noop s3vacfreeze s1s s1insert s1c permutation s2snitch s1brr s1s s2detach s1cancel(s2detach) s1noop s3vacfreeze s1s s1insert s1c
permutation s2snitch s1b s1s s2detach(s1cancel) s1cancel s1noop s3vacfreeze s1s s1insert s1c permutation s2snitch s1b s1s s2detach s1cancel(s2detach) s1noop s3vacfreeze s1s s1insert s1c
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment