refactor(sync): optimized one replica
This commit is contained in:
parent
a6f33ba01c
commit
6eecbcd1a6
|
@ -155,7 +155,6 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
if (rsp.info.handle != NULL) {
|
if (rsp.info.handle != NULL) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
code = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,11 +182,13 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||||
} else {
|
} else {
|
||||||
|
if (code != 1) {
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
vError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", vgId, pMsg, tstrerror(code), code);
|
vError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", vgId, pMsg, tstrerror(code), code);
|
||||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code);
|
vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code);
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
|
|
@ -2654,11 +2654,18 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
||||||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||||
|
|
||||||
// user commit
|
// user commit
|
||||||
bool internalExecute = (ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType);
|
if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) {
|
||||||
if (ths->replicaNum == 1) {
|
bool internalExecute = true;
|
||||||
internalExecute = syncNodeIsOptimizedOneReplica(ths, &rpcMsg) && !(ths->restoreFinish);
|
if ((ths->replicaNum == 1) && ths->restoreFinish && (ths->vgId != 1)) {
|
||||||
|
internalExecute = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
char logBuf[128];
|
||||||
|
snprintf(logBuf, sizeof(logBuf), "index:%ld, internalExecute:%d", i, internalExecute);
|
||||||
|
syncNodeEventLog(ths, logBuf);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
// execute fsm in apply thread, or execute outside syncPropose
|
// execute fsm in apply thread, or execute outside syncPropose
|
||||||
if (internalExecute) {
|
if (internalExecute) {
|
||||||
SFsmCbMeta cbMeta = {0};
|
SFsmCbMeta cbMeta = {0};
|
||||||
|
@ -2674,6 +2681,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
||||||
|
|
||||||
ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, cbMeta);
|
ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, cbMeta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// config change
|
// config change
|
||||||
if (pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE) {
|
if (pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE) {
|
||||||
|
|
|
@ -419,15 +419,12 @@ void test6() {
|
||||||
logStoreDestory(pLogStore);
|
logStoreDestory(pLogStore);
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// restart
|
// restart
|
||||||
init();
|
init();
|
||||||
pLogStore = logStoreCreate(pSyncNode);
|
pLogStore = logStoreCreate(pSyncNode);
|
||||||
assert(pLogStore);
|
assert(pLogStore);
|
||||||
pSyncNode->pLogStore = pLogStore;
|
pSyncNode->pLogStore = pLogStore;
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
SyncIndex firstVer = walGetFirstVer(pWal);
|
SyncIndex firstVer = walGetFirstVer(pWal);
|
||||||
SyncIndex lastVer = walGetLastVer(pWal);
|
SyncIndex lastVer = walGetLastVer(pWal);
|
||||||
|
|
Loading…
Reference in New Issue