Add back test for INSERT where all placements fail

Since we now short-circuit on certain remote errors, we want to ensure
we preserve the old behavior of not modifying any placement states if
a non-short-circuiting error occurs on all placements.
pull/552/head
Jason Petersen 2016-06-07 13:21:23 -06:00
parent 48f4e5d1a5
commit a19520b9bd
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
2 changed files with 73 additions and 4 deletions

View File

@ -274,8 +274,8 @@ CONTEXT: while executing command on localhost:57638
-- Test that shards which miss a modification are marked unhealthy
-- First: Connect to the second worker node
\c - - - :worker_2_port
-- Second: Drop limit_orders shard on the second worker node
DROP TABLE limit_orders_750000;
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE limit_orders_750000 RENAME TO renamed_orders;
-- Third: Connect back to master node
\c - - - :master_port
-- Fourth: Perform an INSERT on the remaining node
@ -302,6 +302,39 @@ AND s.logicalrelid = 'limit_orders'::regclass;
1
(1 row)
-- Test that if all shards miss a modification, no state change occurs
-- First: Connect to the first worker node
\c - - - :worker_1_port
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE limit_orders_750000 RENAME TO renamed_orders;
-- Third: Connect back to master node
\c - - - :master_port
-- Fourth: Perform an INSERT on the remaining node
INSERT INTO limit_orders VALUES (276, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67);
WARNING: relation "limit_orders_750000" does not exist
CONTEXT: while executing command on localhost:57637
ERROR: could not modify any active placements
-- Last: Verify worker is still healthy
SELECT count(*)
FROM pg_dist_shard_placement AS sp,
pg_dist_shard AS s
WHERE sp.shardid = s.shardid
AND sp.nodename = 'localhost'
AND sp.nodeport = :worker_1_port
AND sp.shardstate = 1
AND s.logicalrelid = 'limit_orders'::regclass;
count
-------
2
(1 row)
-- Undo our change...
-- First: Connect to the first worker node
\c - - - :worker_1_port
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE renamed_orders RENAME TO limit_orders_750000;
-- Third: Connect back to master node
\c - - - :master_port
-- commands with no constraints on the partition key are not supported
UPDATE limit_orders SET limit_price = 0.00;
ERROR: distributed modifications must target exactly one shard

View File

@ -199,8 +199,8 @@ INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell',
-- First: Connect to the second worker node
\c - - - :worker_2_port
-- Second: Drop limit_orders shard on the second worker node
DROP TABLE limit_orders_750000;
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE limit_orders_750000 RENAME TO renamed_orders;
-- Third: Connect back to master node
\c - - - :master_port
@ -210,6 +210,7 @@ INSERT INTO limit_orders VALUES (276, 'ADR', 140, '2007-07-02 16:32:15', 'sell',
-- Last: Verify the insert worked but the deleted placement is now unhealthy
SELECT count(*) FROM limit_orders WHERE id = 276;
SELECT count(*)
FROM pg_dist_shard_placement AS sp,
pg_dist_shard AS s
@ -219,6 +220,41 @@ AND sp.nodeport = :worker_2_port
AND sp.shardstate = 3
AND s.logicalrelid = 'limit_orders'::regclass;
-- Test that if all shards miss a modification, no state change occurs
-- First: Connect to the first worker node
\c - - - :worker_1_port
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE limit_orders_750000 RENAME TO renamed_orders;
-- Third: Connect back to master node
\c - - - :master_port
-- Fourth: Perform an INSERT on the remaining node
INSERT INTO limit_orders VALUES (276, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67);
-- Last: Verify worker is still healthy
SELECT count(*)
FROM pg_dist_shard_placement AS sp,
pg_dist_shard AS s
WHERE sp.shardid = s.shardid
AND sp.nodename = 'localhost'
AND sp.nodeport = :worker_1_port
AND sp.shardstate = 1
AND s.logicalrelid = 'limit_orders'::regclass;
-- Undo our change...
-- First: Connect to the first worker node
\c - - - :worker_1_port
-- Second: Move aside limit_orders shard on the second worker node
ALTER TABLE renamed_orders RENAME TO limit_orders_750000;
-- Third: Connect back to master node
\c - - - :master_port
-- commands with no constraints on the partition key are not supported
UPDATE limit_orders SET limit_price = 0.00;