Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
ded4b1d3
T
TDengine
项目概览
小楼昨夜-听风雨
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ded4b1d3
编写于
11月 03, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 03, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4086 from taosdata/feature/wal
Feature/wal
上级
b5f65e47
b8e60b79
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
20 deletion
+39
-20
src/inc/twal.h
src/inc/twal.h
+1
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+4
-0
src/wal/inc/walInt.h
src/wal/inc/walInt.h
+2
-0
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+11
-3
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+6
-1
tests/script/general/insert/basic.sim
tests/script/general/insert/basic.sim
+15
-16
未找到文件。
src/inc/twal.h
浏览文件 @
ded4b1d3
...
...
@@ -51,6 +51,7 @@ void walCleanUp();
twalh
walOpen
(
char
*
path
,
SWalCfg
*
pCfg
);
int32_t
walAlter
(
twalh
pWal
,
SWalCfg
*
pCfg
);
void
walStop
(
twalh
);
void
walClose
(
twalh
);
int32_t
walRenew
(
twalh
);
int32_t
walWrite
(
twalh
,
SWalHead
*
);
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
ded4b1d3
...
...
@@ -386,6 +386,10 @@ void vnodeRelease(void *pVnodeRaw) {
pVnode
->
qMgmt
=
NULL
;
}
if
(
pVnode
->
wal
)
{
walStop
(
pVnode
->
wal
);
}
if
(
pVnode
->
tsdb
)
{
tsdbCloseRepo
(
pVnode
->
tsdb
,
1
);
pVnode
->
tsdb
=
NULL
;
...
...
src/wal/inc/walInt.h
浏览文件 @
ded4b1d3
...
...
@@ -49,6 +49,8 @@ typedef struct {
int32_t
level
;
int32_t
fsyncPeriod
;
int32_t
fsyncSeq
;
int8_t
stop
;
int8_t
reserved
[
3
];
char
path
[
WAL_PATH_LEN
];
char
name
[
WAL_FILE_LEN
];
pthread_mutex_t
mutex
;
...
...
src/wal/src/walMgmt.c
浏览文件 @
ded4b1d3
...
...
@@ -110,6 +110,16 @@ int32_t walAlter(void *handle, SWalCfg *pCfg) {
return
TSDB_CODE_SUCCESS
;
}
void
walStop
(
void
*
handle
)
{
if
(
handle
==
NULL
)
return
;
SWal
*
pWal
=
handle
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
pWal
->
stop
=
1
;
pthread_mutex_unlock
(
&
pWal
->
mutex
);
wDebug
(
"vgId:%d, stop write wal"
,
pWal
->
vgId
);
}
void
walClose
(
void
*
handle
)
{
if
(
handle
==
NULL
)
return
;
...
...
@@ -123,9 +133,7 @@ void walClose(void *handle) {
while
(
walGetNextFile
(
pWal
,
&
fileId
)
>=
0
)
{
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
fileId
);
if
(
fileId
==
pWal
->
fileId
)
{
wDebug
(
"vgId:%d, wal:%p file:%s, it is closed and kept"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
else
if
(
remove
(
pWal
->
name
)
<
0
)
{
if
(
remove
(
pWal
->
name
)
<
0
)
{
wError
(
"vgId:%d, wal:%p file:%s, failed to remove"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
else
{
wDebug
(
"vgId:%d, wal:%p file:%s, it is removed"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
...
...
src/wal/src/walWrite.c
浏览文件 @
ded4b1d3
...
...
@@ -29,6 +29,11 @@ int32_t walRenew(void *handle) {
SWal
*
pWal
=
handle
;
int32_t
code
=
0
;
if
(
pWal
->
stop
)
{
wDebug
(
"vgId:%d, do not create a new wal file"
,
pWal
->
vgId
);
return
0
;
}
pthread_mutex_lock
(
&
pWal
->
mutex
);
if
(
pWal
->
fd
>=
0
)
{
...
...
@@ -151,7 +156,7 @@ int32_t walRestore(void *handle, void *pVnode, int32_t (*writeFp)(void *, void *
if
(
!
pWal
->
keep
)
return
TSDB_CODE_SUCCESS
;
if
(
count
==
0
)
{
wDebug
(
"vgId:%d,
file:%s not exist, renew it"
,
pWal
->
vgId
,
pWal
->
name
);
wDebug
(
"vgId:%d,
wal file not exist, renew it"
,
pWal
->
vgId
);
return
walRenew
(
pWal
);
}
else
{
// open the existing WAL file in append mode
...
...
tests/script/general/insert/basic.sim
浏览文件 @
ded4b1d3
...
...
@@ -8,8 +8,8 @@ sleep 3000
sql connect
$i = 0
$dbPrefix =
tb_in_db
$tbPrefix = t
b_in_tb
$dbPrefix =
d
$tbPrefix = t
$db = $dbPrefix . $i
$tb = $tbPrefix . $i
...
...
@@ -22,28 +22,27 @@ sql create table $tb (ts timestamp, speed int)
$x = 0
while $x < 10
$ms = $x . m
sql insert into $tb values (now + $ms , $x )
$cc = $x * 60000
$ms = 1601481600000 + $cc
sql insert into $tb values ($ms , $x )
$x = $x + 1
endw
print =============== step 2
sql insert into $tb values (now - 5m , 10)
sql insert into $tb values (now - 6m , 10)
sql insert into $tb values (now - 7m , 10)
sql insert into $tb values (now - 8m , 10)
$x = 0
while $x < 5
$cc = $x * 60000
$ms = 1551481600000 + $cc
sql insert into $tb values ($ms , $x )
$x = $x + 1
endw
sql select * from $tb
print $rows points data are retrieved
if $rows != 14 then
return -1
endi
sql drop database $db
sleep 1000
sql show databases
if $rows != 0 then
if $rows != 15 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录