Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98eb87d

Browse files
knizhnikkelvich
authored andcommitted
Rename paxos to taftable and make last one optionally included
1 parent0f23a54 commit98eb87d

File tree

2 files changed

+40
-60
lines changed

2 files changed

+40
-60
lines changed

‎multimaster.c

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
#include"multimaster.h"
5959
#include"ddd.h"
60-
#include"paxos.h"
60+
#include"raftable.h"
6161

6262
typedefstruct {
6363
TransactionIdxid;/* local transaction ID */
@@ -178,6 +178,7 @@ static int MtmWorkers;
178178
staticintMtmVacuumDelay;
179179
staticintMtmMinRecoveryLag;
180180
staticintMtmMaxRecoveryLag;
181+
staticboolMtmUseRaftable;
181182

182183
staticExecutorFinish_hook_typePreviousExecutorFinishHook;
183184
staticProcessUtility_hook_typePreviousProcessUtilityHook;
@@ -1102,7 +1103,7 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
11021103
inti,j,n=MtmNodes;
11031104
for (i=0;i<n;i++) {
11041105
if (i+1!=MtmNodeId) {
1105-
void*data=PaxosGet(psprintf("node-mask-%d",i+1),NULL,NULL,nowait);
1106+
void*data=RaftableGet(psprintf("node-mask-%d",i+1),NULL,NULL,nowait);
11061107
if (data==NULL) {
11071108
return false;
11081109
}
@@ -1132,7 +1133,7 @@ bool MtmRefreshClusterStatus(bool nowait)
11321133
intclique_size;
11331134
inti;
11341135

1135-
if (!MtmBuildConnectivityMatrix(matrix,nowait)) {
1136+
if (!MtmUseRaftable|| !MtmBuildConnectivityMatrix(matrix,nowait)) {
11361137
/* RAFT is not available */
11371138
return false;
11381139
}
@@ -1192,7 +1193,7 @@ void MtmCheckQuorum(void)
11921193
voidMtmOnNodeDisconnect(intnodeId)
11931194
{
11941195
BIT_SET(Mtm->connectivityMask,nodeId-1);
1195-
PaxosSet(psprintf("node-mask-%d",MtmNodeId),&Mtm->connectivityMask,sizeofMtm->connectivityMask, false);
1196+
RaftableSet(psprintf("node-mask-%d",MtmNodeId),&Mtm->connectivityMask,sizeofMtm->connectivityMask, false);
11961197

11971198
/* Wait more than socket KEEPALIVE timeout to let other nodes update their statuses */
11981199
MtmSleep(MtmKeepaliveTimeout);
@@ -1211,52 +1212,9 @@ void MtmOnNodeDisconnect(int nodeId)
12111212
voidMtmOnNodeConnect(intnodeId)
12121213
{
12131214
BIT_CLEAR(Mtm->connectivityMask,nodeId-1);
1214-
PaxosSet(psprintf("node-mask-%d",MtmNodeId),&Mtm->connectivityMask,sizeofMtm->connectivityMask, false);
1215+
RaftableSet(psprintf("node-mask-%d",MtmNodeId),&Mtm->connectivityMask,sizeofMtm->connectivityMask, false);
12151216
}
12161217

1217-
/*
1218-
* Paxos function stubs (until them are miplemented)
1219-
*/
1220-
void*PaxosGet(charconst*key,int*size,PaxosTimestamp*ts,boolnowait)
1221-
{
1222-
unsignedenclen,declen,len;
1223-
char*enc,*dec;
1224-
Assert(ts==NULL);// not implemented
1225-
1226-
enc=raftable_get(key);
1227-
if (enc==NULL)
1228-
{
1229-
*size=0;
1230-
returnNULL;
1231-
}
1232-
1233-
enclen=strlen(enc);
1234-
declen=hex_dec_len(enc,enclen);
1235-
dec=palloc(declen);
1236-
len=hex_decode(enc,enclen,dec);
1237-
pfree(enc);
1238-
Assert(len==declen);
1239-
1240-
if (size!=NULL) {
1241-
*size=declen;
1242-
}
1243-
returndec;
1244-
}
1245-
1246-
voidPaxosSet(charconst*key,voidconst*value,intsize,boolnowait)
1247-
{
1248-
unsignedenclen,declen,len;
1249-
char*enc,*dec;
1250-
1251-
enclen=hex_enc_len(value,size);
1252-
enc=palloc(enclen)+1;
1253-
len=hex_encode(value,size,enc);
1254-
Assert(len==enclen);
1255-
enc[len]='\0';
1256-
1257-
raftable_set(key,enc,nowait ?1 :INT_MAX);
1258-
pfree(enc);
1259-
}
12601218

12611219

12621220
/*
@@ -1483,6 +1441,19 @@ _PG_init(void)
14831441
NULL
14841442
);
14851443

1444+
DefineCustomBoolVariable(
1445+
"multimaster.use_raftable",
1446+
"Use raftable plugin for internode communication",
1447+
NULL,
1448+
&MtmUseRaftable,
1449+
false,
1450+
PGC_BACKEND,
1451+
0,
1452+
NULL,
1453+
NULL,
1454+
NULL
1455+
);
1456+
14861457
DefineCustomIntVariable(
14871458
"multimaster.workers",
14881459
"Number of multimaster executor workers per node",
@@ -1773,6 +1744,10 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
17731744
break;
17741745
}
17751746
}
1747+
if (isRecoverySession) {
1748+
MTM_INFO("%d: PGLOGICAL startup hook\n",MyProcPid);
1749+
sleep(30);
1750+
}
17761751
MtmLock(LW_EXCLUSIVE);
17771752
if (isRecoverySession) {
17781753
elog(WARNING,"Node %d start recovery of node %d",MtmNodeId,MtmReplicationNodeId);
@@ -1805,7 +1780,7 @@ MtmReplicationTxnFilterHook(struct PGLogicalTxnFilterArgs* args)
18051780
boolres=Mtm->status!=MTM_RECOVERY
18061781
&& (args->origin_id==InvalidRepOriginId
18071782
||MtmIsRecoveredNode(MtmReplicationNodeId));
1808-
MTM_INFO("%d: MtmReplicationTxnFilterHook->%d\n",MyProcPid,res);
1783+
MTM_TRACE("%d: MtmReplicationTxnFilterHook->%d\n",MyProcPid,res);
18091784
returnres;
18101785
}
18111786

@@ -2373,16 +2348,16 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
23732348

23742349
ByteBufferAlloc(&buf);
23752350
EnumerateLocks(MtmSerializeLock,&buf);
2376-
PaxosSet(psprintf("lock-graph-%d",MtmNodeId),buf.data,buf.used, true);
2351+
RaftableSet(psprintf("lock-graph-%d",MtmNodeId),buf.data,buf.used, true);
23772352
MtmGraphInit(&graph);
23782353
MtmGraphAdd(&graph, (GlobalTransactionId*)buf.data,buf.used/sizeof(GlobalTransactionId));
23792354
ByteBufferFree(&buf);
23802355
for (i=0;i<MtmNodes;i++) {
23812356
if (i+1!=MtmNodeId&& !BIT_CHECK(Mtm->disabledNodeMask,i)) {
23822357
intsize;
2383-
void*data=PaxosGet(psprintf("lock-graph-%d",i+1),&size,NULL, true);
2358+
void*data=RaftableGet(psprintf("lock-graph-%d",i+1),&size,NULL, true);
23842359
if (data==NULL) {
2385-
return true;/*Just temporary hack until no Paxos */
2360+
return true;/*If using Raftable is disabled */
23862361
}else {
23872362
MtmGraphAdd(&graph, (GlobalTransactionId*)data,size/sizeof(GlobalTransactionId));
23882363
}

‎paxos.hrenamed to‎raftable.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#ifndef__PAXOS_H__
2-
#define__PAXOS_H__
1+
#ifndef__RAFTABLE_H__
2+
#define__RAFTABLE_H__
33

4-
typedefstructPaxosTimestamp {
4+
typedefstructRaftableTimestamp {
55
time_ttime;/* local time at master */
66
uint32master;/* master node for this operation */
7-
uint32psn;/*PAXOS serial number */
8-
}PaxosTimestamp;
7+
uint32psn;/*RAFTABLE serial number */
8+
}RaftableTimestamp;
99

1010
/*
1111
* Get key value.
@@ -15,18 +15,23 @@ typedef struct PaxosTimestamp {
1515
* If "ts" is not NULL, then it is assigned timestamp of last update of this value
1616
* If RAFT master is not accessible, then depending non value of "nowait" parameter, this funciton should either block until RAFT quorum is reached, either report error.
1717
*/
18-
externvoid*PaxosGet(charconst*key,int*size,PaxosTimestamp*ts,boolnowait);
18+
externvoid*RaftableGet(charconst*key,int*size,RaftableTimestamp*ts,boolnowait);
1919

2020
/*
2121
* Set new value for the specified key. IF value is NULL, then key should be deleted.
2222
* If RAFT master is not accessible, then depending non value of "nowait" parameter, this funciton should either block until RAFT quorum is reached, either report error.
2323
*/
24-
externvoidPaxosSet(charconst*key,voidconst*value,intsize,boolnowait);
24+
externvoidRaftableSet(charconst*key,voidconst*value,intsize,boolnowait);
2525

2626
/*
2727
* If key doesn't exists or its value is not equal to the specified value then store this value and return true.
2828
* Otherwise do nothing and return false.
2929
* If RAFT master is not accessible, then depending non value of "nowait" parameter, this funciton should either block until RAFT quorum is reached, either report error.
3030
*/
31-
externboolPaxosCAS(charconst*key,charconst*value,boolnowait);
31+
externboolRaftableCAS(charconst*key,charconst*value,boolnowait);
32+
33+
typedefvoid* (*raftable_get_t)(charconst*key,int*size,inttimeout);
34+
typedefvoid (*raftable_set_t)(charconst*key,voidconst*value,intsize,inttimeout);
35+
36+
3237
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp