Convert multi_shard_transaction.[ch] to new framework.

pull/1020/head
Andres Freund 2016-12-06 20:03:47 -08:00
parent fc298ec095
commit fa5e202403
8 changed files with 54 additions and 294 deletions

View File

@ -31,7 +31,6 @@
#include "distributed/multi_router_executor.h" #include "distributed/multi_router_executor.h"
#include "distributed/multi_router_planner.h" #include "distributed/multi_router_planner.h"
#include "distributed/multi_server_executor.h" #include "distributed/multi_server_executor.h"
#include "distributed/multi_shard_transaction.h"
#include "distributed/multi_utility.h" #include "distributed/multi_utility.h"
#include "distributed/remote_commands.h" #include "distributed/remote_commands.h"
#include "distributed/task_tracker.h" #include "distributed/task_tracker.h"
@ -163,7 +162,6 @@ _PG_init(void)
/* initialize transaction callbacks */ /* initialize transaction callbacks */
RegisterRouterExecutorXactCallbacks(); RegisterRouterExecutorXactCallbacks();
RegisterShardPlacementXactCallbacks();
/* enable modification of pg_catalog tables during pg_upgrade */ /* enable modification of pg_catalog tables during pg_upgrade */
if (IsBinaryUpgrade) if (IsBinaryUpgrade)

View File

@ -30,14 +30,8 @@
#define INITIAL_CONNECTION_CACHE_SIZE 1001 #define INITIAL_CONNECTION_CACHE_SIZE 1001
/* Global variables used in commit handler */ /* per-transaction state */
static HTAB *shardConnectionHash = NULL; 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))); UINT64_FORMAT, shardId)));
} }
BeginOrContinueCoordinatedTransaction();
if (MultiShardCommitProtocol == COMMIT_PROTOCOL_2PC)
{
CoordinatedTransactionUse2PC();
}
/* get existing connections to the shard placements, if any */ /* get existing connections to the shard placements, if any */
shardConnections = GetShardConnections(shardId, &shardConnectionsFound); shardConnections = GetShardConnections(shardId, &shardConnectionsFound);
if (shardConnectionsFound) if (shardConnectionsFound)
@ -129,11 +129,11 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName)
foreach(placementCell, shardPlacementList) foreach(placementCell, shardPlacementList)
{ {
ShardPlacement *shardPlacement = (ShardPlacement *) lfirst(placementCell); ShardPlacement *shardPlacement = (ShardPlacement *) lfirst(placementCell);
PGconn *connection = NULL; MultiConnection *connection = NULL;
TransactionConnection *transactionConnection = NULL; TransactionConnection *transactionConnection = NULL;
WorkerNode *workerNode = FindWorkerNode(shardPlacement->nodeName, WorkerNode *workerNode = FindWorkerNode(shardPlacement->nodeName,
shardPlacement->nodePort); shardPlacement->nodePort);
PGresult *result = NULL; int connectionFlags = FORCE_NEW_CONNECTION;
if (workerNode == NULL) if (workerNode == NULL)
{ {
@ -141,10 +141,13 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName)
shardPlacement->nodeName, shardPlacement->nodePort))); shardPlacement->nodeName, shardPlacement->nodePort)));
} }
connection = ConnectToNode(shardPlacement->nodeName, shardPlacement->nodePort, /* XXX: It'd be nicer to establish connections asynchronously here */
userName); connection = GetNodeUserDatabaseConnection(connectionFlags,
shardPlacement->nodeName,
if (connection == NULL) shardPlacement->nodePort,
userName,
NULL);
if (PQstatus(connection->pgConn) != CONNECTION_OK)
{ {
ereport(ERROR, (errmsg("could not establish a connection to all " ereport(ERROR, (errmsg("could not establish a connection to all "
"placements of shard %lu", shardId))); "placements of shard %lu", shardId)));
@ -158,7 +161,7 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName)
transactionConnection->groupId = workerNode->groupId; transactionConnection->groupId = workerNode->groupId;
transactionConnection->connectionId = shardConnections->shardId; transactionConnection->connectionId = shardConnections->shardId;
transactionConnection->transactionState = TRANSACTION_STATE_OPEN; transactionConnection->transactionState = TRANSACTION_STATE_OPEN;
transactionConnection->connection = connection; transactionConnection->connection = connection->pgConn;
transactionConnection->nodeName = shardPlacement->nodeName; transactionConnection->nodeName = shardPlacement->nodeName;
transactionConnection->nodePort = shardPlacement->nodePort; transactionConnection->nodePort = shardPlacement->nodePort;
@ -167,12 +170,14 @@ BeginTransactionOnShardPlacements(uint64 shardId, char *userName)
MemoryContextSwitchTo(oldContext); MemoryContextSwitchTo(oldContext);
/* now that connection is tracked, issue BEGIN */ /*
result = PQexec(connection, "BEGIN"); * Every individual failure should cause entire distributed
if (PQresultStatus(result) != PGRES_COMMAND_OK) * transaction to fail.
{ */
ReraiseRemoteError(connection, result); MarkRemoteTransactionCritical(connection);
}
/* issue BEGIN */
RemoteTransactionBegin(connection);
} }
} }
@ -253,98 +258,18 @@ ConnectionList(HTAB *connectionHash)
/* /*
* RegisterShardPlacementXactCallbacks registers transaction callbacks needed * ResetShardPlacementTransactionState performs cleanup after the end of a
* for multi-shard transactions. * transaction.
*/ */
void 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, * Now that transaction management does most of our work, nothing remains
* and remote changes to either roll back (1PC) or, in case of * but to reset the connection hash, which wouldn't be valid next time
* connection or node failure, leave a prepared transaction * round.
* (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);
shardConnectionHash = NULL; 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;
}
} }

View File

@ -21,6 +21,7 @@
#include "access/xact.h" #include "access/xact.h"
#include "distributed/connection_management.h" #include "distributed/connection_management.h"
#include "distributed/hash_helpers.h" #include "distributed/hash_helpers.h"
#include "distributed/multi_shard_transaction.h"
#include "distributed/transaction_management.h" #include "distributed/transaction_management.h"
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/guc.h" #include "utils/guc.h"
@ -140,6 +141,13 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
{ {
case XACT_EVENT_COMMIT: 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) if (CurrentCoordinatedTransactionState == COORD_TRANS_PREPARED)
{ {
/* handles both already prepared and open transactions */ /* handles both already prepared and open transactions */
@ -168,6 +176,13 @@ CoordinatedTransactionCallback(XactEvent event, void *arg)
* XACT_EVENT_PRE_COMMIT state. * 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 */ /* handles both already prepared and open transactions */
if (CurrentCoordinatedTransactionState > COORD_TRANS_IDLE) if (CurrentCoordinatedTransactionState > COORD_TRANS_IDLE)
{ {

View File

@ -33,7 +33,7 @@ extern ShardConnections * GetShardHashConnections(HTAB *connectionHash, int64 sh
bool *connectionsFound); bool *connectionsFound);
extern List * ConnectionList(HTAB *connectionHash); extern List * ConnectionList(HTAB *connectionHash);
extern void CloseConnections(List *connectionList); extern void CloseConnections(List *connectionList);
extern void RegisterShardPlacementXactCallbacks(void); extern void ResetShardPlacementTransactionState(void);
#endif /* MULTI_SHARD_TRANSACTION_H */ #endif /* MULTI_SHARD_TRANSACTION_H */

View File

@ -80,14 +80,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- see that our first multi shard INSERT...SELECT works expected
SET client_min_messages TO INFO; SET client_min_messages TO INFO;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
@ -283,14 +275,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 user_id | time | value_1 | value_2 | value_3 | value_4
---------+------+---------+---------+---------+--------- ---------+------+---------+---------+---------+---------
9 | | 90 | | 9000 | 9 | | 90 | | 9000 |
@ -363,14 +347,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- 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) INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, user_id)
SELECT SELECT
@ -574,14 +550,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- add one more level subqueris on top of subquery JOINs
INSERT INTO agg_events INSERT INTO agg_events
(user_id, value_4_agg) (user_id, value_4_agg)
@ -659,14 +627,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- subqueries in WHERE clause
INSERT INTO raw_events_second INSERT INTO raw_events_second
(user_id) (user_id)
@ -711,14 +671,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- some UPSERTS
INSERT INTO agg_events AS ae INSERT INTO agg_events AS ae
( (
@ -758,14 +710,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- upserts with returning
INSERT INTO agg_events AS ae INSERT INTO agg_events AS ae
( (
@ -806,14 +750,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 user_id | value_1_agg
---------+------------- ---------+-------------
7 | 7 |
@ -848,14 +784,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- FILTER CLAUSE
INSERT INTO agg_events (user_id, value_1_agg) INSERT INTO agg_events (user_id, value_1_agg)
SELECT SELECT
@ -886,14 +814,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- a test with reference table JOINs
INSERT INTO INSERT INTO
agg_events (user_id, value_1_agg) agg_events (user_id, value_1_agg)
@ -929,14 +849,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- a note on the outer joins is that
-- we filter out outer join results -- we filter out outer join results
-- where partition column returns -- where partition column returns
@ -1024,14 +936,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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; SET client_min_messages TO INFO;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
@ -1094,14 +998,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- we don't want to see constraint vialotions, so truncate first
SET client_min_messages TO INFO; SET client_min_messages TO INFO;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
@ -1168,14 +1064,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- We do not support any set operations
INSERT INTO INSERT INTO
raw_events_first(user_id) raw_events_first(user_id)
@ -1547,14 +1435,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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; SET client_min_messages TO INFO;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
@ -1695,13 +1575,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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; SET client_min_messages TO INFO;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
@ -1784,10 +1657,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- see that defaults are filled
INSERT INTO table_with_defaults (store_id, first_name) INSERT INTO table_with_defaults (store_id, first_name)
SELECT SELECT
@ -1806,10 +1675,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- shuffle one of the defaults and skip the other
INSERT INTO table_with_defaults (default_2, store_id, first_name) INSERT INTO table_with_defaults (default_2, store_id, first_name)
SELECT SELECT
@ -1828,10 +1693,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- shuffle both defaults
INSERT INTO table_with_defaults (default_2, store_id, default_1, first_name) INSERT INTO table_with_defaults (default_2, store_id, default_1, first_name)
SELECT SELECT
@ -1850,10 +1711,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- use constants instead of non-default column
INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name) INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name)
SELECT SELECT
@ -1872,10 +1729,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- use constants instead of non-default column and skip both defauls
INSERT INTO table_with_defaults (last_name, store_id, first_name) INSERT INTO table_with_defaults (last_name, store_id, first_name)
SELECT SELECT
@ -1894,10 +1747,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- use constants instead of default columns
INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name, default_1) INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name, default_1)
SELECT SELECT
@ -1916,10 +1765,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 -- 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) INSERT INTO table_with_defaults (default_2, last_name, store_id, first_name, default_1)
SELECT SELECT
@ -1938,10 +1783,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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, -- some of the the ultimate queries where we have constants,
-- defaults and group by entry is not on the target entry -- defaults and group by entry is not on the target entry
INSERT INTO table_with_defaults (default_2, store_id, first_name) INSERT INTO table_with_defaults (default_2, store_id, first_name)
@ -1963,10 +1804,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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) INSERT INTO table_with_defaults (default_1, store_id, first_name, default_2)
SELECT SELECT
1000, store_id, 'Andres', '2000' 1000, store_id, 'Andres', '2000'
@ -1986,10 +1823,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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) INSERT INTO table_with_defaults (default_1, store_id, first_name, default_2)
SELECT SELECT
1000, store_id, 'Andres', '2000' 1000, store_id, 'Andres', '2000'
@ -2009,10 +1842,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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) INSERT INTO table_with_defaults (default_1, store_id, first_name)
SELECT SELECT
1000, store_id, 'Andres' 1000, store_id, 'Andres'
@ -2032,10 +1861,6 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: 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 back to the default
SET citus.shard_count TO DEFAULT; SET citus.shard_count TO DEFAULT;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand

View File

@ -45,8 +45,6 @@ CREATE INDEX lineitem_hash_time_index ON lineitem_hash (l_shipdate);
NOTICE: using one-phase commit for distributed DDL commands 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' 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: 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 ( CREATE TABLE orders_hash (
o_orderkey bigint not null, o_orderkey bigint not null,
o_custkey integer not null, o_custkey integer not null,

View File

@ -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 350001
DEBUG: predicate pruning for shardId 350002 DEBUG: predicate pruning for shardId 350002
DEBUG: predicate pruning for shardId 350003 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 master_modify_multiple_shards
------------------------------- -------------------------------
1 1

View File

@ -559,7 +559,7 @@ COMMIT;
WARNING: duplicate key value violates unique constraint "ddl_commands_command_key" WARNING: duplicate key value violates unique constraint "ddl_commands_command_key"
DETAIL: Key (command)=(CREATE INDEX) already exists. DETAIL: Key (command)=(CREATE INDEX) already exists.
CONTEXT: while executing command on localhost:57638 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 -- Nothing from the block should have committed
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items'; SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items';
indexname | tablename 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' 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); CREATE INDEX single_index_3 ON single_shard_items(name);
COMMIT; 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 -- The block should have committed with a warning
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items'; SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items';
indexname | tablename indexname | tablename