mirror of https://github.com/citusdata/citus.git
Merge pull request #1022 from citusdata/feature/2PCBUMPISM
Make prepared transactions available if not configured.pull/1025/merge
commit
4bea1f621a
|
@ -17,11 +17,13 @@
|
||||||
|
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
|
||||||
|
#include "access/twophase.h"
|
||||||
#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/transaction_management.h"
|
#include "distributed/transaction_management.h"
|
||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
|
#include "utils/guc.h"
|
||||||
|
|
||||||
|
|
||||||
CoordinatedTransactionState CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
|
CoordinatedTransactionState CurrentCoordinatedTransactionState = COORD_TRANS_NONE;
|
||||||
|
@ -41,6 +43,9 @@ static void CoordinatedTransactionCallback(XactEvent event, void *arg);
|
||||||
static void CoordinatedSubTransactionCallback(SubXactEvent event, SubTransactionId subId,
|
static void CoordinatedSubTransactionCallback(SubXactEvent event, SubTransactionId subId,
|
||||||
SubTransactionId parentSubid, void *arg);
|
SubTransactionId parentSubid, void *arg);
|
||||||
|
|
||||||
|
/* remaining functions */
|
||||||
|
static void AdjustMaxPreparedTransactions(void);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InitializeTransactionManagement(void)
|
InitializeTransactionManagement(void)
|
||||||
|
@ -48,6 +53,8 @@ InitializeTransactionManagement(void)
|
||||||
/* hook into transaction machinery */
|
/* hook into transaction machinery */
|
||||||
RegisterXactCallback(CoordinatedTransactionCallback, NULL);
|
RegisterXactCallback(CoordinatedTransactionCallback, NULL);
|
||||||
RegisterSubXactCallback(CoordinatedSubTransactionCallback, NULL);
|
RegisterSubXactCallback(CoordinatedSubTransactionCallback, NULL);
|
||||||
|
|
||||||
|
AdjustMaxPreparedTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,3 +149,34 @@ CoordinatedSubTransactionCallback(SubXactEvent event, SubTransactionId subId,
|
||||||
subXactAbortAttempted = true;
|
subXactAbortAttempted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AdjustMaxPreparedTransactions configures the number of available prepared
|
||||||
|
* transaction slots at startup.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
AdjustMaxPreparedTransactions(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* As Citus uses 2PC internally, there always should be some available. As
|
||||||
|
* the default is 0, we increase it to something appropriate
|
||||||
|
* (connections * 2 currently). If the user explicitly configured 2PC, we
|
||||||
|
* leave the configuration alone - there might have been intent behind the
|
||||||
|
* decision.
|
||||||
|
*/
|
||||||
|
if (max_prepared_xacts == 0)
|
||||||
|
{
|
||||||
|
char newvalue[12];
|
||||||
|
|
||||||
|
snprintf(newvalue, sizeof(newvalue), "%d", MaxConnections * 2);
|
||||||
|
|
||||||
|
SetConfigOption("max_prepared_transactions", newvalue, PGC_POSTMASTER,
|
||||||
|
PGC_S_OVERRIDE);
|
||||||
|
|
||||||
|
ereport(LOG, (errmsg("number of prepared transactions has not been "
|
||||||
|
"configured, overriding"),
|
||||||
|
errdetail("max_prepared_transactions is now set to %s",
|
||||||
|
newvalue)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -129,7 +129,6 @@ push(@pgOptions, '-c', "listen_addresses='${host}'");
|
||||||
push(@pgOptions, '-c', "unix_socket_directories=");
|
push(@pgOptions, '-c', "unix_socket_directories=");
|
||||||
push(@pgOptions, '-c', "fsync=off");
|
push(@pgOptions, '-c', "fsync=off");
|
||||||
push(@pgOptions, '-c', "shared_preload_libraries=citus");
|
push(@pgOptions, '-c', "shared_preload_libraries=citus");
|
||||||
push(@pgOptions, '-c', "max_prepared_transactions=100");
|
|
||||||
|
|
||||||
# Citus options set for the tests
|
# Citus options set for the tests
|
||||||
push(@pgOptions, '-c', "citus.shard_max_size=300kB");
|
push(@pgOptions, '-c', "citus.shard_max_size=300kB");
|
||||||
|
|
Loading…
Reference in New Issue