From fa5e202403867f5ac4d0733f1ba3765f9c213191 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 6 Dec 2016 20:03:47 -0800 Subject: [PATCH] Convert multi_shard_transaction.[ch] to new framework. --- src/backend/distributed/shared_library_init.c | 2 - .../transaction/multi_shard_transaction.c | 141 ++++---------- .../transaction/transaction_management.c | 15 ++ .../distributed/multi_shard_transaction.h | 2 +- .../regress/expected/multi_insert_select.out | 175 ------------------ .../expected/multi_join_order_additional.out | 2 - .../regress/expected/multi_shard_modify.out | 4 - .../multi_alter_table_statements.source | 7 +- 8 files changed, 54 insertions(+), 294 deletions(-) diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 60c4f3656..3f092d3d3 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -31,7 +31,6 @@ #include "distributed/multi_router_executor.h" #include "distributed/multi_router_planner.h" #include "distributed/multi_server_executor.h" -#include "distributed/multi_shard_transaction.h" #include "distributed/multi_utility.h" #include "distributed/remote_commands.h" #include "distributed/task_tracker.h" @@ -163,7 +162,6 @@ _PG_init(void) /* initialize transaction callbacks */ RegisterRouterExecutorXactCallbacks(); - RegisterShardPlacementXactCallbacks(); /* enable modification of pg_catalog tables during pg_upgrade */ if (IsBinaryUpgrade) diff --git a/src/backend/distributed/transaction/multi_shard_transaction.c b/src/backend/distributed/transaction/multi_shard_transaction.c index 9f3d15c0f..f62507af8 100644 --- a/src/backend/distributed/transaction/multi_shard_transaction.c +++ b/src/backend/distributed/transaction/multi_shard_transaction.c @@ -30,14 +30,8 @@ #define INITIAL_CONNECTION_CACHE_SIZE 1001 -/* Global variables used in commit handler */ +/* per-transaction state */ static HTAB *shardConnectionHash = NULL; -static bool subXactAbortAttempted = false; - -/* functions needed by callbacks and hooks */ -static void CompleteShardPlacementTransactions(XactEvent event, void *arg); -static void MultiShardSubXactCallback(SubXactEvent event, SubTransactionId subId, - SubTransactionId parentSubid, void *arg); /* @@ -118,6 +112,12 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName) UINT64_FORMAT, shardId))); } + BeginOrContinueCoordinatedTransaction(); + if (MultiShardCommitProtocol == COMMIT_PROTOCOL_2PC) + { + CoordinatedTransactionUse2PC(); + } + /* get existing connections to the shard placements, if any */ shardConnections = GetShardConnections(shardId, &shardConnectionsFound); if (shardConnectionsFound) @@ -129,11 +129,11 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName) foreach(placementCell, shardPlacementList) { ShardPlacement *shardPlacement = (ShardPlacement *) lfirst(placementCell); - PGconn *connection = NULL; + MultiConnection *connection = NULL; TransactionConnection *transactionConnection = NULL; WorkerNode *workerNode = FindWorkerNode(shardPlacement->nodeName, shardPlacement->nodePort); - PGresult *result = NULL; + int connectionFlags = FORCE_NEW_CONNECTION; if (workerNode == NULL) { @@ -141,10 +141,13 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName) shardPlacement->nodeName, shardPlacement->nodePort))); } - connection = ConnectToNode(shardPlacement->nodeName, shardPlacement->nodePort, - userName); - - if (connection == NULL) + /* XXX: It'd be nicer to establish connections asynchronously here */ + connection = GetNodeUserDatabaseConnection(connectionFlags, + shardPlacement->nodeName, + shardPlacement->nodePort, + userName, + NULL); + if (PQstatus(connection->pgConn) != CONNECTION_OK) { ereport(ERROR, (errmsg("could not establish a connection to all " "placements of shard %lu", shardId))); @@ -158,7 +161,7 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName) transactionConnection->groupId = workerNode->groupId; transactionConnection->connectionId = shardConnections->shardId; transactionConnection->transactionState = TRANSACTION_STATE_OPEN; - transactionConnection->connection = connection; + transactionConnection->connection = connection->pgConn; transactionConnection->nodeName = shardPlacement->nodeName; transactionConnection->nodePort = shardPlacement->nodePort; @@ -167,12 +170,14 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName) MemoryContextSwitchTo(oldContext); - /* now that connection is tracked, issue BEGIN */ - result = PQexec(connection, "BEGIN"); - if (PQresultStatus(result) != PGRES_COMMAND_OK) - { - ReraiseRemoteError(connection, result); - } + /* + * Every individual failure should cause entire distributed + * transaction to fail. + */ + MarkRemoteTransactionCritical(connection); + + /* issue BEGIN */ + RemoteTransactionBegin(connection); } } @@ -253,98 +258,18 @@ ConnectionList(HTAB *connectionHash) /* - * RegisterShardPlacementXactCallbacks registers transaction callbacks needed - * for multi-shard transactions. + * ResetShardPlacementTransactionState performs cleanup after the end of a + * transaction. */ void -RegisterShardPlacementXactCallbacks(void) +ResetShardPlacementTransactionState(void) { - RegisterXactCallback(CompleteShardPlacementTransactions, NULL); - RegisterSubXactCallback(MultiShardSubXactCallback, NULL); -} - - -/* - * CompleteShardPlacementTransactions commits or aborts pending shard placement - * transactions when the local transaction commits or aborts. - */ -static void -CompleteShardPlacementTransactions(XactEvent event, void *arg) -{ - List *connectionList = ConnectionList(shardConnectionHash); - - if (shardConnectionHash == NULL) - { - /* nothing to do */ - return; - } - - if (event == XACT_EVENT_PRE_COMMIT) - { - if (subXactAbortAttempted) - { - subXactAbortAttempted = false; - - ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot ROLLBACK TO SAVEPOINT in transactions " - "which modify distributed tables"))); - } - - /* - * Any failure here will cause local changes to be rolled back, - * and remote changes to either roll back (1PC) or, in case of - * connection or node failure, leave a prepared transaction - * (2PC). - */ - - if (MultiShardCommitProtocol == COMMIT_PROTOCOL_2PC) - { - PrepareRemoteTransactions(connectionList); - } - - return; - } - else if (event == XACT_EVENT_COMMIT) - { - /* - * A failure here will cause some remote changes to either - * roll back (1PC) or, in case of connection or node failure, - * leave a prepared transaction (2PC). However, the local - * changes have already been committed. - */ - - CommitRemoteTransactions(connectionList, false); - } - else if (event == XACT_EVENT_ABORT) - { - /* - * A failure here will cause some remote changes to either - * roll back (1PC) or, in case of connection or node failure, - * leave a prepared transaction (2PC). The local changes have - * already been rolled back. - */ - - AbortRemoteTransactions(connectionList); - } - else - { - return; - } - - CloseConnections(connectionList); + /* + * Now that transaction management does most of our work, nothing remains + * but to reset the connection hash, which wouldn't be valid next time + * round. + */ shardConnectionHash = NULL; - subXactAbortAttempted = false; -} - - -static void -MultiShardSubXactCallback(SubXactEvent event, SubTransactionId subId, - SubTransactionId parentSubid, void *arg) -{ - if ((shardConnectionHash != NULL) && (event == SUBXACT_EVENT_ABORT_SUB)) - { - subXactAbortAttempted = true; - } } diff --git a/src/backend/distributed/transaction/transaction_management.c b/src/backend/distributed/transaction/transaction_management.c index a14d4b98f..0dadbd0c9 100644 --- a/src/backend/distributed/transaction/transaction_management.c +++ b/src/backend/distributed/transaction/transaction_management.c @@ -21,6 +21,7 @@ #include "access/xact.h" #include "distributed/connection_management.h" #include "distributed/hash_helpers.h" +#include "distributed/multi_shard_transaction.h" #include "distributed/transaction_management.h" #include "utils/hsearch.h" #include "utils/guc.h" @@ -140,6 +141,13 @@ CoordinatedTransactionCallback(XactEvent event, void *arg) { case XACT_EVENT_COMMIT: { + /* + * Call other parts of citus that need to integrate into + * transaction management. Do so before doing other work, so the + * callbacks still can perform work if needed. + */ + ResetShardPlacementTransactionState(); + if (CurrentCoordinatedTransactionState == COORD_TRANS_PREPARED) { /* handles both already prepared and open transactions */ @@ -168,6 +176,13 @@ CoordinatedTransactionCallback(XactEvent event, void *arg) * XACT_EVENT_PRE_COMMIT state. */ + /* + * Call other parts of citus that need to integrate into + * transaction management. Do so before doing other work, so the + * callbacks still can perform work if needed. + */ + ResetShardPlacementTransactionState(); + /* handles both already prepared and open transactions */ if (CurrentCoordinatedTransactionState > COORD_TRANS_IDLE) { diff --git a/src/include/distributed/multi_shard_transaction.h b/src/include/distributed/multi_shard_transaction.h index 4b5ec354a..95dd29d32 100644 --- a/src/include/distributed/multi_shard_transaction.h +++ b/src/include/distributed/multi_shard_transaction.h @@ -33,7 +33,7 @@ extern ShardConnections * GetShardHashConnections(HTAB *connectionHash, int64 sh bool *connectionsFound); extern List * ConnectionList(HTAB *connectionHash); extern void CloseConnections(List *connectionList); -extern void RegisterShardPlacementXactCallbacks(void); +extern void ResetShardPlacementTransactionState(void); #endif /* MULTI_SHARD_TRANSACTION_H */ diff --git a/src/test/regress/expected/multi_insert_select.out b/src/test/regress/expected/multi_insert_select.out index 4bcc20e00..7d675b60e 100644 --- a/src/test/regress/expected/multi_insert_select.out +++ b/src/test/regress/expected/multi_insert_select.out @@ -80,14 +80,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- see that our first multi shard INSERT...SELECT works expected SET client_min_messages TO INFO; DEBUG: StartTransactionCommand @@ -283,14 +275,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 user_id | time | value_1 | value_2 | value_3 | value_4 ---------+------+---------+---------+---------+--------- 9 | | 90 | | 9000 | @@ -363,14 +347,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- group by column not exists on the SELECT target list INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, user_id) SELECT @@ -574,14 +550,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- add one more level subqueris on top of subquery JOINs INSERT INTO agg_events (user_id, value_4_agg) @@ -659,14 +627,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- subqueries in WHERE clause INSERT INTO raw_events_second (user_id) @@ -711,14 +671,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- some UPSERTS INSERT INTO agg_events AS ae ( @@ -758,14 +710,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- upserts with returning INSERT INTO agg_events AS ae ( @@ -806,14 +750,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 user_id | value_1_agg ---------+------------- 7 | @@ -848,14 +784,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- FILTER CLAUSE INSERT INTO agg_events (user_id, value_1_agg) SELECT @@ -886,14 +814,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- a test with reference table JOINs INSERT INTO agg_events (user_id, value_1_agg) @@ -929,14 +849,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- a note on the outer joins is that -- we filter out outer join results -- where partition column returns @@ -1024,14 +936,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 SET client_min_messages TO INFO; DEBUG: StartTransactionCommand DEBUG: StartTransaction @@ -1094,14 +998,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- we don't want to see constraint vialotions, so truncate first SET client_min_messages TO INFO; DEBUG: StartTransactionCommand @@ -1168,14 +1064,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 -- We do not support any set operations INSERT INTO raw_events_first(user_id) @@ -1547,14 +1435,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 SET client_min_messages TO INFO; DEBUG: StartTransactionCommand DEBUG: StartTransaction @@ -1695,13 +1575,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300001 -DEBUG: sent COMMIT over connection 13300000 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300002 -DEBUG: sent COMMIT over connection 13300003 -DEBUG: sent COMMIT over connection 13300003 SET client_min_messages TO INFO; DEBUG: StartTransactionCommand DEBUG: StartTransaction @@ -1784,10 +1657,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- see that defaults are filled INSERT INTO table_with_defaults (store_id, first_name) SELECT @@ -1806,10 +1675,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- shuffle one of the defaults and skip the other INSERT INTO table_with_defaults (default_2, store_id, first_name) SELECT @@ -1828,10 +1693,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- shuffle both defaults INSERT INTO table_with_defaults (default_2, store_id, default_1, first_name) SELECT @@ -1850,10 +1711,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- use constants instead of non-default column INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name) SELECT @@ -1872,10 +1729,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- use constants instead of non-default column and skip both defauls INSERT INTO table_with_defaults (last_name, store_id, first_name) SELECT @@ -1894,10 +1747,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- use constants instead of default columns INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name, default_1) SELECT @@ -1916,10 +1765,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- use constants instead of both default columns and non-default columns INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name, default_1) SELECT @@ -1938,10 +1783,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- some of the the ultimate queries where we have constants, -- defaults and group by entry is not on the target entry INSERT INTO table_with_defaults (default_2, store_id, first_name) @@ -1963,10 +1804,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 INSERT INTO table_with_defaults (default_1, store_id, first_name, default_2) SELECT 1000, store_id, 'Andres', '2000' @@ -1986,10 +1823,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 INSERT INTO table_with_defaults (default_1, store_id, first_name, default_2) SELECT 1000, store_id, 'Andres', '2000' @@ -2009,10 +1842,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 INSERT INTO table_with_defaults (default_1, store_id, first_name) SELECT 1000, store_id, 'Andres' @@ -2032,10 +1861,6 @@ DEBUG: Plan is router executable DEBUG: CommitTransactionCommand DEBUG: CommitTransaction DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300013 -DEBUG: sent COMMIT over connection 13300014 -DEBUG: sent COMMIT over connection 13300014 -- set back to the default SET citus.shard_count TO DEFAULT; DEBUG: StartTransactionCommand diff --git a/src/test/regress/expected/multi_join_order_additional.out b/src/test/regress/expected/multi_join_order_additional.out index 2d9090150..7cebe1ec9 100644 --- a/src/test/regress/expected/multi_join_order_additional.out +++ b/src/test/regress/expected/multi_join_order_additional.out @@ -45,8 +45,6 @@ CREATE INDEX lineitem_hash_time_index ON lineitem_hash (l_shipdate); NOTICE: using one-phase commit for distributed DDL commands HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' DEBUG: building index "lineitem_hash_time_index" on table "lineitem_hash" -DEBUG: sent COMMIT over connection 650000 -DEBUG: sent COMMIT over connection 650001 CREATE TABLE orders_hash ( o_orderkey bigint not null, o_custkey integer not null, diff --git a/src/test/regress/expected/multi_shard_modify.out b/src/test/regress/expected/multi_shard_modify.out index 328b6ce33..f0ae3bc1d 100644 --- a/src/test/regress/expected/multi_shard_modify.out +++ b/src/test/regress/expected/multi_shard_modify.out @@ -119,10 +119,6 @@ SELECT master_modify_multiple_shards('DELETE FROM multi_shard_modify_test WHERE DEBUG: predicate pruning for shardId 350001 DEBUG: predicate pruning for shardId 350002 DEBUG: predicate pruning for shardId 350003 -DEBUG: sent PREPARE TRANSACTION over connection 350000 -DEBUG: sent PREPARE TRANSACTION over connection 350000 -DEBUG: sent COMMIT PREPARED over connection 350000 -DEBUG: sent COMMIT PREPARED over connection 350000 master_modify_multiple_shards ------------------------------- 1 diff --git a/src/test/regress/output/multi_alter_table_statements.source b/src/test/regress/output/multi_alter_table_statements.source index 93a826c4a..4ecd9ab33 100644 --- a/src/test/regress/output/multi_alter_table_statements.source +++ b/src/test/regress/output/multi_alter_table_statements.source @@ -559,7 +559,7 @@ COMMIT; WARNING: duplicate key value violates unique constraint "ddl_commands_command_key" DETAIL: Key (command)=(CREATE INDEX) already exists. CONTEXT: while executing command on localhost:57638 -ERROR: failed to prepare transaction +ERROR: failure on connection marked as essential: localhost:57638 -- Nothing from the block should have committed SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items'; indexname | tablename @@ -574,7 +574,10 @@ NOTICE: using one-phase commit for distributed DDL commands HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' CREATE INDEX single_index_3 ON single_shard_items(name); COMMIT; -WARNING: failed to commit transaction on localhost:57638 +WARNING: duplicate key value violates unique constraint "ddl_commands_command_key" +DETAIL: Key (command)=(CREATE INDEX) already exists. +CONTEXT: while executing command on localhost:57638 +WARNING: failed to commit critical transaction on localhost:57638, metadata is likely out of sync -- The block should have committed with a warning SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items'; indexname | tablename