SET citus.next_shard_id TO 1490000;
SELECT citus.mitmproxy('conn.allow()');
 mitmproxy
---------------------------------------------------------------------

(1 row)

SET citus.shard_replication_factor TO 2;
SET "citus.replication_model" to "statement";
SET citus.shard_count TO 4;
CREATE TABLE partitioned_table (
	dist_key bigint,
	partition_id integer
) PARTITION BY LIST (partition_id );
SELECT create_distributed_table('partitioned_table', 'dist_key');
 create_distributed_table
---------------------------------------------------------------------

(1 row)

CREATE TABLE partitioned_table_0
	PARTITION OF partitioned_table (dist_key, partition_id)
	FOR VALUES IN ( 0 );
INSERT INTO partitioned_table VALUES (0, 0);
SELECT citus.mitmproxy('conn.onQuery(query="^INSERT").kill()');
 mitmproxy
---------------------------------------------------------------------

(1 row)

INSERT INTO partitioned_table VALUES (0, 0);
WARNING:  connection error: localhost:xxxxx
DETAIL:  server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
-- use both placements
SET citus.task_assignment_policy TO "round-robin";
-- the results should be the same
SELECT count(*) FROM partitioned_table_0;
 count
---------------------------------------------------------------------
     2
(1 row)

SELECT count(*) FROM partitioned_table_0;
 count
---------------------------------------------------------------------
     2
(1 row)

SELECT count(*) FROM partitioned_table;
 count
---------------------------------------------------------------------
     2
(1 row)

SELECT count(*) FROM partitioned_table;
 count
---------------------------------------------------------------------
     2
(1 row)

-- ==== Clean up, we're done here ====
SELECT citus.mitmproxy('conn.allow()');
 mitmproxy
---------------------------------------------------------------------

(1 row)

DROP TABLE partitioned_table;
