Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a0c8360
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
8a0c8360
编写于
11月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into fix/TD-20317
上级
2f0dad7b
344395b0
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
304 addition
and
137 deletion
+304
-137
cmake/taosadapter_CMakeLists.txt.in
cmake/taosadapter_CMakeLists.txt.in
+1
-1
include/common/systable.h
include/common/systable.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-3
packaging/release.bat
packaging/release.bat
+1
-1
packaging/tools/tdengine.iss
packaging/tools/tdengine.iss
+10
-0
source/common/src/systable.c
source/common/src/systable.c
+11
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+3
-1
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-0
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+107
-1
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+6
-11
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+28
-21
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+10
-10
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+16
-0
source/libs/executor/src/tsimplehash.c
source/libs/executor/src/tsimplehash.c
+5
-3
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+7
-7
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+10
-8
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+0
-37
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+10
-10
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+23
-2
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+19
-5
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+8
-7
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+4
-2
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+1
-0
source/util/src/tconfig.c
source/util/src/tconfig.c
+4
-1
tools/CMakeLists.txt
tools/CMakeLists.txt
+12
-3
未找到文件。
cmake/taosadapter_CMakeLists.txt.in
浏览文件 @
8a0c8360
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# taosadapter
# taosadapter
ExternalProject_Add(taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
GIT_TAG
0d5663d
GIT_TAG
ff7de07
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
#BUILD_IN_SOURCE TRUE
...
...
include/common/systable.h
浏览文件 @
8a0c8360
...
@@ -46,6 +46,7 @@ extern "C" {
...
@@ -46,6 +46,7 @@ extern "C" {
#define TSDB_INS_TABLE_SUBSCRIPTIONS "ins_subscriptions"
#define TSDB_INS_TABLE_SUBSCRIPTIONS "ins_subscriptions"
#define TSDB_INS_TABLE_TOPICS "ins_topics"
#define TSDB_INS_TABLE_TOPICS "ins_topics"
#define TSDB_INS_TABLE_STREAMS "ins_streams"
#define TSDB_INS_TABLE_STREAMS "ins_streams"
#define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
...
...
include/common/tmsg.h
浏览文件 @
8a0c8360
...
@@ -119,6 +119,7 @@ typedef enum _mgmt_table {
...
@@ -119,6 +119,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_APPS
,
TSDB_MGMT_TABLE_APPS
,
TSDB_MGMT_TABLE_STREAM_TASKS
,
TSDB_MGMT_TABLE_MAX
,
TSDB_MGMT_TABLE_MAX
,
}
EShowType
;
}
EShowType
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
8a0c8360
...
@@ -74,9 +74,8 @@ typedef struct SColumnNode {
...
@@ -74,9 +74,8 @@ typedef struct SColumnNode {
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
// SNode* pProjectRef;
int16_t
dataBlockId
;
int16_t
dataBlockId
;
int16_t
slotId
;
int16_t
slotId
;
}
SColumnNode
;
}
SColumnNode
;
typedef
struct
SColumnRefNode
{
typedef
struct
SColumnRefNode
{
...
...
packaging/release.bat
浏览文件 @
8a0c8360
...
@@ -39,7 +39,7 @@ if not exist %work_dir%\debug\ver-%2-x86 (
...
@@ -39,7 +39,7 @@ if not exist %work_dir%\debug\ver-%2-x86 (
md
%work_dir%
\debug\ver
-
%
2
-x
86
md
%work_dir%
\debug\ver
-
%
2
-x
86
)
)
cd
%work_dir%
\debug\ver
-
%
2
-x
64
cd
%work_dir%
\debug\ver
-
%
2
-x
64
rem #
call vcvarsall.bat x64
call
vcvarsall
.bat
x64
cmake
../../
-G
"NMake Makefiles JOM"
-DCMAKE
_MAKE_PROGRAM
=
jom
-DBUILD
_TOOLS
=
true
-DWEBSOCKET
=
true
-DBUILD
_HTTP
=
false
-DBUILD
_TEST
=
false
-DVERNUMBER
=
%
2
-DCPUTYPE
=
x64
cmake
../../
-G
"NMake Makefiles JOM"
-DCMAKE
_MAKE_PROGRAM
=
jom
-DBUILD
_TOOLS
=
true
-DWEBSOCKET
=
true
-DBUILD
_HTTP
=
false
-DBUILD
_TEST
=
false
-DVERNUMBER
=
%
2
-DCPUTYPE
=
x64
cmake
--build
.
cmake
--build
.
rd
/s /Q
C
:\TDengine
rd
/s /Q
C
:\TDengine
...
...
packaging/tools/tdengine.iss
浏览文件 @
8a0c8360
...
@@ -61,6 +61,16 @@ Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExc
...
@@ -61,6 +61,16 @@ Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExc
Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
[run]
Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\TDengine\\taosd.exe --win_service""" ; Flags: runhidden
Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe --win_service""" ; Flags: runhidden
[UninstallRun]
RunOnceId: "stoptaosd"; Filename: {sys}\sc.exe; Parameters: "stop taosd" ; Flags: runhidden
RunOnceId: "stoptaosadapter"; Filename: {sys}\sc.exe; Parameters: "stop taosadapter" ; Flags: runhidden
RunOnceId: "deltaosd"; Filename: {sys}\sc.exe; Parameters: "delete taosd" ; Flags: runhidden
RunOnceId: "deltaosadapter"; Filename: {sys}\sc.exe; Parameters: "delete taosadapter" ; Flags: runhidden
[Registry]
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\TDengine"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\TDengine"; \
...
...
source/common/src/systable.c
浏览文件 @
8a0c8360
...
@@ -134,7 +134,7 @@ static const SSysDbTableSchema userStbsSchema[] = {
...
@@ -134,7 +134,7 @@ static const SSysDbTableSchema userStbsSchema[] = {
};
};
static
const
SSysDbTableSchema
streamSchema
[]
=
{
static
const
SSysDbTableSchema
streamSchema
[]
=
{
{.
name
=
"stream_name"
,
.
bytes
=
SYSTABLE_SCH_
DB
_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"stream_name"
,
.
bytes
=
SYSTABLE_SCH_
TABLE
_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
sysInfo
=
false
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
sysInfo
=
false
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"status"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"status"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
...
@@ -145,6 +145,15 @@ static const SSysDbTableSchema streamSchema[] = {
...
@@ -145,6 +145,15 @@ static const SSysDbTableSchema streamSchema[] = {
{.
name
=
"trigger"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"trigger"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
};
static
const
SSysDbTableSchema
streamTaskSchema
[]
=
{
{.
name
=
"stream_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"task_id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"node_type"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"node_id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
{.
name
=
"level"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"status"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
static
const
SSysDbTableSchema
userTblsSchema
[]
=
{
static
const
SSysDbTableSchema
userTblsSchema
[]
=
{
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
...
@@ -287,6 +296,7 @@ static const SSysTableMeta infosMeta[] = {
...
@@ -287,6 +296,7 @@ static const SSysTableMeta infosMeta[] = {
{
TSDB_INS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
),
false
},
{
TSDB_INS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
),
false
},
{
TSDB_INS_TABLE_SUBSCRIPTIONS
,
subscriptionSchema
,
tListLen
(
subscriptionSchema
),
false
},
{
TSDB_INS_TABLE_SUBSCRIPTIONS
,
subscriptionSchema
,
tListLen
(
subscriptionSchema
),
false
},
{
TSDB_INS_TABLE_STREAMS
,
streamSchema
,
tListLen
(
streamSchema
),
false
},
{
TSDB_INS_TABLE_STREAMS
,
streamSchema
,
tListLen
(
streamSchema
),
false
},
{
TSDB_INS_TABLE_STREAM_TASKS
,
streamTaskSchema
,
tListLen
(
streamTaskSchema
),
false
},
{
TSDB_INS_TABLE_VNODES
,
vnodesSchema
,
tListLen
(
vnodesSchema
),
true
},
{
TSDB_INS_TABLE_VNODES
,
vnodesSchema
,
tListLen
(
vnodesSchema
),
true
},
};
};
...
...
source/common/src/tdatablock.c
浏览文件 @
8a0c8360
...
@@ -277,7 +277,9 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
...
@@ -277,7 +277,9 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
pColumnInfoData
->
varmeta
.
allocLen
=
len
+
oldLen
;
pColumnInfoData
->
varmeta
.
allocLen
=
len
+
oldLen
;
}
}
memcpy
(
pColumnInfoData
->
pData
+
oldLen
,
pSource
->
pData
,
len
);
if
(
pColumnInfoData
->
pData
&&
pSource
->
pData
)
{
// TD-20382
memcpy
(
pColumnInfoData
->
pData
+
oldLen
,
pSource
->
pData
,
len
);
}
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
}
else
{
}
else
{
if
(
finalNumOfRows
>
(
*
capacity
))
{
if
(
finalNumOfRows
>
(
*
capacity
))
{
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
8a0c8360
...
@@ -106,6 +106,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
...
@@ -106,6 +106,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type
=
TSDB_MGMT_TABLE_STREAMS
;
type
=
TSDB_MGMT_TABLE_STREAMS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_PERFS_TABLE_APPS
,
len
)
==
0
)
{
}
else
if
(
strncasecmp
(
name
,
TSDB_PERFS_TABLE_APPS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_APPS
;
type
=
TSDB_MGMT_TABLE_APPS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_STREAM_TASKS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_STREAM_TASKS
;
}
else
{
}
else
{
// ASSERT(0);
// ASSERT(0);
}
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
8a0c8360
...
@@ -41,6 +41,8 @@ static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
...
@@ -41,6 +41,8 @@ static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
static
int32_t
mndGetStreamMeta
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndGetStreamMeta
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveStream
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveStream
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStream
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextStream
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndRetrieveStreamTask
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStreamTask
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitStream
(
SMnode
*
pMnode
)
{
int32_t
mndInitStream
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
SSdbTable
table
=
{
...
@@ -62,6 +64,8 @@ int32_t mndInitStream(SMnode *pMnode) {
...
@@ -62,6 +64,8 @@ int32_t mndInitStream(SMnode *pMnode) {
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndRetrieveStream
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndRetrieveStream
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndCancelGetNextStream
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndCancelGetNextStream
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAM_TASKS
,
mndRetrieveStreamTask
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAM_TASKS
,
mndCancelGetNextStreamTask
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
}
...
@@ -891,7 +895,7 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -891,7 +895,7 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SName
n
;
SName
n
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
streamName
[
TSDB_
DB
_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
streamName
[
TSDB_
TABLE
_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
streamName
,
mndGetDbStr
(
pStream
->
name
),
sizeof
(
streamName
));
STR_WITH_MAXSIZE_TO_VARSTR
(
streamName
,
mndGetDbStr
(
pStream
->
name
),
sizeof
(
streamName
));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
streamName
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
streamName
,
false
);
...
@@ -953,3 +957,105 @@ static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
...
@@ -953,3 +957,105 @@ static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
}
}
static
int32_t
mndRetrieveStreamTask
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rowsCapacity
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SStreamObj
*
pStream
=
NULL
;
while
(
numOfRows
<
rowsCapacity
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STREAM
,
pShow
->
pIter
,
(
void
**
)
&
pStream
);
if
(
pShow
->
pIter
==
NULL
)
break
;
// lock
taosRLockLatch
(
&
pStream
->
lock
);
// count task num
int32_t
sz
=
taosArrayGetSize
(
pStream
->
tasks
);
int32_t
count
=
0
;
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
pLevel
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
count
+=
taosArrayGetSize
(
pLevel
);
}
if
(
numOfRows
+
count
>
rowsCapacity
)
{
blockDataEnsureCapacity
(
pBlock
,
numOfRows
+
count
);
}
// add row for each task
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
pLevel
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
int32_t
levelCnt
=
taosArrayGetSize
(
pLevel
);
for
(
int32_t
j
=
0
;
j
<
levelCnt
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pLevel
,
j
);
SColumnInfoData
*
pColInfo
;
int32_t
cols
=
0
;
// stream name
char
streamName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
streamName
,
mndGetDbStr
(
pStream
->
name
),
sizeof
(
streamName
));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
streamName
,
false
);
// task id
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTask
->
taskId
,
false
);
// node type
char
nodeType
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
varDataSetLen
(
nodeType
,
5
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
if
(
pTask
->
nodeId
>
0
)
{
memcpy
(
varDataVal
(
nodeType
),
"vnode"
,
5
);
}
else
{
memcpy
(
varDataVal
(
nodeType
),
"snode"
,
5
);
}
colDataAppend
(
pColInfo
,
numOfRows
,
nodeType
,
false
);
// node id
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
int32_t
nodeId
=
TMAX
(
pTask
->
nodeId
,
0
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
nodeId
,
false
);
// level
char
level
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
if
(
pTask
->
taskLevel
==
TASK_LEVEL__SOURCE
)
{
memcpy
(
varDataVal
(
level
),
"source"
,
6
);
varDataSetLen
(
level
,
6
);
}
else
if
(
pTask
->
taskLevel
==
TASK_LEVEL__AGG
)
{
memcpy
(
varDataVal
(
level
),
"agg"
,
3
);
varDataSetLen
(
level
,
3
);
}
else
if
(
pTask
->
taskLevel
==
TASK_LEVEL__SINK
)
{
memcpy
(
varDataVal
(
level
),
"sink"
,
4
);
varDataSetLen
(
level
,
4
);
}
else
if
(
pTask
->
taskLevel
==
TASK_LEVEL__SINK
)
{
}
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
level
,
false
);
// status
char
status
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
status2
[
20
]
=
{
0
};
strcpy
(
status
,
"normal"
);
STR_WITH_MAXSIZE_TO_VARSTR
(
status
,
status2
,
sizeof
(
status
));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
status
,
false
);
numOfRows
++
;
}
}
// unlock
taosRUnLockLatch
(
&
pStream
->
lock
);
sdbRelease
(
pSdb
,
pStream
);
}
pShow
->
numOfRows
+=
numOfRows
;
return
numOfRows
;
}
static
void
mndCancelGetNextStreamTask
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
8a0c8360
...
@@ -108,8 +108,8 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
...
@@ -108,8 +108,8 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
#define TSDBROW_KEY(ROW) ((TSDBKEY){.version = TSDBROW_VERSION(ROW), .ts = TSDBROW_TS(ROW)})
#define TSDBROW_KEY(ROW) ((TSDBKEY){.version = TSDBROW_VERSION(ROW), .ts = TSDBROW_TS(ROW)})
#define tsdbRowFromTSRow(VERSION, TSROW) ((TSDBROW){.type = 0, .version = (VERSION), .pTSRow = (TSROW)})
#define tsdbRowFromTSRow(VERSION, TSROW) ((TSDBROW){.type = 0, .version = (VERSION), .pTSRow = (TSROW)})
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
#define tsdbRowFromBlockData(BLOCKDATA, IROW) ((TSDBROW){.type = 1, .pBlockData = (BLOCKDATA), .iRow = (IROW)})
void
tsdbRowGetColVal
(
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
void
tsdbRowGetColVal
(
TSDBROW
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
int32_t
tPutTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
);
//
int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
int32_t
tsdbRowCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tsdbRowCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
// SRowIter
// SRowIter
void
tRowIterInit
(
SRowIter
*
pIter
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
void
tRowIterInit
(
SRowIter
*
pIter
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
...
@@ -333,6 +333,8 @@ struct SVersionRange {
...
@@ -333,6 +333,8 @@ struct SVersionRange {
typedef
struct
SMemSkipListNode
SMemSkipListNode
;
typedef
struct
SMemSkipListNode
SMemSkipListNode
;
struct
SMemSkipListNode
{
struct
SMemSkipListNode
{
int8_t
level
;
int8_t
level
;
int64_t
version
;
STSRow
*
pTSRow
;
SMemSkipListNode
*
forwards
[
0
];
SMemSkipListNode
*
forwards
[
0
];
};
};
typedef
struct
SMemSkipList
{
typedef
struct
SMemSkipList
{
...
@@ -772,14 +774,6 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
...
@@ -772,14 +774,6 @@ static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
static
FORCE_INLINE
int32_t
tGetTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
)
{
int32_t
n
=
tGetI64
(
p
,
&
pRow
->
version
);
pRow
->
pTSRow
=
(
STSRow
*
)(
p
+
n
);
n
+=
pRow
->
pTSRow
->
len
;
return
n
;
}
static
FORCE_INLINE
TSDBROW
*
tsdbTbDataIterGet
(
STbDataIter
*
pIter
)
{
static
FORCE_INLINE
TSDBROW
*
tsdbTbDataIterGet
(
STbDataIter
*
pIter
)
{
if
(
pIter
==
NULL
)
return
NULL
;
if
(
pIter
==
NULL
)
return
NULL
;
...
@@ -798,8 +792,9 @@ static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
...
@@ -798,8 +792,9 @@ static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
}
}
}
}
tGetTSDBRow
((
uint8_t
*
)
SL_NODE_DATA
(
pIter
->
pNode
),
&
pIter
->
row
);
pIter
->
pRow
=
&
pIter
->
row
;
pIter
->
pRow
=
&
pIter
->
row
;
pIter
->
pRow
->
version
=
pIter
->
pNode
->
version
;
pIter
->
pRow
->
pTSRow
=
pIter
->
pNode
->
pTSRow
;
return
pIter
->
pRow
;
return
pIter
->
pRow
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
8a0c8360
...
@@ -18,10 +18,10 @@
...
@@ -18,10 +18,10 @@
#define MEM_MIN_HASH 1024
#define MEM_MIN_HASH 1024
#define SL_MAX_LEVEL 5
#define SL_MAX_LEVEL 5
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l)*2)
// sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l) * 2
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + ((l) << 4))
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
#define SL_MOVE_BACKWARD 0x1
#define SL_MOVE_BACKWARD 0x1
#define SL_MOVE_FROM_POS 0x2
#define SL_MOVE_FROM_POS 0x2
...
@@ -263,30 +263,27 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDa
...
@@ -263,30 +263,27 @@ void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDa
}
}
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
)
{
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
)
{
SMemSkipListNode
*
pHead
=
pIter
->
pTbData
->
sl
.
pHead
;
SMemSkipListNode
*
pTail
=
pIter
->
pTbData
->
sl
.
pTail
;
pIter
->
pRow
=
NULL
;
pIter
->
pRow
=
NULL
;
if
(
pIter
->
backward
)
{
if
(
pIter
->
backward
)
{
ASSERT
(
pIter
->
pNode
!=
pTail
);
ASSERT
(
pIter
->
pNode
!=
p
Iter
->
pTbData
->
sl
.
p
Tail
);
if
(
pIter
->
pNode
==
pHead
)
{
if
(
pIter
->
pNode
==
p
Iter
->
pTbData
->
sl
.
p
Head
)
{
return
false
;
return
false
;
}
}
pIter
->
pNode
=
SL_NODE_BACKWARD
(
pIter
->
pNode
,
0
);
pIter
->
pNode
=
SL_NODE_BACKWARD
(
pIter
->
pNode
,
0
);
if
(
pIter
->
pNode
==
pHead
)
{
if
(
pIter
->
pNode
==
p
Iter
->
pTbData
->
sl
.
p
Head
)
{
return
false
;
return
false
;
}
}
}
else
{
}
else
{
ASSERT
(
pIter
->
pNode
!=
pHead
);
ASSERT
(
pIter
->
pNode
!=
p
Iter
->
pTbData
->
sl
.
p
Head
);
if
(
pIter
->
pNode
==
pTail
)
{
if
(
pIter
->
pNode
==
p
Iter
->
pTbData
->
sl
.
p
Tail
)
{
return
false
;
return
false
;
}
}
pIter
->
pNode
=
SL_NODE_FORWARD
(
pIter
->
pNode
,
0
);
pIter
->
pNode
=
SL_NODE_FORWARD
(
pIter
->
pNode
,
0
);
if
(
pIter
->
pNode
==
pTail
)
{
if
(
pIter
->
pNode
==
p
Iter
->
pTbData
->
sl
.
p
Tail
)
{
return
false
;
return
false
;
}
}
}
}
...
@@ -394,7 +391,7 @@ _err:
...
@@ -394,7 +391,7 @@ _err:
static
void
tbDataMovePosTo
(
STbData
*
pTbData
,
SMemSkipListNode
**
pos
,
TSDBKEY
*
pKey
,
int32_t
flags
)
{
static
void
tbDataMovePosTo
(
STbData
*
pTbData
,
SMemSkipListNode
**
pos
,
TSDBKEY
*
pKey
,
int32_t
flags
)
{
SMemSkipListNode
*
px
;
SMemSkipListNode
*
px
;
SMemSkipListNode
*
pn
;
SMemSkipListNode
*
pn
;
TSDBKEY
*
pTKey
;
TSDBKEY
tKey
=
{
0
}
;
int32_t
backward
=
flags
&
SL_MOVE_BACKWARD
;
int32_t
backward
=
flags
&
SL_MOVE_BACKWARD
;
int32_t
fromPos
=
flags
&
SL_MOVE_FROM_POS
;
int32_t
fromPos
=
flags
&
SL_MOVE_FROM_POS
;
...
@@ -413,9 +410,10 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p
...
@@ -413,9 +410,10 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p
for
(
int8_t
iLevel
=
pTbData
->
sl
.
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
for
(
int8_t
iLevel
=
pTbData
->
sl
.
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
pn
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
pn
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
while
(
pn
!=
pTbData
->
sl
.
pHead
)
{
while
(
pn
!=
pTbData
->
sl
.
pHead
)
{
pTKey
=
(
TSDBKEY
*
)
SL_NODE_DATA
(
pn
);
tKey
.
version
=
pn
->
version
;
tKey
.
ts
=
pn
->
pTSRow
->
ts
;
int32_t
c
=
tsdbKeyCmprFn
(
pT
Key
,
pKey
);
int32_t
c
=
tsdbKeyCmprFn
(
&
t
Key
,
pKey
);
if
(
c
<=
0
)
{
if
(
c
<=
0
)
{
break
;
break
;
}
else
{
}
else
{
...
@@ -442,7 +440,10 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p
...
@@ -442,7 +440,10 @@ static void tbDataMovePosTo(STbData *pTbData, SMemSkipListNode **pos, TSDBKEY *p
for
(
int8_t
iLevel
=
pTbData
->
sl
.
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
for
(
int8_t
iLevel
=
pTbData
->
sl
.
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
pn
=
SL_NODE_FORWARD
(
px
,
iLevel
);
pn
=
SL_NODE_FORWARD
(
px
,
iLevel
);
while
(
pn
!=
pTbData
->
sl
.
pTail
)
{
while
(
pn
!=
pTbData
->
sl
.
pTail
)
{
int32_t
c
=
tsdbKeyCmprFn
(
SL_NODE_DATA
(
pn
),
pKey
);
tKey
.
version
=
pn
->
version
;
tKey
.
ts
=
pn
->
pTSRow
->
ts
;
int32_t
c
=
tsdbKeyCmprFn
(
&
tKey
,
pKey
);
if
(
c
>=
0
)
{
if
(
c
>=
0
)
{
break
;
break
;
}
else
{
}
else
{
...
@@ -467,8 +468,8 @@ static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
...
@@ -467,8 +468,8 @@ static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
return
level
;
return
level
;
}
}
static
int32_t
tbDataDoPut
(
SMemTable
*
pMemTable
,
STbData
*
pTbData
,
SMemSkipListNode
**
pos
,
TSDBROW
*
pRow
,
static
int32_t
tbDataDoPut
(
SMemTable
*
pMemTable
,
STbData
*
pTbData
,
SMemSkipListNode
**
pos
,
int64_t
version
,
int8_t
forward
)
{
STSRow
*
pRow
,
int8_t
forward
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int8_t
level
;
int8_t
level
;
SMemSkipListNode
*
pNode
;
SMemSkipListNode
*
pNode
;
...
@@ -477,13 +478,19 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN
...
@@ -477,13 +478,19 @@ static int32_t tbDataDoPut(SMemTable *pMemTable, STbData *pTbData, SMemSkipListN
// node
// node
level
=
tsdbMemSkipListRandLevel
(
&
pTbData
->
sl
);
level
=
tsdbMemSkipListRandLevel
(
&
pTbData
->
sl
);
ASSERT
(
pPool
!=
NULL
);
ASSERT
(
pPool
!=
NULL
);
pNode
=
(
SMemSkipListNode
*
)
vnodeBufPoolMalloc
(
pPool
,
SL_NODE_SIZE
(
level
)
+
tPutTSDBRow
(
NULL
,
pRow
)
);
pNode
=
(
SMemSkipListNode
*
)
vnodeBufPoolMalloc
(
pPool
,
SL_NODE_SIZE
(
level
));
if
(
pNode
==
NULL
)
{
if
(
pNode
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
pNode
->
level
=
level
;
pNode
->
level
=
level
;
tPutTSDBRow
((
uint8_t
*
)
SL_NODE_DATA
(
pNode
),
pRow
);
pNode
->
version
=
version
;
pNode
->
pTSRow
=
vnodeBufPoolMalloc
(
pPool
,
pRow
->
len
);
if
(
NULL
==
pNode
->
pTSRow
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
memcpy
(
pNode
->
pTSRow
,
pRow
,
pRow
->
len
);
for
(
int8_t
iLevel
=
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
for
(
int8_t
iLevel
=
level
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
SMemSkipListNode
*
pn
=
pos
[
iLevel
];
SMemSkipListNode
*
pn
=
pos
[
iLevel
];
...
@@ -549,7 +556,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
...
@@ -549,7 +556,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
key
.
ts
=
row
.
pTSRow
->
ts
;
key
.
ts
=
row
.
pTSRow
->
ts
;
nRow
++
;
nRow
++
;
tbDataMovePosTo
(
pTbData
,
pos
,
&
key
,
SL_MOVE_BACKWARD
);
tbDataMovePosTo
(
pTbData
,
pos
,
&
key
,
SL_MOVE_BACKWARD
);
code
=
tbDataDoPut
(
pMemTable
,
pTbData
,
pos
,
&
r
ow
,
0
);
code
=
tbDataDoPut
(
pMemTable
,
pTbData
,
pos
,
version
,
row
.
pTSR
ow
,
0
);
if
(
code
)
{
if
(
code
)
{
goto
_err
;
goto
_err
;
}
}
...
@@ -570,7 +577,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
...
@@ -570,7 +577,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
if
(
SL_NODE_FORWARD
(
pos
[
0
],
0
)
!=
pTbData
->
sl
.
pTail
)
{
if
(
SL_NODE_FORWARD
(
pos
[
0
],
0
)
!=
pTbData
->
sl
.
pTail
)
{
tbDataMovePosTo
(
pTbData
,
pos
,
&
key
,
SL_MOVE_FROM_POS
);
tbDataMovePosTo
(
pTbData
,
pos
,
&
key
,
SL_MOVE_FROM_POS
);
}
}
code
=
tbDataDoPut
(
pMemTable
,
pTbData
,
pos
,
&
r
ow
,
1
);
code
=
tbDataDoPut
(
pMemTable
,
pTbData
,
pos
,
version
,
row
.
pTSR
ow
,
1
);
if
(
code
)
{
if
(
code
)
{
goto
_err
;
goto
_err
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
8a0c8360
...
@@ -3219,7 +3219,7 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe
...
@@ -3219,7 +3219,7 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe
static
int32_t
doMergeRowsInFileBlockImpl
(
SBlockData
*
pBlockData
,
int32_t
rowIndex
,
int64_t
key
,
SRowMerger
*
pMerger
,
static
int32_t
doMergeRowsInFileBlockImpl
(
SBlockData
*
pBlockData
,
int32_t
rowIndex
,
int64_t
key
,
SRowMerger
*
pMerger
,
SVersionRange
*
pVerRange
,
int32_t
step
)
{
SVersionRange
*
pVerRange
,
int32_t
step
)
{
while
(
pBlockData
->
aTSKEY
[
rowIndex
]
==
key
&&
rowIndex
<
pBlockData
->
nRow
&&
rowIndex
>=
0
)
{
while
(
rowIndex
<
pBlockData
->
nRow
&&
rowIndex
>=
0
&&
pBlockData
->
aTSKEY
[
rowIndex
]
==
key
)
{
if
(
pBlockData
->
aVersion
[
rowIndex
]
>
pVerRange
->
maxVer
||
pBlockData
->
aVersion
[
rowIndex
]
<
pVerRange
->
minVer
)
{
if
(
pBlockData
->
aVersion
[
rowIndex
]
>
pVerRange
->
maxVer
||
pBlockData
->
aVersion
[
rowIndex
]
<
pVerRange
->
minVer
)
{
rowIndex
+=
step
;
rowIndex
+=
step
;
continue
;
continue
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
8a0c8360
...
@@ -565,15 +565,15 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *
...
@@ -565,15 +565,15 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *
}
}
}
}
int32_t
tPutTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
)
{
//
int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow) {
int32_t
n
=
0
;
//
int32_t n = 0;
n
+=
tPutI64
(
p
,
pRow
->
version
);
//
n += tPutI64(p, pRow->version);
if
(
p
)
memcpy
(
p
+
n
,
pRow
->
pTSRow
,
pRow
->
pTSRow
->
len
);
//
if (p) memcpy(p + n, pRow->pTSRow, pRow->pTSRow->len);
n
+=
pRow
->
pTSRow
->
len
;
//
n += pRow->pTSRow->len;
return
n
;
//
return n;
}
//
}
int32_t
tsdbRowCmprFn
(
const
void
*
p1
,
const
void
*
p2
)
{
int32_t
tsdbRowCmprFn
(
const
void
*
p1
,
const
void
*
p2
)
{
return
tsdbKeyCmprFn
(
&
TSDBROW_KEY
((
TSDBROW
*
)
p1
),
&
TSDBROW_KEY
((
TSDBROW
*
)
p2
));
return
tsdbKeyCmprFn
(
&
TSDBROW_KEY
((
TSDBROW
*
)
p1
),
&
TSDBROW_KEY
((
TSDBROW
*
)
p2
));
...
@@ -1084,7 +1084,7 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
...
@@ -1084,7 +1084,7 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
cv
.
flag
=
CV_FLAG_VALUE
;
cv
.
flag
=
CV_FLAG_VALUE
;
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
void
*
pData
=
(
char
*
)
pRow
+
*
(
int32_t
*
)(
pRow
->
data
+
pTColumn
->
offset
-
sizeof
(
TSKEY
));
void
*
pData
=
(
char
*
)
pRow
+
*
(
int32_t
*
)(
pRow
->
data
+
pTColumn
->
offset
-
sizeof
(
TSKEY
));
cv
.
value
.
nData
=
varDataLen
(
pData
);
cv
.
value
.
nData
=
varDataLen
(
pData
);
cv
.
value
.
pData
=
varDataVal
(
pData
);
cv
.
value
.
pData
=
varDataVal
(
pData
);
}
else
{
}
else
{
...
@@ -1106,7 +1106,7 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
...
@@ -1106,7 +1106,7 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
cv
.
flag
=
CV_FLAG_VALUE
;
cv
.
flag
=
CV_FLAG_VALUE
;
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
void
*
pData
=
(
char
*
)
pRow
+
*
(
int32_t
*
)(
pRow
->
data
+
pTColumn
->
offset
-
sizeof
(
TSKEY
));
void
*
pData
=
(
char
*
)
pRow
+
*
(
int32_t
*
)(
pRow
->
data
+
pTColumn
->
offset
-
sizeof
(
TSKEY
));
cv
.
value
.
nData
=
varDataLen
(
pData
);
cv
.
value
.
nData
=
varDataLen
(
pData
);
cv
.
value
.
pData
=
varDataVal
(
pData
);
cv
.
value
.
pData
=
varDataVal
(
pData
);
}
else
{
}
else
{
...
@@ -1151,7 +1151,7 @@ static int32_t tBlockDataAppendKVRow(SBlockData *pBlockData, STSRow *pRow, STSch
...
@@ -1151,7 +1151,7 @@ static int32_t tBlockDataAppendKVRow(SBlockData *pBlockData, STSRow *pRow, STSch
ASSERT
(
pTColumn
->
type
==
pColData
->
type
);
ASSERT
(
pTColumn
->
type
==
pColData
->
type
);
SColVal
cv
=
{.
cid
=
pTColumn
->
colId
,
.
type
=
pTColumn
->
type
};
SColVal
cv
=
{.
cid
=
pTColumn
->
colId
,
.
type
=
pTColumn
->
type
};
TDRowValT
vt
=
TD_VTYPE_NONE
;
// default is NONE
TDRowValT
vt
=
TD_VTYPE_NONE
;
// default is NONE
SKvRowIdx
*
pKvIdx
=
NULL
;
SKvRowIdx
*
pKvIdx
=
NULL
;
while
(
kvIter
<
nKvCols
)
{
while
(
kvIter
<
nKvCols
)
{
...
...
source/libs/executor/src/tfill.c
浏览文件 @
8a0c8360
...
@@ -513,6 +513,22 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
...
@@ -513,6 +513,22 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
// taosMemoryFreeClear(pFillInfo->pTags[i].tagVal);
// taosMemoryFreeClear(pFillInfo->pTags[i].tagVal);
// }
// }
// free pFillCol
if
(
pFillInfo
->
pFillCol
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
i
++
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
if
(
!
pCol
->
notFillCol
)
{
if
(
pCol
->
fillVal
.
nType
==
TSDB_DATA_TYPE_VARBINARY
||
pCol
->
fillVal
.
nType
==
TSDB_DATA_TYPE_VARCHAR
||
pCol
->
fillVal
.
nType
==
TSDB_DATA_TYPE_NCHAR
||
pCol
->
fillVal
.
nType
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pCol
->
fillVal
.
pz
)
{
taosMemoryFree
(
pCol
->
fillVal
.
pz
);
pCol
->
fillVal
.
pz
=
NULL
;
}
}
}
}
}
taosMemoryFreeClear
(
pFillInfo
->
pTags
);
taosMemoryFreeClear
(
pFillInfo
->
pTags
);
taosMemoryFreeClear
(
pFillInfo
->
pFillCol
);
taosMemoryFreeClear
(
pFillInfo
->
pFillCol
);
taosMemoryFreeClear
(
pFillInfo
);
taosMemoryFreeClear
(
pFillInfo
);
...
...
source/libs/executor/src/tsimplehash.c
浏览文件 @
8a0c8360
...
@@ -189,7 +189,7 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons
...
@@ -189,7 +189,7 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons
}
}
while
(
pNode
)
{
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
),
key
,
keyLen
)
==
0
)
{
if
((
keyLen
==
pNode
->
keyLen
)
&&
(
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
),
key
,
keyLen
)
==
0
)
{
break
;
break
;
}
}
pNode
=
pNode
->
next
;
pNode
=
pNode
->
next
;
...
@@ -213,10 +213,12 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons
...
@@ -213,10 +213,12 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, size_t keyLen, cons
static
FORCE_INLINE
SHNode
*
doSearchInEntryList
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
int32_t
index
)
{
static
FORCE_INLINE
SHNode
*
doSearchInEntryList
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
int32_t
index
)
{
SHNode
*
pNode
=
pHashObj
->
hashList
[
index
];
SHNode
*
pNode
=
pHashObj
->
hashList
[
index
];
while
(
pNode
)
{
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
),
key
,
keyLen
)
==
0
)
{
const
char
*
p
=
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
);
ASSERT
(
keyLen
>
0
);
if
(
pNode
->
keyLen
==
keyLen
&&
((
*
(
pHashObj
->
equalFp
))(
p
,
key
,
keyLen
)
==
0
))
{
break
;
break
;
}
}
pNode
=
pNode
->
next
;
pNode
=
pNode
->
next
;
}
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
8a0c8360
...
@@ -475,7 +475,7 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le
...
@@ -475,7 +475,7 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -1506,7 +1506,7 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -1506,7 +1506,7 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -1519,7 +1519,7 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -1519,7 +1519,7 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
//if (1 != numOfParams && 3 != numOfParams && 4 != numOfParams) {
//
if (1 != numOfParams && 3 != numOfParams && 4 != numOfParams) {
if
(
1
!=
numOfParams
)
{
if
(
1
!=
numOfParams
)
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
@@ -1835,7 +1835,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -1835,7 +1835,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -1894,7 +1894,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int
...
@@ -1894,7 +1894,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
int32_t
code
=
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -2474,7 +2474,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2474,7 +2474,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"first"
,
.
name
=
"first"
,
.
type
=
FUNCTION_TYPE_FIRST
,
.
type
=
FUNCTION_TYPE_FIRST
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_IMPLICIT_TS_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_IMPLICIT_TS_FUNC
|
FUNC_MGT_KEEP_ORDER_FUNC
,
.
translateFunc
=
translateFirstLast
,
.
translateFunc
=
translateFirstLast
,
.
dynDataRequiredFunc
=
firstDynDataReq
,
.
dynDataRequiredFunc
=
firstDynDataReq
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
...
@@ -2512,7 +2512,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2512,7 +2512,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"last"
,
.
name
=
"last"
,
.
type
=
FUNCTION_TYPE_LAST
,
.
type
=
FUNCTION_TYPE_LAST
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_IMPLICIT_TS_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_IMPLICIT_TS_FUNC
|
FUNC_MGT_KEEP_ORDER_FUNC
,
.
translateFunc
=
translateFirstLast
,
.
translateFunc
=
translateFirstLast
,
.
dynDataRequiredFunc
=
lastDynDataReq
,
.
dynDataRequiredFunc
=
lastDynDataReq
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
8a0c8360
...
@@ -622,7 +622,7 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -622,7 +622,7 @@ void nodesDestroyNode(SNode* pNode) {
}
}
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
// pProjectRef is weak reference, no need to release
case
QUERY_NODE_COLUMN
:
destroyExprNode
((
SExprNode
*
)
pNode
);
destroyExprNode
((
SExprNode
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_VALUE
:
{
case
QUERY_NODE_VALUE
:
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
8a0c8360
...
@@ -744,7 +744,8 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
...
@@ -744,7 +744,8 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
return
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pExpr
)
->
colId
);
return
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pExpr
)
->
colId
);
}
else
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pExpr
))
{
}
else
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pExpr
))
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pExpr
;
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pExpr
;
if
(
FUNCTION_TYPE_SELECT_VALUE
==
pFunc
->
funcType
)
{
if
(
FUNCTION_TYPE_SELECT_VALUE
==
pFunc
->
funcType
||
FUNCTION_TYPE_FIRST
==
pFunc
->
funcType
||
FUNCTION_TYPE_LAST
==
pFunc
->
funcType
)
{
return
isPrimaryKeyImpl
(
nodesListGetNode
(
pFunc
->
pParameterList
,
0
));
return
isPrimaryKeyImpl
(
nodesListGetNode
(
pFunc
->
pParameterList
,
0
));
}
else
if
(
FUNCTION_TYPE_WSTART
==
pFunc
->
funcType
||
FUNCTION_TYPE_WEND
==
pFunc
->
funcType
)
{
}
else
if
(
FUNCTION_TYPE_WSTART
==
pFunc
->
funcType
||
FUNCTION_TYPE_WEND
==
pFunc
->
funcType
)
{
return
true
;
return
true
;
...
@@ -787,7 +788,6 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
...
@@ -787,7 +788,6 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
static
void
setColumnInfoByExpr
(
STempTableNode
*
pTable
,
SExprNode
*
pExpr
,
SColumnNode
**
pColRef
)
{
static
void
setColumnInfoByExpr
(
STempTableNode
*
pTable
,
SExprNode
*
pExpr
,
SColumnNode
**
pColRef
)
{
SColumnNode
*
pCol
=
*
pColRef
;
SColumnNode
*
pCol
=
*
pColRef
;
// pCol->pProjectRef = (SNode*)pExpr;
if
(
NULL
==
pExpr
->
pAssociation
)
{
if
(
NULL
==
pExpr
->
pAssociation
)
{
pExpr
->
pAssociation
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
pExpr
->
pAssociation
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
}
}
...
@@ -2932,8 +2932,8 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
...
@@ -2932,8 +2932,8 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
TSWINDOW_IS_EQUAL
(
pFill
->
timeRange
,
TSWINDOW_INITIALIZER
)
||
if
(
!
pCxt
->
createStream
&&
(
TSWINDOW_IS_EQUAL
(
pFill
->
timeRange
,
TSWINDOW_INITIALIZER
)
||
TSWINDOW_IS_EQUAL
(
pFill
->
timeRange
,
TSWINDOW_DESC_INITIALIZER
))
{
TSWINDOW_IS_EQUAL
(
pFill
->
timeRange
,
TSWINDOW_DESC_INITIALIZER
)
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE
);
}
}
...
@@ -5268,9 +5268,7 @@ static int32_t checkTopicQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -5268,9 +5268,7 @@ static int32_t checkTopicQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
}
static
int32_t
buildCreateTopicReq
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
SCMCreateTopicReq
*
pReq
)
{
static
int32_t
buildCreateTopicReq
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
SCMCreateTopicReq
*
pReq
)
{
SName
name
;
snprintf
(
pReq
->
name
,
sizeof
(
pReq
->
name
),
"%d.%s"
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
topicName
);
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
topicName
,
strlen
(
pStmt
->
topicName
));
tNameGetFullDbName
(
&
name
,
pReq
->
name
);
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
withMeta
=
pStmt
->
withMeta
;
pReq
->
withMeta
=
pStmt
->
withMeta
;
...
@@ -5280,7 +5278,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
...
@@ -5280,7 +5278,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
}
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SName
name
;
if
(
'\0'
!=
pStmt
->
subSTbName
[
0
])
{
if
(
'\0'
!=
pStmt
->
subSTbName
[
0
])
{
pReq
->
subType
=
TOPIC_SUB_TYPE__TABLE
;
pReq
->
subType
=
TOPIC_SUB_TYPE__TABLE
;
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
&
name
);
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
&
name
);
...
@@ -5548,6 +5546,10 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -5548,6 +5546,10 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
crossTableWithUdaf
(
pSelect
))
{
crossTableWithUdaf
(
pSelect
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"Unsupported stream query"
);
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"Unsupported stream query"
);
}
}
if
(
NULL
!=
pSelect
->
pSubtable
&&
TSDB_DATA_TYPE_VARCHAR
!=
((
SExprNode
*
)
pSelect
->
pSubtable
)
->
resType
.
type
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"SUBTABLE expression must be of VARCHAR type"
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
8a0c8360
...
@@ -37,43 +37,6 @@
...
@@ -37,43 +37,6 @@
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
//
//
// only start once
static
void
syncNodeStartSnapshotOnce
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
SyncTerm
lastApplyTerm
,
SyncAppendEntriesReply
*
pMsg
)
{
if
(
beginIndex
>
endIndex
)
{
sNError
(
ths
,
"snapshot param error, start:%"
PRId64
", end:%"
PRId64
,
beginIndex
,
endIndex
);
return
;
}
// get sender
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pSender
!=
NULL
);
if
(
snapshotSenderIsStart
(
pSender
))
{
sSError
(
pSender
,
"snapshot sender already start"
);
return
;
}
SSnapshot
snapshot
=
{
.
data
=
NULL
,
.
lastApplyIndex
=
endIndex
,
.
lastApplyTerm
=
lastApplyTerm
,
.
lastConfigIndex
=
SYNC_INDEX_INVALID
};
void
*
pReader
=
NULL
;
SSnapshotParam
readerParam
=
{.
start
=
beginIndex
,
.
end
=
endIndex
};
int32_t
code
=
ths
->
pFsm
->
FpSnapshotStartRead
(
ths
->
pFsm
,
&
readerParam
,
&
pReader
);
ASSERT
(
code
==
0
);
#if 0
if (pMsg->privateTerm < pSender->privateTerm) {
ASSERT(pReader != NULL);
snapshotSenderStart(pSender, readerParam, snapshot, pReader);
} else {
if (pReader != NULL) {
ths->pFsm->FpSnapshotStopRead(ths->pFsm, pReader);
}
}
#endif
}
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
SyncAppendEntriesReply
*
pMsg
=
pRpcMsg
->
pCont
;
SyncAppendEntriesReply
*
pMsg
=
pRpcMsg
->
pCont
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
8a0c8360
...
@@ -385,7 +385,7 @@ bool syncIsReadyForRead(int64_t rid) {
...
@@ -385,7 +385,7 @@ bool syncIsReadyForRead(int64_t rid) {
if
(
!
pSyncNode
->
pLogStore
->
syncLogIsEmpty
(
pSyncNode
->
pLogStore
))
{
if
(
!
pSyncNode
->
pLogStore
->
syncLogIsEmpty
(
pSyncNode
->
pLogStore
))
{
SSyncRaftEntry
*
pEntry
=
NULL
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_NOOP
&&
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_NOOP
&&
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
ready
=
true
;
ready
=
true
;
...
@@ -1806,7 +1806,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
...
@@ -1806,7 +1806,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
int32_t
code
=
syncBuildTimeout
(
&
rpcMsg
,
SYNC_TIMEOUT_PING
,
atomic_load_64
(
&
pNode
->
pingTimerLogicClock
),
int32_t
code
=
syncBuildTimeout
(
&
rpcMsg
,
SYNC_TIMEOUT_PING
,
atomic_load_64
(
&
pNode
->
pingTimerLogicClock
),
pNode
->
pingTimerMS
,
pNode
);
pNode
->
pingTimerMS
,
pNode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to build ping msg"
);
s
Error
(
"failed to build ping msg"
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
return
;
return
;
}
}
...
@@ -1814,7 +1814,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
...
@@ -1814,7 +1814,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
sNTrace
(
pNode
,
"enqueue ping msg"
);
sNTrace
(
pNode
,
"enqueue ping msg"
);
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to sync enqueue ping msg since %s"
,
terrstr
());
s
Error
(
"failed to sync enqueue ping msg since %s"
,
terrstr
());
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
return
;
return
;
}
}
...
@@ -1839,7 +1839,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
...
@@ -1839,7 +1839,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
int32_t
code
=
syncBuildTimeout
(
&
rpcMsg
,
SYNC_TIMEOUT_ELECTION
,
pElectTimer
->
logicClock
,
pNode
->
electTimerMS
,
pNode
);
int32_t
code
=
syncBuildTimeout
(
&
rpcMsg
,
SYNC_TIMEOUT_ELECTION
,
pElectTimer
->
logicClock
,
pNode
->
electTimerMS
,
pNode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to build elect msg"
);
s
Error
(
"failed to build elect msg"
);
taosMemoryFree
(
pElectTimer
);
taosMemoryFree
(
pElectTimer
);
return
;
return
;
}
}
...
@@ -1849,7 +1849,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
...
@@ -1849,7 +1849,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to sync enqueue elect msg since %s"
,
terrstr
());
s
Error
(
"failed to sync enqueue elect msg since %s"
,
terrstr
());
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
taosMemoryFree
(
pElectTimer
);
taosMemoryFree
(
pElectTimer
);
return
;
return
;
...
@@ -1879,14 +1879,14 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
...
@@ -1879,14 +1879,14 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
pNode
->
heartbeatTimerMS
,
pNode
);
pNode
->
heartbeatTimerMS
,
pNode
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to build heartbeat msg"
);
s
Error
(
"failed to build heartbeat msg"
);
return
;
return
;
}
}
sNTrace
(
pNode
,
"enqueue heartbeat timer"
);
sNTrace
(
pNode
,
"enqueue heartbeat timer"
);
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to enqueue heartbeat msg since %s"
,
terrstr
());
s
Error
(
"failed to enqueue heartbeat msg since %s"
,
terrstr
());
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
return
;
return
;
}
}
...
@@ -1971,7 +1971,7 @@ static int32_t syncNodeEqNoop(SSyncNode* pNode) {
...
@@ -1971,7 +1971,7 @@ static int32_t syncNodeEqNoop(SSyncNode* pNode) {
sNTrace
(
pNode
,
"propose msg, type:noop"
);
sNTrace
(
pNode
,
"propose msg, type:noop"
);
code
=
(
*
pNode
->
syncEqMsg
)(
pNode
->
msgcb
,
&
rpcMsg
);
code
=
(
*
pNode
->
syncEqMsg
)(
pNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
pNode
,
"failed to propose noop msg while enqueue since %s"
,
terrstr
());
s
Error
(
"failed to propose noop msg while enqueue since %s"
,
terrstr
());
}
}
return
code
;
return
code
;
...
@@ -2005,7 +2005,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
...
@@ -2005,7 +2005,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
int32_t
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
int32_t
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
s
NError
(
ths
,
"append noop error"
);
s
Error
(
"append noop error"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -2109,7 +2109,7 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -2109,7 +2109,7 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
syncNodeFollowerCommit
(
ths
,
pMsg
->
fcIndex
);
syncNodeFollowerCommit
(
ths
,
pMsg
->
fcIndex
);
}
else
{
}
else
{
s
NError
(
ths
,
"error local cmd"
);
s
Error
(
"error local cmd"
);
}
}
return
0
;
return
0
;
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
8a0c8360
...
@@ -197,7 +197,12 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
...
@@ -197,7 +197,12 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
syncMeta
.
isWeek
=
pEntry
->
isWeak
;
syncMeta
.
isWeek
=
pEntry
->
isWeak
;
syncMeta
.
seqNum
=
pEntry
->
seqNum
;
syncMeta
.
seqNum
=
pEntry
->
seqNum
;
syncMeta
.
term
=
pEntry
->
term
;
syncMeta
.
term
=
pEntry
->
term
;
int64_t
tsWriteBegin
=
taosGetTimestampNs
();
index
=
walAppendLog
(
pWal
,
pEntry
->
originalRpcType
,
syncMeta
,
pEntry
->
data
,
pEntry
->
dataLen
);
index
=
walAppendLog
(
pWal
,
pEntry
->
originalRpcType
,
syncMeta
,
pEntry
->
data
,
pEntry
->
dataLen
);
int64_t
tsWriteEnd
=
taosGetTimestampNs
();
int64_t
tsElapsed
=
tsWriteEnd
-
tsWriteBegin
;
if
(
index
<
0
)
{
if
(
index
<
0
)
{
int32_t
err
=
terrno
;
int32_t
err
=
terrno
;
const
char
*
errStr
=
tstrerror
(
err
);
const
char
*
errStr
=
tstrerror
(
err
);
...
@@ -210,8 +215,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
...
@@ -210,8 +215,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
}
}
pEntry
->
index
=
index
;
pEntry
->
index
=
index
;
sNTrace
(
pData
->
pSyncNode
,
"write index:%"
PRId64
", type:%s, origin type:%s
"
,
pEntry
->
index
,
sNTrace
(
pData
->
pSyncNode
,
"write index:%"
PRId64
", type:%s, origin type:%s
, elapsed:%"
PRId64
,
pEntry
->
index
,
TMSG_INFO
(
pEntry
->
msgType
),
TMSG_INFO
(
pEntry
->
originalRpcType
));
TMSG_INFO
(
pEntry
->
msgType
),
TMSG_INFO
(
pEntry
->
originalRpcType
)
,
tsElapsed
);
return
0
;
return
0
;
}
}
...
@@ -234,9 +239,13 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
...
@@ -234,9 +239,13 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
return
-
1
;
return
-
1
;
}
}
int64_t
ts1
=
taosGetTimestampNs
();
taosThreadMutexLock
(
&
(
pData
->
mutex
));
taosThreadMutexLock
(
&
(
pData
->
mutex
));
int64_t
ts2
=
taosGetTimestampNs
();
code
=
walReadVer
(
pWalHandle
,
index
);
code
=
walReadVer
(
pWalHandle
,
index
);
int64_t
ts3
=
taosGetTimestampNs
();
// code = walReadVerCached(pWalHandle, index);
// code = walReadVerCached(pWalHandle, index);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
int32_t
err
=
terrno
;
int32_t
err
=
terrno
;
...
@@ -280,6 +289,18 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
...
@@ -280,6 +289,18 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
*/
*/
taosThreadMutexUnlock
(
&
(
pData
->
mutex
));
taosThreadMutexUnlock
(
&
(
pData
->
mutex
));
int64_t
ts4
=
taosGetTimestampNs
();
int64_t
tsElapsed
=
ts4
-
ts1
;
int64_t
tsElapsedLock
=
ts2
-
ts1
;
int64_t
tsElapsedRead
=
ts3
-
ts2
;
int64_t
tsElapsedBuild
=
ts4
-
ts3
;
sNTrace
(
pData
->
pSyncNode
,
"read index:%"
PRId64
", elapsed:%"
PRId64
", elapsed-lock:%"
PRId64
", elapsed-read:%"
PRId64
", elapsed-build:%"
PRId64
,
index
,
tsElapsed
,
tsElapsedLock
,
tsElapsedRead
,
tsElapsedBuild
);
return
code
;
return
code
;
}
}
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
8a0c8360
...
@@ -72,7 +72,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh
...
@@ -72,7 +72,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
SyncAppendEntries
*
pMsg
=
NULL
;
SyncAppendEntries
*
pMsg
=
NULL
;
SSyncRaftEntry
*
pEntry
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
nextIndex
,
&
pEntry
);
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
nextIndex
,
&
pEntry
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
...
@@ -99,6 +99,8 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh
...
@@ -99,6 +99,8 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh
}
}
}
}
syncEntryDestory
(
pEntry
);
// prepare msg
// prepare msg
ASSERT
(
pMsg
!=
NULL
);
ASSERT
(
pMsg
!=
NULL
);
pMsg
->
srcId
=
pSyncNode
->
myRaftId
;
pMsg
->
srcId
=
pSyncNode
->
myRaftId
;
...
@@ -140,9 +142,10 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
...
@@ -140,9 +142,10 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
int32_t
syncNodeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
)
{
int32_t
syncNodeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
SyncAppendEntries
*
pMsg
=
pRpcMsg
->
pCont
;
SyncAppendEntries
*
pMsg
=
pRpcMsg
->
pCont
;
if
(
pMsg
==
NULL
)
{
syncLogSendAppendEntries
(
pSyncNode
,
pMsg
,
""
);
sError
(
"vgId:%d, sync-append-entries msg is NULL"
,
pSyncNode
->
vgId
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
pRpcMsg
);
return
0
;
}
SPeerState
*
pState
=
syncNodeGetPeerState
(
pSyncNode
,
destRaftId
);
SPeerState
*
pState
=
syncNodeGetPeerState
(
pSyncNode
,
destRaftId
);
if
(
pState
==
NULL
)
{
if
(
pState
==
NULL
)
{
...
@@ -150,8 +153,19 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI
...
@@ -150,8 +153,19 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI
return
0
;
return
0
;
}
}
// save index, otherwise pMsg will be free by rpc
SyncIndex
saveLastSendIndex
=
pState
->
lastSendIndex
;
bool
update
=
false
;
if
(
pMsg
->
dataLen
>
0
)
{
if
(
pMsg
->
dataLen
>
0
)
{
pState
->
lastSendIndex
=
pMsg
->
prevLogIndex
+
1
;
saveLastSendIndex
=
pMsg
->
prevLogIndex
+
1
;
update
=
true
;
}
syncLogSendAppendEntries
(
pSyncNode
,
pMsg
,
""
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
pRpcMsg
);
if
(
update
)
{
pState
->
lastSendIndex
=
saveLastSendIndex
;
pState
->
lastSendTime
=
taosGetTimestampMs
();
pState
->
lastSendTime
=
taosGetTimestampMs
();
}
}
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
8a0c8360
...
@@ -194,6 +194,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
...
@@ -194,6 +194,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
void
syncPrintNodeLog
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
SSyncNode
*
pNode
,
const
char
*
format
,
...)
{
void
syncPrintNodeLog
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
SSyncNode
*
pNode
,
const
char
*
format
,
...)
{
if
(
pNode
==
NULL
||
pNode
->
pRaftCfg
!=
NULL
&&
pNode
->
pRaftStore
==
NULL
||
pNode
->
pLogStore
==
NULL
)
return
;
if
(
pNode
==
NULL
||
pNode
->
pRaftCfg
!=
NULL
&&
pNode
->
pRaftStore
==
NULL
||
pNode
->
pLogStore
==
NULL
)
return
;
int64_t
currentTerm
=
pNode
->
pRaftStore
->
currentTerm
;
// save error code, otherwise it will be overwritten
// save error code, otherwise it will be overwritten
int32_t
errCode
=
terrno
;
int32_t
errCode
=
terrno
;
...
@@ -235,8 +236,8 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
...
@@ -235,8 +236,8 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
", tm:%"
PRIu64
", cmt:%"
PRId64
", fst:%"
PRId64
", lst:%"
PRId64
", min:%"
PRId64
", snap:%"
PRId64
", tm:%"
PRIu64
", cmt:%"
PRId64
", fst:%"
PRId64
", lst:%"
PRId64
", min:%"
PRId64
", snap:%"
PRId64
", snap-tm:%"
PRIu64
", sby:%d, aq:%d, bch:%d, r-num:%d, lcfg:%"
PRId64
", snap-tm:%"
PRIu64
", sby:%d, aq:%d, bch:%d, r-num:%d, lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
pNode
->
vgId
,
syncStr
(
pNode
->
state
),
eventLog
,
pNode
->
pRaftStore
->
currentTerm
,
pNode
->
commit
Index
,
pNode
->
vgId
,
syncStr
(
pNode
->
state
),
eventLog
,
currentTerm
,
pNode
->
commitIndex
,
logBegin
Index
,
log
BeginIndex
,
log
LastIndex
,
pNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
logLastIndex
,
pNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pNode
->
pRaftCfg
->
isStandBy
,
aqItems
,
pNode
->
pRaftCfg
->
batchSize
,
pNode
->
replicaNum
,
pNode
->
pRaftCfg
->
isStandBy
,
aqItems
,
pNode
->
pRaftCfg
->
batchSize
,
pNode
->
replicaNum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
peerStr
,
cfgStr
);
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
peerStr
,
cfgStr
);
...
@@ -374,9 +375,9 @@ void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntries
...
@@ -374,9 +375,9 @@ void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntries
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
sNTrace
(
pSyncNode
,
sNTrace
(
pSyncNode
,
"recv sync-append-entries-reply from %s:%d {term:%"
PRId64
", pterm:%"
PRId64
", success:%d, match:%"
PRId64
"recv sync-append-entries-reply from %s:%d {term:%"
PRId64
", pterm:%"
PRId64
"}, %s"
,
"
, success:%d, lsend-index:%"
PRId64
", match:%"
PRId64
"
}, %s"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
privateTerm
,
pMsg
->
success
,
pMsg
->
matchIndex
,
s
);
host
,
port
,
pMsg
->
term
,
pMsg
->
privateTerm
,
pMsg
->
success
,
pMsg
->
lastSendIndex
,
pMsg
->
matchIndex
,
s
);
}
}
void
syncLogSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SyncHeartbeat
*
pMsg
,
const
char
*
s
)
{
void
syncLogSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SyncHeartbeat
*
pMsg
,
const
char
*
s
)
{
...
@@ -511,8 +512,8 @@ void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMs
...
@@ -511,8 +512,8 @@ void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMs
syncUtilU642Addr
(
pMsg
->
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
sNTrace
(
pSyncNode
,
sNTrace
(
pSyncNode
,
"send sync-append-entries to %s:%d, {term:%"
PRId64
", pre-index:%"
PRId64
", pre-term:%"
PRId64
"send sync-append-entries to %s:%d, {term:%"
PRId64
", pre-index:%"
PRId64
", pre-term:%"
PRId64
",
pterm
:%"
PRId64
", cmt:%"
PRId64
", datalen:%d}, %s"
,
",
lsend-index
:%"
PRId64
", cmt:%"
PRId64
", datalen:%d}, %s"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
privateTerm
,
pMsg
->
commitIndex
,
host
,
port
,
pMsg
->
term
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
(
pMsg
->
prevLogIndex
+
1
)
,
pMsg
->
commitIndex
,
pMsg
->
dataLen
,
s
);
pMsg
->
dataLen
,
s
);
}
}
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
8a0c8360
...
@@ -124,8 +124,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
...
@@ -124,8 +124,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
goto
_err
;
goto
_err
;
}
}
char
*
candidate
=
NULL
;
char
*
candidate
=
NULL
;
char
*
haystack
=
buf
;
char
*
haystack
=
buf
;
int64_t
pos
=
0
;
int64_t
pos
=
0
;
SWalCkHead
*
logContent
=
NULL
;
SWalCkHead
*
logContent
=
NULL
;
...
@@ -414,8 +414,10 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -414,8 +414,10 @@ int walCheckAndRepairMeta(SWal* pWal) {
}
}
ASSERT
(
pFileInfo
->
fileSize
==
0
);
ASSERT
(
pFileInfo
->
fileSize
==
0
);
// remove the empty wal log, and its idx
// remove the empty wal log, and its idx
wInfo
(
"vgId:%d, wal remove empty file %s"
,
pWal
->
cfg
.
vgId
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
taosRemoveFile
(
fnameStr
);
walBuildIdxName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
walBuildIdxName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
wInfo
(
"vgId:%d, wal remove empty file %s"
,
pWal
->
cfg
.
vgId
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
taosRemoveFile
(
fnameStr
);
// remove its meta entry
// remove its meta entry
taosArrayRemove
(
pWal
->
fileInfoSet
,
fileIdx
);
taosArrayRemove
(
pWal
->
fileInfoSet
,
fileIdx
);
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
8a0c8360
...
@@ -407,6 +407,7 @@ int32_t walRollImpl(SWal *pWal) {
...
@@ -407,6 +407,7 @@ int32_t walRollImpl(SWal *pWal) {
}
}
walBuildLogName
(
pWal
,
newFileFirstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
newFileFirstVer
,
fnameStr
);
pLogFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
pLogFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
wDebug
(
"vgId:%d, wal create new file for write:%s"
,
pWal
->
cfg
.
vgId
,
fnameStr
);
if
(
pLogFile
==
NULL
)
{
if
(
pLogFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
-
1
;
code
=
-
1
;
...
...
source/util/src/tconfig.c
浏览文件 @
8a0c8360
...
@@ -271,8 +271,11 @@ static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType
...
@@ -271,8 +271,11 @@ static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType
cfgStypeStr
(
stype
),
value
,
terrstr
());
cfgStypeStr
(
stype
),
value
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
pItem
->
stype
=
stype
;
pItem
->
stype
=
stype
;
// apply new timezone
osSetTimezone
(
value
);
return
0
;
return
0
;
}
}
...
...
tools/CMakeLists.txt
浏览文件 @
8a0c8360
...
@@ -87,6 +87,7 @@ ELSE ()
...
@@ -87,6 +87,7 @@ ELSE ()
MESSAGE
(
"CURRENT SOURCE DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
MESSAGE
(
"CURRENT SOURCE DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
"
)
IF
(
TD_WINDOWS
)
IF
(
TD_WINDOWS
)
MESSAGE
(
"Building taosAdapter on Windows"
)
INCLUDE
(
ExternalProject
)
INCLUDE
(
ExternalProject
)
ExternalProject_Add
(
taosadapter
ExternalProject_Add
(
taosadapter
PREFIX
"taosadapter"
PREFIX
"taosadapter"
...
@@ -104,14 +105,18 @@ ELSE ()
...
@@ -104,14 +105,18 @@ ELSE ()
COMMAND go build -a -o taosadapter-debug.exe -ldflags
"-X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND go build -a -o taosadapter-debug.exe -ldflags
"-X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
INSTALL_COMMAND
INSTALL_COMMAND
COMMAND cmake -E time upx taosadapter ||:
COMMAND cmake -E echo
"Comparessing taosadapter.exe"
COMMAND cmake -E copy taosadapter.exe
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E time upx taosadapter.exe
COMMAND cmake -E echo
"Copy taosadapter.exe"
COMMAND cmake -E copy taosadapter.exe
${
CMAKE_BINARY_DIR
}
/build/bin/taosadapter.exe
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E echo
"Copy taosadapter.toml"
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E
copy ./taosadapter.service
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E
echo
"Copy taosadapter-debug.exe"
COMMAND cmake -E copy taosadapter-debug.exe
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E copy taosadapter-debug.exe
${
CMAKE_BINARY_DIR
}
/build/bin
)
)
ELSE
(
TD_WINDOWS
)
ELSE
(
TD_WINDOWS
)
MESSAGE
(
"Building taosAdapter on non-Windows"
)
INCLUDE
(
ExternalProject
)
INCLUDE
(
ExternalProject
)
ExternalProject_Add
(
taosadapter
ExternalProject_Add
(
taosadapter
PREFIX
"taosadapter"
PREFIX
"taosadapter"
...
@@ -126,11 +131,15 @@ ELSE ()
...
@@ -126,11 +131,15 @@ ELSE ()
COMMAND CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib go build -a -ldflags
"-s -w -X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib go build -a -ldflags
"-s -w -X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib go build -a -o taosadapter-debug -ldflags
"-X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
COMMAND CGO_CFLAGS=-I
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include/client CGO_LDFLAGS=-L
${
CMAKE_BINARY_DIR
}
/build/lib go build -a -o taosadapter-debug -ldflags
"-X github.com/taosdata/taosadapter/v3/version.Version=
${
taos_version
}
-X github.com/taosdata/taosadapter/v3/version.CommitID=
${
taosadapter_commit_sha1
}
"
INSTALL_COMMAND
INSTALL_COMMAND
COMMAND cmake -E echo
"Comparessing taosadapter.exe"
COMMAND upx taosadapter || :
COMMAND upx taosadapter || :
COMMAND cmake -E echo
"Copy taosadapter"
COMMAND cmake -E copy taosadapter
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E copy taosadapter
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E make_directory
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E echo
"Copy taosadapter.toml"
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./example/config/taosadapter.toml
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./taosadapter.service
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E copy ./taosadapter.service
${
CMAKE_BINARY_DIR
}
/test/cfg/
COMMAND cmake -E echo
"Copy taosadapter-debug"
COMMAND cmake -E copy taosadapter-debug
${
CMAKE_BINARY_DIR
}
/build/bin
COMMAND cmake -E copy taosadapter-debug
${
CMAKE_BINARY_DIR
}
/build/bin
)
)
ENDIF
(
TD_WINDOWS
)
ENDIF
(
TD_WINDOWS
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录