TD-10431 rename variables
This commit is contained in:
parent
1bf566a701
commit
c7451a9949
|
@ -25,20 +25,20 @@ extern "C" {
|
||||||
int32_t mndInitTrans(SMnode *pMnode);
|
int32_t mndInitTrans(SMnode *pMnode);
|
||||||
void mndCleanupTrans(SMnode *pMnode);
|
void mndCleanupTrans(SMnode *pMnode);
|
||||||
|
|
||||||
STrans *trnCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle);
|
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle);
|
||||||
void trnDrop(STrans *pTrans);
|
void mndTransDrop(STrans *pTrans);
|
||||||
int32_t trnAppendRedoLog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
int32_t trnAppendUndoLog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
int32_t trnAppendCommitLog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
int32_t trnAppendRedoAction(STrans *pTrans, SEpSet *, void *pMsg);
|
int32_t mndTransAppendRedoAction(STrans *pTrans, SEpSet *, void *pMsg);
|
||||||
int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *, void *pMsg);
|
int32_t mndTransAppendUndoAction(STrans *pTrans, SEpSet *, void *pMsg);
|
||||||
|
|
||||||
int32_t trnPrepare(STrans *pTrans, int32_t (*syncfp)(SSdbRaw *pRaw, void *pData));
|
int32_t mndTransPrepare(STrans *pTrans, int32_t (*syncfp)(SSdbRaw *pRaw, void *pData));
|
||||||
int32_t trnApply(SMnode *pMnode, SSdbRaw *pRaw, void *pData, int32_t code);
|
int32_t mndTransApply(SMnode *pMnode, SSdbRaw *pRaw, void *pData, int32_t code);
|
||||||
int32_t trnExecute(SSdb *pSdb, int32_t tranId);
|
int32_t mndTransExecute(SSdb *pSdb, int32_t tranId);
|
||||||
|
|
||||||
SSdbRaw *trnActionEncode(STrans *pTrans);
|
SSdbRaw *mndTransActionEncode(STrans *pTrans);
|
||||||
SSdbRow *trnActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndTransActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ int32_t mndInitSync(SMnode *pMnode) { return 0; }
|
||||||
void mndCleanupSync(SMnode *pMnode) {}
|
void mndCleanupSync(SMnode *pMnode) {}
|
||||||
|
|
||||||
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, void *pData) {
|
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, void *pData) {
|
||||||
trnApply(pMnode, pData, pData, 0);
|
mndTransApply(pMnode, pData, pData, 0);
|
||||||
free(pData);
|
free(pData);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#define SDB_TRANS_VER 1
|
#define SDB_TRANS_VER 1
|
||||||
#define TRN_DEFAULT_ARRAY_SIZE 8
|
#define TRN_DEFAULT_ARRAY_SIZE 8
|
||||||
|
|
||||||
SSdbRaw *trnActionEncode(STrans *pTrans) {
|
SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
int32_t rawDataLen = 10 * sizeof(int32_t);
|
int32_t rawDataLen = 10 * sizeof(int32_t);
|
||||||
int32_t redoLogNum = taosArrayGetSize(pTrans->redoLogs);
|
int32_t redoLogNum = taosArrayGetSize(pTrans->redoLogs);
|
||||||
int32_t undoLogNum = taosArrayGetSize(pTrans->undoLogs);
|
int32_t undoLogNum = taosArrayGetSize(pTrans->undoLogs);
|
||||||
|
@ -84,7 +84,7 @@ SSdbRaw *trnActionEncode(STrans *pTrans) {
|
||||||
return pRaw;
|
return pRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *trnActionDecode(SSdbRaw *pRaw) {
|
SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) {
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) {
|
||||||
mError("failed to get soft ver from raw:%p since %s", pRaw, terrstr());
|
mError("failed to get soft ver from raw:%p since %s", pRaw, terrstr());
|
||||||
|
@ -150,7 +150,7 @@ SSdbRow *trnActionDecode(SSdbRaw *pRaw) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
mError("trn:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
|
mError("trn:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ SSdbRow *trnActionDecode(SSdbRaw *pRaw) {
|
||||||
return pRow;
|
return pRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t trnActionInsert(SSdb *pSdb, STrans *pTrans) {
|
static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
|
||||||
SArray *pArray = pTrans->redoLogs;
|
SArray *pArray = pTrans->redoLogs;
|
||||||
int32_t arraySize = taosArrayGetSize(pArray);
|
int32_t arraySize = taosArrayGetSize(pArray);
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ static int32_t trnActionInsert(SSdb *pSdb, STrans *pTrans) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t trnActionDelete(SSdb *pSdb, STrans *pTrans) {
|
static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) {
|
||||||
SArray *pArray = pTrans->redoLogs;
|
SArray *pArray = pTrans->redoLogs;
|
||||||
int32_t arraySize = taosArrayGetSize(pArray);
|
int32_t arraySize = taosArrayGetSize(pArray);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ static int32_t trnActionDelete(SSdb *pSdb, STrans *pTrans) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t trnActionUpdate(SSdb *pSdb, STrans *pTrans, STrans *pDstTrans) {
|
static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pTrans, STrans *pDstTrans) {
|
||||||
assert(true);
|
assert(true);
|
||||||
SArray *pArray = pTrans->redoLogs;
|
SArray *pArray = pTrans->redoLogs;
|
||||||
int32_t arraySize = taosArrayGetSize(pArray);
|
int32_t arraySize = taosArrayGetSize(pArray);
|
||||||
|
@ -213,7 +213,7 @@ static int32_t trnActionUpdate(SSdb *pSdb, STrans *pTrans, STrans *pDstTrans) {
|
||||||
|
|
||||||
static int32_t trnGenerateTransId() { return 1; }
|
static int32_t trnGenerateTransId() { return 1; }
|
||||||
|
|
||||||
STrans *trnCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
|
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
|
||||||
STrans *pTrans = calloc(1, sizeof(STrans));
|
STrans *pTrans = calloc(1, sizeof(STrans));
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -251,7 +251,7 @@ static void trnDropArray(SArray *pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trnDrop(STrans *pTrans) {
|
void mndTransDrop(STrans *pTrans) {
|
||||||
trnDropArray(pTrans->redoLogs);
|
trnDropArray(pTrans->redoLogs);
|
||||||
trnDropArray(pTrans->undoLogs);
|
trnDropArray(pTrans->undoLogs);
|
||||||
trnDropArray(pTrans->commitLogs);
|
trnDropArray(pTrans->commitLogs);
|
||||||
|
@ -262,12 +262,12 @@ void trnDrop(STrans *pTrans) {
|
||||||
tfree(pTrans);
|
tfree(pTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trnSetRpcHandle(STrans *pTrans, void *rpcHandle) {
|
void mndTransSetRpcHandle(STrans *pTrans, void *rpcHandle) {
|
||||||
pTrans->rpcHandle = rpcHandle;
|
pTrans->rpcHandle = rpcHandle;
|
||||||
mTrace("trn:%d, set rpc handle:%p", pTrans->id, rpcHandle);
|
mTrace("trn:%d, set rpc handle:%p", pTrans->id, rpcHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t trnAppendArray(SArray *pArray, SSdbRaw *pRaw) {
|
static int32_t mndTransAppendArray(SArray *pArray, SSdbRaw *pRaw) {
|
||||||
if (pArray == NULL || pRaw == NULL) {
|
if (pArray == NULL || pRaw == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -282,32 +282,32 @@ static int32_t trnAppendArray(SArray *pArray, SSdbRaw *pRaw) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnAppendRedoLog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
int32_t code = trnAppendArray(pTrans->redoLogs, pRaw);
|
int32_t code = mndTransAppendArray(pTrans->redoLogs, pRaw);
|
||||||
mTrace("trn:%d, raw:%p append to redo logs, code:%d", pTrans->id, pRaw, code);
|
mTrace("trn:%d, raw:%p append to redo logs, code:%d", pTrans->id, pRaw, code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnAppendUndoLog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
int32_t code = trnAppendArray(pTrans->undoLogs, pRaw);
|
int32_t code = mndTransAppendArray(pTrans->undoLogs, pRaw);
|
||||||
mTrace("trn:%d, raw:%p append to undo logs, code:%d", pTrans->id, pRaw, code);
|
mTrace("trn:%d, raw:%p append to undo logs, code:%d", pTrans->id, pRaw, code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnAppendCommitLog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
int32_t code = trnAppendArray(pTrans->commitLogs, pRaw);
|
int32_t code = mndTransAppendArray(pTrans->commitLogs, pRaw);
|
||||||
mTrace("trn:%d, raw:%p append to commit logs, code:%d", pTrans->id, pRaw, code);
|
mTrace("trn:%d, raw:%p append to commit logs, code:%d", pTrans->id, pRaw, code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnAppendRedoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
int32_t mndTransAppendRedoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
||||||
int32_t code = trnAppendArray(pTrans->redoActions, pMsg);
|
int32_t code = mndTransAppendArray(pTrans->redoActions, pMsg);
|
||||||
mTrace("trn:%d, msg:%p append to redo actions", pTrans->id, pMsg);
|
mTrace("trn:%d, msg:%p append to redo actions", pTrans->id, pMsg);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
int32_t mndTransAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
||||||
int32_t code = trnAppendArray(pTrans->undoActions, pMsg);
|
int32_t code = mndTransAppendArray(pTrans->undoActions, pMsg);
|
||||||
mTrace("trn:%d, msg:%p append to undo actions", pTrans->id, pMsg);
|
mTrace("trn:%d, msg:%p append to undo actions", pTrans->id, pMsg);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -315,11 +315,11 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
||||||
int32_t mndInitTrans(SMnode *pMnode) {
|
int32_t mndInitTrans(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_TRANS,
|
SSdbTable table = {.sdbType = SDB_TRANS,
|
||||||
.keyType = SDB_KEY_INT32,
|
.keyType = SDB_KEY_INT32,
|
||||||
.encodeFp = (SdbEncodeFp)trnActionEncode,
|
.encodeFp = (SdbEncodeFp)mndTransActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)trnActionDecode,
|
.decodeFp = (SdbDecodeFp)mndTransActionDecode,
|
||||||
.insertFp = (SdbInsertFp)trnActionInsert,
|
.insertFp = (SdbInsertFp)mndTransActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)trnActionUpdate,
|
.updateFp = (SdbUpdateFp)mndTransActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)trnActionDelete};
|
.deleteFp = (SdbDeleteFp)mndTransActionDelete};
|
||||||
sdbSetTable(pMnode->pSdb, table);
|
sdbSetTable(pMnode->pSdb, table);
|
||||||
|
|
||||||
mInfo("trn module is initialized");
|
mInfo("trn module is initialized");
|
||||||
|
@ -329,10 +329,10 @@ int32_t mndInitTrans(SMnode *pMnode) {
|
||||||
void mndCleanupTrans(SMnode *pMnode) { mInfo("trn module is cleaned up"); }
|
void mndCleanupTrans(SMnode *pMnode) { mInfo("trn module is cleaned up"); }
|
||||||
|
|
||||||
|
|
||||||
int32_t trnPrepare(STrans *pTrans, int32_t (*syncfp)(SSdbRaw *pRaw, void *pData)) {
|
int32_t mndTransPrepare(STrans *pTrans, int32_t (*syncfp)(SSdbRaw *pRaw, void *pData)) {
|
||||||
if (syncfp == NULL) return -1;
|
if (syncfp == NULL) return -1;
|
||||||
|
|
||||||
SSdbRaw *pRaw = trnActionEncode(pTrans);
|
SSdbRaw *pRaw = mndTransActionEncode(pTrans);
|
||||||
if (pRaw == NULL) {
|
if (pRaw == NULL) {
|
||||||
mError("trn:%d, failed to decode trans since %s", pTrans->id, terrstr());
|
mError("trn:%d, failed to decode trans since %s", pTrans->id, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -359,7 +359,7 @@ static void trnSendRpcRsp(void *rpcHandle, int32_t code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnApply(SMnode *pMnode, SSdbRaw *pRaw, void *pData, int32_t code) {
|
int32_t mndTransApply(SMnode *pMnode, SSdbRaw *pRaw, void *pData, int32_t code) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
trnSendRpcRsp(pData, terrno);
|
trnSendRpcRsp(pData, terrno);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -454,7 +454,7 @@ static int32_t trnPerformRetryStage(STrans *pTrans) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trnExecute(SSdb *pSdb, int32_t tranId) {
|
int32_t mndTransExecute(SSdb *pSdb, int32_t tranId) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
STrans *pTrans = sdbAcquire(pSdb, SDB_TRANS, &tranId);
|
STrans *pTrans = sdbAcquire(pSdb, SDB_TRANS, &tranId);
|
||||||
|
|
|
@ -137,39 +137,39 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
userObj.rootAuth = 0;
|
userObj.rootAuth = 0;
|
||||||
|
|
||||||
STrans *pTrans = trnCreate(pMnode, TRN_POLICY_ROLLBACK, pMsg->rpcMsg.handle);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, pMsg->rpcMsg.handle);
|
||||||
if (pTrans == NULL) return -1;
|
if (pTrans == NULL) return -1;
|
||||||
|
|
||||||
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||||
if (pRedoRaw == NULL || trnAppendRedoLog(pTrans, pRedoRaw) != 0) {
|
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||||
mError("failed to append redo log since %s", terrstr());
|
mError("failed to append redo log since %s", terrstr());
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING);
|
sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING);
|
||||||
|
|
||||||
SSdbRaw *pUndoRaw = mndUserActionEncode(&userObj);
|
SSdbRaw *pUndoRaw = mndUserActionEncode(&userObj);
|
||||||
if (pUndoRaw == NULL || trnAppendUndoLog(pTrans, pUndoRaw) != 0) {
|
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) {
|
||||||
mError("failed to append undo log since %s", terrstr());
|
mError("failed to append undo log since %s", terrstr());
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
|
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
|
||||||
|
|
||||||
SSdbRaw *pCommitRaw = mndUserActionEncode(&userObj);
|
SSdbRaw *pCommitRaw = mndUserActionEncode(&userObj);
|
||||||
if (pCommitRaw == NULL || trnAppendCommitLog(pTrans, pCommitRaw) != 0) {
|
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||||
mError("failed to append commit log since %s", terrstr());
|
mError("failed to append commit log since %s", terrstr());
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||||
|
|
||||||
if (trnPrepare(pTrans, mndSyncPropose) != 0) {
|
if (mndTransPrepare(pTrans, mndSyncPropose) != 0) {
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
trnDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue