Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
71097ea5
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71097ea5
编写于
3月 26, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
put schema into stream
上级
96eb6a9b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
72 addition
and
42 deletion
+72
-42
example/src/tstream.c
example/src/tstream.c
+1
-1
include/common/tcommon.h
include/common/tcommon.h
+2
-2
include/common/tmsg.h
include/common/tmsg.h
+23
-2
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+6
-6
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+9
-1
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+6
-8
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+18
-19
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+5
-3
未找到文件。
example/src/tstream.c
浏览文件 @
71097ea5
...
@@ -25,7 +25,7 @@ int32_t init_env() {
...
@@ -25,7 +25,7 @@ int32_t init_env() {
return
-
1
;
return
-
1
;
}
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
2
"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
1
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
...
include/common/tcommon.h
浏览文件 @
71097ea5
...
@@ -127,7 +127,7 @@ static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp
...
@@ -127,7 +127,7 @@ static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
skipLogNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
skipLogNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
numOfTopics
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
numOfTopics
);
if
(
pRsp
->
numOfTopics
==
0
)
return
tlen
;
if
(
pRsp
->
numOfTopics
==
0
)
return
tlen
;
tlen
+=
tEncodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
tlen
+=
t
aos
EncodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
if
(
pRsp
->
pBlockData
)
{
if
(
pRsp
->
pBlockData
)
{
sz
=
taosArrayGetSize
(
pRsp
->
pBlockData
);
sz
=
taosArrayGetSize
(
pRsp
->
pBlockData
);
}
}
...
@@ -149,7 +149,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
...
@@ -149,7 +149,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
if
(
pRsp
->
numOfTopics
==
0
)
return
buf
;
if
(
pRsp
->
numOfTopics
==
0
)
return
buf
;
pRsp
->
schema
=
(
SSchemaWrapper
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
pRsp
->
schema
=
(
SSchemaWrapper
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pRsp
->
schema
==
NULL
)
return
NULL
;
if
(
pRsp
->
schema
==
NULL
)
return
NULL
;
buf
=
tDecodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
buf
=
t
aos
DecodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pRsp
->
pBlockData
=
taosArrayInit
(
sz
,
sizeof
(
SSDataBlock
));
pRsp
->
pBlockData
=
taosArrayInit
(
sz
,
sizeof
(
SSDataBlock
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
...
...
include/common/tmsg.h
浏览文件 @
71097ea5
...
@@ -1931,7 +1931,7 @@ static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
...
@@ -1931,7 +1931,7 @@ static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
void
**
buf
,
const
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
int32_t
t
aos
EncodeSSchemaWrapper
(
void
**
buf
,
const
SSchemaWrapper
*
pSW
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
...
@@ -1940,7 +1940,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
...
@@ -1940,7 +1940,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
tDecodeSSchemaWrapper
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
*
t
aos
DecodeSSchemaWrapper
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
if
(
pSW
->
pSchema
==
NULL
)
{
if
(
pSW
->
pSchema
==
NULL
)
{
...
@@ -1953,6 +1953,27 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
...
@@ -1953,6 +1953,27 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
return
buf
;
return
buf
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
SCoder
*
pEncoder
,
const
SSchemaWrapper
*
pSW
)
{
if
(
tEncodeU32
(
pEncoder
,
pSW
->
nCols
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
if
(
tEncodeSSchema
(
pEncoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
}
return
pEncoder
->
pos
;
}
static
FORCE_INLINE
int32_t
tDecodeSSchemaWrapper
(
SCoder
*
pDecoder
,
SSchemaWrapper
*
pSW
)
{
if
(
tDecodeU32
(
pDecoder
,
&
pSW
->
nCols
)
<
0
)
return
-
1
;
void
*
ptr
=
taosMemoryRealloc
(
pSW
->
pSchema
,
pSW
->
nCols
*
sizeof
(
SSchema
));
if
(
ptr
==
NULL
)
{
return
-
1
;
}
pSW
->
pSchema
=
(
SSchema
*
)
ptr
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
if
(
tDecodeSSchema
(
pDecoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
}
return
0
;
}
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
...
...
include/util/taoserror.h
浏览文件 @
71097ea5
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_UTIL_TAOS_ERROR_H_
#ifndef _TD_UTIL_TAOS_ERROR_H_
#define _TD_UTIL_TAOS_ERROR_H_
#define _TD_UTIL_TAOS_ERROR_H_
#include "os.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
71097ea5
...
@@ -733,12 +733,12 @@ typedef struct {
...
@@ -733,12 +733,12 @@ typedef struct {
int8_t
sourceType
;
int8_t
sourceType
;
int8_t
sinkType
;
int8_t
sinkType
;
// int32_t sqlLen;
// int32_t sqlLen;
int32_t
sinkVgId
;
// 0 for automatic
int32_t
sinkVgId
;
// 0 for automatic
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
S
Array
*
ColAlias
;
// SArray<char*>
S
SchemaWrapper
outputSchema
;
}
SStreamObj
;
}
SStreamObj
;
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
71097ea5
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
sz
=
0
;
int32_t
sz
=
0
;
int32_t
outputNameSz
=
0
;
/*int32_t outputNameSz = 0;*/
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
...
@@ -45,6 +45,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -45,6 +45,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
}
}
}
}
if
(
tEncodeSSchemaWrapper
(
pEncoder
,
&
pObj
->
outputSchema
)
<
0
)
return
-
1
;
#if 0
if (pObj->ColAlias != NULL) {
if (pObj->ColAlias != NULL) {
outputNameSz = taosArrayGetSize(pObj->ColAlias);
outputNameSz = taosArrayGetSize(pObj->ColAlias);
}
}
...
@@ -53,6 +56,7 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -53,6 +56,7 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
char *name = taosArrayGetP(pObj->ColAlias, i);
char *name = taosArrayGetP(pObj->ColAlias, i);
if (tEncodeCStr(pEncoder, name) < 0) return -1;
if (tEncodeCStr(pEncoder, name) < 0) return -1;
}
}
#endif
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
}
}
...
@@ -85,6 +89,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -85,6 +89,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
taosArrayPush
(
pObj
->
tasks
,
pArray
);
taosArrayPush
(
pObj
->
tasks
,
pArray
);
}
}
}
}
if
(
tDecodeSSchemaWrapper
(
pDecoder
,
&
pObj
->
outputSchema
)
<
0
)
return
-
1
;
#if 0
int32_t outputNameSz;
int32_t outputNameSz;
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
if (outputNameSz != 0) {
if (outputNameSz != 0) {
...
@@ -98,5 +105,6 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -98,5 +105,6 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
taosArrayPush(pObj->ColAlias, &name);
taosArrayPush(pObj->ColAlias, &name);
}
}
#endif
return
0
;
return
0
;
}
}
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
71097ea5
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#include "mndStream.h"
#include "mndStream.h"
#include "parser.h"
#include "mndAuth.h"
#include "mndAuth.h"
#include "mndDb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndDnode.h"
...
@@ -26,6 +25,7 @@
...
@@ -26,6 +25,7 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "parser.h"
#include "tname.h"
#include "tname.h"
#define MND_STREAM_VER_NUMBER 1
#define MND_STREAM_VER_NUMBER 1
...
@@ -248,23 +248,21 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
...
@@ -248,23 +248,21 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
#if 1 // TODO: remove debug info later
#if 1
// TODO: remove debug info later
printf
(
"ast = %s
\n
"
,
ast
);
printf
(
"ast = %s
\n
"
,
ast
);
#endif
#endif
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
#if 1
#if 1
SSchemaWrapper
sw
=
{
0
};
qExtractResultSchema
(
pAst
,
(
int32_t
*
)
&
pStream
->
outputSchema
.
nCols
,
&
pStream
->
outputSchema
.
pSchema
);
qExtractResultSchema
(
pAst
,
(
int32_t
*
)
&
sw
.
nCols
,
&
sw
.
pSchema
);
printf
(
"|"
);
printf
(
"|"
);
for
(
int
i
=
0
;
i
<
sw
.
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pStream
->
outputSchema
.
nCols
;
i
++
)
{
printf
(
" %15s |"
,
(
char
*
)
sw
.
pSchema
[
i
].
name
);
printf
(
" %15s |"
,
(
char
*
)
pStream
->
outputSchema
.
pSchema
[
i
].
name
);
}
}
printf
(
"
\n
=======================================================
\n
"
);
printf
(
"
\n
=======================================================
\n
"
);
pStream
->
ColAlias
=
NULL
;
#endif
#endif
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
71097ea5
...
@@ -37,8 +37,7 @@ void* tmemmem(char* haystack, int hlen, char* needle, int nlen) {
...
@@ -37,8 +37,7 @@ void* tmemmem(char* haystack, int hlen, char* needle, int nlen) {
}
}
limit
=
haystack
+
hlen
-
nlen
+
1
;
limit
=
haystack
+
hlen
-
nlen
+
1
;
while
((
haystack
=
(
char
*
)
memchr
(
while
((
haystack
=
(
char
*
)
memchr
(
haystack
,
needle
[
0
],
limit
-
haystack
))
!=
NULL
)
{
haystack
,
needle
[
0
],
limit
-
haystack
))
!=
NULL
)
{
if
(
memcmp
(
haystack
,
needle
,
nlen
)
==
0
)
{
if
(
memcmp
(
haystack
,
needle
,
nlen
)
==
0
)
{
return
haystack
;
return
haystack
;
}
}
...
@@ -57,8 +56,8 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
...
@@ -57,8 +56,8 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
}
}
#endif
#endif
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
sz
-
1
);
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
sz
-
1
);
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
int64_t
file_size
=
0
;
int64_t
file_size
=
0
;
...
@@ -88,20 +87,20 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
...
@@ -88,20 +87,20 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
char
*
haystack
=
buf
;
char
*
haystack
=
buf
;
char
*
found
=
NULL
;
char
*
found
=
NULL
;
char
*
candidate
;
char
*
candidate
;
while
((
candidate
=
tmemmem
(
haystack
,
readSize
-
(
haystack
-
buf
),
(
char
*
)
&
magic
,
sizeof
(
uint64_t
)))
!=
NULL
)
{
while
((
candidate
=
tmemmem
(
haystack
,
readSize
-
(
haystack
-
buf
),
(
char
*
)
&
magic
,
sizeof
(
uint64_t
)))
!=
NULL
)
{
// read and validate
// read and validate
SWalHead
*
logContent
=
(
SWalHead
*
)
candidate
;
SWalHead
*
logContent
=
(
SWalHead
*
)
candidate
;
if
(
walValidHeadCksum
(
logContent
)
==
0
&&
walValidBodyCksum
(
logContent
)
==
0
)
{
if
(
walValidHeadCksum
(
logContent
)
==
0
&&
walValidBodyCksum
(
logContent
)
==
0
)
{
found
=
candidate
;
found
=
candidate
;
}
}
haystack
=
candidate
+
1
;
haystack
=
candidate
+
1
;
}
}
if
(
found
==
buf
)
{
if
(
found
==
buf
)
{
SWalHead
*
logContent
=
(
SWalHead
*
)
found
;
SWalHead
*
logContent
=
(
SWalHead
*
)
found
;
if
(
walValidHeadCksum
(
logContent
)
!=
0
||
walValidBodyCksum
(
logContent
)
!=
0
)
{
if
(
walValidHeadCksum
(
logContent
)
!=
0
||
walValidBodyCksum
(
logContent
)
!=
0
)
{
// file has to be deleted
// file has to be deleted
taosMemoryFree
(
buf
);
taosMemoryFree
(
buf
);
...
@@ -111,7 +110,7 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
...
@@ -111,7 +110,7 @@ static inline int64_t walScanLogGetLastVer(SWal* pWal) {
}
}
}
}
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
SWalHead
*
lastEntry
=
(
SWalHead
*
)
found
;
SWalHead
*
lastEntry
=
(
SWalHead
*
)
found
;
return
lastEntry
->
head
.
version
;
return
lastEntry
->
head
.
version
;
}
}
...
@@ -158,10 +157,10 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -158,10 +157,10 @@ int walCheckAndRepairMeta(SWal* pWal) {
int
newSz
=
taosArrayGetSize
(
pLogInfoArray
);
int
newSz
=
taosArrayGetSize
(
pLogInfoArray
);
if
(
oldSz
>
newSz
)
{
if
(
oldSz
>
newSz
)
{
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
oldSz
-
newSz
);
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
oldSz
-
newSz
);
}
else
if
(
oldSz
<
newSz
)
{
}
else
if
(
oldSz
<
newSz
)
{
for
(
int
i
=
oldSz
;
i
<
newSz
;
i
++
)
{
for
(
int
i
=
oldSz
;
i
<
newSz
;
i
++
)
{
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pLogInfoArray
,
i
);
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pLogInfoArray
,
i
);
taosArrayPush
(
pWal
->
fileInfoSet
,
pFileInfo
);
taosArrayPush
(
pWal
->
fileInfoSet
,
pFileInfo
);
}
}
}
}
...
@@ -171,8 +170,8 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -171,8 +170,8 @@ int walCheckAndRepairMeta(SWal* pWal) {
if
(
newSz
>
0
)
{
if
(
newSz
>
0
)
{
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
int64_t
file_size
=
0
;
int64_t
file_size
=
0
;
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
taosStatFile
(
fnameStr
,
&
file_size
,
NULL
);
...
@@ -191,8 +190,8 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -191,8 +190,8 @@ int walCheckAndRepairMeta(SWal* pWal) {
}
}
}
}
//TODO: set fileSize and lastVer if necessary
//
TODO: set fileSize and lastVer if necessary
return
0
;
return
0
;
}
}
...
@@ -239,13 +238,13 @@ char* walMetaSerialize(SWal* pWal) {
...
@@ -239,13 +238,13 @@ char* walMetaSerialize(SWal* pWal) {
cJSON
*
pFiles
=
cJSON_CreateArray
();
cJSON
*
pFiles
=
cJSON_CreateArray
();
cJSON
*
pField
;
cJSON
*
pField
;
if
(
pRoot
==
NULL
||
pMeta
==
NULL
||
pFiles
==
NULL
)
{
if
(
pRoot
==
NULL
||
pMeta
==
NULL
||
pFiles
==
NULL
)
{
if
(
pRoot
)
{
if
(
pRoot
)
{
cJSON_Delete
(
pRoot
);
cJSON_Delete
(
pRoot
);
}
}
if
(
pMeta
)
{
if
(
pMeta
)
{
cJSON_Delete
(
pMeta
);
cJSON_Delete
(
pMeta
);
}
}
if
(
pFiles
)
{
if
(
pFiles
)
{
cJSON_Delete
(
pFiles
);
cJSON_Delete
(
pFiles
);
}
}
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
...
...
source/libs/wal/src/walRead.c
浏览文件 @
71097ea5
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "walInt.h"
#include "taoserror.h"
#include "taoserror.h"
#include "walInt.h"
SWalReadHandle
*
walOpenReadHandle
(
SWal
*
pWal
)
{
SWalReadHandle
*
walOpenReadHandle
(
SWal
*
pWal
)
{
SWalReadHandle
*
pRead
=
taosMemoryMalloc
(
sizeof
(
SWalReadHandle
));
SWalReadHandle
*
pRead
=
taosMemoryMalloc
(
sizeof
(
SWalReadHandle
));
...
@@ -92,6 +92,7 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) {
...
@@ -92,6 +92,7 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) {
walBuildIdxName
(
pRead
->
pWal
,
fileFirstVer
,
fnameStr
);
walBuildIdxName
(
pRead
->
pWal
,
fileFirstVer
,
fnameStr
);
TdFilePtr
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
TdFilePtr
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
if
(
pIdxTFile
==
NULL
)
{
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
...
@@ -169,7 +170,8 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
...
@@ -169,7 +170,8 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
}
}
if
(
pRead
->
pHead
->
head
.
version
!=
ver
)
{
if
(
pRead
->
pHead
->
head
.
version
!=
ver
)
{
wError
(
"unexpected wal log version: %"
PRId64
", read request version:%"
PRId64
""
,
pRead
->
pHead
->
head
.
version
,
ver
);
wError
(
"unexpected wal log version: %"
PRId64
", read request version:%"
PRId64
""
,
pRead
->
pHead
->
head
.
version
,
ver
);
pRead
->
curVersion
=
-
1
;
pRead
->
curVersion
=
-
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
-
1
;
return
-
1
;
...
@@ -177,7 +179,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
...
@@ -177,7 +179,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
code
=
walValidBodyCksum
(
pRead
->
pHead
);
code
=
walValidBodyCksum
(
pRead
->
pHead
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
wError
(
"unexpected wal log version:
checksum not passed"
);
wError
(
"unexpected wal log version:
% "
PRId64
"checksum not passed"
,
ver
);
pRead
->
curVersion
=
-
1
;
pRead
->
curVersion
=
-
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
-
1
;
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录