Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de1e0a0a
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
de1e0a0a
编写于
2月 19, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: more code
上级
30b0af90
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
122 addition
and
19 deletion
+122
-19
src/inc/tsdb.h
src/inc/tsdb.h
+1
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+93
-0
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+27
-17
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-1
未找到文件。
src/inc/tsdb.h
浏览文件 @
de1e0a0a
...
...
@@ -131,7 +131,7 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg);
int
tsdbCreateTable
(
STsdbRepo
*
repo
,
STableCfg
*
pCfg
);
int
tsdbDropTable
(
STsdbRepo
*
pRepo
,
STableId
tableId
);
int
tsdbUpdateTableTagValue
(
STsdbRepo
*
repo
,
SUpdateTableTagValMsg
*
pMsg
);
int
tsdbPrintTables
(
STsdbRepo
*
repo
);
int
tsdbPrintTables
(
STsdbRepo
*
repo
,
uint64_t
qId
);
uint32_t
tsdbGetFileInfo
(
STsdbRepo
*
repo
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
de1e0a0a
...
...
@@ -52,6 +52,8 @@
// informal
#define META_SYNC_TABLE_NAME "_taos_meta_sync_table_name_taos_"
#define META_SYNC_TABLE_NAME_LEN 32
#define META_SYNC_DROP_TABLE "_taos_meta_sync_drop_table_taos_"
#define META_SYNC_DROP_TABLE_LEN 32
// informal
int64_t
tsCTableRid
=
-
1
;
...
...
@@ -86,6 +88,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg);
static
void
mnodeProcessDropSuperTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
);
static
void
mnodeProcessDropChildTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeProcessMetaSyncDropTableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessSuperTableVgroupMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessMultiTableMetaMsg
(
SMnodeMsg
*
pMsg
);
...
...
@@ -1015,6 +1018,10 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
}
#endif
if
(
tsMetaSyncOption
&&
strstr
(
pDrop
->
name
,
META_SYNC_DROP_TABLE
))
{
return
mnodeProcessMetaSyncDropTableMsg
(
pMsg
);
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pDrop
->
name
);
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
pDrop
->
igNotExists
)
{
...
...
@@ -2437,6 +2444,92 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
return
code
;
}
static
int32_t
mnodeProcessMetaSyncDropTableMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
code
=
0
;
int32_t
vgId
=
-
1
;
int32_t
tid
=
-
1
;
uint64_t
uid
=
0
;
int32_t
tableType
=
0
;
char
tbName
[
TSDB_TABLE_FNAME_LEN
]
=
""
;
int32_t
fnum
=
0
;
char
*
fStr
=
NULL
;
char
**
fnameList
=
NULL
;
SCTableObj
ctableObj
=
{
0
};
SCMDropTableMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pMsg
->
pTable
=
(
struct
STableObj
*
)
&
ctableObj
;
SCTableObj
*
pTable
=
(
SCTableObj
*
)
pMsg
->
pTable
;
// META_SYNC_DROP_TABLE: _taos_meta_sync_drop_table_taos_tableType_vgId_uid_tid_tbName;
fStr
=
strndup
(
pDrop
->
name
,
strlen
(
pDrop
->
name
));
if
(
!
fStr
)
{
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
goto
_exit
;
}
fnameList
=
strsplit
(
fStr
,
"."
,
&
fnum
);
if
(
fnum
>
6
&&
0
==
strncmp
(
fnameList
[
2
],
META_SYNC_DROP_TABLE
,
META_SYNC_DROP_TABLE_LEN
))
{
tableType
=
atoi
(
fnameList
[
3
]);
if
(
errno
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
vgId
=
atoi
(
fnameList
[
4
]);
if
(
errno
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
uid
=
strtoull
(
fnameList
[
5
],
NULL
,
10
);
if
(
errno
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
tid
=
atoi
(
fnameList
[
6
]);
if
(
errno
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_exit
;
}
strncpy
(
tbName
,
fnameList
[
0
],
TSDB_TABLE_FNAME_LEN
);
tbName
[
strlen
(
tbName
)]
=
'.'
;
strncpy
(
tbName
+
strlen
(
tbName
),
fnameList
[
1
],
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
tbName
[
strlen
(
tbName
)]
=
'.'
;
if
(
strchr
(
pDrop
->
name
,
' '
))
{
strncpy
(
tbName
+
strlen
(
tbName
),
pDrop
->
name
+
1
,
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
}
}
else
{
code
=
TSDB_CODE_TSC_INVALID_TABLE_NAME
;
goto
_exit
;
}
if
(
tableType
!=
TSDB_CHILD_TABLE
&&
tableType
!=
TSDB_NORMAL_TABLE
)
{
code
=
TSDB_CODE_TSC_INVALID_TABLE_NAME
;
goto
_exit
;
}
pTable
->
info
.
type
=
TSDB_CHILD_TABLE
;
pTable
->
info
.
tableId
=
tbName
;
pTable
->
uid
=
uid
;
pTable
->
tid
=
tid
;
pTable
->
vgId
=
vgId
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"%s:%d, msg:%p, app:%p table:%s, failed to drop table, vgroup not exist"
,
__func__
,
__LINE__
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
code
=
TSDB_CODE_MND_APP_ERROR
;
goto
_exit
;
}
mnodeSendDropChildTableMsg
(
pMsg
,
false
);
_exit:
if
(
code
)
{
mError
(
"%s:%d, msg:%p, app:%p table:%s, failed to drop table since %s"
,
__func__
,
__LINE__
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pDrop
->
name
,
tstrerror
(
code
));
}
tfree
(
fStr
);
tfree
(
fnameList
);
return
code
;
}
static
int32_t
mnodeFindNormalTableColumnIndex
(
SCTableObj
*
pTable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pTable
->
schema
;
for
(
int32_t
col
=
0
;
col
<
pTable
->
numOfColumns
;
col
++
)
{
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
de1e0a0a
...
...
@@ -73,9 +73,9 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) {
return
0
;
}
else
{
tsdbInfo
(
"vgId:%d table %s at tid %d uid %"
PRIu64
" exists, replace it with new table, this can be not reasonable"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pMeta
->
tables
[
tid
]),
TABLE_TID
(
pMeta
->
tables
[
tid
]),
TABLE_UID
(
pMeta
->
tables
[
tid
]));
" exists, replace it with new table, this can be not reasonable"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pMeta
->
tables
[
tid
]),
TABLE_TID
(
pMeta
->
tables
[
tid
]),
TABLE_UID
(
pMeta
->
tables
[
tid
]));
tsdbDropTable
(
pRepo
,
pMeta
->
tables
[
tid
]
->
tableId
);
}
}
...
...
@@ -165,34 +165,43 @@ int tsdbDropTable(STsdbRepo *repo, STableId tableId) {
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
uid
);
if
(
pTable
==
NULL
)
{
tsdbError
(
"vgId:%d
failed to drop table since table not exists! tid:%d uid
%"
PRIu64
,
REPO_ID
(
pRepo
),
tableId
.
tid
,
tsdbError
(
"vgId:%d
, failed to drop table since table not exists! tid:%d, uid:
%"
PRIu64
,
REPO_ID
(
pRepo
),
tableId
.
tid
,
uid
);
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
return
-
1
;
}
tsdbDebug
(
"vgId:%d try to drop table %s type %d"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TYPE
(
pTable
));
tsdbDebug
(
"vgId:%d
,
try to drop table %s type %d"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TYPE
(
pTable
));
tid
=
TABLE_TID
(
pTable
);
tbname
=
strdup
(
TABLE_CHAR_NAME
(
pTable
));
if
(
tbname
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbError
(
"vgId:%d, failed to drop table %s since %s! tid:%d, uid:%"
PRIu64
,
REPO_ID
(
pRepo
),
tbname
,
tstrerror
(
terrno
),
tableId
.
tid
,
uid
);
return
-
1
;
}
// Write to KV store first
if
(
tsdbRemoveTableFromStore
(
pRepo
,
pTable
)
<
0
)
{
tsdbError
(
"vgId:%d failed to drop table %s since %s"
,
REPO_ID
(
pRepo
),
tbname
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d, failed to drop table %s since %s! tid:%d, uid:%"
PRIu64
,
REPO_ID
(
pRepo
),
tbname
,
tstrerror
(
terrno
),
tableId
.
tid
,
uid
);
goto
_err
;
}
// Remove table from Meta
if
(
tsdbRmTableFromMeta
(
pRepo
,
pTable
)
<
0
)
{
tsdbError
(
"vgId:%d failed to drop table %s since %s"
,
REPO_ID
(
pRepo
),
tbname
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d, failed to drop table %s since %s! tid:%d, uid:%"
PRIu64
,
REPO_ID
(
pRepo
),
tbname
,
tstrerror
(
terrno
),
tableId
.
tid
,
uid
);
goto
_err
;
}
tsdbDebug
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
tbname
,
tid
,
uid
);
if
(
tsMetaSyncOption
)
{
tsdbInfo
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
tbname
,
tid
,
uid
);
}
else
{
tsdbDebug
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
tbname
,
tid
,
uid
);
}
free
(
tbname
);
if
(
tsdbCheckCommit
(
pRepo
)
<
0
)
goto
_err
;
...
...
@@ -204,14 +213,15 @@ _err:
return
-
1
;
}
int
tsdbPrintTables
(
STsdbRepo
*
pRepo
)
{
int
tsdbPrintTables
(
STsdbRepo
*
pRepo
,
uint64_t
qId
)
{
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
if
(
tsdbRLockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pMeta
->
maxTables
;
++
i
)
{
if
(
pMeta
->
tables
[
i
]
!=
NULL
)
{
STable
*
pTable
=
pMeta
->
tables
[
i
];
tsdbDebug
(
"vgId:%d tbname:%s tid:%d uid:%"
PRIu64
,
REPO_ID
(
pRepo
),
pTable
->
name
->
data
,
pTable
->
tableId
.
tid
,
pTable
->
tableId
.
uid
);
tsdbInfo
(
"vgId:%d QID:%"
PRIu64
" stb:%s tbn:%s tid:%d uid:%"
PRIu64
,
REPO_ID
(
pRepo
),
qId
,
pTable
->
pSuper
?
pTable
->
pSuper
->
name
->
data
:
"-"
,
pTable
->
name
->
data
,
pTable
->
tableId
.
tid
,
pTable
->
tableId
.
uid
);
}
}
if
(
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
...
...
@@ -699,9 +709,9 @@ int tsdbUpdateLastColSchema(STable *pTable, STSchema *pNewSchema) {
if
(
pTable
->
lastColSVersion
==
schemaVersion
(
pNewSchema
))
{
return
0
;
}
tsdbDebug
(
"tsdbUpdateLastColSchema:%s,%d->%d"
,
pTable
->
name
->
data
,
pTable
->
lastColSVersion
,
schemaVersion
(
pNewSchema
));
int16_t
numOfCols
=
pNewSchema
->
numOfCols
;
SDataCol
*
lastCols
=
(
SDataCol
*
)
malloc
(
numOfCols
*
sizeof
(
SDataCol
));
if
(
lastCols
==
NULL
)
{
...
...
@@ -961,7 +971,7 @@ static void tsdbFreeTable(STable *pTable) {
tSkipListDestroy
(
pTable
->
pIndex
);
taosHashCleanup
(
pTable
->
jsonKeyMap
);
taosTZfree
(
pTable
->
lastRow
);
taosTZfree
(
pTable
->
lastRow
);
tfree
(
pTable
->
sql
);
tsdbFreeLastColumns
(
pTable
);
...
...
@@ -1415,7 +1425,7 @@ static int tsdbEncodeTable(void **buf, STable *pTable) {
tlen
+=
taosEncodeFixedU64
(
buf
,
TABLE_SUID
(
pTable
));
tlen
+=
tdEncodeKVRow
(
buf
,
pTable
->
tagVal
);
}
else
{
uint32_t
arraySize
=
(
uint32_t
)
taosArrayGetSize
(
pTable
->
schema
);
uint32_t
arraySize
=
(
uint32_t
)
taosArrayGetSize
(
pTable
->
schema
);
if
(
arraySize
>
UINT8_MAX
)
{
tlen
+=
taosEncodeFixedU8
(
buf
,
0
);
tlen
+=
taosEncodeFixedU32
(
buf
,
arraySize
);
...
...
@@ -1477,10 +1487,10 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
tsdbFreeTable
(
pTable
);
return
NULL
;
}
taosHashSetFreeFp
(
pTable
->
jsonKeyMap
,
taosArrayDestroyForHash
);
taosHashSetFreeFp
(
pTable
->
jsonKeyMap
,
taosArrayDestroyForHash
);
}
else
{
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
colType
(
pCol
),
(
uint8_t
)(
colBytes
(
pCol
)),
NULL
,
SL_ALLOW_DUP_KEY
,
getTagIndexKey
);
SL_ALLOW_DUP_KEY
,
getTagIndexKey
);
if
(
pTable
->
pIndex
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbFreeTable
(
pTable
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
de1e0a0a
...
...
@@ -2810,7 +2810,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
tsdbUnLockFS
(
pFileHandle
);
if
(
tsMetaSyncOption
)
{
tsdbPrintTables
(
pQueryHandle
->
pTsdb
);
tsdbPrintTables
(
pQueryHandle
->
pTsdb
,
pQueryHandle
->
qId
);
}
pTableBlockInfo
->
numOfFiles
+=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录