Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
68a98d4d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
68a98d4d
编写于
5月 23, 2023
作者:
W
wade zhang
提交者:
GitHub
5月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21429 from taosdata/fix/TD-24306
fix(cache): sychronize commit, read and write threads with writebatch
上级
41c74eb4
81048f93
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
10 deletion
+23
-10
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+23
-10
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
68a98d4d
...
@@ -211,10 +211,18 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
...
@@ -211,10 +211,18 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
taosMemoryFree
(
pTsdb
->
rCache
.
pTSchema
);
taosMemoryFree
(
pTsdb
->
rCache
.
pTSchema
);
}
}
static
void
rocksMayWrite
(
STsdb
*
pTsdb
,
bool
force
,
bool
read
)
{
static
void
rocksMayWrite
(
STsdb
*
pTsdb
,
bool
force
,
bool
read
,
bool
lock
)
{
rocksdb_writebatch_t
*
wb
=
pTsdb
->
rCache
.
writebatch
;
rocksdb_writebatch_t
*
wb
=
NULL
;
if
(
read
)
{
if
(
read
)
{
if
(
lock
)
{
taosThreadMutexLock
(
&
pTsdb
->
lruMutex
);
}
wb
=
pTsdb
->
rCache
.
rwritebatch
;
wb
=
pTsdb
->
rCache
.
rwritebatch
;
}
else
{
if
(
lock
)
{
taosThreadMutexLock
(
&
pTsdb
->
rCache
.
rMutex
);
}
wb
=
pTsdb
->
rCache
.
writebatch
;
}
}
int
count
=
rocksdb_writebatch_count
(
wb
);
int
count
=
rocksdb_writebatch_count
(
wb
);
if
((
force
&&
count
>
0
)
||
count
>=
1024
)
{
if
((
force
&&
count
>
0
)
||
count
>=
1024
)
{
...
@@ -228,14 +236,19 @@ static void rocksMayWrite(STsdb *pTsdb, bool force, bool read) {
...
@@ -228,14 +236,19 @@ static void rocksMayWrite(STsdb *pTsdb, bool force, bool read) {
rocksdb_writebatch_clear
(
wb
);
rocksdb_writebatch_clear
(
wb
);
}
}
if
(
read
)
{
if
(
lock
)
taosThreadMutexUnlock
(
&
pTsdb
->
lruMutex
);
}
else
{
if
(
lock
)
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
}
}
}
int32_t
tsdbCacheCommit
(
STsdb
*
pTsdb
)
{
int32_t
tsdbCacheCommit
(
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
char
*
err
=
NULL
;
char
*
err
=
NULL
;
rocksMayWrite
(
pTsdb
,
true
,
false
);
rocksMayWrite
(
pTsdb
,
true
,
false
,
true
);
rocksMayWrite
(
pTsdb
,
true
,
true
);
rocksMayWrite
(
pTsdb
,
true
,
true
,
true
);
rocksdb_flush
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
flushoptions
,
&
err
);
rocksdb_flush
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
flushoptions
,
&
err
);
if
(
NULL
!=
err
)
{
if
(
NULL
!=
err
)
{
tsdbError
(
"vgId:%d, %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
__LINE__
,
err
);
tsdbError
(
"vgId:%d, %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
__LINE__
,
err
);
...
@@ -461,7 +474,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
...
@@ -461,7 +474,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list_sizes
);
taosMemoryFree
(
values_list_sizes
);
rocksMayWrite
(
pTsdb
,
false
,
false
);
rocksMayWrite
(
pTsdb
,
false
,
false
,
false
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
_exit:
_exit:
...
@@ -560,7 +573,7 @@ int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheR
...
@@ -560,7 +573,7 @@ int32_t tsdbCacheGetSlow(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheR
}
}
if
(
wb
)
{
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
,
true
);
rocksMayWrite
(
pTsdb
,
false
,
true
,
false
);
}
}
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
...
@@ -628,7 +641,7 @@ static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t sl
...
@@ -628,7 +641,7 @@ static SLastCol *tsdbCacheLoadCol(STsdb *pTsdb, SCacheRowsReader *pr, int16_t sl
}
}
if
(
wb
)
{
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
,
true
);
rocksMayWrite
(
pTsdb
,
false
,
true
,
false
);
}
}
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
...
@@ -714,7 +727,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
...
@@ -714,7 +727,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
}
}
if
(
wb
)
{
if
(
wb
)
{
rocksMayWrite
(
pTsdb
,
false
,
true
);
rocksMayWrite
(
pTsdb
,
false
,
true
,
false
);
}
}
taosArrayDestroy
(
pTmpColArray
);
taosArrayDestroy
(
pTmpColArray
);
...
@@ -944,7 +957,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
...
@@ -944,7 +957,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
));
size_t
*
values_list_sizes
=
taosMemoryCalloc
(
num_keys
*
2
,
sizeof
(
size_t
));
char
**
errs
=
taosMemoryCalloc
(
num_keys
*
2
,
sizeof
(
char
*
));
char
**
errs
=
taosMemoryCalloc
(
num_keys
*
2
,
sizeof
(
char
*
));
taosThreadMutexLock
(
&
pTsdb
->
rCache
.
rMutex
);
taosThreadMutexLock
(
&
pTsdb
->
rCache
.
rMutex
);
rocksMayWrite
(
pTsdb
,
true
,
false
);
rocksMayWrite
(
pTsdb
,
true
,
false
,
false
);
rocksdb_multi_get
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
readoptions
,
num_keys
*
2
,
(
const
char
*
const
*
)
keys_list
,
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
);
keys_list_sizes
,
values_list
,
values_list_sizes
,
errs
);
for
(
int
i
=
0
;
i
<
num_keys
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num_keys
;
++
i
)
{
...
@@ -983,7 +996,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
...
@@ -983,7 +996,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list_sizes
);
taosMemoryFree
(
values_list_sizes
);
rocksMayWrite
(
pTsdb
,
true
,
false
);
rocksMayWrite
(
pTsdb
,
true
,
false
,
false
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
_exit:
_exit:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录