Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
75ccd024
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看板
提交
75ccd024
编写于
5月 22, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cache/writebatch: separate read & write batches
上级
a5c1b9a0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
12 deletion
+20
-12
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+19
-12
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
75ccd024
...
...
@@ -351,6 +351,7 @@ typedef struct {
rocksdb_writeoptions_t
*
writeoptions
;
rocksdb_readoptions_t
*
readoptions
;
rocksdb_writebatch_t
*
writebatch
;
rocksdb_writebatch_t
*
rwritebatch
;
TdThreadMutex
rMutex
;
STSchema
*
pTSchema
;
}
SRocksCache
;
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
75ccd024
...
...
@@ -164,8 +164,10 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
}
rocksdb_writebatch_t
*
writebatch
=
rocksdb_writebatch_create
();
rocksdb_writebatch_t
*
rwritebatch
=
rocksdb_writebatch_create
();
pTsdb
->
rCache
.
writebatch
=
writebatch
;
pTsdb
->
rCache
.
rwritebatch
=
rwritebatch
;
pTsdb
->
rCache
.
my_comparator
=
cmp
;
pTsdb
->
rCache
.
options
=
options
;
pTsdb
->
rCache
.
writeoptions
=
writeoptions
;
...
...
@@ -198,6 +200,7 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
rocksdb_close
(
pTsdb
->
rCache
.
db
);
rocksdb_flushoptions_destroy
(
pTsdb
->
rCache
.
flushoptions
);
rocksdb_writebatch_destroy
(
pTsdb
->
rCache
.
writebatch
);
rocksdb_writebatch_destroy
(
pTsdb
->
rCache
.
rwritebatch
);
rocksdb_readoptions_destroy
(
pTsdb
->
rCache
.
readoptions
);
rocksdb_writeoptions_destroy
(
pTsdb
->
rCache
.
writeoptions
);
rocksdb_options_destroy
(
pTsdb
->
rCache
.
options
);
...
...
@@ -208,9 +211,12 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
taosMemoryFree
(
pTsdb
->
rCache
.
pTSchema
);
}
static
void
rocksMayWrite
(
STsdb
*
pTsdb
,
bool
force
)
{
static
void
rocksMayWrite
(
STsdb
*
pTsdb
,
bool
force
,
bool
read
)
{
rocksdb_writebatch_t
*
wb
=
pTsdb
->
rCache
.
writebatch
;
int
count
=
rocksdb_writebatch_count
(
wb
);
if
(
read
)
{
wb
=
pTsdb
->
rCache
.
rwritebatch
;
}
int
count
=
rocksdb_writebatch_count
(
wb
);
if
((
force
&&
count
>
0
)
||
count
>=
1024
)
{
char
*
err
=
NULL
;
rocksdb_write
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
writeoptions
,
wb
,
&
err
);
...
...
@@ -228,7 +234,8 @@ int32_t tsdbCacheCommit(STsdb *pTsdb) {
int32_t
code
=
0
;
char
*
err
=
NULL
;
rocksMayWrite
(
pTsdb
,
true
);
rocksMayWrite
(
pTsdb
,
true
,
false
);
rocksMayWrite
(
pTsdb
,
true
,
true
);
rocksdb_flush
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
flushoptions
,
&
err
);
if
(
NULL
!=
err
)
{
tsdbError
(
"vgId:%d, %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
__LINE__
,
err
);
...
...
@@ -454,7 +461,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list_sizes
);
rocksMayWrite
(
pTsdb
,
false
);
rocksMayWrite
(
pTsdb
,
false
,
false
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
_exit:
...
...
@@ -538,7 +545,7 @@ int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheR
}
// store result back to rocks cache
wb
=
pTsdb
->
rCache
.
writebatch
;
wb
=
pTsdb
->
rCache
.
r
writebatch
;
char
*
value
=
NULL
;
size_t
vlen
=
0
;
tsdbCacheSerialize
(
pLastCol
,
&
value
,
&
vlen
);
...
...
@@ -553,7 +560,7 @@ int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheR
}
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
);
rocksMayWrite
(
pTsdb
,
false
,
true
);
}
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
...
...
@@ -603,7 +610,7 @@ static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t sl
}
// store result back to rocks cache
wb
=
pTsdb
->
rCache
.
writebatch
;
wb
=
pTsdb
->
rCache
.
r
writebatch
;
char
*
value
=
NULL
;
size_t
vlen
=
0
;
tsdbCacheSerialize
(
pLastCol
,
&
value
,
&
vlen
);
...
...
@@ -621,7 +628,7 @@ static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t sl
}
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
);
rocksMayWrite
(
pTsdb
,
false
,
true
);
}
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
...
...
@@ -688,7 +695,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
}
// store result back to rocks cache
wb
=
pTsdb
->
rCache
.
writebatch
;
wb
=
pTsdb
->
rCache
.
r
writebatch
;
char
*
value
=
NULL
;
size_t
vlen
=
0
;
tsdbCacheSerialize
(
pLastCol
,
&
value
,
&
vlen
);
...
...
@@ -703,7 +710,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
}
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
);
rocksMayWrite
(
pTsdb
,
false
,
true
);
}
taosArrayDestroy
(
pTmpColArray
);
...
...
@@ -933,7 +940,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
size_t
*
values_list_sizes
=
taosMemoryCalloc
(
num_keys
*
2
,
sizeof
(
size_t
));
char
**
errs
=
taosMemoryCalloc
(
num_keys
*
2
,
sizeof
(
char
*
));
taosThreadMutexLock
(
&
pTsdb
->
rCache
.
rMutex
);
rocksMayWrite
(
pTsdb
,
true
);
rocksMayWrite
(
pTsdb
,
true
,
false
);
rocksdb_multi_get
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
readoptions
,
num_keys
*
2
,
(
const
char
*
const
*
)
keys_list
,
keys_list_sizes
,
values_list
,
values_list_sizes
,
errs
);
for
(
int
i
=
0
;
i
<
num_keys
;
++
i
)
{
...
...
@@ -972,7 +979,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list_sizes
);
rocksMayWrite
(
pTsdb
,
true
);
rocksMayWrite
(
pTsdb
,
true
,
false
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
_exit:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录