Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a17e3f32
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看板
提交
a17e3f32
编写于
3月 04, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/config
上级
bc25fed8
448492a7
变更
77
展开全部
显示空白变更内容
内联
并排
Showing
77 changed file
with
2678 addition
and
814 deletion
+2678
-814
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/libs/index/index.h
include/libs/index/index.h
+102
-12
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+4
-6
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-3
include/os/osDir.h
include/os/osDir.h
+1
-1
include/os/osFile.h
include/os/osFile.h
+17
-7
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+6
-6
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-0
source/common/test/commonTests.cpp
source/common/test/commonTests.cpp
+2
-2
source/common/test/tmsgTest.cpp
source/common/test/tmsgTest.cpp
+1
-1
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+3
-0
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+3
-0
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+3
-0
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+7
-8
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+3
-0
source/libs/CMakeLists.txt
source/libs/CMakeLists.txt
+0
-1
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+28
-13
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+213
-92
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+552
-34
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+4
-4
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+3
-3
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+1
-1
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+42
-19
source/libs/index/inc/index_comm.h
source/libs/index/inc/index_comm.h
+32
-0
source/libs/index/src/index.c
source/libs/index/src/index.c
+19
-7
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+22
-12
source/libs/index/src/index_comm.c
source/libs/index/src/index_comm.c
+48
-0
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+10
-8
source/libs/index/src/index_json.c
source/libs/index/src/index_json.c
+44
-0
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+23
-6
source/libs/index/test/CMakeLists.txt
source/libs/index/test/CMakeLists.txt
+18
-0
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+15
-10
source/libs/index/test/fstUT.cc
source/libs/index/test/fstUT.cc
+21
-5
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+135
-0
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-4
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+2
-2
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+1
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+2
-2
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+2
-2
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+2
-2
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+12
-3
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+150
-133
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+82
-60
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+46
-26
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+107
-75
source/libs/sync/inc/syncVoteMgr.h
source/libs/sync/inc/syncVoteMgr.h
+6
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+4
-10
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-11
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+337
-56
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+348
-23
source/libs/sync/test/syncIOSendMsgClientTest.cpp
source/libs/sync/test/syncIOSendMsgClientTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgServerTest.cpp
source/libs/sync/test/syncIOSendMsgServerTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+1
-1
source/libs/sync/test/syncIOTickPingTest.cpp
source/libs/sync/test/syncIOTickPingTest.cpp
+1
-1
source/libs/sync/test/syncIOTickQTest.cpp
source/libs/sync/test/syncIOTickQTest.cpp
+1
-1
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+19
-12
source/libs/sync/test/syncRaftStoreTest.cpp
source/libs/sync/test/syncRaftStoreTest.cpp
+2
-2
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+1
-1
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+1
-1
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+21
-22
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+4
-4
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+1
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+2
-9
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+49
-49
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+12
-10
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+11
-11
source/os/src/osDir.c
source/os/src/osDir.c
+1
-1
source/os/src/osFile.c
source/os/src/osFile.c
+39
-0
source/util/test/cacheTest.cpp
source/util/test/cacheTest.cpp
+1
-1
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+1
-1
source/util/test/freelistTest.cpp
source/util/test/freelistTest.cpp
+1
-1
source/util/test/hashTest.cpp
source/util/test/hashTest.cpp
+2
-2
tools/shell/src/backup/shellImport.c
tools/shell/src/backup/shellImport.c
+3
-5
未找到文件。
include/common/tmsg.h
浏览文件 @
a17e3f32
...
...
@@ -739,6 +739,9 @@ typedef struct {
int32_t
maxRows
;
int32_t
commitTime
;
int32_t
fsyncPeriod
;
uint32_t
hashBegin
;
uint32_t
hashEnd
;
int8_t
hashMethod
;
int8_t
walLevel
;
int8_t
precision
;
int8_t
compression
;
...
...
@@ -749,6 +752,7 @@ typedef struct {
int8_t
selfIndex
;
int8_t
streamMode
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
}
SCreateVnodeReq
,
SAlterVnodeReq
;
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
...
...
include/libs/index/index.h
浏览文件 @
a17e3f32
...
...
@@ -29,6 +29,12 @@ typedef struct SIndexOpts SIndexOpts;
typedef
struct
SIndexMultiTermQuery
SIndexMultiTermQuery
;
typedef
struct
SArray
SIndexMultiTerm
;
typedef
struct
SIndex
SIndexJson
;
typedef
struct
SIndexTerm
SIndexJsonTerm
;
typedef
struct
SIndexOpts
SIndexJsonOpts
;
typedef
struct
SIndexMultiTermQuery
SIndexJsonMultiTermQuery
;
typedef
struct
SArray
SIndexJsonMultiTerm
;
typedef
enum
{
ADD_VALUE
,
// add index colume value
DEL_VALUE
,
// delete index column value
...
...
@@ -39,24 +45,108 @@ typedef enum {
}
SIndexOperOnColumn
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
}
EIndexQueryType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
,
QUERY_RANGE
=
4
}
EIndexQueryType
;
/*
*
@param: oper
*
*
create multi query
*
@param oper (input, relation between querys)
*/
SIndexMultiTermQuery
*
indexMultiTermQueryCreate
(
EIndexOperatorType
oper
);
/*
* destroy multi query
* @param pQuery (input, multi-query-object to be destory)
*/
void
indexMultiTermQueryDestroy
(
SIndexMultiTermQuery
*
pQuery
);
/*
* add query to multi query
* @param pQuery (input, multi-query-object)
* @param term (input, single query term)
* @param type (input, single query type)
* @return error code
*/
int
indexMultiTermQueryAdd
(
SIndexMultiTermQuery
*
pQuery
,
SIndexTerm
*
term
,
EIndexQueryType
type
);
/*
* @param:
* @param:
* open index
* @param opt (input, index opt)
* @param path (input, index path)
* @param index (output, index object)
* @return error code
*/
int
indexOpen
(
SIndexOpts
*
opt
,
const
char
*
path
,
SIndex
**
index
);
/*
* close index
* @param index (input, index to be closed)
* @return error code
*/
void
indexClose
(
SIndex
*
index
);
/*
* insert terms into index
* @param index (input, index object)
* @param term (input, terms inserted into index)
* @param uid (input, uid of terms)
* @return error code
*/
int
indexPut
(
SIndex
*
index
,
SIndexMultiTerm
*
terms
,
uint64_t
uid
);
/*
* delete terms that meet query condition
* @param index (input, index object)
* @param query (input, condition query to deleted)
* @return error code
*/
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
);
/*
* search index
* @param index (input, index object)
* @param query (input, multi query condition)
* @param result(output, query result)
* @return error code
*/
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
,
SArray
*
result
);
/*
* rebuild index
* @param index (input, index object)
* @parma opt (input, rebuild index opts)
* @return error code
*/
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opt
);
/*
* open index
* @param opt (input,index json opt)
* @param path (input, index json path)
* @param index (output, index json object)
* @return error code
*/
int
tIndexJsonOpen
(
SIndexJsonOpts
*
opts
,
const
char
*
path
,
SIndexJson
**
index
);
/*
* close index
* @param index (input, index to be closed)
* @return void
*/
void
tIndexJsonClose
(
SIndexJson
*
index
);
/*
* insert terms into index
* @param index (input, index object)
* @param term (input, terms inserted into index)
* @param uid (input, uid of terms)
* @return error code
*/
int
tIndexJsonPut
(
SIndexJson
*
index
,
SIndexJsonMultiTerm
*
terms
,
uint64_t
uid
);
/*
* search index
* @param index (input, index object)
* @param query (input, multi query condition)
* @param result(output, query result)
* @return error code
*/
int
tIndexJsonSearch
(
SIndexJson
*
index
,
SIndexJsonMultiTermQuery
*
query
,
SArray
*
result
);
/*
* @param
* @param
...
...
include/libs/scheduler/scheduler.h
浏览文件 @
a17e3f32
...
...
@@ -23,8 +23,6 @@ extern "C" {
#include "catalog.h"
#include "planner.h"
struct
SSchJob
;
typedef
struct
SSchedulerCfg
{
uint32_t
maxJobNum
;
}
SSchedulerCfg
;
...
...
@@ -72,7 +70,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg);
* @param nodeList Qnode/Vnode address list, element is SQueryNodeAddr
* @return
*/
int32_t
schedulerExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
struct
SSchJob
**
pJob
,
const
char
*
sql
,
SQueryResult
*
pRes
);
int32_t
schedulerExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
int64_t
*
pJob
,
const
char
*
sql
,
SQueryResult
*
pRes
);
/**
* Process the query job, generated according to the query physical plan.
...
...
@@ -80,7 +78,7 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryDag* pDag, str
* @param pNodeList Qnode/Vnode address list, element is SQueryNodeAddr
* @return
*/
int32_t
schedulerAsyncExecJob
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
const
char
*
sql
,
struct
SSchJob
**
pJob
);
int32_t
schedulerAsyncExecJob
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
const
char
*
sql
,
int64_t
*
pJob
);
/**
* Fetch query result from the remote query executor
...
...
@@ -88,7 +86,7 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryDag* pDa
* @param data
* @return
*/
int32_t
schedulerFetchRows
(
struct
SSchJob
*
pJ
ob
,
void
**
data
);
int32_t
schedulerFetchRows
(
int64_t
j
ob
,
void
**
data
);
/**
...
...
@@ -102,7 +100,7 @@ int32_t schedulerFetchRows(struct SSchJob *pJob, void **data);
* Free the query job
* @param pJob
*/
void
schedulerFreeJob
(
void
*
pJ
ob
);
void
schedulerFreeJob
(
int64_t
j
ob
);
void
schedulerDestroy
(
void
);
...
...
include/libs/sync/sync.h
浏览文件 @
a17e3f32
...
...
@@ -34,9 +34,7 @@ typedef enum {
TAOS_SYNC_STATE_FOLLOWER
=
0
,
TAOS_SYNC_STATE_CANDIDATE
=
1
,
TAOS_SYNC_STATE_LEADER
=
2
,
}
ESyncRole
;
typedef
ESyncRole
ESyncState
;
}
ESyncState
;
typedef
struct
SSyncBuffer
{
void
*
data
;
...
...
include/os/osDir.h
浏览文件 @
a17e3f32
...
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
void
taosRemoveDir
(
const
char
*
dirname
);
int32_t
taosDirExist
(
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
...
...
include/os/osFile.h
浏览文件 @
a17e3f32
...
...
@@ -25,8 +25,12 @@ extern "C" {
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
// #define close CLOSE_FUNC_TAOS_FORBID
// #define fclose FCLOSE_FUNC_TAOS_FORBID
#define access ACCESS_FUNC_TAOS_FORBID
#define stat STAT_FUNC_TAOS_FORBID
#define lstat LSTAT_FUNC_TAOS_FORBID
#define fstat FSTAT_FUNC_TAOS_FORBID
#define close CLOSE_FUNC_TAOS_FORBID
#define fclose FCLOSE_FUNC_TAOS_FORBID
#endif
#ifndef PATH_MAX
...
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
#define TD_FILE_ACCESS_EXIST_OK 0x1
#define TD_FILE_ACCESS_READ_OK 0x2
#define TD_FILE_ACCESS_WRITE_OK 0x4
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int
mode
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
...
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
bool
taosCheckExistFile
(
const
char
*
pathname
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
...
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
bool
taosValidFile
(
TdFilePtr
pFile
);
int
taosGetErrorFile
(
TdFilePtr
pFile
);
int
32_t
taosGetErrorFile
(
TdFilePtr
pFile
);
#ifdef __cplusplus
}
...
...
source/client/inc/clientInt.h
浏览文件 @
a17e3f32
...
...
@@ -171,7 +171,7 @@ typedef struct SRequestSendRecvBody {
void
*
fp
;
SShowReqInfo
showInfo
;
// todo this attribute will be removed after the query framework being completed.
SDataBuf
requestMsg
;
struct
SSchJob
*
pQ
ueryJob
;
// query job, created according to sql query DAG.
int64_t
q
ueryJob
;
// query job, created according to sql query DAG.
struct
SQueryDag
*
pDag
;
// the query dag, generated according to the sql statement.
SReqResultInfo
resInfo
;
}
SRequestSendRecvBody
;
...
...
source/client/src/clientImpl.c
浏览文件 @
a17e3f32
...
...
@@ -227,10 +227,10 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryDag
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
pQ
ueryJob
,
pRequest
->
sqlstr
,
&
res
);
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
q
ueryJob
,
pRequest
->
sqlstr
,
&
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
pQueryJob
!=
NULL
)
{
schedulerFreeJob
(
pRequest
->
body
.
pQ
ueryJob
);
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
q
ueryJob
);
}
pRequest
->
code
=
code
;
...
...
@@ -240,8 +240,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, SArray* pNodeList)
if
(
TSDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL_CREATE_TABLE
==
pRequest
->
type
)
{
pRequest
->
body
.
resInfo
.
numOfRows
=
res
.
numOfRows
;
if
(
pRequest
->
body
.
pQueryJob
!=
NULL
)
{
schedulerFreeJob
(
pRequest
->
body
.
pQ
ueryJob
);
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
q
ueryJob
);
}
}
...
...
@@ -494,7 +494,7 @@ void* doFetchRow(SRequestObj* pRequest) {
}
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
int32_t
code
=
schedulerFetchRows
(
pRequest
->
body
.
pQ
ueryJob
,
(
void
**
)
&
pResInfo
->
pData
);
int32_t
code
=
schedulerFetchRows
(
pRequest
->
body
.
q
ueryJob
,
(
void
**
)
&
pResInfo
->
pData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
return
NULL
;
...
...
source/common/src/tmsg.c
浏览文件 @
a17e3f32
...
...
@@ -2112,6 +2112,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
if
(
tEncodeI32
(
&
encoder
,
pReq
->
maxRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commitTime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pReq
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pReq
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
hashMethod
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
walLevel
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
precision
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
compression
)
<
0
)
return
-
1
;
...
...
@@ -2152,6 +2155,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
maxRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commitTime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pReq
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pReq
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
hashMethod
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
walLevel
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
precision
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
compression
)
<
0
)
return
-
1
;
...
...
source/common/test/commonTests.cpp
浏览文件 @
a17e3f32
#include "tcommon.h"
#include <gtest/gtest.h>
#include <tep.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -10,6 +8,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "tep.h"
#include "tcommon.h"
#include "taos.h"
#include "tvariant.h"
#include "tdef.h"
...
...
source/common/test/tmsgTest.cpp
浏览文件 @
a17e3f32
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tmsg.h"
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
a17e3f32
...
...
@@ -523,6 +523,9 @@ static void dndGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
walCfg
.
rollPeriod
=
128
;
pCfg
->
walCfg
.
segSize
=
128
;
pCfg
->
walCfg
.
vgId
=
pCreate
->
vgId
;
pCfg
->
hashBegin
=
pCreate
->
hashBegin
;
pCfg
->
hashEnd
=
pCreate
->
hashEnd
;
pCfg
->
hashMethod
=
pCreate
->
hashMethod
;
}
static
void
dndGenerateWrapperCfg
(
SDnode
*
pDnode
,
SCreateVnodeReq
*
pCreate
,
SWrapperCfg
*
pCfg
)
{
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
a17e3f32
...
...
@@ -215,6 +215,9 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq
.
replica
=
pVgroup
->
replica
;
createReq
.
selfIndex
=
-
1
;
createReq
.
streamMode
=
pVgroup
->
streamMode
;
createReq
.
hashBegin
=
pVgroup
->
hashBegin
;
createReq
.
hashEnd
=
pVgroup
->
hashEnd
;
createReq
.
hashMethod
=
pDb
->
hashMethod
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
a17e3f32
...
...
@@ -57,6 +57,9 @@ typedef struct {
SMetaCfg
metaCfg
;
STqCfg
tqCfg
;
SWalCfg
walCfg
;
uint32_t
hashBegin
;
uint32_t
hashEnd
;
int8_t
hashMethod
;
}
SVnodeCfg
;
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
a17e3f32
...
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
char
name
[
pathLen
+
10
];
strcpy
(
name
,
path
);
if
(
taosDirExist
(
name
)
!=
0
&&
taosMkDir
(
name
)
!=
0
)
{
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
a17e3f32
...
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmadF
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmadF
))
)
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
...
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
if
((
pCommith
->
isLFileSame
)
&&
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmalF
))
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
a17e3f32
...
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
if
(
access
(
current
,
F_OK
)
==
0
)
{
if
(
taosCheckExistFile
(
current
)
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
a17e3f32
...
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
struct
stat
dfstat
;
SDFile
df
;
tsdbInitDFileEx
(
&
df
,
pDFile
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pDFile
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pDFile
))
)
{
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
}
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
dfstat
)
<
0
)
{
int64_t
file_size
=
0
;
if
(
taosStatFile
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
file_size
,
NULL
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
pDFile
->
info
.
size
<
dfstat
.
st
_size
)
{
if
(
pDFile
->
info
.
size
<
file
_size
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
...
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
tsdbCloseDFile
(
&
df
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
dfstat
.
st
_size
)
{
file
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
file
_size
)
{
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
file
_size
,
pDFile
->
info
.
size
);
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
a17e3f32
...
...
@@ -30,6 +30,9 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
cfg
.
pDnode
=
pVnodeCfg
->
pDnode
;
cfg
.
pTfs
=
pVnodeCfg
->
pTfs
;
cfg
.
dbId
=
pVnodeCfg
->
dbId
;
cfg
.
hashBegin
=
pVnodeCfg
->
hashBegin
;
cfg
.
hashEnd
=
pVnodeCfg
->
hashEnd
;
cfg
.
hashMethod
=
pVnodeCfg
->
hashMethod
;
}
// Validate options
...
...
source/libs/CMakeLists.txt
浏览文件 @
a17e3f32
add_definitions
(
"-D ALLOW_FORBID_FUNC"
)
add_subdirectory
(
transport
)
add_subdirectory
(
sync
)
add_subdirectory
(
tdb
)
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
a17e3f32
...
...
@@ -60,6 +60,7 @@ typedef struct SCtgDebug {
bool
lockDebug
;
bool
cacheDebug
;
bool
apiDebug
;
bool
metaDebug
;
uint32_t
showCachePeriodSec
;
}
SCtgDebug
;
...
...
@@ -119,6 +120,10 @@ typedef struct SCatalogStat {
SCtgCacheStat
cache
;
}
SCatalogStat
;
typedef
struct
SCtgUpdateMsgHeader
{
SCatalog
*
pCtg
;
}
SCtgUpdateMsgHeader
;
typedef
struct
SCtgUpdateVgMsg
{
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
...
@@ -145,6 +150,14 @@ typedef struct SCtgRemoveStbMsg {
uint64_t
suid
;
}
SCtgRemoveStbMsg
;
typedef
struct
SCtgRemoveTblMsg
{
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
tbName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
dbId
;
}
SCtgRemoveTblMsg
;
typedef
struct
SCtgMetaAction
{
int32_t
act
;
void
*
data
;
...
...
@@ -193,15 +206,17 @@ typedef struct SCtgAction {
#define CTG_FLAG_NOT_STB 0x2
#define CTG_FLAG_UNKNOWN_STB 0x4
#define CTG_FLAG_INF_DB 0x8
#define CTG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB)
#define CTG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB)
#define CTG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB)
#define CTG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB)
#define CTG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB)
#define CTG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0)
#define CTG_GEN_STB_FLAG(_isStb) ((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)
#define CTG_TBTYPE_MATCH(_flag, tbType) (CTG_IS_UNKNOWN_STB(_flag) || (CTG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
#define CTG_FLAG_FORCE_UPDATE 0x10
#define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB)
#define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB)
#define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB)
#define CTG_FLAG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB)
#define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE)
#define CTG_FLAG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB)
#define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0)
#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB))
#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB)))
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
a17e3f32
...
...
@@ -72,6 +72,12 @@ int32_t ctgDbgEnableDebug(char *option) {
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcasecmp
(
option
,
"meta"
))
{
gCTGDebug
.
metaDebug
=
true
;
qDebug
(
"api debug enabled"
);
return
TSDB_CODE_SUCCESS
;
}
qError
(
"invalid debug option:%s"
,
option
);
return
TSDB_CODE_CTG_INTERNAL_ERROR
;
...
...
@@ -148,9 +154,30 @@ int32_t ctgDbgGetClusterCacheNum(SCatalog* pCtg, int32_t type) {
return
num
;
}
void
ctgDbgShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
if
(
!
gCTGDebug
.
metaDebug
)
{
return
;
}
STableComInfo
*
c
=
&
p
->
tableInfo
;
void
ctgDbgShowDBCache
(
SHashObj
*
dbHash
)
{
if
(
NULL
==
dbHash
)
{
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
return
;
}
else
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
SSchema
*
s
=
&
p
->
schema
[
i
];
ctgDebug
(
"[%d] name:%s, type:%d, colId:%d, bytes:%d"
,
i
,
s
->
name
,
s
->
type
,
s
->
colId
,
s
->
bytes
);
}
}
void
ctgDbgShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
if
(
NULL
==
dbHash
||
!
gCTGDebug
.
cacheDebug
)
{
return
;
}
...
...
@@ -165,29 +192,22 @@ void ctgDbgShowDBCache(SHashObj *dbHash) {
taosHashGetKey
(
dbCache
,
(
void
**
)
&
dbFName
,
&
len
);
CTG_CACHE_DEBUG
(
"** %dth db [%.*s][%"
PRIx64
"] **"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
);
int32_t
metaNum
=
dbCache
->
tbCache
.
metaCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
tbCache
.
stbCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
hashMethod
=
-
1
;
int32_t
vgNum
=
0
;
CTG_CACHE_DEBUG
(
"deleted: %d"
,
dbCache
->
deleted
);
if
(
dbCache
->
vgInfo
)
{
CTG_CACHE_DEBUG
(
"vgVersion: %d"
,
dbCache
->
vgInfo
->
vgVersion
)
;
CTG_CACHE_DEBUG
(
"hashMethod: %d"
,
dbCache
->
vgInfo
->
hashMethod
)
;
vgVersion
=
dbCache
->
vgInfo
->
vgVersion
;
hashMethod
=
dbCache
->
vgInfo
->
hashMethod
;
if
(
dbCache
->
vgInfo
->
vgHash
)
{
CTG_CACHE_DEBUG
(
"vgNum: %d"
,
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
));
//TODO
}
else
{
CTG_CACHE_DEBUG
(
"vgHash: %p"
,
dbCache
->
vgInfo
->
vgHash
);
}
}
else
{
CTG_CACHE_DEBUG
(
"vgInfo: %p"
,
dbCache
->
vgInfo
);
vgNum
=
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
}
if
(
dbCache
->
tbCache
.
metaCache
)
{
CTG_CACHE_DEBUG
(
"metaNum: %d"
,
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
));
}
if
(
dbCache
->
tbCache
.
stbCache
)
{
CTG_CACHE_DEBUG
(
"stbNum: %d"
,
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
));
}
ctgDebug
(
"[%d] db [%.*s][%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
...
...
@@ -197,15 +217,15 @@ void ctgDbgShowDBCache(SHashObj *dbHash) {
void
ctgDbgShowClusterCache
(
SCatalog
*
pCtg
)
{
if
(
NULL
==
pCtg
)
{
if
(
!
gCTGDebug
.
cacheDebug
||
NULL
==
pCtg
)
{
return
;
}
CTG_CACHE_DEBUG
(
"## cluster %"
PRIx64
" %p cache Info ##"
,
pCtg
->
clusterId
,
pCtg
);
CTG_CACHE_DEBUG
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgDebug
(
"## cluster %"
PRIx64
" %p cache Info ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgDbgShowDBCache
(
pCtg
->
dbCache
);
ctgDbgShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
}
...
...
@@ -292,6 +312,66 @@ _return:
}
int32_t
ctgPushRmStbMsgInQueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
stbName
,
uint64_t
suid
)
{
int32_t
code
=
0
;
SCtgMetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_STB
};
SCtgRemoveStbMsg
*
msg
=
malloc
(
sizeof
(
SCtgRemoveStbMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveStbMsg
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
strncpy
(
msg
->
dbFName
,
dbFName
,
sizeof
(
msg
->
dbFName
));
strncpy
(
msg
->
stbName
,
stbName
,
sizeof
(
msg
->
stbName
));
msg
->
dbId
=
dbId
;
msg
->
suid
=
suid
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctgPushAction
(
&
action
));
ctgDebug
(
"action [%s] added into queue"
,
gCtgAction
[
action
.
act
].
name
);
return
TSDB_CODE_SUCCESS
;
_return:
tfree
(
action
.
data
);
CTG_RET
(
code
);
}
int32_t
ctgPushRmTblMsgInQueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
)
{
int32_t
code
=
0
;
SCtgMetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_TBL
};
SCtgRemoveTblMsg
*
msg
=
malloc
(
sizeof
(
SCtgRemoveTblMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveTblMsg
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
strncpy
(
msg
->
dbFName
,
dbFName
,
sizeof
(
msg
->
dbFName
));
strncpy
(
msg
->
tbName
,
tbName
,
sizeof
(
msg
->
tbName
));
msg
->
dbId
=
dbId
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctgPushAction
(
&
action
));
ctgDebug
(
"action [%s] added into queue"
,
gCtgAction
[
action
.
act
].
name
);
return
TSDB_CODE_SUCCESS
;
_return:
tfree
(
action
.
data
);
CTG_RET
(
code
);
}
void
ctgFreeTableMetaCache
(
SCtgTbMetaCache
*
cache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
cache
->
stbLock
);
if
(
cache
->
stbCache
)
{
...
...
@@ -554,7 +634,7 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName,
}
int32_t
ctgGetTableMetaFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
,
int32_t
flag
)
{
int32_t
ctgGetTableMetaFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
,
int32_t
flag
,
uint64_t
*
dbId
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
*
exist
=
0
;
ctgWarn
(
"empty tbmeta cache, tbName:%s"
,
pTableName
->
tname
);
...
...
@@ -562,7 +642,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
}
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
if
(
CTG_IS_INF_DB
(
flag
))
{
if
(
CTG_
FLAG_
IS_INF_DB
(
flag
))
{
strcpy
(
dbFName
,
pTableName
->
dbname
);
}
else
{
tNameGetFullDbName
(
pTableName
,
dbFName
);
...
...
@@ -590,6 +670,9 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
}
*
exist
=
1
;
if
(
dbId
)
{
*
dbId
=
dbCache
->
dbId
;
}
tbMeta
=
*
pTableMeta
;
...
...
@@ -646,7 +729,7 @@ int32_t ctgGetTableTypeFromCache(SCatalog* pCtg, const SName* pTableName, int32_
}
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
if
(
CTG_IS_INF_DB
(
flag
))
{
if
(
CTG_
FLAG_
IS_INF_DB
(
flag
))
{
strcpy
(
dbFName
,
pTableName
->
dbname
);
}
else
{
tNameGetFullDbName
(
pTableName
,
dbFName
);
...
...
@@ -1304,9 +1387,9 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
STableMeta
*
orig
=
taosHashGet
(
tbCache
->
metaCache
,
tbName
,
strlen
(
tbName
));
if
(
orig
)
{
origType
=
orig
->
tableType
;
origSuid
=
orig
->
suid
;
if
(
origType
==
TSDB_SUPER_TABLE
&&
((
!
isStb
)
||
origSuid
!=
meta
->
suid
))
{
if
(
origType
==
TSDB_SUPER_TABLE
)
{
if
((
!
isStb
)
||
orig
->
suid
!=
meta
->
suid
)
{
CTG_LOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
if
(
taosHashRemove
(
tbCache
->
stbCache
,
&
orig
->
suid
,
sizeof
(
orig
->
suid
)))
{
ctgError
(
"stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
...
...
@@ -1317,6 +1400,9 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
orig
->
suid
,
ctgStbVersionCompare
);
}
origSuid
=
orig
->
suid
;
}
}
if
(
isStb
)
{
...
...
@@ -1334,13 +1420,14 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
}
ctgDebug
(
"tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d"
,
dbFName
,
tbName
,
meta
->
tableType
);
ctgDbgShowTableMeta
(
pCtg
,
tbName
,
meta
);
if
(
!
isStb
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
return
TSDB_CODE_SUCCESS
;
}
if
(
isStb
&&
origSuid
==
meta
->
suid
)
{
if
(
origType
==
TSDB_SUPER_TABLE
&&
origSuid
==
meta
->
suid
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1506,7 +1593,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
SVgroupInfo
vgroupInfo
=
{
0
};
int32_t
code
=
0
;
if
(
!
CTG_IS_INF_DB
(
flag
))
{
if
(
!
CTG_
FLAG_
IS_INF_DB
(
flag
))
{
CTG_ERR_RET
(
catalogGetTableHashVgroup
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
));
}
...
...
@@ -1518,11 +1605,11 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
if
(
CTG_IS_INF_DB
(
flag
))
{
if
(
CTG_
FLAG_
IS_INF_DB
(
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed in information_schema, tbName:%s"
,
tNameGetTableName
(
pTableName
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCtg
,
pTrans
,
pMgmtEps
,
(
char
*
)
pTableName
->
dbname
,
(
char
*
)
pTableName
->
tname
,
output
));
}
else
if
(
CTG_IS_STB
(
flag
))
{
}
else
if
(
CTG_
FLAG_
IS_STB
(
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed to be stb, tbName:%s"
,
tNameGetTableName
(
pTableName
));
// if get from mnode failed, will not try vnode
...
...
@@ -1538,14 +1625,17 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
output
));
if
(
CTG_IS_META_TABLE
(
output
->
metaType
)
&&
TSDB_SUPER_TABLE
==
output
->
tbMeta
->
tableType
)
{
ctgDebug
(
"will continue to refresh tbmeta since got stb, tbName:%s
, metaType:%d"
,
tNameGetTableName
(
pTableName
),
output
->
metaType
);
ctgDebug
(
"will continue to refresh tbmeta since got stb, tbName:%s
"
,
tNameGetTableName
(
pTableName
)
);
tfree
(
output
->
tbMeta
);
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCtg
,
pTrans
,
pMgmtEps
,
output
->
dbFName
,
output
->
tbName
,
output
));
}
else
if
(
CTG_IS_META_BOTH
(
output
->
metaType
))
{
int32_t
exist
=
0
;
if
(
!
CTG_FLAG_IS_FORCE_UPDATE
(
flag
))
{
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCtg
,
output
->
dbFName
,
output
->
tbName
,
&
exist
));
}
if
(
0
==
exist
)
{
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCtg
,
pTrans
,
pMgmtEps
,
output
->
dbFName
,
output
->
tbName
,
&
moutput
));
...
...
@@ -1606,35 +1696,40 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgGetTableMeta
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
bool
forceUpdate
,
STableMeta
**
pTableMeta
,
int32_t
flag
)
{
int32_t
ctgGetTableMeta
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
flag
)
{
if
(
NULL
==
pCtg
||
NULL
==
pRpc
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
||
NULL
==
pTableMeta
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
exist
=
0
;
int32_t
code
=
0
;
uint64_t
dbId
=
0
;
uint64_t
suid
=
0
;
STableMetaOutput
*
output
=
NULL
;
if
(
CTG_IS_INF_DBNAME
(
pTableName
->
dbname
))
{
CTG_SET_INF_DB
(
flag
);
CTG_
FLAG_
SET_INF_DB
(
flag
);
}
if
((
!
forceUpdate
)
||
(
CTG_IS_INF_DB
(
flag
)))
{
CTG_ERR_RET
(
ctgGetTableMetaFromCache
(
pCtg
,
pTableName
,
pTableMeta
,
&
exist
,
flag
));
CTG_ERR_RET
(
ctgGetTableMetaFromCache
(
pCtg
,
pTableName
,
pTableMeta
,
&
exist
,
flag
,
&
dbId
));
if
(
exist
&&
CTG_TBTYPE_MATCH
(
flag
,
(
*
pTableMeta
)
->
tableType
))
{
return
TSDB_CODE_SUCCESS
;
int32_t
tbType
=
0
;
if
(
exist
)
{
if
(
CTG_FLAG_MATCH_STB
(
flag
,
(
*
pTableMeta
)
->
tableType
)
&&
((
!
CTG_FLAG_IS_FORCE_UPDATE
(
flag
))
||
(
CTG_FLAG_IS_INF_DB
(
flag
))))
{
goto
_return
;
}
tfree
(
*
pTableMeta
);
}
else
if
(
CTG_IS_UNKNOWN_STB
(
flag
))
{
int32_t
tbType
=
0
;
tbType
=
(
*
pTableMeta
)
->
tableType
;
suid
=
(
*
pTableMeta
)
->
suid
;
CTG_ERR_RET
(
ctgGetTableTypeFromCache
(
pCtg
,
pTableName
,
&
tbType
,
flag
));
tfree
(
*
pTableMeta
);
}
CTG_SET_STB
(
flag
,
tbType
);
if
(
CTG_FLAG_IS_UNKNOWN_STB
(
flag
))
{
CTG_FLAG_SET_STB
(
flag
,
tbType
);
}
STableMetaOutput
*
output
=
NULL
;
while
(
true
)
{
CTG_ERR_JRET
(
ctgRefreshTblMeta
(
pCtg
,
pRpc
,
pMgmtEps
,
pTableName
,
flag
,
&
output
));
...
...
@@ -1662,7 +1757,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
SName
stbName
=
*
pTableName
;
strcpy
(
stbName
.
tname
,
output
->
tbName
);
CTG_ERR_JRET
(
ctgGetTableMetaFromCache
(
pCtg
,
&
stbName
,
pTableMeta
,
&
exist
,
flag
));
CTG_ERR_JRET
(
ctgGetTableMetaFromCache
(
pCtg
,
&
stbName
,
pTableMeta
,
&
exist
,
flag
,
NULL
));
if
(
0
==
exist
)
{
ctgDebug
(
"stb no longer exist, dbFName:%s, tbName:%s"
,
output
->
dbFName
,
pTableName
->
tname
);
continue
;
...
...
@@ -1675,10 +1770,26 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
_return:
if
(
CTG_TABLE_NOT_EXIST
(
code
)
&&
exist
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
if
(
CTG_FLAG_IS_INF_DB
(
flag
))
{
strcpy
(
dbFName
,
pTableName
->
dbname
);
}
else
{
tNameGetFullDbName
(
pTableName
,
dbFName
);
}
if
(
TSDB_SUPER_TABLE
==
tbType
)
{
ctgPushRmStbMsgInQueue
(
pCtg
,
dbFName
,
dbId
,
pTableName
->
tname
,
suid
);
}
else
{
ctgPushRmTblMsgInQueue
(
pCtg
,
dbFName
,
dbId
,
pTableName
->
tname
);
}
}
tfree
(
output
);
if
(
*
pTableMeta
)
{
ctgDebug
(
"tbmeta returned, tbName:%s, tbType:%d"
,
pTableName
->
tname
,
(
*
pTableMeta
)
->
tableType
);
ctgDbgShowTableMeta
(
pCtg
,
pTableName
->
tname
,
*
pTableMeta
);
}
CTG_RET
(
code
);
...
...
@@ -1694,7 +1805,7 @@ int32_t ctgActUpdateVg(SCtgMetaAction *action) {
_return:
tfree
(
msg
->
dbInfo
);
ctgFreeVgInfo
(
msg
->
dbInfo
);
tfree
(
msg
);
CTG_RET
(
code
);
...
...
@@ -1780,7 +1891,6 @@ _return:
int32_t
ctgActRemoveStb
(
SCtgMetaAction
*
action
)
{
int32_t
code
=
0
;
SCtgRemoveStbMsg
*
msg
=
action
->
data
;
bool
removed
=
false
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
...
...
@@ -1826,7 +1936,36 @@ _return:
}
int32_t
ctgActRemoveTbl
(
SCtgMetaAction
*
action
)
{
int32_t
code
=
0
;
SCtgRemoveTblMsg
*
msg
=
action
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
ctgGetDBCache
(
pCtg
,
msg
->
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
dbCache
->
dbId
!=
msg
->
dbId
)
{
ctgDebug
(
"dbId already modified, dbFName:%s, current:%"
PRIx64
", dbId:%"
PRIx64
", tbName:%s"
,
msg
->
dbFName
,
dbCache
->
dbId
,
msg
->
dbId
,
msg
->
tbName
);
return
TSDB_CODE_SUCCESS
;
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
taosHashRemove
(
dbCache
->
tbCache
.
metaCache
,
msg
->
tbName
,
strlen
(
msg
->
tbName
)))
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctgError
(
"stb not exist in cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctgInfo
(
"table removed from cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
_return:
tfree
(
msg
);
CTG_RET
(
code
);
}
...
...
@@ -1846,12 +1985,15 @@ void* ctgUpdateThreadFunc(void* param) {
SCtgMetaAction
*
action
=
NULL
;
ctgPopAction
(
&
action
);
SCatalog
*
pCtg
=
((
SCtgUpdateMsgHeader
*
)
action
->
data
)
->
pCtg
;
qDebug
(
"process %s
action"
,
gCtgAction
[
action
->
act
].
name
);
ctgDebug
(
"process [%s]
action"
,
gCtgAction
[
action
->
act
].
name
);
(
*
gCtgAction
[
action
->
act
].
func
)(
action
);
CTG_STAT_ADD
(
gCtgMgmt
.
stat
.
runtime
.
qDoneNum
);
ctgDbgShowClusterCache
(
pCtg
);
}
CTG_UNLOCK
(
CTG_READ
,
&
gCtgMgmt
.
lock
);
...
...
@@ -2121,22 +2263,20 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId
strncpy
(
msg
->
dbFName
,
dbFName
,
sizeof
(
msg
->
dbFName
));
msg
->
dbId
=
dbId
;
msg
->
dbInfo
=
dbInfo
;
dbInfo
=
NULL
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctgPushAction
(
&
action
));
dbInfo
=
NULL
;
ctgDebug
(
"action [%s] added into queue"
,
gCtgAction
[
action
.
act
].
name
);
CTG_API_LEAVE
(
code
);
_return:
if
(
dbInfo
)
{
taosHashCleanup
(
dbInfo
->
vgHash
);
tfree
(
dbInfo
);
}
ctgFreeVgInfo
(
dbInfo
);
tfree
(
msg
);
...
...
@@ -2179,31 +2319,12 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId,
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
SCtgMetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_STB
};
SCtgRemoveStbMsg
*
msg
=
malloc
(
sizeof
(
SCtgRemoveStbMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveStbMsg
));
CTG_API_LEAVE
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
strncpy
(
msg
->
dbFName
,
dbFName
,
sizeof
(
msg
->
dbFName
));
strncpy
(
msg
->
stbName
,
stbName
,
sizeof
(
msg
->
stbName
));
msg
->
dbId
=
dbId
;
msg
->
suid
=
suid
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctgPushAction
(
&
action
));
ctgDebug
(
"action [%s] added into queue"
,
gCtgAction
[
action
.
act
].
name
);
CTG_ERR_JRET
(
ctgPushRmStbMsgInQueue
(
pCtg
,
dbFName
,
dbId
,
stbName
,
suid
));
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
_return:
tfree
(
action
.
data
);
CTG_API_LEAVE
(
code
);
}
...
...
@@ -2211,13 +2332,13 @@ _return:
int32_t
catalogGetTableMeta
(
SCatalog
*
pCtg
,
void
*
pTrans
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
false
,
pTableMeta
,
CTG_FLAG_UNKNOWN_STB
));
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
pTableMeta
,
CTG_FLAG_UNKNOWN_STB
));
}
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
void
*
pTrans
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
false
,
pTableMeta
,
CTG_FLAG_STB
));
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
pTableMeta
,
CTG_FLAG_STB
));
}
int32_t
catalogUpdateSTableMeta
(
SCatalog
*
pCtg
,
STableMetaRsp
*
rspMsg
)
{
...
...
@@ -2279,13 +2400,13 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgm
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
CTG_API_LEAVE
(
ctgRefreshTblMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
CTG_
GEN_STB_FLAG
(
isSTable
),
NULL
));
CTG_API_LEAVE
(
ctgRefreshTblMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
CTG_
FLAG_FORCE_UPDATE
|
CTG_FLAG_MAKE_STB
(
isSTable
),
NULL
));
}
int32_t
catalogRefreshGetTableMeta
(
SCatalog
*
pCtg
,
void
*
pTrans
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
true
,
pTableMeta
,
CTG_GEN_STB_FLAG
(
isSTable
)));
CTG_API_LEAVE
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
pTableName
,
pTableMeta
,
CTG_FLAG_FORCE_UPDATE
|
CTG_FLAG_MAKE_STB
(
isSTable
)));
}
int32_t
catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
...
...
@@ -2309,7 +2430,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
*
pVgList
=
NULL
;
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCtg
,
pRpc
,
pMgmtEps
,
pTableName
,
false
,
&
tbMeta
,
CTG_FLAG_UNKNOWN_STB
));
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCtg
,
pRpc
,
pMgmtEps
,
pTableName
,
&
tbMeta
,
CTG_FLAG_UNKNOWN_STB
));
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
...
...
@@ -2441,7 +2562,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
SName
*
name
=
taosArrayGet
(
pReq
->
pTableName
,
i
);
STableMeta
*
pTableMeta
=
NULL
;
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
name
,
false
,
&
pTableMeta
,
CTG_FLAG_UNKNOWN_STB
));
CTG_ERR_JRET
(
ctgGetTableMeta
(
pCtg
,
pTrans
,
pMgmtEps
,
name
,
&
pTableMeta
,
CTG_FLAG_UNKNOWN_STB
));
if
(
NULL
==
taosArrayPush
(
pRsp
->
pTableMeta
,
&
pTableMeta
))
{
ctgError
(
"taosArrayPush failed, idx:%d"
,
i
);
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/libs/executor/src/executorimpl.c
浏览文件 @
a17e3f32
...
...
@@ -2215,10 +2215,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
if
(
pColInfoData
)
{
FILE
*
f
=
*
(
FILE
*
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
f
)
{
fclose
(
f
);
*
(
FILE
*
*
)
pColInfoData
->
pData
=
NULL
;
TdFilePtr
pFile
=
*
(
TdFilePtr
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
pFile
!=
NULL
)
{
taosCloseFile
(
&
pFile
);
*
(
TdFilePtr
*
)
pColInfoData
->
pData
=
NULL
;
}
}
}
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,10 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <executorimpl.h>
#include <function.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,6 +23,9 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "tglobal.h"
#include "executorimpl.h"
#include "function.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
source/libs/executor/test/sortTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <executorimpl.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tsort.h>
...
...
@@ -26,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "stub.h"
#include "taos.h"
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
a17e3f32
...
...
@@ -122,30 +122,53 @@ typedef struct TFileCacheKey {
int
indexFlushCacheToTFile
(
SIndex
*
sIdx
,
void
*
);
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
#define indexFatal(...) \
do { \
if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("index FATAL ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_FATAL) { \
taosPrintLog("index FATAL ", 255, __VA_ARGS__); \
} \
} while (0)
#define indexError(...) \
do { \
if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("index ERROR ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_ERROR) { \
taosPrintLog("index ERROR ", 255, __VA_ARGS__); \
} \
} while (0)
#define indexWarn(...) \
do { \
if (sDebugFlag & DEBUG_WARN) { taosPrintLog("index WARN ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_WARN) { \
taosPrintLog("index WARN ", 255, __VA_ARGS__); \
} \
} while (0)
#define indexInfo(...) \
do { \
if (sDebugFlag & DEBUG_INFO) { taosPrintLog("index ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_INFO) { \
taosPrintLog("index ", 255, __VA_ARGS__); \
} \
} while (0)
#define indexDebug(...) \
do { \
if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
} \
} while (0)
#define indexTrace(...) \
do { \
if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_TRACE) { \
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
} \
} while (0)
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
#define INDEX_TYPE_GET_TYPE(ty) (ty & 0x0F)
#define INDEX_TYPE_ADD_EXTERN_TYPE(ty, exTy) \
do { \
uint8_t oldTy = ty; \
ty = (ty >> 4) | exTy; \
ty = (ty << 4) | oldTy; \
} while (0)
#ifdef __cplusplus
...
...
source/libs/index/inc/index_comm.h
0 → 100644
浏览文件 @
a17e3f32
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_INDEX_COMM_H_
#define _TD_INDEX_COMM_H_
#ifdef __cplusplus
extern
"C"
{
#endif
extern
char
JSON_COLUMN
[];
extern
char
JSON_VALUE_DELIM
;
char
*
indexPackJsonData
(
SIndexTerm
*
itm
);
#ifdef __cplusplus
}
#endif
#endif
source/libs/index/src/index.c
浏览文件 @
a17e3f32
...
...
@@ -2,8 +2,8 @@
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
*
or later ("AGPL"), as published by the Free
Software Foundation.
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -30,6 +30,8 @@
void
*
indexQhandle
=
NULL
;
static
char
JSON_COLUMN
[]
=
"JSON"
;
void
indexInit
()
{
// refactor later
indexQhandle
=
taosInitScheduler
(
INDEX_QUEUE_SIZE
,
INDEX_NUM_OF_THREADS
,
"index"
);
...
...
@@ -63,6 +65,9 @@ static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch);
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
);
static
void
indexMergeSameKey
(
SArray
*
result
,
TFileValue
*
tv
);
// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
int
indexOpen
(
SIndexOpts
*
opts
,
const
char
*
path
,
SIndex
**
index
)
{
pthread_once
(
&
isInit
,
indexInit
);
SIndex
*
sIdx
=
calloc
(
1
,
sizeof
(
SIndex
));
...
...
@@ -148,7 +153,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)
,
.
colType
=
p
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
...
...
@@ -163,7 +168,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)
,
.
colType
=
p
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
...
...
@@ -330,7 +335,8 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
IndexCache
*
cache
=
NULL
;
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
term
->
suid
,
.
colName
=
term
->
colName
,
.
nColName
=
strlen
(
term
->
colName
)};
ICacheKey
key
=
{
.
suid
=
term
->
suid
,
.
colName
=
term
->
colName
,
.
nColName
=
strlen
(
term
->
colName
),
.
colType
=
term
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
pthread_mutex_lock
(
&
sIdx
->
mtx
);
...
...
@@ -555,11 +561,17 @@ END:
}
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
key
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
buf
;
SERIALIZE_MEM_TO_BUF
(
buf
,
key
,
suid
);
SERIALIZE_VAR_TO_BUF
(
buf
,
'_'
,
char
);
// SERIALIZE_MEM_TO_BUF(buf, key, colType);
// SERIALIZE_VAR_TO_BUF(buf, '_', char);
if
(
hasJson
)
{
SERIALIZE_STR_VAR_TO_BUF
(
buf
,
JSON_COLUMN
,
strlen
(
JSON_COLUMN
));
}
else
{
SERIALIZE_STR_MEM_TO_BUF
(
buf
,
key
,
colName
,
key
->
nColName
);
}
return
buf
-
p
;
}
source/libs/index/src/index_cache.c
浏览文件 @
a17e3f32
...
...
@@ -14,6 +14,7 @@
*/
#include "index_cache.h"
#include "index_comm.h"
#include "index_util.h"
#include "tcompare.h"
#include "tsched.h"
...
...
@@ -44,8 +45,9 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in
indexError
(
"failed to create index cache"
);
return
NULL
;
};
cache
->
mem
=
indexInternalCacheCreate
(
type
);
cache
->
colName
=
tstrdup
(
colName
);
cache
->
colName
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
type
,
TSDB_DATA_TYPE_JSON
)
?
tstrdup
(
JSON_COLUMN
)
:
tstrdup
(
colName
);
cache
->
type
=
type
;
cache
->
index
=
idx
;
cache
->
version
=
0
;
...
...
@@ -207,11 +209,11 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
}
}
}
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
uint64_t
uid
)
{
if
(
cache
==
NULL
)
{
return
-
1
;
}
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
IndexCache
*
pCache
=
cache
;
indexCacheRef
(
pCache
);
...
...
@@ -222,8 +224,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
}
// set up key
ct
->
colType
=
term
->
colType
;
if
(
hasJson
)
{
ct
->
colVal
=
indexPackJsonData
(
term
);
}
else
{
ct
->
colVal
=
(
char
*
)
calloc
(
1
,
sizeof
(
char
)
*
(
term
->
nColVal
+
1
));
memcpy
(
ct
->
colVal
,
term
->
colVal
,
term
->
nColVal
);
}
ct
->
version
=
atomic_add_fetch_32
(
&
pCache
->
version
,
1
);
// set value
ct
->
uid
=
uid
;
...
...
@@ -294,13 +300,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
CacheTerm
ct
=
{.
colVal
=
term
->
colVal
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
term
->
colVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
term
);
}
CacheTerm
ct
=
{.
colVal
=
p
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
// continue search in imm
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
}
if
(
hasJson
)
{
tfree
(
p
);
}
indexMemUnRef
(
mem
);
indexMemUnRef
(
imm
);
...
...
@@ -367,6 +382,8 @@ static int32_t indexCacheTermCompare(const void* l, const void* r) {
}
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
)
{
type
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
type
,
TSDB_DATA_TYPE_JSON
)
?
TSDB_DATA_TYPE_BINARY
:
type
;
MemTable
*
tbl
=
calloc
(
1
,
sizeof
(
MemTable
));
indexMemRef
(
tbl
);
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
...
@@ -389,9 +406,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
IterateValue
*
iv
=
&
itera
->
val
;
iterateValueDestroy
(
iv
,
false
);
// IterateValue* iv = &itera->val;
// IterateValue tIterVal = {.colVal = NULL, .val = taosArrayInit(1, sizeof(uint64_t))};
bool
next
=
tSkipListIterNext
(
iter
);
if
(
next
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
...
...
@@ -411,10 +425,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
}
// IterateValue* iv = &itera->val;
// iterateValueDestroy(iv, true);
//*iv = tIterVal;
return
next
;
}
...
...
source/libs/index/src/index_comm.c
0 → 100644
浏览文件 @
a17e3f32
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "index.h"
#include "indexInt.h"
char
JSON_COLUMN
[]
=
"JSON"
;
char
JSON_VALUE_DELIM
=
'&'
;
char
*
indexPackJsonData
(
SIndexTerm
*
itm
)
{
/*
* |<-----colname---->|<-----dataType---->|<--------colVal---------->|
* |<-----string----->|<-----uint8_t----->|<----depend on dataType-->|
*/
uint8_t
ty
=
INDEX_TYPE_GET_TYPE
(
itm
->
colType
);
int32_t
sz
=
itm
->
nColName
+
itm
->
nColVal
+
sizeof
(
uint8_t
)
+
sizeof
(
JSON_VALUE_DELIM
)
*
2
+
1
;
char
*
buf
=
(
char
*
)
calloc
(
1
,
sz
);
char
*
p
=
buf
;
memcpy
(
p
,
itm
->
colName
,
itm
->
nColName
);
p
+=
itm
->
nColName
;
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
p
+=
sizeof
(
JSON_VALUE_DELIM
);
memcpy
(
p
,
&
ty
,
sizeof
(
ty
));
p
+=
sizeof
(
ty
);
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
p
+=
sizeof
(
JSON_VALUE_DELIM
);
memcpy
(
p
,
itm
->
colVal
,
itm
->
nColVal
);
return
buf
;
}
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
a17e3f32
...
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
struct
stat
fstat
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
return
fstat
.
st
_size
;
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
return
(
int
)
file
_size
;
}
return
0
;
}
...
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
struct
stat
fstat
;
stat
(
path
,
&
fstat
);
ctx
->
file
.
size
=
fstat
.
st
_size
;
int64_t
file_size
=
0
;
taosFStatFile
(
ctx
->
file
.
pFile
,
&
file_size
,
NULL
);
ctx
->
file
.
size
=
(
int
)
file
_size
;
#ifdef USE_MMAP
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
#endif
...
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
#endif
}
if
(
ctx
->
file
.
readOnly
==
false
)
{
struct
stat
fstat
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
// struct stat fstat;
// stat(ctx->file.buf, &fstat);
// indexError("write file size: %d", (int)(fstat.st_size));
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
...
...
source/libs/index/src/index_json.c
0 → 100644
浏览文件 @
a17e3f32
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "index.h"
#include "indexInt.h"
int
tIndexJsonOpen
(
SIndexJsonOpts
*
opts
,
const
char
*
path
,
SIndexJson
**
index
)
{
// handle
return
indexOpen
(
opts
,
path
,
index
);
}
int
tIndexJsonPut
(
SIndexJson
*
index
,
SIndexJsonMultiTerm
*
terms
,
uint64_t
uid
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
terms
);
i
++
)
{
SIndexJsonTerm
*
p
=
taosArrayGetP
(
terms
,
i
);
INDEX_TYPE_ADD_EXTERN_TYPE
(
p
->
colType
,
TSDB_DATA_TYPE_JSON
);
}
return
indexPut
(
index
,
terms
,
uid
);
// handle put
}
int
tIndexJsonSearch
(
SIndexJson
*
index
,
SIndexJsonMultiTermQuery
*
tq
,
SArray
*
result
)
{
SArray
*
terms
=
tq
->
query
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
terms
);
i
++
)
{
SIndexJsonTerm
*
p
=
taosArrayGetP
(
terms
,
i
);
INDEX_TYPE_ADD_EXTERN_TYPE
(
p
->
colType
,
TSDB_DATA_TYPE_JSON
);
}
return
indexSearch
(
index
,
tq
,
result
);
// handle search
}
void
tIndexJsonClose
(
SIndexJson
*
index
)
{
return
indexClose
(
index
);
// handle close
}
source/libs/index/src/index_tfile.c
浏览文件 @
a17e3f32
...
...
@@ -15,6 +15,7 @@ p *
#include "index_tfile.h"
#include "index.h"
#include "index_comm.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_util.h"
...
...
@@ -186,13 +187,20 @@ void tfileReaderDestroy(TFileReader* reader) {
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
SIndexTerm
*
term
=
query
->
term
;
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
EIndexQueryType
qtype
=
query
->
qType
;
int
ret
=
-
1
;
// refactor to callback later
if
(
qtype
==
QUERY_TERM
)
{
uint64_t
offset
;
FstSlice
key
=
fstSliceCreate
(
term
->
colVal
,
term
->
nColVal
);
char
*
p
=
term
->
colVal
;
uint64_t
sz
=
term
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
term
);
sz
=
strlen
(
p
);
}
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
...
...
@@ -202,10 +210,17 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
term
->
colVal
);
}
fstSliceDestroy
(
&
key
);
if
(
hasJson
)
{
free
(
p
);
}
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
// handle later
//
}
else
{
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_REGEX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_RANGE
)
{
// handle later
}
tfileReaderUnRef
(
reader
);
...
...
@@ -260,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
__compar_fn_t
fn
;
int8_t
colType
=
tw
->
header
.
colType
;
colType
=
INDEX_TYPE_GET_TYPE
(
colType
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
fn
=
tfileStrCompare
;
}
else
{
...
...
@@ -557,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) {
static
int
tfileWriteData
(
TFileWriter
*
write
,
TFileValue
*
tval
)
{
TFileHeader
*
header
=
&
write
->
header
;
uint8_t
colType
=
header
->
colType
;
colType
=
INDEX_TYPE_GET_TYPE
(
colType
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)(
tval
->
colVal
),
(
size_t
)
strlen
(
tval
->
colVal
));
if
(
fstBuilderInsert
(
write
->
fb
,
key
,
tval
->
offset
))
{
...
...
@@ -586,11 +604,10 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
int64_t
nread
=
reader
->
ctx
->
readFrom
(
reader
->
ctx
,
buf
,
sizeof
(
buf
),
0
);
if
(
nread
==
-
1
)
{
indexError
(
"actual Read: %d, to read: %d, errno: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
errno
,
reader
->
ctx
->
file
.
buf
);
}
else
{
indexInfo
(
"actual Read: %d, to read: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
indexError
(
"actual Read: %d, to read: %d, errno: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
errno
,
reader
->
ctx
->
file
.
buf
);
}
else
{
indexInfo
(
"actual Read: %d, to read: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
reader
->
ctx
->
file
.
buf
);
}
// assert(nread == sizeof(buf));
memcpy
(
&
reader
->
header
,
buf
,
sizeof
(
buf
));
...
...
source/libs/index/test/CMakeLists.txt
浏览文件 @
a17e3f32
...
...
@@ -2,6 +2,7 @@ add_executable(indexTest "")
add_executable
(
fstTest
""
)
add_executable
(
fstUT
""
)
add_executable
(
UtilUT
""
)
add_executable
(
jsonUT
""
)
target_sources
(
indexTest
PRIVATE
...
...
@@ -21,6 +22,10 @@ target_sources(UtilUT
"utilUT.cc"
)
target_sources
(
jsonUT
PRIVATE
"jsonUT.cc"
)
target_include_directories
(
indexTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
...
...
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
jsonUT
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
indexTest
os
util
...
...
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
index
)
target_link_libraries
(
jsonUT
os
util
common
gtest_main
index
)
#add_test(
# NAME index_test
...
...
source/libs/index/test/fstTest.cc
浏览文件 @
a17e3f32
...
...
@@ -301,9 +301,14 @@ void validateTFile(char* arg) {
}
}
void
iterTFileReader
(
char
*
path
,
char
*
ver
)
{
void
iterTFileReader
(
char
*
path
,
char
*
uid
,
char
*
colName
,
char
*
ver
)
{
// tfInit();
uint64_t
suid
=
atoi
(
uid
);
int
version
=
atoi
(
ver
);
TFileReader
*
reader
=
tfileReaderOpen
(
path
,
0
,
version
,
"tag1"
);
TFileReader
*
reader
=
tfileReaderOpen
(
path
,
suid
,
version
,
colName
);
Iterate
*
iter
=
tfileIteratorCreate
(
reader
);
bool
tn
=
iter
?
iter
->
next
(
iter
)
:
false
;
int
count
=
0
;
...
...
@@ -323,9 +328,9 @@ void iterTFileReader(char* path, char* ver) {
int
main
(
int
argc
,
char
*
argv
[])
{
// tool to check all kind of fst test
// if (argc > 1) { validateTFile(argv[1]); }
if
(
argc
>
2
)
{
//
opt
iterTFileReader
(
argv
[
1
],
argv
[
2
]);
if
(
argc
>
4
)
{
//
path suid colName ver
iterTFileReader
(
argv
[
1
],
argv
[
2
]
,
argv
[
3
],
argv
[
4
]
);
}
// checkFstCheckIterator();
// checkFstLongTerm();
...
...
source/libs/index/test/fstUT.cc
浏览文件 @
a17e3f32
...
...
@@ -213,21 +213,21 @@ class FstEnv : public ::testing::Test {
TEST_F
(
FstEnv
,
writeNormal
)
{
fst
->
CreateWriter
();
std
::
string
str
(
"
aa
"
);
std
::
string
str
(
"
11
"
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
str
[
0
]
=
'
a
'
+
i
;
str
[
0
]
=
'
1
'
+
i
;
str
.
resize
(
2
);
assert
(
fst
->
Put
(
str
,
i
)
==
true
);
}
// order failed
assert
(
fst
->
Put
(
"
aa
"
,
1
)
==
false
);
assert
(
fst
->
Put
(
"
11
"
,
1
)
==
false
);
fst
->
DestroyWriter
();
fst
->
CreateReader
();
uint64_t
val
;
assert
(
fst
->
Get
(
"
a
"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"
aa
"
,
&
val
)
==
true
);
assert
(
fst
->
Get
(
"
1
"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"
11
"
,
&
val
)
==
true
);
assert
(
val
==
0
);
std
::
vector
<
uint64_t
>
rlt
;
...
...
@@ -235,3 +235,19 @@ TEST_F(FstEnv, writeNormal) {
assert
(
fst
->
Search
(
ctx
,
rlt
)
==
true
);
}
TEST_F
(
FstEnv
,
WriteMillonrRecord
)
{}
TEST_F
(
FstEnv
,
writeAbNormal
)
{
fst
->
CreateWriter
();
std
::
string
str1
(
"voltage&
\b
&ab"
);
std
::
string
str2
(
"voltbge&
\b
&ab"
);
fst
->
Put
(
str1
,
1
);
fst
->
Put
(
str2
,
2
);
fst
->
DestroyWriter
();
fst
->
CreateReader
();
uint64_t
val
;
assert
(
fst
->
Get
(
"1"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"voltage&
\b
&ab"
,
&
val
)
==
true
);
assert
(
val
==
1
);
}
source/libs/index/test/jsonUT.cc
0 → 100644
浏览文件 @
a17e3f32
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include "index.h"
#include "indexInt.h"
#include "index_cache.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_fst_util.h"
#include "index_tfile.h"
#include "index_util.h"
#include "tglobal.h"
#include "tskiplist.h"
#include "tutil.h"
static
std
::
string
dir
=
"/tmp/json"
;
class
JsonEnv
:
public
::
testing
::
Test
{
protected:
virtual
void
SetUp
()
{
taosRemoveDir
(
dir
.
c_str
());
taosMkDir
(
dir
.
c_str
());
printf
(
"set up
\n
"
);
opts
=
indexOptsCreate
();
int
ret
=
tIndexJsonOpen
(
opts
,
dir
.
c_str
(),
&
index
);
assert
(
ret
==
0
);
}
virtual
void
TearDown
()
{
tIndexJsonClose
(
index
);
indexOptsDestroy
(
opts
);
printf
(
"destory
\n
"
);
}
SIndexJsonOpts
*
opts
;
SIndexJson
*
index
;
};
TEST_F
(
JsonEnv
,
testWrite
)
{
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab1"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"123"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
assert
(
100
==
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
TEST_F
(
JsonEnv
,
testWriteMillonData
)
{
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
assert
(
100
==
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,19 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mockCatalog.h"
#include <iostream>
#include "stub.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#include
"addr_any.h"
#include
<addr_any.h>
#pragma GCC diagnostic pop
#include "mockCatalog.h"
namespace
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,10 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <function.h>
#include <gtest/gtest.h>
#include <iostream>
#include "tglobal.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
...
@@ -25,6 +23,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "function.h"
#include "tglobal.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "taos.h"
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <function.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
...
...
@@ -25,6 +24,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "function.h"
#include "astGenerator.h"
#include "parserInt.h"
#include "taos.h"
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,9 +25,11 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
@@ -37,7 +38,6 @@
#include "planner.h"
#include "qworker.h"
#include "stub.h"
#include "addr_any.h"
#include "executor.h"
#include "dataSinkMgt.h"
...
...
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,15 +25,16 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -14,7 +14,6 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
...
...
@@ -26,15 +25,16 @@
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-arith"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tep.h"
#include "stub.h"
#include "addr_any.h"
#include "scalar.h"
#include "nodes.h"
#include "tlog.h"
...
...
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
a17e3f32
...
...
@@ -36,6 +36,11 @@ enum {
SCH_WRITE
,
};
typedef
struct
SSchTrans
{
void
*
transInst
;
void
*
transHandle
;
}
SSchTrans
;
typedef
struct
SSchApiStat
{
}
SSchApiStat
;
...
...
@@ -59,12 +64,13 @@ typedef struct SSchedulerMgmt {
uint64_t
taskId
;
// sequential taksId
uint64_t
sId
;
// schedulerId
SSchedulerCfg
cfg
;
SHashObj
*
jobs
;
// key: queryId, value: SQueryJob*
int32_t
jobRef
;
SSchedulerStat
stat
;
}
SSchedulerMgmt
;
typedef
struct
SSchCallbackParam
{
uint64_t
queryId
;
int64_t
refId
;
uint64_t
taskId
;
}
SSchCallbackParam
;
...
...
@@ -75,6 +81,7 @@ typedef struct SSchLevel {
int32_t
taskFailed
;
int32_t
taskSucceed
;
int32_t
taskNum
;
int32_t
taskLaunchIdx
;
// launch startup index
SArray
*
subTasks
;
// Element is SQueryTask
}
SSchLevel
;
...
...
@@ -105,6 +112,7 @@ typedef struct SSchJobAttr {
}
SSchJobAttr
;
typedef
struct
SSchJob
{
int64_t
refId
;
uint64_t
queryId
;
SSchJobAttr
attr
;
int32_t
levelNum
;
...
...
@@ -119,7 +127,6 @@ typedef struct SSchJob {
SHashObj
*
succTasks
;
// succeed tasks, key:taskid, value:SQueryTask*
SHashObj
*
failTasks
;
// failed tasks, key:taskid, value:SQueryTask*
int32_t
ref
;
int8_t
status
;
SQueryNodeAddr
resNode
;
tsem_t
rspSem
;
...
...
@@ -168,6 +175,8 @@ typedef struct SSchJob {
static
int32_t
schLaunchTask
(
SSchJob
*
job
,
SSchTask
*
task
);
static
int32_t
schBuildAndSendMsg
(
SSchJob
*
job
,
SSchTask
*
task
,
SQueryNodeAddr
*
addr
,
int32_t
msgType
);
SSchJob
*
schAcquireJob
(
int64_t
refId
);
int32_t
schReleaseJob
(
int64_t
refId
);
#ifdef __cplusplus
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
a17e3f32
...
...
@@ -17,12 +17,17 @@
#include "tmsg.h"
#include "query.h"
#include "catalog.h"
#include "tref.h"
typedef
struct
SSchTrans
{
void
*
transInst
;
void
*
transHandle
;
}
SSchTrans
;
static
SSchedulerMgmt
schMgmt
=
{
0
};
SSchedulerMgmt
schMgmt
=
{
0
};
FORCE_INLINE
SSchJob
*
schAcquireJob
(
int64_t
refId
)
{
return
(
SSchJob
*
)
taosAcquireRef
(
schMgmt
.
jobRef
,
refId
);
}
FORCE_INLINE
int32_t
schReleaseJob
(
int64_t
refId
)
{
return
taosReleaseRef
(
schMgmt
.
jobRef
,
refId
);
}
uint64_t
schGenTaskId
(
void
)
{
return
atomic_add_fetch_64
(
&
schMgmt
.
taskId
,
1
);
...
...
@@ -886,7 +891,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
}
case
TDMT_VND_DROP_TASK_RSP
:
{
// SHOULD NEVER REACH HERE
SCH_TASK_ELOG
(
"invalid status to handle drop task rsp, ref
:%d"
,
atomic_load_32
(
&
pJob
->
ref
)
);
SCH_TASK_ELOG
(
"invalid status to handle drop task rsp, ref
Id:%"
PRIx64
,
pJob
->
refId
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
break
;
}
...
...
@@ -908,28 +913,23 @@ _return:
int32_t
schHandleCallback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
msgType
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
SSchCallbackParam
*
pParam
=
(
SSchCallbackParam
*
)
param
;
SSchJob
*
pJob
=
NULL
;
SSchTask
*
pTask
=
NULL
;
SSchJob
*
*
job
=
taosHashGet
(
schMgmt
.
jobs
,
&
pParam
->
queryId
,
sizeof
(
pParam
->
queryId
)
);
if
(
NULL
==
job
||
NULL
==
(
*
job
)
)
{
qError
(
"QID:
%"
PRIx64
" taosHashGet queryId not exist, may be dropped"
,
pParam
->
query
Id
);
SSchJob
*
pJob
=
taosAcquireRef
(
schMgmt
.
jobRef
,
pParam
->
refId
);
if
(
NULL
==
pJob
)
{
qError
(
"QID:
0x%"
PRIx64
",TID:0x%"
PRIx64
"taosAcquireRef job failed, may be dropped, refId:%"
PRIx64
,
pParam
->
queryId
,
pParam
->
taskId
,
pParam
->
ref
Id
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_JOB_FREED
);
}
pJob
=
*
job
;
atomic_add_fetch_32
(
&
pJob
->
ref
,
1
);
int32_t
s
=
taosHashGetSize
(
pJob
->
execTasks
);
if
(
s
<=
0
)
{
qError
(
"QID:%"
PRIx64
",TID:%"
PRId64
" no task in execTask list"
,
pParam
->
query
Id
,
pParam
->
taskId
);
SCH_JOB_ELOG
(
"empty execTask list, refId:%"
PRIx64
", taskId:%"
PRIx64
,
pParam
->
ref
Id
,
pParam
->
taskId
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
}
SSchTask
**
task
=
taosHashGet
(
pJob
->
execTasks
,
&
pParam
->
taskId
,
sizeof
(
pParam
->
taskId
));
if
(
NULL
==
task
||
NULL
==
(
*
task
))
{
qError
(
"QID:%"
PRIx64
",TID:%"
PRId64
" taosHashGet taskId not exist"
,
pParam
->
query
Id
,
pParam
->
taskId
);
SCH_JOB_ELOG
(
"task not found in execTask list, refId:%"
PRIx64
", taskId:%"
PRIx64
,
pParam
->
ref
Id
,
pParam
->
taskId
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
}
...
...
@@ -942,7 +942,7 @@ int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, in
_return:
if
(
pJob
)
{
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
taosReleaseRef
(
schMgmt
.
jobRef
,
pParam
->
refId
);
}
tfree
(
param
);
...
...
@@ -1003,28 +1003,29 @@ int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
}
int32_t
schAsyncSendMsg
(
void
*
transport
,
SEpSet
*
epSet
,
uint64_t
qId
,
uint64_t
tId
,
int32_t
msgType
,
void
*
msg
,
uint32_t
msgSize
)
{
int32_t
schAsyncSendMsg
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
void
*
transport
,
SEpSet
*
epSet
,
int32_t
msgType
,
void
*
msg
,
uint32_t
msgSize
)
{
int32_t
code
=
0
;
SSchTrans
*
trans
=
(
SSchTrans
*
)
transport
;
SMsgSendInfo
*
pMsgSendInfo
=
calloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
NULL
==
pMsgSendInfo
)
{
qError
(
"QID:%"
PRIx64
",TID:%"
PRIx64
" calloc %d failed"
,
qId
,
tId
,
(
int32_t
)
sizeof
(
SMsgSendInfo
));
SCH_TASK_ELOG
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SMsgSendInfo
));
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
SSchCallbackParam
*
param
=
calloc
(
1
,
sizeof
(
SSchCallbackParam
));
if
(
NULL
==
param
)
{
qError
(
"QID:%"
PRIx64
",TID:%"
PRIx64
" calloc %d failed"
,
qId
,
tId
,
(
int32_t
)
sizeof
(
SSchCallbackParam
));
SCH_TASK_ELOG
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SSchCallbackParam
));
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
__async_send_cb_fn_t
fp
=
NULL
;
SCH_ERR_JRET
(
schGetCallbackFp
(
msgType
,
&
fp
));
param
->
queryId
=
qId
;
param
->
taskId
=
tId
;
param
->
queryId
=
pJob
->
queryId
;
param
->
refId
=
pJob
->
refId
;
param
->
taskId
=
pTask
->
taskId
;
pMsgSendInfo
->
param
=
param
;
...
...
@@ -1040,7 +1041,7 @@ int32_t schAsyncSendMsg(void *transport, SEpSet* epSet, uint64_t qId, uint64_t t
SCH_ERR_JRET
(
code
);
}
qDebug
(
"QID:0x%"
PRIx64
",TID:0x%"
PRIx64
" req msg sent, type:%d, %s"
,
qId
,
t
Id
,
msgType
,
TMSG_INFO
(
msgType
));
SCH_TASK_DLOG
(
"req msg sent, refId:%"
PRIx64
", type:%d, %s"
,
pJob
->
ref
Id
,
msgType
,
TMSG_INFO
(
msgType
));
return
TSDB_CODE_SUCCESS
;
_return:
...
...
@@ -1160,7 +1161,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
atomic_store_32
(
&
pTask
->
lastMsgType
,
msgType
);
SSchTrans
trans
=
{.
transInst
=
pJob
->
transport
,
.
transHandle
=
pTask
->
handle
};
SCH_ERR_JRET
(
schAsyncSendMsg
(
&
trans
,
&
epSet
,
pJob
->
queryId
,
pTask
->
taskId
,
msgType
,
msg
,
msgSize
));
SCH_ERR_JRET
(
schAsyncSendMsg
(
pJob
,
pTask
,
&
trans
,
&
epSet
,
msgType
,
msg
,
msgSize
));
if
(
isCandidateAddr
)
{
SCH_ERR_RET
(
schRecordTaskExecNode
(
pJob
,
pTask
,
addr
));
...
...
@@ -1283,7 +1284,60 @@ void schDropJobAllTasks(SSchJob *pJob) {
schDropTaskInHashList
(
pJob
,
pJob
->
failTasks
);
}
static
int32_t
schExecJobImpl
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
struct
SSchJob
**
job
,
const
char
*
sql
,
bool
syncSchedule
)
{
int32_t
schCancelJob
(
SSchJob
*
pJob
)
{
//TODO
//TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST
}
void
schFreeJobImpl
(
void
*
job
)
{
if
(
NULL
==
job
)
{
return
;
}
SSchJob
*
pJob
=
job
;
uint64_t
queryId
=
pJob
->
queryId
;
int64_t
refId
=
pJob
->
refId
;
if
(
pJob
->
status
==
JOB_TASK_STATUS_EXECUTING
)
{
schCancelJob
(
pJob
);
}
schDropJobAllTasks
(
pJob
);
pJob
->
subPlans
=
NULL
;
// it is a reference to pDag->pSubplans
int32_t
numOfLevels
=
taosArrayGetSize
(
pJob
->
levels
);
for
(
int32_t
i
=
0
;
i
<
numOfLevels
;
++
i
)
{
SSchLevel
*
pLevel
=
taosArrayGet
(
pJob
->
levels
,
i
);
int32_t
numOfTasks
=
taosArrayGetSize
(
pLevel
->
subTasks
);
for
(
int32_t
j
=
0
;
j
<
numOfTasks
;
++
j
)
{
SSchTask
*
pTask
=
taosArrayGet
(
pLevel
->
subTasks
,
j
);
schFreeTask
(
pTask
);
}
taosArrayDestroy
(
pLevel
->
subTasks
);
}
taosHashCleanup
(
pJob
->
execTasks
);
taosHashCleanup
(
pJob
->
failTasks
);
taosHashCleanup
(
pJob
->
succTasks
);
taosArrayDestroy
(
pJob
->
levels
);
taosArrayDestroy
(
pJob
->
nodeList
);
tfree
(
pJob
->
res
);
tfree
(
pJob
);
qDebug
(
"QID:0x%"
PRIx64
" job freed, refId:%"
PRIx64
", pointer:%p"
,
queryId
,
refId
,
pJob
);
}
static
int32_t
schExecJobImpl
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
int64_t
*
job
,
const
char
*
sql
,
bool
syncSchedule
)
{
qDebug
(
"QID:0x%"
PRIx64
" job started"
,
pDag
->
queryId
);
if
(
pNodeList
==
NULL
||
(
pNodeList
&&
taosArrayGetSize
(
pNodeList
)
<=
0
))
{
...
...
@@ -1327,21 +1381,20 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryDag* pDa
tsem_init
(
&
pJob
->
rspSem
,
0
,
0
);
code
=
taosHashPut
(
schMgmt
.
jobs
,
&
pJob
->
queryId
,
sizeof
(
pJob
->
queryId
),
&
pJob
,
POINTER_BYTES
);
if
(
0
!=
code
)
{
if
(
HASH_NODE_EXIST
(
code
))
{
SCH_JOB_ELOG
(
"job already exist, isQueryJob:%d"
,
pJob
->
attr
.
queryJob
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
else
{
SCH_JOB_ELOG
(
"taosHashPut job failed, errno:%d"
,
errno
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
pJob
->
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
if
(
pJob
->
refId
<
0
)
{
SCH_JOB_ELOG
(
"taosHashPut job failed, error:%s"
,
tstrerror
(
terrno
));
SCH_ERR_JRET
(
terrno
);
}
SCH_JOB_DLOG
(
"job refId:%"
PRIx64
,
pJob
->
refId
);
pJob
->
status
=
JOB_TASK_STATUS_NOT_START
;
SCH_ERR_JRET
(
schLaunchJob
(
pJob
));
*
(
SSchJob
**
)
job
=
pJob
;
taosAcquireRef
(
schMgmt
.
jobRef
,
pJob
->
refId
);
*
job
=
pJob
->
refId
;
if
(
syncSchedule
)
{
SCH_JOB_DLOG
(
"will wait for rsp now, job status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
...
...
@@ -1349,25 +1402,20 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryDag* pDa
}
SCH_JOB_DLOG
(
"job exec done, job status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
taosReleaseRef
(
schMgmt
.
jobRef
,
pJob
->
refId
);
return
TSDB_CODE_SUCCESS
;
_return:
*
(
SSchJob
**
)
job
=
NULL
;
schedulerFreeJob
(
pJob
);
schFreeJobImpl
(
pJob
);
SCH_RET
(
code
);
}
int32_t
schCancelJob
(
SSchJob
*
pJob
)
{
//TODO
//TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST
}
int32_t
schedulerInit
(
SSchedulerCfg
*
cfg
)
{
if
(
schMgmt
.
job
s
)
{
if
(
schMgmt
.
job
Ref
)
{
qError
(
"scheduler already initialized"
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
...
...
@@ -1382,8 +1430,8 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
schMgmt
.
cfg
.
maxJobNum
=
SCHEDULE_DEFAULT_JOB_NUMBER
;
}
schMgmt
.
job
s
=
taosHashInit
(
schMgmt
.
cfg
.
maxJobNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
false
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
schMgmt
.
jobs
)
{
schMgmt
.
job
Ref
=
taosOpenRef
(
schMgmt
.
cfg
.
maxJobNum
,
schFreeJobImpl
);
if
(
schMgmt
.
jobRef
<
0
)
{
qError
(
"init schduler jobs failed, num:%u"
,
schMgmt
.
cfg
.
maxJobNum
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -1398,24 +1446,28 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
schedulerExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
struct
SSchJob
**
pJob
,
const
char
*
sql
,
SQueryResult
*
pRes
)
{
int32_t
schedulerExecJob
(
void
*
transport
,
SArray
*
nodeList
,
SQueryDag
*
pDag
,
int64_t
*
pJob
,
const
char
*
sql
,
SQueryResult
*
pRes
)
{
if
(
NULL
==
transport
||
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
||
NULL
==
pRes
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SCH_ERR_RET
(
schExecJobImpl
(
transport
,
nodeList
,
pDag
,
pJob
,
sql
,
true
));
pRes
->
code
=
atomic_load_32
(
&
(
*
pJob
)
->
errCode
);
pRes
->
numOfRows
=
(
*
pJob
)
->
resNumOfRows
;
SSchJob
*
job
=
taosAcquireRef
(
schMgmt
.
jobRef
,
*
pJob
);
pRes
->
code
=
atomic_load_32
(
&
job
->
errCode
);
pRes
->
numOfRows
=
job
->
resNumOfRows
;
taosReleaseRef
(
schMgmt
.
jobRef
,
*
pJob
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
schedulerAsyncExecJob
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
const
char
*
sql
,
struct
SSchJob
**
pJob
)
{
int32_t
schedulerAsyncExecJob
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryDag
*
pDag
,
const
char
*
sql
,
int64_t
*
pJob
)
{
if
(
NULL
==
transport
||
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SCH_ERR_RET
(
schExecJobImpl
(
transport
,
pNodeList
,
pDag
,
pJob
,
sql
,
false
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1541,28 +1593,35 @@ _return:
}
int32_t
schedulerFetchRows
(
SSchJob
*
pJ
ob
,
void
**
pData
)
{
if
(
NULL
==
p
Job
||
NULL
==
p
Data
)
{
int32_t
schedulerFetchRows
(
int64_t
j
ob
,
void
**
pData
)
{
if
(
NULL
==
pData
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
int32_t
code
=
0
;
atomic_add_fetch_32
(
&
pJob
->
ref
,
1
);
SSchJob
*
pJob
=
taosAcquireRef
(
schMgmt
.
jobRef
,
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped, refId:%"
PRIx64
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
int8_t
status
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
status
==
JOB_TASK_STATUS_DROPPING
)
{
SCH_JOB_ELOG
(
"job is dropping, status:%d"
,
status
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_STATUS_ERROR
);
taosReleaseRef
(
schMgmt
.
jobRef
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
if
(
!
SCH_JOB_NEED_FETCH
(
&
pJob
->
attr
))
{
SCH_JOB_ELOG
(
"no need to fetch data, status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
taosReleaseRef
(
schMgmt
.
jobRef
,
job
);
SCH_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
0
,
1
)
!=
0
)
{
SCH_JOB_ELOG
(
"prior fetching not finished, userFetch:%d"
,
atomic_load_8
(
&
pJob
->
userFetch
));
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
taosReleaseRef
(
schMgmt
.
jobRef
,
job
);
SCH_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
JOB_TASK_STATUS_FAILED
==
status
||
JOB_TASK_STATUS_DROPPING
==
status
)
{
...
...
@@ -1588,7 +1647,6 @@ int32_t schedulerFetchRows(SSchJob *pJob, void** pData) {
SCH_ERR_JRET
(
schCheckAndUpdateJobStatus
(
pJob
,
JOB_TASK_STATUS_SUCCEED
));
}
_return:
while
(
true
)
{
*
pData
=
atomic_load_ptr
(
&
pJob
->
res
);
...
...
@@ -1609,96 +1667,47 @@ _return:
SCH_JOB_DLOG
(
"empty res and set query complete, code:%x"
,
code
);
}
SCH_JOB_DLOG
(
"fetch done, totalRows:%d, code:%s"
,
pJob
->
resNumOfRows
,
tstrerror
(
code
));
_return:
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
1
,
0
);
SCH_JOB_DLOG
(
"fetch done, totalRows:%d, code:%s"
,
pJob
->
resNumOfRows
,
tstrerror
(
code
));
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
taosReleaseRef
(
schMgmt
.
jobRef
,
job
);
SCH_RET
(
code
);
}
int32_t
scheduleCancelJob
(
void
*
job
)
{
SSchJob
*
pJob
=
(
SSchJob
*
)
job
;
atomic_add_fetch_32
(
&
pJob
->
ref
,
1
);
int32_t
scheduleCancelJob
(
int64_t
job
)
{
SSchJob
*
pJob
=
taosAcquireRef
(
schMgmt
.
jobRef
,
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped, refId:%"
PRIx64
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
int32_t
code
=
schCancelJob
(
pJob
);
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
taosReleaseRef
(
schMgmt
.
jobRef
,
job
);
SCH_RET
(
code
);
}
void
schedulerFreeJob
(
void
*
job
)
{
if
(
NULL
==
job
)
{
return
;
}
SSchJob
*
pJob
=
job
;
uint64_t
queryId
=
pJob
->
queryId
;
bool
setJobFree
=
false
;
if
(
SCH_GET_JOB_STATUS
(
pJob
)
>
0
)
{
if
(
0
!=
taosHashRemove
(
schMgmt
.
jobs
,
&
pJob
->
queryId
,
sizeof
(
pJob
->
queryId
)))
{
SCH_JOB_ELOG
(
"taosHashRemove job from list failed, may already freed, pJob:%p"
,
pJob
);
void
schedulerFreeJob
(
int64_t
job
)
{
SSchJob
*
pJob
=
taosAcquireRef
(
schMgmt
.
jobRef
,
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped, refId:%"
PRIx64
,
job
);
return
;
}
SCH_JOB_DLOG
(
"job removed from list, no further ref, ref:%d"
,
atomic_load_32
(
&
pJob
->
ref
));
while
(
true
)
{
int32_t
ref
=
atomic_load_32
(
&
pJob
->
ref
);
if
(
0
==
ref
)
{
break
;
}
else
if
(
ref
>
0
)
{
if
(
1
==
ref
&&
atomic_load_8
(
&
pJob
->
userFetch
)
>
0
&&
!
setJobFree
)
{
if
(
atomic_load_8
(
&
pJob
->
userFetch
)
>
0
)
{
schProcessOnJobDropped
(
pJob
,
TSDB_CODE_QRY_JOB_FREED
);
setJobFree
=
true
;
}
usleep
(
1
);
}
else
{
SCH_JOB_ELOG
(
"invalid job ref number, ref:%d"
,
ref
);
break
;
}
}
SCH_JOB_DLOG
(
"job no ref now, status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
)
);
SCH_JOB_DLOG
(
"start to remove job from jobRef list, refId:%"
PRIx64
,
job
);
if
(
pJob
->
status
==
JOB_TASK_STATUS_EXECUTING
)
{
schCancelJob
(
pJob
);
}
schDropJobAllTasks
(
pJob
);
}
pJob
->
subPlans
=
NULL
;
// it is a reference to pDag->pSubplans
int32_t
numOfLevels
=
taosArrayGetSize
(
pJob
->
levels
);
for
(
int32_t
i
=
0
;
i
<
numOfLevels
;
++
i
)
{
SSchLevel
*
pLevel
=
taosArrayGet
(
pJob
->
levels
,
i
);
int32_t
numOfTasks
=
taosArrayGetSize
(
pLevel
->
subTasks
);
for
(
int32_t
j
=
0
;
j
<
numOfTasks
;
++
j
)
{
SSchTask
*
pTask
=
taosArrayGet
(
pLevel
->
subTasks
,
j
);
schFreeTask
(
pTask
);
}
taosArrayDestroy
(
pLevel
->
subTasks
);
if
(
taosRemoveRef
(
schMgmt
.
jobRef
,
job
))
{
SCH_JOB_ELOG
(
"remove job from job list failed, refId:%"
PRIx64
,
job
);
}
taosHashCleanup
(
pJob
->
execTasks
);
taosHashCleanup
(
pJob
->
failTasks
);
taosHashCleanup
(
pJob
->
succTasks
);
taosArrayDestroy
(
pJob
->
levels
);
taosArrayDestroy
(
pJob
->
nodeList
);
tfree
(
pJob
->
res
);
tfree
(
pJob
);
qDebug
(
"QID:0x%"
PRIx64
" job freed"
,
queryId
);
}
void
schedulerFreeTaskList
(
SArray
*
taskList
)
{
...
...
@@ -1716,9 +1725,17 @@ void schedulerFreeTaskList(SArray *taskList) {
}
void
schedulerDestroy
(
void
)
{
if
(
schMgmt
.
jobs
)
{
taosHashCleanup
(
schMgmt
.
jobs
);
//TODO
schMgmt
.
jobs
=
NULL
;
if
(
schMgmt
.
jobRef
)
{
SSchJob
*
pJob
=
taosIterateRef
(
schMgmt
.
jobRef
,
0
);
while
(
pJob
)
{
taosRemoveRef
(
schMgmt
.
jobRef
,
pJob
->
refId
);
pJob
=
taosIterateRef
(
schMgmt
.
jobRef
,
pJob
->
refId
);
}
taosCloseRef
(
schMgmt
.
jobRef
);
schMgmt
.
jobRef
=
0
;
}
}
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
a17e3f32
...
...
@@ -14,11 +14,21 @@
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "os.h"
#include "tglobal.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
...
...
@@ -26,27 +36,17 @@
#include "scheduler.h"
#include "tep.h"
#include "trpc.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#include "schedulerInt.h"
#include "stub.h"
#include "addr_any.h"
#include "tref.h"
namespace
{
extern
"C"
int32_t
schHandleResponseMsg
(
SSchJob
*
job
,
SSchTask
*
task
,
int32_t
msgType
,
char
*
msg
,
int32_t
msgSize
,
int32_t
rspCode
);
extern
"C"
int32_t
schHandleCallback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
msgType
,
int32_t
rspCode
);
struct
SSchJob
*
pInsertJob
=
NULL
;
struct
SSchJob
*
pQueryJob
=
NULL
;
int64_t
insertJobRefId
=
0
;
int64_t
queryJobRefId
=
0
;
uint64_t
schtMergeTemplateId
=
0x4
;
uint64_t
schtFetchTaskId
=
0
;
...
...
@@ -65,6 +65,7 @@ void schtInitLogFile() {
tsAsyncLog
=
0
;
qDebugFlag
=
159
;
strcpy
(
tsLogDir
,
"/var/log/taos"
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
...
...
@@ -255,11 +256,12 @@ void schtSetAsyncSendMsgToServer() {
void
*
schtSendRsp
(
void
*
param
)
{
SSchJob
*
job
=
NULL
;
SSchJob
*
pJob
=
NULL
;
int64_t
job
=
0
;
int32_t
code
=
0
;
while
(
true
)
{
job
=
*
(
SSchJob
*
*
)
param
;
job
=
*
(
int64_t
*
)
param
;
if
(
job
)
{
break
;
}
...
...
@@ -267,22 +269,27 @@ void *schtSendRsp(void *param) {
usleep
(
1000
);
}
void
*
pIter
=
taosHashIterate
(
job
->
execTasks
,
NULL
);
pJob
=
schAcquireJob
(
job
);
void
*
pIter
=
taosHashIterate
(
pJob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
SSubmitRsp
rsp
=
{
0
};
rsp
.
affectedRows
=
10
;
schHandleResponseMsg
(
j
ob
,
task
,
TDMT_VND_SUBMIT_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
schHandleResponseMsg
(
pJ
ob
,
task
,
TDMT_VND_SUBMIT_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
schReleaseJob
(
job
);
return
NULL
;
}
void
*
schtCreateFetchRspThread
(
void
*
param
)
{
struct
SSchJob
*
job
=
(
struct
SSchJob
*
)
param
;
int64_t
job
=
*
(
int64_t
*
)
param
;
SSchJob
*
pJob
=
schAcquireJob
(
job
);
sleep
(
1
);
...
...
@@ -291,7 +298,9 @@ void *schtCreateFetchRspThread(void *param) {
rsp
->
completed
=
1
;
rsp
->
numOfRows
=
10
;
code
=
schHandleResponseMsg
(
job
,
job
->
fetchTask
,
TDMT_VND_FETCH_RSP
,
(
char
*
)
rsp
,
sizeof
(
*
rsp
),
0
);
code
=
schHandleResponseMsg
(
pJob
,
pJob
->
fetchTask
,
TDMT_VND_FETCH_RSP
,
(
char
*
)
rsp
,
sizeof
(
*
rsp
),
0
);
schReleaseJob
(
job
);
assert
(
code
==
0
);
}
...
...
@@ -329,9 +338,9 @@ void *schtFetchRspThread(void *aa) {
void
schtFreeQueryJob
(
int32_t
freeThread
)
{
static
uint32_t
freeNum
=
0
;
SSchJob
*
job
=
atomic_load_ptr
(
&
pQueryJob
)
;
int64_t
job
=
queryJobRefId
;
if
(
job
&&
atomic_val_compare_exchange_
ptr
(
&
pQueryJob
,
job
,
NULL
))
{
if
(
job
&&
atomic_val_compare_exchange_
64
(
&
queryJobRefId
,
job
,
0
))
{
schedulerFreeJob
(
job
);
if
(
freeThread
)
{
if
(
++
freeNum
%
schtTestPrintNum
==
0
)
{
...
...
@@ -360,7 +369,7 @@ void* schtRunJobThread(void *aa) {
schtSetExecNode
();
schtSetAsyncSendMsgToServer
();
SSchJob
*
j
ob
=
NULL
;
SSchJob
*
pJ
ob
=
NULL
;
SSchCallbackParam
*
param
=
NULL
;
SHashObj
*
execTasks
=
NULL
;
SDataBuf
dataBuf
=
{
0
};
...
...
@@ -376,24 +385,29 @@ void* schtRunJobThread(void *aa) {
qnodeAddr
.
port
=
6031
;
taosArrayPush
(
qnodeList
,
&
qnodeAddr
);
code
=
schedulerAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
"select * from tb"
,
&
job
);
code
=
schedulerAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
"select * from tb"
,
&
queryJobRefId
);
assert
(
code
==
0
);
pJob
=
schAcquireJob
(
queryJobRefId
);
if
(
NULL
==
pJob
)
{
taosArrayDestroy
(
qnodeList
);
schtFreeQueryDag
(
&
dag
);
continue
;
}
execTasks
=
taosHashInit
(
5
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
false
,
HASH_ENTRY_LOCK
);
void
*
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
schtFetchTaskId
=
task
->
taskId
-
1
;
taosHashPut
(
execTasks
,
&
task
->
taskId
,
sizeof
(
task
->
taskId
),
task
,
sizeof
(
*
task
));
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
param
=
(
SSchCallbackParam
*
)
calloc
(
1
,
sizeof
(
*
param
));
param
->
queryId
=
schtQueryId
;
pQueryJob
=
job
;
param
->
refId
=
queryJobRefId
;
param
->
queryId
=
pJob
->
queryId
;
pIter
=
taosHashIterate
(
execTasks
,
NULL
);
while
(
pIter
)
{
...
...
@@ -412,7 +426,8 @@ void* schtRunJobThread(void *aa) {
param
=
(
SSchCallbackParam
*
)
calloc
(
1
,
sizeof
(
*
param
));
param
->
queryId
=
schtQueryId
;
param
->
refId
=
queryJobRefId
;
param
->
queryId
=
pJob
->
queryId
;
pIter
=
taosHashIterate
(
execTasks
,
NULL
);
while
(
pIter
)
{
...
...
@@ -431,7 +446,8 @@ void* schtRunJobThread(void *aa) {
param
=
(
SSchCallbackParam
*
)
calloc
(
1
,
sizeof
(
*
param
));
param
->
queryId
=
schtQueryId
;
param
->
refId
=
queryJobRefId
;
param
->
queryId
=
pJob
->
queryId
;
pIter
=
taosHashIterate
(
execTasks
,
NULL
);
while
(
pIter
)
{
...
...
@@ -450,7 +466,8 @@ void* schtRunJobThread(void *aa) {
param
=
(
SSchCallbackParam
*
)
calloc
(
1
,
sizeof
(
*
param
));
param
->
queryId
=
schtQueryId
;
param
->
refId
=
queryJobRefId
;
param
->
queryId
=
pJob
->
queryId
;
pIter
=
taosHashIterate
(
execTasks
,
NULL
);
while
(
pIter
)
{
...
...
@@ -470,7 +487,7 @@ void* schtRunJobThread(void *aa) {
atomic_store_32
(
&
schtStartFetch
,
1
);
void
*
data
=
NULL
;
code
=
schedulerFetchRows
(
pQueryJob
,
&
data
);
code
=
schedulerFetchRows
(
queryJobRefId
,
&
data
);
assert
(
code
==
0
||
code
);
if
(
0
==
code
)
{
...
...
@@ -480,12 +497,13 @@ void* schtRunJobThread(void *aa) {
}
data
=
NULL
;
code
=
schedulerFetchRows
(
pQueryJob
,
&
data
);
code
=
schedulerFetchRows
(
queryJobRefId
,
&
data
);
assert
(
code
==
0
||
code
);
schtFreeQueryJob
(
0
);
taosHashCleanup
(
execTasks
);
taosArrayDestroy
(
qnodeList
);
schtFreeQueryDag
(
&
dag
);
...
...
@@ -516,7 +534,7 @@ TEST(queryTest, normalCase) {
char
*
dbname
=
"1.db1"
;
char
*
tablename
=
"table1"
;
SVgroupInfo
vgInfo
=
{
0
};
SSchJob
*
pJob
=
NULL
;
int64_t
job
=
0
;
SQueryDag
dag
=
{
0
};
schtInitLogFile
();
...
...
@@ -537,59 +555,61 @@ TEST(queryTest, normalCase) {
schtSetExecNode
();
schtSetAsyncSendMsgToServer
();
code
=
schedulerAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
"select * from tb"
,
&
pJ
ob
);
code
=
schedulerAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
"select * from tb"
,
&
j
ob
);
ASSERT_EQ
(
code
,
0
);
SSchJob
*
job
=
(
SSchJob
*
)
pJob
;
void
*
pIter
=
taosHashIterate
(
job
->
execTasks
,
NULL
);
SSchJob
*
pJob
=
schAcquireJob
(
job
);
void
*
pIter
=
taosHashIterate
(
pJob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
SQueryTableRsp
rsp
=
{
0
};
code
=
schHandleResponseMsg
(
j
ob
,
task
,
TDMT_VND_QUERY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
code
=
schHandleResponseMsg
(
pJ
ob
,
task
,
TDMT_VND_QUERY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
ASSERT_EQ
(
code
,
0
);
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
NULL
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
SResReadyRsp
rsp
=
{
0
};
code
=
schHandleResponseMsg
(
j
ob
,
task
,
TDMT_VND_RES_READY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
code
=
schHandleResponseMsg
(
pJ
ob
,
task
,
TDMT_VND_RES_READY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
printf
(
"code:%d"
,
code
);
ASSERT_EQ
(
code
,
0
);
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
NULL
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
SQueryTableRsp
rsp
=
{
0
};
code
=
schHandleResponseMsg
(
j
ob
,
task
,
TDMT_VND_QUERY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
code
=
schHandleResponseMsg
(
pJ
ob
,
task
,
TDMT_VND_QUERY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
ASSERT_EQ
(
code
,
0
);
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
NULL
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
NULL
);
while
(
pIter
)
{
SSchTask
*
task
=
*
(
SSchTask
**
)
pIter
;
SResReadyRsp
rsp
=
{
0
};
code
=
schHandleResponseMsg
(
j
ob
,
task
,
TDMT_VND_RES_READY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
code
=
schHandleResponseMsg
(
pJ
ob
,
task
,
TDMT_VND_RES_READY_RSP
,
(
char
*
)
&
rsp
,
sizeof
(
rsp
),
0
);
ASSERT_EQ
(
code
,
0
);
pIter
=
taosHashIterate
(
j
ob
->
execTasks
,
pIter
);
pIter
=
taosHashIterate
(
pJ
ob
->
execTasks
,
pIter
);
}
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_t
thread1
;
pthread_create
(
&
(
thread1
),
&
thattr
,
schtCreateFetchRspThread
,
job
);
pthread_create
(
&
(
thread1
),
&
thattr
,
schtCreateFetchRspThread
,
&
job
);
void
*
data
=
NULL
;
code
=
schedulerFetchRows
(
job
,
&
data
);
...
...
@@ -603,9 +623,11 @@ TEST(queryTest, normalCase) {
data
=
NULL
;
code
=
schedulerFetchRows
(
job
,
&
data
);
ASSERT_EQ
(
code
,
0
);
ASSERT_TRUE
(
data
);
ASSERT_TRUE
(
data
==
NULL
);
schedulerFreeJob
(
pJob
);
schReleaseJob
(
job
);
schedulerFreeJob
(
job
);
schtFreeQueryDag
(
&
dag
);
...
...
@@ -644,14 +666,14 @@ TEST(insertTest, normalCase) {
pthread_attr_init
(
&
thattr
);
pthread_t
thread1
;
pthread_create
(
&
(
thread1
),
&
thattr
,
schtSendRsp
,
&
pInsertJob
);
pthread_create
(
&
(
thread1
),
&
thattr
,
schtSendRsp
,
&
insertJobRefId
);
SQueryResult
res
=
{
0
};
code
=
schedulerExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
&
pInsertJob
,
"insert into tb values(now,1)"
,
&
res
);
code
=
schedulerExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
&
insertJobRefId
,
"insert into tb values(now,1)"
,
&
res
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
res
.
numOfRows
,
20
);
schedulerFreeJob
(
pInsertJob
);
schedulerFreeJob
(
insertJobRefId
);
schedulerDestroy
();
}
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
a17e3f32
...
...
@@ -25,6 +25,7 @@ extern "C" {
#include <stdlib.h>
#include "sync.h"
#include "taosdef.h"
#include "tglobal.h"
#include "tlog.h"
#include "ttimer.h"
...
...
@@ -91,31 +92,61 @@ typedef struct SyncAppendEntriesReply SyncAppendEntriesReply;
struct
SSyncEnv
;
typedef
struct
SSyncEnv
SSyncEnv
;
struct
SRaftStore
;
typedef
struct
SRaftStore
SRaftStore
;
struct
SVotesGranted
;
typedef
struct
SVotesGranted
SVotesGranted
;
struct
SVotesResponded
;
typedef
struct
SVotesResponded
SVotesResponded
;
typedef
struct
SRaftId
{
SyncNodeId
addr
;
// typedef uint64_t SyncNodeId;
SyncGroupId
vgId
;
// typedef int32_t SyncGroupId;
}
SRaftId
;
typedef
struct
SSyncNode
{
// init by SSyncInfo
SyncGroupId
vgId
;
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
SSyncFSM
*
pFsm
;
// passed from outside
void
*
rpcClient
;
int32_t
(
*
FpSendMsg
)(
void
*
rpcClient
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
refCount
;
int64_t
rid
;
// init internal
SNodeInfo
me
;
SNodeInfo
peers
[
TSDB_MAX_REPLICA
];
int32_t
peersNum
;
SNodeInfo
peers
[
TSDB_MAX_REPLICA
];
ESyncRole
role
;
// raft algorithm
SSyncFSM
*
pFsm
;
SRaftId
raftId
;
SRaftId
peersId
[
TSDB_MAX_REPLICA
];
int32_t
replicaNum
;
int32_t
quorum
;
// life cycle
int32_t
refCount
;
int64_t
rid
;
// tla+ server vars
ESyncState
state
;
SRaftStore
*
pRaftStore
;
// tla+ candidate vars
SVotesGranted
*
pVotesGranted
;
SVotesResponded
*
pVotesResponded
;
// tla+ leader vars
SHashObj
*
pNextIndex
;
SHashObj
*
pMatchIndex
;
// tla+ log vars
SSyncLogStore
*
pLogStore
;
SyncIndex
commitIndex
;
// timer
tmr_h
pPingTimer
;
int32_t
pingTimerMS
;
uint8_t
pingTimerStart
;
...
...
@@ -136,31 +167,20 @@ typedef struct SSyncNode {
// callback
int32_t
(
*
FpOnPing
)(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
(
*
FpOnPingReply
)(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
int32_t
(
*
FpOnRequestVote
)(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
(
*
FpOnRequestVoteReply
)(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
(
*
FpOnAppendEntries
)(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnAppendEntriesReply
)(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
}
SSyncNode
;
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
#ifdef __cplusplus
...
...
source/libs/sync/inc/syncMessage.h
浏览文件 @
a17e3f32
...
...
@@ -28,30 +28,25 @@ extern "C" {
#include "syncRaftEntry.h"
#include "taosdef.h"
// encode as uint
64
// encode as uint
32
typedef
enum
ESyncMessageType
{
SYNC_PING
=
101
,
SYNC_PING_REPLY
=
103
,
SYNC_CLIENT_REQUEST
,
SYNC_CLIENT_REQUEST_REPLY
,
SYNC_REQUEST_VOTE
,
SYNC_REQUEST_VOTE_REPLY
,
SYNC_APPEND_ENTRIES
,
SYNC_APPEND_ENTRIES_REPLY
,
SYNC_CLIENT_REQUEST
=
105
,
SYNC_CLIENT_REQUEST_REPLY
=
107
,
SYNC_REQUEST_VOTE
=
109
,
SYNC_REQUEST_VOTE_REPLY
=
111
,
SYNC_APPEND_ENTRIES
=
113
,
SYNC_APPEND_ENTRIES_REPLY
=
115
,
}
ESyncMessageType
;
/*
typedef struct SRaftId {
SyncNodeId addr; // typedef uint64_t SyncNodeId;
SyncGroupId vgId; // typedef int32_t SyncGroupId;
} SRaftId;
*/
// ---------------------------------------------
typedef
struct
SyncPing
{
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
uint32_t
dataLen
;
char
data
[];
}
SyncPing
;
...
...
@@ -59,28 +54,22 @@ typedef struct SyncPing {
#define SYNC_PING_FIX_LEN (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(uint32_t))
SyncPing
*
syncPingBuild
(
uint32_t
dataLen
);
void
syncPingDestroy
(
SyncPing
*
pMsg
);
void
syncPingSerialize
(
const
SyncPing
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncPingDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncPing
*
pMsg
);
void
syncPing2RpcMsg
(
const
SyncPing
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncPingFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncPing
*
pMsg
);
cJSON
*
syncPing2Json
(
const
SyncPing
*
pMsg
);
SyncPing
*
syncPingBuild2
(
const
SRaftId
*
srcId
,
const
SRaftId
*
destId
,
const
char
*
str
);
SyncPing
*
syncPingBuild3
(
const
SRaftId
*
srcId
,
const
SRaftId
*
destId
);
// ---------------------------------------------
typedef
struct
SyncPingReply
{
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
uint32_t
dataLen
;
char
data
[];
}
SyncPingReply
;
...
...
@@ -89,74 +78,117 @@ typedef struct SyncPingReply {
(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(uint32_t))
SyncPingReply
*
syncPingReplyBuild
(
uint32_t
dataLen
);
void
syncPingReplyDestroy
(
SyncPingReply
*
pMsg
);
void
syncPingReplySerialize
(
const
SyncPingReply
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncPingReplyDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncPingReply
*
pMsg
);
void
syncPingReply2RpcMsg
(
const
SyncPingReply
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncPingReplyFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncPingReply
*
pMsg
);
cJSON
*
syncPingReply2Json
(
const
SyncPingReply
*
pMsg
);
SyncPingReply
*
syncPingReplyBuild2
(
const
SRaftId
*
srcId
,
const
SRaftId
*
destId
,
const
char
*
str
);
SyncPingReply
*
syncPingReplyBuild3
(
const
SRaftId
*
srcId
,
const
SRaftId
*
destId
);
// ---------------------------------------------
typedef
struct
SyncClientRequest
{
ESyncMessageType
msgType
;
char
*
data
;
uint32_t
dataLen
;
uint32_t
bytes
;
uint32_t
msgType
;
int64_t
seqNum
;
bool
isWeak
;
uint32_t
dataLen
;
char
data
[];
}
SyncClientRequest
;
// ---------------------------------------------
typedef
struct
SyncClientRequestReply
{
ESyncMessageType
msgType
;
uint32_t
bytes
;
uint32_t
msgType
;
int32_t
errCode
;
SSyncBuffer
*
pErrMsg
;
SSyncBuffer
*
pLeaderHint
;
SRaftId
leaderHint
;
}
SyncClientRequestReply
;
// ---------------------------------------------
typedef
struct
SyncRequestVote
{
ESyncMessageType
msgType
;
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
SyncTerm
currentTerm
;
SyncNodeId
nodeId
;
SyncGroupId
vgId
;
SyncIndex
lastLogIndex
;
SyncTerm
lastLogTerm
;
}
SyncRequestVote
;
SyncRequestVote
*
syncRequestVoteBuild
();
void
syncRequestVoteDestroy
(
SyncRequestVote
*
pMsg
);
void
syncRequestVoteSerialize
(
const
SyncRequestVote
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncRequestVoteDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncRequestVote
*
pMsg
);
void
syncRequestVote2RpcMsg
(
const
SyncRequestVote
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncRequestVoteFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncRequestVote
*
pMsg
);
cJSON
*
syncRequestVote2Json
(
const
SyncRequestVote
*
pMsg
);
// ---------------------------------------------
typedef
struct
SyncRequestVoteReply
{
ESyncMessageType
msgType
;
SyncTerm
currentTerm
;
SyncNodeId
nodeId
;
SyncGroupId
vgId
;
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
SyncTerm
term
;
bool
voteGranted
;
}
SyncRequestVoteReply
;
SyncRequestVoteReply
*
SyncRequestVoteReplyBuild
();
void
syncRequestVoteReplyDestroy
(
SyncRequestVoteReply
*
pMsg
);
void
syncRequestVoteReplySerialize
(
const
SyncRequestVoteReply
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncRequestVoteReplyDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncRequestVoteReply
*
pMsg
);
void
syncRequestVoteReply2RpcMsg
(
const
SyncRequestVoteReply
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncRequestVoteReplyFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncRequestVoteReply
*
pMsg
);
cJSON
*
syncRequestVoteReply2Json
(
const
SyncRequestVoteReply
*
pMsg
);
// ---------------------------------------------
typedef
struct
SyncAppendEntries
{
ESyncMessageType
msgType
;
SyncTerm
currentTerm
;
SyncNodeId
nodeId
;
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
SyncIndex
prevLogIndex
;
SyncTerm
prevLogTerm
;
int32_t
entryCount
;
SSyncRaftEntry
*
logEntries
;
SyncIndex
commitIndex
;
uint32_t
dataLen
;
char
data
[];
}
SyncAppendEntries
;
#define SYNC_APPEND_ENTRIES_FIX_LEN \
(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(SRaftId) + sizeof(SRaftId) + sizeof(SyncIndex) + sizeof(SyncTerm) + \
sizeof(SyncIndex) + sizeof(uint32_t))
SyncAppendEntries
*
syncAppendEntriesBuild
(
uint32_t
dataLen
);
void
syncAppendEntriesDestroy
(
SyncAppendEntries
*
pMsg
);
void
syncAppendEntriesSerialize
(
const
SyncAppendEntries
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncAppendEntriesDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncAppendEntries
*
pMsg
);
void
syncAppendEntries2RpcMsg
(
const
SyncAppendEntries
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncAppendEntriesFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncAppendEntries
*
pMsg
);
cJSON
*
syncAppendEntries2Json
(
const
SyncAppendEntries
*
pMsg
);
// ---------------------------------------------
typedef
struct
SyncAppendEntriesReply
{
ESyncMessageType
msgType
;
SyncTerm
currentTerm
;
SyncNodeId
nodeId
;
uint32_t
bytes
;
uint32_t
msgType
;
SRaftId
srcId
;
SRaftId
destId
;
// private data
bool
success
;
SyncIndex
matchIndex
;
}
SyncAppendEntriesReply
;
SyncAppendEntriesReply
*
syncAppendEntriesReplyBuild
();
void
syncAppendEntriesReplyDestroy
(
SyncAppendEntriesReply
*
pMsg
);
void
syncAppendEntriesReplySerialize
(
const
SyncAppendEntriesReply
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncAppendEntriesReplyDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncAppendEntriesReply
*
pMsg
);
void
syncAppendEntriesReply2RpcMsg
(
const
SyncAppendEntriesReply
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncAppendEntriesReplyFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncAppendEntriesReply
*
pMsg
);
cJSON
*
syncAppendEntriesReply2Json
(
const
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncVoteMgr.h
浏览文件 @
a17e3f32
...
...
@@ -26,6 +26,12 @@ extern "C" {
#include "syncInt.h"
#include "taosdef.h"
typedef
struct
SVotesGranted
{
}
SVotesGranted
;
typedef
struct
SVotesResponded
{
}
SVotesResponded
;
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
a17e3f32
...
...
@@ -211,23 +211,17 @@ static void *syncIOConsumerFunc(void *param) {
if
(
pRpcMsg
->
msgType
==
SYNC_PING
)
{
if
(
io
->
FpOnSyncPing
!=
NULL
)
{
SyncPing
*
pSyncMsg
;
SRpcMsg
tmpRpcMsg
;
memcpy
(
&
tmpRpcMsg
,
pRpcMsg
,
sizeof
(
SRpcMsg
));
pSyncMsg
=
syncPingBuild
(
tmpRpcMsg
.
contLen
);
pSyncMsg
=
syncPingBuild
(
pRpcMsg
->
contLen
);
syncPingFromRpcMsg
(
pRpcMsg
,
pSyncMsg
);
// memcpy(pSyncMsg, tmpRpcMsg.pCont, tmpRpcMsg.contLen);
io
->
FpOnSyncPing
(
io
->
pSyncNode
,
pSyncMsg
);
}
}
else
if
(
pRpcMsg
->
msgType
==
SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyBuild
(
pRpcMsg
->
contLen
);
syncPingReplyFromRpcMsg
(
pRpcMsg
,
pSyncMsg
);
if
(
io
->
FpOnSyncPingReply
!=
NULL
)
{
SyncPingReply
*
pSyncMsg
;
pSyncMsg
=
syncPingReplyBuild
(
pRpcMsg
->
contLen
);
syncPingReplyFromRpcMsg
(
pRpcMsg
,
pSyncMsg
);
io
->
FpOnSyncPingReply
(
io
->
pSyncNode
,
pSyncMsg
);
}
}
else
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
a17e3f32
...
...
@@ -88,7 +88,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
}
}
pSyncNode
->
rol
e
=
TAOS_SYNC_STATE_FOLLOWER
;
pSyncNode
->
stat
e
=
TAOS_SYNC_STATE_FOLLOWER
;
syncUtilnodeInfo2raftId
(
&
pSyncNode
->
me
,
pSyncNode
->
vgId
,
&
pSyncNode
->
raftId
);
pSyncNode
->
pPingTimer
=
NULL
;
...
...
@@ -171,16 +171,6 @@ static int32_t syncNodePing(SSyncNode* pSyncNode, const SRaftId* destRaftId, Syn
SRpcMsg
rpcMsg
;
syncPing2RpcMsg
(
pMsg
,
&
rpcMsg
);
/*
SRpcMsg rpcMsg;
rpcMsg.contLen = 64;
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
snprintf((char*)rpcMsg.pCont, rpcMsg.contLen, "%s", "xxxxxxxxxxxxxx");
rpcMsg.handle = NULL;
rpcMsg.msgType = 1;
*/
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
{
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
a17e3f32
...
...
@@ -60,12 +60,15 @@ void syncPingFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPing* pMsg) {
}
cJSON
*
syncPing2Json
(
const
SyncPing
*
pMsg
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON
*
pSrcId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pSrcId
,
"addr"
,
pMsg
->
srcId
.
addr
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
...
...
@@ -79,7 +82,8 @@ cJSON* syncPing2Json(const SyncPing* pMsg) {
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
cJSON
*
pDestId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pDestId
,
"addr"
,
pMsg
->
destId
.
addr
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
destId
.
addr
);
cJSON_AddStringToObject
(
pDestId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
...
...
@@ -154,12 +158,15 @@ void syncPingReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncPingReply* pMsg) {
}
cJSON
*
syncPingReply2Json
(
const
SyncPingReply
*
pMsg
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON
*
pSrcId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pSrcId
,
"addr"
,
pMsg
->
srcId
.
addr
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
...
...
@@ -173,7 +180,8 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) {
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
cJSON
*
pDestId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pDestId
,
"addr"
,
pMsg
->
destId
.
addr
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
destId
.
addr
);
cJSON_AddStringToObject
(
pDestId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
...
...
@@ -208,72 +216,345 @@ SyncPingReply* syncPingReplyBuild3(const SRaftId* srcId, const SRaftId* destId)
return
pMsg
;
}
#if 0
void syncPingSerialize(const SyncPing* pMsg, char** ppBuf, uint32_t* bufLen) {
*bufLen = sizeof(SyncPing) + pMsg->dataLen;
*ppBuf = (char*)malloc(*bufLen);
void* pStart = *ppBuf;
uint32_t allBytes = *bufLen;
// ---- message process SyncRequestVote----
SyncRequestVote
*
syncRequestVoteBuild
()
{
uint32_t
bytes
=
sizeof
(
SyncRequestVote
);
SyncRequestVote
*
pMsg
=
malloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
SYNC_REQUEST_VOTE
;
}
void
syncRequestVoteDestroy
(
SyncRequestVote
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
free
(
pMsg
);
}
}
void
syncRequestVoteSerialize
(
const
SyncRequestVote
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
)
{
assert
(
pMsg
->
bytes
<=
bufLen
);
memcpy
(
buf
,
pMsg
,
pMsg
->
bytes
);
}
void
syncRequestVoteDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncRequestVote
*
pMsg
)
{
memcpy
(
pMsg
,
buf
,
len
);
assert
(
len
==
pMsg
->
bytes
);
}
void
syncRequestVote2RpcMsg
(
const
SyncRequestVote
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
memset
(
pRpcMsg
,
0
,
sizeof
(
*
pRpcMsg
));
pRpcMsg
->
msgType
=
pMsg
->
msgType
;
pRpcMsg
->
contLen
=
pMsg
->
bytes
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
syncRequestVoteSerialize
(
pMsg
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
}
void
syncRequestVoteFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncRequestVote
*
pMsg
)
{
syncRequestVoteDeserialize
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
pMsg
);
}
cJSON
*
syncRequestVote2Json
(
const
SyncRequestVote
*
pMsg
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON
*
pSrcId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pSrcId
,
"vgId"
,
pMsg
->
srcId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
cJSON
*
pDestId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pDestId
,
"addr"
,
pMsg
->
destId
.
addr
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pDestId
,
"vgId"
,
pMsg
->
destId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"destId"
,
pDestId
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
currentTerm
);
cJSON_AddStringToObject
(
pRoot
,
"currentTerm"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
lastLogIndex
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogIndex"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
lastLogTerm
);
cJSON_AddStringToObject
(
pRoot
,
"lastLogTerm"
,
u64buf
);
int len = 0;
len = taosEncodeFixedU32(&pStart, pMsg->msgType);
allBytes -= len;
assert(len > 0);
pStart += len;
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncRequestVote"
,
pRoot
);
return
pJson
;
}
len = taosEncodeFixedU64(&pStart, pMsg->srcId.addr);
allBytes -= len;
assert(len > 0);
pStart += len;
// ---- message process SyncRequestVoteReply----
SyncRequestVoteReply
*
SyncRequestVoteReplyBuild
()
{
uint32_t
bytes
=
sizeof
(
SyncRequestVoteReply
);
SyncRequestVoteReply
*
pMsg
=
malloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
SYNC_REQUEST_VOTE_REPLY
;
}
len = taosEncodeFixedI32(&pStart, pMsg->srcId.vgId);
allBytes -= len;
assert(len > 0);
pStart += len;
void
syncRequestVoteReplyDestroy
(
SyncRequestVoteReply
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
free
(
pMsg
);
}
}
len = taosEncodeFixedU64(&pStart, pMsg->destId.addr);
a
llBytes -= len
;
assert(len > 0
);
pStart += len;
void
syncRequestVoteReplySerialize
(
const
SyncRequestVoteReply
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
)
{
a
ssert
(
pMsg
->
bytes
<=
bufLen
)
;
memcpy
(
buf
,
pMsg
,
pMsg
->
bytes
);
}
len = taosEncodeFixedI32(&pStart, pMsg->destId.vgId);
allBytes -= len
;
assert(len
> 0
);
pStart += len;
void
syncRequestVoteReplyDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncRequestVoteReply
*
pMsg
)
{
memcpy
(
pMsg
,
buf
,
len
)
;
assert
(
len
==
pMsg
->
bytes
);
}
len = taosEncodeFixedU32(&pStart, pMsg->dataLen);
allBytes -= len;
assert(len > 0);
pStart += len;
void
syncRequestVoteReply2RpcMsg
(
const
SyncRequestVoteReply
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
memset
(
pRpcMsg
,
0
,
sizeof
(
*
pRpcMsg
));
pRpcMsg
->
msgType
=
pMsg
->
msgType
;
pRpcMsg
->
contLen
=
pMsg
->
bytes
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
syncRequestVoteReplySerialize
(
pMsg
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
}
memcpy(pStart, pMsg->data, pMsg->dataLen);
allBytes -= pMsg->dataLen;
assert(allBytes == 0);
void
syncRequestVoteReplyFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncRequestVoteReply
*
pMsg
)
{
syncRequestVoteReplyDeserialize
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
pMsg
);
}
cJSON
*
syncRequestVoteReply2Json
(
const
SyncRequestVoteReply
*
pMsg
)
{
char
u64buf
[
128
];
void syncPingDeserialize(const char* buf, uint32_t len, SyncPing* pMsg) {
void* pStart = (void*)buf;
uint64_t u64;
int32_t i32;
uint32_t u32;
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
pStart = taosDecodeFixedU64(pStart, &u64);
pMsg->msgType = u64;
cJSON
*
pSrcId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pSrcId
,
"vgId"
,
pMsg
->
srcId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
pStart = taosDecodeFixedU64(pStart, &u64);
pMsg->srcId.addr = u64;
cJSON
*
pDestId
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pDestId
,
"addr"
,
pMsg
->
destId
.
addr
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pDestId
,
"vgId"
,
pMsg
->
destId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"destId"
,
pDestId
);
pStart = taosDecodeFixedI32(pStart, &i32);
pMsg->srcId.vgId = i32;
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
term
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"vote_granted"
,
pMsg
->
voteGranted
);
pStart = taosDecodeFixedU64(pStart, &u64);
pMsg->destId.addr = u64;
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncRequestVoteReply"
,
pRoot
);
return
pJson
;
}
pStart = taosDecodeFixedI32(pStart, &i32);
pMsg->destId.vgId = i32;
// ---- message process SyncAppendEntries----
SyncAppendEntries
*
syncAppendEntriesBuild
(
uint32_t
dataLen
)
{
uint32_t
bytes
=
SYNC_APPEND_ENTRIES_FIX_LEN
+
dataLen
;
SyncAppendEntries
*
pMsg
=
malloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
SYNC_APPEND_ENTRIES
;
pMsg
->
dataLen
=
dataLen
;
}
pStart = taosDecodeFixedU32(pStart, &u32);
pMsg->dataLen = u32;
void
syncAppendEntriesDestroy
(
SyncAppendEntries
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
free
(
pMsg
);
}
}
void
syncAppendEntriesSerialize
(
const
SyncAppendEntries
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
)
{
assert
(
pMsg
->
bytes
<=
bufLen
);
memcpy
(
buf
,
pMsg
,
pMsg
->
bytes
);
}
void
syncAppendEntriesDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncAppendEntries
*
pMsg
)
{
memcpy
(
pMsg
,
buf
,
len
);
assert
(
len
==
pMsg
->
bytes
);
assert
(
pMsg
->
bytes
==
SYNC_APPEND_ENTRIES_FIX_LEN
+
pMsg
->
dataLen
);
}
void
syncAppendEntries2RpcMsg
(
const
SyncAppendEntries
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
memset
(
pRpcMsg
,
0
,
sizeof
(
*
pRpcMsg
));
pRpcMsg
->
msgType
=
pMsg
->
msgType
;
pRpcMsg
->
contLen
=
pMsg
->
bytes
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
syncAppendEntriesSerialize
(
pMsg
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
}
void
syncAppendEntriesFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncAppendEntries
*
pMsg
)
{
syncAppendEntriesDeserialize
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
pMsg
);
}
cJSON
*
syncAppendEntries2Json
(
const
SyncAppendEntries
*
pMsg
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON
*
pSrcId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pSrcId
,
"vgId"
,
pMsg
->
srcId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
cJSON
*
pDestId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
destId
.
addr
);
cJSON_AddStringToObject
(
pDestId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pDestId
,
"vgId"
,
pMsg
->
destId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"destId"
,
pDestId
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
prevLogIndex
);
cJSON_AddStringToObject
(
pRoot
,
"pre_log_index"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
prevLogTerm
);
cJSON_AddStringToObject
(
pRoot
,
"pre_log_term"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
commitIndex
);
cJSON_AddStringToObject
(
pRoot
,
"commit_index"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pMsg
->
dataLen
);
cJSON_AddStringToObject
(
pRoot
,
"data"
,
pMsg
->
data
);
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncAppendEntries"
,
pRoot
);
return
pJson
;
}
// ---- message process SyncAppendEntriesReply----
SyncAppendEntriesReply
*
syncAppendEntriesReplyBuild
()
{
uint32_t
bytes
=
sizeof
(
SyncAppendEntriesReply
);
SyncAppendEntriesReply
*
pMsg
=
malloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
SYNC_APPEND_ENTRIES_REPLY
;
}
void
syncAppendEntriesReplyDestroy
(
SyncAppendEntriesReply
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
free
(
pMsg
);
}
}
void
syncAppendEntriesReplySerialize
(
const
SyncAppendEntriesReply
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
)
{
assert
(
pMsg
->
bytes
<=
bufLen
);
memcpy
(
buf
,
pMsg
,
pMsg
->
bytes
);
}
void
syncAppendEntriesReplyDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncAppendEntriesReply
*
pMsg
)
{
memcpy
(
pMsg
,
buf
,
len
);
assert
(
len
==
pMsg
->
bytes
);
}
void
syncAppendEntriesReply2RpcMsg
(
const
SyncAppendEntriesReply
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
memset
(
pRpcMsg
,
0
,
sizeof
(
*
pRpcMsg
));
pRpcMsg
->
msgType
=
pMsg
->
msgType
;
pRpcMsg
->
contLen
=
pMsg
->
bytes
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
syncAppendEntriesReplySerialize
(
pMsg
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
}
void
syncAppendEntriesReplyFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncAppendEntriesReply
*
pMsg
)
{
syncAppendEntriesReplyDeserialize
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
pMsg
);
}
cJSON
*
syncAppendEntriesReply2Json
(
const
SyncAppendEntriesReply
*
pMsg
)
{
char
u64buf
[
128
];
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON
*
pSrcId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
srcId
.
addr
);
cJSON_AddStringToObject
(
pSrcId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
srcId
.
addr
;
cJSON
*
pTmp
=
pSrcId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pSrcId
,
"vgId"
,
pMsg
->
srcId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"srcId"
,
pSrcId
);
cJSON
*
pDestId
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
destId
.
addr
);
cJSON_AddStringToObject
(
pDestId
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pMsg
->
destId
.
addr
;
cJSON
*
pTmp
=
pDestId
;
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
cJSON_AddStringToObject
(
pTmp
,
"addr_host"
,
host
);
cJSON_AddNumberToObject
(
pTmp
,
"addr_port"
,
port
);
}
cJSON_AddNumberToObject
(
pDestId
,
"vgId"
,
pMsg
->
destId
.
vgId
);
cJSON_AddItemToObject
(
pRoot
,
"destId"
,
pDestId
);
cJSON_AddNumberToObject
(
pRoot
,
"success"
,
pMsg
->
success
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pMsg
->
matchIndex
);
cJSON_AddStringToObject
(
pRoot
,
"match_index"
,
u64buf
);
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncAppendEntriesReply"
,
pRoot
);
return
pJson
;
}
\ No newline at end of file
#endif
\ No newline at end of file
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
a17e3f32
...
...
@@ -3,6 +3,7 @@
#include "syncIO.h"
#include "syncInt.h"
#include "syncMessage.h"
#include "syncUtil.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
...
...
@@ -14,6 +15,7 @@ void logTest() {
}
#define PING_MSG_LEN 20
#define APPEND_ENTRIES_VALUE_LEN 32
void
test1
()
{
sTrace
(
"test1: ---- syncPingSerialize, syncPingDeserialize"
);
...
...
@@ -21,16 +23,16 @@ void test1() {
char
msg
[
PING_MSG_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"test ping"
);
SyncPing
*
pMsg
=
syncPingBuild
(
PING_MSG_LEN
);
pMsg
->
srcId
.
addr
=
1
;
pMsg
->
srcId
.
vgId
=
2
;
pMsg
->
destId
.
addr
=
3
;
pMsg
->
destId
.
vgId
=
4
;
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1111
)
;
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
2222
)
;
pMsg
->
destId
.
vgId
=
100
;
memcpy
(
pMsg
->
data
,
msg
,
PING_MSG_LEN
);
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPing:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -45,7 +47,7 @@ void test1() {
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPing2:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -61,16 +63,16 @@ void test2() {
char
msg
[
PING_MSG_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"hello raft"
);
SyncPing
*
pMsg
=
syncPingBuild
(
PING_MSG_LEN
);
pMsg
->
srcId
.
addr
=
100
;
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
3333
)
;
pMsg
->
srcId
.
vgId
=
200
;
pMsg
->
destId
.
addr
=
300
;
pMsg
->
destId
.
vgId
=
4
00
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
4444
)
;
pMsg
->
destId
.
vgId
=
2
00
;
memcpy
(
pMsg
->
data
,
msg
,
PING_MSG_LEN
);
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPing:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -84,7 +86,7 @@ void test2() {
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPing2:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -99,16 +101,16 @@ void test3() {
char
msg
[
PING_MSG_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"test ping"
);
SyncPingReply
*
pMsg
=
syncPingReplyBuild
(
PING_MSG_LEN
);
pMsg
->
srcId
.
addr
=
19
;
pMsg
->
srcId
.
vgId
=
29
;
pMsg
->
destId
.
addr
=
39
;
pMsg
->
destId
.
vgId
=
49
;
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
5555
)
;
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
6666
)
;
pMsg
->
destId
.
vgId
=
100
;
memcpy
(
pMsg
->
data
,
msg
,
PING_MSG_LEN
);
{
cJSON
*
pJson
=
syncPingReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPingReply:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -123,7 +125,7 @@ void test3() {
{
cJSON
*
pJson
=
syncPingReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPingReply2:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -139,16 +141,16 @@ void test4() {
char
msg
[
PING_MSG_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"hello raft"
);
SyncPingReply
*
pMsg
=
syncPingReplyBuild
(
PING_MSG_LEN
);
pMsg
->
srcId
.
addr
=
66
;
pMsg
->
srcId
.
vgId
=
77
;
pMsg
->
destId
.
addr
=
88
;
pMsg
->
destId
.
vgId
=
99
;
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
7777
)
;
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
8888
)
;
pMsg
->
destId
.
vgId
=
100
;
memcpy
(
pMsg
->
data
,
msg
,
PING_MSG_LEN
);
{
cJSON
*
pJson
=
syncPingReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPingReply:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -162,7 +164,7 @@ void test4() {
{
cJSON
*
pJson
=
syncPingReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
SyncPingReply2:
\n
%s
\n\n
"
,
serialized
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
...
...
@@ -170,6 +172,321 @@ void test4() {
syncPingReplyDestroy
(
pMsg
);
syncPingReplyDestroy
(
pMsg2
);
}
void
test5
()
{
sTrace
(
"test5: ---- syncRequestVoteSerialize, syncRequestVoteDeserialize"
);
SyncRequestVote
*
pMsg
=
syncRequestVoteBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1234
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"8.8.8.8"
,
5678
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
currentTerm
=
20
;
pMsg
->
lastLogIndex
=
21
;
pMsg
->
lastLogTerm
=
22
;
{
cJSON
*
pJson
=
syncRequestVote2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
uint32_t
bufLen
=
pMsg
->
bytes
;
char
*
buf
=
(
char
*
)
malloc
(
bufLen
);
syncRequestVoteSerialize
(
pMsg
,
buf
,
bufLen
);
SyncRequestVote
*
pMsg2
=
(
SyncRequestVote
*
)
malloc
(
pMsg
->
bytes
);
syncRequestVoteDeserialize
(
buf
,
bufLen
,
pMsg2
);
{
cJSON
*
pJson
=
syncRequestVote2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncRequestVoteDestroy
(
pMsg
);
syncRequestVoteDestroy
(
pMsg2
);
free
(
buf
);
}
void
test6
()
{
sTrace
(
"test6: ---- syncRequestVote2RpcMsg, syncRequestVoteFromRpcMsg"
);
SyncRequestVote
*
pMsg
=
syncRequestVoteBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1234
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"8.8.8.8"
,
5678
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
currentTerm
=
20
;
pMsg
->
lastLogIndex
=
21
;
pMsg
->
lastLogTerm
=
22
;
{
cJSON
*
pJson
=
syncRequestVote2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
SRpcMsg
rpcMsg
;
syncRequestVote2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncRequestVote
*
pMsg2
=
(
SyncRequestVote
*
)
malloc
(
pMsg
->
bytes
);
syncRequestVoteFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
rpcFreeCont
(
rpcMsg
.
pCont
);
{
cJSON
*
pJson
=
syncRequestVote2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncRequestVoteDestroy
(
pMsg
);
syncRequestVoteDestroy
(
pMsg2
);
}
void
test7
()
{
sTrace
(
"test7: ---- syncRequestVoteReplySerialize, syncRequestVoteReplyDeserialize"
);
SyncRequestVoteReply
*
pMsg
=
SyncRequestVoteReplyBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1234
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"8.8.8.8"
,
5678
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
term
=
20
;
pMsg
->
voteGranted
=
1
;
{
cJSON
*
pJson
=
syncRequestVoteReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
uint32_t
bufLen
=
pMsg
->
bytes
;
char
*
buf
=
(
char
*
)
malloc
(
bufLen
);
syncRequestVoteReplySerialize
(
pMsg
,
buf
,
bufLen
);
SyncRequestVoteReply
*
pMsg2
=
(
SyncRequestVoteReply
*
)
malloc
(
pMsg
->
bytes
);
syncRequestVoteReplyDeserialize
(
buf
,
bufLen
,
pMsg2
);
{
cJSON
*
pJson
=
syncRequestVoteReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncRequestVoteReplyDestroy
(
pMsg
);
syncRequestVoteReplyDestroy
(
pMsg2
);
free
(
buf
);
}
void
test8
()
{
sTrace
(
"test8: ---- syncRequestVoteReply2RpcMsg, syncRequestVoteReplyFromRpcMsg"
);
SyncRequestVoteReply
*
pMsg
=
SyncRequestVoteReplyBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1234
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"8.8.8.8"
,
5678
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
term
=
20
;
pMsg
->
voteGranted
=
1
;
{
cJSON
*
pJson
=
syncRequestVoteReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
SRpcMsg
rpcMsg
;
syncRequestVoteReply2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncRequestVoteReply
*
pMsg2
=
(
SyncRequestVoteReply
*
)
malloc
(
pMsg
->
bytes
);
syncRequestVoteReplyFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
rpcFreeCont
(
rpcMsg
.
pCont
);
{
cJSON
*
pJson
=
syncRequestVoteReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncRequestVoteReplyDestroy
(
pMsg
);
syncRequestVoteReplyDestroy
(
pMsg2
);
}
void
test9
()
{
sTrace
(
"test9: ---- syncAppendEntriesSerialize, syncAppendEntriesDeserialize"
);
char
msg
[
APPEND_ENTRIES_VALUE_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"test value"
);
SyncAppendEntries
*
pMsg
=
syncAppendEntriesBuild
(
APPEND_ENTRIES_VALUE_LEN
);
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1111
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
2222
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
prevLogIndex
=
55
;
pMsg
->
prevLogTerm
=
66
;
pMsg
->
commitIndex
=
77
;
memcpy
(
pMsg
->
data
,
msg
,
APPEND_ENTRIES_VALUE_LEN
);
{
cJSON
*
pJson
=
syncAppendEntries2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
uint32_t
bufLen
=
pMsg
->
bytes
;
char
*
buf
=
(
char
*
)
malloc
(
bufLen
);
syncAppendEntriesSerialize
(
pMsg
,
buf
,
bufLen
);
SyncAppendEntries
*
pMsg2
=
(
SyncAppendEntries
*
)
malloc
(
pMsg
->
bytes
);
syncAppendEntriesDeserialize
(
buf
,
bufLen
,
pMsg2
);
{
cJSON
*
pJson
=
syncAppendEntries2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncAppendEntriesDestroy
(
pMsg
);
syncAppendEntriesDestroy
(
pMsg2
);
free
(
buf
);
}
void
test10
()
{
sTrace
(
"test10: ---- syncAppendEntries2RpcMsg, syncAppendEntriesFromRpcMsg"
);
char
msg
[
APPEND_ENTRIES_VALUE_LEN
];
snprintf
(
msg
,
sizeof
(
msg
),
"%s"
,
"test value"
);
SyncAppendEntries
*
pMsg
=
syncAppendEntriesBuild
(
APPEND_ENTRIES_VALUE_LEN
);
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1111
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
2222
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
prevLogIndex
=
55
;
pMsg
->
prevLogTerm
=
66
;
pMsg
->
commitIndex
=
77
;
memcpy
(
pMsg
->
data
,
msg
,
APPEND_ENTRIES_VALUE_LEN
);
{
cJSON
*
pJson
=
syncAppendEntries2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
SRpcMsg
rpcMsg
;
syncAppendEntries2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncAppendEntries
*
pMsg2
=
(
SyncAppendEntries
*
)
malloc
(
pMsg
->
bytes
);
syncAppendEntriesFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
rpcFreeCont
(
rpcMsg
.
pCont
);
{
cJSON
*
pJson
=
syncAppendEntries2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncAppendEntriesDestroy
(
pMsg
);
syncAppendEntriesDestroy
(
pMsg2
);
}
void
test11
()
{
sTrace
(
"test11: ---- syncAppendEntriesReplySerialize, syncAppendEntriesReplyDeserialize"
);
SyncAppendEntriesReply
*
pMsg
=
syncAppendEntriesReplyBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1111
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
2222
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
success
=
1
;
pMsg
->
matchIndex
=
23
;
{
cJSON
*
pJson
=
syncAppendEntriesReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
uint32_t
bufLen
=
pMsg
->
bytes
;
char
*
buf
=
(
char
*
)
malloc
(
bufLen
);
syncAppendEntriesReplySerialize
(
pMsg
,
buf
,
bufLen
);
SyncAppendEntriesReply
*
pMsg2
=
(
SyncAppendEntriesReply
*
)
malloc
(
pMsg
->
bytes
);
syncAppendEntriesReplyDeserialize
(
buf
,
bufLen
,
pMsg2
);
{
cJSON
*
pJson
=
syncAppendEntriesReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncAppendEntriesReplyDestroy
(
pMsg
);
syncAppendEntriesReplyDestroy
(
pMsg2
);
free
(
buf
);
}
void
test12
()
{
sTrace
(
"test12: ---- syncAppendEntriesReply2RpcMsg, syncAppendEntriesReplyFromRpcMsg"
);
SyncAppendEntriesReply
*
pMsg
=
syncAppendEntriesReplyBuild
();
pMsg
->
srcId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
1111
);
pMsg
->
srcId
.
vgId
=
100
;
pMsg
->
destId
.
addr
=
syncUtilAddr2U64
(
"127.0.0.1"
,
2222
);
pMsg
->
destId
.
vgId
=
100
;
pMsg
->
success
=
1
;
pMsg
->
matchIndex
=
23
;
{
cJSON
*
pJson
=
syncAppendEntriesReply2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
SRpcMsg
rpcMsg
;
syncAppendEntriesReply2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncAppendEntriesReply
*
pMsg2
=
(
SyncAppendEntriesReply
*
)
malloc
(
pMsg
->
bytes
);
syncAppendEntriesReplyFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
rpcFreeCont
(
rpcMsg
.
pCont
);
{
cJSON
*
pJson
=
syncAppendEntriesReply2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
printf
(
"
\n
%s
\n\n
"
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
syncAppendEntriesReplyDestroy
(
pMsg
);
syncAppendEntriesReplyDestroy
(
pMsg2
);
}
int
main
()
{
// taosInitLog((char*)"syncPingTest.log", 100000, 10);
tsAsyncLog
=
0
;
...
...
@@ -179,6 +496,14 @@ int main() {
test2
();
test3
();
test4
();
test5
();
test6
();
test7
();
test8
();
test9
();
test10
();
test11
();
test12
();
return
0
;
}
source/libs/sync/test/syncIOSendMsgClientTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgServerTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncPingTest.cpp
浏览文件 @
a17e3f32
...
...
@@ -13,7 +13,9 @@ void logTest() {
sFatal
(
"--- sync log test: fatal"
);
}
SSyncNode
*
doSync
()
{
uint16_t
ports
[
3
]
=
{
7010
,
7110
,
7210
};
SSyncNode
*
doSync
(
int
myIndex
)
{
SSyncFSM
*
pFsm
;
SSyncInfo
syncInfo
;
...
...
@@ -24,18 +26,18 @@ SSyncNode* doSync() {
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./test_sync_ping"
);
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
0
;
pCfg
->
replicaNum
=
2
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
3
;
pCfg
->
nodeInfo
[
0
].
nodePort
=
7010
;
pCfg
->
nodeInfo
[
0
].
nodePort
=
ports
[
0
]
;
snprintf
(
pCfg
->
nodeInfo
[
0
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
0
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
pCfg
->
nodeInfo
[
1
].
nodePort
=
7110
;
pCfg
->
nodeInfo
[
1
].
nodePort
=
ports
[
1
]
;
snprintf
(
pCfg
->
nodeInfo
[
1
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
1
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[1].nodeFqdn);
pCfg
->
nodeInfo
[
2
].
nodePort
=
7210
;
pCfg
->
nodeInfo
[
2
].
nodePort
=
ports
[
2
]
;
snprintf
(
pCfg
->
nodeInfo
[
2
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
2
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[2].nodeFqdn);
...
...
@@ -53,20 +55,25 @@ void timerPingAll(void* param, void* tmrId) {
syncNodePingAll
(
pSyncNode
);
}
int
main
()
{
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char*)"syncPingTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
logTest
();
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
7010
);
int
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
ret
=
syncEnvStart
();
assert
(
ret
==
0
);
SSyncNode
*
pSyncNode
=
doSync
();
SSyncNode
*
pSyncNode
=
doSync
(
myIndex
);
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
...
...
source/libs/sync/test/syncRaftStoreTest.cpp
浏览文件 @
a17e3f32
#include "syncRaftStore.h"
#include <stdio.h>
#include "gtest/gtest.h"
#include <gtest/gtest.h>
#include "syncRaftStore.h"
#include "syncIO.h"
#include "syncInt.h"
...
...
source/libs/sync/test/syncTest.cpp
浏览文件 @
a17e3f32
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
...
...
source/libs/tdb/src/db/tdb.c
浏览文件 @
a17e3f32
...
...
@@ -90,7 +90,7 @@ int tdbOpen(TDB *pDb, const char *fname, const char *dbname, TENV *pEnv) {
// get page file from the env, if not opened yet, open it
pPgFile
=
NULL
;
snprintf
(
dbfname
,
128
,
"%s/%s"
,
tdbEnvGetRootDir
(
pEnv
),
fname
);
fileExist
=
(
tdbCheckFileAccess
(
fname
,
TDB_F_OK
)
==
0
);
fileExist
=
taosCheckExistFile
(
fname
);
if
(
fileExist
)
{
tdbGnrtFileID
(
dbfname
,
fileid
,
false
);
pPgFile
=
tdbEnvGetPageFile
(
pEnv
,
fileid
);
...
...
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
a17e3f32
...
...
@@ -30,10 +30,10 @@ extern "C" {
int
tdbGnrtFileID
(
const
char
*
fname
,
uint8_t
*
fileid
,
bool
unique
);
#define TDB_F_OK 0x1
#define TDB_R_OK 0x2
#define TDB_W_OK 0x4
int
tdbCheckFileAccess
(
const
char
*
pathname
,
int
mode
);
//
#define TDB_F_OK 0x1
//
#define TDB_R_OK 0x2
//
#define TDB_W_OK 0x4
//
int tdbCheckFileAccess(const char *pathname, int mode);
int
tdbGetFileSize
(
const
char
*
fname
,
pgsz_t
pgSize
,
pgno_t
*
pSize
);
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
a17e3f32
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tdb.h"
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/libs/transport/src/transSrv.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/os/src/osDir.c
浏览文件 @
a17e3f32
...
...
@@ -60,7 +60,7 @@ void taosRemoveDir(const char *dirname) {
//printf("dir:%s is removed\n", dirname);
}
int32_t
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
);
}
bool
taosDirExist
(
char
*
dirname
)
{
return
taosCheckExistFile
(
dirname
);
}
int32_t
taosMkDir
(
const
char
*
dirname
)
{
int32_t
code
=
mkdir
(
dirname
,
0755
);
...
...
source/os/src/osFile.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/util/test/cacheTest.cpp
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/util/test/encodeTest.cpp
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
source/util/test/freelistTest.cpp
浏览文件 @
a17e3f32
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tfreelist.h"
...
...
source/util/test/hashTest.cpp
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
tools/shell/src/backup/shellImport.c
浏览文件 @
a17e3f32
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录