case1.txt

text/plain

# Deadlock caused by leader worker, parallel worker, and backend.

## SCHEMA DEFINITIONS

[Publisher]

CREATE TABLE tbl1 (c int);
CREATE TABLE tbl2 (c1 int primary key, c2 int, c3 int);
CREATE PUBLICATION pub FOR ALL TABLES;

[Subscriber]
CREATE TABLE tbl1 (c int);
CREATE UNIQUE INDEX idx_tbl1 on tbl1(c)
CREATE TABLE tbl2 (c1 int primary key, c2 int, c3 int);
CREATE SUBSCRIPTION sub CONNECTION 'port=$port_N1 user=postgres' PUBLICATION pub WITH(streaming = 'parallel', copy_data = 'false', two_phase = 'on');


### WORKLOADS


Tx1 on publisher
BEGIN;
INSERT INTO tbl1 SELECT i FROM generate_series(1, 5000);

	Tx2 on subscriber
	BEGIN;
	INSERT INTO tbl2 VALUES (1, 2, 3);
	INSERT INTO tbl1 VALUES (1);

		Tx3 on publisher
		BEGIN;
		INSERT INTO tbl2 VALUES(1, 2, 3);
		COMMIT;


### RESULTS

Followings were copied from log on subscriber.

```
ERROR:  deadlock detected
DETAIL:  Process (LA) waits for ShareLock on transaction 743; blocked by process (Backend).
        Process (Backend) waits for ShareLock on transaction 742; blocked by process (PA).
        Process (PA) waits for AccessShareLock on object 16393 of class 6100 of database 0; blocked by process (LA).
        Process (LA): <command string not enabled>
        Process (Backend): INSERT INTO tbl1 VALUES (1);
        Process (PA): <command string not enabled>
```