Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
97434ac0
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看板
提交
97434ac0
编写于
11月 25, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1795
上级
a988483a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
28 deletion
+42
-28
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+42
-28
未找到文件。
src/mnode/src/mnodeSdb.c
浏览文件 @
97434ac0
...
@@ -107,7 +107,7 @@ static taos_queue tsSdbWQueue;
...
@@ -107,7 +107,7 @@ static taos_queue tsSdbWQueue;
static
SSdbWorkerPool
tsSdbPool
;
static
SSdbWorkerPool
tsSdbPool
;
static
int32_t
sdbProcessWrite
(
void
*
pRow
,
void
*
pHead
,
int32_t
qtype
,
void
*
unused
);
static
int32_t
sdbProcessWrite
(
void
*
pRow
,
void
*
pHead
,
int32_t
qtype
,
void
*
unused
);
static
int32_t
sdbWrite
Wal
ToQueue
(
int32_t
vgId
,
void
*
pHead
,
int32_t
qtype
,
void
*
rparam
);
static
int32_t
sdbWrite
Fwd
ToQueue
(
int32_t
vgId
,
void
*
pHead
,
int32_t
qtype
,
void
*
rparam
);
static
int32_t
sdbWriteRowToQueue
(
SSdbRow
*
pRow
,
int32_t
action
);
static
int32_t
sdbWriteRowToQueue
(
SSdbRow
*
pRow
,
int32_t
action
);
static
void
sdbFreeFromQueue
(
SSdbRow
*
pRow
);
static
void
sdbFreeFromQueue
(
SSdbRow
*
pRow
);
static
void
*
sdbWorkerFp
(
void
*
pWorker
);
static
void
*
sdbWorkerFp
(
void
*
pWorker
);
...
@@ -261,12 +261,6 @@ static void sdbHandleFailedConfirm(SSdbRow *pRow) {
...
@@ -261,12 +261,6 @@ static void sdbHandleFailedConfirm(SSdbRow *pRow) {
SSdbRow
row
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
pRow
->
pTable
,
.
pObj
=
pRow
->
pObj
};
SSdbRow
row
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
pRow
->
pTable
,
.
pObj
=
pRow
->
pObj
};
sdbDeleteRow
(
&
row
);
sdbDeleteRow
(
&
row
);
}
}
// Drop database/stable may take a long time and cause a timeout, so confirm is not enforced
if
(
action
==
SDB_ACTION_DELETE
&&
pRow
->
code
==
TSDB_CODE_SYN_CONFIRM_EXPIRED
)
{
sdbDebug
(
"vgId:1, confirm is not enforced while perform drop operation, set it success"
);
pRow
->
code
=
TSDB_CODE_SUCCESS
;
}
}
}
FORCE_INLINE
FORCE_INLINE
...
@@ -378,7 +372,7 @@ void sdbUpdateSync(void *pMnodes) {
...
@@ -378,7 +372,7 @@ void sdbUpdateSync(void *pMnodes) {
sprintf
(
syncInfo
.
path
,
"%s"
,
tsMnodeDir
);
sprintf
(
syncInfo
.
path
,
"%s"
,
tsMnodeDir
);
syncInfo
.
getWalInfo
=
sdbGetWalInfo
;
syncInfo
.
getWalInfo
=
sdbGetWalInfo
;
syncInfo
.
getFileInfo
=
sdbGetFileInfo
;
syncInfo
.
getFileInfo
=
sdbGetFileInfo
;
syncInfo
.
writeToCache
=
sdbWrite
Wal
ToQueue
;
syncInfo
.
writeToCache
=
sdbWrite
Fwd
ToQueue
;
syncInfo
.
confirmForward
=
sdbConfirmForward
;
syncInfo
.
confirmForward
=
sdbConfirmForward
;
syncInfo
.
notifyRole
=
sdbNotifyRole
;
syncInfo
.
notifyRole
=
sdbNotifyRole
;
tsSdbMgmt
.
cfg
=
syncCfg
;
tsSdbMgmt
.
cfg
=
syncCfg
;
...
@@ -565,7 +559,36 @@ static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbRow *pRow) {
...
@@ -565,7 +559,36 @@ static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbRow *pRow) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int
sdbProcessWrite
(
void
*
wparam
,
void
*
hparam
,
int32_t
qtype
,
void
*
unused
)
{
static
int32_t
sdbPerformInsertAction
(
SWalHead
*
pHead
,
SSdbTable
*
pTable
)
{
SSdbRow
row
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pTable
=
pTable
};
(
*
pTable
->
fpDecode
)(
&
row
);
return
sdbInsertHash
(
pTable
,
&
row
);
}
static
int32_t
sdbPerformDeleteAction
(
SWalHead
*
pHead
,
SSdbTable
*
pTable
)
{
void
*
pObj
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pObj
==
NULL
)
{
sdbDebug
(
"vgId:1, sdb:%s, object:%s not exist in hash, ignore delete action"
,
pTable
->
name
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
}
SSdbRow
row
=
{.
pTable
=
pTable
,
.
pObj
=
pObj
};
return
sdbDeleteHash
(
pTable
,
&
row
);
}
static
int32_t
sdbPerformUpdateAction
(
SWalHead
*
pHead
,
SSdbTable
*
pTable
)
{
void
*
pObj
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pObj
==
NULL
)
{
sdbDebug
(
"vgId:1, sdb:%s, object:%s not exist in hash, ignore update action"
,
pTable
->
name
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
}
SSdbRow
row
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pTable
=
pTable
};
(
*
pTable
->
fpDecode
)(
&
row
);
return
sdbUpdateHash
(
pTable
,
&
row
);
}
static
int32_t
sdbProcessWrite
(
void
*
wparam
,
void
*
hparam
,
int32_t
qtype
,
void
*
unused
)
{
SSdbRow
*
pRow
=
wparam
;
SSdbRow
*
pRow
=
wparam
;
SWalHead
*
pHead
=
hparam
;
SWalHead
*
pHead
=
hparam
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
...
@@ -574,6 +597,8 @@ static int sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *unus
...
@@ -574,6 +597,8 @@ static int sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *unus
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
assert
(
pTable
!=
NULL
);
assert
(
pTable
!=
NULL
);
if
(
qtype
==
TAOS_QTYPE_QUERY
)
return
sdbPerformDeleteAction
(
pHead
,
pTable
);
pthread_mutex_lock
(
&
tsSdbMgmt
.
mutex
);
pthread_mutex_lock
(
&
tsSdbMgmt
.
mutex
);
if
(
pHead
->
version
==
0
)
{
if
(
pHead
->
version
==
0
)
{
...
@@ -633,28 +658,17 @@ static int sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *unus
...
@@ -633,28 +658,17 @@ static int sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *unus
// from wal or forward msg, row not created, should add into hash
// from wal or forward msg, row not created, should add into hash
if
(
action
==
SDB_ACTION_INSERT
)
{
if
(
action
==
SDB_ACTION_INSERT
)
{
SSdbRow
row
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pTable
=
pTable
};
return
sdbPerformInsertAction
(
pHead
,
pTable
);
code
=
(
*
pTable
->
fpDecode
)(
&
row
);
return
sdbInsertHash
(
pTable
,
&
row
);
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
void
*
pObj
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
qtype
==
TAOS_QTYPE_FWD
)
{
if
(
pObj
==
NULL
)
{
// Drop database/stable may take a long time and cause a timeout, so we confirm first then reput it into queue
sdbDebug
(
"vgId:1, sdb:%s, object:%s not exist in hash, ignore delete action"
,
pTable
->
name
,
sdbWriteFwdToQueue
(
1
,
hparam
,
TAOS_QTYPE_QUERY
,
unused
);
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
return
sdbPerformDeleteAction
(
pHead
,
pTable
);
}
}
SSdbRow
row
=
{.
pTable
=
pTable
,
.
pObj
=
pObj
};
return
sdbDeleteHash
(
pTable
,
&
row
);
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
void
*
pObj
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
return
sdbPerformUpdateAction
(
pHead
,
pTable
);
if
(
pObj
==
NULL
)
{
sdbDebug
(
"vgId:1, sdb:%s, object:%s not exist in hash, ignore update action"
,
pTable
->
name
,
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
}
SSdbRow
row
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pTable
=
pTable
};
code
=
(
*
pTable
->
fpDecode
)(
&
row
);
return
sdbUpdateHash
(
pTable
,
&
row
);
}
else
{
}
else
{
return
TSDB_CODE_MND_INVALID_MSG_TYPE
;
return
TSDB_CODE_MND_INVALID_MSG_TYPE
;
}
}
...
@@ -972,7 +986,7 @@ static void sdbFreeFromQueue(SSdbRow *pRow) {
...
@@ -972,7 +986,7 @@ static void sdbFreeFromQueue(SSdbRow *pRow) {
taosFreeQitem
(
pRow
);
taosFreeQitem
(
pRow
);
}
}
static
int32_t
sdbWrite
Wal
ToQueue
(
int32_t
vgId
,
void
*
wparam
,
int32_t
qtype
,
void
*
rparam
)
{
static
int32_t
sdbWrite
Fwd
ToQueue
(
int32_t
vgId
,
void
*
wparam
,
int32_t
qtype
,
void
*
rparam
)
{
SWalHead
*
pHead
=
wparam
;
SWalHead
*
pHead
=
wparam
;
int32_t
size
=
sizeof
(
SSdbRow
)
+
sizeof
(
SWalHead
)
+
pHead
->
len
;
int32_t
size
=
sizeof
(
SSdbRow
)
+
sizeof
(
SWalHead
)
+
pHead
->
len
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录