Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ad9c3cbd
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看板
未验证
提交
ad9c3cbd
编写于
7月 26, 2022
作者:
L
Liu Jicong
提交者:
GitHub
7月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15427 from taosdata/fix/wal
enh: add wal options to db
上级
10d378b4
e6e95dff
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
136 addition
and
85 deletion
+136
-85
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/libs/wal/wal.h
include/libs/wal/wal.h
+2
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+9
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+7
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+5
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+22
-0
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+4
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+2
-2
source/libs/wal/src/walMgmt.c
source/libs/wal/src/walMgmt.c
+7
-7
source/libs/wal/src/walSeek.c
source/libs/wal/src/walSeek.c
+12
-12
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+56
-55
tests/system-test/7-tmq/db.py
tests/system-test/7-tmq/db.py
+1
-1
tests/system-test/7-tmq/tmqDelete-1ctb.py
tests/system-test/7-tmq/tmqDelete-1ctb.py
+1
-1
tests/system-test/7-tmq/tmqDelete-multiCtb.py
tests/system-test/7-tmq/tmqDelete-multiCtb.py
+1
-1
tests/system-test/7-tmq/tmqDnodeRestart.py
tests/system-test/7-tmq/tmqDnodeRestart.py
+1
-1
tests/system-test/7-tmq/tmqUpdateWithConsume.py
tests/system-test/7-tmq/tmqUpdateWithConsume.py
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
ad9c3cbd
...
...
@@ -1154,6 +1154,10 @@ typedef struct {
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
// SRetention
void
*
pTsma
;
int32_t
walRetentionPeriod
;
int64_t
walRetentionSize
;
int32_t
walRollPeriod
;
int64_t
walSegmentSize
;
}
SCreateVnodeReq
;
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
...
...
include/libs/wal/wal.h
浏览文件 @
ad9c3cbd
...
...
@@ -103,8 +103,8 @@ typedef struct SWal {
int32_t
fsyncSeq
;
// meta
SWalVer
vers
;
TdFilePtr
p
WriteLogT
File
;
TdFilePtr
p
WriteIdxT
File
;
TdFilePtr
p
Log
File
;
TdFilePtr
p
Idx
File
;
int32_t
writeCur
;
SArray
*
fileInfoSet
;
// SArray<SWalFileInfo>
// status
...
...
source/common/src/tmsg.c
浏览文件 @
ad9c3cbd
...
...
@@ -3750,6 +3750,10 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
uint32_t
tsmaLen
=
(
uint32_t
)(
htonl
(((
SMsgHead
*
)
pReq
->
pTsma
)
->
contLen
));
if
(
tEncodeBinary
(
&
encoder
,
(
const
uint8_t
*
)
pReq
->
pTsma
,
tsmaLen
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32
(
&
encoder
,
pReq
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -3818,6 +3822,11 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeBinary
(
&
decoder
,
(
uint8_t
**
)
&
pReq
->
pTsma
,
NULL
)
<
0
)
return
-
1
;
}
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
walSegmentSize
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
ad9c3cbd
...
...
@@ -160,6 +160,13 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
}
pCfg
->
walCfg
.
vgId
=
pCreate
->
vgId
;
pCfg
->
walCfg
.
fsyncPeriod
=
pCreate
->
fsyncPeriod
;
pCfg
->
walCfg
.
retentionPeriod
=
pCreate
->
walRetentionPeriod
;
pCfg
->
walCfg
.
rollPeriod
=
pCreate
->
walRollPeriod
;
pCfg
->
walCfg
.
retentionSize
=
pCreate
->
walRetentionSize
;
pCfg
->
walCfg
.
segSize
=
pCreate
->
walSegmentSize
;
pCfg
->
walCfg
.
level
=
pCreate
->
walLevel
;
pCfg
->
hashBegin
=
pCreate
->
hashBegin
;
pCfg
->
hashEnd
=
pCreate
->
hashEnd
;
pCfg
->
hashMethod
=
pCreate
->
hashMethod
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
ad9c3cbd
...
...
@@ -302,9 +302,13 @@ typedef struct {
int8_t
strict
;
int8_t
hashMethod
;
// default is 1
int8_t
cacheLast
;
int8_t
schemaless
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
int8_t
schemaless
;
int32_t
walRetentionPeriod
;
int64_t
walRetentionSize
;
int32_t
walRollPeriod
;
int64_t
walSegmentSize
;
}
SDbCfg
;
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
ad9c3cbd
...
...
@@ -120,6 +120,10 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
keepUnit
,
_OVER
)
}
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
schemaless
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walRetentionPeriod
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walRetentionSize
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walRollPeriod
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pDb
->
cfg
.
walSegmentSize
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
...
@@ -199,6 +203,10 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
}
}
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
schemaless
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walRetentionPeriod
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walRetentionSize
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walRollPeriod
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
walSegmentSize
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
DB_RESERVE_SIZE
,
_OVER
)
taosInitRWLatch
(
&
pDb
->
lock
);
...
...
@@ -318,6 +326,10 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
return
-
1
;
}
if
(
pCfg
->
walRetentionPeriod
<
TSDB_DB_MIN_WAL_RETENTION_PERIOD
)
return
-
1
;
if
(
pCfg
->
walRetentionSize
<
TSDB_DB_MIN_WAL_RETENTION_SIZE
)
return
-
1
;
if
(
pCfg
->
walRollPeriod
<
TSDB_DB_MIN_WAL_ROLL_PERIOD
)
return
-
1
;
if
(
pCfg
->
walSegmentSize
<
TSDB_DB_MIN_WAL_SEGMENT_SIZE
)
return
-
1
;
terrno
=
0
;
return
terrno
;
...
...
@@ -345,6 +357,12 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
cacheLastSize
<=
0
)
pCfg
->
cacheLastSize
=
TSDB_DEFAULT_CACHE_SIZE
;
if
(
pCfg
->
numOfRetensions
<
0
)
pCfg
->
numOfRetensions
=
0
;
if
(
pCfg
->
schemaless
<
0
)
pCfg
->
schemaless
=
TSDB_DB_SCHEMALESS_OFF
;
if
(
pCfg
->
walRetentionPeriod
<
0
&&
pCfg
->
walRetentionPeriod
!=
-
1
)
pCfg
->
walRetentionPeriod
=
TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD
;
if
(
pCfg
->
walRetentionSize
<
0
&&
pCfg
->
walRetentionSize
!=
-
1
)
pCfg
->
walRetentionSize
=
TSDB_DEFAULT_DB_WAL_RETENTION_SIZE
;
if
(
pCfg
->
walRollPeriod
<
0
)
pCfg
->
walRollPeriod
=
TSDB_DEFAULT_DB_WAL_ROLL_PERIOD
;
if
(
pCfg
->
walSegmentSize
<
0
)
pCfg
->
walSegmentSize
=
TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE
;
}
static
int32_t
mndSetCreateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
...
...
@@ -457,6 +475,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
.
cacheLast
=
pCreate
->
cacheLast
,
.
hashMethod
=
1
,
.
schemaless
=
pCreate
->
schemaless
,
.
walRetentionPeriod
=
pCreate
->
walRetentionPeriod
,
.
walRetentionSize
=
pCreate
->
walRetentionSize
,
.
walRollPeriod
=
pCreate
->
walRollPeriod
,
.
walSegmentSize
=
pCreate
->
walSegmentSize
,
};
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
ad9c3cbd
...
...
@@ -230,6 +230,10 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq
.
standby
=
standby
;
createReq
.
isTsma
=
pVgroup
->
isTsma
;
createReq
.
pTsma
=
pVgroup
->
pTsma
;
createReq
.
walRetentionPeriod
=
pDb
->
cfg
.
walRetentionPeriod
;
createReq
.
walRetentionSize
=
pDb
->
cfg
.
walRetentionSize
;
createReq
.
walRollPeriod
=
pDb
->
cfg
.
walRollPeriod
;
createReq
.
walSegmentSize
=
pDb
->
cfg
.
walSegmentSize
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
ad9c3cbd
...
...
@@ -583,7 +583,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
vnodeGetCtbIdList
(
pTq
->
pVnode
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vgId:%d, tq try
get
suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
tqDebug
(
"vgId:%d, tq try
to get all ctb,
suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
tqDebug
(
"vgId:%d, idx %d, uid:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
i
,
tbUid
);
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
ad9c3cbd
...
...
@@ -40,8 +40,8 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
-
1
,
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
retentionSize
=
-
1
,
.
level
=
TAOS_WAL_WRITE
,
},
...
...
source/libs/wal/src/walMgmt.c
浏览文件 @
ad9c3cbd
...
...
@@ -101,8 +101,8 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
// open meta
walResetVer
(
&
pWal
->
vers
);
pWal
->
p
WriteLogT
File
=
NULL
;
pWal
->
p
WriteIdxT
File
=
NULL
;
pWal
->
p
Log
File
=
NULL
;
pWal
->
p
Idx
File
=
NULL
;
pWal
->
writeCur
=
-
1
;
pWal
->
fileInfoSet
=
taosArrayInit
(
8
,
sizeof
(
SWalFileInfo
));
if
(
pWal
->
fileInfoSet
==
NULL
)
{
...
...
@@ -179,10 +179,10 @@ int32_t walAlter(SWal *pWal, SWalCfg *pCfg) {
void
walClose
(
SWal
*
pWal
)
{
taosThreadMutexLock
(
&
pWal
->
mutex
);
taosCloseFile
(
&
pWal
->
p
WriteLogT
File
);
pWal
->
p
WriteLogT
File
=
NULL
;
taosCloseFile
(
&
pWal
->
p
WriteIdxT
File
);
pWal
->
p
WriteIdxT
File
=
NULL
;
taosCloseFile
(
&
pWal
->
p
Log
File
);
pWal
->
p
Log
File
=
NULL
;
taosCloseFile
(
&
pWal
->
p
Idx
File
);
pWal
->
p
Idx
File
=
NULL
;
walSaveMeta
(
pWal
);
taosArrayDestroy
(
pWal
->
fileInfoSet
);
pWal
->
fileInfoSet
=
NULL
;
...
...
@@ -223,7 +223,7 @@ static void walFsyncAll() {
if
(
walNeedFsync
(
pWal
))
{
wTrace
(
"vgId:%d, do fsync, level:%d seq:%d rseq:%d"
,
pWal
->
cfg
.
vgId
,
pWal
->
cfg
.
level
,
pWal
->
fsyncSeq
,
atomic_load_32
(
&
tsWal
.
seq
));
int32_t
code
=
taosFsyncFile
(
pWal
->
p
WriteLogT
File
);
int32_t
code
=
taosFsyncFile
(
pWal
->
p
Log
File
);
if
(
code
!=
0
)
{
wError
(
"vgId:%d, file:%"
PRId64
".log, failed to fsync since %s"
,
pWal
->
cfg
.
vgId
,
walGetLastFileFirstVer
(
pWal
),
strerror
(
code
));
...
...
source/libs/wal/src/walSeek.c
浏览文件 @
ad9c3cbd
...
...
@@ -22,8 +22,8 @@
static
int64_t
walSeekWritePos
(
SWal
*
pWal
,
int64_t
ver
)
{
int64_t
code
=
0
;
TdFilePtr
pIdxTFile
=
pWal
->
p
WriteIdxT
File
;
TdFilePtr
pLogTFile
=
pWal
->
p
WriteLogT
File
;
TdFilePtr
pIdxTFile
=
pWal
->
p
Idx
File
;
TdFilePtr
pLogTFile
=
pWal
->
p
Log
File
;
// seek position
int64_t
idxOff
=
walGetVerIdxOffset
(
pWal
,
ver
);
...
...
@@ -68,8 +68,8 @@ int walInitWriteFile(SWal* pWal) {
return
-
1
;
}
// switch file
pWal
->
p
WriteIdxT
File
=
pIdxTFile
;
pWal
->
p
WriteLogT
File
=
pLogTFile
;
pWal
->
p
Idx
File
=
pIdxTFile
;
pWal
->
p
Log
File
=
pLogTFile
;
pWal
->
writeCur
=
taosArrayGetSize
(
pWal
->
fileInfoSet
)
-
1
;
return
0
;
}
...
...
@@ -78,15 +78,15 @@ int walChangeWrite(SWal* pWal, int64_t ver) {
int
code
;
TdFilePtr
pIdxTFile
,
pLogTFile
;
char
fnameStr
[
WAL_FILE_LEN
];
if
(
pWal
->
p
WriteLogT
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
WriteLogT
File
);
if
(
pWal
->
p
Log
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
Log
File
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
if
(
pWal
->
p
WriteIdxT
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
WriteIdxT
File
);
if
(
pWal
->
p
Idx
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
Idx
File
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -106,7 +106,7 @@ int walChangeWrite(SWal* pWal, int64_t ver) {
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
pWal
->
p
WriteIdxT
File
=
NULL
;
pWal
->
p
Idx
File
=
NULL
;
return
-
1
;
}
walBuildLogName
(
pWal
,
fileFirstVer
,
fnameStr
);
...
...
@@ -114,12 +114,12 @@ int walChangeWrite(SWal* pWal, int64_t ver) {
if
(
pLogTFile
==
NULL
)
{
taosCloseFile
(
&
pIdxTFile
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
pWal
->
p
WriteLogT
File
=
NULL
;
pWal
->
p
Log
File
=
NULL
;
return
-
1
;
}
pWal
->
p
WriteLogT
File
=
pLogTFile
;
pWal
->
p
WriteIdxT
File
=
pIdxTFile
;
pWal
->
p
Log
File
=
pLogTFile
;
pWal
->
p
Idx
File
=
pIdxTFile
;
pWal
->
writeCur
=
idx
;
return
fileFirstVer
;
}
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
ad9c3cbd
...
...
@@ -32,8 +32,8 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
}
}
taosCloseFile
(
&
pWal
->
p
WriteLogT
File
);
taosCloseFile
(
&
pWal
->
p
WriteIdxT
File
);
taosCloseFile
(
&
pWal
->
p
Log
File
);
taosCloseFile
(
&
pWal
->
p
Idx
File
);
if
(
pWal
->
vers
.
firstVer
!=
-
1
)
{
int32_t
fileSetSize
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
...
...
@@ -261,14 +261,13 @@ int32_t walEndSnapshot(SWal *pWal) {
pWal
->
vers
.
snapshotVer
=
ver
;
int
ts
=
taosGetTimestampSec
();
int64_t
minVerToDelete
=
ver
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pWal
->
pRefHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SWalRef
*
pRef
=
*
(
SWalRef
**
)
pIter
;
if
(
pRef
->
refVer
==
-
1
)
continue
;
minVerToDelete
=
TMIN
(
minVerToDelete
,
pRef
->
refVer
);
ver
=
TMIN
(
ver
,
pRef
->
refVer
);
}
int
deleteCnt
=
0
;
...
...
@@ -277,35 +276,37 @@ int32_t walEndSnapshot(SWal *pWal) {
tmp
.
firstVer
=
ver
;
// find files safe to delete
SWalFileInfo
*
pInfo
=
taosArraySearch
(
pWal
->
fileInfoSet
,
&
tmp
,
compareWalFileInfo
,
TD_LE
);
if
(
ver
>=
pInfo
->
lastVer
)
{
pInfo
++
;
}
// iterate files, until the searched result
for
(
SWalFileInfo
*
iter
=
pWal
->
fileInfoSet
->
pData
;
iter
<
pInfo
;
iter
++
)
{
if
((
pWal
->
cfg
.
retentionSize
!=
-
1
&&
newTotSize
>
pWal
->
cfg
.
retentionSize
)
||
(
pWal
->
cfg
.
retentionPeriod
!=
-
1
&&
iter
->
closeTs
+
pWal
->
cfg
.
retentionPeriod
>
ts
))
{
// delete according to file size or close time
deleteCnt
++
;
newTotSize
-=
iter
->
fileSize
;
if
(
pInfo
)
{
if
(
ver
>=
pInfo
->
lastVer
)
{
pInfo
++
;
}
// iterate files, until the searched result
for
(
SWalFileInfo
*
iter
=
pWal
->
fileInfoSet
->
pData
;
iter
<
pInfo
;
iter
++
)
{
if
((
pWal
->
cfg
.
retentionSize
!=
-
1
&&
newTotSize
>
pWal
->
cfg
.
retentionSize
)
||
(
pWal
->
cfg
.
retentionPeriod
!=
-
1
&&
iter
->
closeTs
+
pWal
->
cfg
.
retentionPeriod
>
ts
))
{
// delete according to file size or close time
deleteCnt
++
;
newTotSize
-=
iter
->
fileSize
;
}
}
char
fnameStr
[
WAL_FILE_LEN
];
// remove file
for
(
int
i
=
0
;
i
<
deleteCnt
;
i
++
)
{
pInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
i
);
walBuildLogName
(
pWal
,
pInfo
->
firstVer
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
walBuildIdxName
(
pWal
,
pInfo
->
firstVer
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
}
}
char
fnameStr
[
WAL_FILE_LEN
];
// remove file
for
(
int
i
=
0
;
i
<
deleteCnt
;
i
++
)
{
pInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
i
);
walBuildLogName
(
pWal
,
pInfo
->
firstVer
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
walBuildIdxName
(
pWal
,
pInfo
->
firstVer
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
}
// make new array, remove files
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
deleteCnt
);
if
(
taosArrayGetSize
(
pWal
->
fileInfoSet
)
==
0
)
{
pWal
->
writeCur
=
-
1
;
pWal
->
vers
.
firstVer
=
-
1
;
}
else
{
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
// make new array, remove files
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
deleteCnt
);
if
(
taosArrayGetSize
(
pWal
->
fileInfoSet
)
==
0
)
{
pWal
->
writeCur
=
-
1
;
pWal
->
vers
.
firstVer
=
-
1
;
}
else
{
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
}
}
pWal
->
writeCur
=
taosArrayGetSize
(
pWal
->
fileInfoSet
)
-
1
;
pWal
->
totSize
=
newTotSize
;
...
...
@@ -324,34 +325,34 @@ END:
int32_t
walRollImpl
(
SWal
*
pWal
)
{
int32_t
code
=
0
;
if
(
pWal
->
p
WriteIdxT
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
WriteIdxT
File
);
if
(
pWal
->
p
Idx
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
Idx
File
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
END
;
}
}
if
(
pWal
->
p
WriteLogT
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
WriteLogT
File
);
if
(
pWal
->
p
Log
File
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
p
Log
File
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
END
;
}
}
TdFilePtr
pIdx
TFile
,
pLogT
File
;
TdFilePtr
pIdx
File
,
pLog
File
;
// create new file
int64_t
newFileFirstVer
sion
=
pWal
->
vers
.
lastVer
+
1
;
int64_t
newFileFirstVer
=
pWal
->
vers
.
lastVer
+
1
;
char
fnameStr
[
WAL_FILE_LEN
];
walBuildIdxName
(
pWal
,
newFileFirstVer
sion
,
fnameStr
);
pIdx
T
File
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdx
T
File
==
NULL
)
{
walBuildIdxName
(
pWal
,
newFileFirstVer
,
fnameStr
);
pIdxFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
-
1
;
goto
END
;
}
walBuildLogName
(
pWal
,
newFileFirstVer
sion
,
fnameStr
);
pLog
T
File
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLog
T
File
==
NULL
)
{
walBuildLogName
(
pWal
,
newFileFirstVer
,
fnameStr
);
pLogFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLogFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
-
1
;
goto
END
;
...
...
@@ -363,8 +364,8 @@ int32_t walRollImpl(SWal *pWal) {
}
// switch file
pWal
->
p
WriteIdxTFile
=
pIdxT
File
;
pWal
->
p
WriteLogTFile
=
pLogT
File
;
pWal
->
p
IdxFile
=
pIdx
File
;
pWal
->
p
LogFile
=
pLog
File
;
pWal
->
writeCur
=
taosArrayGetSize
(
pWal
->
fileInfoSet
)
-
1
;
ASSERT
(
pWal
->
writeCur
>=
0
);
...
...
@@ -378,10 +379,10 @@ END:
static
int32_t
walWriteIndex
(
SWal
*
pWal
,
int64_t
ver
,
int64_t
offset
)
{
SWalIdxEntry
entry
=
{.
ver
=
ver
,
.
offset
=
offset
};
int64_t
idxOffset
=
taosLSeekFile
(
pWal
->
p
WriteIdxT
File
,
0
,
SEEK_END
);
int64_t
idxOffset
=
taosLSeekFile
(
pWal
->
p
Idx
File
,
0
,
SEEK_END
);
wDebug
(
"vgId:%d, write index, index:%"
PRId64
", offset:%"
PRId64
", at %"
PRId64
,
pWal
->
cfg
.
vgId
,
ver
,
offset
,
idxOffset
);
int64_t
size
=
taosWriteFile
(
pWal
->
p
WriteIdxT
File
,
&
entry
,
sizeof
(
SWalIdxEntry
));
int64_t
size
=
taosWriteFile
(
pWal
->
p
Idx
File
,
&
entry
,
sizeof
(
SWalIdxEntry
));
if
(
size
!=
sizeof
(
SWalIdxEntry
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
// TODO truncate
...
...
@@ -407,7 +408,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
pWal
->
writeHead
.
cksumHead
=
walCalcHeadCksum
(
&
pWal
->
writeHead
);
pWal
->
writeHead
.
cksumBody
=
walCalcBodyCksum
(
body
,
bodyLen
);
if
(
taosWriteFile
(
pWal
->
p
WriteLogT
File
,
&
pWal
->
writeHead
,
sizeof
(
SWalCkHead
))
!=
sizeof
(
SWalCkHead
))
{
if
(
taosWriteFile
(
pWal
->
p
Log
File
,
&
pWal
->
writeHead
,
sizeof
(
SWalCkHead
))
!=
sizeof
(
SWalCkHead
))
{
// TODO ftruncate
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%"
PRId64
".log, failed to write since %s"
,
pWal
->
cfg
.
vgId
,
walGetLastFileFirstVer
(
pWal
),
...
...
@@ -416,7 +417,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
goto
END
;
}
if
(
taosWriteFile
(
pWal
->
p
WriteLogT
File
,
(
char
*
)
body
,
bodyLen
)
!=
bodyLen
)
{
if
(
taosWriteFile
(
pWal
->
p
Log
File
,
(
char
*
)
body
,
bodyLen
)
!=
bodyLen
)
{
// TODO ftruncate
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%"
PRId64
".log, failed to write since %s"
,
pWal
->
cfg
.
vgId
,
walGetLastFileFirstVer
(
pWal
),
...
...
@@ -456,14 +457,14 @@ int64_t walAppendLog(SWal *pWal, tmsg_t msgType, SWalSyncInfo syncMeta, const vo
return
-
1
;
}
if
(
pWal
->
p
WriteIdxTFile
==
NULL
||
pWal
->
pWriteIdxT
File
==
NULL
||
pWal
->
writeCur
<
0
)
{
if
(
pWal
->
p
IdxFile
==
NULL
||
pWal
->
pIdx
File
==
NULL
||
pWal
->
writeCur
<
0
)
{
if
(
walInitWriteFile
(
pWal
)
<
0
)
{
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
}
}
ASSERT
(
pWal
->
p
WriteIdxTFile
!=
NULL
&&
pWal
->
pWriteLogT
File
!=
NULL
&&
pWal
->
writeCur
>=
0
);
ASSERT
(
pWal
->
p
IdxFile
!=
NULL
&&
pWal
->
pLog
File
!=
NULL
&&
pWal
->
writeCur
>=
0
);
if
(
walWriteImpl
(
pWal
,
index
,
msgType
,
syncMeta
,
body
,
bodyLen
)
<
0
)
{
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
...
...
@@ -494,14 +495,14 @@ int32_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SWalSync
return
-
1
;
}
if
(
pWal
->
p
WriteIdxTFile
==
NULL
||
pWal
->
pWriteIdxT
File
==
NULL
||
pWal
->
writeCur
<
0
)
{
if
(
pWal
->
p
IdxFile
==
NULL
||
pWal
->
pIdx
File
==
NULL
||
pWal
->
writeCur
<
0
)
{
if
(
walInitWriteFile
(
pWal
)
<
0
)
{
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
}
}
ASSERT
(
pWal
->
p
WriteIdxTFile
!=
NULL
&&
pWal
->
pWriteLogT
File
!=
NULL
&&
pWal
->
writeCur
>=
0
);
ASSERT
(
pWal
->
p
IdxFile
!=
NULL
&&
pWal
->
pLog
File
!=
NULL
&&
pWal
->
writeCur
>=
0
);
if
(
walWriteImpl
(
pWal
,
index
,
msgType
,
syncMeta
,
body
,
bodyLen
)
<
0
)
{
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
...
...
@@ -524,7 +525,7 @@ int32_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, in
void
walFsync
(
SWal
*
pWal
,
bool
forceFsync
)
{
if
(
forceFsync
||
(
pWal
->
cfg
.
level
==
TAOS_WAL_FSYNC
&&
pWal
->
cfg
.
fsyncPeriod
==
0
))
{
wTrace
(
"vgId:%d, fileId:%"
PRId64
".log, do fsync"
,
pWal
->
cfg
.
vgId
,
walGetCurFileFirstVer
(
pWal
));
if
(
taosFsyncFile
(
pWal
->
p
WriteLogT
File
)
<
0
)
{
if
(
taosFsyncFile
(
pWal
->
p
Log
File
)
<
0
)
{
wError
(
"vgId:%d, file:%"
PRId64
".log, fsync failed since %s"
,
pWal
->
cfg
.
vgId
,
walGetCurFileFirstVer
(
pWal
),
strerror
(
errno
));
}
...
...
tests/system-test/7-tmq/db.py
浏览文件 @
ad9c3cbd
...
...
@@ -118,7 +118,7 @@ class TDTestCase:
if
dropFlag
==
1
:
tsql
.
execute
(
"drop database if exists %s"
%
(
dbName
))
tsql
.
execute
(
"create database if not exists %s vgroups %d replica %d"
%
(
dbName
,
vgroups
,
replica
))
tsql
.
execute
(
"create database if not exists %s vgroups %d replica %d
wal_retention_period -1 wal_retention_size -1
"
%
(
dbName
,
vgroups
,
replica
))
tdLog
.
debug
(
"complete to create database %s"
%
(
dbName
))
return
...
...
tests/system-test/7-tmq/tmqDelete-1ctb.py
浏览文件 @
ad9c3cbd
...
...
@@ -52,7 +52,7 @@ class TDTestCase:
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
)
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
,
wal_retention_size
=-
1
,
wal_retention_period
=-
1
)
tdLog
.
info
(
"create stb"
)
tmqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
...
...
tests/system-test/7-tmq/tmqDelete-multiCtb.py
浏览文件 @
ad9c3cbd
...
...
@@ -52,7 +52,7 @@ class TDTestCase:
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
)
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
,
wal_retention_size
=-
1
,
wal_retention_period
=-
1
)
tdLog
.
info
(
"create stb"
)
tmqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
...
...
tests/system-test/7-tmq/tmqDnodeRestart.py
浏览文件 @
ad9c3cbd
...
...
@@ -53,7 +53,7 @@ class TDTestCase:
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
)
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
,
wal_retention_size
=-
1
,
wal_retention_period
=-
1
)
tdLog
.
info
(
"create stb"
)
tmqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
...
...
tests/system-test/7-tmq/tmqUpdateWithConsume.py
浏览文件 @
ad9c3cbd
...
...
@@ -52,7 +52,7 @@ class TDTestCase:
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
)
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
,
wal_retention_size
=-
1
,
wal_retention_period
=-
1
)
tdLog
.
info
(
"create stb"
)
tmqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录