Parsed test spec with 4 sessions

starting permutation: add-node replicate-reference-tables s1-begin s2-begin s1-update-dist-table s2-lock-ref-table-placement-on-coordinator s1-lock-ref-table-placement-on-coordinator s2-update-dist-table deadlock-checker-call s1-end s2-end
create_distributed_table
---------------------------------------------------------------------

(1 row)

step add-node:
  SELECT 1 FROM master_add_node('localhost', 57636, groupid => 0);

?column?
---------------------------------------------------------------------
       1
(1 row)

step replicate-reference-tables:
  SELECT replicate_reference_tables(shard_transfer_mode := 'block_writes');

replicate_reference_tables
---------------------------------------------------------------------

(1 row)

step s1-begin:
    BEGIN;

step s2-begin:
    BEGIN;

step s1-update-dist-table:
    update dist_table set b = 2 where a = 1;

step s2-lock-ref-table-placement-on-coordinator:
    DO $$
      DECLARE refshardid int;
      BEGIN
        SELECT shardid INTO refshardid FROM pg_dist_shard WHERE logicalrelid='ref_table'::regclass;
        EXECUTE format('SELECT * from ref_table_%s FOR UPDATE', refshardid::text);
      END
    $$;

step s1-lock-ref-table-placement-on-coordinator:
    DO $$
      DECLARE refshardid int;
      BEGIN
        SELECT shardid INTO refshardid FROM pg_dist_shard WHERE logicalrelid='ref_table'::regclass;
        EXECUTE format('SELECT * from ref_table_%s FOR UPDATE', refshardid::text);
      END
    $$;
 <waiting ...>
step s2-update-dist-table: 
    update dist_table set b = 2 where a = 1;
 <waiting ...>
step deadlock-checker-call: 
  SELECT check_distributed_deadlocks();

check_distributed_deadlocks
---------------------------------------------------------------------
t
(1 row)

step s1-lock-ref-table-placement-on-coordinator: <... completed>
step s2-update-dist-table: <... completed>
ERROR:  canceling the transaction since it was involved in a distributed deadlock
step s1-end:
    END;

step s2-end:
    END;

master_remove_node
---------------------------------------------------------------------

(1 row)


starting permutation: add-node replicate-reference-tables s1-begin s2-begin s1-update-ref-table s2-sleep s2-view-dist s2-view-worker s2-end s1-end
create_distributed_table
---------------------------------------------------------------------

(1 row)

step add-node:
  SELECT 1 FROM master_add_node('localhost', 57636, groupid => 0);

?column?
---------------------------------------------------------------------
       1
(1 row)

step replicate-reference-tables:
  SELECT replicate_reference_tables(shard_transfer_mode := 'block_writes');

replicate_reference_tables
---------------------------------------------------------------------

(1 row)

step s1-begin:
    BEGIN;

step s2-begin:
    BEGIN;

step s1-update-ref-table:
    update ref_table set a = a + 1;

step s2-sleep:
 SELECT pg_sleep(0.5);

pg_sleep
---------------------------------------------------------------------

(1 row)

step s2-view-dist:
        SELECT query, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE backend_type = 'client backend' AND query NOT ILIKE ALL(VALUES('%pg_prepared_xacts%'), ('%COMMIT%'), ('%pg_isolation_test_session_is_blocked%'), ('%BEGIN%'), ('%add_node%')) ORDER BY query DESC;

query                                                                        |state              |wait_event_type|wait_event|usename |datname
---------------------------------------------------------------------

  SELECT replicate_reference_tables(shard_transfer_mode := 'block_writes');
|idle               |Client         |ClientRead|postgres|regression

  SELECT check_distributed_deadlocks();
                                    |idle               |Client         |ClientRead|postgres|regression

    update ref_table set a = a + 1;
                                        |idle in transaction|Client         |ClientRead|postgres|regression
(3 rows)

step s2-view-worker:
 SELECT query, state, wait_event_type, wait_event, usename, datname
    FROM citus_stat_activity
    WHERE query NOT ILIKE ALL(VALUES
      ('%application_name%'),
      ('%pg_prepared_xacts%'),
      ('%COMMIT%'),
      ('%dump_local_%'),
      ('%citus_internal.local_blocked_processes%'),
      ('%add_node%'),
      ('%csa_from_one_node%'),
      ('%pg_locks%'))
    AND is_worker_query = true
    AND backend_type = 'client backend'
    AND query != ''
    ORDER BY query DESC;

query                                                                         |state              |wait_event_type|wait_event|usename |datname
---------------------------------------------------------------------
UPDATE public.ref_table_1500877 ref_table SET a = (a OPERATOR(pg_catalog.+) 1)|idle in transaction|Client         |ClientRead|postgres|regression
UPDATE public.ref_table_1500877 ref_table SET a = (a OPERATOR(pg_catalog.+) 1)|idle in transaction|Client         |ClientRead|postgres|regression
(2 rows)

step s2-end:
    END;

step s1-end:
    END;

master_remove_node
---------------------------------------------------------------------

(1 row)


starting permutation: add-node replicate-reference-tables s1-begin s2-begin s1-update-ref-table s2-active-transactions s1-end s2-end
create_distributed_table
---------------------------------------------------------------------

(1 row)

step add-node:
  SELECT 1 FROM master_add_node('localhost', 57636, groupid => 0);

?column?
---------------------------------------------------------------------
       1
(1 row)

step replicate-reference-tables:
  SELECT replicate_reference_tables(shard_transfer_mode := 'block_writes');

replicate_reference_tables
---------------------------------------------------------------------

(1 row)

step s1-begin:
    BEGIN;

step s2-begin:
    BEGIN;

step s1-update-ref-table:
    update ref_table set a = a + 1;

step s2-active-transactions:
 -- Admin should be able to see all transactions
 SELECT count(*) FROM get_all_active_transactions() WHERE transaction_number != 0;
 SELECT count(*) FROM get_global_active_transactions() WHERE transaction_number != 0;

count
---------------------------------------------------------------------
    1
(1 row)

count
---------------------------------------------------------------------
    3
(1 row)

step s1-end:
    END;

step s2-end:
    END;

master_remove_node
---------------------------------------------------------------------

(1 row)

