Merge branch 'fix/valgrind' into feature/3.0_liaohj
This commit is contained in:
commit
ea8832baa5
|
@ -18,15 +18,15 @@ target_sources(demoapi
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tmq
|
target_link_libraries(tmq
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tstream
|
target_link_libraries(tstream
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(demoapi
|
target_link_libraries(demoapi
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(tmq
|
target_include_directories(tmq
|
||||||
|
|
|
@ -36,12 +36,12 @@ void *taosMemoryStrDup(void *ptr);
|
||||||
void taosMemoryFree(void *ptr);
|
void taosMemoryFree(void *ptr);
|
||||||
int32_t taosMemorySize(void *ptr);
|
int32_t taosMemorySize(void *ptr);
|
||||||
|
|
||||||
#define taosMemoryFreeClear(ptr) \
|
#define taosMemoryFreeClear(ptr) \
|
||||||
do { \
|
do { \
|
||||||
if (ptr) { \
|
if (ptr) { \
|
||||||
taosMemoryFree((void*)ptr); \
|
taosMemoryFree((void *)ptr); \
|
||||||
(ptr) = NULL; \
|
(ptr) = NULL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
aux_source_directory(src CLIENT_SRC)
|
aux_source_directory(src CLIENT_SRC)
|
||||||
add_library(taos ${CLIENT_SRC})
|
add_library(taos SHARED ${CLIENT_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
taos
|
taos
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
@ -11,6 +11,25 @@ target_link_libraries(
|
||||||
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
taos
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${TD_VER_NUMBER}
|
||||||
|
SOVERSION ${TD_VER_NUMBER}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(taos_static STATIC ${CLIENT_SRC})
|
||||||
|
target_include_directories(
|
||||||
|
taos_static
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
taos_static
|
||||||
|
INTERFACE api
|
||||||
|
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||||
|
)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
|
@ -69,9 +69,9 @@ void taos_cleanup(void) {
|
||||||
rpcCleanup();
|
rpcCleanup();
|
||||||
catalogDestroy();
|
catalogDestroy();
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
taosCloseLog();
|
|
||||||
|
|
||||||
tscInfo("all local resources released");
|
tscInfo("all local resources released");
|
||||||
|
taosCloseLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfRet taos_set_config(const char *config) {
|
setConfRet taos_set_config(const char *config) {
|
||||||
|
|
|
@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
clientTest
|
clientTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
tmqTest
|
tmqTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -238,7 +238,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
|
||||||
|
|
||||||
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
||||||
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) {
|
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) {
|
||||||
uError("failed to load from config file:%s since %s", cfgFile, terrstr());
|
uInfo("cfg file:%s not read since %s", cfgFile, terrstr());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@ target_include_directories(
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode_interface cjson mnode vnode qnode snode bnode wal sync taos tfs monitor
|
dnode_interface cjson mnode vnode qnode snode bnode wal sync taos_static tfs monitor
|
||||||
)
|
)
|
|
@ -262,6 +262,7 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
|
||||||
vmCloseVnodes(pMgmt);
|
vmCloseVnodes(pMgmt);
|
||||||
vmStopWorker(pMgmt);
|
vmStopWorker(pMgmt);
|
||||||
vnodeCleanup();
|
vnodeCleanup();
|
||||||
|
tfsClose(pMgmt->pTfs);
|
||||||
// walCleanUp();
|
// walCleanUp();
|
||||||
taosMemoryFree(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
|
|
|
@ -18,12 +18,11 @@ target_sources(
|
||||||
"src/vnd/vnodeSvr.c"
|
"src/vnd/vnodeSvr.c"
|
||||||
|
|
||||||
# meta
|
# meta
|
||||||
# "src/meta/metaBDBImpl.c"
|
"src/meta/metaOpen.c"
|
||||||
"src/meta/metaIdx.c"
|
"src/meta/metaIdx.c"
|
||||||
"src/meta/metaMain.c"
|
|
||||||
"src/meta/metaTable.c"
|
"src/meta/metaTable.c"
|
||||||
"src/meta/metaTbUid.c"
|
|
||||||
"src/meta/metaTDBImpl.c"
|
"src/meta/metaTDBImpl.c"
|
||||||
|
# "src/meta/metaBDBImpl.c"
|
||||||
|
|
||||||
# tsdb
|
# tsdb
|
||||||
"src/tsdb/tsdbTDBImpl.c"
|
"src/tsdb/tsdbTDBImpl.c"
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SMetaCache SMetaCache;
|
|
||||||
typedef struct SMetaIdx SMetaIdx;
|
typedef struct SMetaIdx SMetaIdx;
|
||||||
typedef struct SMetaDB SMetaDB;
|
typedef struct SMetaDB SMetaDB;
|
||||||
typedef struct SMCtbCursor SMCtbCursor;
|
typedef struct SMCtbCursor SMCtbCursor;
|
||||||
|
@ -36,13 +35,22 @@ typedef struct SMSmaCursor SMSmaCursor;
|
||||||
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
|
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
// metaOpen ==================
|
||||||
|
int metaOpen(SVnode* pVnode, SMeta** ppMeta);
|
||||||
|
int metaClose(SMeta* pMeta);
|
||||||
|
|
||||||
|
// metaIdx ==================
|
||||||
|
int metaOpenIdx(SMeta* pMeta);
|
||||||
|
void metaCloseIdx(SMeta* pMeta);
|
||||||
|
int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
|
||||||
|
int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
||||||
|
|
||||||
|
static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); }
|
||||||
|
|
||||||
#define META_SUPER_TABLE TD_SUPER_TABLE
|
#define META_SUPER_TABLE TD_SUPER_TABLE
|
||||||
#define META_CHILD_TABLE TD_CHILD_TABLE
|
#define META_CHILD_TABLE TD_CHILD_TABLE
|
||||||
#define META_NORMAL_TABLE TD_NORMAL_TABLE
|
#define META_NORMAL_TABLE TD_NORMAL_TABLE
|
||||||
|
|
||||||
SMeta* metaOpen(const char* path, SMemAllocatorFactory* pMAF);
|
|
||||||
void metaClose(SMeta* pMeta);
|
|
||||||
void metaRemove(const char* path);
|
|
||||||
int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg);
|
int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg);
|
||||||
int metaDropTable(SMeta* pMeta, tb_uid_t uid);
|
int metaDropTable(SMeta* pMeta, tb_uid_t uid);
|
||||||
int metaCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta);
|
||||||
|
@ -71,37 +79,15 @@ int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid);
|
||||||
int metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg);
|
int metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg);
|
||||||
int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
|
int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
|
||||||
|
|
||||||
// SMetaCache
|
|
||||||
int metaOpenCache(SMeta* pMeta);
|
|
||||||
void metaCloseCache(SMeta* pMeta);
|
|
||||||
|
|
||||||
// SMetaIdx
|
// SMetaIdx
|
||||||
int metaOpenIdx(SMeta* pMeta);
|
|
||||||
void metaCloseIdx(SMeta* pMeta);
|
|
||||||
int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
|
|
||||||
int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
|
||||||
|
|
||||||
// STbUidGnrt
|
|
||||||
typedef struct STbUidGenerator {
|
|
||||||
tb_uid_t nextUid;
|
|
||||||
} STbUidGenerator;
|
|
||||||
|
|
||||||
// STableUidGenerator
|
|
||||||
int metaOpenUidGnrt(SMeta* pMeta);
|
|
||||||
void metaCloseUidGnrt(SMeta* pMeta);
|
|
||||||
|
|
||||||
// tb_uid_t
|
|
||||||
#define IVLD_TB_UID 0
|
|
||||||
tb_uid_t metaGenerateUid(SMeta* pMeta);
|
tb_uid_t metaGenerateUid(SMeta* pMeta);
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
char* path;
|
char* path;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
SMetaDB* pDB;
|
SMetaDB* pDB;
|
||||||
SMetaIdx* pIdx;
|
SMetaIdx* pIdx;
|
||||||
SMetaCache* pCache;
|
|
||||||
STbUidGenerator uidGnrt;
|
|
||||||
SMemAllocatorFactory* pmaf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -44,6 +44,11 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||||
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||||
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
||||||
|
int vnodeBegin(SVnode* pVnode, int option);
|
||||||
|
int vnodeSyncCommit(SVnode* pVnode);
|
||||||
|
int vnodeAsyncCommit(SVnode* pVnode);
|
||||||
|
|
||||||
|
#define vnodeShouldCommit vnodeBufPoolIsFull
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// SVBufPool
|
// SVBufPool
|
||||||
|
@ -84,13 +89,8 @@ bool vmaIsFull(SVMemAllocator* pVMA);
|
||||||
// vnodeCfg.h
|
// vnodeCfg.h
|
||||||
extern const SVnodeCfg vnodeCfgDefault;
|
extern const SVnodeCfg vnodeCfgDefault;
|
||||||
|
|
||||||
int vnodeCheckCfg(const SVnodeCfg*);
|
int vnodeCheckCfg(const SVnodeCfg*);
|
||||||
void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc);
|
|
||||||
|
|
||||||
// For commit
|
|
||||||
#define vnodeShouldCommit vnodeBufPoolIsFull
|
|
||||||
int vnodeSyncCommit(SVnode* pVnode);
|
|
||||||
int vnodeAsyncCommit(SVnode* pVnode);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "tcoding.h"
|
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
|
||||||
|
|
||||||
static SMeta *metaNew(const char *path, SMemAllocatorFactory *pMAF);
|
|
||||||
static void metaFree(SMeta *pMeta);
|
|
||||||
static int metaOpenImpl(SMeta *pMeta);
|
|
||||||
static void metaCloseImpl(SMeta *pMeta);
|
|
||||||
|
|
||||||
SMeta *metaOpen(const char *path, SMemAllocatorFactory *pMAF) {
|
|
||||||
SMeta *pMeta = NULL;
|
|
||||||
|
|
||||||
// Allocate handle
|
|
||||||
pMeta = metaNew(path, pMAF);
|
|
||||||
if (pMeta == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create META path (TODO)
|
|
||||||
taosMkDir(path);
|
|
||||||
|
|
||||||
// Open meta
|
|
||||||
if (metaOpenImpl(pMeta) < 0) {
|
|
||||||
metaFree(pMeta);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaClose(SMeta *pMeta) {
|
|
||||||
if (pMeta) {
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
metaFree(pMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaRemove(const char *path) { taosRemoveDir(path); }
|
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
|
||||||
static SMeta *metaNew(const char *path, SMemAllocatorFactory *pMAF) {
|
|
||||||
SMeta *pMeta;
|
|
||||||
size_t psize = strlen(path);
|
|
||||||
|
|
||||||
pMeta = (SMeta *)taosMemoryCalloc(1, sizeof(*pMeta));
|
|
||||||
if (pMeta == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pMeta->path = strdup(path);
|
|
||||||
if (pMeta->path == NULL) {
|
|
||||||
metaFree(pMeta);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pMeta;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void metaFree(SMeta *pMeta) {
|
|
||||||
if (pMeta) {
|
|
||||||
taosMemoryFreeClear(pMeta->path);
|
|
||||||
taosMemoryFree(pMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int metaOpenImpl(SMeta *pMeta) {
|
|
||||||
// Open meta db
|
|
||||||
if (metaOpenDB(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open meta index
|
|
||||||
if (metaOpenIdx(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open meta table uid generator
|
|
||||||
if (metaOpenUidGnrt(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void metaCloseImpl(SMeta *pMeta) {
|
|
||||||
metaCloseUidGnrt(pMeta);
|
|
||||||
metaCloseIdx(pMeta);
|
|
||||||
metaCloseDB(pMeta);
|
|
||||||
}
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* 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 "vnodeInt.h"
|
||||||
|
|
||||||
|
int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
|
SMeta *pMeta = NULL;
|
||||||
|
int slen;
|
||||||
|
|
||||||
|
*ppMeta = NULL;
|
||||||
|
|
||||||
|
// create handle
|
||||||
|
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
||||||
|
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMeta->path = (char *)&pMeta[1];
|
||||||
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
|
VNODE_META_DIR);
|
||||||
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
|
// create path if not created yet
|
||||||
|
taosMkDir(pMeta->path);
|
||||||
|
|
||||||
|
// open meta
|
||||||
|
if (metaOpenDB(pMeta) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metaOpenIdx(pMeta) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppMeta = pMeta;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||||
|
if (pMeta->pDB) metaCloseDB(pMeta);
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int metaClose(SMeta *pMeta) {
|
||||||
|
if (pMeta) {
|
||||||
|
metaCloseIdx(pMeta);
|
||||||
|
metaCloseDB(pMeta);
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "vnodeInt.h"
|
|
||||||
|
|
||||||
int metaOpenUidGnrt(SMeta *pMeta) {
|
|
||||||
// Init a generator
|
|
||||||
pMeta->uidGnrt.nextUid = IVLD_TB_UID;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */
|
|
||||||
}
|
|
||||||
|
|
||||||
tb_uid_t metaGenerateUid(SMeta *pMeta) {
|
|
||||||
// Generate a new table UID
|
|
||||||
return tGenIdPI64();
|
|
||||||
}
|
|
|
@ -23,11 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1 //======================================================================
|
|
||||||
void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) {
|
|
||||||
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
|
||||||
}
|
|
||||||
|
|
||||||
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
||||||
uint32_t hashValue = 0;
|
uint32_t hashValue = 0;
|
||||||
|
|
||||||
|
@ -47,5 +42,3 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -65,14 +65,15 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create handle
|
// create handle
|
||||||
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode));
|
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
vError("vgId: %d failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
vError("vgId: %d failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->path = strdup(dir);
|
pVnode->path = (char *)&pVnode[1];
|
||||||
|
strcpy(pVnode->path, path);
|
||||||
pVnode->config = info.config;
|
pVnode->config = info.config;
|
||||||
pVnode->state.committed = info.state.committed;
|
pVnode->state.committed = info.state.committed;
|
||||||
pVnode->state.processed = pVnode->state.applied = pVnode->state.committed;
|
pVnode->state.processed = pVnode->state.applied = pVnode->state.committed;
|
||||||
|
@ -88,9 +89,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// open meta
|
// open meta
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_META_DIR);
|
if (metaOpen(pVnode, &pVnode->pMeta) < 0) {
|
||||||
pVnode->pMeta = metaOpen(tdir, vBufPoolGetMAF(pVnode));
|
|
||||||
if (pVnode->pMeta == NULL) {
|
|
||||||
vError("vgId: %d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId: %d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +140,6 @@ _err:
|
||||||
if (pVnode->pTsdb) tsdbClose(pVnode->pTsdb);
|
if (pVnode->pTsdb) tsdbClose(pVnode->pTsdb);
|
||||||
if (pVnode->pMeta) metaClose(pVnode->pMeta);
|
if (pVnode->pMeta) metaClose(pVnode->pMeta);
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
taosMemoryFreeClear(pVnode->path);
|
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +157,6 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
vnodeCloseBufPool(pVnode);
|
vnodeCloseBufPool(pVnode);
|
||||||
// destroy handle
|
// destroy handle
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
taosMemoryFreeClear(pVnode->path);
|
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
catalogTest
|
catalogTest
|
||||||
PUBLIC os util common catalog transport gtest qcom taos
|
PUBLIC os util common catalog transport gtest qcom taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -22,38 +22,275 @@ typedef struct SIFCtx {
|
||||||
SHashObj *pRes; /* element is SScalarParam */
|
SHashObj *pRes; /* element is SScalarParam */
|
||||||
} SIFCtx;
|
} SIFCtx;
|
||||||
|
|
||||||
|
#define SIF_ERR_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
return _code; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define SIF_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
} \
|
||||||
|
return _code; \
|
||||||
|
} while (0)
|
||||||
|
#define SIF_ERR_JRET(c) \
|
||||||
|
do { \
|
||||||
|
code = c; \
|
||||||
|
if (code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = code; \
|
||||||
|
goto _return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
typedef struct SIFParam {
|
typedef struct SIFParam {
|
||||||
SArray * result;
|
SArray * result;
|
||||||
SHashObj *pFilter;
|
SHashObj *pFilter;
|
||||||
} SIFParam;
|
} SIFParam;
|
||||||
|
|
||||||
|
typedef int32_t (*sif_func_t)(SNode *left, SNode *rigth, SIFParam *output);
|
||||||
// construct tag filter operator later
|
// construct tag filter operator later
|
||||||
static void destroyTagFilterOperatorInfo(void *param) {
|
static void destroyTagFilterOperatorInfo(void *param) { STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; }
|
||||||
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sifFreeParam(SIFParam *param) {
|
static void sifFreeParam(SIFParam *param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
taosArrayDestroy(param->result);
|
taosArrayDestroy(param->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sifInitOperParams(SIFParam *params, SOperatorNode *node, SIFCtx *ctx) {
|
static int32_t sifGetOperParamNum(EOperatorType ty) {
|
||||||
|
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty || OP_TYPE_IS_FALSE == ty ||
|
||||||
|
OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty || OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
|
switch (nodeType(node)) {
|
||||||
|
case QUERY_NODE_VALUE: {
|
||||||
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_COLUMN: {
|
||||||
|
SColumnNode *cn = (SColumnNode *)node;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_NODE_LIST: {
|
||||||
|
SNodeListNode *nl = (SNodeListNode *)node;
|
||||||
|
if (LIST_LENGTH(nl->pNodeList) <= 0) {
|
||||||
|
qError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||||
|
taosHashCleanup(param->pFilter);
|
||||||
|
qError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_FUNCTION:
|
||||||
|
case QUERY_NODE_OPERATOR:
|
||||||
|
case QUERY_NODE_LOGIC_CONDITION: {
|
||||||
|
SIFParam *res = (SIFParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES);
|
||||||
|
if (NULL == res) {
|
||||||
|
qError("no result for node, type:%d, node:%p", nodeType(node), node);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
|
}
|
||||||
|
*param = *res;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx *ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
return code;
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
|
if (NULL == node->pLeft || (nParam == 2 && NULL == node->pRight)) {
|
||||||
|
qError("invalid operation node, left: %p, rigth: %p", node->pLeft, node->pRight);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||||
|
if (NULL == paramList) {
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
||||||
|
if (nParam > 1) {
|
||||||
|
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||||
|
}
|
||||||
|
*params = paramList;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(paramList);
|
||||||
|
SIF_RET(code);
|
||||||
|
}
|
||||||
|
static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx *ctx) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam));
|
||||||
|
if (tParams == NULL) {
|
||||||
|
qError("failed to calloc, nodeList: %p", nodeList);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SListCell *cell = nodeList->pHead;
|
||||||
|
for (int32_t i = 0; i < nodeList->length; i++) {
|
||||||
|
if (NULL == cell || NULL == cell->pNode) {
|
||||||
|
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
SIF_ERR_JRET(sifInitParam(cell->pNode, &tParams[i], ctx));
|
||||||
|
cell = cell->pNext;
|
||||||
|
}
|
||||||
|
*params = tParams;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(tParams);
|
||||||
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
qError("index-filter not support buildin function");
|
qError("index-filter not support buildin function");
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifLessThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static int32_t sifLessEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifGreaterThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifGreaterEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifInFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotInFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifDefaultFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// add more except
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static sif_func_t sifGetOperFn(int32_t funcId) {
|
||||||
|
// impl later
|
||||||
|
switch (funcId) {
|
||||||
|
case OP_TYPE_GREATER_THAN:
|
||||||
|
return sifGreaterThanFunc;
|
||||||
|
case OP_TYPE_GREATER_EQUAL:
|
||||||
|
return sifGreaterEqualFunc;
|
||||||
|
case OP_TYPE_LOWER_THAN:
|
||||||
|
return sifLessThanFunc;
|
||||||
|
case OP_TYPE_LOWER_EQUAL:
|
||||||
|
return sifLessEqualFunc;
|
||||||
|
case OP_TYPE_EQUAL:
|
||||||
|
return sifEqualFunc;
|
||||||
|
case OP_TYPE_NOT_EQUAL:
|
||||||
|
return sifNotEqualFunc;
|
||||||
|
case OP_TYPE_IN:
|
||||||
|
return sifInFunc;
|
||||||
|
case OP_TYPE_NOT_IN:
|
||||||
|
return sifNotInFunc;
|
||||||
|
case OP_TYPE_LIKE:
|
||||||
|
return sifLikeFunc;
|
||||||
|
case OP_TYPE_NOT_LIKE:
|
||||||
|
return sifNotLikeFunc;
|
||||||
|
case OP_TYPE_MATCH:
|
||||||
|
return sifMatchFunc;
|
||||||
|
case OP_TYPE_NMATCH:
|
||||||
|
return sifNotMatchFunc;
|
||||||
|
default:
|
||||||
|
return sifDefaultFunc;
|
||||||
|
}
|
||||||
|
return sifDefaultFunc;
|
||||||
|
}
|
||||||
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
|
int32_t code = 0;
|
||||||
SIFParam *params = NULL;
|
SIFParam *params = NULL;
|
||||||
|
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
|
if (nParam <= 1) {
|
||||||
|
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
sif_func_t operFn = sifGetOperFn(node->opType);
|
||||||
|
|
||||||
|
return operFn(node->pLeft, node->pRight, output);
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(params);
|
||||||
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) { return TSDB_CODE_SUCCESS; }
|
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
|
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||||
|
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
SIFParam *params = NULL;
|
||||||
|
SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx));
|
||||||
|
|
||||||
|
for (int32_t m = 0; m < node->pParameterList->length; m++) {
|
||||||
|
// add impl later
|
||||||
|
if (node->condType == LOGIC_COND_TYPE_AND) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
} else if (node->condType == LOGIC_COND_TYPE_OR) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
} else if (node->condType == LOGIC_COND_TYPE_NOT) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(params);
|
||||||
|
SIF_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
||||||
// impl later
|
|
||||||
SFunctionNode *node = (SFunctionNode *)pNode;
|
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||||
SIFParam output = {0};
|
SIFParam output = {0};
|
||||||
|
|
||||||
|
@ -104,8 +341,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EDealRes sifCalcWalker(SNode *node, void *context) {
|
EDealRes sifCalcWalker(SNode *node, void *context) {
|
||||||
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) ||
|
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || QUERY_NODE_COLUMN == nodeType(node)) {
|
||||||
QUERY_NODE_COLUMN == nodeType(node)) {
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
SIFCtx *ctx = (SIFCtx *)context;
|
SIFCtx *ctx = (SIFCtx *)context;
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(executorTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(executorTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
executorTest
|
executorTest
|
||||||
PRIVATE os util common transport gtest taos qcom executor function planner scalar nodes
|
PRIVATE os util common transport gtest taos_static qcom executor function planner scalar nodes
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -1470,6 +1470,9 @@ void qWorkerDestroy(void **qWorkerMgmt) {
|
||||||
|
|
||||||
//TODO FREE ALL
|
//TODO FREE ALL
|
||||||
|
|
||||||
|
taosHashCleanup(mgmt->ctxHash);
|
||||||
|
taosHashCleanup(mgmt->schHash);
|
||||||
|
|
||||||
taosMemoryFreeClear(*qWorkerMgmt);
|
taosMemoryFreeClear(*qWorkerMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
schedulerTest
|
schedulerTest
|
||||||
PUBLIC os util common catalog transport gtest qcom taos planner scheduler
|
PUBLIC os util common catalog transport gtest qcom taos_static planner scheduler
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -910,6 +910,8 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1)
|
||||||
|
|
||||||
void taosStopCacheRefreshWorker(void) {
|
void taosStopCacheRefreshWorker(void) {
|
||||||
stopRefreshWorker = true;
|
stopRefreshWorker = true;
|
||||||
|
taosThreadJoin(cacheRefreshWorker, NULL);
|
||||||
|
taosArrayDestroy(pCacheArrayList);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t taosCacheGetNumOfObj(const SCacheObj* pCacheObj) {
|
size_t taosCacheGetNumOfObj(const SCacheObj* pCacheObj) {
|
||||||
|
|
|
@ -591,12 +591,12 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
||||||
uInfo("load from env variables not implemented yet");
|
uDebug("load from env variables not implemented yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) {
|
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) {
|
||||||
uInfo("load from env file not implemented yet");
|
uDebug("load from env file not implemented yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,6 +655,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
uInfo("load from apoll url not implemented yet");
|
uDebug("load from apoll url not implemented yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,27 +38,26 @@
|
||||||
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
|
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int32_t buffStart;
|
int32_t buffStart;
|
||||||
int32_t buffEnd;
|
int32_t buffEnd;
|
||||||
int32_t buffSize;
|
int32_t buffSize;
|
||||||
int32_t minBuffSize;
|
int32_t minBuffSize;
|
||||||
TdFilePtr pFile;
|
TdFilePtr pFile;
|
||||||
int32_t stop;
|
int32_t stop;
|
||||||
TdThread asyncThread;
|
TdThread asyncThread;
|
||||||
TdThreadMutex buffMutex;
|
TdThreadMutex buffMutex;
|
||||||
tsem_t buffNotEmpty;
|
|
||||||
} SLogBuff;
|
} SLogBuff;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t fileNum;
|
int32_t fileNum;
|
||||||
int32_t maxLines;
|
int32_t maxLines;
|
||||||
int32_t lines;
|
int32_t lines;
|
||||||
int32_t flag;
|
int32_t flag;
|
||||||
int32_t openInProgress;
|
int32_t openInProgress;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char logName[LOG_FILE_NAME_LEN];
|
char logName[LOG_FILE_NAME_LEN];
|
||||||
SLogBuff *logHandle;
|
SLogBuff *logHandle;
|
||||||
TdThreadMutex logMutex;
|
TdThreadMutex logMutex;
|
||||||
} SLogObj;
|
} SLogObj;
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ int64_t dbgBigWN = 0;
|
||||||
int64_t dbgWSize = 0;
|
int64_t dbgWSize = 0;
|
||||||
|
|
||||||
static void *taosAsyncOutputLog(void *param);
|
static void *taosAsyncOutputLog(void *param);
|
||||||
static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen);
|
static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen);
|
||||||
static SLogBuff *taosLogBuffNew(int32_t bufSize);
|
static SLogBuff *taosLogBuffNew(int32_t bufSize);
|
||||||
static void taosCloseLogByFd(TdFilePtr pFile);
|
static void taosCloseLogByFd(TdFilePtr pFile);
|
||||||
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
|
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
|
||||||
|
@ -136,16 +135,24 @@ static void taosStopLog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void taosLogBuffDestroy() {
|
||||||
|
taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex);
|
||||||
|
taosCloseFile(&tsLogObj.logHandle->pFile);
|
||||||
|
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
||||||
|
memset(&tsLogObj.logHandle->buffer, 0, sizeof(tsLogObj.logHandle->buffer));
|
||||||
|
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
||||||
|
taosMemoryFreeClear(tsLogObj.logHandle);
|
||||||
|
memset(&tsLogObj.logHandle, 0, sizeof(tsLogObj.logHandle));
|
||||||
|
tsLogObj.logHandle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void taosCloseLog() {
|
void taosCloseLog() {
|
||||||
taosStopLog();
|
taosStopLog();
|
||||||
if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) {
|
if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) {
|
||||||
taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL);
|
taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL);
|
||||||
}
|
}
|
||||||
tsLogInited = 0;
|
tsLogInited = 0;
|
||||||
// In case that other threads still use log resources causing invalid write in valgrind
|
taosLogBuffDestroy(tsLogObj.logHandle);
|
||||||
// we comment two lines below.
|
|
||||||
// taosLogBuffDestroy(tsLogObj.logHandle);
|
|
||||||
// taosCloseLog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taosLockLogFile(TdFilePtr pFile) {
|
static bool taosLockLogFile(TdFilePtr pFile) {
|
||||||
|
@ -231,7 +238,7 @@ static int32_t taosOpenNewLogFile() {
|
||||||
tsLogObj.openInProgress = 1;
|
tsLogObj.openInProgress = 1;
|
||||||
|
|
||||||
uInfo("open new log file ......");
|
uInfo("open new log file ......");
|
||||||
TdThread thread;
|
TdThread thread;
|
||||||
TdThreadAttr attr;
|
TdThreadAttr attr;
|
||||||
taosThreadAttrInit(&attr);
|
taosThreadAttrInit(&attr);
|
||||||
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
@ -506,45 +513,45 @@ static void taosCloseLogByFd(TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLogBuff *taosLogBuffNew(int32_t bufSize) {
|
static SLogBuff *taosLogBuffNew(int32_t bufSize) {
|
||||||
SLogBuff *tLogBuff = NULL;
|
SLogBuff *pLogBuf = NULL;
|
||||||
|
|
||||||
tLogBuff = taosMemoryCalloc(1, sizeof(SLogBuff));
|
pLogBuf = taosMemoryCalloc(1, sizeof(SLogBuff));
|
||||||
if (tLogBuff == NULL) return NULL;
|
if (pLogBuf == NULL) return NULL;
|
||||||
|
|
||||||
LOG_BUF_BUFFER(tLogBuff) = taosMemoryMalloc(bufSize);
|
LOG_BUF_BUFFER(pLogBuf) = taosMemoryMalloc(bufSize);
|
||||||
if (LOG_BUF_BUFFER(tLogBuff) == NULL) goto _err;
|
if (LOG_BUF_BUFFER(pLogBuf) == NULL) goto _err;
|
||||||
|
|
||||||
LOG_BUF_START(tLogBuff) = LOG_BUF_END(tLogBuff) = 0;
|
LOG_BUF_START(pLogBuf) = LOG_BUF_END(pLogBuf) = 0;
|
||||||
LOG_BUF_SIZE(tLogBuff) = bufSize;
|
LOG_BUF_SIZE(pLogBuf) = bufSize;
|
||||||
tLogBuff->minBuffSize = bufSize / 10;
|
pLogBuf->minBuffSize = bufSize / 10;
|
||||||
tLogBuff->stop = 0;
|
pLogBuf->stop = 0;
|
||||||
|
|
||||||
if (taosThreadMutexInit(&LOG_BUF_MUTEX(tLogBuff), NULL) < 0) goto _err;
|
if (taosThreadMutexInit(&LOG_BUF_MUTEX(pLogBuf), NULL) < 0) goto _err;
|
||||||
// tsem_init(&(tLogBuff->buffNotEmpty), 0, 0);
|
// tsem_init(&(pLogBuf->buffNotEmpty), 0, 0);
|
||||||
|
|
||||||
return tLogBuff;
|
return pLogBuf;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
taosMemoryFreeClear(LOG_BUF_BUFFER(tLogBuff));
|
taosMemoryFreeClear(LOG_BUF_BUFFER(pLogBuf));
|
||||||
taosMemoryFreeClear(tLogBuff);
|
taosMemoryFreeClear(pLogBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosCopyLogBuffer(SLogBuff *tLogBuff, int32_t start, int32_t end, const char *msg, int32_t msgLen) {
|
static void taosCopyLogBuffer(SLogBuff *pLogBuf, int32_t start, int32_t end, const char *msg, int32_t msgLen) {
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen);
|
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen);
|
||||||
} else {
|
} else {
|
||||||
if (LOG_BUF_SIZE(tLogBuff) - end < msgLen) {
|
if (LOG_BUF_SIZE(pLogBuf) - end < msgLen) {
|
||||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, LOG_BUF_SIZE(tLogBuff) - end);
|
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, LOG_BUF_SIZE(pLogBuf) - end);
|
||||||
memcpy(LOG_BUF_BUFFER(tLogBuff), msg + LOG_BUF_SIZE(tLogBuff) - end, msgLen - LOG_BUF_SIZE(tLogBuff) + end);
|
memcpy(LOG_BUF_BUFFER(pLogBuf), msg + LOG_BUF_SIZE(pLogBuf) - end, msgLen - LOG_BUF_SIZE(pLogBuf) + end);
|
||||||
} else {
|
} else {
|
||||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen);
|
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_BUF_END(tLogBuff) = (LOG_BUF_END(tLogBuff) + msgLen) % LOG_BUF_SIZE(tLogBuff);
|
LOG_BUF_END(pLogBuf) = (LOG_BUF_END(pLogBuf) + msgLen) % LOG_BUF_SIZE(pLogBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen) {
|
static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen) {
|
||||||
int32_t start = 0;
|
int32_t start = 0;
|
||||||
int32_t end = 0;
|
int32_t end = 0;
|
||||||
int32_t remainSize = 0;
|
int32_t remainSize = 0;
|
||||||
|
@ -552,13 +559,13 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms
|
||||||
char tmpBuf[40] = {0};
|
char tmpBuf[40] = {0};
|
||||||
int32_t tmpBufLen = 0;
|
int32_t tmpBufLen = 0;
|
||||||
|
|
||||||
if (tLogBuff == NULL || tLogBuff->stop) return -1;
|
if (pLogBuf == NULL || pLogBuf->stop) return -1;
|
||||||
|
|
||||||
taosThreadMutexLock(&LOG_BUF_MUTEX(tLogBuff));
|
taosThreadMutexLock(&LOG_BUF_MUTEX(pLogBuf));
|
||||||
start = LOG_BUF_START(tLogBuff);
|
start = LOG_BUF_START(pLogBuf);
|
||||||
end = LOG_BUF_END(tLogBuff);
|
end = LOG_BUF_END(pLogBuf);
|
||||||
|
|
||||||
remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(tLogBuff) - end - 1);
|
remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(pLogBuf) - end - 1);
|
||||||
|
|
||||||
if (lostLine > 0) {
|
if (lostLine > 0) {
|
||||||
sprintf(tmpBuf, "...Lost %" PRId64 " lines here...\n", lostLine);
|
sprintf(tmpBuf, "...Lost %" PRId64 " lines here...\n", lostLine);
|
||||||
|
@ -568,47 +575,47 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms
|
||||||
if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) {
|
if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) {
|
||||||
lostLine++;
|
lostLine++;
|
||||||
tsAsyncLogLostLines++;
|
tsAsyncLogLostLines++;
|
||||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff));
|
taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lostLine > 0) {
|
if (lostLine > 0) {
|
||||||
taosCopyLogBuffer(tLogBuff, start, end, tmpBuf, tmpBufLen);
|
taosCopyLogBuffer(pLogBuf, start, end, tmpBuf, tmpBufLen);
|
||||||
lostLine = 0;
|
lostLine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCopyLogBuffer(tLogBuff, LOG_BUF_START(tLogBuff), LOG_BUF_END(tLogBuff), msg, msgLen);
|
taosCopyLogBuffer(pLogBuf, LOG_BUF_START(pLogBuf), LOG_BUF_END(pLogBuf), msg, msgLen);
|
||||||
|
|
||||||
// int32_t w = atomic_sub_fetch_32(&waitLock, 1);
|
// int32_t w = atomic_sub_fetch_32(&waitLock, 1);
|
||||||
/*
|
/*
|
||||||
if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(tLogBuff) * 4 /5))) {
|
if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(pLogBuf) * 4 /5))) {
|
||||||
tsem_post(&(tLogBuff->buffNotEmpty));
|
tsem_post(&(pLogBuf->buffNotEmpty));
|
||||||
dbgPostN++;
|
dbgPostN++;
|
||||||
} else {
|
} else {
|
||||||
dbgNoPostN++;
|
dbgNoPostN++;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff));
|
taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosGetLogRemainSize(SLogBuff *tLogBuff, int32_t start, int32_t end) {
|
static int32_t taosGetLogRemainSize(SLogBuff *pLogBuf, int32_t start, int32_t end) {
|
||||||
int32_t rSize = end - start;
|
int32_t rSize = end - start;
|
||||||
|
|
||||||
return rSize >= 0 ? rSize : LOG_BUF_SIZE(tLogBuff) + rSize;
|
return rSize >= 0 ? rSize : LOG_BUF_SIZE(pLogBuf) + rSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosWriteLog(SLogBuff *tLogBuff) {
|
static void taosWriteLog(SLogBuff *pLogBuf) {
|
||||||
static int32_t lastDuration = 0;
|
static int32_t lastDuration = 0;
|
||||||
int32_t remainChecked = 0;
|
int32_t remainChecked = 0;
|
||||||
int32_t start, end, pollSize;
|
int32_t start, end, pollSize;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (remainChecked == 0) {
|
if (remainChecked == 0) {
|
||||||
start = LOG_BUF_START(tLogBuff);
|
start = LOG_BUF_START(pLogBuf);
|
||||||
end = LOG_BUF_END(tLogBuff);
|
end = LOG_BUF_END(pLogBuf);
|
||||||
|
|
||||||
if (start == end) {
|
if (start == end) {
|
||||||
dbgEmptyW++;
|
dbgEmptyW++;
|
||||||
|
@ -616,8 +623,8 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pollSize = taosGetLogRemainSize(tLogBuff, start, end);
|
pollSize = taosGetLogRemainSize(pLogBuf, start, end);
|
||||||
if (pollSize < tLogBuff->minBuffSize) {
|
if (pollSize < pLogBuf->minBuffSize) {
|
||||||
lastDuration += tsWriteInterval;
|
lastDuration += tsWriteInterval;
|
||||||
if (lastDuration < LOG_MAX_WAIT_MSEC) {
|
if (lastDuration < LOG_MAX_WAIT_MSEC) {
|
||||||
break;
|
break;
|
||||||
|
@ -628,38 +635,38 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < end) {
|
if (start < end) {
|
||||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, pollSize);
|
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, pollSize);
|
||||||
} else {
|
} else {
|
||||||
int32_t tsize = LOG_BUF_SIZE(tLogBuff) - start;
|
int32_t tsize = LOG_BUF_SIZE(pLogBuf) - start;
|
||||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, tsize);
|
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, tsize);
|
||||||
|
|
||||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff), end);
|
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf), end);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgWN++;
|
dbgWN++;
|
||||||
dbgWSize += pollSize;
|
dbgWSize += pollSize;
|
||||||
|
|
||||||
if (pollSize < tLogBuff->minBuffSize) {
|
if (pollSize < pLogBuf->minBuffSize) {
|
||||||
dbgSmallWN++;
|
dbgSmallWN++;
|
||||||
if (tsWriteInterval < LOG_MAX_INTERVAL) {
|
if (tsWriteInterval < LOG_MAX_INTERVAL) {
|
||||||
tsWriteInterval += LOG_INTERVAL_STEP;
|
tsWriteInterval += LOG_INTERVAL_STEP;
|
||||||
}
|
}
|
||||||
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 3) {
|
} else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 3) {
|
||||||
dbgBigWN++;
|
dbgBigWN++;
|
||||||
tsWriteInterval = LOG_MIN_INTERVAL;
|
tsWriteInterval = LOG_MIN_INTERVAL;
|
||||||
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 4) {
|
} else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 4) {
|
||||||
if (tsWriteInterval > LOG_MIN_INTERVAL) {
|
if (tsWriteInterval > LOG_MIN_INTERVAL) {
|
||||||
tsWriteInterval -= LOG_INTERVAL_STEP;
|
tsWriteInterval -= LOG_INTERVAL_STEP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_BUF_START(tLogBuff) = (LOG_BUF_START(tLogBuff) + pollSize) % LOG_BUF_SIZE(tLogBuff);
|
LOG_BUF_START(pLogBuf) = (LOG_BUF_START(pLogBuf) + pollSize) % LOG_BUF_SIZE(pLogBuf);
|
||||||
|
|
||||||
start = LOG_BUF_START(tLogBuff);
|
start = LOG_BUF_START(pLogBuf);
|
||||||
end = LOG_BUF_END(tLogBuff);
|
end = LOG_BUF_END(pLogBuf);
|
||||||
|
|
||||||
pollSize = taosGetLogRemainSize(tLogBuff, start, end);
|
pollSize = taosGetLogRemainSize(pLogBuf, start, end);
|
||||||
if (pollSize < tLogBuff->minBuffSize) {
|
if (pollSize < pLogBuf->minBuffSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,16 +677,16 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *taosAsyncOutputLog(void *param) {
|
static void *taosAsyncOutputLog(void *param) {
|
||||||
SLogBuff *tLogBuff = (SLogBuff *)param;
|
SLogBuff *pLogBuf = (SLogBuff *)param;
|
||||||
setThreadName("log");
|
setThreadName("log");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
taosMsleep(tsWriteInterval);
|
taosMsleep(tsWriteInterval);
|
||||||
|
|
||||||
// Polling the buffer
|
// Polling the buffer
|
||||||
taosWriteLog(tLogBuff);
|
taosWriteLog(pLogBuf);
|
||||||
|
|
||||||
if (tLogBuff->stop) break;
|
if (pLogBuf->stop) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$loop_cnt = 0
|
$loop_cnt = 0
|
||||||
|
|
|
@ -3,21 +3,21 @@ add_executable(tmq_demo tmqDemo.c)
|
||||||
add_executable(tmq_sim tmqSim.c)
|
add_executable(tmq_sim tmqSim.c)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
create_table
|
create_table
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tmq_demo
|
tmq_demo
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tmq_sim
|
tmq_sim
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
|
|
|
@ -2,7 +2,7 @@ aux_source_directory(src TSIM_SRC)
|
||||||
add_executable(tsim ${TSIM_SRC})
|
add_executable(tsim ${TSIM_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tsim
|
tsim
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#define MAX_BACKGROUND_SCRIPT_NUM 10
|
#define MAX_BACKGROUND_SCRIPT_NUM 10
|
||||||
#define MAX_FILE_NAME_LEN 256
|
#define MAX_FILE_NAME_LEN 256
|
||||||
#define MAX_ERROR_LEN 1024
|
#define MAX_ERROR_LEN 1024
|
||||||
#define MAX_QUERY_VALUE_LEN 40
|
#define MAX_QUERY_VALUE_LEN 10240
|
||||||
#define MAX_QUERY_COL_NUM 20
|
#define MAX_QUERY_COL_NUM 20
|
||||||
#define MAX_QUERY_ROW_NUM 20
|
#define MAX_QUERY_ROW_NUM 20
|
||||||
#define MAX_SYSTEM_RESULT_LEN 2048
|
#define MAX_SYSTEM_RESULT_LEN 2048
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
void simLogSql(char *sql, bool useSharp) {
|
void simLogSql(char *sql, bool useSharp) {
|
||||||
static TdFilePtr pFile = NULL;
|
static TdFilePtr pFile = NULL;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
sprintf(filename, "%s/sim.sql", simScriptDir);
|
sprintf(filename, "%s/sim.sql", simScriptDir);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
// fp = fopen(filename, "w");
|
// fp = fopen(filename, "w");
|
||||||
|
@ -305,7 +305,8 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void simReplaceStr(char *buf, char *src, char *dst) {
|
bool simReplaceStr(char *buf, char *src, char *dst) {
|
||||||
|
bool replaced = false;
|
||||||
char *begin = strstr(buf, src);
|
char *begin = strstr(buf, src);
|
||||||
if (begin != NULL) {
|
if (begin != NULL) {
|
||||||
int32_t srcLen = (int32_t)strlen(src);
|
int32_t srcLen = (int32_t)strlen(src);
|
||||||
|
@ -320,13 +321,16 @@ void simReplaceStr(char *buf, char *src, char *dst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(begin, dst, dstLen);
|
memcpy(begin, dst, dstLen);
|
||||||
|
replaced = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
simInfo("system cmd is %s", buf);
|
simInfo("system cmd is %s", buf);
|
||||||
|
return replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simExecuteSystemCmd(SScript *script, char *option) {
|
bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||||
char buf[4096] = {0};
|
char buf[4096] = {0};
|
||||||
|
bool replaced = false;
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
sprintf(buf, "cd %s; ", simScriptDir);
|
sprintf(buf, "cd %s; ", simScriptDir);
|
||||||
|
@ -341,7 +345,7 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useValgrind) {
|
if (useValgrind) {
|
||||||
simReplaceStr(buf, "exec.sh", "exec.sh -v");
|
replaced = simReplaceStr(buf, "exec.sh", "exec.sh -v");
|
||||||
}
|
}
|
||||||
|
|
||||||
simLogSql(buf, true);
|
simLogSql(buf, true);
|
||||||
|
@ -359,6 +363,11 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||||
|
|
||||||
sprintf(script->system_exit_code, "%d", code);
|
sprintf(script->system_exit_code, "%d", code);
|
||||||
script->linePos++;
|
script->linePos++;
|
||||||
|
if (replaced && strstr(buf, "start") != NULL) {
|
||||||
|
simInfo("====> startup is slow in valgrind mode, so sleep 5 seconds after exec.sh -s start");
|
||||||
|
taosMsleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,7 +783,7 @@ bool simExecuteSqlSlowCmd(SScript *script, char *rest) {
|
||||||
|
|
||||||
bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
sprintf(filename, "%s/tmp.sql", simScriptDir);
|
sprintf(filename, "%s/tmp.sql", simScriptDir);
|
||||||
// fp = fopen(filename, "w");
|
// fp = fopen(filename, "w");
|
||||||
pFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
pFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||||
|
|
|
@ -3,7 +3,7 @@ aux_source_directory(src SHELL_SRC)
|
||||||
add_executable(shell ${SHELL_SRC})
|
add_executable(shell ${SHELL_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
shell
|
shell
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PRIVATE os common transport util
|
PRIVATE os common transport util
|
||||||
)
|
)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
|
|
|
@ -45,7 +45,7 @@ static tsem_t cancelSem;
|
||||||
|
|
||||||
static struct argp_option options[] = {
|
static struct argp_option options[] = {
|
||||||
{"host", 'h', "HOST", 0, "TDengine server FQDN to connect. The default host is localhost."},
|
{"host", 'h', "HOST", 0, "TDengine server FQDN to connect. The default host is localhost."},
|
||||||
{"password", 'p', 0, 0, "The password to use when connecting to the server."},
|
{"password", 'p', 0, 0, "The password to use when connecting to the server."},
|
||||||
{"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."},
|
{"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."},
|
||||||
{"user", 'u', "USER", 0, "The user name to use when connecting to the server."},
|
{"user", 'u', "USER", 0, "The user name to use when connecting to the server."},
|
||||||
{"auth", 'A', "Auth", 0, "The auth string to use when connecting to the server."},
|
{"auth", 'A', "Auth", 0, "The auth string to use when connecting to the server."},
|
||||||
|
|
Loading…
Reference in New Issue