Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e3090485
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
e3090485
编写于
12月 30, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle read/write crash concurrently
上级
236b8bc3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
5 deletion
+58
-5
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+2
-2
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+56
-3
未找到文件。
source/libs/index/src/index_cache.c
浏览文件 @
e3090485
...
...
@@ -181,9 +181,9 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
break
;
}
else
if
(
cache
->
imm
!=
NULL
)
{
// TODO: wake up by condition variable
//
pthread_mutex_unlock(&cache->mtx);
pthread_mutex_unlock
(
&
cache
->
mtx
);
taosMsleep
(
50
);
//
pthread_mutex_lock(&cache->mtx);
pthread_mutex_lock
(
&
cache
->
mtx
);
}
else
{
indexCacheRef
(
cache
);
cache
->
imm
=
cache
->
mem
;
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
e3090485
...
...
@@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <thread>
#include "index.h"
#include "indexInt.h"
#include "index_cache.h"
...
...
@@ -25,6 +26,9 @@
#include "tskiplist.h"
#include "tutil.h"
using
namespace
std
;
#define NUM_OF_THREAD 10
class
DebugInfo
{
public:
DebugInfo
(
const
char
*
str
)
:
info
(
str
)
{
...
...
@@ -41,6 +45,7 @@ class DebugInfo {
private:
std
::
string
info
;
};
class
FstWriter
{
public:
FstWriter
()
{
...
...
@@ -637,6 +642,23 @@ class IndexObj {
indexMultiTermDestroy
(
terms
);
return
numOfTable
;
}
int
WriteMultiMillonData
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
=
"Hello world"
,
size_t
numOfTable
=
100
*
10000
)
{
std
::
string
tColVal
=
colVal
;
for
(
int
i
=
0
;
i
<
numOfTable
;
i
++
)
{
tColVal
[
tColVal
.
size
()
-
1
]
=
'a'
+
i
%
26
;
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
10
;
i
++
)
{
int
ret
=
Put
(
terms
,
i
);
assert
(
ret
==
0
);
}
indexMultiTermDestroy
(
terms
);
}
return
numOfTable
;
}
int
Put
(
SIndexMultiTerm
*
fvs
,
uint64_t
uid
)
{
numOfWrite
+=
taosArrayGetSize
(
fvs
);
...
...
@@ -659,6 +681,14 @@ class IndexObj {
return
taosArrayGetSize
(
result
);
// assert(taosArrayGetSize(result) == targetSize);
}
void
PutOne
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
)
{
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
Put
(
terms
,
10
);
indexMultiTermDestroy
(
terms
);
}
void
Debug
()
{
std
::
cout
<<
"numOfWrite:"
<<
numOfWrite
<<
std
::
endl
;
std
::
cout
<<
"numOfRead:"
<<
numOfRead
<<
std
::
endl
;
...
...
@@ -758,15 +788,38 @@ TEST_F(IndexEnv2, testIndexOpen) {
TEST_F
(
IndexEnv2
,
testIndex_TrigeFlush
)
{
std
::
string
path
=
"/tmp/test"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
// r
std
::
cout
<<
"failed to init"
<<
std
::
endl
;
}
int
numOfTable
=
100
*
10000
;
index
->
WriteMillonData
(
"tag1"
,
"Hello"
,
numOfTable
);
int
target
=
index
->
SearchOne
(
"tag1"
,
"Hello"
);
assert
(
numOfTable
==
target
);
}
static
void
write_and_search
(
IndexObj
*
idx
)
{
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
int
target
=
idx
->
SearchOne
(
"tag1"
,
"Hello"
);
idx
->
PutOne
(
colName
,
colVal
);
}
TEST_F
(
IndexEnv2
,
testIndex_serarch_cache_and_tfile
)
{
std
::
string
path
=
"/tmp"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
// opt
}
index
->
WriteMultiMillonData
(
"tag1"
,
"Hello"
,
200000
);
std
::
thread
threads
[
NUM_OF_THREAD
];
for
(
int
i
=
0
;
i
<
NUM_OF_THREAD
;
i
++
)
{
//
threads
[
i
]
=
std
::
thread
(
write_and_search
,
index
);
}
for
(
int
i
=
0
;
i
<
NUM_OF_THREAD
;
i
++
)
{
// TOD
threads
[
i
].
join
();
}
}
TEST_F
(
IndexEnv2
,
testIndex_multi_thread_write
)
{
std
::
string
path
=
"/tmp"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录