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

Commit fe7bfe2

Browse files
committed
Merge branch 'PGPROEE10_MULTIMASTER_stable' into PGPROEE10
2 parents 0ab01e8 + a5892cb commit fe7bfe2

17 files changed

+561
-123
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ fi
27882788

27892789

27902790

2791-
PGPRO_VERSION="$PACKAGE_VERSION.2"
2791+
PGPRO_VERSION="$PACKAGE_VERSION.3"
27922792
PGPRO_PACKAGE_NAME="PostgresPro"
27932793
PGPRO_EDITION="enterprise"
27942794
PGPRO_EDN="ent"

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
3939
[PG_VERSION="$PACKAGE_VERSION$withval"],
4040
[PG_VERSION="$PACKAGE_VERSION"])
4141

42-
PGPRO_VERSION="$PACKAGE_VERSION.2"
42+
PGPRO_VERSION="$PACKAGE_VERSION.3"
4343
PGPRO_PACKAGE_NAME="PostgresPro"
4444
PGPRO_EDITION="enterprise"
4545
PGPRO_EDN="ent"

contrib/mmts/Cluster.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ sub new
7373
my $self = {
7474
nodenum => $nodenum,
7575
nodes => $nodes,
76+
recv_timeout => 5,
7677
};
7778

7879
bless $self, $class;

contrib/mmts/multimaster--1.0.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CREATE FUNCTION mtm.make_table_local(relation regclass) RETURNS void
8484
AS 'MODULE_PATHNAME','mtm_make_table_local'
8585
LANGUAGE C;
8686

87-
CREATE FUNCTION mtm.broadcast_table(srcTable regclass, dstNodesMask bigint) RETURNS void
87+
CREATE FUNCTION mtm.broadcast_table(srcTable regclass) RETURNS void
8888
AS 'MODULE_PATHNAME','mtm_broadcast_table'
8989
LANGUAGE C;
9090

contrib/mmts/multimaster.c

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static ExecutorStart_hook_type PreviousExecutorStartHook;
290290
static ExecutorFinish_hook_type PreviousExecutorFinishHook;
291291
static ProcessUtility_hook_type PreviousProcessUtilityHook;
292292
static shmem_startup_hook_type PreviousShmemStartupHook;
293-
// static seq_nextval_hook_t PreviousSeqNextvalHook;
293+
static seq_nextval_hook_t PreviousSeqNextvalHook;
294294

295295
static void MtmExecutorStart(QueryDesc *queryDesc, int eflags);
296296
static void MtmExecutorFinish(QueryDesc *queryDesc);
@@ -602,14 +602,16 @@ csn_t MtmDistributedTransactionSnapshot(TransactionId xid, int nodeId, nodemask_
602602
MtmTransState* ts = (MtmTransState*)hash_search(MtmXid2State, &xid, HASH_FIND, NULL);
603603
if (ts != NULL) {
604604
*participantsMask = ts->participantsMask;
605-
/* If node is disables, then we are in a process of recovery of this node */
606-
if (!ts->isLocal && BIT_CHECK(ts->participantsMask|Mtm->disabledNodeMask, nodeId-1)) {
605+
if (!ts->isLocal)
607606
snapshot = ts->snapshot;
608-
Assert(ts->gtid.node == MtmNodeId || MtmIsRecoverySession);
609-
} else {
610-
MTM_LOG1("Do not send transaction %s (%llu) to node %d participants mask %llx",
611-
ts->gid, (long64)ts->xid, nodeId, ts->participantsMask);
612-
}
607+
// /* If node is disables, then we are in a process of recovery of this node */
608+
// if (!ts->isLocal && BIT_CHECK(ts->participantsMask|Mtm->disabledNodeMask, nodeId-1)) {
609+
// snapshot = ts->snapshot;
610+
// Assert(ts->gtid.node == MtmNodeId || MtmIsRecoverySession);
611+
// } else {
612+
// MTM_LOG1("Do not send transaction %s (%llu) to node %d participants mask %llx",
613+
// ts->gid, (long64)ts->xid, nodeId, ts->participantsMask);
614+
// }
613615
}
614616
}
615617
MtmUnlock();
@@ -3389,8 +3391,8 @@ _PG_init(void)
33893391
PreviousProcessUtilityHook = ProcessUtility_hook;
33903392
ProcessUtility_hook = MtmProcessUtility;
33913393

3392-
// PreviousSeqNextvalHook = SeqNextvalHook;
3393-
// SeqNextvalHook = MtmSeqNextvalHook;
3394+
PreviousSeqNextvalHook = SeqNextvalHook;
3395+
SeqNextvalHook = MtmSeqNextvalHook;
33943396
}
33953397

33963398
/*
@@ -3402,7 +3404,7 @@ _PG_fini(void)
34023404
shmem_startup_hook = PreviousShmemStartupHook;
34033405
ExecutorFinish_hook = PreviousExecutorFinishHook;
34043406
ProcessUtility_hook = PreviousProcessUtilityHook;
3405-
// SeqNextvalHook = PreviousSeqNextvalHook;
3407+
SeqNextvalHook = PreviousSeqNextvalHook;
34063408
}
34073409

34083410

@@ -4462,7 +4464,7 @@ Datum mtm_broadcast_table(PG_FUNCTION_ARGS)
44624464
{
44634465
MtmCopyRequest copy;
44644466
copy.sourceTable = PG_GETARG_OID(0);
4465-
copy.targetNodes = PG_GETARG_INT64(1);
4467+
copy.targetNodes = ~Mtm->disabledNodeMask;
44664468
LogLogicalMessage("B", (char*)&copy, sizeof(copy), true);
44674469
MtmTx.containsDML = true;
44684470
PG_RETURN_VOID();
@@ -4724,7 +4726,7 @@ static void
47244726
MtmGenerateGid(char* gid)
47254727
{
47264728
static int localCount;
4727-
sprintf(gid, "MTM-%d-%d-%d-%ld", MtmNodeId, MyProcPid, ++localCount, (int64) GetCurrentTimestamp());
4729+
sprintf(gid, "MTM-%d-%d-%d-" INT64_FORMAT, MtmNodeId, MyProcPid, ++localCount, (int64) GetCurrentTimestamp());
47284730
}
47294731

47304732
/*
@@ -5088,7 +5090,33 @@ static bool MtmFunctionProfileDependsOnTempTable(CreateFunctionStmt* func)
50885090
return false;
50895091
}
50905092

5093+
static void
5094+
AdjustCreateSequence(List *options)
5095+
{
5096+
bool has_increment = false, has_start = false;
5097+
ListCell *option;
50915098

5099+
foreach(option, options)
5100+
{
5101+
DefElem *defel = (DefElem *) lfirst(option);
5102+
if (strcmp(defel->defname, "increment") == 0)
5103+
has_increment = true;
5104+
else if (strcmp(defel->defname, "start") == 0)
5105+
has_start = true;
5106+
}
5107+
5108+
if (!has_increment)
5109+
{
5110+
DefElem *defel = makeDefElem("increment", (Node *) makeInteger(MtmMaxNodes), -1);
5111+
options = lappend(options, defel);
5112+
}
5113+
5114+
if (!has_start)
5115+
{
5116+
DefElem *defel = makeDefElem("start", (Node *) makeInteger(MtmNodeId), -1);
5117+
options = lappend(options, defel);
5118+
}
5119+
}
50925120

50935121
static void MtmProcessUtility(PlannedStmt *pstmt,
50945122
const char *queryString, ProcessUtilityContext context,
@@ -5161,6 +5189,14 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
51615189
elog(ERROR, "Multimaster doesn't support creating and dropping databases");
51625190
break;
51635191

5192+
case T_CreateSeqStmt:
5193+
{
5194+
CreateSeqStmt *stmt = (CreateSeqStmt *) parsetree;
5195+
if (!MtmVolksWagenMode)
5196+
AdjustCreateSequence(stmt->options);
5197+
}
5198+
break;
5199+
51645200
case T_CreateTableSpaceStmt:
51655201
case T_DropTableSpaceStmt:
51665202
{
@@ -5453,11 +5489,9 @@ static void MtmProcessUtility(PlannedStmt *pstmt,
54535489
if (relid != InvalidOid) {
54545490
Oid constraint_oid;
54555491
Bitmapset* pk = get_primary_key_attnos(relid, true, &constraint_oid);
5456-
if (pk == NULL && !MtmVolksWagenMode) {
5492+
if (pk == NULL && !MtmVolksWagenMode && MtmIgnoreTablesWithoutPk) {
54575493
elog(WARNING,
5458-
MtmIgnoreTablesWithoutPk
5459-
? "Table %s.%s without primary will not be replicated"
5460-
: "Updates and deletes of table %s.%s without primary will not be replicated",
5494+
"Table %s.%s without primary will not be replicated",
54615495
create->relation->schemaname ? create->relation->schemaname : "public",
54625496
create->relation->relname);
54635497
}

0 commit comments

Comments
 (0)