Clarify placement connection error messages

pull/1455/head
Marco Slot 2017-07-07 17:08:57 +02:00
parent d3785b97c0
commit 9f7e4769e2
4 changed files with 35 additions and 30 deletions

View File

@ -341,8 +341,10 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot perform DDL on a placement which has been read over " errmsg(
"multiple connections"))); "cannot perform DDL on placement %ld, which has been read over "
"multiple connections",
placement->placementId)));
} }
else if (accessType == PLACEMENT_ACCESS_DDL && colocatedEntry != NULL && else if (accessType == PLACEMENT_ACCESS_DDL && colocatedEntry != NULL &&
colocatedEntry->hasSecondaryConnections) colocatedEntry->hasSecondaryConnections)
@ -358,8 +360,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot perform DDL on a placement if a co-located placement " errmsg("cannot perform DDL on placement %ld since a co-located "
"has been read over multiple connections"))); "placement has been read over multiple connections",
placement->placementId)));
} }
else if (foundModifyingConnection) else if (foundModifyingConnection)
{ {
@ -411,8 +414,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot establish new placement connection when DDL has " errmsg("cannot establish a new connection for placement %ld, since "
"been executed on existing placement connection"))); "DDL has been executed on a connection that is in use",
placement->placementId)));
} }
else if (placementConnection->hadDML) else if (placementConnection->hadDML)
{ {
@ -432,8 +436,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot establish new placement connection when DML has " errmsg("cannot establish a new connection for placement %ld, since "
"been executed on existing placement connection"))); "DML has been executed on a connection that is in use",
placement->placementId)));
} }
else if (accessType == PLACEMENT_ACCESS_DDL) else if (accessType == PLACEMENT_ACCESS_DDL)
{ {
@ -450,7 +455,7 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot perform parallel DDL command because multiple " errmsg("cannot perform a parallel DDL command because multiple "
"placements have been accessed over the same connection"))); "placements have been accessed over the same connection")));
} }
else else

View File

@ -443,7 +443,7 @@ BEGIN;
INSERT INTO products VALUES(1,'product_1', 5); INSERT INTO products VALUES(1,'product_1', 5);
-- DDL may error out after an INSERT because it might pick the wrong connection -- DDL may error out after an INSERT because it might pick the wrong connection
ALTER TABLE products ADD CONSTRAINT unn_pno UNIQUE(product_no); ALTER TABLE products ADD CONSTRAINT unn_pno UNIQUE(product_no);
ERROR: cannot establish new placement connection when DML has been executed on existing placement connection ERROR: cannot establish a new connection for placement 2327, since DML has been executed on a connection that is in use
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
-- Add constraints -- Add constraints

View File

@ -1645,7 +1645,7 @@ BEGIN;
ALTER TABLE reference_table ADD COLUMN z int; ALTER TABLE reference_table ADD COLUMN z int;
INSERT INTO raw_events_first (user_id) INSERT INTO raw_events_first (user_id)
SELECT user_id FROM raw_events_second JOIN reference_table USING (user_id); SELECT user_id FROM raw_events_second JOIN reference_table USING (user_id);
ERROR: cannot establish new placement connection when DDL has been executed on existing placement connection ERROR: cannot establish a new connection for placement 655, since DDL has been executed on a connection that is in use
ROLLBACK; ROLLBACK;
-- Insert after copy is disallowed when the INSERT INTO ... SELECT chooses -- Insert after copy is disallowed when the INSERT INTO ... SELECT chooses
-- to use a connection for one shard, while the connection already modified -- to use a connection for one shard, while the connection already modified
@ -1653,7 +1653,7 @@ ROLLBACK;
BEGIN; BEGIN;
COPY raw_events_second (user_id, value_1) FROM STDIN DELIMITER ','; COPY raw_events_second (user_id, value_1) FROM STDIN DELIMITER ',';
INSERT INTO raw_events_first SELECT * FROM raw_events_second; INSERT INTO raw_events_first SELECT * FROM raw_events_second;
ERROR: cannot establish new placement connection when DML has been executed on existing placement connection ERROR: cannot establish a new connection for placement 636, since DML has been executed on a connection that is in use
ROLLBACK; ROLLBACK;
-- Insert after copy is currently allowed for single-shard operation. -- Insert after copy is currently allowed for single-shard operation.
-- Both insert and copy are rolled back successfully. -- Both insert and copy are rolled back successfully.

View File

@ -205,7 +205,7 @@ BEGIN;
INSERT INTO researchers VALUES (2, 1, 'Knuth Donald'); INSERT INTO researchers VALUES (2, 1, 'Knuth Donald');
INSERT INTO researchers VALUES (10, 6, 'Lamport Leslie'); INSERT INTO researchers VALUES (10, 6, 'Lamport Leslie');
\copy researchers from stdin delimiter ',' \copy researchers from stdin delimiter ','
ERROR: cannot establish new placement connection when DML has been executed on existing placement connection ERROR: cannot establish a new connection for placement 2704, since DML has been executed on a connection that is in use
CONTEXT: COPY researchers, line 2: "10,6,Lesport Lampie" CONTEXT: COPY researchers, line 2: "10,6,Lesport Lampie"
ROLLBACK; ROLLBACK;
-- after a COPY you can modify multiple shards, since they'll use different connections -- after a COPY you can modify multiple shards, since they'll use different connections
@ -403,7 +403,7 @@ SELECT lab_id FROM researchers WHERE lab_id = 2 AND id = 0;
(0 rows) (0 rows)
ALTER TABLE researchers ADD COLUMN motto text; ALTER TABLE researchers ADD COLUMN motto text;
ERROR: cannot perform parallel DDL command because multiple placements have been accessed over the same connection ERROR: cannot perform a parallel DDL command because multiple placements have been accessed over the same connection
ROLLBACK; ROLLBACK;
-- multi-shard operations can co-exist with DDL in a transactional way -- multi-shard operations can co-exist with DDL in a transactional way
BEGIN; BEGIN;
@ -1350,17 +1350,17 @@ USING (shardid)
ORDER BY ORDER BY
id; id;
id | shard_name | nodename | nodeport id | shard_name | nodename | nodeport
----+---------------+-----------+---------- ----+----------------------+-----------+----------
1 | users_1200022 | localhost | 57637 1 | public.users_1200022 | localhost | 57637
2 | users_1200025 | localhost | 57638 2 | public.users_1200025 | localhost | 57638
3 | users_1200023 | localhost | 57638 3 | public.users_1200023 | localhost | 57638
4 | users_1200023 | localhost | 57638 4 | public.users_1200023 | localhost | 57638
5 | users_1200022 | localhost | 57637 5 | public.users_1200022 | localhost | 57637
6 | users_1200024 | localhost | 57637 6 | public.users_1200024 | localhost | 57637
7 | users_1200023 | localhost | 57638 7 | public.users_1200023 | localhost | 57638
8 | users_1200022 | localhost | 57637 8 | public.users_1200022 | localhost | 57637
9 | users_1200025 | localhost | 57638 9 | public.users_1200025 | localhost | 57638
10 | users_1200022 | localhost | 57637 10 | public.users_1200022 | localhost | 57637
(10 rows) (10 rows)
END; END;
@ -1382,7 +1382,7 @@ BEGIN;
INSERT INTO users VALUES (2, 'burak'); INSERT INTO users VALUES (2, 'burak');
INSERT INTO users VALUES (3, 'burak'); INSERT INTO users VALUES (3, 'burak');
\COPY items FROM STDIN WITH CSV \COPY items FROM STDIN WITH CSV
ERROR: cannot establish new placement connection when DML has been executed on existing placement connection ERROR: cannot establish a new connection for placement 2743, since DML has been executed on a connection that is in use
END; END;
-- cannot perform DDL after a co-located table has been read over 1 connection -- cannot perform DDL after a co-located table has been read over 1 connection
BEGIN; BEGIN;
@ -1400,7 +1400,7 @@ SELECT id FROM users WHERE id = 6;
ALTER TABLE items ADD COLUMN last_update timestamptz; ALTER TABLE items ADD COLUMN last_update timestamptz;
NOTICE: using one-phase commit for distributed DDL commands NOTICE: using one-phase commit for distributed DDL commands
ERROR: cannot perform parallel DDL command because multiple placements have been accessed over the same connection ERROR: cannot perform a parallel DDL command because multiple placements have been accessed over the same connection
END; END;
-- but the other way around is fine -- but the other way around is fine
BEGIN; BEGIN;
@ -1434,7 +1434,7 @@ SELECT user_id FROM items JOIN itemgroups ON (item_group = gid) WHERE user_id =
-- perform a DDL command on the reference table -- perform a DDL command on the reference table
ALTER TABLE itemgroups ADD COLUMN last_update timestamptz; ALTER TABLE itemgroups ADD COLUMN last_update timestamptz;
ERROR: cannot perform DDL on a placement which has been read over multiple connections ERROR: cannot perform DDL on placement 2737, which has been read over multiple connections
END; END;
BEGIN; BEGIN;
-- establish multiple connections to a node -- establish multiple connections to a node
@ -1452,7 +1452,7 @@ SELECT user_id FROM items JOIN itemgroups ON (item_group = gid) WHERE user_id =
-- perform a DDL command on a co-located reference table -- perform a DDL command on a co-located reference table
ALTER TABLE usergroups ADD COLUMN last_update timestamptz; ALTER TABLE usergroups ADD COLUMN last_update timestamptz;
ERROR: cannot perform DDL on a placement if a co-located placement has been read over multiple connections ERROR: cannot perform DDL on placement 2735 since a co-located placement has been read over multiple connections
END; END;
BEGIN; BEGIN;
-- make a modification over connection 1 -- make a modification over connection 1