2021-11-09 06:27:17 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-30 07:28:51 +00:00
|
|
|
#ifndef _TD_MND_TRANS_H_
|
|
|
|
|
#define _TD_MND_TRANS_H_
|
2021-11-09 06:27:17 +00:00
|
|
|
|
2021-11-27 14:56:18 +00:00
|
|
|
#include "mndInt.h"
|
2021-11-09 06:27:17 +00:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-05-30 01:47:16 +00:00
|
|
|
typedef enum {
|
|
|
|
|
TRANS_START_FUNC_TEST = 1,
|
|
|
|
|
TRANS_STOP_FUNC_TEST = 2,
|
|
|
|
|
TRANS_START_FUNC_MQ_REB = 3,
|
2022-05-30 12:38:46 +00:00
|
|
|
TRANS_STOP_FUNC_MQ_REB = 4,
|
2022-07-15 09:48:48 +00:00
|
|
|
TRANS_FUNC_RECOVER_STREAM_STEP_NEXT = 5,
|
2022-05-30 01:47:16 +00:00
|
|
|
} ETrnFunc;
|
|
|
|
|
|
2022-06-04 04:42:50 +00:00
|
|
|
typedef enum {
|
|
|
|
|
TRANS_ACTION_NULL = 0,
|
|
|
|
|
TRANS_ACTION_MSG = 1,
|
|
|
|
|
TRANS_ACTION_RAW = 2,
|
|
|
|
|
} ETrnAct;
|
|
|
|
|
|
2021-12-20 03:51:18 +00:00
|
|
|
typedef struct {
|
2022-06-07 01:59:15 +00:00
|
|
|
int32_t id;
|
|
|
|
|
int32_t errCode;
|
|
|
|
|
int32_t acceptableCode;
|
2022-06-27 09:10:38 +00:00
|
|
|
int32_t retryCode;
|
2022-06-07 01:59:15 +00:00
|
|
|
ETrnAct actionType;
|
2022-06-27 09:10:38 +00:00
|
|
|
ETrnStage stage;
|
|
|
|
|
int8_t reserved;
|
2022-06-07 01:59:15 +00:00
|
|
|
int8_t rawWritten;
|
|
|
|
|
int8_t msgSent;
|
|
|
|
|
int8_t msgReceived;
|
|
|
|
|
tmsg_t msgType;
|
|
|
|
|
SEpSet epSet;
|
|
|
|
|
int32_t contLen;
|
|
|
|
|
void *pCont;
|
|
|
|
|
SSdbRaw *pRaw;
|
2023-03-16 10:25:46 +00:00
|
|
|
|
|
|
|
|
int64_t mTraceId;
|
2022-05-30 12:38:46 +00:00
|
|
|
} STransAction;
|
2022-04-27 02:35:21 +00:00
|
|
|
|
|
|
|
|
typedef void (*TransCbFp)(SMnode *pMnode, void *param, int32_t paramLen);
|
|
|
|
|
|
2021-11-29 05:29:13 +00:00
|
|
|
int32_t mndInitTrans(SMnode *pMnode);
|
|
|
|
|
void mndCleanupTrans(SMnode *pMnode);
|
2022-05-04 15:58:42 +00:00
|
|
|
STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId);
|
|
|
|
|
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans);
|
2021-11-09 06:27:17 +00:00
|
|
|
|
2022-09-22 08:18:51 +00:00
|
|
|
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq,
|
|
|
|
|
const char *opername);
|
2021-11-29 08:02:37 +00:00
|
|
|
void mndTransDrop(STrans *pTrans);
|
2023-08-18 10:35:44 +00:00
|
|
|
|
|
|
|
|
int32_t mndTransAppendPrepareLog(STrans *pTrans, SSdbRaw *pRaw);
|
2021-11-29 08:02:37 +00:00
|
|
|
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
|
|
|
|
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
|
|
|
|
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
|
2022-06-04 04:42:50 +00:00
|
|
|
int32_t mndTransAppendNullLog(STrans *pTrans);
|
2023-08-18 10:35:44 +00:00
|
|
|
|
2021-12-20 03:51:18 +00:00
|
|
|
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
|
|
|
|
|
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
|
2022-01-27 01:33:44 +00:00
|
|
|
void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen);
|
2022-05-30 01:47:16 +00:00
|
|
|
void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *param, int32_t paramLen);
|
2022-09-19 02:39:51 +00:00
|
|
|
void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname);
|
2024-05-21 09:10:57 +00:00
|
|
|
void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId);
|
2022-05-31 09:35:28 +00:00
|
|
|
void mndTransSetSerial(STrans *pTrans);
|
2023-05-05 10:57:15 +00:00
|
|
|
void mndTransSetParallel(STrans *pTrans);
|
2024-03-22 07:27:22 +00:00
|
|
|
void mndTransSetChangeless(STrans *pTrans);
|
2022-07-19 04:00:43 +00:00
|
|
|
void mndTransSetOper(STrans *pTrans, EOperType oper);
|
2023-05-16 09:32:54 +00:00
|
|
|
int32_t mndTransCheckConflict(SMnode *pMnode, STrans *pTrans);
|
2024-06-26 09:40:17 +00:00
|
|
|
int32_t mndTransCheckConflictWithCompact(SMnode *pMnode, STrans *pTrans);
|
2024-02-17 10:25:10 +00:00
|
|
|
#ifndef BUILD_NO_CALL
|
2023-05-16 09:32:54 +00:00
|
|
|
static int32_t mndTrancCheckConflict(SMnode *pMnode, STrans *pTrans) {
|
|
|
|
|
return mndTransCheckConflict(pMnode, pTrans);
|
|
|
|
|
}
|
2024-02-17 10:25:10 +00:00
|
|
|
#endif
|
2021-12-14 09:13:18 +00:00
|
|
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
2022-06-04 04:42:50 +00:00
|
|
|
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
2022-01-04 11:44:44 +00:00
|
|
|
void mndTransPullup(SMnode *pMnode);
|
2022-05-05 08:13:51 +00:00
|
|
|
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
|
2023-05-22 02:37:55 +00:00
|
|
|
void mndTransExecute(SMnode *pMnode, STrans *pTrans);
|
|
|
|
|
void mndTransRefresh(SMnode *pMnode, STrans *pTrans);
|
2022-07-19 04:00:43 +00:00
|
|
|
int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, const char *dbname);
|
2021-11-29 08:02:37 +00:00
|
|
|
|
2023-05-30 10:50:00 +00:00
|
|
|
SSdbRaw *mndTransEncode(STrans *pTrans);
|
|
|
|
|
SSdbRow *mndTransDecode(SSdbRaw *pRaw);
|
|
|
|
|
void mndTransDropData(STrans *pTrans);
|
|
|
|
|
|
2023-12-19 11:51:51 +00:00
|
|
|
bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf);
|
2021-11-09 06:27:17 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-30 07:28:51 +00:00
|
|
|
#endif /*_TD_MND_TRANS_H_*/
|