Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7cce5d88
T
TDengine
项目概览
慢慢CG
/
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看板
未验证
提交
7cce5d88
编写于
11月 12, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 12, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4195 from taosdata/feature/wal
[TD-1896]<fix>: Wal data may be lost when the system crashes
上级
cfe2e67f
028e62c9
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
94 addition
and
26 deletion
+94
-26
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+11
-0
src/inc/twal.h
src/inc/twal.h
+11
-10
src/util/src/tutil.c
src/util/src/tutil.c
+2
-1
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+4
-4
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+1
-10
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+17
-1
tests/script/general/wal/maxtables.sim
tests/script/general/wal/maxtables.sim
+46
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
未找到文件。
src/common/inc/tglobal.h
浏览文件 @
7cce5d88
...
...
@@ -44,6 +44,7 @@ extern int32_t tsMaxShellConns;
extern
int32_t
tsShellActivityTimer
;
extern
uint32_t
tsMaxTmrCtrl
;
extern
float
tsNumOfThreadsPerCore
;
extern
int32_t
tsNumOfCommitThreads
;
extern
float
tsRatioOfQueryThreads
;
// todo remove it
extern
int8_t
tsDaylight
;
extern
char
tsTimezone
[];
...
...
src/common/src/tglobal.c
浏览文件 @
7cce5d88
...
...
@@ -51,6 +51,7 @@ int32_t tsMaxShellConns = 5000;
int32_t
tsMaxConnections
=
5000
;
int32_t
tsShellActivityTimer
=
3
;
// second
float
tsNumOfThreadsPerCore
=
1
.
0
f
;
int32_t
tsNumOfCommitThreads
=
1
;
float
tsRatioOfQueryThreads
=
0
.
5
f
;
int8_t
tsDaylight
=
0
;
char
tsTimezone
[
TSDB_TIMEZONE_LEN
]
=
{
0
};
...
...
@@ -426,6 +427,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"numOfCommitThreads"
;
cfg
.
ptr
=
&
tsNumOfCommitThreads
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
1
;
cfg
.
maxValue
=
100
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"ratioOfQueryThreads"
;
cfg
.
ptr
=
&
tsRatioOfQueryThreads
;
cfg
.
valType
=
TAOS_CFG_VTYPE_FLOAT
;
...
...
src/inc/twal.h
浏览文件 @
7cce5d88
...
...
@@ -54,16 +54,17 @@ typedef int32_t FWalWrite(void *ahandle, void *pHead, int32_t qtype, void *pMsg)
int32_t
walInit
();
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
);
void
walRemoveOldFiles
(
twalh
);
int32_t
walWrite
(
twalh
,
SWalHead
*
);
void
walFsync
(
twalh
,
bool
forceFsync
);
int32_t
walRestore
(
twalh
,
void
*
pVnode
,
FWalWrite
writeFp
);
int32_t
walGetWalFile
(
twalh
,
char
*
fileName
,
int64_t
*
fileId
);
twalh
walOpen
(
char
*
path
,
SWalCfg
*
pCfg
);
int32_t
walAlter
(
twalh
pWal
,
SWalCfg
*
pCfg
);
void
walStop
(
twalh
);
void
walClose
(
twalh
);
int32_t
walRenew
(
twalh
);
void
walRemoveOneOldFile
(
twalh
);
void
walRemoveAllOldFiles
(
twalh
);
int32_t
walWrite
(
twalh
,
SWalHead
*
);
void
walFsync
(
twalh
,
bool
forceFsync
);
int32_t
walRestore
(
twalh
,
void
*
pVnode
,
FWalWrite
writeFp
);
int32_t
walGetWalFile
(
twalh
,
char
*
fileName
,
int64_t
*
fileId
);
uint64_t
walGetVersion
(
twalh
);
#ifdef __cplusplus
...
...
src/util/src/tutil.c
浏览文件 @
7cce5d88
...
...
@@ -377,7 +377,8 @@ int taosCheckVersion(char *input_client_version, char *input_server_version, int
for
(
int32_t
i
=
0
;
i
<
comparedSegments
;
++
i
)
{
if
(
clientVersionNumber
[
i
]
!=
serverVersionNumber
[
i
])
{
uError
(
"the %d-th number of server version:%s not matched with client version:%s"
,
i
,
server_version
,
version
);
uError
(
"the %d-th number of server version:%s not matched with client version:%s"
,
i
,
server_version
,
client_version
);
return
TSDB_CODE_TSC_INVALID_VERSION
;
}
}
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
7cce5d88
...
...
@@ -28,8 +28,6 @@
#include "vnodeCfg.h"
#include "vnodeVersion.h"
#define DEFAULT_COMMIT_THREADS 1
static
SHashObj
*
tsVnodesHash
;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
int
vnodeProcessTsdbStatus
(
void
*
arg
,
int
status
);
...
...
@@ -69,7 +67,7 @@ int32_t vnodeInitResources() {
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
}
if
(
tsdbInitCommitQueue
(
DEFAULT_COMMIT_THREADS
)
<
0
)
{
if
(
tsdbInitCommitQueue
(
tsNumOfCommitThreads
)
<
0
)
{
vError
(
"failed to init vnode commit queue"
);
return
terrno
;
}
...
...
@@ -317,6 +315,8 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode
->
version
=
walGetVersion
(
pVnode
->
wal
);
}
tsdbSyncCommit
(
pVnode
->
tsdb
);
walRemoveAllOldFiles
(
pVnode
->
wal
);
walRenew
(
pVnode
->
wal
);
SSyncInfo
syncInfo
;
...
...
@@ -592,7 +592,7 @@ static int vnodeProcessTsdbStatus(void *arg, int status) {
if
(
status
==
TSDB_STATUS_COMMIT_OVER
)
{
vDebug
(
"vgId:%d, commit over, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
pVnode
->
fversion
,
pVnode
->
version
);
walRemoveO
ldFiles
(
pVnode
->
wal
);
walRemoveO
neOldFile
(
pVnode
->
wal
);
return
vnodeSaveVersion
(
pVnode
);
}
...
...
src/wal/src/walMgmt.c
浏览文件 @
7cce5d88
...
...
@@ -128,16 +128,7 @@ void walClose(void *handle) {
taosClose
(
pWal
->
fd
);
if
(
pWal
->
keep
!=
TAOS_WAL_KEEP
)
{
int64_t
fileId
=
-
1
;
while
(
walGetNextFile
(
pWal
,
&
fileId
)
>=
0
)
{
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
fileId
);
if
(
remove
(
pWal
->
name
)
<
0
)
{
wError
(
"vgId:%d, wal:%p file:%s, failed to remove"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
else
{
wInfo
(
"vgId:%d, wal:%p file:%s, it is removed"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
}
walRemoveAllOldFiles
(
pWal
);
}
else
{
wDebug
(
"vgId:%d, wal:%p file:%s, it is closed and kept"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
...
...
src/wal/src/walWrite.c
浏览文件 @
7cce5d88
...
...
@@ -63,7 +63,7 @@ int32_t walRenew(void *handle) {
return
code
;
}
void
walRemoveO
ldFiles
(
void
*
handle
)
{
void
walRemoveO
neOldFile
(
void
*
handle
)
{
SWal
*
pWal
=
handle
;
if
(
pWal
==
NULL
)
return
;
if
(
pWal
->
keep
==
TAOS_WAL_KEEP
)
return
;
...
...
@@ -86,6 +86,22 @@ void walRemoveOldFiles(void *handle) {
pthread_mutex_unlock
(
&
pWal
->
mutex
);
}
void
walRemoveAllOldFiles
(
void
*
handle
)
{
if
(
handle
==
NULL
)
return
;
SWal
*
pWal
=
handle
;
int64_t
fileId
=
-
1
;
while
(
walGetNextFile
(
pWal
,
&
fileId
)
>=
0
)
{
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
fileId
);
if
(
remove
(
pWal
->
name
)
<
0
)
{
wError
(
"vgId:%d, wal:%p file:%s, failed to remove"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
else
{
wInfo
(
"vgId:%d, wal:%p file:%s, it is removed"
,
pWal
->
vgId
,
pWal
,
pWal
->
name
);
}
}
}
int32_t
walWrite
(
void
*
handle
,
SWalHead
*
pHead
)
{
if
(
handle
==
NULL
)
return
-
1
;
...
...
tests/script/general/wal/maxtables.sim
0 → 100644
浏览文件 @
7cce5d88
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1
system sh/cfg.sh -n dnode1 -c tableIncStepPerVnode -v 2
print ============== deploy
system sh/exec.sh -n dnode1 -s start
sleep 3001
sql connect
sql create database d1
sql use d1
sql create table st (ts timestamp, tbcol int) TAGS(tgcol int)
$i = 0
while $i < 100
$tb = t . $i
sql create table $tb using st tags( $i )
sql insert into $tb values (now , $i )
$i = $i + 1
endw
sql_error sql create table tt (ts timestamp, i int)
print =============== step3
sql select * from st;
if $rows != 100 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
sleep 3000
print =============== step4
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql select * from st;
if $rows != 100 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/jenkins/basic.txt
浏览文件 @
7cce5d88
...
...
@@ -238,6 +238,7 @@ cd ../../../debug; make
./test.sh -f general/wal/sync.sim
./test.sh -f general/wal/kill.sim
./test.sh -f general/wal/maxtables.sim
./test.sh -f unique/account/account_create.sim
./test.sh -f unique/account/account_delete.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录