Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
691cc93e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
691cc93e
编写于
5月 31, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
5月 31, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13311 from taosdata/fix/mnode
refactor: make trans support multi steps
上级
fac2a7ef
18ca6d93
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
477 addition
and
457 deletion
+477
-457
include/util/tdef.h
include/util/tdef.h
+1
-0
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+1
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+10
-12
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+15
-22
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+2
-6
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+2
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+6
-4
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+3
-3
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+1
-1
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+1
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+389
-369
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-2
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+1
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+1
-0
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+30
-24
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+5
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+1
-3
未找到文件。
include/util/tdef.h
浏览文件 @
691cc93e
...
...
@@ -254,6 +254,7 @@ typedef enum ELogicConditionType {
#define TSDB_TRANS_STAGE_LEN 12
#define TSDB_TRANS_TYPE_LEN 16
#define TSDB_TRANS_ERROR_LEN 64
#define TSDB_TRANS_DESC_LEN 128
#define TSDB_STEP_NAME_LEN 32
#define TSDB_STEP_DESC_LEN 128
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
691cc93e
...
...
@@ -130,7 +130,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
_OVER:
if
(
code
!=
0
)
{
d
Error
(
"msg:%p, failed to process since %s"
,
pMsg
,
terrstr
(
));
d
Trace
(
"msg:%p, failed to process since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pRpc
->
msgType
));
if
(
terrno
!=
0
)
code
=
terrno
;
if
(
IsReq
(
pRpc
))
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
691cc93e
...
...
@@ -60,14 +60,12 @@ typedef enum {
typedef
enum
{
TRN_STAGE_PREPARE
=
0
,
TRN_STAGE_REDO_LOG
=
1
,
TRN_STAGE_REDO_ACTION
=
2
,
TRN_STAGE_ROLLBACK
=
3
,
TRN_STAGE_UNDO_ACTION
=
4
,
TRN_STAGE_UNDO_LOG
=
5
,
TRN_STAGE_COMMIT
=
6
,
TRN_STAGE_COMMIT_LOG
=
7
,
TRN_STAGE_FINISHED
=
8
TRN_STAGE_REDO_ACTION
=
1
,
TRN_STAGE_ROLLBACK
=
2
,
TRN_STAGE_UNDO_ACTION
=
3
,
TRN_STAGE_COMMIT
=
4
,
TRN_STAGE_COMMIT_ACTION
=
5
,
TRN_STAGE_FINISHED
=
6
}
ETrnStage
;
typedef
enum
{
...
...
@@ -131,7 +129,7 @@ typedef enum {
typedef
enum
{
TRN_EXEC_PARALLEL
=
0
,
TRN_EXEC_
ONE_BY_ONE
=
1
,
TRN_EXEC_
NO_PARALLEL
=
1
,
}
ETrnExecType
;
typedef
enum
{
...
...
@@ -168,16 +166,16 @@ typedef struct {
SRpcHandleInfo
rpcInfo
;
void
*
rpcRsp
;
int32_t
rpcRspLen
;
SArray
*
redoLogs
;
SArray
*
undoLogs
;
SArray
*
commitLogs
;
int32_t
redoActionPos
;
SArray
*
redoActions
;
SArray
*
undoActions
;
SArray
*
commitActions
;
int64_t
createdTime
;
int64_t
lastExecTime
;
int64_t
dbUid
;
char
dbname
[
TSDB_DB_FNAME_LEN
];
char
lastError
[
TSDB_TRANS_ERROR_LEN
];
char
desc
[
TSDB_TRANS_DESC_LEN
];
int32_t
startFunc
;
int32_t
stopFunc
;
int32_t
paramLen
;
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
691cc93e
...
...
@@ -26,31 +26,24 @@ typedef enum {
TRANS_START_FUNC_TEST
=
1
,
TRANS_STOP_FUNC_TEST
=
2
,
TRANS_START_FUNC_MQ_REB
=
3
,
TRANS_STOP_FUNC_
TEST_
MQ_REB
=
4
,
TRANS_STOP_FUNC_MQ_REB
=
4
,
}
ETrnFunc
;
typedef
struct
{
SEpSet
epSet
;
tmsg_t
msgType
;
int8_t
msgSent
;
int8_t
msgReceived
;
int32_t
errCode
;
int32_t
acceptableCode
;
int32_t
contLen
;
void
*
pCont
;
}
STransAction
;
typedef
struct
{
int32_t
id
;
int32_t
errCode
;
int32_t
acceptableCode
;
int8_t
stage
;
int8_t
isRaw
;
int8_t
rawWritten
;
int8_t
msgSent
;
int8_t
msgReceived
;
tmsg_t
msgType
;
SEpSet
epSet
;
int32_t
contLen
;
void
*
pCont
;
SSdbRaw
*
pRaw
;
}
STransLog
;
typedef
struct
{
ETrnStep
stepType
;
STransAction
redoAction
;
STransAction
undoAction
;
STransLog
redoLog
;
STransLog
undoLog
;
}
STransStep
;
}
STransAction
;
typedef
void
(
*
TransCbFp
)(
SMnode
*
pMnode
,
void
*
param
,
int32_t
paramLen
);
...
...
@@ -69,7 +62,7 @@ int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
void
mndTransSetCb
(
STrans
*
pTrans
,
ETrnFunc
startFunc
,
ETrnFunc
stopFunc
,
void
*
param
,
int32_t
paramLen
);
void
mndTransSetDbInfo
(
STrans
*
pTrans
,
SDbObj
*
pDb
);
void
mndTransSet
ExecOneByOne
(
STrans
*
pTrans
);
void
mndTransSet
NoParallel
(
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransProcessRsp
(
SRpcMsg
*
pRsp
);
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
691cc93e
...
...
@@ -78,10 +78,8 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"acct:%s, will be created while deploy sdb, raw:%p"
,
acctObj
.
acct
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
#else
mDebug
(
"acct:%s, will be created when deploying, raw:%p"
,
acctObj
.
acct
,
pRaw
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_ACCT
,
NULL
);
if
(
pTrans
==
NULL
)
{
mError
(
"acct:%s, failed to create since %s"
,
acctObj
.
acct
,
terrstr
());
...
...
@@ -94,7 +92,6 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
...
...
@@ -104,7 +101,6 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
mndTransDrop
(
pTrans
);
return
0
;
#endif
}
static
SSdbRaw
*
mndAcctActionEncode
(
SAcctObj
*
pAcct
)
{
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
691cc93e
...
...
@@ -172,13 +172,13 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
clusterObj
.
id
=
mndGenerateUid
(
clusterObj
.
name
,
TSDB_CLUSTER_ID_LEN
);
clusterObj
.
id
=
(
clusterObj
.
id
>=
0
?
clusterObj
.
id
:
-
clusterObj
.
id
);
pMnode
->
clusterId
=
clusterObj
.
id
;
m
Debug
(
"cluster:%"
PRId64
", name is %s"
,
clusterObj
.
id
,
clusterObj
.
name
);
m
Info
(
"cluster:%"
PRId64
", name is %s"
,
clusterObj
.
id
,
clusterObj
.
name
);
SSdbRaw
*
pRaw
=
mndClusterActionEncode
(
&
clusterObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"cluster:%"
PRId64
", will be created wh
ile deploy sdb
, raw:%p"
,
clusterObj
.
id
,
pRaw
);
mDebug
(
"cluster:%"
PRId64
", will be created wh
en deploying
, raw:%p"
,
clusterObj
.
id
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
#else
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
691cc93e
...
...
@@ -1314,7 +1314,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pDbVgVersion
->
dbFName
);
if
(
pDb
==
NULL
)
{
m
Debug
(
"db:%s, no exist"
,
pDbVgVersion
->
dbFName
);
m
Trace
(
"db:%s, no exist"
,
pDbVgVersion
->
dbFName
);
memcpy
(
usedbRsp
.
db
,
pDbVgVersion
->
dbFName
,
TSDB_DB_FNAME_LEN
);
usedbRsp
.
uid
=
pDbVgVersion
->
dbId
;
usedbRsp
.
vgVersion
=
-
1
;
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
691cc93e
...
...
@@ -98,7 +98,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
if
(
pRaw
==
NULL
)
return
-
1
;
if
(
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
mDebug
(
"dnode:%d, will be created wh
ile deploy sdb
, raw:%p"
,
dnodeObj
.
id
,
pRaw
);
mDebug
(
"dnode:%d, will be created wh
en deploying
, raw:%p"
,
dnodeObj
.
id
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
...
...
@@ -388,9 +388,10 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
mndReleaseMnode
(
pMnode
,
pObj
);
}
int64_t
dnodeVer
=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
)
+
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_MNODE
);
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
bool
dnodeChanged
=
(
statusReq
.
dnodeVer
!=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
)
);
bool
dnodeChanged
=
(
statusReq
.
dnodeVer
!=
dnodeVer
);
bool
reboot
=
(
pDnode
->
rebootTime
!=
statusReq
.
rebootTime
);
bool
needCheck
=
!
online
||
dnodeChanged
||
reboot
;
...
...
@@ -433,7 +434,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
if
(
!
online
)
{
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
}
else
{
mDebug
(
"dnode:%d, send dnode eps"
,
pDnode
->
id
);
mDebug
(
"dnode:%d, send dnode epset, online:%d ver:% "
PRId64
":%"
PRId64
" reboot:%d"
,
pDnode
->
id
,
online
,
statusReq
.
dnodeVer
,
dnodeVer
,
reboot
);
}
pDnode
->
rebootTime
=
statusReq
.
rebootTime
;
...
...
@@ -441,7 +443,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
pDnode
->
numOfSupportVnodes
=
statusReq
.
numOfSupportVnodes
;
SStatusRsp
statusRsp
=
{
0
};
statusRsp
.
dnodeVer
=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
)
+
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_MNODE
)
;
statusRsp
.
dnodeVer
=
dnodeVer
;
statusRsp
.
dnodeCfg
.
dnodeId
=
pDnode
->
id
;
statusRsp
.
dnodeCfg
.
clusterId
=
pMnode
->
clusterId
;
statusRsp
.
pDnodeEps
=
taosArrayInit
(
mndGetDnodeSize
(
pMnode
),
sizeof
(
SDnodeEp
));
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
691cc93e
...
...
@@ -472,7 +472,7 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
}
else
if
(
code
==
0
)
{
mTrace
(
"msg:%p, successfully processed and response"
,
pMsg
);
}
else
{
m
Error
(
"msg:%p, failed to process since %s, app:%p type:%s"
,
pMsg
,
terrstr
(),
pMsg
->
info
.
ahandle
,
m
Debug
(
"msg:%p, failed to process since %s, app:%p type:%s"
,
pMsg
,
terrstr
(),
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
691cc93e
...
...
@@ -90,7 +90,7 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"mnode:%d, will be created wh
ile deploy sdb
, raw:%p"
,
mnodeObj
.
id
,
pRaw
);
mDebug
(
"mnode:%d, will be created wh
en deploying
, raw:%p"
,
mnodeObj
.
id
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
...
...
@@ -367,7 +367,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
mndTransSet
ExecOneByOne
(
pTrans
);
mndTransSet
NoParallel
(
pTrans
);
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
...
...
@@ -539,7 +539,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop mnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
mndTransSet
ExecOneByOne
(
pTrans
);
mndTransSet
NoParallel
(
pTrans
);
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
691cc93e
...
...
@@ -507,7 +507,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
mDebug
(
"trans:%d, used to create sma:%s"
,
pTrans
->
id
,
pCreate
->
name
);
mndTransSetDbInfo
(
pTrans
,
pDb
);
mndTransSet
ExecOneByOne
(
pTrans
);
mndTransSet
NoParallel
(
pTrans
);
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
691cc93e
...
...
@@ -1597,7 +1597,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
pReq
->
info
.
rspLen
=
rspLen
;
code
=
0
;
m
Debug
(
"stb:
%s.%s, meta is retrieved"
,
infoReq
.
dbFName
,
infoReq
.
tbName
);
m
Trace
(
"
%s.%s, meta is retrieved"
,
infoReq
.
dbFName
,
infoReq
.
tbName
);
_OVER:
if
(
code
!=
0
)
{
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
691cc93e
...
...
@@ -501,7 +501,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu
// 4. TODO commit log: modification log
// 5. set cb
mndTransSetCb
(
pTrans
,
TRANS_START_FUNC_MQ_REB
,
TRANS_STOP_FUNC_
TEST_
MQ_REB
,
NULL
,
0
);
mndTransSetCb
(
pTrans
,
TRANS_START_FUNC_MQ_REB
,
TRANS_STOP_FUNC_MQ_REB
,
NULL
,
0
);
// 6. execution
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
691cc93e
...
...
@@ -65,7 +65,7 @@ int32_t mndSyncGetSnapshot(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
void
mndRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
if
(
!
pMnode
->
deploy
)
{
mInfo
(
"mnode sync restore finished"
);
mInfo
(
"mnode sync restore finished
, and will handle outstanding transactions
"
);
mndTransPullup
(
pMnode
);
mndSetRestore
(
pMnode
,
true
);
}
else
{
...
...
@@ -244,7 +244,7 @@ void mndSyncStart(SMnode *pMnode) {
}
else
{
syncStart
(
pMgmt
->
sync
);
}
mDebug
(
"
sync:%"
PRId64
" is started,
standby:%d"
,
pMgmt
->
sync
,
pMgmt
->
standby
);
mDebug
(
"
mnode sync started, id:%"
PRId64
"
standby:%d"
,
pMgmt
->
sync
,
pMgmt
->
standby
);
}
void
mndSyncStop
(
SMnode
*
pMnode
)
{}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
691cc93e
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
691cc93e
...
...
@@ -77,7 +77,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"user:%s, will be created wh
ile deploy sdb
, raw:%p"
,
userObj
.
user
,
pRaw
);
mDebug
(
"user:%s, will be created wh
en deploying
, raw:%p"
,
userObj
.
user
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
691cc93e
...
...
@@ -501,7 +501,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
*
ppVgroups
=
pVgroups
;
code
=
0
;
mInfo
(
"db:%s, %d vgroups is alloced, replica:%d"
,
pDb
->
name
,
pDb
->
cfg
.
numOfVgroups
,
pDb
->
cfg
.
replications
);
mInfo
(
"db:%s,
total
%d vgroups is alloced, replica:%d"
,
pDb
->
name
,
pDb
->
cfg
.
numOfVgroups
,
pDb
->
cfg
.
replications
);
_OVER:
if
(
code
!=
0
)
taosMemoryFree
(
pVgroups
);
...
...
@@ -539,7 +539,7 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
pVgid
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
pDnode
->
numOfVnodes
++
;
mInfo
(
"db:%s, vgId:%d, vn:%d dnode:%d is added"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
,
maxPos
,
pVgid
->
dnodeId
);
mInfo
(
"db:%s, vgId:%d, vn
ode_index
:%d dnode:%d is added"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
,
maxPos
,
pVgid
->
dnodeId
);
maxPos
++
;
if
(
maxPos
==
3
)
return
0
;
}
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
691cc93e
...
...
@@ -168,6 +168,7 @@ typedef struct SSdb {
char
*
currDir
;
char
*
tmpDir
;
int64_t
lastCommitVer
;
int64_t
lastCommitTerm
;
int64_t
curVer
;
int64_t
curTerm
;
int64_t
tableVer
[
SDB_MAX
];
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
691cc93e
...
...
@@ -55,6 +55,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
pSdb
->
curVer
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
lastCommitTerm
=
-
1
;
pSdb
->
pMnode
=
pOption
->
pMnode
;
taosThreadMutexInit
(
&
pSdb
->
filelock
,
NULL
);
mDebug
(
"sdb init successfully"
);
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
691cc93e
...
...
@@ -70,6 +70,7 @@ static void sdbResetData(SSdb *pSdb) {
pSdb
->
curVer
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
lastCommitTerm
=
-
1
;
mDebug
(
"sdb reset successfully"
);
}
...
...
@@ -211,12 +212,12 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
char
file
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
mDebug
(
"start to read file:%s"
,
file
);
mDebug
(
"start to read
sdb
file:%s"
,
file
);
SSdbRaw
*
pRaw
=
taosMemoryMalloc
(
WAL_MAX_SIZE
+
100
);
if
(
pRaw
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"failed read file since %s"
,
terrstr
());
mError
(
"failed read
sdb
file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -224,12 +225,12 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
if
(
pFile
==
NULL
)
{
taosMemoryFree
(
pRaw
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to read file:%s since %s"
,
file
,
terrstr
());
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
terrstr
());
return
0
;
}
if
(
sdbReadFileHead
(
pSdb
,
pFile
)
!=
0
)
{
mError
(
"failed to read file:%s head since %s"
,
file
,
terrstr
());
mError
(
"failed to read
sdb
file:%s head since %s"
,
file
,
terrstr
());
taosMemoryFree
(
pRaw
);
taosCloseFile
(
&
pFile
);
return
-
1
;
...
...
@@ -245,13 +246,13 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
if
(
ret
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
if
(
ret
!=
readLen
)
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
...
...
@@ -259,34 +260,36 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
ret
=
taosReadFile
(
pFile
,
pRaw
->
pData
,
readLen
);
if
(
ret
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
if
(
ret
!=
readLen
)
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
int32_t
totalLen
=
sizeof
(
SSdbRaw
)
+
pRaw
->
dataLen
+
sizeof
(
int32_t
);
if
((
!
taosCheckChecksumWhole
((
const
uint8_t
*
)
pRaw
,
totalLen
))
!=
0
)
{
code
=
TSDB_CODE_CHECKSUM_ERROR
;
mError
(
"failed to read file:%s since %s"
,
file
,
tstrerror
(
code
));
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
tstrerror
(
code
));
break
;
}
code
=
sdbWriteWithoutFree
(
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"failed to read file:%s since %s"
,
file
,
terrstr
());
mError
(
"failed to read
sdb
file:%s since %s"
,
file
,
terrstr
());
goto
_OVER
;
}
}
code
=
0
;
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
pSdb
->
lastCommitTerm
=
pSdb
->
curTerm
;
memcpy
(
pSdb
->
tableVer
,
tableVer
,
sizeof
(
tableVer
));
mDebug
(
"read file:%s successfully, ver:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
);
mDebug
(
"read sdb file:%s successfully, ver:%"
PRId64
" term:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
);
_OVER:
taosCloseFile
(
&
pFile
);
...
...
@@ -302,7 +305,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
sdbResetData
(
pSdb
);
int32_t
code
=
sdbReadFileImp
(
pSdb
);
if
(
code
!=
0
)
{
mError
(
"failed to read sdb since %s"
,
terrstr
());
mError
(
"failed to read sdb
file
since %s"
,
terrstr
());
sdbResetData
(
pSdb
);
}
...
...
@@ -318,18 +321,19 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
char
curfile
[
PATH_MAX
]
=
{
0
};
snprintf
(
curfile
,
sizeof
(
curfile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
mDebug
(
"start to write file:%s, current ver:%"
PRId64
" term:%"
PRId64
", commit ver:%"
PRId64
,
curfile
,
pSdb
->
curVer
,
pSdb
->
curTerm
,
pSdb
->
lastCommitVer
);
mDebug
(
"start to write sdb file, current ver:%"
PRId64
" term:%"
PRId64
", commit ver:%"
PRId64
" term:%"
PRId64
" file:%s"
,
pSdb
->
curVer
,
pSdb
->
curTerm
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
,
curfile
);
TdFilePtr
pFile
=
taosOpenFile
(
tmpfile
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to open file:%s for write since %s"
,
tmpfile
,
terrstr
());
mError
(
"failed to open
sdb
file:%s for write since %s"
,
tmpfile
,
terrstr
());
return
-
1
;
}
if
(
sdbWriteFileHead
(
pSdb
,
pFile
)
!=
0
)
{
mError
(
"failed to write file:%s head since %s"
,
tmpfile
,
terrstr
());
mError
(
"failed to write
sdb
file:%s head since %s"
,
tmpfile
,
terrstr
());
taosCloseFile
(
&
pFile
);
return
-
1
;
}
...
...
@@ -338,7 +342,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
SdbEncodeFp
encodeFp
=
pSdb
->
encodeFps
[
i
];
if
(
encodeFp
==
NULL
)
continue
;
mTrace
(
"write %s to file, total %d rows"
,
sdbTableName
(
i
),
sdbGetSize
(
pSdb
,
i
));
mTrace
(
"write %s to
sdb
file, total %d rows"
,
sdbTableName
(
i
),
sdbGetSize
(
pSdb
,
i
));
SHashObj
*
hash
=
pSdb
->
hashObjs
[
i
];
TdThreadRwlock
*
pLock
=
&
pSdb
->
locks
[
i
];
...
...
@@ -394,7 +398,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
code
=
taosFsyncFile
(
pFile
);
if
(
code
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to sync file:%s since %s"
,
tmpfile
,
tstrerror
(
code
));
mError
(
"failed to sync
sdb
file:%s since %s"
,
tmpfile
,
tstrerror
(
code
));
}
}
...
...
@@ -404,15 +408,17 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
code
=
taosRenameFile
(
tmpfile
,
curfile
);
if
(
code
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to write file:%s since %s"
,
curfile
,
tstrerror
(
code
));
mError
(
"failed to write
sdb
file:%s since %s"
,
curfile
,
tstrerror
(
code
));
}
}
if
(
code
!=
0
)
{
mError
(
"failed to write file:%s since %s"
,
curfile
,
tstrerror
(
code
));
mError
(
"failed to write
sdb
file:%s since %s"
,
curfile
,
tstrerror
(
code
));
}
else
{
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
mDebug
(
"write file:%s successfully, ver:%"
PRId64
" term:%"
PRId64
,
curfile
,
pSdb
->
lastCommitVer
,
pSdb
->
curTerm
);
pSdb
->
lastCommitTerm
=
pSdb
->
curTerm
;
mDebug
(
"write sdb file successfully, ver:%"
PRId64
" term:%"
PRId64
" file:%s"
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
,
curfile
);
}
terrno
=
code
;
...
...
@@ -427,7 +433,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
taosThreadMutexLock
(
&
pSdb
->
filelock
);
int32_t
code
=
sdbWriteFileImp
(
pSdb
);
if
(
code
!=
0
)
{
mError
(
"failed to write sdb since %s"
,
terrstr
());
mError
(
"failed to write sdb
file
since %s"
,
terrstr
());
}
taosThreadMutexUnlock
(
&
pSdb
->
filelock
);
return
code
;
...
...
@@ -493,7 +499,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
if
(
taosCopyFile
(
datafile
,
pIter
->
name
)
<
0
)
{
taosThreadMutexUnlock
(
&
pSdb
->
filelock
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to copy file %s to %s since %s"
,
datafile
,
pIter
->
name
,
terrstr
());
mError
(
"failed to copy
sdb
file %s to %s since %s"
,
datafile
,
pIter
->
name
,
terrstr
());
sdbCloseIter
(
pIter
);
return
-
1
;
}
...
...
@@ -502,7 +508,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
pIter
->
file
=
taosOpenFile
(
pIter
->
name
,
TD_FILE_READ
);
if
(
pIter
->
file
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to open file:%s since %s"
,
pIter
->
name
,
terrstr
());
mError
(
"failed to open
sdb
file:%s since %s"
,
pIter
->
name
,
terrstr
());
sdbCloseIter
(
pIter
);
return
-
1
;
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
691cc93e
...
...
@@ -79,7 +79,11 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryEnd) {
if
(
taskHandle
)
{
code
=
qExecTask
(
taskHandle
,
&
pRes
,
&
useconds
);
if
(
code
)
{
QW_TASK_ELOG
(
"qExecTask failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
if
(
code
!=
TSDB_CODE_OPS_NOT_SUPPORT
)
{
QW_TASK_ELOG
(
"qExecTask failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
}
else
{
QW_TASK_DLOG
(
"qExecTask failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
}
QW_ERR_RET
(
code
);
}
}
...
...
tests/test/c/sdbDump.c
浏览文件 @
691cc93e
...
...
@@ -283,9 +283,7 @@ void dumpTrans(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject
(
item
,
"createdTime"
,
i642str
(
pObj
->
createdTime
));
tjsonAddStringToObject
(
item
,
"dbUid"
,
i642str
(
pObj
->
dbUid
));
tjsonAddStringToObject
(
item
,
"dbname"
,
pObj
->
dbname
);
tjsonAddIntegerToObject
(
item
,
"redoLogNum"
,
taosArrayGetSize
(
pObj
->
redoLogs
));
tjsonAddIntegerToObject
(
item
,
"undoLogNum"
,
taosArrayGetSize
(
pObj
->
undoLogs
));
tjsonAddIntegerToObject
(
item
,
"commitLogNum"
,
taosArrayGetSize
(
pObj
->
commitLogs
));
tjsonAddIntegerToObject
(
item
,
"commitLogNum"
,
taosArrayGetSize
(
pObj
->
commitActions
));
tjsonAddIntegerToObject
(
item
,
"redoActionNum"
,
taosArrayGetSize
(
pObj
->
redoActions
));
tjsonAddIntegerToObject
(
item
,
"undoActionNum"
,
taosArrayGetSize
(
pObj
->
undoActions
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录