Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
80d780eb
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
80d780eb
编写于
5月 25, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: use schema version of row when commit
上级
42cc609a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
29 deletion
+41
-29
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+10
-3
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+16
-14
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+14
-11
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+1
-1
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
80d780eb
...
...
@@ -40,8 +40,8 @@ typedef struct STable STable;
int
tsdbMemTableCreate
(
STsdb
*
pTsdb
,
STsdbMemTable
**
ppMemTable
);
void
tsdbMemTableDestroy
(
STsdb
*
pTsdb
,
STsdbMemTable
*
pMemTable
);
int
tsdbLoadDataFromCache
(
ST
able
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
int
tsdbLoadDataFromCache
(
ST
sdb
*
pTsdb
,
STable
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
// tsdbCommit ================
...
...
@@ -179,7 +179,14 @@ struct STsdbFS {
int
tsdbLockRepo
(
STsdb
*
pTsdb
);
int
tsdbUnlockRepo
(
STsdb
*
pTsdb
);
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STsdb
*
pTsdb
,
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
if
((
version
!=
-
1
)
&&
(
schemaVersion
(
pTable
->
pSchema
)
!=
version
))
{
taosMemoryFreeClear
(
pTable
->
pSchema
);
pTable
->
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdb
),
pTable
->
uid
,
version
);
}
return
pTable
->
pSchema
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
80d780eb
...
...
@@ -84,7 +84,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols
static
void
tsdbResetCommitTable
(
SCommitH
*
pCommith
);
static
void
tsdbCloseCommitFile
(
SCommitH
*
pCommith
,
bool
hasError
);
static
bool
tsdbCanAddSubBlock
(
SCommitH
*
pCommith
,
SBlock
*
pBlock
,
SMergeInfo
*
pInfo
);
static
void
tsdbLoadAndMergeFromCache
(
SDataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
static
void
tsdbLoadAndMergeFromCache
(
S
Tsdb
*
pTsdb
,
S
DataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
...
...
@@ -301,7 +301,8 @@ static void tsdbSeekCommitIter(SCommitH *pCommith, TSKEY key) {
SCommitIter
*
pIter
=
pCommith
->
iters
+
i
;
if
(
pIter
->
pTable
==
NULL
||
pIter
->
pIter
==
NULL
)
continue
;
tsdbLoadDataFromCache
(
pIter
->
pTable
,
pIter
->
pIter
,
key
-
1
,
INT32_MAX
,
NULL
,
NULL
,
0
,
true
,
NULL
);
tsdbLoadDataFromCache
(
TSDB_COMMIT_REPO
(
pCommith
),
pIter
->
pTable
,
pIter
->
pIter
,
key
-
1
,
INT32_MAX
,
NULL
,
NULL
,
0
,
true
,
NULL
);
}
}
...
...
@@ -947,7 +948,7 @@ static int tsdbMoveBlkIdx(SCommitH *pCommith, SBlockIdx *pIdx) {
}
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
TSDB_COMMIT_REPO
(
pCommith
),
pTable
,
false
,
false
,
-
1
);
pCommith
->
pTable
=
pTable
;
...
...
@@ -1254,8 +1255,8 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi
SBlock
block
;
while
(
true
)
{
tsdbLoadDataFromCache
(
pIter
->
pTable
,
pIter
->
pIter
,
keyLimit
,
defaultRows
,
pCommith
->
pDataCols
,
NULL
,
0
,
pCfg
->
update
,
&
mInfo
);
tsdbLoadDataFromCache
(
TSDB_COMMIT_REPO
(
pCommith
),
pIter
->
pTable
,
pIter
->
pIter
,
keyLimit
,
defaultRows
,
pC
ommith
->
pDataCols
,
NULL
,
0
,
pC
fg
->
update
,
&
mInfo
);
if
(
pCommith
->
pDataCols
->
numOfRows
<=
0
)
break
;
...
...
@@ -1298,8 +1299,9 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
SSkipListIterator
titer
=
*
(
pIter
->
pIter
);
if
(
tsdbLoadBlockDataCols
(
&
(
pCommith
->
readh
),
pBlock
,
NULL
,
&
colId
,
1
,
false
)
<
0
)
return
-
1
;
tsdbLoadDataFromCache
(
pIter
->
pTable
,
&
titer
,
keyLimit
,
INT32_MAX
,
NULL
,
pCommith
->
readh
.
pDCols
[
0
]
->
cols
[
0
].
pData
,
pCommith
->
readh
.
pDCols
[
0
]
->
numOfRows
,
pCfg
->
update
,
&
mInfo
);
tsdbLoadDataFromCache
(
TSDB_COMMIT_REPO
(
pCommith
),
pIter
->
pTable
,
&
titer
,
keyLimit
,
INT32_MAX
,
NULL
,
pCommith
->
readh
.
pDCols
[
0
]
->
cols
[
0
].
pData
,
pCommith
->
readh
.
pDCols
[
0
]
->
numOfRows
,
pCfg
->
update
,
&
mInfo
);
if
(
mInfo
.
nOperations
==
0
)
{
// no new data to insert (all updates denied)
...
...
@@ -1313,9 +1315,9 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
*
(
pIter
->
pIter
)
=
titer
;
}
else
if
(
tsdbCanAddSubBlock
(
pCommith
,
pBlock
,
&
mInfo
))
{
// Add a sub-block
tsdbLoadDataFromCache
(
pIter
->
pTable
,
pIter
->
pIter
,
keyLimit
,
INT32_MAX
,
pCommith
->
pDataCols
,
pCommith
->
readh
.
pDCols
[
0
]
->
cols
[
0
].
pData
,
pCommith
->
readh
.
pDCols
[
0
]
->
numOfRows
,
pCfg
->
update
,
&
mInfo
);
tsdbLoadDataFromCache
(
TSDB_COMMIT_REPO
(
pCommith
),
pIter
->
pTable
,
pIter
->
pIter
,
keyLimit
,
INT32_MAX
,
pCommith
->
pDataCols
,
pCommith
->
readh
.
pDCols
[
0
]
->
cols
[
0
].
pData
,
pCommith
->
readh
.
pDCols
[
0
]
->
numOfRows
,
pCfg
->
update
,
&
mInfo
);
if
(
pBlock
->
last
)
{
pDFile
=
TSDB_COMMIT_LAST_FILE
(
pCommith
);
}
else
{
...
...
@@ -1420,7 +1422,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols
int
biter
=
0
;
while
(
true
)
{
tsdbLoadAndMergeFromCache
(
pCommith
->
readh
.
pDCols
[
0
],
&
biter
,
pIter
,
pCommith
->
pDataCols
,
keyLimit
,
defaultRows
,
tsdbLoadAndMergeFromCache
(
TSDB_COMMIT_REPO
(
pCommith
),
pCommith
->
readh
.
pDCols
[
0
],
&
biter
,
pIter
,
pCommith
->
pDataCols
,
keyLimit
,
defaultRows
,
pCfg
->
update
);
if
(
pCommith
->
pDataCols
->
numOfRows
==
0
)
break
;
...
...
@@ -1445,7 +1447,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols
return
0
;
}
static
void
tsdbLoadAndMergeFromCache
(
SDataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
static
void
tsdbLoadAndMergeFromCache
(
S
Tsdb
*
pTsdb
,
S
DataCols
*
pDataCols
,
int
*
iter
,
SCommitIter
*
pCommitIter
,
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
)
{
TSKEY
key1
=
INT64_MAX
;
TSKEY
key2
=
INT64_MAX
;
...
...
@@ -1487,7 +1489,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
++
(
*
iter
);
}
else
if
(
key1
>
key2
)
{
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
TD_ROW_SVER
(
row
))
{
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
TD_ROW_SVER
(
row
));
pSchema
=
tsdbGetTableSchemaImpl
(
p
Tsdb
,
p
CommitIter
->
pTable
,
false
,
false
,
TD_ROW_SVER
(
row
));
ASSERT
(
pSchema
!=
NULL
);
}
...
...
@@ -1527,7 +1529,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
if
(
TD_SUPPORT_UPDATE
(
update
))
{
// copy mem data(Multi-Version)
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
TD_ROW_SVER
(
row
))
{
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
TD_ROW_SVER
(
row
));
pSchema
=
tsdbGetTableSchemaImpl
(
p
Tsdb
,
p
CommitIter
->
pTable
,
false
,
false
,
TD_ROW_SVER
(
row
));
ASSERT
(
pSchema
!=
NULL
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
80d780eb
...
...
@@ -20,7 +20,8 @@ static void tsdbFreeTbData(STbData *pTbData);
static
char
*
tsdbGetTsTupleKey
(
const
void
*
data
);
static
int
tsdbTbDataComp
(
const
void
*
arg1
,
const
void
*
arg2
);
static
char
*
tsdbTbDataGetUid
(
const
void
*
arg
);
static
int
tsdbAppendTableRowToCols
(
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
STSRow
*
row
,
bool
merge
);
static
int
tsdbAppendTableRowToCols
(
STsdb
*
pTsdb
,
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
STSRow
*
row
,
bool
merge
);
int
tsdbMemTableCreate
(
STsdb
*
pTsdb
,
STsdbMemTable
**
ppMemTable
)
{
STsdbMemTable
*
pMemTable
;
...
...
@@ -88,8 +89,8 @@ void tsdbMemTableDestroy(STsdb *pTsdb, STsdbMemTable *pMemTable) {
*
* The function tries to procceed AS MUCH AS POSSIBLE.
*/
int
tsdbLoadDataFromCache
(
ST
able
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
)
{
int
tsdbLoadDataFromCache
(
ST
sdb
*
pTsdb
,
STable
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
)
{
ASSERT
(
maxRowsToRead
>
0
&&
nFilterKeys
>=
0
);
if
(
pIter
==
NULL
)
return
0
;
STSchema
*
pSchema
=
NULL
;
...
...
@@ -222,12 +223,12 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
if
(
lastKey
!=
TSKEY_INITIAL_VAL
)
{
++
pCols
->
numOfRows
;
}
tsdbAppendTableRowToCols
(
pTable
,
pCols
,
&
pSchema
,
row
,
false
);
tsdbAppendTableRowToCols
(
pT
sdb
,
pT
able
,
pCols
,
&
pSchema
,
row
,
false
);
}
lastKey
=
rowKey
;
}
else
{
if
(
keepDup
)
{
tsdbAppendTableRowToCols
(
pTable
,
pCols
,
&
pSchema
,
row
,
true
);
tsdbAppendTableRowToCols
(
pT
sdb
,
pT
able
,
pCols
,
&
pSchema
,
row
,
true
);
}
else
{
// discard
}
...
...
@@ -249,7 +250,7 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
if
(
pCols
&&
pMergeInfo
->
nOperations
>=
pCols
->
maxPoints
)
break
;
pMergeInfo
->
rowsDeleteSucceed
++
;
pMergeInfo
->
nOperations
++
;
tsdbAppendTableRowToCols
(
pTable
,
pCols
,
&
pSchema
,
row
,
false
);
tsdbAppendTableRowToCols
(
pT
sdb
,
pT
able
,
pCols
,
&
pSchema
,
row
,
false
);
}
else
{
if
(
keepDup
)
{
if
(
pCols
&&
pMergeInfo
->
nOperations
>=
pCols
->
maxPoints
)
break
;
...
...
@@ -262,11 +263,11 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
if
(
lastKey
!=
TSKEY_INITIAL_VAL
)
{
++
pCols
->
numOfRows
;
}
tsdbAppendTableRowToCols
(
pTable
,
pCols
,
&
pSchema
,
row
,
false
);
tsdbAppendTableRowToCols
(
pT
sdb
,
pT
able
,
pCols
,
&
pSchema
,
row
,
false
);
}
lastKey
=
rowKey
;
}
else
{
tsdbAppendTableRowToCols
(
pTable
,
pCols
,
&
pSchema
,
row
,
true
);
tsdbAppendTableRowToCols
(
pT
sdb
,
pT
able
,
pCols
,
&
pSchema
,
row
,
true
);
}
}
else
{
pMergeInfo
->
keyFirst
=
TMIN
(
pMergeInfo
->
keyFirst
,
fKey
);
...
...
@@ -321,7 +322,7 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo
return
-
1
;
}
strcat
(
pRsp
->
tblFName
,
mr
.
me
.
name
);
if
(
mr
.
me
.
type
==
TSDB_NORMAL_TABLE
)
{
sverNew
=
mr
.
me
.
ntbEntry
.
schema
.
sver
;
}
else
{
...
...
@@ -431,10 +432,12 @@ static char *tsdbTbDataGetUid(const void *arg) {
STbData
*
pTbData
=
(
STbData
*
)
arg
;
return
(
char
*
)(
&
(
pTbData
->
uid
));
}
static
int
tsdbAppendTableRowToCols
(
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
STSRow
*
row
,
bool
merge
)
{
static
int
tsdbAppendTableRowToCols
(
STsdb
*
pTsdb
,
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
STSRow
*
row
,
bool
merge
)
{
if
(
pCols
)
{
if
(
*
ppSchema
==
NULL
||
schemaVersion
(
*
ppSchema
)
!=
TD_ROW_SVER
(
row
))
{
*
ppSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
TD_ROW_SVER
(
row
));
*
ppSchema
=
tsdbGetTableSchemaImpl
(
pT
sdb
,
pT
able
,
false
,
false
,
TD_ROW_SVER
(
row
));
if
(
*
ppSchema
==
NULL
)
{
ASSERT
(
false
);
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
80d780eb
...
...
@@ -157,7 +157,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) {
}
int
tsdbSetReadTable
(
SReadH
*
pReadh
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
TSDB_READ_REPO
(
pReadh
),
pTable
,
false
,
false
,
-
1
);
pReadh
->
pTable
=
pTable
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录