Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/data_format
This commit is contained in:
commit
c03f7aa72d
|
@ -46,7 +46,7 @@ ENDIF ()
|
||||||
|
|
||||||
IF (TD_WINDOWS)
|
IF (TD_WINDOWS)
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(COMMON_FLAGS "/w /D_WIN32")
|
SET(COMMON_FLAGS "/w /D_WIN32 /Zi")
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
|
||||||
|
|
|
@ -100,8 +100,10 @@ endif(${BUILD_WITH_NURAFT})
|
||||||
|
|
||||||
# addr2line
|
# addr2line
|
||||||
if(${BUILD_ADDR2LINE})
|
if(${BUILD_ADDR2LINE})
|
||||||
|
if(NOT ${TD_WINDOWS})
|
||||||
cat("${TD_SUPPORT_DIR}/libdwarf_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/libdwarf_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
cat("${TD_SUPPORT_DIR}/addr2line_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/addr2line_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif(NOT ${TD_WINDOWS})
|
||||||
endif(${BUILD_ADDR2LINE})
|
endif(${BUILD_ADDR2LINE})
|
||||||
|
|
||||||
# download dependencies
|
# download dependencies
|
||||||
|
@ -335,6 +337,7 @@ endif(${BUILD_WITH_SQLITE})
|
||||||
|
|
||||||
# addr2line
|
# addr2line
|
||||||
if(${BUILD_ADDR2LINE})
|
if(${BUILD_ADDR2LINE})
|
||||||
|
if(NOT ${TD_WINDOWS})
|
||||||
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
|
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H)
|
||||||
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
|
check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
|
||||||
check_include_file( "inttypes.h" HAVE_INTTYPES_H )
|
check_include_file( "inttypes.h" HAVE_INTTYPES_H )
|
||||||
|
@ -374,6 +377,7 @@ if(${BUILD_ADDR2LINE})
|
||||||
add_library(addr2line STATIC "addr2line/addr2line.c")
|
add_library(addr2line STATIC "addr2line/addr2line.c")
|
||||||
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
target_link_libraries(addr2line PUBLIC libdwarf dl z)
|
||||||
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf" )
|
target_include_directories(addr2line PUBLIC "libdwarf/src/lib/libdwarf" )
|
||||||
|
endif(NOT ${TD_WINDOWS})
|
||||||
endif(${BUILD_ADDR2LINE})
|
endif(${BUILD_ADDR2LINE})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx"
|
||||||
|
|
||||||
`TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。
|
`TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。
|
||||||
|
|
||||||
`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、订阅、schemaless 数据写入、参数绑定接口数据写入等功能 `TDengine.Connector` 目前暂未提供 REST 连接方式,用户可以参考 [RESTful APIs](https://docs.taosdata.com//reference/restful-api/) 文档自行编写。
|
`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、订阅、schemaless 数据写入、参数绑定接口数据写入等功能 `TDengine.Connector` 目前暂未提供 REST 连接方式,用户可以参考 [REST API](/reference/rest-api/) 文档自行编写。
|
||||||
|
|
||||||
本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。
|
本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx"
|
||||||
|
|
||||||
`TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data.
|
`TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data.
|
||||||
|
|
||||||
The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [RESTful APIs](https://docs.taosdata.com//reference/restful-api/) documentation.
|
The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [REST API](/reference/rest-api/) documentation.
|
||||||
|
|
||||||
This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying.
|
This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying.
|
||||||
|
|
||||||
|
|
|
@ -244,12 +244,12 @@ typedef struct {
|
||||||
const void* pMsg;
|
const void* pMsg;
|
||||||
} SSubmitMsgIter;
|
} SSubmitMsgIter;
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
int32_t tInitSubmitMsgIter(SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||||
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
||||||
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
||||||
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
||||||
// for debug
|
// for debug
|
||||||
int32_t tPrintFixedSchemaSubmitReq(const SSubmitReq* pReq, STSchema* pSchema);
|
int32_t tPrintFixedSchemaSubmitReq(SSubmitReq* pReq, STSchema* pSchema);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
@ -1697,7 +1697,7 @@ int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
|
||||||
|
|
||||||
// TDMT_VND_CREATE_STB ==============
|
// TDMT_VND_CREATE_STB ==============
|
||||||
typedef struct SVCreateStbReq {
|
typedef struct SVCreateStbReq {
|
||||||
const char* name;
|
char* name;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
int8_t rollup;
|
int8_t rollup;
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
|
@ -1710,7 +1710,7 @@ int tDecodeSVCreateStbReq(SDecoder* pCoder, SVCreateStbReq* pReq);
|
||||||
|
|
||||||
// TDMT_VND_DROP_STB ==============
|
// TDMT_VND_DROP_STB ==============
|
||||||
typedef struct SVDropStbReq {
|
typedef struct SVDropStbReq {
|
||||||
const char* name;
|
char* name;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
} SVDropStbReq;
|
} SVDropStbReq;
|
||||||
|
|
||||||
|
@ -1723,13 +1723,13 @@ typedef struct SVCreateTbReq {
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
const char* name;
|
char* name;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
int8_t type;
|
int8_t type;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
const uint8_t* pTag;
|
uint8_t* pTag;
|
||||||
} ctb;
|
} ctb;
|
||||||
struct {
|
struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
|
@ -1777,7 +1777,7 @@ int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatc
|
||||||
|
|
||||||
// TDMT_VND_DROP_TABLE =================
|
// TDMT_VND_DROP_TABLE =================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* name;
|
char* name;
|
||||||
int8_t igNotExists;
|
int8_t igNotExists;
|
||||||
} SVDropTbReq;
|
} SVDropTbReq;
|
||||||
|
|
||||||
|
@ -1809,9 +1809,9 @@ int32_t tDecodeSVDropTbBatchRsp(SDecoder* pCoder, SVDropTbBatchRsp* pRsp);
|
||||||
|
|
||||||
// TDMT_VND_ALTER_TABLE =====================
|
// TDMT_VND_ALTER_TABLE =====================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* tbName;
|
char* tbName;
|
||||||
int8_t action;
|
int8_t action;
|
||||||
const char* colName;
|
char* colName;
|
||||||
// TSDB_ALTER_TABLE_ADD_COLUMN
|
// TSDB_ALTER_TABLE_ADD_COLUMN
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int8_t flags;
|
int8_t flags;
|
||||||
|
@ -1820,17 +1820,17 @@ typedef struct {
|
||||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
|
||||||
int32_t colModBytes;
|
int32_t colModBytes;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
// TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
|
||||||
const char* colNewName;
|
char* colNewName;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
// TSDB_ALTER_TABLE_UPDATE_TAG_VAL
|
||||||
const char* tagName;
|
char* tagName;
|
||||||
int8_t isNull;
|
int8_t isNull;
|
||||||
uint32_t nTagVal;
|
uint32_t nTagVal;
|
||||||
const uint8_t* pTagVal;
|
uint8_t* pTagVal;
|
||||||
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
|
||||||
int8_t updateTTL;
|
int8_t updateTTL;
|
||||||
int32_t newTTL;
|
int32_t newTTL;
|
||||||
int8_t updateComment;
|
int8_t updateComment;
|
||||||
const char* newComment;
|
char* newComment;
|
||||||
} SVAlterTbReq;
|
} SVAlterTbReq;
|
||||||
|
|
||||||
int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
|
int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
|
||||||
|
@ -2267,8 +2267,8 @@ typedef struct {
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t offset; // use unit by precision of DB
|
int64_t offset; // use unit by precision of DB
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
const char* expr; // sma expression
|
char* expr; // sma expression
|
||||||
const char* tagsFilter;
|
char* tagsFilter;
|
||||||
} STSma; // Time-range-wise SMA
|
} STSma; // Time-range-wise SMA
|
||||||
|
|
||||||
typedef STSma SVCreateTSmaReq;
|
typedef STSma SVCreateTSmaReq;
|
||||||
|
@ -2600,7 +2600,7 @@ typedef struct {
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
uint32_t nData;
|
uint32_t nData;
|
||||||
const uint8_t* pData;
|
uint8_t* pData;
|
||||||
SVCreateTbReq cTbReq;
|
SVCreateTbReq cTbReq;
|
||||||
} SVSubmitBlk;
|
} SVSubmitBlk;
|
||||||
|
|
||||||
|
|
|
@ -46,24 +46,34 @@ typedef enum {
|
||||||
AUTH_TYPE_OTHER,
|
AUTH_TYPE_OTHER,
|
||||||
} AUTH_TYPE;
|
} AUTH_TYPE;
|
||||||
|
|
||||||
|
typedef struct SUserAuthInfo {
|
||||||
|
char user[TSDB_USER_LEN];
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
AUTH_TYPE type;
|
||||||
|
} SUserAuthInfo;
|
||||||
|
|
||||||
typedef struct SCatalogReq {
|
typedef struct SCatalogReq {
|
||||||
SArray *pTableName; // element is SNAME
|
SArray *pTableMeta; // element is SNAME
|
||||||
SArray *pUdf; // udf name
|
SArray *pDbVgroup; // element is db full name
|
||||||
|
SArray *pTableHash; // element is SNAME
|
||||||
|
SArray *pUdf; // element is udf name
|
||||||
|
SArray *pDbCfg; // element is db full name
|
||||||
|
SArray *pIndex; // element is index name
|
||||||
|
SArray *pUser; // element is SUserAuthInfo
|
||||||
bool qNodeRequired; // valid qnode
|
bool qNodeRequired; // valid qnode
|
||||||
} SCatalogReq;
|
} SCatalogReq;
|
||||||
|
|
||||||
typedef struct SMetaData {
|
typedef struct SMetaData {
|
||||||
SArray *pTableMeta; // STableMeta array
|
SArray *pTableMeta; // SArray<STableMeta>
|
||||||
SArray *pVgroupInfo; // SVgroupInfo list
|
SArray *pDbVgroup; // SArray<SArray<SVgroupInfo>*>
|
||||||
SArray *pUdfList; // udf info list
|
SArray *pTableHash; // SArray<SVgroupInfo>
|
||||||
SArray *pQnodeList; // qnode list, SArray<SQueryNodeAddr>
|
SArray *pUdfList; // SArray<SFuncInfo>
|
||||||
|
SArray *pDbCfg; // SArray<SDbCfgInfo>
|
||||||
|
SArray *pIndex; // SArray<SIndexInfo>
|
||||||
|
SArray *pUser; // SArray<bool>
|
||||||
|
SArray *pQnodeList; // SArray<SQueryNodeAddr>
|
||||||
} SMetaData;
|
} SMetaData;
|
||||||
|
|
||||||
typedef struct STbSVersion {
|
|
||||||
char* tbFName;
|
|
||||||
int32_t sver;
|
|
||||||
} STbSVersion;
|
|
||||||
|
|
||||||
typedef struct SCatalogCfg {
|
typedef struct SCatalogCfg {
|
||||||
uint32_t maxTblCacheNum;
|
uint32_t maxTblCacheNum;
|
||||||
uint32_t maxDBCacheNum;
|
uint32_t maxDBCacheNum;
|
||||||
|
@ -88,6 +98,11 @@ typedef struct SDbVgVersion {
|
||||||
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT
|
||||||
} SDbVgVersion;
|
} SDbVgVersion;
|
||||||
|
|
||||||
|
typedef struct STbSVersion {
|
||||||
|
char* tbFName;
|
||||||
|
int32_t sver;
|
||||||
|
} STbSVersion;
|
||||||
|
|
||||||
typedef struct SUserAuthVersion {
|
typedef struct SUserAuthVersion {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
int32_t version;
|
int32_t version;
|
||||||
|
@ -96,6 +111,8 @@ typedef struct SUserAuthVersion {
|
||||||
typedef SDbCfgRsp SDbCfgInfo;
|
typedef SDbCfgRsp SDbCfgInfo;
|
||||||
typedef SUserIndexRsp SIndexInfo;
|
typedef SUserIndexRsp SIndexInfo;
|
||||||
|
|
||||||
|
typedef void (*catalogCallback)(SMetaData* pResult, void* param, int32_t code);
|
||||||
|
|
||||||
int32_t catalogInit(SCatalogCfg *cfg);
|
int32_t catalogInit(SCatalogCfg *cfg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +148,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCatalog, const char* dbName, uint64_t d
|
||||||
|
|
||||||
int32_t catalogRemoveDB(SCatalog* pCatalog, const char* dbName, uint64_t dbId);
|
int32_t catalogRemoveDB(SCatalog* pCatalog, const char* dbName, uint64_t dbId);
|
||||||
|
|
||||||
int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName);
|
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName);
|
||||||
|
|
||||||
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid);
|
int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, const char* stbName, uint64_t suid);
|
||||||
|
|
||||||
|
@ -241,9 +258,9 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion **users, uint32_
|
||||||
|
|
||||||
int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SDbCfgInfo* pDbCfg);
|
int32_t catalogGetDBCfg(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SDbCfgInfo* pDbCfg);
|
||||||
|
|
||||||
int32_t catalogGetIndexInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* indexName, SIndexInfo* pInfo);
|
int32_t catalogGetIndexMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* indexName, SIndexInfo* pInfo);
|
||||||
|
|
||||||
int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* funcName, SFuncInfo** pInfo);
|
int32_t catalogGetUdfInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* funcName, SFuncInfo* pInfo);
|
||||||
|
|
||||||
int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass);
|
int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
||||||
} SEncoder;
|
} SEncoder;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint8_t* data;
|
uint8_t* data;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
SCoderMem* mList;
|
SCoderMem* mList;
|
||||||
|
@ -120,7 +120,7 @@ static int32_t tEncodeCStrWithLen(SEncoder* pCoder, const char* val, uint32_t le
|
||||||
static int32_t tEncodeCStr(SEncoder* pCoder, const char* val);
|
static int32_t tEncodeCStr(SEncoder* pCoder, const char* val);
|
||||||
|
|
||||||
/* ------------------------ DECODE ------------------------ */
|
/* ------------------------ DECODE ------------------------ */
|
||||||
void tDecoderInit(SDecoder* pCoder, const uint8_t* data, uint32_t size);
|
void tDecoderInit(SDecoder* pCoder, uint8_t* data, uint32_t size);
|
||||||
void tDecoderClear(SDecoder* SDecoder);
|
void tDecoderClear(SDecoder* SDecoder);
|
||||||
int32_t tStartDecode(SDecoder* pCoder);
|
int32_t tStartDecode(SDecoder* pCoder);
|
||||||
void tEndDecode(SDecoder* pCoder);
|
void tEndDecode(SDecoder* pCoder);
|
||||||
|
@ -141,9 +141,9 @@ static int32_t tDecodeU64v(SDecoder* pCoder, uint64_t* val);
|
||||||
static int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val);
|
static int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val);
|
||||||
static int32_t tDecodeFloat(SDecoder* pCoder, float* val);
|
static int32_t tDecodeFloat(SDecoder* pCoder, float* val);
|
||||||
static int32_t tDecodeDouble(SDecoder* pCoder, double* val);
|
static int32_t tDecodeDouble(SDecoder* pCoder, double* val);
|
||||||
static int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val, uint32_t* len);
|
static int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint32_t* len);
|
||||||
static int32_t tDecodeCStrAndLen(SDecoder* pCoder, const char** val, uint32_t* len);
|
static int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len);
|
||||||
static int32_t tDecodeCStr(SDecoder* pCoder, const char** val);
|
static int32_t tDecodeCStr(SDecoder* pCoder, char** val);
|
||||||
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val);
|
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val);
|
||||||
|
|
||||||
/* ------------------------ IMPL ------------------------ */
|
/* ------------------------ IMPL ------------------------ */
|
||||||
|
@ -317,7 +317,7 @@ static FORCE_INLINE int32_t tDecodeI16v(SDecoder* pCoder, int16_t* val) {
|
||||||
if (tDecodeU16v(pCoder, &tval) < 0) {
|
if (tDecodeU16v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int16_t, tval);
|
if (val) *val = ZIGZAGD(int16_t, tval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ static FORCE_INLINE int32_t tDecodeI32v(SDecoder* pCoder, int32_t* val) {
|
||||||
if (tDecodeU32v(pCoder, &tval) < 0) {
|
if (tDecodeU32v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int32_t, tval);
|
if (val) *val = ZIGZAGD(int32_t, tval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ static FORCE_INLINE int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val) {
|
||||||
if (tDecodeU64v(pCoder, &tval) < 0) {
|
if (tDecodeU64v(pCoder, &tval) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*val = ZIGZAGD(int64_t, tval);
|
if (val) *val = ZIGZAGD(int64_t, tval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ static FORCE_INLINE int32_t tDecodeDouble(SDecoder* pCoder, double* val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val, uint32_t* len) {
|
static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint32_t* len) {
|
||||||
if (tDecodeU32v(pCoder, len) < 0) return -1;
|
if (tDecodeU32v(pCoder, len) < 0) return -1;
|
||||||
|
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, *len)) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, *len)) return -1;
|
||||||
|
@ -389,19 +389,19 @@ static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, const uint8_t** val,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, const char** val, uint32_t* len) {
|
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) {
|
||||||
if (tDecodeBinary(pCoder, (const uint8_t**)val, len) < 0) return -1;
|
if (tDecodeBinary(pCoder, (uint8_t**)val, len) < 0) return -1;
|
||||||
(*len) -= 1;
|
(*len) -= 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeCStr(SDecoder* pCoder, const char** val) {
|
static FORCE_INLINE int32_t tDecodeCStr(SDecoder* pCoder, char** val) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
return tDecodeCStrAndLen(pCoder, val, &len);
|
return tDecodeCStrAndLen(pCoder, val, &len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
||||||
const char* pStr;
|
char* pStr;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
if (tDecodeCStrAndLen(pCoder, &pStr, &len) < 0) return -1;
|
if (tDecodeCStrAndLen(pCoder, &pStr, &len) < 0) return -1;
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,36 @@
|
||||||
set -e
|
set -e
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
|
verMode=edge
|
||||||
|
pagMode=full
|
||||||
|
|
||||||
|
iplist=""
|
||||||
|
serverFqdn=""
|
||||||
|
|
||||||
# -----------------------Variables definition---------------------
|
# -----------------------Variables definition---------------------
|
||||||
script_dir=$(dirname $(readlink -f "$0"))
|
script_dir=$(dirname $(readlink -f "$0"))
|
||||||
# Dynamic directory
|
# Dynamic directory
|
||||||
data_dir="/var/lib/taos"
|
|
||||||
log_dir="/var/log/taos"
|
|
||||||
|
|
||||||
data_link_dir="/usr/local/taos/data"
|
clientName="taos"
|
||||||
log_link_dir="/usr/local/taos/log"
|
serverName="taosd"
|
||||||
|
configFile="taos.cfg"
|
||||||
|
productName="TDengine"
|
||||||
|
emailName="taosdata.com"
|
||||||
|
uninstallScript="rmtaos"
|
||||||
|
historyFile="taos_history"
|
||||||
|
tarName="taos.tar.gz"
|
||||||
|
dataDir="/var/lib/taos"
|
||||||
|
logDir="/var/log/taos"
|
||||||
|
configDir="/etc/taos"
|
||||||
|
installDir="/usr/local/taos"
|
||||||
|
adapterName="taosadapter"
|
||||||
|
benchmarkName="taosBenchmark"
|
||||||
|
dumpName="taosdump"
|
||||||
|
demoName="taosdemo"
|
||||||
|
|
||||||
cfg_install_dir="/etc/taos"
|
data_dir=${dataDir}
|
||||||
|
log_dir=${logDir}
|
||||||
|
cfg_install_dir=${configDir}
|
||||||
|
|
||||||
bin_link_dir="/usr/bin"
|
bin_link_dir="/usr/bin"
|
||||||
lib_link_dir="/usr/lib"
|
lib_link_dir="/usr/lib"
|
||||||
|
@ -23,21 +43,13 @@ lib64_link_dir="/usr/lib64"
|
||||||
inc_link_dir="/usr/include"
|
inc_link_dir="/usr/include"
|
||||||
|
|
||||||
#install main path
|
#install main path
|
||||||
install_main_dir="/usr/local/taos"
|
install_main_dir=${installDir}
|
||||||
|
|
||||||
# old bin dir
|
# old bin dir
|
||||||
bin_dir="/usr/local/taos/bin"
|
bin_dir="${installDir}/bin"
|
||||||
|
|
||||||
service_config_dir="/etc/systemd/system"
|
service_config_dir="/etc/systemd/system"
|
||||||
|
nginx_port=6060
|
||||||
#taos-tools para
|
nginx_dir="/usr/local/nginxd"
|
||||||
demoName="taosdemo"
|
|
||||||
benchmarkName="taosBenchmark"
|
|
||||||
dumpName="taosdump"
|
|
||||||
emailName="taosdata.com"
|
|
||||||
taosName="taos"
|
|
||||||
toolsName="taostools"
|
|
||||||
|
|
||||||
|
|
||||||
# Color setting
|
# Color setting
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
@ -74,7 +86,6 @@ else
|
||||||
service_mod=2
|
service_mod=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# get the operating system type for using the corresponding init file
|
# get the operating system type for using the corresponding init file
|
||||||
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
||||||
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||||
|
@ -110,11 +121,10 @@ else
|
||||||
echo " osinfo: ${osinfo}"
|
echo " osinfo: ${osinfo}"
|
||||||
echo " This is an officially unverified linux system,"
|
echo " This is an officially unverified linux system,"
|
||||||
echo " if there are any problems with the installation and operation, "
|
echo " if there are any problems with the installation and operation, "
|
||||||
echo " please feel free to contact taosdata.com for support."
|
echo " please feel free to contact ${emailName} for support."
|
||||||
os_type=1
|
os_type=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================= get input parameters =================================================
|
# ============================= get input parameters =================================================
|
||||||
|
|
||||||
# install.sh -v [server | client] -e [yes | no] -i [systemd | service | ...]
|
# install.sh -v [server | client] -e [yes | no] -i [systemd | service | ...]
|
||||||
|
@ -124,8 +134,7 @@ interactiveFqdn=yes # [yes | no]
|
||||||
verType=server # [server | client]
|
verType=server # [server | client]
|
||||||
initType=systemd # [systemd | service | ...]
|
initType=systemd # [systemd | service | ...]
|
||||||
|
|
||||||
while getopts "hv:e:i:" arg
|
while getopts "hv:e:i:" arg; do
|
||||||
do
|
|
||||||
case $arg in
|
case $arg in
|
||||||
e)
|
e)
|
||||||
#echo "interactiveFqdn=$OPTARG"
|
#echo "interactiveFqdn=$OPTARG"
|
||||||
|
@ -140,7 +149,7 @@ do
|
||||||
initType=$(echo $OPTARG)
|
initType=$(echo $OPTARG)
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage: `basename $0` -v [server | client] -e [yes | no]"
|
echo "Usage: $(basename $0) -v [server | client] -e [yes | no]"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
?) #unknow option
|
?) #unknow option
|
||||||
|
@ -165,11 +174,11 @@ function install_main_path() {
|
||||||
${csudo}mkdir -p ${install_main_dir}
|
${csudo}mkdir -p ${install_main_dir}
|
||||||
${csudo}mkdir -p ${install_main_dir}/cfg
|
${csudo}mkdir -p ${install_main_dir}/cfg
|
||||||
${csudo}mkdir -p ${install_main_dir}/bin
|
${csudo}mkdir -p ${install_main_dir}/bin
|
||||||
${csudo} mkdir -p ${install_main_dir}/connector
|
# ${csudo}mkdir -p ${install_main_dir}/connector
|
||||||
${csudo} mkdir -p ${install_main_dir}/lib
|
${csudo}mkdir -p ${install_main_dir}/driver
|
||||||
${csudo}mkdir -p ${install_main_dir}/examples
|
${csudo}mkdir -p ${install_main_dir}/examples
|
||||||
${csudo}mkdir -p ${install_main_dir}/include
|
${csudo}mkdir -p ${install_main_dir}/include
|
||||||
${csudo} mkdir -p ${install_main_dir}/init.d
|
# ${csudo}mkdir -p ${install_main_dir}/init.d
|
||||||
if [ "$verMode" == "cluster" ]; then
|
if [ "$verMode" == "cluster" ]; then
|
||||||
${csudo}mkdir -p ${nginx_dir}
|
${csudo}mkdir -p ${nginx_dir}
|
||||||
fi
|
fi
|
||||||
|
@ -181,74 +190,139 @@ function install_main_path() {
|
||||||
|
|
||||||
function install_bin() {
|
function install_bin() {
|
||||||
# Remove links
|
# Remove links
|
||||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
${csudo}rm -f ${bin_link_dir}/${clientName} || :
|
||||||
${csudo} rm -f ${bin_link_dir}/taosd || :
|
${csudo}rm -f ${bin_link_dir}/${serverName} || :
|
||||||
${csudo} rm -f ${bin_link_dir}/taosadapter || :
|
${csudo}rm -f ${bin_link_dir}/${adapterName} || :
|
||||||
${csudo} rm -f ${bin_link_dir}/create_table || :
|
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
|
||||||
${csudo} rm -f ${bin_link_dir}/tmq_sim || :
|
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
|
||||||
${csudo} rm -f ${bin_link_dir}/taosdump || :
|
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||||
${csudo} rm -f ${bin_link_dir}/rmtaos || :
|
${csudo}rm -f ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || :
|
||||||
#${csudo} rm -f ${bin_link_dir}/set_core || :
|
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
||||||
|
|
||||||
${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/*
|
${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/*
|
||||||
|
|
||||||
#Make link
|
#Make link
|
||||||
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
|
[ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || :
|
||||||
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
|
[ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || :
|
||||||
[ -x ${install_main_dir}/bin/create_table ] && ${csudo} ln -s ${install_main_dir}/bin/create_table ${bin_link_dir}/create_table || :
|
[ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || :
|
||||||
[ -x ${install_main_dir}/bin/tmq_sim ] && ${csudo} ln -s ${install_main_dir}/bin/tmq_sim ${bin_link_dir}/tmq_sim || :
|
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || :
|
||||||
# [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
|
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
|
||||||
# [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
|
[ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
|
||||||
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
|
[ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
|
||||||
# [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
|
||||||
|
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
||||||
|
[ -x ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || :
|
||||||
|
[ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || :
|
||||||
|
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
${csudo}cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo}chmod 0555 ${nginx_dir}/*
|
||||||
|
${csudo}mkdir -p ${nginx_dir}/logs
|
||||||
|
${csudo}chmod 777 ${nginx_dir}/sbin/nginx
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_lib() {
|
function install_lib() {
|
||||||
# Remove links
|
# Remove links
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||||
${csudo} rm -f ${lib_link_dir}/libtdb.* || :
|
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||||
${csudo} rm -f ${lib64_link_dir}/libtdb.* || :
|
${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/*
|
||||||
|
|
||||||
${csudo} cp -rf ${script_dir}/lib/* ${install_main_dir}/lib && ${csudo} chmod 777 ${install_main_dir}/lib/*
|
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||||
|
|
||||||
${csudo} ln -s ${install_main_dir}/lib/libtaos.* ${lib_link_dir}/libtaos.so.1
|
|
||||||
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
||||||
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
|
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
|
||||||
${csudo} ln -s ${install_main_dir}/lib/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
|
||||||
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${csudo}ldconfig
|
${csudo}ldconfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_avro() {
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
avro_dir=${script_dir}/avro
|
||||||
|
if [ -f "${avro_dir}/lib/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/$1
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.so.23.0.0 /usr/local/$1
|
||||||
|
${csudo}ln -sf /usr/local/$1/libavro.so.23.0.0 /usr/local/$1/libavro.so.23
|
||||||
|
${csudo}ln -sf /usr/local/$1/libavro.so.23 /usr/local/$1/libavro.so
|
||||||
|
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/$1
|
||||||
|
[ -f ${avro_dir}/lib/libavro.a ] &&
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.a /usr/local/$1
|
||||||
|
|
||||||
|
if [ -d /etc/ld.so.conf.d ]; then
|
||||||
|
echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf"
|
||||||
|
${csudo}ldconfig
|
||||||
|
else
|
||||||
|
echo "/etc/ld.so.conf.d not found!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_jemalloc() {
|
||||||
|
jemalloc_dir=${script_dir}/jemalloc
|
||||||
|
|
||||||
|
if [ -d ${jemalloc_dir} ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/bin
|
||||||
|
|
||||||
|
if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/bin/jeprof ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib
|
||||||
|
${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib
|
||||||
|
if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc
|
||||||
|
fi
|
||||||
|
if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/share/man/man3
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /etc/ld.so.conf.d ]; then
|
||||||
|
echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf"
|
||||||
|
${csudo}ldconfig
|
||||||
|
else
|
||||||
|
echo "/etc/ld.so.conf.d not found!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function install_header() {
|
function install_header() {
|
||||||
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || :
|
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || :
|
||||||
${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
||||||
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||||
# ${csudo} ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
|
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
|
||||||
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||||
}
|
}
|
||||||
|
|
||||||
# temp install taosBenchmark
|
|
||||||
function install_taosTools() {
|
|
||||||
${csudo} rm -f ${bin_link_dir}/${benchmarkName} || :
|
|
||||||
${csudo} rm -f ${bin_link_dir}/${dumpName} || :
|
|
||||||
${csudo} rm -f ${bin_link_dir}/rm${toolsName} || :
|
|
||||||
|
|
||||||
${csudo} /usr/bin/install -c -m 755 ${script_dir}/bin/${dumpName} ${install_main_dir}/bin/${dumpName}
|
|
||||||
${csudo} /usr/bin/install -c -m 755 ${script_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${benchmarkName}
|
|
||||||
${csudo} ln -sf ${install_main_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${demoName}
|
|
||||||
#Make link
|
|
||||||
[[ -x ${install_main_dir}/bin/${benchmarkName} ]] && \
|
|
||||||
${csudo} ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
|
|
||||||
[[ -x ${install_main_dir}/bin/${demoName} ]] && \
|
|
||||||
${csudo} ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
|
|
||||||
[[ -x ${install_main_dir}/bin/${dumpName} ]] && \
|
|
||||||
${csudo} ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_newHostname_to_hosts() {
|
function add_newHostname_to_hosts() {
|
||||||
localIp="127.0.0.1"
|
localIp="127.0.0.1"
|
||||||
OLD_IFS="$IFS"
|
OLD_IFS="$IFS"
|
||||||
|
@ -256,8 +330,7 @@ function add_newHostname_to_hosts() {
|
||||||
iphost=$(cat /etc/hosts | grep $1 | awk '{print $1}')
|
iphost=$(cat /etc/hosts | grep $1 | awk '{print $1}')
|
||||||
arr=($iphost)
|
arr=($iphost)
|
||||||
IFS="$OLD_IFS"
|
IFS="$OLD_IFS"
|
||||||
for s in "${arr[@]}"
|
for s in "${arr[@]}"; do
|
||||||
do
|
|
||||||
if [[ "$s" == "$localIp" ]]; then
|
if [[ "$s" == "$localIp" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -277,15 +350,12 @@ function set_hostname() {
|
||||||
done
|
done
|
||||||
|
|
||||||
${csudo}hostname $newHostname || :
|
${csudo}hostname $newHostname || :
|
||||||
retval=`echo $?`
|
retval=$(echo $?)
|
||||||
if [[ $retval != 0 ]]; then
|
if [[ $retval != 0 ]]; then
|
||||||
echo
|
echo
|
||||||
echo "set hostname fail!"
|
echo "set hostname fail!"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
#echo -e -n "$(hostnamectl status --static)"
|
|
||||||
#echo -e -n "$(hostnamectl status --transient)"
|
|
||||||
#echo -e -n "$(hostnamectl status --pretty)"
|
|
||||||
|
|
||||||
#ubuntu/centos /etc/hostname
|
#ubuntu/centos /etc/hostname
|
||||||
if [[ -e /etc/hostname ]]; then
|
if [[ -e /etc/hostname ]]; then
|
||||||
|
@ -297,7 +367,7 @@ function set_hostname() {
|
||||||
${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || :
|
${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg
|
${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile}
|
||||||
serverFqdn=$newHostname
|
serverFqdn=$newHostname
|
||||||
|
|
||||||
if [[ -e /etc/hosts ]]; then
|
if [[ -e /etc/hosts ]]; then
|
||||||
|
@ -311,8 +381,7 @@ function is_correct_ipaddr() {
|
||||||
IFS=" "
|
IFS=" "
|
||||||
arr=($iplist)
|
arr=($iplist)
|
||||||
IFS="$OLD_IFS"
|
IFS="$OLD_IFS"
|
||||||
for s in "${arr[@]}"
|
for s in "${arr[@]}"; do
|
||||||
do
|
|
||||||
if [[ "$s" == "$newIp" ]]; then
|
if [[ "$s" == "$newIp" ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -332,7 +401,7 @@ function set_ipAsFqdn() {
|
||||||
echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}"
|
echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}"
|
||||||
localFqdn="127.0.0.1"
|
localFqdn="127.0.0.1"
|
||||||
# Write the local FQDN to configuration file
|
# Write the local FQDN to configuration file
|
||||||
${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
|
${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile}
|
||||||
serverFqdn=$localFqdn
|
serverFqdn=$localFqdn
|
||||||
echo
|
echo
|
||||||
return
|
return
|
||||||
|
@ -349,12 +418,12 @@ function set_ipAsFqdn() {
|
||||||
if [ ! -z "$localFqdn" ]; then
|
if [ ! -z "$localFqdn" ]; then
|
||||||
# Check if correct ip address
|
# Check if correct ip address
|
||||||
is_correct_ipaddr $localFqdn
|
is_correct_ipaddr $localFqdn
|
||||||
retval=`echo $?`
|
retval=$(echo $?)
|
||||||
if [[ $retval != 0 ]]; then
|
if [[ $retval != 0 ]]; then
|
||||||
read -p "Please choose an IP from local IP list:" localFqdn
|
read -p "Please choose an IP from local IP list:" localFqdn
|
||||||
else
|
else
|
||||||
# Write the local FQDN to configuration file
|
# Write the local FQDN to configuration file
|
||||||
${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
|
${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile}
|
||||||
serverFqdn=$localFqdn
|
serverFqdn=$localFqdn
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -373,8 +442,7 @@ function local_fqdn_check() {
|
||||||
echo -e -n "${GREEN}It is strongly recommended to configure a hostname for this machine ${NC}"
|
echo -e -n "${GREEN}It is strongly recommended to configure a hostname for this machine ${NC}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
while true
|
while true; do
|
||||||
do
|
|
||||||
read -r -p "Set hostname now? [Y/n] " input
|
read -r -p "Set hostname now? [Y/n] " input
|
||||||
if [ ! -n "$input" ]; then
|
if [ ! -n "$input" ]; then
|
||||||
set_hostname
|
set_hostname
|
||||||
|
@ -400,6 +468,74 @@ function local_fqdn_check() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_adapter_config() {
|
||||||
|
if [ ! -f "${cfg_install_dir}/${adapterName}.toml" ]; then
|
||||||
|
${csudo}mkdir -p ${cfg_install_dir}
|
||||||
|
[ -f ${script_dir}/cfg/${adapterName}.toml ] && ${csudo}cp ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir}
|
||||||
|
[ -f ${cfg_install_dir}/${adapterName}.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/${adapterName}.toml
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -f ${script_dir}/cfg/${adapterName}.toml ] &&
|
||||||
|
${csudo}cp -f ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir}/${adapterName}.toml.new
|
||||||
|
|
||||||
|
[ -f ${cfg_install_dir}/${adapterName}.toml ] &&
|
||||||
|
${csudo}ln -s ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml
|
||||||
|
|
||||||
|
[ ! -z $1 ] && return 0 || : # only install client
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_config() {
|
||||||
|
|
||||||
|
if [ ! -f "${cfg_install_dir}/${configFile}" ]; then
|
||||||
|
${csudo}mkdir -p ${cfg_install_dir}
|
||||||
|
[ -f ${script_dir}/cfg/${configFile} ] && ${csudo}cp ${script_dir}/cfg/${configFile} ${cfg_install_dir}
|
||||||
|
${csudo}chmod 644 ${cfg_install_dir}/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
${csudo}cp -f ${script_dir}/cfg/${configFile} ${cfg_install_dir}/${configFile}.new
|
||||||
|
${csudo}ln -s ${cfg_install_dir}/${configFile} ${install_main_dir}/cfg
|
||||||
|
|
||||||
|
[ ! -z $1 ] && return 0 || : # only install client
|
||||||
|
|
||||||
|
if ((${update_flag} == 1)); then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$interactiveFqdn" == "no" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local_fqdn_check
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}"
|
||||||
|
echo
|
||||||
|
echo -e -n "${GREEN}OR leave it blank to build one${NC}:"
|
||||||
|
read firstEp
|
||||||
|
while true; do
|
||||||
|
if [ ! -z "$firstEp" ]; then
|
||||||
|
${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile}
|
||||||
|
break
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e -n "${GREEN}Enter your email address for priority support or enter empty to skip${NC}: "
|
||||||
|
read emailAddr
|
||||||
|
while true; do
|
||||||
|
if [ ! -z "$emailAddr" ]; then
|
||||||
|
email_file="${install_main_dir}/email"
|
||||||
|
${csudo}bash -c "echo $emailAddr > ${email_file}"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function install_log() {
|
function install_log() {
|
||||||
${csudo}rm -rf ${log_dir} || :
|
${csudo}rm -rf ${log_dir} || :
|
||||||
${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir}
|
${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir}
|
||||||
|
@ -413,13 +549,96 @@ function install_data() {
|
||||||
${csudo}ln -s ${data_dir} ${install_main_dir}/data
|
${csudo}ln -s ${data_dir} ${install_main_dir}/data
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_service_on_systemd() {
|
function install_connector() {
|
||||||
taosd_service_config="${service_config_dir}/taosd.service"
|
[ -d "${script_dir}/connector/" ] && ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/
|
||||||
if systemctl is-active --quiet taosd; then
|
}
|
||||||
echo "TDengine is running, stopping it..."
|
|
||||||
${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null
|
function install_examples() {
|
||||||
|
if [ -d ${script_dir}/examples ]; then
|
||||||
|
${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples
|
||||||
fi
|
fi
|
||||||
${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null
|
}
|
||||||
|
|
||||||
|
function clean_service_on_sysvinit() {
|
||||||
|
if pidof ${serverName} &>/dev/null; then
|
||||||
|
${csudo}service ${serverName} stop || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if pidof tarbitrator &>/dev/null; then
|
||||||
|
${csudo}service tarbitratord stop || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${initd_mod} == 1)); then
|
||||||
|
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||||
|
${csudo}chkconfig --del ${serverName} || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||||
|
${csudo}chkconfig --del tarbitratord || :
|
||||||
|
fi
|
||||||
|
elif ((${initd_mod} == 2)); then
|
||||||
|
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||||
|
${csudo}insserv -r ${serverName} || :
|
||||||
|
fi
|
||||||
|
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||||
|
${csudo}insserv -r tarbitratord || :
|
||||||
|
fi
|
||||||
|
elif ((${initd_mod} == 3)); then
|
||||||
|
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||||
|
${csudo}update-rc.d -f ${serverName} remove || :
|
||||||
|
fi
|
||||||
|
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||||
|
${csudo}update-rc.d -f tarbitratord remove || :
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
${csudo}rm -f ${service_config_dir}/${serverName} || :
|
||||||
|
${csudo}rm -f ${service_config_dir}/tarbitratord || :
|
||||||
|
|
||||||
|
if $(which init &>/dev/null); then
|
||||||
|
${csudo}init q || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_service_on_sysvinit() {
|
||||||
|
clean_service_on_sysvinit
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if ((${os_type} == 1)); then
|
||||||
|
# ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName}
|
||||||
|
${csudo}cp ${script_dir}/init.d/${serverName}.deb ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName}
|
||||||
|
# ${csudo}cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord
|
||||||
|
${csudo}cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord
|
||||||
|
elif ((${os_type} == 2)); then
|
||||||
|
# ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName}
|
||||||
|
${csudo}cp ${script_dir}/init.d/${serverName}.rpm ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName}
|
||||||
|
# ${csudo}cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord
|
||||||
|
${csudo}cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo}chmod a+x ${service_config_dir}/tarbitratord
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${initd_mod} == 1)); then
|
||||||
|
${csudo}chkconfig --add ${serverName} || :
|
||||||
|
${csudo}chkconfig --level 2345 ${serverName} on || :
|
||||||
|
${csudo}chkconfig --add tarbitratord || :
|
||||||
|
${csudo}chkconfig --level 2345 tarbitratord on || :
|
||||||
|
elif ((${initd_mod} == 2)); then
|
||||||
|
${csudo}insserv ${serverName} || :
|
||||||
|
${csudo}insserv -d ${serverName} || :
|
||||||
|
${csudo}insserv tarbitratord || :
|
||||||
|
${csudo}insserv -d tarbitratord || :
|
||||||
|
elif ((${initd_mod} == 3)); then
|
||||||
|
${csudo}update-rc.d ${serverName} defaults || :
|
||||||
|
${csudo}update-rc.d tarbitratord defaults || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_service_on_systemd() {
|
||||||
|
taosd_service_config="${service_config_dir}/${serverName}.service"
|
||||||
|
if systemctl is-active --quiet ${serverName}; then
|
||||||
|
echo "${productName} is running, stopping it..."
|
||||||
|
${csudo}systemctl stop ${serverName} &>/dev/null || echo &>/dev/null
|
||||||
|
fi
|
||||||
|
${csudo}systemctl disable ${serverName} &>/dev/null || echo &>/dev/null
|
||||||
${csudo}rm -f ${taosd_service_config}
|
${csudo}rm -f ${taosd_service_config}
|
||||||
|
|
||||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||||
|
@ -433,7 +652,7 @@ function clean_service_on_systemd() {
|
||||||
if [ "$verMode" == "cluster" ]; then
|
if [ "$verMode" == "cluster" ]; then
|
||||||
nginx_service_config="${service_config_dir}/nginxd.service"
|
nginx_service_config="${service_config_dir}/nginxd.service"
|
||||||
if systemctl is-active --quiet nginxd; then
|
if systemctl is-active --quiet nginxd; then
|
||||||
echo "Nginx for TDengine is running, stopping it..."
|
echo "Nginx for ${productName} is running, stopping it..."
|
||||||
${csudo}systemctl stop nginxd &>/dev/null || echo &>/dev/null
|
${csudo}systemctl stop nginxd &>/dev/null || echo &>/dev/null
|
||||||
fi
|
fi
|
||||||
${csudo}systemctl disable nginxd &>/dev/null || echo &>/dev/null
|
${csudo}systemctl disable nginxd &>/dev/null || echo &>/dev/null
|
||||||
|
@ -441,89 +660,277 @@ function clean_service_on_systemd() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# taos:2345:respawn:/etc/init.d/taosd start
|
|
||||||
|
|
||||||
function install_service_on_systemd() {
|
function install_service_on_systemd() {
|
||||||
clean_service_on_systemd
|
clean_service_on_systemd
|
||||||
|
|
||||||
taosd_service_config="${service_config_dir}/taosd.service"
|
[ -f ${script_dir}/cfg/${serverName}.service ] &&
|
||||||
${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
${csudo}cp ${script_dir}/cfg/${serverName}.service \
|
||||||
${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}"
|
${service_config_dir}/ || :
|
||||||
${csudo} bash -c "echo 'After=network-online.target taosadapter.service' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'Wants=network-online.target taosadapter.service' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo '[Service]' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'Type=simple' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'Restart=always' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}"
|
|
||||||
#${csudo} bash -c "echo 'StartLimitIntervalSec=60s' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}"
|
|
||||||
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
|
||||||
${csudo} systemctl enable taosd
|
|
||||||
|
|
||||||
${csudo}systemctl daemon-reload
|
${csudo}systemctl daemon-reload
|
||||||
|
|
||||||
|
${csudo}systemctl enable ${serverName}
|
||||||
|
|
||||||
|
[ -f ${script_dir}/cfg/tarbitratord.service ] &&
|
||||||
|
${csudo}cp ${script_dir}/cfg/tarbitratord.service \
|
||||||
|
${service_config_dir}/ || :
|
||||||
|
${csudo}systemctl daemon-reload
|
||||||
|
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
[ -f ${script_dir}/cfg/nginxd.service ] &&
|
||||||
|
${csudo}cp ${script_dir}/cfg/nginxd.service \
|
||||||
|
${service_config_dir}/ || :
|
||||||
|
${csudo}systemctl daemon-reload
|
||||||
|
|
||||||
|
if ! ${csudo}systemctl enable nginxd &>/dev/null; then
|
||||||
|
${csudo}systemctl daemon-reexec
|
||||||
|
${csudo}systemctl enable nginxd
|
||||||
|
fi
|
||||||
|
${csudo}systemctl start nginxd
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_adapter_service() {
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
[ -f ${script_dir}/cfg/${adapterName}.service ] &&
|
||||||
|
${csudo}cp ${script_dir}/cfg/${adapterName}.service \
|
||||||
|
${service_config_dir}/ || :
|
||||||
|
${csudo}systemctl daemon-reload
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_service() {
|
function install_service() {
|
||||||
# if ((${service_mod}==0)); then
|
if ((${service_mod} == 0)); then
|
||||||
# install_service_on_systemd
|
install_service_on_systemd
|
||||||
# elif ((${service_mod}==1)); then
|
elif ((${service_mod} == 1)); then
|
||||||
# install_service_on_sysvinit
|
install_service_on_sysvinit
|
||||||
# else
|
else
|
||||||
# # must manual stop taosd
|
kill_process ${serverName}
|
||||||
kill_process taosd
|
fi
|
||||||
# fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_config() {
|
vercomp() {
|
||||||
if [ ! -f ${cfg_install_dir}/${configFile} ]; then
|
if [[ $1 == $2 ]]; then
|
||||||
${csudo}mkdir -p ${cfg_install_dir}
|
return 0
|
||||||
[ -f ${script_dir}/cfg/${configFile} ] && ${csudo}cp ${script_dir}/cfg/${configFile} ${cfg_install_dir}
|
fi
|
||||||
${csudo}chmod 644 ${cfg_install_dir}/*
|
local IFS=.
|
||||||
|
local i ver1=($1) ver2=($2)
|
||||||
|
# fill empty fields in ver1 with zeros
|
||||||
|
for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)); do
|
||||||
|
ver1[i]=0
|
||||||
|
done
|
||||||
|
|
||||||
|
for ((i = 0; i < ${#ver1[@]}; i++)); do
|
||||||
|
if [[ -z ${ver2[i]} ]]; then
|
||||||
|
# fill empty fields in ver2 with zeros
|
||||||
|
ver2[i]=0
|
||||||
|
fi
|
||||||
|
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ((10#${ver1[i]} < 10#${ver2[i]})); then
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_version_compatible() {
|
||||||
|
|
||||||
|
curr_version=$(ls ${script_dir}/driver/libtaos.so* | awk -F 'libtaos.so.' '{print $2}')
|
||||||
|
|
||||||
|
if [ -f ${script_dir}/driver/vercomp.txt ]; then
|
||||||
|
min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt)
|
||||||
|
else
|
||||||
|
min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${csudo}cp -f ${script_dir}/cfg/${configFile} ${install_main_dir}/cfg/${configFile}.org
|
exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3)
|
||||||
${csudo}ln -s ${cfg_install_dir}/${configFile} ${install_main_dir}/cfg
|
vercomp $exist_version "2.0.16.0"
|
||||||
|
case $? in
|
||||||
|
2)
|
||||||
|
prompt_force=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
vercomp $curr_version $min_compatible_version
|
||||||
|
echo "" # avoid $? value not update
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
0) return 0 ;;
|
||||||
|
1) return 0 ;;
|
||||||
|
2) return 1 ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_TDengine() {
|
function updateProduct() {
|
||||||
# Start to install
|
# Check if version compatible
|
||||||
echo -e "${GREEN}Start to install TDengine...${NC}"
|
if ! is_version_compatible; then
|
||||||
|
echo -e "${RED}Version incompatible${NC}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start to update
|
||||||
|
if [ ! -e ${tarName} ]; then
|
||||||
|
echo "File ${tarName} does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tar -zxf ${tarName}
|
||||||
|
install_jemalloc
|
||||||
|
|
||||||
|
echo -e "${GREEN}Start to update ${productName}...${NC}"
|
||||||
|
# Stop the service if running
|
||||||
|
if pidof ${serverName} &>/dev/null; then
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
${csudo}systemctl stop ${serverName} || :
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
${csudo}service ${serverName} stop || :
|
||||||
|
else
|
||||||
|
kill_process ${serverName}
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
if pidof nginx &>/dev/null; then
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
${csudo}systemctl stop nginxd || :
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
${csudo}service nginxd stop || :
|
||||||
|
else
|
||||||
|
kill_process nginx
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
install_main_path
|
install_main_path
|
||||||
install_data
|
|
||||||
install_log
|
install_log
|
||||||
install_header
|
install_header
|
||||||
install_lib
|
install_lib
|
||||||
install_taosTools
|
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
install_connector
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_examples
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
install_bin
|
||||||
|
install_service
|
||||||
|
install_adapter_service
|
||||||
|
install_config
|
||||||
|
install_adapter_config
|
||||||
|
|
||||||
|
openresty_work=false
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
# Check if openresty is installed
|
||||||
|
# Check if nginx is installed successfully
|
||||||
|
if type curl &>/dev/null; then
|
||||||
|
if curl -sSf http://127.0.0.1:${nginx_port} &>/dev/null; then
|
||||||
|
echo -e "\033[44;32;1mNginx for ${productName} is updated successfully!${NC}"
|
||||||
|
openresty_work=true
|
||||||
|
else
|
||||||
|
echo -e "\033[44;31;5mNginx for ${productName} does not work! Please try again!\033[0m"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}"
|
||||||
|
echo -e "${GREEN_DARK}To configure Adapter (if has) ${NC}: edit ${cfg_install_dir}/${adapterName}.toml"
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN_DARK}To start Adapter (if has)${NC}: ${adapterName} &${NC}"
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${openresty_work} = 'true' ]; then
|
||||||
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${prompt_force} == 1)); then
|
||||||
|
echo ""
|
||||||
|
echo -e "${RED}Please run '${serverName} --force-keep-file' at first time for the exist ${productName} $exist_version!${NC}"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
|
||||||
|
else
|
||||||
|
install_bin
|
||||||
|
install_config
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $(tar -tf ${tarName} | grep -v "^\./$")
|
||||||
|
}
|
||||||
|
|
||||||
|
function installProduct() {
|
||||||
|
# Start to install
|
||||||
|
if [ ! -e ${tarName} ]; then
|
||||||
|
echo "File ${tarName} does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tar -zxf ${tarName}
|
||||||
|
|
||||||
|
echo -e "${GREEN}Start to install ${productName}...${NC}"
|
||||||
|
|
||||||
|
install_main_path
|
||||||
|
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
install_data
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_log
|
||||||
|
install_header
|
||||||
|
install_lib
|
||||||
|
install_jemalloc
|
||||||
|
#install_avro lib
|
||||||
|
#install_avro lib64
|
||||||
|
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
install_connector
|
||||||
|
fi
|
||||||
|
install_examples
|
||||||
|
|
||||||
if [ -z $1 ]; then # install service and client
|
if [ -z $1 ]; then # install service and client
|
||||||
# For installing new
|
# For installing new
|
||||||
install_bin
|
install_bin
|
||||||
install_service
|
install_service
|
||||||
|
install_adapter_service
|
||||||
|
install_adapter_config
|
||||||
|
|
||||||
|
openresty_work=false
|
||||||
|
if [ "$verMode" == "cluster" ]; then
|
||||||
|
# Check if nginx is installed successfully
|
||||||
|
if type curl &>/dev/null; then
|
||||||
|
if curl -sSf http://127.0.0.1:${nginx_port} &>/dev/null; then
|
||||||
|
echo -e "\033[44;32;1mNginx for ${productName} is installed successfully!${NC}"
|
||||||
|
openresty_work=true
|
||||||
|
else
|
||||||
|
echo -e "\033[44;31;5mNginx for ${productName} does not work! Please try again!\033[0m"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
install_config
|
install_config
|
||||||
|
|
||||||
# Ask if to start the service
|
# Ask if to start the service
|
||||||
#echo
|
|
||||||
#echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
|
|
||||||
echo
|
echo
|
||||||
echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
|
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}"
|
||||||
|
echo -e "${GREEN_DARK}To configure ${adapterName} (if has) ${NC}: edit ${cfg_install_dir}/${adapterName}.toml"
|
||||||
if ((${service_mod} == 0)); then
|
if ((${service_mod} == 0)); then
|
||||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
|
||||||
elif ((${service_mod} == 1)); then
|
elif ((${service_mod} == 1)); then
|
||||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
|
echo -e "${GREEN_DARK}To start Adapter (if has)${NC}: ${adapterName} &${NC}"
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$firstEp" ]; then
|
if [ ! -z "$firstEp" ]; then
|
||||||
|
@ -535,39 +942,49 @@ function install_TDengine() {
|
||||||
tmpPort=""
|
tmpPort=""
|
||||||
fi
|
fi
|
||||||
if [[ "$tmpPort" != "" ]]; then
|
if [[ "$tmpPort" != "" ]]; then
|
||||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
|
||||||
fi
|
fi
|
||||||
echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
|
echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
|
||||||
echo
|
echo
|
||||||
elif [ ! -z "$serverFqdn" ]; then
|
elif [ ! -z "$serverFqdn" ]; then
|
||||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}"
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $serverFqdn${GREEN_DARK} to login into ${productName} server${NC}"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
|
echo -e "\033[44;32;1m${productName} is installed successfully!${NC}"
|
||||||
echo
|
echo
|
||||||
else # Only install client
|
else # Only install client
|
||||||
install_bin
|
install_bin
|
||||||
install_config
|
install_config
|
||||||
echo
|
echo
|
||||||
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
|
echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch ~/.taos_history
|
touch ~/.${historyFile}
|
||||||
|
rm -rf $(tar -tf ${tarName} | grep -v "^\./$")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## ==============================Main program starts from here============================
|
## ==============================Main program starts from here============================
|
||||||
serverFqdn=$(hostname)
|
serverFqdn=$(hostname)
|
||||||
if [ "$verType" == "server" ]; then
|
if [ "$verType" == "server" ]; then
|
||||||
# Install server and client
|
# Install server and client
|
||||||
install_TDengine
|
if [ -x ${bin_dir}/${serverName} ]; then
|
||||||
|
update_flag=1
|
||||||
|
updateProduct
|
||||||
|
else
|
||||||
|
installProduct
|
||||||
|
fi
|
||||||
elif [ "$verType" == "client" ]; then
|
elif [ "$verType" == "client" ]; then
|
||||||
interactiveFqdn=no
|
interactiveFqdn=no
|
||||||
# Only install client
|
# Only install client
|
||||||
install_TDengine client
|
if [ -x ${bin_dir}/${clientName} ]; then
|
||||||
|
update_flag=1
|
||||||
|
updateProduct client
|
||||||
|
else
|
||||||
|
installProduct client
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "please input correct verType"
|
echo "please input correct verType"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -121,7 +121,7 @@ struct SAppInstInfo {
|
||||||
SCorEpSet mgmtEp;
|
SCorEpSet mgmtEp;
|
||||||
SInstanceSummary summary;
|
SInstanceSummary summary;
|
||||||
SList* pConnList; // STscObj linked list
|
SList* pConnList; // STscObj linked list
|
||||||
int64_t clusterId;
|
uint64_t clusterId;
|
||||||
void* pTransporter;
|
void* pTransporter;
|
||||||
SAppHbMgr* pAppHbMgr;
|
SAppHbMgr* pAppHbMgr;
|
||||||
};
|
};
|
||||||
|
@ -286,6 +286,8 @@ void initMsgHandleFp();
|
||||||
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||||
uint16_t port, int connType);
|
uint16_t port, int connType);
|
||||||
|
|
||||||
|
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen);
|
||||||
|
|
||||||
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
||||||
|
|
||||||
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList);
|
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList);
|
||||||
|
|
|
@ -565,10 +565,32 @@ const char *taos_get_server_info(TAOS *taos) {
|
||||||
|
|
||||||
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
|
||||||
if (taos == NULL || sql == NULL) {
|
if (taos == NULL || sql == NULL) {
|
||||||
// todo directly call fp
|
fp(param, NULL, TSDB_CODE_INVALID_PARA);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_query_l(taos, sql, (int32_t)strlen(sql));
|
SRequestObj* pRequest = NULL;
|
||||||
|
int32_t retryNum = 0;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
size_t sqlLen = strlen(sql);
|
||||||
|
|
||||||
|
while (retryNum++ < REQUEST_MAX_TRY_TIMES) {
|
||||||
|
pRequest = launchQuery(taos, sql, sqlLen);
|
||||||
|
if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = refreshMeta(taos, pRequest);
|
||||||
|
if (code) {
|
||||||
|
pRequest->code = code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyRequest(pRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp(param, pRequest, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
|
|
|
@ -125,10 +125,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
|
|
||||||
if (usedbRsp.vgVersion >= 0) {
|
if (usedbRsp.vgVersion >= 0) {
|
||||||
int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
uint64_t clusterId = pRequest->pTscObj->pAppInfo->clusterId;
|
||||||
|
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
|
||||||
if (code1 != TSDB_CODE_SUCCESS) {
|
if (code1 != TSDB_CODE_SUCCESS) {
|
||||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
|
tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId, tstrerror(code1));
|
||||||
tstrerror(code1));
|
|
||||||
} else {
|
} else {
|
||||||
catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid);
|
catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
|
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
|
||||||
taosMemoryFreeClear(output.dbVgroup);
|
taosMemoryFreeClear(output.dbVgroup);
|
||||||
|
|
||||||
tscError("failed to build use db output since %s", terrstr());
|
tscError("0x%" PRIx64" failed to build use db output since %s", pRequest->requestId, terrstr());
|
||||||
} else if (output.dbVgroup) {
|
} else if (output.dbVgroup) {
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
int32_t tInitSubmitMsgIter(SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||||
if (pMsg == NULL) {
|
if (pMsg == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -102,7 +102,7 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tPrintFixedSchemaSubmitReq(const SSubmitReq *pReq, STSchema *pTschema) {
|
int32_t tPrintFixedSchemaSubmitReq(SSubmitReq *pReq, STSchema *pTschema) {
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
if (tInitSubmitMsgIter(pReq, &msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pReq, &msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -113,6 +113,8 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
|
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
|
||||||
SRpcMsg rsp = {.info = pMsg->info};
|
SRpcMsg rsp = {.info = pMsg->info};
|
||||||
|
|
||||||
|
vnodePreprocessReq(pVnode->pImpl, pMsg);
|
||||||
|
|
||||||
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pMsg, false);
|
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pMsg, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
||||||
dTrace("msg:%p, is redirect since not leader, vgId:%d ", pMsg, pVnode->vgId);
|
dTrace("msg:%p, is redirect since not leader, vgId:%d ", pMsg, pVnode->vgId);
|
||||||
|
|
|
@ -51,7 +51,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
||||||
void vnodeDestroy(const char *path, STfs *pTfs);
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||||
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||||
void vnodeClose(SVnode *pVnode);
|
void vnodeClose(SVnode *pVnode);
|
||||||
int32_t vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version);
|
int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
||||||
int32_t vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
|
@ -177,7 +177,7 @@ struct SMetaEntry {
|
||||||
int64_t version;
|
int64_t version;
|
||||||
int8_t type;
|
int8_t type;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
const char *name;
|
char *name;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
|
@ -187,7 +187,7 @@ struct SMetaEntry {
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
int32_t ttlDays;
|
int32_t ttlDays;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
const uint8_t *pTags;
|
uint8_t *pTags;
|
||||||
} ctbEntry;
|
} ctbEntry;
|
||||||
struct {
|
struct {
|
||||||
int64_t ctime;
|
int64_t ctime;
|
||||||
|
|
|
@ -104,7 +104,7 @@ int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeep
|
||||||
int tsdbClose(STsdb** pTsdb);
|
int tsdbClose(STsdb** pTsdb);
|
||||||
int tsdbBegin(STsdb* pTsdb);
|
int tsdbBegin(STsdb* pTsdb);
|
||||||
int tsdbCommit(STsdb* pTsdb);
|
int tsdbCommit(STsdb* pTsdb);
|
||||||
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, const SSubmitReq* pMsg);
|
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq* pMsg);
|
||||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||||
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
||||||
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
|
|
|
@ -165,7 +165,9 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
||||||
|
|
||||||
tDecoderInit(&dc, pData, nData);
|
oStbEntry.pBuf = taosMemoryMalloc(nData);
|
||||||
|
memcpy(oStbEntry.pBuf, pData, nData);
|
||||||
|
tDecoderInit(&dc, oStbEntry.pBuf, nData);
|
||||||
metaDecodeEntry(&dc, &oStbEntry);
|
metaDecodeEntry(&dc, &oStbEntry);
|
||||||
|
|
||||||
nStbEntry.version = version;
|
nStbEntry.version = version;
|
||||||
|
@ -193,6 +195,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
// update uid index
|
// update uid index
|
||||||
tdbTbcUpsert(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &version, sizeof(version), 0);
|
tdbTbcUpsert(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &version, sizeof(version), 0);
|
||||||
|
|
||||||
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
@ -220,9 +223,6 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
||||||
terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
|
terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
pReq->uid = tGenIdPI64();
|
|
||||||
pReq->ctime = taosGetTimestampMs();
|
|
||||||
}
|
}
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
|
@ -420,7 +420,9 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
|
|
||||||
// get table entry
|
// get table entry
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
tDecoderInit(&dc, pData, nData);
|
entry.pBuf = taosMemoryMalloc(nData);
|
||||||
|
memcpy(entry.pBuf, pData, nData);
|
||||||
|
tDecoderInit(&dc, entry.pBuf, nData);
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
ASSERT(ret == 0);
|
ASSERT(ret == 0);
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
|
||||||
if (tDecodeIsEnd(&dc)) break;
|
if (tDecodeIsEnd(&dc)) break;
|
||||||
|
|
||||||
// decode row
|
// decode row
|
||||||
if (tDecodeBinary(&dc, (const uint8_t **)&tRow.pRow, &tRow.szRow) < 0) {
|
if (tDecodeBinary(&dc, (uint8_t **)&tRow.pRow, &tRow.szRow) < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ static FORCE_INLINE int32_t tsdbEncodeRow(SEncoder *pEncoder, const STsdbRow *pR
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tsdbDecodeRow(SDecoder *pDecoder, STsdbRow *pRow) {
|
static FORCE_INLINE int32_t tsdbDecodeRow(SDecoder *pDecoder, STsdbRow *pRow) {
|
||||||
if (tDecodeI64(pDecoder, &pRow->version) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pRow->version) < 0) return -1;
|
||||||
if (tDecodeBinary(pDecoder, (const uint8_t **)&pRow->pRow, &pRow->szRow) < 0) return -1;
|
if (tDecodeBinary(pDecoder, (uint8_t **)&pRow->pRow, &pRow->szRow) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ static FORCE_INLINE int tsdbCheckRowRange(STsdb *pTsdb, tb_uid_t uid, STSRow *ro
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, const SSubmitReq *pMsg) {
|
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
||||||
ASSERT(pMsg != NULL);
|
ASSERT(pMsg != NULL);
|
||||||
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
|
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
|
@ -150,7 +150,6 @@ int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, const SSubmitReq *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
||||||
|
|
|
@ -24,26 +24,62 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
static int vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
||||||
|
|
||||||
int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version) {
|
int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
#if 0
|
SDecoder dc = {0};
|
||||||
SRpcMsg *pMsg;
|
|
||||||
SRpcMsg *pRpc;
|
|
||||||
|
|
||||||
*version = pVnode->state.processed;
|
switch (pMsg->msgType) {
|
||||||
for (int i = 0; i < taosArrayGetSize(pMsgs); i++) {
|
case TDMT_VND_CREATE_TABLE: {
|
||||||
pMsg = *(SRpcMsg **)taosArrayGet(pMsgs, i);
|
int64_t ctime = taosGetTimestampMs();
|
||||||
pRpc = pMsg;
|
int32_t nReqs;
|
||||||
|
|
||||||
// set request version
|
tDecoderInit(&dc, (uint8_t *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead));
|
||||||
if (walWrite(pVnode->pWal, pVnode->state.processed++, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) {
|
tStartDecode(&dc);
|
||||||
vError("vnode:%d write wal error since %s", TD_VID(pVnode), terrstr());
|
|
||||||
return -1;
|
tDecodeI32v(&dc, &nReqs);
|
||||||
|
for (int32_t iReq = 0; iReq < nReqs; iReq++) {
|
||||||
|
tb_uid_t uid = tGenIdPI64();
|
||||||
|
tStartDecode(&dc);
|
||||||
|
|
||||||
|
tDecodeI32v(&dc, NULL);
|
||||||
|
*(int64_t *)(dc.data + dc.pos) = uid;
|
||||||
|
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||||
|
|
||||||
|
tEndDecode(&dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&dc);
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
} break;
|
||||||
|
case TDMT_VND_SUBMIT: {
|
||||||
|
SSubmitMsgIter msgIter = {0};
|
||||||
|
SSubmitReq *pSubmitReq = (SSubmitReq *)pMsg->pCont;
|
||||||
|
SSubmitBlk *pBlock = NULL;
|
||||||
|
int64_t ctime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
tInitSubmitMsgIter(pSubmitReq, &msgIter);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
|
if (pBlock == NULL) break;
|
||||||
|
|
||||||
|
if (msgIter.schemaLen > 0) {
|
||||||
|
tDecoderInit(&dc, pBlock->data, msgIter.schemaLen);
|
||||||
|
tStartDecode(&dc);
|
||||||
|
|
||||||
|
tDecodeI32v(&dc, NULL);
|
||||||
|
*(int64_t *)(dc.data + dc.pos) = tGenIdPI64();
|
||||||
|
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||||
|
|
||||||
|
tEndDecode(&dc);
|
||||||
|
tDecoderClear(&dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
walFsync(pVnode->pWal, false);
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +711,7 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0;;) {
|
for (;;) {
|
||||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
if (pBlock == NULL) break;
|
if (pBlock == NULL) break;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,17 @@ enum {
|
||||||
CTG_ACT_MAX
|
CTG_ACT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CTG_TASK_GET_QNODE = 0,
|
||||||
|
CTG_TASK_GET_DB_VGROUP,
|
||||||
|
CTG_TASK_GET_DB_CFG,
|
||||||
|
CTG_TASK_GET_TB_META,
|
||||||
|
CTG_TASK_GET_TB_HASH,
|
||||||
|
CTG_TASK_GET_INDEX,
|
||||||
|
CTG_TASK_GET_UDF,
|
||||||
|
CTG_TASK_GET_USER,
|
||||||
|
} CTG_TASK_TYPE;
|
||||||
|
|
||||||
typedef struct SCtgDebug {
|
typedef struct SCtgDebug {
|
||||||
bool lockEnable;
|
bool lockEnable;
|
||||||
bool cacheEnable;
|
bool cacheEnable;
|
||||||
|
@ -66,6 +77,43 @@ typedef struct SCtgDebug {
|
||||||
uint32_t showCachePeriodSec;
|
uint32_t showCachePeriodSec;
|
||||||
} SCtgDebug;
|
} SCtgDebug;
|
||||||
|
|
||||||
|
typedef struct SCtgTbCacheInfo {
|
||||||
|
bool inCache;
|
||||||
|
uint64_t dbId;
|
||||||
|
uint64_t suid;
|
||||||
|
int32_t tbType;
|
||||||
|
} SCtgTbCacheInfo;
|
||||||
|
|
||||||
|
typedef struct SCtgTbMetaCtx {
|
||||||
|
SCtgTbCacheInfo tbInfo;
|
||||||
|
SName* pName;
|
||||||
|
int32_t flag;
|
||||||
|
} SCtgTbMetaCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgDbVgCtx {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
} SCtgDbVgCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgDbCfgCtx {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
} SCtgDbCfgCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgTbHashCtx {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
SName* pName;
|
||||||
|
} SCtgTbHashCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgIndexCtx {
|
||||||
|
char indexFName[TSDB_INDEX_FNAME_LEN];
|
||||||
|
} SCtgIndexCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgUdfCtx {
|
||||||
|
char udfName[TSDB_FUNC_NAME_LEN];
|
||||||
|
} SCtgUdfCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgUserCtx {
|
||||||
|
SUserAuthInfo user;
|
||||||
|
} SCtgUserCtx;
|
||||||
|
|
||||||
typedef struct SCtgTbMetaCache {
|
typedef struct SCtgTbMetaCache {
|
||||||
SRWLatch stbLock;
|
SRWLatch stbLock;
|
||||||
|
@ -113,6 +161,55 @@ typedef struct SCatalog {
|
||||||
SCtgRentMgmt stbRent;
|
SCtgRentMgmt stbRent;
|
||||||
} SCatalog;
|
} SCatalog;
|
||||||
|
|
||||||
|
typedef struct SCtgJob {
|
||||||
|
int64_t refId;
|
||||||
|
SArray* pTasks;
|
||||||
|
int32_t taskDone;
|
||||||
|
SMetaData jobRes;
|
||||||
|
int32_t rspCode;
|
||||||
|
|
||||||
|
uint64_t queryId;
|
||||||
|
SCatalog* pCtg;
|
||||||
|
void* pTrans;
|
||||||
|
const SEpSet* pMgmtEps;
|
||||||
|
void* userParam;
|
||||||
|
catalogCallback userFp;
|
||||||
|
int32_t tbMetaNum;
|
||||||
|
int32_t tbHashNum;
|
||||||
|
int32_t dbVgNum;
|
||||||
|
int32_t udfNum;
|
||||||
|
int32_t qnodeNum;
|
||||||
|
int32_t dbCfgNum;
|
||||||
|
int32_t indexNum;
|
||||||
|
int32_t userNum;
|
||||||
|
} SCtgJob;
|
||||||
|
|
||||||
|
typedef struct SCtgMsgCtx {
|
||||||
|
int32_t reqType;
|
||||||
|
void* lastOut;
|
||||||
|
void* out;
|
||||||
|
char* target;
|
||||||
|
} SCtgMsgCtx;
|
||||||
|
|
||||||
|
typedef struct SCtgTask {
|
||||||
|
CTG_TASK_TYPE type;
|
||||||
|
int32_t taskId;
|
||||||
|
SCtgJob *pJob;
|
||||||
|
void* taskCtx;
|
||||||
|
SCtgMsgCtx msgCtx;
|
||||||
|
void* res;
|
||||||
|
} SCtgTask;
|
||||||
|
|
||||||
|
typedef int32_t (*ctgLanchTaskFp)(SCtgTask*);
|
||||||
|
typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTask*, int32_t, const SDataBuf *, int32_t);
|
||||||
|
typedef int32_t (*ctgDumpTaskResFp)(SCtgTask*);
|
||||||
|
|
||||||
|
typedef struct SCtgAsyncFps {
|
||||||
|
ctgLanchTaskFp launchFp;
|
||||||
|
ctgHandleTaskMsgRspFp handleRspFp;
|
||||||
|
ctgDumpTaskResFp dumpResFp;
|
||||||
|
} SCtgAsyncFps;
|
||||||
|
|
||||||
typedef struct SCtgApiStat {
|
typedef struct SCtgApiStat {
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -214,6 +311,7 @@ typedef struct SCtgQueue {
|
||||||
|
|
||||||
typedef struct SCatalogMgmt {
|
typedef struct SCatalogMgmt {
|
||||||
bool exit;
|
bool exit;
|
||||||
|
int32_t jobPool;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
SCtgQueue queue;
|
SCtgQueue queue;
|
||||||
TdThread updateThread;
|
TdThread updateThread;
|
||||||
|
@ -327,10 +425,80 @@ typedef struct SCtgAction {
|
||||||
#define CTG_API_LEAVE(c) do { int32_t __code = c; CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); CTG_RET(__code); } while (0)
|
#define CTG_API_LEAVE(c) do { int32_t __code = c; CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); CTG_RET(__code); } while (0)
|
||||||
#define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0)
|
#define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0)
|
||||||
|
|
||||||
|
#define CTG_PARAMS SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps
|
||||||
|
#define CTG_PARAMS_LIST() pCtg, pTrans, pMgmtEps
|
||||||
|
|
||||||
extern void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p);
|
void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p);
|
||||||
extern void ctgdShowClusterCache(SCatalog* pCtg);
|
void ctgdShowClusterCache(SCatalog* pCtg);
|
||||||
extern int32_t ctgdShowCacheInfo(void);
|
int32_t ctgdShowCacheInfo(void);
|
||||||
|
|
||||||
|
int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq);
|
||||||
|
int32_t ctgGetTbMetaFromCache(CTG_PARAMS, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||||
|
|
||||||
|
int32_t ctgActUpdateVg(SCtgMetaAction *action);
|
||||||
|
int32_t ctgActUpdateTb(SCtgMetaAction *action);
|
||||||
|
int32_t ctgActRemoveDB(SCtgMetaAction *action);
|
||||||
|
int32_t ctgActRemoveStb(SCtgMetaAction *action);
|
||||||
|
int32_t ctgActRemoveTb(SCtgMetaAction *action);
|
||||||
|
int32_t ctgActUpdateUser(SCtgMetaAction *action);
|
||||||
|
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache);
|
||||||
|
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache);
|
||||||
|
void ctgReleaseVgInfo(SCtgDBCache *dbCache);
|
||||||
|
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache);
|
||||||
|
int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist);
|
||||||
|
int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||||
|
int32_t ctgReadTbSverFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *sver, int32_t *tbType, uint64_t *suid, char *stbName);
|
||||||
|
int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass);
|
||||||
|
int32_t ctgPutRmDBToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId);
|
||||||
|
int32_t ctgPutRmStbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq);
|
||||||
|
int32_t ctgPutRmTbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq);
|
||||||
|
int32_t ctgPutUpdateVgToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq);
|
||||||
|
int32_t ctgPutUpdateTbToQueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq);
|
||||||
|
int32_t ctgPutUpdateUserToQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq);
|
||||||
|
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type);
|
||||||
|
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size);
|
||||||
|
int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size);
|
||||||
|
int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq);
|
||||||
|
int32_t ctgStartUpdateThread();
|
||||||
|
int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target);
|
||||||
|
int32_t ctgGetDBVgInfoFromMnode(CTG_PARAMS, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetQnodeListFromMnode(CTG_PARAMS, SArray *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetDBCfgFromMnode(CTG_PARAMS, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetIndexInfoFromMnode(CTG_PARAMS, const char *indexName, SIndexInfo *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetUdfInfoFromMnode(CTG_PARAMS, const char *funcName, SFuncInfo *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetUserDbAuthFromMnode(CTG_PARAMS, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetTbMetaFromMnodeImpl(CTG_PARAMS, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetTbMetaFromMnode(CTG_PARAMS, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask);
|
||||||
|
int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask);
|
||||||
|
|
||||||
|
int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param);
|
||||||
|
int32_t ctgLaunchJob(SCtgJob *pJob);
|
||||||
|
int32_t ctgMakeAsyncRes(SCtgJob *pJob);
|
||||||
|
|
||||||
|
int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst);
|
||||||
|
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput);
|
||||||
|
int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList);
|
||||||
|
void ctgFreeJob(void* job);
|
||||||
|
void ctgFreeHandle(SCatalog* pCtg);
|
||||||
|
void ctgFreeVgInfo(SDBVgInfo *vgInfo);
|
||||||
|
int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup);
|
||||||
|
void ctgResetTbMetaTask(SCtgTask* pTask);
|
||||||
|
void ctgFreeDbCache(SCtgDBCache *dbCache);
|
||||||
|
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2);
|
||||||
|
int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2);
|
||||||
|
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
|
||||||
|
int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2);
|
||||||
|
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
||||||
|
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
||||||
|
|
||||||
|
|
||||||
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
|
extern SCtgDebug gCTGDebug;
|
||||||
|
extern SCtgAsyncFps gCtgAsyncFps[];
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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_CATALOG_REMOTE_H_
|
||||||
|
#define _TD_CATALOG_REMOTE_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct SCtgTaskCallbackParam {
|
||||||
|
uint64_t queryId;
|
||||||
|
int64_t refId;
|
||||||
|
uint64_t taskId;
|
||||||
|
int32_t reqType;
|
||||||
|
} SCtgTaskCallbackParam;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_CATALOG_REMOTE_H_*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,577 @@
|
||||||
|
/*
|
||||||
|
* 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 "trpc.h"
|
||||||
|
#include "query.h"
|
||||||
|
#include "tname.h"
|
||||||
|
#include "catalogInt.h"
|
||||||
|
#include "systable.h"
|
||||||
|
#include "ctgRemote.h"
|
||||||
|
#include "tref.h"
|
||||||
|
|
||||||
|
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
switch (reqType) {
|
||||||
|
case TDMT_MND_QNODE_LIST: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for qnode list, error:%s", tstrerror(rspCode));
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process qnode list rsp failed, error:%s", tstrerror(rspCode));
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got qnode list from mnode, listNum:%d", (int32_t)taosArrayGetSize(out));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_USE_DB: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for use db, error:%s, dbFName:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process use db rsp failed, error:%s, dbFName:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got db vgInfo from mnode, dbFName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_GET_DB_CFG: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for get db cfg, error:%s, db:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process get db cfg rsp failed, error:%s, db:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got db cfg from mnode, dbFName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_GET_INDEX: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for get index, error:%s, indexName:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process get index rsp failed, error:%s, indexName:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got index from mnode, indexName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_RETRIEVE_FUNC: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for get udf, error:%s, funcName:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process get udf rsp failed, error:%s, funcName:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got udf from mnode, funcName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_GET_USER_AUTH: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("error rsp for get user auth, error:%s, user:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process get user auth rsp failed, error:%s, user:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got user auth from mnode, user:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_TABLE_META: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
if (CTG_TABLE_NOT_EXIST(rspCode)) {
|
||||||
|
SET_META_TYPE_NULL(((STableMetaOutput*)out)->metaType);
|
||||||
|
qDebug("stablemeta not exist in mnode, tbFName:%s", target);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
qError("error rsp for stablemeta from mnode, error:%s, tbFName:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process mnode stablemeta rsp failed, error:%s, tbFName:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got table meta from mnode, tbFName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_VND_TABLE_META: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
if (CTG_TABLE_NOT_EXIST(rspCode)) {
|
||||||
|
SET_META_TYPE_NULL(((STableMetaOutput*)out)->metaType);
|
||||||
|
qDebug("tablemeta not exist in vnode, tbFName:%s", target);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
qError("error rsp for table meta from vnode, code:%s, tbFName:%s", tstrerror(rspCode), target);
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize);
|
||||||
|
if (code) {
|
||||||
|
qError("Process vnode tablemeta rsp failed, code:%s, tbFName:%s", tstrerror(code), target);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("Got table meta from vnode, tbFName:%s", target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgHandleMsgCallback(void *param, const SDataBuf *pMsg, int32_t rspCode) {
|
||||||
|
SCtgTaskCallbackParam* cbParam = (SCtgTaskCallbackParam*)param;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
SCtgJob* pJob = taosAcquireRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||||
|
if (NULL == pJob) {
|
||||||
|
qDebug("job refId %" PRIx64 " already dropped", cbParam->refId);
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCtgTask *pTask = taosArrayGet(pJob->pTasks, cbParam->taskId);
|
||||||
|
|
||||||
|
qDebug("QID:%" PRIx64 " task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
||||||
|
|
||||||
|
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
if (pJob) {
|
||||||
|
taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(param);
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
if (NULL == msgSendInfo) {
|
||||||
|
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||||
|
CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCtgTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam));
|
||||||
|
if (NULL == param) {
|
||||||
|
qError("calloc %d failed", (int32_t)sizeof(SCtgTaskCallbackParam));
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
param->reqType = msgType;
|
||||||
|
param->queryId = pTask->pJob->queryId;
|
||||||
|
param->refId = pTask->pJob->refId;
|
||||||
|
param->taskId = pTask->taskId;
|
||||||
|
|
||||||
|
msgSendInfo->param = param;
|
||||||
|
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||||
|
|
||||||
|
*pMsgSendInfo = msgSendInfo;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
taosMemoryFree(param);
|
||||||
|
taosMemoryFree(msgSendInfo);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgAsyncSendMsg(CTG_PARAMS, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
|
CTG_ERR_JRET(ctgMakeMsgSendInfo(pTask, msgType, &pMsgSendInfo));
|
||||||
|
|
||||||
|
pMsgSendInfo->msgInfo.pData = msg;
|
||||||
|
pMsgSendInfo->msgInfo.len = msgSize;
|
||||||
|
pMsgSendInfo->msgInfo.handle = NULL;
|
||||||
|
pMsgSendInfo->msgType = msgType;
|
||||||
|
|
||||||
|
int64_t transporterId = 0;
|
||||||
|
code = asyncSendMsgToServer(pTrans, (SEpSet*)pMgmtEps, &transporterId, pMsgSendInfo);
|
||||||
|
if (code) {
|
||||||
|
ctgError("asyncSendMsgToSever failed, error: %s", tstrerror(code));
|
||||||
|
CTG_ERR_JRET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgDebug("req msg sent, reqId:%" PRIx64 ", msg type:%d, %s", pTask->pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
if (pMsgSendInfo) {
|
||||||
|
taosMemoryFreeClear(pMsgSendInfo->param);
|
||||||
|
taosMemoryFreeClear(pMsgSendInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetQnodeListFromMnode(CTG_PARAMS, SArray *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_QNODE_LIST;
|
||||||
|
|
||||||
|
ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pMgmtEps->inUse);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](NULL, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build qnode list msg failed, error:%s", tstrerror(code));
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, NULL));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetDBVgInfoFromMnode(CTG_PARAMS, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_USE_DB;
|
||||||
|
|
||||||
|
ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](input, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build use db msg failed, code:%x, db:%s", code, input->db);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(SUseDbOutput));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, input->db));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetDBCfgFromMnode(CTG_PARAMS, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_GET_DB_CFG;
|
||||||
|
|
||||||
|
ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)dbFName, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build get db cfg msg failed, code:%x, db:%s", code, dbFName);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(SDbCfgInfo));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = TDMT_MND_GET_DB_CFG,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)dbFName));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetIndexInfoFromMnode(CTG_PARAMS, const char *indexName, SIndexInfo *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_GET_INDEX;
|
||||||
|
|
||||||
|
ctgDebug("try to get index from mnode, indexName:%s", indexName);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)indexName, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build get index msg failed, code:%x, db:%s", code, indexName);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(SIndexInfo));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)indexName));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetUdfInfoFromMnode(CTG_PARAMS, const char *funcName, SFuncInfo *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_RETRIEVE_FUNC;
|
||||||
|
|
||||||
|
ctgDebug("try to get udf info from mnode, funcName:%s", funcName);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)funcName, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build get udf msg failed, code:%x, db:%s", code, funcName);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(SFuncInfo));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)funcName));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetUserDbAuthFromMnode(CTG_PARAMS, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask) {
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_GET_USER_AUTH;
|
||||||
|
|
||||||
|
ctgDebug("try to get user auth from mnode, user:%s", user);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)user, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build get user auth msg failed, code:%x, db:%s", code, user);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(SGetUserAuthRsp));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)user));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetTbMetaFromMnodeImpl(CTG_PARAMS, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask) {
|
||||||
|
SBuildTableMetaInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName};
|
||||||
|
char *msg = NULL;
|
||||||
|
SEpSet *pVnodeEpSet = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
int32_t reqType = TDMT_MND_TABLE_META;
|
||||||
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
sprintf(tbFName, "%s.%s", dbFName, tbName);
|
||||||
|
|
||||||
|
ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName);
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build mnode stablemeta msg failed, code:%x", code);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(STableMetaOutput));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, (SEpSet*)pMgmtEps, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, tbFName));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetTbMetaFromMnode(CTG_PARAMS, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask) {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
|
||||||
|
return ctgGetTbMetaFromMnodeImpl(CTG_PARAMS_LIST(), dbFName, (char *)pTableName->tname, out, pTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask) {
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(pTableName, dbFName);
|
||||||
|
int32_t reqType = TDMT_VND_TABLE_META;
|
||||||
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
sprintf(tbFName, "%s.%s", dbFName, pTableName->tname);
|
||||||
|
|
||||||
|
ctgDebug("try to get table meta from vnode, vgId:%d, tbFName:%s", vgroupInfo->vgId, tbFName);
|
||||||
|
|
||||||
|
SBuildTableMetaInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)};
|
||||||
|
char *msg = NULL;
|
||||||
|
int32_t msgLen = 0;
|
||||||
|
|
||||||
|
int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen);
|
||||||
|
if (code) {
|
||||||
|
ctgError("Build vnode tablemeta msg failed, code:%x, tbFName:%s", code, tbFName);
|
||||||
|
CTG_ERR_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask) {
|
||||||
|
void* pOut = taosMemoryCalloc(1, sizeof(STableMetaOutput));
|
||||||
|
if (NULL == pOut) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(CTG_PARAMS_LIST(), pTask, reqType, msg, msgLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {
|
||||||
|
.msgType = reqType,
|
||||||
|
.pCont = msg,
|
||||||
|
.contLen = msgLen,
|
||||||
|
};
|
||||||
|
|
||||||
|
SRpcMsg rpcRsp = {0};
|
||||||
|
rpcSendRecv(pTrans, &vgroupInfo->epSet, &rpcMsg, &rpcRsp);
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, tbFName));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,577 @@
|
||||||
|
/*
|
||||||
|
* 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 "trpc.h"
|
||||||
|
#include "query.h"
|
||||||
|
#include "tname.h"
|
||||||
|
#include "catalogInt.h"
|
||||||
|
#include "systable.h"
|
||||||
|
|
||||||
|
void ctgFreeSMetaData(SMetaData* pData) {
|
||||||
|
taosArrayDestroy(pData->pTableMeta);
|
||||||
|
pData->pTableMeta = NULL;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pData->pDbVgroup); ++i) {
|
||||||
|
SArray** pArray = taosArrayGet(pData->pDbVgroup, i);
|
||||||
|
taosArrayDestroy(*pArray);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pData->pDbVgroup);
|
||||||
|
pData->pDbVgroup = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pTableHash);
|
||||||
|
pData->pTableHash = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pUdfList);
|
||||||
|
pData->pUdfList = NULL;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pData->pDbCfg); ++i) {
|
||||||
|
SDbCfgInfo* pInfo = taosArrayGet(pData->pDbCfg, i);
|
||||||
|
taosArrayDestroy(pInfo->pRetensions);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pData->pDbCfg);
|
||||||
|
pData->pDbCfg = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pIndex);
|
||||||
|
pData->pIndex = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pUser);
|
||||||
|
pData->pUser = NULL;
|
||||||
|
|
||||||
|
taosArrayDestroy(pData->pQnodeList);
|
||||||
|
pData->pQnodeList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) {
|
||||||
|
taosHashCleanup(userCache->createdDbs);
|
||||||
|
taosHashCleanup(userCache->readDbs);
|
||||||
|
taosHashCleanup(userCache->writeDbs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
|
||||||
|
if (NULL == mgmt->slots) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < mgmt->slotNum; ++i) {
|
||||||
|
SCtgRentSlot *slot = &mgmt->slots[i];
|
||||||
|
if (slot->meta) {
|
||||||
|
taosArrayDestroy(slot->meta);
|
||||||
|
slot->meta = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(mgmt->slots);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ctgFreeTbMetaCache(SCtgTbMetaCache *cache) {
|
||||||
|
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
||||||
|
if (cache->stbCache) {
|
||||||
|
int32_t stblNum = taosHashGetSize(cache->stbCache);
|
||||||
|
taosHashCleanup(cache->stbCache);
|
||||||
|
cache->stbCache = NULL;
|
||||||
|
CTG_CACHE_STAT_SUB(stblNum, stblNum);
|
||||||
|
}
|
||||||
|
CTG_UNLOCK(CTG_WRITE, &cache->stbLock);
|
||||||
|
|
||||||
|
CTG_LOCK(CTG_WRITE, &cache->metaLock);
|
||||||
|
if (cache->metaCache) {
|
||||||
|
int32_t tblNum = taosHashGetSize(cache->metaCache);
|
||||||
|
taosHashCleanup(cache->metaCache);
|
||||||
|
cache->metaCache = NULL;
|
||||||
|
CTG_CACHE_STAT_SUB(tblNum, tblNum);
|
||||||
|
}
|
||||||
|
CTG_UNLOCK(CTG_WRITE, &cache->metaLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
|
||||||
|
if (NULL == vgInfo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vgInfo->vgHash) {
|
||||||
|
taosHashCleanup(vgInfo->vgHash);
|
||||||
|
vgInfo->vgHash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(vgInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeDbCache(SCtgDBCache *dbCache) {
|
||||||
|
if (NULL == dbCache) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_LOCK(CTG_WRITE, &dbCache->vgLock);
|
||||||
|
ctgFreeVgInfo (dbCache->vgInfo);
|
||||||
|
CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock);
|
||||||
|
|
||||||
|
ctgFreeTbMetaCache(&dbCache->tbCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ctgFreeHandle(SCatalog* pCtg) {
|
||||||
|
ctgFreeMetaRent(&pCtg->dbRent);
|
||||||
|
ctgFreeMetaRent(&pCtg->stbRent);
|
||||||
|
|
||||||
|
if (pCtg->dbCache) {
|
||||||
|
int32_t dbNum = taosHashGetSize(pCtg->dbCache);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pCtg->dbCache, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SCtgDBCache *dbCache = pIter;
|
||||||
|
|
||||||
|
atomic_store_8(&dbCache->deleted, 1);
|
||||||
|
|
||||||
|
ctgFreeDbCache(dbCache);
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pCtg->dbCache, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pCtg->dbCache);
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_SUB(dbNum, dbNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCtg->userCache) {
|
||||||
|
int32_t userNum = taosHashGetSize(pCtg->userCache);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pCtg->userCache, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SCtgUserAuth *userCache = pIter;
|
||||||
|
|
||||||
|
ctgFreeSCtgUserAuth(userCache);
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pCtg->userCache, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pCtg->userCache);
|
||||||
|
|
||||||
|
CTG_CACHE_STAT_SUB(userNum, userNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pCtg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) {
|
||||||
|
if (NULL == pOutput || NULL == pOutput->dbVgroup) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pOutput->dbVgroup->vgHash);
|
||||||
|
taosMemoryFreeClear(pOutput->dbVgroup);
|
||||||
|
taosMemoryFree(pOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
|
||||||
|
taosMemoryFreeClear(pCtx->target);
|
||||||
|
if (NULL == pCtx->out) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pCtx->reqType) {
|
||||||
|
case TDMT_MND_GET_DB_CFG: {
|
||||||
|
SDbCfgInfo* pOut = (SDbCfgInfo*)pCtx->out;
|
||||||
|
taosArrayDestroy(pOut->pRetensions);
|
||||||
|
taosMemoryFreeClear(pCtx->out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_USE_DB:{
|
||||||
|
SUseDbOutput* pOut = (SUseDbOutput*)pCtx->out;
|
||||||
|
ctgFreeSUseDbOutput(pOut);
|
||||||
|
pCtx->out = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_GET_INDEX: {
|
||||||
|
SIndexInfo* pOut = (SIndexInfo*)pCtx->out;
|
||||||
|
taosMemoryFreeClear(pCtx->out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_QNODE_LIST: {
|
||||||
|
SArray* pOut = (SArray*)pCtx->out;
|
||||||
|
taosArrayDestroy(pOut);
|
||||||
|
pCtx->out = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_VND_TABLE_META:
|
||||||
|
case TDMT_MND_TABLE_META: {
|
||||||
|
STableMetaOutput* pOut = (STableMetaOutput*)pCtx->out;
|
||||||
|
taosMemoryFree(pOut->tbMeta);
|
||||||
|
taosMemoryFreeClear(pCtx->out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_RETRIEVE_FUNC: {
|
||||||
|
SFuncInfo* pOut = (SFuncInfo*)pCtx->out;
|
||||||
|
taosMemoryFree(pOut->pCode);
|
||||||
|
taosMemoryFree(pOut->pComment);
|
||||||
|
taosMemoryFreeClear(pCtx->out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TDMT_MND_GET_USER_AUTH: {
|
||||||
|
SGetUserAuthRsp* pOut = (SGetUserAuthRsp*)pCtx->out;
|
||||||
|
taosHashCleanup(pOut->createdDbs);
|
||||||
|
taosHashCleanup(pOut->readDbs);
|
||||||
|
taosHashCleanup(pOut->writeDbs);
|
||||||
|
taosMemoryFreeClear(pCtx->out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qError("invalid reqType %d", pCtx->reqType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput) {
|
||||||
|
if (NULL == pOutput) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pOutput->tbMeta);
|
||||||
|
taosMemoryFree(pOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ctgResetTbMetaTask(SCtgTask* pTask) {
|
||||||
|
SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
memset(&taskCtx->tbInfo, 0, sizeof(taskCtx->tbInfo));
|
||||||
|
taskCtx->flag = CTG_FLAG_UNKNOWN_STB;
|
||||||
|
|
||||||
|
if (pTask->msgCtx.lastOut) {
|
||||||
|
ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut);
|
||||||
|
pTask->msgCtx.lastOut = NULL;
|
||||||
|
}
|
||||||
|
if (pTask->msgCtx.out) {
|
||||||
|
ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.out);
|
||||||
|
pTask->msgCtx.out = NULL;
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pTask->msgCtx.target);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeTask(SCtgTask* pTask) {
|
||||||
|
ctgFreeMsgCtx(&pTask->msgCtx);
|
||||||
|
|
||||||
|
switch (pTask->type) {
|
||||||
|
case CTG_TASK_GET_QNODE: {
|
||||||
|
taosArrayDestroy((SArray*)pTask->res);
|
||||||
|
pTask->res = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_TB_META: {
|
||||||
|
SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
taosMemoryFreeClear(taskCtx->pName);
|
||||||
|
if (pTask->msgCtx.lastOut) {
|
||||||
|
ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut);
|
||||||
|
pTask->msgCtx.lastOut = NULL;
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_DB_VGROUP: {
|
||||||
|
taosArrayDestroy((SArray*)pTask->res);
|
||||||
|
pTask->res = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_DB_CFG: {
|
||||||
|
if (pTask->res) {
|
||||||
|
taosArrayDestroy(((SDbCfgInfo*)pTask->res)->pRetensions);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_TB_HASH: {
|
||||||
|
SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx;
|
||||||
|
taosMemoryFreeClear(taskCtx->pName);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_INDEX: {
|
||||||
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_UDF: {
|
||||||
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CTG_TASK_GET_USER: {
|
||||||
|
taosMemoryFreeClear(pTask->taskCtx);
|
||||||
|
taosMemoryFreeClear(pTask->res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
qError("invalid task type %d", pTask->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeTasks(SArray* pArray) {
|
||||||
|
if (NULL == pArray) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t num = taosArrayGetSize(pArray);
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SCtgTask* pTask = taosArrayGet(pArray, i);
|
||||||
|
ctgFreeTask(pTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeJob(void* job) {
|
||||||
|
if (NULL == job) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCtgJob* pJob = (SCtgJob*)job;
|
||||||
|
|
||||||
|
int64_t rid = pJob->refId;
|
||||||
|
uint64_t qid = pJob->queryId;
|
||||||
|
|
||||||
|
ctgFreeTasks(pJob->pTasks);
|
||||||
|
|
||||||
|
ctgFreeSMetaData(&pJob->jobRes);
|
||||||
|
|
||||||
|
taosMemoryFree(job);
|
||||||
|
|
||||||
|
qDebug("QID:%" PRIx64 ", job %" PRIx64 " freed", qid, rid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target) {
|
||||||
|
ctgFreeMsgCtx(pCtx);
|
||||||
|
|
||||||
|
pCtx->reqType = reqType;
|
||||||
|
pCtx->out = out;
|
||||||
|
if (target) {
|
||||||
|
pCtx->target = strdup(target);
|
||||||
|
if (NULL == pCtx->target) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pCtx->target = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) {
|
||||||
|
switch (hashMethod) {
|
||||||
|
default:
|
||||||
|
*fp = MurmurHash3_32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList) {
|
||||||
|
SHashObj *vgroupHash = NULL;
|
||||||
|
SVgroupInfo *vgInfo = NULL;
|
||||||
|
SArray *vgList = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t vgNum = taosHashGetSize(vgHash);
|
||||||
|
|
||||||
|
vgList = taosArrayInit(vgNum, sizeof(SVgroupInfo));
|
||||||
|
if (NULL == vgList) {
|
||||||
|
ctgError("taosArrayInit failed, num:%d", vgNum);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(vgHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
vgInfo = pIter;
|
||||||
|
|
||||||
|
if (NULL == taosArrayPush(vgList, vgInfo)) {
|
||||||
|
ctgError("taosArrayPush failed, vgId:%d", vgInfo->vgId);
|
||||||
|
taosHashCancelIterate(vgHash, pIter);
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(vgHash, pIter);
|
||||||
|
vgInfo = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pList = vgList;
|
||||||
|
|
||||||
|
ctgDebug("Got vgList from cache, vgNum:%d", vgNum);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
if (vgList) {
|
||||||
|
taosArrayDestroy(vgList);
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
int32_t vgNum = taosHashGetSize(dbInfo->vgHash);
|
||||||
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
tNameGetFullDbName(pTableName, db);
|
||||||
|
|
||||||
|
if (vgNum <= 0) {
|
||||||
|
ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", db, vgNum);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
tableNameHashFp fp = NULL;
|
||||||
|
SVgroupInfo *vgInfo = NULL;
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp));
|
||||||
|
|
||||||
|
char tbFullName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
tNameExtractFullName(pTableName, tbFullName);
|
||||||
|
|
||||||
|
uint32_t hashValue = (*fp)(tbFullName, (uint32_t)strlen(tbFullName));
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
vgInfo = pIter;
|
||||||
|
if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) {
|
||||||
|
taosHashCancelIterate(dbInfo->vgHash, pIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(dbInfo->vgHash, pIter);
|
||||||
|
vgInfo = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == vgInfo) {
|
||||||
|
ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, taosHashGetSize(dbInfo->vgHash));
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pVgroup = *vgInfo;
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
|
||||||
|
if (*(uint64_t *)key1 < ((SSTableMetaVersion*)key2)->suid) {
|
||||||
|
return -1;
|
||||||
|
} else if (*(uint64_t *)key1 > ((SSTableMetaVersion*)key2)->suid) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) {
|
||||||
|
if (*(int64_t *)key1 < ((SDbVgVersion*)key2)->dbId) {
|
||||||
|
return -1;
|
||||||
|
} else if (*(int64_t *)key1 > ((SDbVgVersion*)key2)->dbId) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) {
|
||||||
|
if (((SSTableMetaVersion*)key1)->suid < ((SSTableMetaVersion*)key2)->suid) {
|
||||||
|
return -1;
|
||||||
|
} else if (((SSTableMetaVersion*)key1)->suid > ((SSTableMetaVersion*)key2)->suid) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) {
|
||||||
|
if (((SDbVgVersion*)key1)->dbId < ((SDbVgVersion*)key2)->dbId) {
|
||||||
|
return -1;
|
||||||
|
} else if (((SDbVgVersion*)key1)->dbId > ((SDbVgVersion*)key2)->dbId) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) {
|
||||||
|
*dst = taosMemoryMalloc(sizeof(SDBVgInfo));
|
||||||
|
if (NULL == *dst) {
|
||||||
|
qError("malloc %d failed", (int32_t)sizeof(SDBVgInfo));
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(*dst, src, sizeof(SDBVgInfo));
|
||||||
|
|
||||||
|
size_t hashSize = taosHashGetSize(src->vgHash);
|
||||||
|
(*dst)->vgHash = taosHashInit(hashSize, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||||
|
if (NULL == (*dst)->vgHash) {
|
||||||
|
qError("taosHashInit %d failed", (int32_t)hashSize);
|
||||||
|
taosMemoryFreeClear(*dst);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t *vgId = NULL;
|
||||||
|
void *pIter = taosHashIterate(src->vgHash, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
vgId = taosHashGetKey(pIter, NULL);
|
||||||
|
|
||||||
|
if (taosHashPut((*dst)->vgHash, (void *)vgId, sizeof(int32_t), pIter, sizeof(SVgroupInfo))) {
|
||||||
|
qError("taosHashPut failed, hashSize:%d", (int32_t)hashSize);
|
||||||
|
taosHashCancelIterate(src->vgHash, pIter);
|
||||||
|
taosHashCleanup((*dst)->vgHash);
|
||||||
|
taosMemoryFreeClear(*dst);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(src->vgHash, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) {
|
||||||
|
*pOutput = taosMemoryMalloc(sizeof(STableMetaOutput));
|
||||||
|
if (NULL == *pOutput) {
|
||||||
|
qError("malloc %d failed", (int32_t)sizeof(STableMetaOutput));
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(*pOutput, output, sizeof(STableMetaOutput));
|
||||||
|
|
||||||
|
if (output->tbMeta) {
|
||||||
|
int32_t metaSize = CTG_META_SIZE(output->tbMeta);
|
||||||
|
(*pOutput)->tbMeta = taosMemoryMalloc(metaSize);
|
||||||
|
if (NULL == (*pOutput)->tbMeta) {
|
||||||
|
qError("malloc %d failed", (int32_t)sizeof(STableMetaOutput));
|
||||||
|
taosMemoryFreeClear(*pOutput);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy((*pOutput)->tbMeta, output->tbMeta, metaSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,8 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
extern "C" int32_t ctgGetTableMetaFromCache(struct SCatalog *pCatalog, const SName *pTableName, STableMeta **pTableMeta,
|
|
||||||
bool *inCache, int32_t flag, uint64_t *dbId);
|
|
||||||
extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type);
|
extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type);
|
||||||
extern "C" int32_t ctgActUpdateTbl(SCtgMetaAction *action);
|
extern "C" int32_t ctgActUpdateTb(SCtgMetaAction *action);
|
||||||
extern "C" int32_t ctgdEnableDebug(char *option);
|
extern "C" int32_t ctgdEnableDebug(char *option);
|
||||||
extern "C" int32_t ctgdGetStatNum(char *option, void *res);
|
extern "C" int32_t ctgdGetStatNum(char *option, void *res);
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ void ctgTestSetRspCTableMeta();
|
||||||
void ctgTestSetRspSTableMeta();
|
void ctgTestSetRspSTableMeta();
|
||||||
void ctgTestSetRspMultiSTableMeta();
|
void ctgTestSetRspMultiSTableMeta();
|
||||||
|
|
||||||
extern "C" SCatalogMgmt gCtgMgmt;
|
//extern "C" SCatalogMgmt gCtgMgmt;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CTGT_RSP_VGINFO = 1,
|
CTGT_RSP_VGINFO = 1,
|
||||||
|
@ -859,8 +857,12 @@ void *ctgTestGetCtableMetaThread(void *param) {
|
||||||
strcpy(cn.dbname, "db1");
|
strcpy(cn.dbname, "db1");
|
||||||
strcpy(cn.tname, ctgTestCTablename);
|
strcpy(cn.tname, ctgTestCTablename);
|
||||||
|
|
||||||
|
SCtgTbMetaCtx ctx = {0};
|
||||||
|
ctx.pName = &cn;
|
||||||
|
ctx.flag = CTG_FLAG_UNKNOWN_STB;
|
||||||
|
|
||||||
while (!ctgTestStop) {
|
while (!ctgTestStop) {
|
||||||
code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &inCache, 0, NULL);
|
code = ctgReadTbMetaFromCache(pCtg, &ctx, &tbMeta);
|
||||||
if (code || !inCache) {
|
if (code || !inCache) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -899,7 +901,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
|
||||||
msg->output = output;
|
msg->output = output;
|
||||||
action.data = msg;
|
action.data = msg;
|
||||||
|
|
||||||
code = ctgActUpdateTbl(&action);
|
code = ctgActUpdateTb(&action);
|
||||||
if (code) {
|
if (code) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <executorimpl.h>
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
|
@ -1181,6 +1181,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
|
|
||||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
||||||
pInfo->invertible = allInvertible(pInfo->binfo.pCtx, numOfCols);
|
pInfo->invertible = allInvertible(pInfo->binfo.pCtx, numOfCols);
|
||||||
|
pInfo->invertible = false; // Todo(liuyao): Dependent TSDB API
|
||||||
|
|
||||||
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
||||||
|
|
|
@ -66,22 +66,18 @@ static bool isSpecificClassifyFunc(int32_t funcId, uint64_t classification) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getUdfInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc) {
|
static int32_t getUdfInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc) {
|
||||||
SFuncInfo* pInfo = NULL;
|
SFuncInfo funcInfo = {0};
|
||||||
int32_t code = catalogGetUdfInfo(pParam->pCtg, pParam->pRpc, pParam->pMgmtEps, pFunc->functionName, &pInfo);
|
int32_t code = catalogGetUdfInfo(pParam->pCtg, pParam->pRpc, pParam->pMgmtEps, pFunc->functionName, &funcInfo);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (NULL == pInfo) {
|
|
||||||
snprintf(pParam->pErrBuf, pParam->errBufLen, "Invalid function name: %s", pFunc->functionName);
|
|
||||||
return TSDB_CODE_FUNC_INVALID_FUNTION;
|
|
||||||
}
|
|
||||||
pFunc->funcType = FUNCTION_TYPE_UDF;
|
pFunc->funcType = FUNCTION_TYPE_UDF;
|
||||||
pFunc->funcId = TSDB_FUNC_TYPE_AGGREGATE == pInfo->funcType ? FUNC_AGGREGATE_UDF_ID : FUNC_SCALAR_UDF_ID;
|
pFunc->funcId = TSDB_FUNC_TYPE_AGGREGATE == funcInfo.funcType ? FUNC_AGGREGATE_UDF_ID : FUNC_SCALAR_UDF_ID;
|
||||||
pFunc->node.resType.type = pInfo->outputType;
|
pFunc->node.resType.type = funcInfo.outputType;
|
||||||
pFunc->node.resType.bytes = pInfo->outputLen;
|
pFunc->node.resType.bytes = funcInfo.outputLen;
|
||||||
pFunc->udfBufSize = pInfo->bufSize;
|
pFunc->udfBufSize = funcInfo.bufSize;
|
||||||
tFreeSFuncInfo(pInfo);
|
tFreeSFuncInfo(&funcInfo);
|
||||||
taosMemoryFree(pInfo);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,12 +72,20 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) {
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
if (tsProcPath == NULL) {
|
if (tsProcPath == NULL) {
|
||||||
path[0] = '.';
|
path[0] = '.';
|
||||||
|
#ifdef WINDOWS
|
||||||
|
GetModuleFileName(NULL, path, PATH_MAX);
|
||||||
|
taosDirName(path);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
strncpy(path, tsProcPath, strlen(tsProcPath));
|
strncpy(path, tsProcPath, strlen(tsProcPath));
|
||||||
taosDirName(path);
|
taosDirName(path);
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
if (strlen(path)==0) {
|
||||||
strcat(path, "udfd.exe");
|
strcat(path, "udfd.exe");
|
||||||
|
} else {
|
||||||
|
strcat(path, "\\udfd.exe");
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
strcat(path, "/udfd");
|
strcat(path, "/udfd");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -204,7 +204,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, const uint8_t* pNewVal, uint32_t bytes) {
|
auto setAlterTagFunc = [&](const char* pTbname, const char* pTagName, uint8_t* pNewVal, uint32_t bytes) {
|
||||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||||
expect.tbName = strdup(pTbname);
|
expect.tbName = strdup(pTbname);
|
||||||
expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
expect.action = TSDB_ALTER_TABLE_UPDATE_TAG_VAL;
|
||||||
|
@ -215,7 +215,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
expect.pTagVal = pNewVal;
|
expect.pTagVal = pNewVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, const char* pComment = nullptr) {
|
auto setAlterOptionsFunc = [&](const char* pTbname, int32_t ttl, char* pComment = nullptr) {
|
||||||
memset(&expect, 0, sizeof(SVAlterTbReq));
|
memset(&expect, 0, sizeof(SVAlterTbReq));
|
||||||
expect.tbName = strdup(pTbname);
|
expect.tbName = strdup(pTbname);
|
||||||
expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
expect.action = TSDB_ALTER_TABLE_UPDATE_OPTIONS;
|
||||||
|
@ -240,7 +240,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
void* pBuf = POINTER_SHIFT(pVgData->pData, sizeof(SMsgHead));
|
void* pBuf = POINTER_SHIFT(pVgData->pData, sizeof(SMsgHead));
|
||||||
SVAlterTbReq req = {0};
|
SVAlterTbReq req = {0};
|
||||||
SDecoder coder = {0};
|
SDecoder coder = {0};
|
||||||
tDecoderInit(&coder, (const uint8_t*)pBuf, pVgData->size);
|
tDecoderInit(&coder, (uint8_t*)pBuf, pVgData->size);
|
||||||
ASSERT_EQ(tDecodeSVAlterTbReq(&coder, &req), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(tDecodeSVAlterTbReq(&coder, &req), TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
ASSERT_EQ(std::string(req.tbName), std::string(expect.tbName));
|
ASSERT_EQ(std::string(req.tbName), std::string(expect.tbName));
|
||||||
|
@ -274,7 +274,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
setAlterOptionsFunc("t1", 10, nullptr);
|
setAlterOptionsFunc("t1", 10, nullptr);
|
||||||
run("ALTER TABLE t1 TTL 10");
|
run("ALTER TABLE t1 TTL 10");
|
||||||
|
|
||||||
setAlterOptionsFunc("t1", -1, "test");
|
setAlterOptionsFunc("t1", -1, (char*)"test");
|
||||||
run("ALTER TABLE t1 COMMENT 'test'");
|
run("ALTER TABLE t1 COMMENT 'test'");
|
||||||
|
|
||||||
setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT);
|
setAlterColFunc("t1", TSDB_ALTER_TABLE_ADD_COLUMN, "cc1", TSDB_DATA_TYPE_BIGINT);
|
||||||
|
@ -290,7 +290,7 @@ TEST_F(ParserInitialATest, alterTable) {
|
||||||
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
run("ALTER TABLE t1 RENAME COLUMN c1 cc1");
|
||||||
|
|
||||||
int32_t val = 10;
|
int32_t val = 10;
|
||||||
setAlterTagFunc("st1s1", "tag1", (const uint8_t*)&val, sizeof(val));
|
setAlterTagFunc("st1s1", "tag1", (uint8_t*)&val, sizeof(val));
|
||||||
run("ALTER TABLE st1s1 SET TAG tag1=10");
|
run("ALTER TABLE st1s1 SET TAG tag1=10");
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "planTestUtil.h"
|
#include "planTestUtil.h"
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
|
@ -528,20 +528,18 @@ int32_t qwDropTask(QW_FPARAMS_DEF) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
qTaskInfo_t *taskHandle = &ctx->taskHandle;
|
qTaskInfo_t taskHandle = ctx->taskHandle;
|
||||||
|
|
||||||
if (TASK_TYPE_TEMP == ctx->taskType) {
|
if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) {
|
||||||
if (ctx->explain) {
|
if (ctx->explain) {
|
||||||
SExplainExecInfo *execInfo = NULL;
|
SExplainExecInfo *execInfo = NULL;
|
||||||
int32_t resNum = 0;
|
int32_t resNum = 0;
|
||||||
QW_ERR_RET(qGetExplainExecInfo(ctx->taskHandle, &resNum, &execInfo));
|
QW_ERR_RET(qGetExplainExecInfo(taskHandle, &resNum, &execInfo));
|
||||||
|
|
||||||
SRpcHandleInfo connInfo = ctx->ctrlConnInfo;
|
SRpcHandleInfo connInfo = ctx->ctrlConnInfo;
|
||||||
connInfo.ahandle = NULL;
|
connInfo.ahandle = NULL;
|
||||||
QW_ERR_RET(qwBuildAndSendExplainRsp(&connInfo, execInfo, resNum));
|
QW_ERR_RET(qwBuildAndSendExplainRsp(&connInfo, execInfo, resNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
qwFreeTaskHandle(QW_FPARAMS(), taskHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -554,17 +552,22 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryEnd) {
|
||||||
uint64_t useconds = 0;
|
uint64_t useconds = 0;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t execNum = 0;
|
int32_t execNum = 0;
|
||||||
qTaskInfo_t *taskHandle = &ctx->taskHandle;
|
qTaskInfo_t taskHandle = ctx->taskHandle;
|
||||||
DataSinkHandle sinkHandle = ctx->sinkHandle;
|
DataSinkHandle sinkHandle = ctx->sinkHandle;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
QW_TASK_DLOG("start to execTask, loopIdx:%d", i++);
|
QW_TASK_DLOG("start to execTask, loopIdx:%d", i++);
|
||||||
|
|
||||||
code = qExecTask(*taskHandle, &pRes, &useconds);
|
pRes = NULL;
|
||||||
|
|
||||||
|
// if *taskHandle is NULL, it's killed right now
|
||||||
|
if (taskHandle) {
|
||||||
|
code = qExecTask(taskHandle, &pRes, &useconds);
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("qExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
QW_ERR_RET(code);
|
QW_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++execNum;
|
++execNum;
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ typedef struct SSchLevel {
|
||||||
int32_t taskSucceed;
|
int32_t taskSucceed;
|
||||||
int32_t taskNum;
|
int32_t taskNum;
|
||||||
int32_t taskLaunchedNum;
|
int32_t taskLaunchedNum;
|
||||||
SHashObj *flowCtrl; // key is ep, element is SSchFlowControl
|
int32_t taskDoneNum;
|
||||||
SArray *subTasks; // Element is SQueryTask
|
SArray *subTasks; // Element is SQueryTask
|
||||||
} SSchLevel;
|
} SSchLevel;
|
||||||
|
|
||||||
|
@ -175,11 +175,13 @@ typedef struct SSchJob {
|
||||||
SArray *levels; // starting from 0. SArray<SSchLevel>
|
SArray *levels; // starting from 0. SArray<SSchLevel>
|
||||||
SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler
|
SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler
|
||||||
|
|
||||||
|
SArray *dataSrcTasks; // SArray<SQueryTask*>
|
||||||
int32_t levelIdx;
|
int32_t levelIdx;
|
||||||
SEpSet dataSrcEps;
|
SEpSet dataSrcEps;
|
||||||
SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask*
|
SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask*
|
||||||
SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask*
|
SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask*
|
||||||
SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask*
|
SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask*
|
||||||
|
SHashObj *flowCtrl; // key is ep, element is SSchFlowControl
|
||||||
|
|
||||||
SExplainCtx *explainCtx;
|
SExplainCtx *explainCtx;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
@ -200,7 +202,7 @@ typedef struct SSchJob {
|
||||||
|
|
||||||
extern SSchedulerMgmt schMgmt;
|
extern SSchedulerMgmt schMgmt;
|
||||||
|
|
||||||
#define SCH_TASK_READY_TO_LUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children))
|
#define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children))
|
||||||
|
|
||||||
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
|
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
|
||||||
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
|
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
|
||||||
|
@ -223,7 +225,7 @@ extern SSchedulerMgmt schMgmt;
|
||||||
|
|
||||||
#define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true
|
#define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true
|
||||||
#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl)
|
#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl)
|
||||||
#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) (SCH_IS_DATA_SRC_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEAF_TASK(_job, _task) && SCH_IS_LEVEL_UNFINISHED((_task)->level))
|
#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) (SCH_IS_DATA_SRC_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level))
|
||||||
|
|
||||||
#define SCH_SET_JOB_TYPE(_job, type) (_job)->attr.queryJob = ((type) != SUBPLAN_TYPE_MODIFY)
|
#define SCH_SET_JOB_TYPE(_job, type) (_job)->attr.queryJob = ((type) != SUBPLAN_TYPE_MODIFY)
|
||||||
#define SCH_IS_QUERY_JOB(_job) ((_job)->attr.queryJob)
|
#define SCH_IS_QUERY_JOB(_job) ((_job)->attr.queryJob)
|
||||||
|
@ -261,7 +263,7 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task);
|
||||||
int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, SQueryNodeAddr *addr, int32_t msgType);
|
int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, SQueryNodeAddr *addr, int32_t msgType);
|
||||||
SSchJob *schAcquireJob(int64_t refId);
|
SSchJob *schAcquireJob(int64_t refId);
|
||||||
int32_t schReleaseJob(int64_t refId);
|
int32_t schReleaseJob(int64_t refId);
|
||||||
void schFreeFlowCtrl(SSchLevel *pLevel);
|
void schFreeFlowCtrl(SSchJob *pJob);
|
||||||
int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel);
|
int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel);
|
||||||
int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask);
|
int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask);
|
||||||
int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough);
|
int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough);
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
void schFreeFlowCtrl(SSchLevel *pLevel) {
|
void schFreeFlowCtrl(SSchJob *pJob) {
|
||||||
if (NULL == pLevel->flowCtrl) {
|
if (NULL == pJob->flowCtrl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchFlowControl *ctrl = NULL;
|
SSchFlowControl *ctrl = NULL;
|
||||||
void *pIter = taosHashIterate(pLevel->flowCtrl, NULL);
|
void *pIter = taosHashIterate(pJob->flowCtrl, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
ctrl = (SSchFlowControl *)pIter;
|
ctrl = (SSchFlowControl *)pIter;
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ void schFreeFlowCtrl(SSchLevel *pLevel) {
|
||||||
taosArrayDestroy(ctrl->taskList);
|
taosArrayDestroy(ctrl->taskList);
|
||||||
}
|
}
|
||||||
|
|
||||||
pIter = taosHashIterate(pLevel->flowCtrl, pIter);
|
pIter = taosHashIterate(pJob->flowCtrl, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pLevel->flowCtrl);
|
taosHashCleanup(pJob->flowCtrl);
|
||||||
pLevel->flowCtrl = NULL;
|
pJob->flowCtrl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
||||||
|
@ -47,9 +47,9 @@ int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sum = 0;
|
int32_t sum = 0;
|
||||||
|
int32_t taskNum = taosArrayGetSize(pJob->dataSrcTasks);
|
||||||
for (int32_t i = 0; i < pLevel->taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
SSchTask *pTask = taosArrayGet(pLevel->subTasks, i);
|
SSchTask *pTask = *(SSchTask **)taosArrayGet(pJob->dataSrcTasks, i);
|
||||||
|
|
||||||
sum += pTask->plan->execNodeStat.tableNum;
|
sum += pTask->plan->execNodeStat.tableNum;
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,9 @@ int32_t schCheckJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pLevel->flowCtrl = taosHashInit(pLevel->taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
pJob->flowCtrl = taosHashInit(pJob->taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
if (NULL == pLevel->flowCtrl) {
|
if (NULL == pJob->flowCtrl) {
|
||||||
SCH_JOB_ELOG("taosHashInit %d flowCtrl failed", pLevel->taskNum);
|
SCH_JOB_ELOG("taosHashInit %d flowCtrl failed", pJob->taskNum);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
||||||
|
|
||||||
ctrl = (SSchFlowControl *)taosHashGet(pLevel->flowCtrl, ep, sizeof(SEp));
|
ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp));
|
||||||
if (NULL == ctrl) {
|
if (NULL == ctrl) {
|
||||||
SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port);
|
SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||||
|
@ -110,11 +110,11 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) {
|
||||||
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ctrl = (SSchFlowControl *)taosHashGet(pLevel->flowCtrl, ep, sizeof(SEp));
|
ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp));
|
||||||
if (NULL == ctrl) {
|
if (NULL == ctrl) {
|
||||||
SSchFlowControl nctrl = {.tableNumSum = pTask->plan->execNodeStat.tableNum, .execTaskNum = 1};
|
SSchFlowControl nctrl = {.tableNumSum = pTask->plan->execNodeStat.tableNum, .execTaskNum = 1};
|
||||||
|
|
||||||
code = taosHashPut(pLevel->flowCtrl, ep, sizeof(SEp), &nctrl, sizeof(nctrl));
|
code = taosHashPut(pJob->flowCtrl, ep, sizeof(SEp), &nctrl, sizeof(nctrl));
|
||||||
if (code) {
|
if (code) {
|
||||||
if (HASH_NODE_EXIST(code)) {
|
if (HASH_NODE_EXIST(code)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -273,10 +273,9 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask));
|
SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask));
|
||||||
|
|
||||||
SSchLevel *pLevel = pTask->level;
|
|
||||||
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode);
|
||||||
|
|
||||||
SSchFlowControl *ctrl = (SSchFlowControl *)taosHashGet(pLevel->flowCtrl, ep, sizeof(SEp));
|
SSchFlowControl *ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp));
|
||||||
if (NULL == ctrl) {
|
if (NULL == ctrl) {
|
||||||
SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port);
|
SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||||
|
|
|
@ -391,6 +391,8 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) {
|
||||||
SCH_TASK_ELOG("taosArrayPush childTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n);
|
SCH_TASK_ELOG("taosArrayPush childTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCH_TASK_DLOG("children info, the %d child TID %" PRIx64, n, (*childTask)->taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentNum > 0) {
|
if (parentNum > 0) {
|
||||||
|
@ -423,6 +425,8 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) {
|
||||||
SCH_TASK_ELOG("taosArrayPush parentTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n);
|
SCH_TASK_ELOG("taosArrayPush parentTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCH_TASK_DLOG("parents info, the %d parent TID %" PRIx64, n, (*parentTask)->taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_TASK_DLOG("level:%d, parentNum:%d, childNum:%d", i, parentNum, childNum);
|
SCH_TASK_DLOG("level:%d, parentNum:%d, childNum:%d", i, parentNum, childNum);
|
||||||
|
@ -464,6 +468,17 @@ int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *ad
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schRecordQueryDataSrc(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
if (!SCH_IS_DATA_SRC_QRY_TASK(pTask)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pJob->dataSrcTasks, &pTask);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
|
int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
pJob->queryId = pDag->queryId;
|
pJob->queryId = pDag->queryId;
|
||||||
|
@ -473,6 +488,11 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pJob->dataSrcTasks = taosArrayInit(pDag->numOfSubplans, POINTER_BYTES);
|
||||||
|
if (NULL == pJob->dataSrcTasks) {
|
||||||
|
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t levelNum = (int32_t)LIST_LENGTH(pDag->pSubplans);
|
int32_t levelNum = (int32_t)LIST_LENGTH(pDag->pSubplans);
|
||||||
if (levelNum <= 0) {
|
if (levelNum <= 0) {
|
||||||
SCH_JOB_ELOG("invalid level num:%d", levelNum);
|
SCH_JOB_ELOG("invalid level num:%d", levelNum);
|
||||||
|
@ -551,6 +571,8 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCH_ERR_JRET(schRecordQueryDataSrc(pJob, p));
|
||||||
|
|
||||||
if (0 != taosHashPut(planToTask, &plan, POINTER_BYTES, &p, POINTER_BYTES)) {
|
if (0 != taosHashPut(planToTask, &plan, POINTER_BYTES, &p, POINTER_BYTES)) {
|
||||||
SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d", n);
|
SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d", n);
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
@ -629,6 +651,17 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId));
|
||||||
|
if (code) {
|
||||||
|
SCH_TASK_ELOG("task failed to rm from execTask list, code:%x", code);
|
||||||
|
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||||
if (0 != code) {
|
if (0 != code) {
|
||||||
|
@ -774,6 +807,9 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
|
|
||||||
|
SCH_ERR_RET(schRemoveTaskFromExecList(pJob, pTask));
|
||||||
|
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START);
|
||||||
|
|
||||||
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
||||||
SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask));
|
SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask));
|
||||||
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
SCH_ERR_RET(schLaunchTasksInFlowCtrlList(pJob, pTask));
|
||||||
|
@ -947,6 +983,32 @@ _return:
|
||||||
SCH_RET(schProcessOnJobFailure(pJob, errCode));
|
SCH_RET(schProcessOnJobFailure(pJob, errCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schLaunchNextLevelTasks(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
if (!SCH_IS_QUERY_JOB(pJob)) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSchLevel *pLevel = pTask->level;
|
||||||
|
int32_t doneNum = atomic_add_fetch_32(&pLevel->taskDoneNum, 1);
|
||||||
|
if (doneNum == pLevel->taskNum) {
|
||||||
|
pJob->levelIdx--;
|
||||||
|
|
||||||
|
pLevel = taosArrayGet(pJob->levels, pJob->levelIdx);
|
||||||
|
for (int32_t i = 0; i < pLevel->taskNum; ++i) {
|
||||||
|
SSchTask *pTask = taosArrayGet(pLevel->subTasks, i);
|
||||||
|
|
||||||
|
if (pTask->children && taosArrayGetSize(pTask->children) > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_ERR_RET(schLaunchTask(pJob, pTask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note: no more task error processing, handled in function internal
|
// Note: no more task error processing, handled in function internal
|
||||||
int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
bool moved = false;
|
bool moved = false;
|
||||||
|
@ -1015,11 +1077,13 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
qSetSubplanExecutionNode(par->plan, pTask->plan->id.groupId, &source);
|
qSetSubplanExecutionNode(par->plan, pTask->plan->id.groupId, &source);
|
||||||
SCH_UNLOCK(SCH_WRITE, &par->lock);
|
SCH_UNLOCK(SCH_WRITE, &par->lock);
|
||||||
|
|
||||||
if (SCH_TASK_READY_TO_LUNCH(readyNum, par)) {
|
if (SCH_TASK_READY_FOR_LAUNCH(readyNum, par)) {
|
||||||
SCH_ERR_RET(schLaunchTaskImpl(pJob, par));
|
SCH_ERR_RET(schLaunchTask(pJob, par));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCH_ERR_RET(schLaunchNextLevelTasks(pJob, pTask));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
@ -2400,8 +2464,6 @@ void schFreeJobImpl(void *job) {
|
||||||
for (int32_t i = 0; i < numOfLevels; ++i) {
|
for (int32_t i = 0; i < numOfLevels; ++i) {
|
||||||
SSchLevel *pLevel = taosArrayGet(pJob->levels, i);
|
SSchLevel *pLevel = taosArrayGet(pJob->levels, i);
|
||||||
|
|
||||||
schFreeFlowCtrl(pLevel);
|
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks);
|
int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks);
|
||||||
for (int32_t j = 0; j < numOfTasks; ++j) {
|
for (int32_t j = 0; j < numOfTasks; ++j) {
|
||||||
SSchTask *pTask = taosArrayGet(pLevel->subTasks, j);
|
SSchTask *pTask = taosArrayGet(pLevel->subTasks, j);
|
||||||
|
@ -2411,12 +2473,15 @@ void schFreeJobImpl(void *job) {
|
||||||
taosArrayDestroy(pLevel->subTasks);
|
taosArrayDestroy(pLevel->subTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
schFreeFlowCtrl(pJob);
|
||||||
|
|
||||||
taosHashCleanup(pJob->execTasks);
|
taosHashCleanup(pJob->execTasks);
|
||||||
taosHashCleanup(pJob->failTasks);
|
taosHashCleanup(pJob->failTasks);
|
||||||
taosHashCleanup(pJob->succTasks);
|
taosHashCleanup(pJob->succTasks);
|
||||||
|
|
||||||
taosArrayDestroy(pJob->levels);
|
taosArrayDestroy(pJob->levels);
|
||||||
taosArrayDestroy(pJob->nodeList);
|
taosArrayDestroy(pJob->nodeList);
|
||||||
|
taosArrayDestroy(pJob->dataSrcTasks);
|
||||||
|
|
||||||
qExplainFreeCtx(pJob->explainCtx);
|
qExplainFreeCtx(pJob->explainCtx);
|
||||||
|
|
||||||
|
|
|
@ -19,18 +19,24 @@
|
||||||
#define DEFAULT_FALSE_POSITIVE 0.01
|
#define DEFAULT_FALSE_POSITIVE 0.01
|
||||||
#define DEFAULT_BUCKET_SIZE 1024
|
#define DEFAULT_BUCKET_SIZE 1024
|
||||||
#define ROWS_PER_MILLISECOND 1
|
#define ROWS_PER_MILLISECOND 1
|
||||||
#define MAX_NUM_SCALABLE_BF 120
|
#define MAX_NUM_SCALABLE_BF 100000
|
||||||
#define MIN_NUM_SCALABLE_BF 10
|
#define MIN_NUM_SCALABLE_BF 10
|
||||||
#define DEFAULT_PREADD_BUCKET 1
|
#define DEFAULT_PREADD_BUCKET 1
|
||||||
#define MAX_INTERVAL MILLISECOND_PER_MINUTE
|
#define MAX_INTERVAL MILLISECOND_PER_MINUTE
|
||||||
#define MIN_INTERVAL (MILLISECOND_PER_SECOND * 10)
|
#define MIN_INTERVAL (MILLISECOND_PER_SECOND * 10)
|
||||||
|
#define DEFAULT_EXPECTED_ENTRIES 10000
|
||||||
|
|
||||||
|
static int64_t adjustExpEntries(int64_t entries) {
|
||||||
|
return TMIN(DEFAULT_EXPECTED_ENTRIES, entries);
|
||||||
|
}
|
||||||
|
|
||||||
static void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) {
|
static void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) {
|
||||||
if (pInfo->numSBFs < count) {
|
if (pInfo->numSBFs < count) {
|
||||||
count = pInfo->numSBFs;
|
count = pInfo->numSBFs;
|
||||||
}
|
}
|
||||||
for (uint64_t i = 0; i < count; ++i) {
|
for (uint64_t i = 0; i < count; ++i) {
|
||||||
SScalableBf *tsSBF = tScalableBfInit(pInfo->interval * ROWS_PER_MILLISECOND, DEFAULT_FALSE_POSITIVE);
|
int64_t rows = adjustExpEntries(pInfo->interval * ROWS_PER_MILLISECOND);
|
||||||
|
SScalableBf *tsSBF = tScalableBfInit(rows, DEFAULT_FALSE_POSITIVE);
|
||||||
taosArrayPush(pInfo->pTsSBFs, &tsSBF);
|
taosArrayPush(pInfo->pTsSBFs, &tsSBF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,9 +44,9 @@ static void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) {
|
||||||
static void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count) {
|
static void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count) {
|
||||||
if (count < pInfo->numSBFs - 1) {
|
if (count < pInfo->numSBFs - 1) {
|
||||||
for (uint64_t i = 0; i < count; ++i) {
|
for (uint64_t i = 0; i < count; ++i) {
|
||||||
SScalableBf *pTsSBFs = taosArrayGetP(pInfo->pTsSBFs, i);
|
SScalableBf *pTsSBFs = taosArrayGetP(pInfo->pTsSBFs, 0);
|
||||||
tScalableBfDestroy(pTsSBFs);
|
tScalableBfDestroy(pTsSBFs);
|
||||||
taosArrayRemove(pInfo->pTsSBFs, i);
|
taosArrayRemove(pInfo->pTsSBFs, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
taosArrayClearP(pInfo->pTsSBFs, (FDelete)tScalableBfDestroy);
|
taosArrayClearP(pInfo->pTsSBFs, (FDelete)tScalableBfDestroy);
|
||||||
|
@ -66,7 +72,7 @@ static int64_t adjustInterval(int64_t interval, int32_t precision) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t adjustWatermark(int64_t interval, int32_t watermark) {
|
static int64_t adjustWatermark(int64_t interval, int64_t watermark) {
|
||||||
if (watermark <= 0 || watermark > MAX_NUM_SCALABLE_BF * interval) {
|
if (watermark <= 0 || watermark > MAX_NUM_SCALABLE_BF * interval) {
|
||||||
watermark = MAX_NUM_SCALABLE_BF * interval;
|
watermark = MAX_NUM_SCALABLE_BF * interval;
|
||||||
} else if (watermark < MIN_NUM_SCALABLE_BF * interval) {
|
} else if (watermark < MIN_NUM_SCALABLE_BF * interval) {
|
||||||
|
@ -130,7 +136,8 @@ static SScalableBf *getSBf(SUpdateInfo *pInfo, TSKEY ts) {
|
||||||
}
|
}
|
||||||
SScalableBf *res = taosArrayGetP(pInfo->pTsSBFs, index);
|
SScalableBf *res = taosArrayGetP(pInfo->pTsSBFs, index);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
res = tScalableBfInit(pInfo->interval * ROWS_PER_MILLISECOND, DEFAULT_FALSE_POSITIVE);
|
int64_t rows = adjustExpEntries(pInfo->interval * ROWS_PER_MILLISECOND);
|
||||||
|
res = tScalableBfInit(rows, DEFAULT_FALSE_POSITIVE);
|
||||||
taosArrayPush(pInfo->pTsSBFs, &res);
|
taosArrayPush(pInfo->pTsSBFs, &res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#define MAX_NUM_SCALABLE_BF 100000
|
||||||
|
|
||||||
TEST(TD_STREAM_UPDATE_TEST, update) {
|
TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
int64_t interval = 20 * 1000;
|
int64_t interval = 20 * 1000;
|
||||||
|
@ -91,11 +92,11 @@ TEST(TD_STREAM_UPDATE_TEST, update) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SUpdateInfo *pSU4 = updateInfoInit(-1, TSDB_TIME_PRECISION_MILLI, -1);
|
SUpdateInfo *pSU4 = updateInfoInit(-1, TSDB_TIME_PRECISION_MILLI, -1);
|
||||||
GTEST_ASSERT_EQ(pSU4->watermark, 120 * pSU4->interval);
|
GTEST_ASSERT_EQ(pSU4->watermark, MAX_NUM_SCALABLE_BF * pSU4->interval);
|
||||||
GTEST_ASSERT_EQ(pSU4->interval, MILLISECOND_PER_MINUTE);
|
GTEST_ASSERT_EQ(pSU4->interval, MILLISECOND_PER_MINUTE);
|
||||||
|
|
||||||
SUpdateInfo *pSU5 = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0);
|
SUpdateInfo *pSU5 = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
GTEST_ASSERT_EQ(pSU5->watermark, 120 * pSU4->interval);
|
GTEST_ASSERT_EQ(pSU5->watermark, MAX_NUM_SCALABLE_BF * pSU4->interval);
|
||||||
GTEST_ASSERT_EQ(pSU5->interval, MILLISECOND_PER_MINUTE);
|
GTEST_ASSERT_EQ(pSU5->interval, MILLISECOND_PER_MINUTE);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,7 @@ SyncPing* syncPingDeserialize3(void* buf, int32_t bufLen) {
|
||||||
}
|
}
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
if (tDecodeBinary(&decoder, (const uint8_t**)(&data), &len) < 0) {
|
if (tDecodeBinary(&decoder, (uint8_t**)(&data), &len) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(len = pMsg->dataLen);
|
assert(len = pMsg->dataLen);
|
||||||
|
@ -670,7 +670,7 @@ SyncPingReply* syncPingReplyDeserialize3(void* buf, int32_t bufLen) {
|
||||||
}
|
}
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
if (tDecodeBinary(&decoder, (const uint8_t**)(&data), &len) < 0) {
|
if (tDecodeBinary(&decoder, (uint8_t**)(&data), &len) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(len = pMsg->dataLen);
|
assert(len = pMsg->dataLen);
|
||||||
|
|
|
@ -18,15 +18,17 @@ if(USE_TD_MEMORY)
|
||||||
add_definitions(-DUSE_TD_MEMORY)
|
add_definitions(-DUSE_TD_MEMORY)
|
||||||
endif ()
|
endif ()
|
||||||
if(BUILD_ADDR2LINE)
|
if(BUILD_ADDR2LINE)
|
||||||
|
if(NOT TD_WINDOWS)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
os
|
os
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/libdwarf/src/lib/libdwarf"
|
PUBLIC "${TD_SOURCE_DIR}/contrib/libdwarf/src/lib/libdwarf"
|
||||||
)
|
)
|
||||||
add_definitions(-DUSE_ADDR2LINE)
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
os PUBLIC addr2line dl z
|
os PUBLIC addr2line dl z
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
add_definitions(-DUSE_ADDR2LINE)
|
||||||
|
endif ()
|
||||||
if(CHECK_STR2INT_ERROR)
|
if(CHECK_STR2INT_ERROR)
|
||||||
add_definitions(-DTD_CHECK_STR_TO_INT_ERROR)
|
add_definitions(-DTD_CHECK_STR_TO_INT_ERROR)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -91,7 +91,12 @@ void taosRemoveDir(const char *dirname) {
|
||||||
bool taosDirExist(const char *dirname) { return taosCheckExistFile(dirname); }
|
bool taosDirExist(const char *dirname) { return taosCheckExistFile(dirname); }
|
||||||
|
|
||||||
int32_t taosMkDir(const char *dirname) {
|
int32_t taosMkDir(const char *dirname) {
|
||||||
|
if (taosDirExist(dirname)) return 0;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t code = _mkdir(dirname, 0755);
|
||||||
|
#else
|
||||||
int32_t code = mkdir(dirname, 0755);
|
int32_t code = mkdir(dirname, 0755);
|
||||||
|
#endif
|
||||||
if (code < 0 && errno == EEXIST) {
|
if (code < 0 && errno == EEXIST) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -101,36 +106,48 @@ int32_t taosMkDir(const char *dirname) {
|
||||||
|
|
||||||
int32_t taosMulMkDir(const char *dirname) {
|
int32_t taosMulMkDir(const char *dirname) {
|
||||||
if (dirname == NULL) return -1;
|
if (dirname == NULL) return -1;
|
||||||
char * temp = strdup(dirname);
|
char temp[1024];
|
||||||
|
#ifdef WINDOWS
|
||||||
|
taosRealPath(dirname, temp, sizeof(temp));
|
||||||
|
#else
|
||||||
|
strcpy(temp, dirname);
|
||||||
|
#endif
|
||||||
char * pos = temp;
|
char * pos = temp;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (strncmp(temp, "/", 1) == 0) {
|
if (taosDirExist(temp)) return code;
|
||||||
|
|
||||||
|
if (strncmp(temp, TD_DIRSEP, 1) == 0) {
|
||||||
pos += 1;
|
pos += 1;
|
||||||
} else if (strncmp(temp, "./", 2) == 0) {
|
} else if (strncmp(temp, "." TD_DIRSEP, 2) == 0) {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; *pos != '\0'; pos++) {
|
for (; *pos != '\0'; pos++) {
|
||||||
if (*pos == '/') {
|
if (*pos == TD_DIRSEP[0]) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
|
#ifdef WINDOWS
|
||||||
|
code = _mkdir(temp, 0755);
|
||||||
|
#else
|
||||||
code = mkdir(temp, 0755);
|
code = mkdir(temp, 0755);
|
||||||
|
#endif
|
||||||
if (code < 0 && errno != EEXIST) {
|
if (code < 0 && errno != EEXIST) {
|
||||||
free(temp);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
*pos = '/';
|
*pos = TD_DIRSEP[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(pos - 1) != '/') {
|
if (*(pos - 1) != TD_DIRSEP[0]) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
code = _mkdir(temp, 0755);
|
||||||
|
#else
|
||||||
code = mkdir(temp, 0755);
|
code = mkdir(temp, 0755);
|
||||||
|
#endif
|
||||||
if (code < 0 && errno != EEXIST) {
|
if (code < 0 && errno != EEXIST) {
|
||||||
free(temp);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(temp);
|
|
||||||
|
|
||||||
// int32_t code = mkdir(dirname, 0755);
|
// int32_t code = mkdir(dirname, 0755);
|
||||||
if (code < 0 && errno == EEXIST) {
|
if (code < 0 && errno == EEXIST) {
|
||||||
|
@ -233,8 +250,14 @@ char *taosDirName(char *name) {
|
||||||
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
_splitpath(name, Drive1, Dir1, NULL, NULL);
|
||||||
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
size_t dirNameLen = strlen(Drive1) + strlen(Dir1);
|
||||||
if (dirNameLen > 0) {
|
if (dirNameLen > 0) {
|
||||||
|
if (name[dirNameLen - 1] == '/' || name[dirNameLen - 1] == '\\') {
|
||||||
|
name[dirNameLen - 1] = 0;
|
||||||
|
} else {
|
||||||
name[dirNameLen] = 0;
|
name[dirNameLen] = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
name[0] = 0;
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
#else
|
#else
|
||||||
return dirname(name);
|
return dirname(name);
|
||||||
|
|
|
@ -109,8 +109,11 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, cha
|
||||||
|
|
||||||
int64_t taosCopyFile(const char *from, const char *to) {
|
int64_t taosCopyFile(const char *from, const char *to) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
assert(0);
|
if (CopyFile(from, to, 0)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
|
@ -343,7 +346,11 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||||
char *tbuf = (char *)buf;
|
char *tbuf = (char *)buf;
|
||||||
|
|
||||||
while (leftbytes > 0) {
|
while (leftbytes > 0) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
readbytes = _read(pFile->fd, (void *)tbuf, (uint32_t)leftbytes);
|
||||||
|
#else
|
||||||
readbytes = read(pFile->fd, (void *)tbuf, (uint32_t)leftbytes);
|
readbytes = read(pFile->fd, (void *)tbuf, (uint32_t)leftbytes);
|
||||||
|
#endif
|
||||||
if (readbytes < 0) {
|
if (readbytes < 0) {
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -379,10 +386,10 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
||||||
#endif
|
#endif
|
||||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
size_t pos = lseek(pFile->fd, 0, SEEK_CUR);
|
size_t pos = _lseek(pFile->fd, 0, SEEK_CUR);
|
||||||
lseek(pFile->fd, offset, SEEK_SET);
|
_lseek(pFile->fd, offset, SEEK_SET);
|
||||||
int64_t ret = read(pFile->fd, buf, count);
|
int64_t ret = _read(pFile->fd, buf, count);
|
||||||
lseek(pFile->fd, pos, SEEK_SET);
|
_lseek(pFile->fd, pos, SEEK_SET);
|
||||||
#else
|
#else
|
||||||
int64_t ret = pread(pFile->fd, buf, count, offset);
|
int64_t ret = pread(pFile->fd, buf, count, offset);
|
||||||
#endif
|
#endif
|
||||||
|
@ -428,7 +435,11 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int64_t ret = _lseek(pFile->fd, offset, whence);
|
||||||
|
#else
|
||||||
int64_t ret = lseek(pFile->fd, offset, whence);
|
int64_t ret = lseek(pFile->fd, offset, whence);
|
||||||
|
#endif
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
|
@ -567,12 +578,12 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|
||||||
lseek(pFileIn->fd, (int32_t)(*offset), 0);
|
_lseek(pFileIn->fd, (int32_t)(*offset), 0);
|
||||||
int64_t writeLen = 0;
|
int64_t writeLen = 0;
|
||||||
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
uint8_t buffer[_SEND_FILE_STEP_] = {0};
|
||||||
|
|
||||||
for (int64_t len = 0; len < (size - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
for (int64_t len = 0; len < (size - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
|
||||||
size_t rlen = read(pFileIn->fd, (void *)buffer, _SEND_FILE_STEP_);
|
size_t rlen = _read(pFileIn->fd, (void *)buffer, _SEND_FILE_STEP_);
|
||||||
if (rlen <= 0) {
|
if (rlen <= 0) {
|
||||||
return writeLen;
|
return writeLen;
|
||||||
} else if (rlen < _SEND_FILE_STEP_) {
|
} else if (rlen < _SEND_FILE_STEP_) {
|
||||||
|
@ -586,7 +597,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
||||||
|
|
||||||
int64_t remain = size - writeLen;
|
int64_t remain = size - writeLen;
|
||||||
if (remain > 0) {
|
if (remain > 0) {
|
||||||
size_t rlen = read(pFileIn->fd, (void *)buffer, (size_t)remain);
|
size_t rlen = _read(pFileIn->fd, (void *)buffer, (size_t)remain);
|
||||||
if (rlen <= 0) {
|
if (rlen <= 0) {
|
||||||
return writeLen;
|
return writeLen;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,6 +37,49 @@ typedef struct TdMemoryInfo {
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define tstrdup(str) _strdup(str)
|
#define tstrdup(str) _strdup(str)
|
||||||
|
|
||||||
|
int32_t taosBackTrace(void **buffer, int32_t size) {
|
||||||
|
int32_t frame = 0;
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ADDR2LINE
|
||||||
|
#include <DbgHelp.h>
|
||||||
|
#pragma comment(lib, "dbghelp.lib")
|
||||||
|
|
||||||
|
void taosPrintBackTrace() {
|
||||||
|
#define MAX_STACK_FRAMES 20
|
||||||
|
|
||||||
|
void *pStack[MAX_STACK_FRAMES];
|
||||||
|
|
||||||
|
HANDLE process = GetCurrentProcess();
|
||||||
|
SymInitialize(process, NULL, TRUE);
|
||||||
|
WORD frames = CaptureStackBackTrace(1, MAX_STACK_FRAMES, pStack, NULL);
|
||||||
|
|
||||||
|
char buf_tmp[1024];
|
||||||
|
for (WORD i = 0; i < frames; ++i) {
|
||||||
|
DWORD64 address = (DWORD64)(pStack[i]);
|
||||||
|
|
||||||
|
DWORD64 displacementSym = 0;
|
||||||
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
|
||||||
|
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||||
|
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
|
pSymbol->MaxNameLen = MAX_SYM_NAME;
|
||||||
|
|
||||||
|
DWORD displacementLine = 0;
|
||||||
|
IMAGEHLP_LINE64 line;
|
||||||
|
//SymSetOptions(SYMOPT_LOAD_LINES);
|
||||||
|
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||||
|
|
||||||
|
if (SymFromAddr(process, address, &displacementSym, pSymbol) && SymGetLineFromAddr64(process, address, &displacementLine, &line)) {
|
||||||
|
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName, line.LineNumber, pSymbol->Name);
|
||||||
|
} else {
|
||||||
|
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace error: %d\n",GetLastError());
|
||||||
|
}
|
||||||
|
write(1,buf_tmp,strlen(buf_tmp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define tstrdup(str) strdup(str)
|
#define tstrdup(str) strdup(str)
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,32 @@ int32_t tsem_wait(tsem_t* sem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) {
|
int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) {
|
||||||
int ret = 0;
|
struct timespec ts, rel;
|
||||||
|
FILETIME ft_before, ft_after;
|
||||||
|
int rc;
|
||||||
|
|
||||||
return ret;
|
rel.tv_sec = 0;
|
||||||
|
rel.tv_nsec = nanosecs;
|
||||||
|
|
||||||
|
GetSystemTimeAsFileTime(&ft_before);
|
||||||
|
errno = 0;
|
||||||
|
rc = sem_timedwait(&sem, pthread_win32_getabstime_np(&ts, &rel));
|
||||||
|
|
||||||
|
/* This should have timed out */
|
||||||
|
assert(errno == ETIMEDOUT);
|
||||||
|
assert(rc != 0);
|
||||||
|
GetSystemTimeAsFileTime(&ft_after);
|
||||||
|
// We specified a non-zero wait. Time must advance.
|
||||||
|
if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime)
|
||||||
|
{
|
||||||
|
printf("nanoseconds: %d, rc: %d, errno: %d. before filetime: %d, %d; after filetime: %d, %d\n",
|
||||||
|
nanosecs, rc, errno,
|
||||||
|
(int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime,
|
||||||
|
(int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime);
|
||||||
|
printf("time must advance during sem_timedwait.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
|
|
@ -718,7 +718,11 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
|
|
||||||
bzero((char *)&serverAdd, sizeof(serverAdd));
|
bzero((char *)&serverAdd, sizeof(serverAdd));
|
||||||
serverAdd.sin_family = AF_INET;
|
serverAdd.sin_family = AF_INET;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
serverAdd.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
#else
|
||||||
serverAdd.sin_addr.s_addr = ip;
|
serverAdd.sin_addr.s_addr = ip;
|
||||||
|
#endif
|
||||||
serverAdd.sin_port = (uint16_t)htons(port);
|
serverAdd.sin_port = (uint16_t)htons(port);
|
||||||
|
|
||||||
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) <= 2) {
|
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) <= 2) {
|
||||||
|
@ -882,6 +886,16 @@ void taosBlockSIGPIPE() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
|
uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
// Initialize Winsock
|
||||||
|
WSADATA wsaData;
|
||||||
|
int iResult;
|
||||||
|
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
if (iResult != 0) {
|
||||||
|
printf("WSAStartup failed: %d\n", iResult);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
struct addrinfo hints = {0};
|
struct addrinfo hints = {0};
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
@ -899,12 +913,12 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
|
||||||
} else {
|
} else {
|
||||||
#ifdef EAI_SYSTEM
|
#ifdef EAI_SYSTEM
|
||||||
if (ret == EAI_SYSTEM) {
|
if (ret == EAI_SYSTEM) {
|
||||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno));
|
printf("failed to get the ip address, fqdn:%s, errno:%d, since:%s", fqdn, errno, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
|
printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
|
printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret));
|
||||||
#endif
|
#endif
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct SEncoderNode {
|
||||||
|
|
||||||
struct SDecoderNode {
|
struct SDecoderNode {
|
||||||
SDecoderNode* pNext;
|
SDecoderNode* pNext;
|
||||||
const uint8_t* data;
|
uint8_t* data;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ void tEncoderClear(SEncoder* pCoder) {
|
||||||
memset(pCoder, 0, sizeof(*pCoder));
|
memset(pCoder, 0, sizeof(*pCoder));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDecoderInit(SDecoder* pDecoder, const uint8_t* data, uint32_t size) {
|
void tDecoderInit(SDecoder* pDecoder, uint8_t* data, uint32_t size) {
|
||||||
pDecoder->data = data;
|
pDecoder->data = data;
|
||||||
pDecoder->size = size;
|
pDecoder->size = size;
|
||||||
pDecoder->pos = 0;
|
pDecoder->pos = 0;
|
||||||
|
|
|
@ -244,6 +244,7 @@ class TDTestCase:
|
||||||
if user is None:
|
if user is None:
|
||||||
user = self.root_user
|
user = self.root_user
|
||||||
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
||||||
|
time.sleep(2)
|
||||||
use.query("use db")
|
use.query("use db")
|
||||||
use.query("show tables")
|
use.query("show tables")
|
||||||
if check_priv == PRIVILEGES_ALL:
|
if check_priv == PRIVILEGES_ALL:
|
||||||
|
@ -398,6 +399,7 @@ class TDTestCase:
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step 1.18: revoke all from all = nothing")
|
tdLog.printNoPrefix("==========step 1.18: revoke all from all = nothing")
|
||||||
self.revoke_user(user=self.users[2], priv=PRIVILEGES_ALL)
|
self.revoke_user(user=self.users[2], priv=PRIVILEGES_ALL)
|
||||||
|
time.sleep(3)
|
||||||
self.__user_check(user=self.users[2], check_priv=None)
|
self.__user_check(user=self.users[2], check_priv=None)
|
||||||
|
|
||||||
def __grant_err(self):
|
def __grant_err(self):
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0aad27d725f4ee6b18daf1db0c07d933aed16eea
|
Subproject commit 788929bdc475d264d8306ceff30f7df006fd18d8
|
Loading…
Reference in New Issue