diff --git a/src/backend/distributed/connection/placement_connection.c b/src/backend/distributed/connection/placement_connection.c index 047fe041b..26d8287d9 100644 --- a/src/backend/distributed/connection/placement_connection.c +++ b/src/backend/distributed/connection/placement_connection.c @@ -341,8 +341,10 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList, ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("cannot perform DDL on a placement which has been read over " - "multiple connections"))); + errmsg( + "cannot perform DDL on placement %ld, which has been read over " + "multiple connections", + placement->placementId))); } else if (accessType == PLACEMENT_ACCESS_DDL && colocatedEntry != NULL && colocatedEntry->hasSecondaryConnections) @@ -358,8 +360,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList, ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("cannot perform DDL on a placement if a co-located placement " - "has been read over multiple connections"))); + errmsg("cannot perform DDL on placement %ld since a co-located " + "placement has been read over multiple connections", + placement->placementId))); } else if (foundModifyingConnection) { @@ -411,8 +414,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList, ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("cannot establish new placement connection when DDL has " - "been executed on existing placement connection"))); + errmsg("cannot establish a new connection for placement %ld, since " + "DDL has been executed on a connection that is in use", + placement->placementId))); } else if (placementConnection->hadDML) { @@ -432,8 +436,9 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList, ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("cannot establish new placement connection when DML has " - "been executed on existing placement connection"))); + errmsg("cannot establish a new connection for placement %ld, since " + "DML has been executed on a connection that is in use", + placement->placementId))); } else if (accessType == PLACEMENT_ACCESS_DDL) { @@ -450,7 +455,7 @@ StartPlacementListConnection(uint32 flags, List *placementAccessList, ereport(ERROR, (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"))); } else diff --git a/src/test/regress/expected/multi_alter_table_add_constraints.out b/src/test/regress/expected/multi_alter_table_add_constraints.out index 83618f48f..3192f1ad9 100644 --- a/src/test/regress/expected/multi_alter_table_add_constraints.out +++ b/src/test/regress/expected/multi_alter_table_add_constraints.out @@ -443,7 +443,7 @@ BEGIN; INSERT INTO products VALUES(1,'product_1', 5); -- DDL may error out after an INSERT because it might pick the wrong connection 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; BEGIN; -- Add constraints diff --git a/src/test/regress/expected/multi_insert_select.out b/src/test/regress/expected/multi_insert_select.out index 3f9b216a6..30184b38b 100644 --- a/src/test/regress/expected/multi_insert_select.out +++ b/src/test/regress/expected/multi_insert_select.out @@ -1645,7 +1645,7 @@ BEGIN; ALTER TABLE reference_table ADD COLUMN z int; INSERT INTO raw_events_first (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; -- Insert after copy is disallowed when the INSERT INTO ... SELECT chooses -- to use a connection for one shard, while the connection already modified @@ -1653,7 +1653,7 @@ ROLLBACK; BEGIN; COPY raw_events_second (user_id, value_1) FROM STDIN DELIMITER ','; 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; -- Insert after copy is currently allowed for single-shard operation. -- Both insert and copy are rolled back successfully. diff --git a/src/test/regress/expected/multi_modifying_xacts.out b/src/test/regress/expected/multi_modifying_xacts.out index 8eebdc5bf..f41fc45bb 100644 --- a/src/test/regress/expected/multi_modifying_xacts.out +++ b/src/test/regress/expected/multi_modifying_xacts.out @@ -205,7 +205,7 @@ BEGIN; INSERT INTO researchers VALUES (2, 1, 'Knuth Donald'); INSERT INTO researchers VALUES (10, 6, 'Lamport Leslie'); \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" ROLLBACK; -- 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) 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; -- multi-shard operations can co-exist with DDL in a transactional way BEGIN; @@ -1349,18 +1349,18 @@ JOIN USING (shardid) ORDER BY id; - id | shard_name | nodename | nodeport -----+---------------+-----------+---------- - 1 | users_1200022 | localhost | 57637 - 2 | users_1200025 | localhost | 57638 - 3 | users_1200023 | localhost | 57638 - 4 | users_1200023 | localhost | 57638 - 5 | users_1200022 | localhost | 57637 - 6 | users_1200024 | localhost | 57637 - 7 | users_1200023 | localhost | 57638 - 8 | users_1200022 | localhost | 57637 - 9 | users_1200025 | localhost | 57638 - 10 | users_1200022 | localhost | 57637 + id | shard_name | nodename | nodeport +----+----------------------+-----------+---------- + 1 | public.users_1200022 | localhost | 57637 + 2 | public.users_1200025 | localhost | 57638 + 3 | public.users_1200023 | localhost | 57638 + 4 | public.users_1200023 | localhost | 57638 + 5 | public.users_1200022 | localhost | 57637 + 6 | public.users_1200024 | localhost | 57637 + 7 | public.users_1200023 | localhost | 57638 + 8 | public.users_1200022 | localhost | 57637 + 9 | public.users_1200025 | localhost | 57638 + 10 | public.users_1200022 | localhost | 57637 (10 rows) END; @@ -1382,7 +1382,7 @@ BEGIN; INSERT INTO users VALUES (2, 'burak'); INSERT INTO users VALUES (3, 'burak'); \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; -- cannot perform DDL after a co-located table has been read over 1 connection BEGIN; @@ -1400,7 +1400,7 @@ SELECT id FROM users WHERE id = 6; ALTER TABLE items ADD COLUMN last_update timestamptz; 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; -- but the other way around is fine 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 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; BEGIN; -- 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 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; BEGIN; -- make a modification over connection 1