Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
33d14c1b
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
33d14c1b
编写于
9月 22, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3634 from taosdata/feature/crash
TD-1388
上级
2af658f9
bec67429
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
70 addition
and
13 deletion
+70
-13
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/inc/twal.h
src/inc/twal.h
+1
-0
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+4
-4
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+7
-0
src/wal/src/walMain.c
src/wal/src/walMain.c
+47
-3
tests/script/general/db/alter_option.sim
tests/script/general/db/alter_option.sim
+10
-5
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
33d14c1b
...
...
@@ -5755,7 +5755,7 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) {
char
msg
[
512
]
=
{
0
};
if
(
pCreate
->
walLevel
!=
-
1
&&
(
pCreate
->
walLevel
<
TSDB_MIN_WAL_LEVEL
||
pCreate
->
walLevel
>
TSDB_MAX_WAL_LEVEL
))
{
snprintf
(
msg
,
tListLen
(
msg
),
"invalid db option walLevel: %d, only
0
-2 allowed"
,
pCreate
->
walLevel
);
snprintf
(
msg
,
tListLen
(
msg
),
"invalid db option walLevel: %d, only
1
-2 allowed"
,
pCreate
->
walLevel
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
...
...
src/inc/twal.h
浏览文件 @
33d14c1b
...
...
@@ -44,6 +44,7 @@ typedef void* twalh; // WAL HANDLE
typedef
int
(
*
FWalWrite
)(
void
*
ahandle
,
void
*
pHead
,
int
type
);
twalh
walOpen
(
const
char
*
path
,
const
SWalCfg
*
pCfg
);
int
walAlter
(
twalh
pWal
,
const
SWalCfg
*
pCfg
);
void
walClose
(
twalh
);
int
walRenew
(
twalh
);
int
walWrite
(
twalh
,
SWalHead
*
);
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
33d14c1b
...
...
@@ -910,13 +910,13 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
}
if
(
walLevel
>
0
&&
walLevel
!=
pDb
->
cfg
.
walLevel
)
{
m
Error
(
"db:%s, can't alter walLevel option"
,
pDb
->
name
);
terrno
=
TSDB_CODE_MND_INVALID_DB_OPTION
;
m
Debug
(
"db:%s, walLevel:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
walLevel
,
walLevel
);
newCfg
.
walLevel
=
walLevel
;
}
if
(
fsyncPeriod
>=
0
&&
fsyncPeriod
!=
pDb
->
cfg
.
fsyncPeriod
)
{
m
Error
(
"db:%s, can't alter fsyncPeriod option"
,
pDb
->
name
);
terrno
=
TSDB_CODE_MND_INVALID_DB_OPTION
;
m
Debug
(
"db:%s, fsyncPeriod:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
fsyncPeriod
,
fsyncPeriod
);
newCfg
.
fsyncPeriod
=
fsyncPeriod
;
}
if
(
replications
>
0
&&
replications
!=
pDb
->
cfg
.
replications
)
{
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
33d14c1b
...
...
@@ -186,6 +186,12 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
return
code
;
}
code
=
walAlter
(
pVnode
->
wal
,
&
pVnode
->
walCfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
return
code
;
}
code
=
syncReconfig
(
pVnode
->
sync
,
&
pVnode
->
syncCfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
...
...
@@ -390,6 +396,7 @@ void vnodeRelease(void *pVnodeRaw) {
if
(
0
==
tsEnableVnodeBak
)
{
vInfo
(
"vgId:%d, vnode backup not enabled"
,
pVnode
->
vgId
);
}
else
{
taosRemoveDir
(
newDir
);
taosRename
(
rootDir
,
newDir
);
}
...
...
src/wal/src/walMain.c
浏览文件 @
33d14c1b
...
...
@@ -69,6 +69,13 @@ static void walModuleInitFunc() {
wDebug
(
"WAL module is initialized"
);
}
static
inline
bool
walNeedFsyncTimer
(
SWal
*
pWal
)
{
if
(
pWal
->
fsyncPeriod
>
0
&&
pWal
->
level
==
TAOS_WAL_FSYNC
)
{
return
true
;
}
return
false
;
}
void
*
walOpen
(
const
char
*
path
,
const
SWalCfg
*
pCfg
)
{
SWal
*
pWal
=
calloc
(
sizeof
(
SWal
),
1
);
if
(
pWal
==
NULL
)
{
...
...
@@ -95,7 +102,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
tstrncpy
(
pWal
->
path
,
path
,
sizeof
(
pWal
->
path
));
pthread_mutex_init
(
&
pWal
->
mutex
,
NULL
);
if
(
pWal
->
fsyncPeriod
>
0
&&
pWal
->
level
==
TAOS_WAL_FSYNC
)
{
if
(
walNeedFsyncTimer
(
pWal
)
)
{
pWal
->
timer
=
taosTmrStart
(
walProcessFsyncTimer
,
pWal
->
fsyncPeriod
,
pWal
,
walTmrCtrl
);
if
(
pWal
->
timer
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -127,6 +134,37 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
return
pWal
;
}
int
walAlter
(
twalh
wal
,
const
SWalCfg
*
pCfg
)
{
SWal
*
pWal
=
wal
;
if
(
pWal
==
NULL
)
{
return
TSDB_CODE_WAL_APP_ERROR
;
}
if
(
pWal
->
level
==
pCfg
->
walLevel
&&
pWal
->
fsyncPeriod
==
pCfg
->
fsyncPeriod
)
{
wDebug
(
"wal:%s, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change"
,
pWal
->
name
,
pWal
->
level
,
pWal
->
fsyncPeriod
,
pCfg
->
walLevel
,
pCfg
->
fsyncPeriod
);
return
TSDB_CODE_SUCCESS
;
}
wInfo
(
"wal:%s, change old walLevel:%d fsync:%d, new walLevel:%d fsync:%d"
,
pWal
->
name
,
pWal
->
level
,
pWal
->
fsyncPeriod
,
pCfg
->
walLevel
,
pCfg
->
fsyncPeriod
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
fsyncPeriod
=
pCfg
->
fsyncPeriod
;
if
(
walNeedFsyncTimer
(
pWal
))
{
wInfo
(
"wal:%s, reset fsync timer, walLevel:%d fsyncPeriod:%d"
,
pWal
->
name
,
pWal
->
level
,
pWal
->
fsyncPeriod
);
taosTmrReset
(
walProcessFsyncTimer
,
pWal
->
fsyncPeriod
,
pWal
,
&
pWal
->
timer
,
walTmrCtrl
);
}
else
{
wInfo
(
"wal:%s, stop fsync timer, walLevel:%d fsyncPeriod:%d"
,
pWal
->
name
,
pWal
->
level
,
pWal
->
fsyncPeriod
);
taosTmrStop
(
pWal
->
timer
);
pWal
->
timer
=
NULL
;
}
pthread_mutex_unlock
(
&
pWal
->
mutex
);
return
TSDB_CODE_SUCCESS
;
}
void
walClose
(
void
*
handle
)
{
if
(
handle
==
NULL
)
return
;
...
...
@@ -484,6 +522,12 @@ static void walProcessFsyncTimer(void *param, void *tmrId) {
if
(
fsync
(
pWal
->
fd
)
<
0
)
{
wError
(
"wal:%s, fsync failed(%s)"
,
pWal
->
name
,
strerror
(
errno
));
}
pWal
->
timer
=
taosTmrStart
(
walProcessFsyncTimer
,
pWal
->
fsyncPeriod
,
pWal
,
walTmrCtrl
);
if
(
walNeedFsyncTimer
(
pWal
))
{
pWal
->
timer
=
taosTmrStart
(
walProcessFsyncTimer
,
pWal
->
fsyncPeriod
,
pWal
,
walTmrCtrl
);
}
else
{
wInfo
(
"wal:%s, stop fsync timer for walLevel:%d fsyncPeriod:%d"
,
pWal
->
name
,
pWal
->
level
,
pWal
->
fsyncPeriod
);
taosTmrStop
(
pWal
->
timer
);
pWal
->
timer
=
NULL
;
}
}
tests/script/general/db/alter_option.sim
浏览文件 @
33d14c1b
...
...
@@ -218,7 +218,10 @@ if $data12_db != 1 then
return -1
endi
sql_error alter database db wal 2
sql alter database db wal 1
sql alter database db wal 2
sql alter database db wal 1
sql alter database db wal 2
sql_error alter database db wal 0
sql_error alter database db wal 3
sql_error alter database db wal 4
...
...
@@ -226,11 +229,13 @@ sql_error alter database db wal -1
sql_error alter database db wal 1000
print ============== step fsync
sql_error alter database db fsync 2
sql_error alter database db fsync 3
sql_error alter database db fsync 4
sql alter database db fsync 0
sql alter database db fsync 1
sql alter database db fsync 3600
sql alter database db fsync 18000
sql alter database db fsync 180000
sql_error alter database db fsync 180001
sql_error alter database db fsync -1
sql_error alter database db fsync 1000
print ============== step comp
sql show databases
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录