Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c1e1dd64
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c1e1dd64
编写于
11月 18, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2045
上级
98ec34b4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
140 addition
and
150 deletion
+140
-150
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+2
-2
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+3
-3
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+1
-1
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+67
-77
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+61
-61
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+6
-6
未找到文件。
src/mnode/inc/mnodeSdb.h
浏览文件 @
c1e1dd64
...
...
@@ -52,11 +52,11 @@ typedef enum {
typedef
struct
SSWriteMsg
{
ESdbOper
type
;
int32_t
processedCount
;
// for sync fwd callback
int32_t
retCode
;
// for callback in sdb queue
int32_t
code
;
// for callback in sdb queue
int32_t
rowSize
;
void
*
rowData
;
int32_t
(
*
fpReq
)(
SMnodeMsg
*
pMsg
);
int32_t
(
*
fp
Write
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
int32_t
(
*
fp
Rsp
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
void
*
pRow
;
SMnodeMsg
*
pMsg
;
struct
SSdbTable
*
pTable
;
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
c1e1dd64
...
...
@@ -418,7 +418,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
.
pRow
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
),
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeCreateDbCb
.
fp
Rsp
=
mnodeCreateDbCb
};
code
=
sdbInsertRow
(
&
wmsg
);
...
...
@@ -1024,7 +1024,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
.
pTable
=
tsDbSdb
,
.
pRow
=
pDb
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAlterDbCb
.
fp
Rsp
=
mnodeAlterDbCb
};
code
=
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1076,7 +1076,7 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
.
pTable
=
tsDbSdb
,
.
pRow
=
pDb
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeDropDbCb
.
fp
Rsp
=
mnodeDropDbCb
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
c1e1dd64
...
...
@@ -329,7 +329,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsMnodeSdb
,
.
pRow
=
pMnode
,
.
fp
Write
=
mnodeCreateMnodeCb
.
fp
Rsp
=
mnodeCreateMnodeCb
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
c1e1dd64
...
...
@@ -48,6 +48,13 @@ typedef enum {
SDB_STATUS_CLOSING
=
2
}
ESdbStatus
;
char
*
actStr
[]
=
{
"insert"
,
"delete"
,
"update"
,
"invalid"
};
typedef
struct
SSdbTable
{
char
tableName
[
SDB_TABLE_LEN
];
ESdbTable
tableId
;
...
...
@@ -140,18 +147,6 @@ static void *sdbGetObjKey(SSdbTable *pTable, void *key) {
return
key
;
}
static
char
*
sdbGetActionStr
(
int32_t
action
)
{
switch
(
action
)
{
case
SDB_ACTION_INSERT
:
return
"insert"
;
case
SDB_ACTION_DELETE
:
return
"delete"
;
case
SDB_ACTION_UPDATE
:
return
"update"
;
}
return
"invalid"
;
}
static
char
*
sdbGetKeyStr
(
SSdbTable
*
pTable
,
void
*
key
)
{
static
char
str
[
16
];
switch
(
pTable
->
keyType
)
{
...
...
@@ -167,7 +162,7 @@ static char *sdbGetKeyStr(SSdbTable *pTable, void *key) {
}
}
static
char
*
sdbGet
Obj
Str
(
SSdbTable
*
pTable
,
void
*
key
)
{
static
char
*
sdbGet
Row
Str
(
SSdbTable
*
pTable
,
void
*
key
)
{
return
sdbGetKeyStr
(
pTable
,
sdbGetObjKey
(
pTable
,
key
));
}
...
...
@@ -254,33 +249,28 @@ static void sdbNotifyRole(void *ahandle, int8_t role) {
}
FORCE_INLINE
static
void
sdbConfirmForward
(
void
*
ahandle
,
void
*
param
,
int32_t
code
)
{
assert
(
param
);
SSWriteMsg
*
pWrite
=
param
;
SMnodeMsg
*
pMsg
=
pWrite
->
pMsg
;
if
(
code
<=
0
)
pWrite
->
retCode
=
code
;
int32_t
processedCount
=
atomic_add_fetch_32
(
&
pWrite
->
processedCount
,
1
);
if
(
processedCount
<=
1
)
{
if
(
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, msg:%p waiting for confirm, count:%d code:%x"
,
pMsg
,
processedCount
,
code
);
}
return
;
}
static
void
sdbConfirmForward
(
void
*
ahandle
,
void
*
wparam
,
int32_t
code
)
{
if
(
wparam
==
NULL
)
return
;
SSWriteMsg
*
pWrite
=
wparam
;
SMnodeMsg
*
pMsg
=
pWrite
->
pMsg
;
if
(
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, msg:%p is confirmed, code:%x"
,
pMsg
,
code
);
if
(
code
<=
0
)
pWrite
->
code
=
code
;
int32_t
count
=
atomic_add_fetch_32
(
&
pWrite
->
processedCount
,
1
);
if
(
count
<=
1
)
{
if
(
pMsg
!=
NULL
)
sdbTrace
(
"vgId:1, msg:%p waiting for confirm, count:%d code:%x"
,
pMsg
,
count
,
code
);
return
;
}
else
{
if
(
pMsg
!=
NULL
)
sdbTrace
(
"vgId:1, msg:%p is confirmed, code:%x"
,
pMsg
,
code
);
}
// failed to forward, need revert insert
if
(
pWrite
->
retC
ode
!=
TSDB_CODE_SUCCESS
)
{
SWalHead
*
pHead
=
(
void
*
)
pWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
if
(
pWrite
->
c
ode
!=
TSDB_CODE_SUCCESS
)
{
SWalHead
*
pHead
=
(
SWalHead
*
)((
char
*
)
pWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
)
;
int32_t
action
=
pHead
->
msgType
%
10
;
sdbError
(
"vgId:1,
key:%p:%s hver:%"
PRIu64
" action:%d
, failed to foward since %s"
,
pWrite
->
pRow
,
sdbGetKeyStr
(
pWrite
->
pTable
,
pHead
->
cont
),
pHead
->
version
,
act
ion
,
tstrerror
(
pWrite
->
retC
ode
));
sdbError
(
"vgId:1,
row:%p:%s hver:%"
PRIu64
" action:%s
, failed to foward since %s"
,
pWrite
->
pRow
,
sdbGetKeyStr
(
pWrite
->
pTable
,
pHead
->
cont
),
pHead
->
version
,
act
Str
[
action
],
tstrerror
(
pWrite
->
c
ode
));
if
(
action
==
SDB_ACTION_INSERT
)
{
// It's better to create a table in two stages, create it first and then set it success
//sdbDeleteHash(pWrite->pTable, pWrite);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
pWrite
->
pTable
,
...
...
@@ -290,10 +280,10 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
}
}
if
(
pWrite
->
fp
Write
!=
NULL
)
{
pWrite
->
retCode
=
(
*
pWrite
->
fpWrite
)(
pMsg
,
pWrite
->
retC
ode
);
if
(
pWrite
->
fp
Rsp
!=
NULL
)
{
pWrite
->
code
=
(
*
pWrite
->
fpRsp
)(
pMsg
,
pWrite
->
c
ode
);
}
dnodeSendRpcMWriteRsp
(
pMsg
,
pWrite
->
retC
ode
);
dnodeSendRpcMWriteRsp
(
pMsg
,
pWrite
->
c
ode
);
// if ahandle, means this func is called by sdb write
if
(
ahandle
==
NULL
)
{
...
...
@@ -449,7 +439,7 @@ void sdbIncRef(void *tparam, void *pRow) {
SSdbTable
*
pTable
=
tparam
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_add_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"vgId:1, sdb:%s, inc ref to
key:%p:%s:%d"
,
pTable
->
tableName
,
pRow
,
sdbGetObj
Str
(
pTable
,
pRow
),
refCount
);
sdbTrace
(
"vgId:1, sdb:%s, inc ref to
row:%p:%s:%d"
,
pTable
->
tableName
,
pRow
,
sdbGetRow
Str
(
pTable
,
pRow
),
refCount
);
}
void
sdbDecRef
(
void
*
tparam
,
void
*
pRow
)
{
...
...
@@ -458,11 +448,11 @@ void sdbDecRef(void *tparam, void *pRow) {
SSdbTable
*
pTable
=
tparam
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_sub_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"vgId:1, sdb:%s, dec ref to
key:%p:%s:%d"
,
pTable
->
tableName
,
pRow
,
sdbGetObj
Str
(
pTable
,
pRow
),
refCount
);
sdbTrace
(
"vgId:1, sdb:%s, dec ref to
row:%p:%s:%d"
,
pTable
->
tableName
,
pRow
,
sdbGetRow
Str
(
pTable
,
pRow
),
refCount
);
int32_t
*
updateEnd
=
pRow
+
pTable
->
refCountPos
-
4
;
if
(
refCount
<=
0
&&
*
updateEnd
)
{
sdbTrace
(
"vgId:1, sdb:%s,
key:%p:%s:%d destroyed"
,
pTable
->
tableName
,
pRow
,
sdbGetObj
Str
(
pTable
,
pRow
),
refCount
);
sdbTrace
(
"vgId:1, sdb:%s,
row:%p:%s:%d destroyed"
,
pTable
->
tableName
,
pRow
,
sdbGetRow
Str
(
pTable
,
pRow
),
refCount
);
SSWriteMsg
wmsg
=
{.
pRow
=
pRow
};
(
*
pTable
->
fpDestroy
)(
&
wmsg
);
}
...
...
@@ -523,12 +513,12 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
}
sdbDebug
(
"vgId:1, sdb:%s, insert key:%s to hash, rowSize:%d rows:%"
PRId64
", msg:%p"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
),
pWrite
->
rowSize
,
pTable
->
numOfRows
,
pWrite
->
pMsg
);
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
),
pWrite
->
rowSize
,
pTable
->
numOfRows
,
pWrite
->
pMsg
);
int32_t
code
=
(
*
pTable
->
fpInsert
)(
pWrite
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sdbError
(
"vgId:1, sdb:%s, failed to insert key:%s to hash, remove it"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
));
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
));
sdbDeleteHash
(
pTable
,
pWrite
);
}
...
...
@@ -540,7 +530,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
bool
set
=
atomic_val_compare_exchange_32
(
updateEnd
,
0
,
1
)
==
0
;
if
(
!
set
)
{
sdbError
(
"vgId:1, sdb:%s, failed to delete key:%s from hash, for it already removed"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
));
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
));
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
...
...
@@ -559,7 +549,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
atomic_sub_fetch_32
(
&
pTable
->
numOfRows
,
1
);
sdbDebug
(
"vgId:1, sdb:%s, delete key:%s from hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
),
pTable
->
numOfRows
,
pWrite
->
pMsg
);
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
),
pTable
->
numOfRows
,
pWrite
->
pMsg
);
sdbDecRef
(
pTable
,
pWrite
->
pRow
);
...
...
@@ -568,7 +558,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSWriteMsg
*
pWrite
)
{
sdbDebug
(
"vgId:1, sdb:%s, update key:%s in hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
),
pTable
->
numOfRows
,
pWrite
->
pMsg
);
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
),
pTable
->
numOfRows
,
pWrite
->
pMsg
);
(
*
pTable
->
fpUpdate
)(
pWrite
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -594,12 +584,12 @@ static int sdbWrite(void *wparam, void *hparam, int32_t qtype, void *unused) {
if
(
pHead
->
version
<=
tsSdbMgmt
.
version
)
{
pthread_mutex_unlock
(
&
tsSdbMgmt
.
mutex
);
sdbDebug
(
"vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%"
PRIu64
" too large, mver:%"
PRIu64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
qtype
,
pHead
->
version
,
tsSdbMgmt
.
version
);
pTable
->
tableName
,
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
qtype
,
pHead
->
version
,
tsSdbMgmt
.
version
);
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pHead
->
version
!=
tsSdbMgmt
.
version
+
1
)
{
pthread_mutex_unlock
(
&
tsSdbMgmt
.
mutex
);
sdbError
(
"vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%"
PRIu64
" too large, mver:%"
PRIu64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
qtype
,
pHead
->
version
,
tsSdbMgmt
.
version
);
pTable
->
tableName
,
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
qtype
,
pHead
->
version
,
tsSdbMgmt
.
version
);
return
TSDB_CODE_SYN_INVALID_VERSION
;
}
else
{
tsSdbMgmt
.
version
=
pHead
->
version
;
...
...
@@ -623,19 +613,19 @@ static int sdbWrite(void *wparam, void *hparam, int32_t qtype, void *unused) {
if
(
syncCode
<
0
)
{
sdbError
(
"vgId:1, sdb:%s, failed to forward req since %s action:%s key:%s hver:%"
PRIu64
", msg:%p"
,
pTable
->
tableName
,
tstrerror
(
syncCode
),
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
tstrerror
(
syncCode
),
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
}
else
if
(
syncCode
>
0
)
{
sdbDebug
(
"vgId:1, sdb:%s, forward req is sent, action:%s key:%s hver:%"
PRIu64
", msg:%p"
,
pTable
->
tableName
,
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
}
else
{
sdbTrace
(
"vgId:1, sdb:%s, no need to send fwd req, action:%s key:%s hver:%"
PRIu64
", msg:%p"
,
pTable
->
tableName
,
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pWrite
->
pMsg
);
}
return
syncCode
;
}
sdbDebug
(
"vgId:1, sdb:%s, record from wal/fwd is disposed, action:%s key:%s hver:%"
PRIu64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
)
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
actStr
[
action
]
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
// even it is WAL/FWD, it shall be called to update version in sync
syncForwardToPeer
(
tsSdbMgmt
.
sync
,
pHead
,
pWrite
,
TAOS_QTYPE_RPC
);
...
...
@@ -675,7 +665,7 @@ int32_t sdbInsertRow(SSWriteMsg *pWrite) {
if
(
sdbGetRowFromObj
(
pTable
,
pWrite
->
pRow
))
{
sdbError
(
"vgId:1, sdb:%s, failed to insert key:%s, already exist"
,
pTable
->
tableName
,
sdbGet
Obj
Str
(
pTable
,
pWrite
->
pRow
));
sdbGet
Row
Str
(
pTable
,
pWrite
->
pRow
));
sdbDecRef
(
pTable
,
pWrite
->
pRow
);
return
TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE
;
}
...
...
@@ -712,9 +702,9 @@ int32_t sdbInsertRowImp(SSWriteMsg *pWrite) {
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
SSWriteMsg
*
pNew
Oper
=
taosAllocateQitem
(
size
);
SSWriteMsg
*
pNew
Write
=
taosAllocateQitem
(
size
);
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
SWalHead
*
pHead
=
(
SWalHead
*
)((
char
*
)
pNewWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
)
;
pHead
->
version
=
0
;
pHead
->
len
=
pWrite
->
rowSize
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_INSERT
;
...
...
@@ -723,15 +713,15 @@ int32_t sdbInsertRowImp(SSWriteMsg *pWrite) {
(
*
pTable
->
fpEncode
)(
pWrite
);
pHead
->
len
=
pWrite
->
rowSize
;
memcpy
(
pNew
Oper
,
pWrite
,
sizeof
(
SSWriteMsg
));
memcpy
(
pNew
Write
,
pWrite
,
sizeof
(
SSWriteMsg
));
if
(
pNew
Oper
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
key:%p:%s, insert action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Oper
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetObj
Str
(
pTable
,
pWrite
->
pRow
));
if
(
pNew
Write
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
row:%p:%s, insert action is add to sdb queue"
,
pNewWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Write
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetRow
Str
(
pTable
,
pWrite
->
pRow
));
}
sdbIncRef
(
pNew
Oper
->
pTable
,
pNewOper
->
pRow
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Oper
);
sdbIncRef
(
pNew
Write
->
pTable
,
pNewWrite
->
pRow
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Write
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
...
...
@@ -781,9 +771,9 @@ int32_t sdbDeleteRowImp(SSWriteMsg *pWrite) {
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
SSWriteMsg
*
pNew
Oper
=
taosAllocateQitem
(
size
);
SSWriteMsg
*
pNew
Write
=
taosAllocateQitem
(
size
);
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
SWalHead
*
pHead
=
(
SWalHead
*
)((
void
*
)
pNewWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
)
;
pHead
->
version
=
0
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_DELETE
;
...
...
@@ -791,14 +781,14 @@ int32_t sdbDeleteRowImp(SSWriteMsg *pWrite) {
(
*
pTable
->
fpEncode
)(
pWrite
);
pHead
->
len
=
pWrite
->
rowSize
;
memcpy
(
pNew
Oper
,
pWrite
,
sizeof
(
SSWriteMsg
));
memcpy
(
pNew
Write
,
pWrite
,
sizeof
(
SSWriteMsg
));
if
(
pNew
Oper
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
key:%p:%s, delete action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Oper
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetObj
Str
(
pTable
,
pWrite
->
pRow
));
if
(
pNew
Write
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
row:%p:%s, delete action is add to sdb queue"
,
pNewWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Write
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetRow
Str
(
pTable
,
pWrite
->
pRow
));
}
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Oper
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Write
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
...
...
@@ -836,9 +826,9 @@ int32_t sdbUpdateRowImp(SSWriteMsg *pWrite) {
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
SSWriteMsg
*
pNew
Oper
=
taosAllocateQitem
(
size
);
SSWriteMsg
*
pNew
Write
=
taosAllocateQitem
(
size
);
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
SWalHead
*
pHead
=
(
SWalHead
*
)((
void
*
)
pNewWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
)
;
pHead
->
version
=
0
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_UPDATE
;
...
...
@@ -846,15 +836,15 @@ int32_t sdbUpdateRowImp(SSWriteMsg *pWrite) {
(
*
pTable
->
fpEncode
)(
pWrite
);
pHead
->
len
=
pWrite
->
rowSize
;
memcpy
(
pNew
Oper
,
pWrite
,
sizeof
(
SSWriteMsg
));
memcpy
(
pNew
Write
,
pWrite
,
sizeof
(
SSWriteMsg
));
if
(
pNew
Oper
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
key:%p:%s, update action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Oper
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetObj
Str
(
pTable
,
pWrite
->
pRow
));
if
(
pNew
Write
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
row:%p:%s, update action is add to sdb queue"
,
pNewWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pNew
Write
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetRow
Str
(
pTable
,
pWrite
->
pRow
));
}
sdbIncRef
(
pNew
Oper
->
pTable
,
pNewOper
->
pRow
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Oper
);
sdbIncRef
(
pNew
Write
->
pTable
,
pNewWrite
->
pRow
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNew
Write
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
...
...
@@ -1071,7 +1061,7 @@ static void *sdbWorkerFp(void *pWorker) {
pWrite
->
processedCount
=
1
;
pHead
=
(
void
*
)
pWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
if
(
pWrite
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
key
:%p:%s hver:%"
PRIu64
", will be processed in sdb queue"
,
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s
row
:%p:%s hver:%"
PRIu64
", will be processed in sdb queue"
,
pWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pWrite
->
pMsg
,
pWrite
->
pTable
->
tableName
,
pWrite
->
pRow
,
sdbGetKeyStr
(
pWrite
->
pTable
,
pHead
->
cont
),
pHead
->
version
);
}
...
...
@@ -1083,7 +1073,7 @@ static void *sdbWorkerFp(void *pWorker) {
int32_t
code
=
sdbWrite
(
pWrite
,
pHead
,
qtype
,
NULL
);
if
(
code
>
0
)
code
=
0
;
if
(
pWrite
)
{
pWrite
->
retC
ode
=
code
;
pWrite
->
c
ode
=
code
;
}
else
{
pHead
->
len
=
code
;
// hackway
}
...
...
@@ -1098,7 +1088,7 @@ static void *sdbWorkerFp(void *pWorker) {
if
(
qtype
==
TAOS_QTYPE_RPC
)
{
pWrite
=
(
SSWriteMsg
*
)
item
;
sdbConfirmForward
(
NULL
,
pWrite
,
pWrite
->
retC
ode
);
sdbConfirmForward
(
NULL
,
pWrite
,
pWrite
->
c
ode
);
}
else
if
(
qtype
==
TAOS_QTYPE_FWD
)
{
pHead
=
(
SWalHead
*
)
item
;
syncConfirmForward
(
tsSdbMgmt
.
sync
,
pHead
->
version
,
pHead
->
len
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
c1e1dd64
...
...
@@ -879,12 +879,12 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
mnodeIncTableRef
(
pMsg
->
pTable
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
rowSize
=
sizeof
(
SSTableObj
)
+
schemaSize
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeCreateSuperTableCb
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeCreateSuperTableCb
};
int32_t
code
=
sdbInsertRow
(
&
wmsg
);
...
...
@@ -942,7 +942,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeDropSuperTableCb
.
fp
Rsp
=
mnodeDropSuperTableCb
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
...
...
@@ -1011,11 +1011,11 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
schema
[
0
].
name
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAddSuperTableTagCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeAddSuperTableTagCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1045,11 +1045,11 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
mInfo
(
"app:%p:%p, stable %s, start to drop tag %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tagName
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeDropSuperTableTagCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeDropSuperTableTagCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1089,11 +1089,11 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
oldTagName
,
newTagName
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeModifySuperTableTagNameCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeModifySuperTableTagNameCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1163,11 +1163,11 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
mInfo
(
"app:%p:%p, stable %s, start to add column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAddSuperTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeAddSuperTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1208,11 +1208,11 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
mInfo
(
"app:%p:%p, stable %s, start to delete column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeDropSuperTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeDropSuperTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1252,11 +1252,11 @@ static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg, char *oldName, char
oldName
,
newName
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeChangeSuperTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsSuperTableSdb
,
.
pRow
=
pStable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeChangeSuperTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -1902,11 +1902,11 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
}
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeDropChildTableCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeDropChildTableCb
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
...
...
@@ -2006,11 +2006,11 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
mInfo
(
"app:%p:%p, ctable %s, start to add column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAlterNormalTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeAlterNormalTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -2039,11 +2039,11 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
mInfo
(
"app:%p:%p, ctable %s, start to drop column %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
colName
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAlterNormalTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeAlterNormalTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -2076,11 +2076,11 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char
oldName
,
newName
);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Write
=
mnodeAlterNormalTableColumnCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsChildTableSdb
,
.
pRow
=
pTable
,
.
pMsg
=
pMsg
,
.
fp
Rsp
=
mnodeAlterNormalTableColumnCb
};
return
sdbUpdateRow
(
&
wmsg
);
...
...
@@ -2411,11 +2411,11 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
if
(
rpcMsg
->
code
==
TSDB_CODE_SUCCESS
||
rpcMsg
->
code
==
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
SSWriteMsg
desc
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pRow
=
pTable
,
.
pTable
=
tsChildTableSdb
,
.
pMsg
=
mnodeMsg
,
.
fp
Write
=
mnodeDoCreateChildTableCb
.
type
=
SDB_OPER_GLOBAL
,
.
pRow
=
pTable
,
.
pTable
=
tsChildTableSdb
,
.
pMsg
=
mnodeMsg
,
.
fp
Rsp
=
mnodeDoCreateChildTableCb
};
int32_t
code
=
sdbInsertRowImp
(
&
desc
);
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
c1e1dd64
...
...
@@ -958,12 +958,12 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
if
(
mnodeMsg
->
received
==
mnodeMsg
->
successed
)
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pRow
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
mnodeMsg
,
.
fp
Write
=
mnodeCreateVgroupCb
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pRow
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
mnodeMsg
,
.
fp
Rsp
=
mnodeCreateVgroupCb
};
int32_t
code
=
sdbInsertRowImp
(
&
wmsg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录