Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b5b279d

Browse files
committed
volkswagen_mode
1 parent 2f8bcb9 commit b5b279d

File tree

2 files changed

+30
-65
lines changed

2 files changed

+30
-65
lines changed

contrib/mmts/multimaster.c

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ static TransactionManager MtmTM = {
180180
MtmGetTransactionStateSize,
181181
MtmSerializeTransactionState,
182182
MtmDeserializeTransactionState,
183-
// MtmInitializeSequence
184-
PgInitializeSequence
183+
MtmInitializeSequence
185184
};
186185

187186
char const* const MtmNodeStatusMnem[] =
@@ -198,7 +197,6 @@ char const* const MtmNodeStatusMnem[] =
198197
bool MtmDoReplication;
199198
char* MtmDatabaseName;
200199
char* MtmDatabaseUser;
201-
char* MtmUtilityStmt = NULL;
202200

203201
int MtmNodes;
204202
int MtmNodeId;
@@ -214,6 +212,7 @@ int MtmHeartbeatSendTimeout;
214212
int MtmHeartbeatRecvTimeout;
215213
bool MtmUseRaftable;
216214
bool MtmUseDtm;
215+
bool MtmVolksWagenMode;
217216

218217
static char* MtmConnStrs;
219218
static int MtmQueueSize;
@@ -236,9 +235,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
236235
ProcessUtilityContext context, ParamListInfo params,
237236
DestReceiver *dest, char *completionTag);
238237

239-
// static StringInfo MtmGUCBuffer;
240-
// static bool MtmGUCBufferAllocated = false;
241-
242238
/*
243239
* -------------------------------------------
244240
* Synchronize access to MTM structures.
@@ -365,8 +361,16 @@ MtmDeserializeTransactionState(void* ctx)
365361
static void
366362
MtmInitializeSequence(int64* start, int64* step)
367363
{
368-
*start = MtmNodeId;
369-
*step = MtmMaxNodes;
364+
if (MtmVolksWagenMode)
365+
{
366+
*start = 1;
367+
*step = 1;
368+
}
369+
else
370+
{
371+
*start = MtmNodeId;
372+
*step = MtmMaxNodes;
373+
}
370374
}
371375

372376

@@ -683,10 +687,6 @@ static const char* const isoLevelStr[] =
683687
static void
684688
MtmBeginTransaction(MtmCurrentTrans* x)
685689
{
686-
if (MtmUtilityStmt)
687-
pfree(MtmUtilityStmt);
688-
MtmUtilityStmt = NULL;
689-
690690
if (x->snapshot == INVALID_CSN) {
691691
TransactionId xmin = (Mtm->gcCount >= MtmGcPeriod) ? PgGetOldestXmin(NULL, false) : InvalidTransactionId; /* Get oldest xmin outside critical section */
692692

@@ -2070,6 +2070,19 @@ _PG_init(void)
20702070
NULL
20712071
);
20722072

2073+
DefineCustomBoolVariable(
2074+
"multimaster.volkswagen_mode",
2075+
"Pretend to be normal postgres. This means skip some NOTICE's and use local sequences. Default false.",
2076+
NULL,
2077+
&MtmVolksWagenMode,
2078+
false,
2079+
PGC_BACKEND,
2080+
0,
2081+
NULL,
2082+
NULL,
2083+
NULL
2084+
);
2085+
20732086
DefineCustomIntVariable(
20742087
"multimaster.workers",
20752088
"Number of multimaster executor workers per node",
@@ -2936,13 +2949,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
29362949
{
29372950
if (conns[i])
29382951
{
2939-
// if (MtmGUCBufferAllocated && !MtmRunUtilityStmt(conns[i], MtmGUCBuffer->data, &utility_errmsg) && !ignoreError)
2940-
// {
2941-
// errorMsg = "Failed to set GUC variables at node %d";
2942-
// elog(WARNING, "%s", utility_errmsg);
2943-
// failedNode = i;
2944-
// break;
2945-
// }
29462952
if (!MtmRunUtilityStmt(conns[i], "BEGIN TRANSACTION", &utility_errmsg) && !ignoreError)
29472953
{
29482954
errorMsg = "Failed to start transaction at node %d";
@@ -2996,38 +3002,6 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
29963002
}
29973003
}
29983004

2999-
// static void MtmGUCBufferAppend(const char *gucQueryString){
3000-
3001-
// if (!MtmGUCBufferAllocated)
3002-
// {
3003-
// MemoryContext oldcontext;
3004-
// oldcontext = MemoryContextSwitchTo(TopMemoryContext);
3005-
// MtmGUCBuffer = makeStringInfo();
3006-
// MemoryContextSwitchTo(oldcontext);
3007-
// MtmGUCBufferAllocated = true;
3008-
// appendStringInfoString(MtmGUCBuffer, "RESET SESSION AUTHORIZATION; reset all;");
3009-
// }
3010-
3011-
// appendStringInfoString(MtmGUCBuffer, gucQueryString);
3012-
// /* sometimes there is no ';' char at the end. */
3013-
// // appendStringInfoString(MtmGUCBuffer, ";");
3014-
// }
3015-
3016-
// static char * MtmGUCBufferGet(void){
3017-
// if (!MtmGUCBufferAllocated)
3018-
// MtmGUCBufferAppend("");
3019-
// return MtmGUCBuffer->data;
3020-
// }
3021-
3022-
// static void MtmGUCBufferClear(void)
3023-
// {
3024-
// if (MtmGUCBufferAllocated)
3025-
// {
3026-
// resetStringInfo(MtmGUCBuffer);
3027-
// MtmGUCBufferAppend("");
3028-
// }
3029-
// }
3030-
30313005
/*
30323006
* Genenerate global transaction identifier for two-pahse commit.
30333007
* It should be unique for all nodes
@@ -3045,11 +3019,12 @@ static bool MtmTwoPhaseCommit(MtmCurrentTrans* x)
30453019
{
30463020
/*
30473021
* XXX: this tx anyway goes to subscribers later, but without
3048-
* surrounding begin/commit. Probably there is more clever way
3049-
* to do that.
3022+
* surrounding begin/commit. Now it will be filtered out on receiver side.
3023+
* Probably there is more clever way to do that.
30503024
*/
30513025
x->isDistributed = false;
3052-
x->csn = NULL;
3026+
if (!MtmVolksWagenMode)
3027+
elog(NOTICE, "MTM: Transaction was not replicated as it accesed temporary relation");
30533028
return false;
30543029
}
30553030

@@ -3247,8 +3222,6 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
32473222
{
32483223
bool skipCommand = false;
32493224

3250-
// skipCommand = MyXactAccessedTempRel;
3251-
32523225
MTM_LOG3("%d: Process utility statement %s", MyProcPid, queryString);
32533226
switch (nodeTag(parsetree))
32543227
{
@@ -3304,19 +3277,10 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
33043277
skipCommand = true;
33053278
break;
33063279

3307-
// /* Do not skip following unless temp object was accessed */
3308-
// case T_CreateTableAsStmt:
3309-
// case T_CreateStmt:
3310-
// case T_ViewStmt:
3311-
// case T_IndexStmt:
3312-
// case T_DropStmt:
3313-
// break;
3314-
33153280
/* Save GUC context for consequent DDL execution */
33163281
case T_DiscardStmt:
33173282
{
33183283
DiscardStmt *stmt = (DiscardStmt *) parsetree;
3319-
skipCommand = stmt->target == DISCARD_TEMP; // XXX
33203284

33213285
if (!IsTransactionBlock())
33223286
{

contrib/mmts/tests/reinit-mm.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ do
5555
multimaster.heartbeat_recv_timeout = 1000
5656
multimaster.heartbeat_send_timeout = 250
5757
multimaster.twopc_min_timeout = 400000
58+
multimaster.volkswagen_mode = 1
5859
5960
multimaster.conn_strings = '$conn_str'
6061
multimaster.node_id = $i

0 commit comments

Comments
 (0)