Merge branch '3.0' into 3.0_glzhao_math_func
This commit is contained in:
commit
aaa2d2094a
|
@ -25,7 +25,7 @@ int32_t init_env() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -63,7 +63,7 @@ int32_t init_env() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t create_stream() {
|
int32_t create_stream() {
|
||||||
printf("create topic\n");
|
printf("create stream\n");
|
||||||
TAOS_RES* pRes;
|
TAOS_RES* pRes;
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
if (pConn == NULL) {
|
if (pConn == NULL) {
|
||||||
|
@ -77,7 +77,9 @@ int32_t create_stream() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
const char* sql = "select ts,k from tu1";
|
/*const char* sql = "select min(k), max(k), sum(k) from tu1";*/
|
||||||
|
const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";
|
||||||
|
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||||
pRes = tmq_create_stream(pConn, "stream1", "out1", sql);
|
pRes = tmq_create_stream(pConn, "stream1", "out1", sql);
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create stream out1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create stream out1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
|
|
@ -63,9 +63,12 @@ typedef enum {
|
||||||
} ETsdbStatisStatus;
|
} ETsdbStatisStatus;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SMA_STAT_OK = 0, // ready to provide service
|
TSDB_SMA_STAT_UNKNOWN = -1, // unknown
|
||||||
TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired
|
TSDB_SMA_STAT_OK = 0, // ready to provide service
|
||||||
} ETsdbSmaStat;
|
TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired
|
||||||
|
TSDB_SMA_STAT_DROPPED = 2, // sma dropped
|
||||||
|
} ETsdbSmaStat; // bit operation
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
|
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
|
||||||
|
|
|
@ -54,13 +54,16 @@ typedef struct SColumnDataAgg {
|
||||||
} SColumnDataAgg;
|
} SColumnDataAgg;
|
||||||
|
|
||||||
typedef struct SDataBlockInfo {
|
typedef struct SDataBlockInfo {
|
||||||
STimeWindow window;
|
STimeWindow window;
|
||||||
int32_t rows;
|
int32_t rows;
|
||||||
int32_t rowSize;
|
int32_t rowSize;
|
||||||
int16_t numOfCols;
|
int16_t numOfCols;
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
union {int64_t uid; int64_t blockId;};
|
union {
|
||||||
int64_t groupId; // no need to serialize
|
int64_t uid;
|
||||||
|
int64_t blockId;
|
||||||
|
};
|
||||||
|
int64_t groupId; // no need to serialize
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
|
@ -92,7 +95,7 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
|
||||||
void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
int32_t tEncodeDataBlocks(void** buf, const SArray* blocks);
|
||||||
void* tDecodeDataBlocks(const void* buf, SArray* blocks);
|
void* tDecodeDataBlocks(const void* buf, SArray** blocks);
|
||||||
|
|
||||||
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||||
// WARNING: do not use info.numOfCols,
|
// WARNING: do not use info.numOfCols,
|
||||||
|
@ -101,16 +104,16 @@ static FORCE_INLINE void blockDestroyInner(SSDataBlock* pBlock) {
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
tfree(pColInfoData->varmeta.offset);
|
taosMemoryFreeClear(pColInfoData->varmeta.offset);
|
||||||
} else {
|
} else {
|
||||||
tfree(pColInfoData->nullbitmap);
|
taosMemoryFreeClear(pColInfoData->nullbitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pColInfoData->pData);
|
taosMemoryFreeClear(pColInfoData->pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pBlock->pDataBlock);
|
taosArrayDestroy(pBlock->pDataBlock);
|
||||||
tfree(pBlock->pBlockAgg);
|
taosMemoryFreeClear(pBlock->pBlockAgg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); }
|
static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { blockDestroyInner(pBlock); }
|
||||||
|
@ -144,7 +147,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
|
||||||
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
|
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
|
||||||
buf = taosDecodeFixedI32(buf, &pRsp->numOfTopics);
|
buf = taosDecodeFixedI32(buf, &pRsp->numOfTopics);
|
||||||
if (pRsp->numOfTopics == 0) return buf;
|
if (pRsp->numOfTopics == 0) return buf;
|
||||||
pRsp->schema = (SSchemaWrapper*)calloc(1, sizeof(SSchemaWrapper));
|
pRsp->schema = (SSchemaWrapper*)taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
||||||
if (pRsp->schema == NULL) return NULL;
|
if (pRsp->schema == NULL) return NULL;
|
||||||
buf = tDecodeSSchemaWrapper(buf, pRsp->schema);
|
buf = tDecodeSSchemaWrapper(buf, pRsp->schema);
|
||||||
buf = taosDecodeFixedI32(buf, &sz);
|
buf = taosDecodeFixedI32(buf, &sz);
|
||||||
|
@ -160,9 +163,9 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
|
||||||
static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
|
static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
|
||||||
if (pRsp->schema) {
|
if (pRsp->schema) {
|
||||||
if (pRsp->schema->nCols) {
|
if (pRsp->schema->nCols) {
|
||||||
tfree(pRsp->schema->pSchema);
|
taosMemoryFreeClear(pRsp->schema->pSchema);
|
||||||
}
|
}
|
||||||
free(pRsp->schema);
|
taosMemoryFree(pRsp->schema);
|
||||||
}
|
}
|
||||||
taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))blockDestroyInner);
|
taosArrayDestroyEx(pRsp->pBlockData, (void (*)(void*))blockDestroyInner);
|
||||||
pRsp->pBlockData = NULL;
|
pRsp->pBlockData = NULL;
|
||||||
|
|
|
@ -102,7 +102,8 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
|
||||||
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
|
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource, uint32_t numOfRow2);
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource,
|
||||||
|
uint32_t numOfRow2);
|
||||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows);
|
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows);
|
||||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock);
|
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock);
|
||||||
|
|
||||||
|
@ -113,7 +114,8 @@ size_t blockDataGetNumOfCols(const SSDataBlock* pBlock);
|
||||||
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock);
|
size_t blockDataGetNumOfRows(const SSDataBlock* pBlock);
|
||||||
|
|
||||||
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc);
|
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc);
|
||||||
int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex, int32_t pageSize);
|
int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex,
|
||||||
|
int32_t pageSize);
|
||||||
int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock);
|
int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock);
|
||||||
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf);
|
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf);
|
||||||
|
|
||||||
|
@ -136,6 +138,8 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock);
|
||||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
||||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||||
|
|
||||||
|
void blockDebugShowData(SArray* dataBlocks);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -93,7 +93,7 @@ typedef struct {
|
||||||
#define schemaFLen(s) ((s)->flen)
|
#define schemaFLen(s) ((s)->flen)
|
||||||
#define schemaVLen(s) ((s)->vlen)
|
#define schemaVLen(s) ((s)->vlen)
|
||||||
#define schemaColAt(s, i) ((s)->columns + i)
|
#define schemaColAt(s, i) ((s)->columns + i)
|
||||||
#define tdFreeSchema(s) tfree((s))
|
#define tdFreeSchema(s) taosMemoryFreeClear((s))
|
||||||
|
|
||||||
STSchema *tdDupSchema(const STSchema *pSchema);
|
STSchema *tdDupSchema(const STSchema *pSchema);
|
||||||
int32_t tdEncodeSchema(void **buf, STSchema *pSchema);
|
int32_t tdEncodeSchema(void **buf, STSchema *pSchema);
|
||||||
|
@ -493,7 +493,7 @@ typedef struct {
|
||||||
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
|
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
|
||||||
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
|
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
|
||||||
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
|
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
|
||||||
#define kvRowFree(r) tfree(r)
|
#define kvRowFree(r) taosMemoryFreeClear(r)
|
||||||
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
|
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
|
||||||
#define kvRowValLen(r) (kvRowLen(r) - TD_KV_ROW_HEAD_SIZE - sizeof(SColIdx) * kvRowNCols(r))
|
#define kvRowValLen(r) (kvRowLen(r) - TD_KV_ROW_HEAD_SIZE - sizeof(SColIdx) * kvRowNCols(r))
|
||||||
#define kvRowTKey(r) (*(TKEY *)(kvRowValues(r)))
|
#define kvRowTKey(r) (*(TKEY *)(kvRowValues(r)))
|
||||||
|
@ -593,7 +593,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder);
|
||||||
static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, const void *value) {
|
static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t colId, int8_t type, const void *value) {
|
||||||
if (pBuilder->nCols >= pBuilder->tCols) {
|
if (pBuilder->nCols >= pBuilder->tCols) {
|
||||||
pBuilder->tCols *= 2;
|
pBuilder->tCols *= 2;
|
||||||
SColIdx *pColIdx = (SColIdx *)realloc((void *)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols);
|
SColIdx *pColIdx = (SColIdx *)taosMemoryRealloc((void *)(pBuilder->pColIdx), sizeof(SColIdx) * pBuilder->tCols);
|
||||||
if (pColIdx == NULL) return -1;
|
if (pColIdx == NULL) return -1;
|
||||||
pBuilder->pColIdx = pColIdx;
|
pBuilder->pColIdx = pColIdx;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, int16_t col
|
||||||
while (tlen > pBuilder->alloc - pBuilder->size) {
|
while (tlen > pBuilder->alloc - pBuilder->size) {
|
||||||
pBuilder->alloc *= 2;
|
pBuilder->alloc *= 2;
|
||||||
}
|
}
|
||||||
void *buf = realloc(pBuilder->buf, pBuilder->alloc);
|
void *buf = taosMemoryRealloc(pBuilder->buf, pBuilder->alloc);
|
||||||
if (buf == NULL) return -1;
|
if (buf == NULL) return -1;
|
||||||
pBuilder->buf = buf;
|
pBuilder->buf = buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include "tencode.h"
|
#include "tencode.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tlist.h"
|
#include "tlist.h"
|
||||||
#include "trow.h"
|
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "trow.h"
|
||||||
#include "tuuid.h"
|
#include "tuuid.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -109,6 +109,7 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_STREAMTABLES,
|
TSDB_MGMT_TABLE_STREAMTABLES,
|
||||||
TSDB_MGMT_TABLE_TP,
|
TSDB_MGMT_TABLE_TP,
|
||||||
TSDB_MGMT_TABLE_FUNC,
|
TSDB_MGMT_TABLE_FUNC,
|
||||||
|
TSDB_MGMT_TABLE_INDEX,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -183,6 +184,13 @@ typedef struct SField {
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
} SField;
|
} SField;
|
||||||
|
|
||||||
|
typedef struct SRetention {
|
||||||
|
int32_t freq;
|
||||||
|
int32_t keep;
|
||||||
|
int8_t freqUnit;
|
||||||
|
int8_t keepUnit;
|
||||||
|
} SRetention;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
|
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
|
||||||
|
@ -193,21 +201,13 @@ typedef struct SEp {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
union {
|
int32_t vgId;
|
||||||
int32_t vgId;
|
|
||||||
int32_t streamTaskId;
|
|
||||||
};
|
|
||||||
} SMsgHead;
|
} SMsgHead;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t workerType;
|
|
||||||
int32_t streamTaskId;
|
|
||||||
} SStreamExecMsgHead;
|
|
||||||
|
|
||||||
// Submit message for one table
|
// Submit message for one table
|
||||||
typedef struct SSubmitBlk {
|
typedef struct SSubmitBlk {
|
||||||
int64_t uid; // table unique id
|
int64_t uid; // table unique id
|
||||||
int32_t tid; // table id
|
int64_t suid; // stable id
|
||||||
int32_t padding; // TODO just for padding here
|
int32_t padding; // TODO just for padding here
|
||||||
int32_t sversion; // data schema version
|
int32_t sversion; // data schema version
|
||||||
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||||
|
@ -232,12 +232,12 @@ typedef struct {
|
||||||
} SSubmitBlkIter;
|
} SSubmitBlkIter;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t totalLen;
|
int32_t totalLen;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
void* pMsg;
|
const void* pMsg;
|
||||||
} SSubmitMsgIter;
|
} SSubmitMsgIter;
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||||
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
||||||
int32_t tInitSubmitBlkIter(SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
int32_t tInitSubmitBlkIter(SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
||||||
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
||||||
|
@ -268,11 +268,18 @@ typedef struct SSchema {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
|
float xFilesFactor;
|
||||||
|
int32_t aggregationMethod;
|
||||||
|
int32_t delay;
|
||||||
|
int32_t ttl;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
SArray* pColumns;
|
int32_t numOfSmas;
|
||||||
SArray* pTags;
|
int32_t commentLen;
|
||||||
char comment[TSDB_STB_COMMENT_LEN];
|
SArray* pColumns; // array of SField
|
||||||
|
SArray* pTags; // array of SField
|
||||||
|
SArray* pSmas; // array of SField
|
||||||
|
char* comment;
|
||||||
} SMCreateStbReq;
|
} SMCreateStbReq;
|
||||||
|
|
||||||
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
|
||||||
|
@ -462,7 +469,9 @@ typedef struct {
|
||||||
int32_t tz; // query client timezone
|
int32_t tz; // query client timezone
|
||||||
char intervalUnit;
|
char intervalUnit;
|
||||||
char slidingUnit;
|
char slidingUnit;
|
||||||
char offsetUnit;
|
char
|
||||||
|
offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
|
||||||
|
int8_t precision;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
|
@ -472,10 +481,9 @@ typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} SQueryTableRsp;
|
} SQueryTableRsp;
|
||||||
|
|
||||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
||||||
|
|
||||||
int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
|
||||||
|
|
||||||
|
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -499,10 +507,13 @@ typedef struct {
|
||||||
int8_t cacheLastRow;
|
int8_t cacheLastRow;
|
||||||
int8_t ignoreExist;
|
int8_t ignoreExist;
|
||||||
int8_t streamMode;
|
int8_t streamMode;
|
||||||
|
int32_t numOfRetensions;
|
||||||
|
SArray* pRetensions; // SRetention
|
||||||
} SCreateDbReq;
|
} SCreateDbReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
||||||
int32_t tDeserializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
int32_t tDeserializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
||||||
|
void tFreeSCreateDbReq(SCreateDbReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -747,11 +758,13 @@ typedef struct {
|
||||||
int8_t selfIndex;
|
int8_t selfIndex;
|
||||||
int8_t streamMode;
|
int8_t streamMode;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
|
int32_t numOfRetensions;
|
||||||
|
SArray* pRetensions; // SRetention
|
||||||
} SCreateVnodeReq, SAlterVnodeReq;
|
} SCreateVnodeReq, SAlterVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||||
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||||
|
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
|
@ -888,14 +901,14 @@ typedef struct {
|
||||||
} SRetrieveTableRsp;
|
} SRetrieveTableRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t handle;
|
int64_t handle;
|
||||||
int64_t useconds;
|
int64_t useconds;
|
||||||
int8_t completed; // all results are returned to client
|
int8_t completed; // all results are returned to client
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
int8_t compressed;
|
int8_t compressed;
|
||||||
int32_t compLen;
|
int32_t compLen;
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
char data[];
|
char data[];
|
||||||
} SRetrieveMetaTableRsp;
|
} SRetrieveMetaTableRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1147,7 +1160,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
char outputTbName[TSDB_TABLE_NAME_LEN];
|
char outputSTbName[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* ast;
|
char* ast;
|
||||||
|
@ -1296,7 +1309,7 @@ typedef struct {
|
||||||
} SMqRebSubscribe;
|
} SMqRebSubscribe;
|
||||||
|
|
||||||
static FORCE_INLINE SMqRebSubscribe* tNewSMqRebSubscribe(const char* key) {
|
static FORCE_INLINE SMqRebSubscribe* tNewSMqRebSubscribe(const char* key) {
|
||||||
SMqRebSubscribe* pRebSub = (SMqRebSubscribe*)calloc(1, sizeof(SMqRebSubscribe));
|
SMqRebSubscribe* pRebSub = (SMqRebSubscribe*)taosMemoryCalloc(1, sizeof(SMqRebSubscribe));
|
||||||
if (pRebSub == NULL) {
|
if (pRebSub == NULL) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -1318,7 +1331,7 @@ _err:
|
||||||
taosArrayDestroy(pRebSub->lostConsumers);
|
taosArrayDestroy(pRebSub->lostConsumers);
|
||||||
taosArrayDestroy(pRebSub->removedConsumers);
|
taosArrayDestroy(pRebSub->removedConsumers);
|
||||||
taosArrayDestroy(pRebSub->newConsumers);
|
taosArrayDestroy(pRebSub->newConsumers);
|
||||||
tfree(pRebSub);
|
taosMemoryFreeClear(pRebSub);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,12 +1438,11 @@ int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq);
|
||||||
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
|
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray* rspList; // SArray<SVCreateTbRsp>
|
SArray* rspList; // SArray<SVCreateTbRsp>
|
||||||
} SVCreateTbBatchRsp;
|
} SVCreateTbBatchRsp;
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp);
|
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp);
|
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
|
@ -1620,7 +1632,7 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
|
||||||
void* pIter = taosHashIterate(info, NULL);
|
void* pIter = taosHashIterate(info, NULL);
|
||||||
while (pIter != NULL) {
|
while (pIter != NULL) {
|
||||||
SKv* kv = (SKv*)pIter;
|
SKv* kv = (SKv*)pIter;
|
||||||
tfree(kv->value);
|
taosMemoryFreeClear(kv->value);
|
||||||
pIter = taosHashIterate(info, pIter);
|
pIter = taosHashIterate(info, pIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1643,13 +1655,13 @@ static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq, bool deep) {
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroy(req->reqs);
|
taosArrayDestroy(req->reqs);
|
||||||
}
|
}
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tFreeClientKv(void* pKv) {
|
static FORCE_INLINE void tFreeClientKv(void* pKv) {
|
||||||
SKv* kv = (SKv*)pKv;
|
SKv* kv = (SKv*)pKv;
|
||||||
if (kv) {
|
if (kv) {
|
||||||
tfree(kv->value);
|
taosMemoryFreeClear(kv->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1676,7 +1688,7 @@ static FORCE_INLINE int32_t tEncodeSKv(SCoder* pEncoder, const SKv* pKv) {
|
||||||
static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
|
static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) {
|
||||||
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pKv->key) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pKv->valueLen) < 0) return -1;
|
||||||
pKv->value = malloc(pKv->valueLen + 1);
|
pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
|
||||||
if (pKv->value == NULL) return -1;
|
if (pKv->value == NULL) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, (char*)pKv->value) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1930,7 +1942,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) {
|
static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) {
|
||||||
buf = taosDecodeFixedU32(buf, &pSW->nCols);
|
buf = taosDecodeFixedU32(buf, &pSW->nCols);
|
||||||
pSW->pSchema = (SSchema*)calloc(pSW->nCols, sizeof(SSchema));
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
if (pSW->pSchema == NULL) {
|
if (pSW->pSchema == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1940,12 +1952,47 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
|
char stb[TSDB_TABLE_FNAME_LEN];
|
||||||
|
int8_t igExists;
|
||||||
|
int8_t intervalUnit;
|
||||||
|
int8_t slidingUnit;
|
||||||
|
int8_t timezone;
|
||||||
|
int32_t dstVgId; // for stream
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
int32_t exprLen; // strlen + 1
|
||||||
|
int32_t tagsFilterLen; // strlen + 1
|
||||||
|
int32_t sqlLen; // strlen + 1
|
||||||
|
int32_t astLen; // strlen + 1
|
||||||
|
char* expr;
|
||||||
|
char* tagsFilter;
|
||||||
|
char* sql;
|
||||||
|
char* ast;
|
||||||
|
} SMCreateSmaReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||||
|
int32_t tDeserializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||||
|
void tFreeSMCreateSmaReq(SMCreateSmaReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
|
int8_t igNotExists;
|
||||||
|
} SMDropSmaReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||||
|
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t version; // for compatibility(default 0)
|
int8_t version; // for compatibility(default 0)
|
||||||
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
||||||
int8_t slidingUnit; // MACRO: TIME_UNIT_XXX
|
int8_t slidingUnit; // MACRO: TIME_UNIT_XXX
|
||||||
|
int8_t timezoneInt; // sma data expired if timezone changes.
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
char timezone[TD_TIMEZONE_LEN]; // sma data expired if timezone changes.
|
char timezone[TD_TIMEZONE_LEN];
|
||||||
int32_t exprLen;
|
int32_t exprLen;
|
||||||
int32_t tagsFilterLen;
|
int32_t tagsFilterLen;
|
||||||
int64_t indexUid;
|
int64_t indexUid;
|
||||||
|
@ -2030,8 +2077,8 @@ typedef struct {
|
||||||
|
|
||||||
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
|
static FORCE_INLINE void tdDestroyTSma(STSma* pSma) {
|
||||||
if (pSma) {
|
if (pSma) {
|
||||||
tfree(pSma->expr);
|
taosMemoryFreeClear(pSma->expr);
|
||||||
tfree(pSma->tagsFilter);
|
taosMemoryFreeClear(pSma->tagsFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2041,19 +2088,24 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
|
||||||
for (uint32_t i = 0; i < pSW->number; ++i) {
|
for (uint32_t i = 0; i < pSW->number; ++i) {
|
||||||
tdDestroyTSma(pSW->tSma + i);
|
tdDestroyTSma(pSW->tSma + i);
|
||||||
}
|
}
|
||||||
tfree(pSW->tSma);
|
taosMemoryFreeClear(pSW->tSma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdFreeTSmaWrapper(STSmaWrapper* pSW) {
|
||||||
|
tdDestroyTSmaWrapper(pSW);
|
||||||
|
taosMemoryFreeClear(pSW);
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSma->version);
|
tlen += taosEncodeFixedI8(buf, pSma->version);
|
||||||
tlen += taosEncodeFixedI8(buf, pSma->intervalUnit);
|
tlen += taosEncodeFixedI8(buf, pSma->intervalUnit);
|
||||||
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
|
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSma->timezoneInt);
|
||||||
tlen += taosEncodeString(buf, pSma->indexName);
|
tlen += taosEncodeString(buf, pSma->indexName);
|
||||||
tlen += taosEncodeString(buf, pSma->timezone);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pSma->exprLen);
|
tlen += taosEncodeFixedI32(buf, pSma->exprLen);
|
||||||
tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen);
|
tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen);
|
||||||
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
|
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
|
||||||
|
@ -2087,8 +2139,8 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
||||||
buf = taosDecodeFixedI8(buf, &pSma->version);
|
buf = taosDecodeFixedI8(buf, &pSma->version);
|
||||||
buf = taosDecodeFixedI8(buf, &pSma->intervalUnit);
|
buf = taosDecodeFixedI8(buf, &pSma->intervalUnit);
|
||||||
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
|
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pSma->timezoneInt);
|
||||||
buf = taosDecodeStringTo(buf, pSma->indexName);
|
buf = taosDecodeStringTo(buf, pSma->indexName);
|
||||||
buf = taosDecodeStringTo(buf, pSma->timezone);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pSma->exprLen);
|
buf = taosDecodeFixedI32(buf, &pSma->exprLen);
|
||||||
buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen);
|
buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen);
|
||||||
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
|
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
|
||||||
|
@ -2121,7 +2173,7 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
||||||
static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
|
static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
|
||||||
buf = taosDecodeFixedU32(buf, &pSW->number);
|
buf = taosDecodeFixedU32(buf, &pSW->number);
|
||||||
|
|
||||||
pSW->tSma = (STSma*)calloc(pSW->number, sizeof(STSma));
|
pSW->tSma = (STSma*)taosMemoryCalloc(pSW->number, sizeof(STSma));
|
||||||
if (pSW->tSma == NULL) {
|
if (pSW->tSma == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2131,7 +2183,7 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
|
||||||
for (uint32_t j = i; j >= 0; --i) {
|
for (uint32_t j = i; j >= 0; --i) {
|
||||||
tdDestroyTSma(pSW->tSma + j);
|
tdDestroyTSma(pSW->tSma + j);
|
||||||
}
|
}
|
||||||
free(pSW->tSma);
|
taosMemoryFree(pSW->tSma);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2306,68 +2358,6 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
|
||||||
STREAM_TASK_STATUS__RUNNING = 1,
|
|
||||||
STREAM_TASK_STATUS__STOP,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void* inputHandle;
|
|
||||||
void* executor;
|
|
||||||
} SStreamRunner;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int64_t streamId;
|
|
||||||
int32_t taskId;
|
|
||||||
int32_t level;
|
|
||||||
int8_t status;
|
|
||||||
int8_t pipeSource;
|
|
||||||
int8_t pipeSink;
|
|
||||||
int8_t numOfRunners;
|
|
||||||
int8_t parallelizable;
|
|
||||||
SEpSet NextOpEp;
|
|
||||||
char* qmsg;
|
|
||||||
// not applied to encoder and decoder
|
|
||||||
SStreamRunner runner[8];
|
|
||||||
// void* executor;
|
|
||||||
// void* stateStore;
|
|
||||||
// storage handle
|
|
||||||
} SStreamTask;
|
|
||||||
|
|
||||||
static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level) {
|
|
||||||
SStreamTask* pTask = (SStreamTask*)calloc(1, sizeof(SStreamTask));
|
|
||||||
if (pTask == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pTask->taskId = tGenIdPI32();
|
|
||||||
pTask->status = STREAM_TASK_STATUS__RUNNING;
|
|
||||||
pTask->qmsg = NULL;
|
|
||||||
return pTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask);
|
|
||||||
int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask);
|
|
||||||
void tFreeSStreamTask(SStreamTask* pTask);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SMsgHead head;
|
|
||||||
SStreamTask* task;
|
|
||||||
} SStreamTaskDeployReq;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t reserved;
|
|
||||||
} SStreamTaskDeployRsp;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SStreamExecMsgHead head;
|
|
||||||
SArray* data; // SArray<SSDataBlock>
|
|
||||||
} SStreamTaskExecReq;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t reserved;
|
|
||||||
} SStreamTaskExecRsp;
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -25,7 +25,15 @@ extern "C" {
|
||||||
typedef struct SRpcMsg SRpcMsg;
|
typedef struct SRpcMsg SRpcMsg;
|
||||||
typedef struct SEpSet SEpSet;
|
typedef struct SEpSet SEpSet;
|
||||||
typedef struct SMgmtWrapper SMgmtWrapper;
|
typedef struct SMgmtWrapper SMgmtWrapper;
|
||||||
typedef enum { QUERY_QUEUE, FETCH_QUEUE, WRITE_QUEUE, APPLY_QUEUE, SYNC_QUEUE, QUEUE_MAX } EQueueType;
|
typedef enum {
|
||||||
|
QUERY_QUEUE,
|
||||||
|
FETCH_QUEUE,
|
||||||
|
WRITE_QUEUE,
|
||||||
|
APPLY_QUEUE,
|
||||||
|
SYNC_QUEUE,
|
||||||
|
MERGE_QUEUE,
|
||||||
|
QUEUE_MAX,
|
||||||
|
} EQueueType;
|
||||||
|
|
||||||
typedef int32_t (*PutToQueueFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
typedef int32_t (*PutToQueueFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
||||||
typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueType qtype);
|
typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueType qtype);
|
||||||
|
|
|
@ -127,6 +127,8 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_STB, "mnode-create-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_STB, "mnode-create-stb", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_STB, "mnode-alter-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_STB, "mnode-alter-stb", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_STB, "mnode-drop-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_DROP_STB, "mnode-drop-stb", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_SMA, "mnode-create-sma", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_DROP_SMA, "mnode-drop-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_META, "mnode-table-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_META, "mnode-table-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_VGROUP_LIST, "mnode-vgroup-list", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_VGROUP_LIST, "mnode-vgroup-list", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_QNODE_LIST, "mnode-qnode-list", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_QNODE_LIST, "mnode-qnode-list", NULL, NULL)
|
||||||
|
@ -191,6 +193,10 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqCVConsumeReq, SMqCVConsumeRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqCVConsumeReq, SMqCVConsumeRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_DEPLOY, "vnode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_TASK_DEPLOY, "vnode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TASK_EXEC, "vnode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_TASK_EXEC, "vnode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_TASK_PIPE_EXEC, "vnode-task-pipe-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_TASK_MERGE_EXEC, "vnode-task-merge-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_TASK_WRITE_EXEC, "vnode-task-write-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL)
|
||||||
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||||
|
@ -203,6 +209,8 @@ enum {
|
||||||
TD_NEW_MSG_SEG(TDMT_SND_MSG)
|
TD_NEW_MSG_SEG(TDMT_SND_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SND_TASK_PIPE_EXEC, "snode-task-pipe-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SND_TASK_MERGE_EXEC, "snode-task-merge-exec", SStreamTaskExecReq, SStreamTaskExecRsp)
|
||||||
|
|
||||||
#if defined(TD_MSG_NUMBER_)
|
#if defined(TD_MSG_NUMBER_)
|
||||||
TDMT_MAX
|
TDMT_MAX
|
||||||
|
|
|
@ -166,6 +166,7 @@ typedef struct {
|
||||||
#define TD_ROW_HEAD_LEN (sizeof(STSRow))
|
#define TD_ROW_HEAD_LEN (sizeof(STSRow))
|
||||||
#define TD_ROW_NCOLS_LEN (sizeof(col_id_t))
|
#define TD_ROW_NCOLS_LEN (sizeof(col_id_t))
|
||||||
|
|
||||||
|
#define TD_ROW_INFO(r) ((r)->info)
|
||||||
#define TD_ROW_TYPE(r) ((r)->type)
|
#define TD_ROW_TYPE(r) ((r)->type)
|
||||||
#define TD_ROW_DELETE(r) ((r)->del)
|
#define TD_ROW_DELETE(r) ((r)->del)
|
||||||
#define TD_ROW_ENDIAN(r) ((r)->endian)
|
#define TD_ROW_ENDIAN(r) ((r)->endian)
|
||||||
|
@ -180,6 +181,7 @@ typedef struct {
|
||||||
// (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined.
|
// (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined.
|
||||||
#define TD_ROW_MAX_BYTES_FROM_SCHEMA(s) (schemaTLen(s) + TD_ROW_HEAD_LEN)
|
#define TD_ROW_MAX_BYTES_FROM_SCHEMA(s) (schemaTLen(s) + TD_ROW_HEAD_LEN)
|
||||||
|
|
||||||
|
#define TD_ROW_SET_INFO(r, i) (TD_ROW_INFO(r) = (i))
|
||||||
#define TD_ROW_SET_TYPE(r, t) (TD_ROW_TYPE(r) = (t))
|
#define TD_ROW_SET_TYPE(r, t) (TD_ROW_TYPE(r) = (t))
|
||||||
#define TD_ROW_SET_DELETE(r) (TD_ROW_DELETE(r) = 1)
|
#define TD_ROW_SET_DELETE(r) (TD_ROW_DELETE(r) = 1)
|
||||||
#define TD_ROW_SET_SVER(r, v) (TD_ROW_SVER(r) = (v))
|
#define TD_ROW_SET_SVER(r, v) (TD_ROW_SVER(r) = (v))
|
||||||
|
@ -473,6 +475,7 @@ static int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TD_ROW_SET_INFO(pBuilder->pBuf, 0);
|
||||||
TD_ROW_SET_TYPE(pBuilder->pBuf, pBuilder->rowType);
|
TD_ROW_SET_TYPE(pBuilder->pBuf, pBuilder->rowType);
|
||||||
|
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
|
|
|
@ -159,6 +159,7 @@ typedef struct {
|
||||||
(IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
(IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
||||||
#define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL))
|
#define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL))
|
||||||
|
|
||||||
|
// TODO remove this function
|
||||||
static FORCE_INLINE bool isNull(const void *val, int32_t type) {
|
static FORCE_INLINE bool isNull(const void *val, int32_t type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
#define _TD_MND_H_
|
#define _TD_MND_H_
|
||||||
|
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
#include "tmsg.h"
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -119,10 +119,11 @@ typedef enum {
|
||||||
SDB_CONSUMER = 13,
|
SDB_CONSUMER = 13,
|
||||||
SDB_TOPIC = 14,
|
SDB_TOPIC = 14,
|
||||||
SDB_VGROUP = 15,
|
SDB_VGROUP = 15,
|
||||||
SDB_STB = 16,
|
SDB_SMA = 16,
|
||||||
SDB_DB = 17,
|
SDB_STB = 17,
|
||||||
SDB_FUNC = 18,
|
SDB_DB = 18,
|
||||||
SDB_MAX = 19
|
SDB_FUNC = 19,
|
||||||
|
SDB_MAX = 20
|
||||||
} ESdbType;
|
} ESdbType;
|
||||||
|
|
||||||
typedef struct SSdb SSdb;
|
typedef struct SSdb SSdb;
|
||||||
|
|
|
@ -327,7 +327,7 @@ bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||||
|
|
||||||
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||||
int64_t slidingTime, int8_t slidingUnit, int8_t precision, int32_t fillType,
|
int64_t slidingTime, int8_t slidingUnit, int8_t precision, int32_t fillType,
|
||||||
struct SFillColInfo* pFillCol, void* handle);
|
struct SFillColInfo* pFillCol, const char* id);
|
||||||
|
|
||||||
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
|
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
|
||||||
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, void** output, int32_t capacity);
|
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, void** output, int32_t capacity);
|
||||||
|
|
|
@ -199,6 +199,7 @@ typedef struct SIndexOptions {
|
||||||
typedef struct SCreateIndexStmt {
|
typedef struct SCreateIndexStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
EIndexType indexType;
|
EIndexType indexType;
|
||||||
|
bool ignoreExists;
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
SNodeList* pCols;
|
SNodeList* pCols;
|
||||||
|
@ -207,6 +208,7 @@ typedef struct SCreateIndexStmt {
|
||||||
|
|
||||||
typedef struct SDropIndexStmt {
|
typedef struct SDropIndexStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
|
bool ignoreNotExists;
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
char tableName[TSDB_TABLE_NAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
} SDropIndexStmt;
|
} SDropIndexStmt;
|
||||||
|
|
|
@ -135,6 +135,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
||||||
QUERY_NODE_PHYSICAL_SUBPLAN,
|
QUERY_NODE_PHYSICAL_SUBPLAN,
|
||||||
|
@ -169,6 +170,7 @@ void nodesDestroyNode(SNodeptr pNode);
|
||||||
SNodeList* nodesMakeList();
|
SNodeList* nodesMakeList();
|
||||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
||||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
||||||
|
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode);
|
||||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||||
|
|
|
@ -95,6 +95,7 @@ typedef struct SWindowLogicNode {
|
||||||
int8_t intervalUnit;
|
int8_t intervalUnit;
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
SFillNode* pFill;
|
SFillNode* pFill;
|
||||||
|
int64_t sessionGap;
|
||||||
} SWindowLogicNode;
|
} SWindowLogicNode;
|
||||||
|
|
||||||
typedef enum ESubplanType {
|
typedef enum ESubplanType {
|
||||||
|
@ -110,7 +111,7 @@ typedef struct SSubplanId {
|
||||||
int32_t subplanId;
|
int32_t subplanId;
|
||||||
} SSubplanId;
|
} SSubplanId;
|
||||||
|
|
||||||
typedef struct SSubLogicPlan {
|
typedef struct SLogicSubplan {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SSubplanId id;
|
SSubplanId id;
|
||||||
SNodeList* pChildren;
|
SNodeList* pChildren;
|
||||||
|
@ -120,7 +121,7 @@ typedef struct SSubLogicPlan {
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t splitFlag;
|
int32_t splitFlag;
|
||||||
} SSubLogicPlan;
|
} SLogicSubplan;
|
||||||
|
|
||||||
typedef struct SQueryLogicPlan {
|
typedef struct SQueryLogicPlan {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
|
@ -213,10 +214,14 @@ typedef struct SExchangePhysiNode {
|
||||||
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
||||||
} SExchangePhysiNode;
|
} SExchangePhysiNode;
|
||||||
|
|
||||||
typedef struct SIntervalPhysiNode {
|
typedef struct SWinodwPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pExprs; // these are expression list of parameter expression of function
|
SNodeList* pExprs; // these are expression list of parameter expression of function
|
||||||
SNodeList* pFuncs;
|
SNodeList* pFuncs;
|
||||||
|
} SWinodwPhysiNode;
|
||||||
|
|
||||||
|
typedef struct SIntervalPhysiNode {
|
||||||
|
SWinodwPhysiNode window;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
|
@ -225,6 +230,11 @@ typedef struct SIntervalPhysiNode {
|
||||||
SFillNode* pFill;
|
SFillNode* pFill;
|
||||||
} SIntervalPhysiNode;
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
|
typedef struct SSessionWinodwPhysiNode {
|
||||||
|
SWinodwPhysiNode window;
|
||||||
|
int64_t gap;
|
||||||
|
} SSessionWinodwPhysiNode;
|
||||||
|
|
||||||
typedef struct SDataSinkNode {
|
typedef struct SDataSinkNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SDataBlockDescNode* pInputDataBlockDesc;
|
SDataBlockDescNode* pInputDataBlockDesc;
|
||||||
|
|
|
@ -191,8 +191,8 @@ typedef struct SStateWindowNode {
|
||||||
|
|
||||||
typedef struct SSessionWindowNode {
|
typedef struct SSessionWindowNode {
|
||||||
ENodeType type; // QUERY_NODE_SESSION_WINDOW
|
ENodeType type; // QUERY_NODE_SESSION_WINDOW
|
||||||
int64_t gap; // gap between two session window(in microseconds)
|
|
||||||
SNode* pCol;
|
SNode* pCol;
|
||||||
|
SNode* pGap; // gap between two session window(in microseconds)
|
||||||
} SSessionWindowNode;
|
} SSessionWindowNode;
|
||||||
|
|
||||||
typedef struct SIntervalWindowNode {
|
typedef struct SIntervalWindowNode {
|
||||||
|
|
|
@ -60,6 +60,8 @@ int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
|
||||||
|
|
||||||
void qDestroyQuery(SQuery* pQueryNode);
|
void qDestroyQuery(SQuery* pQueryNode);
|
||||||
|
|
||||||
|
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,198 @@
|
||||||
|
/*
|
||||||
|
* 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 "tdatablock.h"
|
||||||
|
#include "tmsg.h"
|
||||||
|
#include "tmsgcb.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _TSTREAM_H_
|
||||||
|
#define _TSTREAM_H_
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STREAM_TASK_STATUS__RUNNING = 1,
|
||||||
|
STREAM_TASK_STATUS__STOP,
|
||||||
|
};
|
||||||
|
|
||||||
|
// pipe -> fetch/pipe queue
|
||||||
|
// merge -> merge queue
|
||||||
|
// write -> write queue
|
||||||
|
enum {
|
||||||
|
TASK_SINK_MSG__SND_PIPE = 1,
|
||||||
|
TASK_SINK_MSG__SND_MERGE,
|
||||||
|
TASK_SINK_MSG__VND_PIPE,
|
||||||
|
TASK_SINK_MSG__VND_MERGE,
|
||||||
|
TASK_SINK_MSG__VND_WRITE,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t nodeId; // 0 for snode
|
||||||
|
SEpSet epSet;
|
||||||
|
} SStreamTaskEp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void* inputHandle;
|
||||||
|
void* executor;
|
||||||
|
} SStreamRunner;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t parallelizable;
|
||||||
|
char* qmsg;
|
||||||
|
// followings are not applicable to encoder and decoder
|
||||||
|
int8_t numOfRunners;
|
||||||
|
SStreamRunner* runners;
|
||||||
|
} STaskExec;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} STaskDispatcherInplace;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t nodeId;
|
||||||
|
SEpSet epSet;
|
||||||
|
} STaskDispatcherFixedEp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t hashMethod;
|
||||||
|
SArray* info;
|
||||||
|
} STaskDispatcherShuffle;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
// not applicable to encoder and decoder
|
||||||
|
SHashObj* pHash; // groupId to tbuid
|
||||||
|
} STaskSinkTb;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} STaskSinkSma;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} STaskSinkFetch;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t reserved;
|
||||||
|
} STaskSinkShow;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_SOURCE__SCAN = 1,
|
||||||
|
TASK_SOURCE__SINGLE,
|
||||||
|
TASK_SOURCE__MULTI,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_EXEC__NONE = 1,
|
||||||
|
TASK_EXEC__EXEC,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_DISPATCH__NONE = 1,
|
||||||
|
TASK_DISPATCH__INPLACE,
|
||||||
|
TASK_DISPATCH__FIXED,
|
||||||
|
TASK_DISPATCH__SHUFFLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_SINK__NONE = 1,
|
||||||
|
TASK_SINK__TABLE,
|
||||||
|
TASK_SINK__SMA,
|
||||||
|
TASK_SINK__FETCH,
|
||||||
|
TASK_SINK__SHOW,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t streamId;
|
||||||
|
int32_t taskId;
|
||||||
|
int8_t status;
|
||||||
|
|
||||||
|
int8_t sourceType;
|
||||||
|
int8_t execType;
|
||||||
|
int8_t sinkType;
|
||||||
|
int8_t dispatchType;
|
||||||
|
int16_t dispatchMsgType;
|
||||||
|
int32_t downstreamTaskId;
|
||||||
|
|
||||||
|
// source preprocess
|
||||||
|
|
||||||
|
// exec
|
||||||
|
STaskExec exec;
|
||||||
|
|
||||||
|
// local sink
|
||||||
|
union {
|
||||||
|
STaskSinkTb tbSink;
|
||||||
|
STaskSinkSma smaSink;
|
||||||
|
STaskSinkFetch fetchSink;
|
||||||
|
STaskSinkShow showSink;
|
||||||
|
};
|
||||||
|
|
||||||
|
// dispatch
|
||||||
|
union {
|
||||||
|
STaskDispatcherInplace inplaceDispatcher;
|
||||||
|
STaskDispatcherFixedEp fixedEpDispatcher;
|
||||||
|
STaskDispatcherShuffle shuffleDispatcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
// state storage
|
||||||
|
|
||||||
|
} SStreamTask;
|
||||||
|
|
||||||
|
SStreamTask* tNewSStreamTask(int64_t streamId);
|
||||||
|
int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask);
|
||||||
|
int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask);
|
||||||
|
void tFreeSStreamTask(SStreamTask* pTask);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// SMsgHead head;
|
||||||
|
SStreamTask* task;
|
||||||
|
} SStreamTaskDeployReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t reserved;
|
||||||
|
} SStreamTaskDeployRsp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// SMsgHead head;
|
||||||
|
int64_t streamId;
|
||||||
|
int32_t taskId;
|
||||||
|
SArray* data; // SArray<SSDataBlock>
|
||||||
|
} SStreamTaskExecReq;
|
||||||
|
|
||||||
|
int32_t tEncodeSStreamTaskExecReq(void** buf, const SStreamTaskExecReq* pReq);
|
||||||
|
void* tDecodeSStreamTaskExecReq(const void* buf, SStreamTaskExecReq* pReq);
|
||||||
|
void tFreeSStreamTaskExecReq(SStreamTaskExecReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t reserved;
|
||||||
|
} SStreamTaskExecRsp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// SMsgHead head;
|
||||||
|
int64_t streamId;
|
||||||
|
int64_t version;
|
||||||
|
SArray* res; // SArray<SSDataBlock>
|
||||||
|
} SStreamSinkReq;
|
||||||
|
|
||||||
|
int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, int32_t inputType, int32_t workId);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ifndef _TSTREAM_H_ */
|
|
@ -35,6 +35,7 @@ typedef enum {
|
||||||
TAOS_SYNC_STATE_FOLLOWER = 100,
|
TAOS_SYNC_STATE_FOLLOWER = 100,
|
||||||
TAOS_SYNC_STATE_CANDIDATE = 101,
|
TAOS_SYNC_STATE_CANDIDATE = 101,
|
||||||
TAOS_SYNC_STATE_LEADER = 102,
|
TAOS_SYNC_STATE_LEADER = 102,
|
||||||
|
TAOS_SYNC_STATE_ERROR = 103,
|
||||||
} ESyncState;
|
} ESyncState;
|
||||||
|
|
||||||
typedef struct SSyncBuffer {
|
typedef struct SSyncBuffer {
|
||||||
|
@ -68,17 +69,20 @@ typedef struct SSnapshot {
|
||||||
typedef struct SSyncFSM {
|
typedef struct SSyncFSM {
|
||||||
void* data;
|
void* data;
|
||||||
|
|
||||||
// when value in pBuf finish a raft flow, FpCommitCb is called, code indicates the result
|
// when value in pMsg finish a raft flow, FpCommitCb is called, code indicates the result
|
||||||
// user can do something according to the code and isWeak. for example, write data into tsdb
|
// user can do something according to the code and isWeak. for example, write data into tsdb
|
||||||
void (*FpCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pBuf, SyncIndex index, bool isWeak, int32_t code);
|
void (*FpCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||||
|
ESyncState state);
|
||||||
|
|
||||||
// when value in pBuf has been written into local log store, FpPreCommitCb is called, code indicates the result
|
// when value in pMsg has been written into local log store, FpPreCommitCb is called, code indicates the result
|
||||||
// user can do something according to the code and isWeak. for example, write data into tsdb
|
// user can do something according to the code and isWeak. for example, write data into tsdb
|
||||||
void (*FpPreCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pBuf, SyncIndex index, bool isWeak, int32_t code);
|
void (*FpPreCommitCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||||
|
ESyncState state);
|
||||||
|
|
||||||
// when log entry is updated by a new one, FpRollBackCb is called
|
// when log entry is updated by a new one, FpRollBackCb is called
|
||||||
// user can do something to roll back. for example, delete data from tsdb, or just ignore it
|
// user can do something to roll back. for example, delete data from tsdb, or just ignore it
|
||||||
void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pBuf, SyncIndex index, bool isWeak, int32_t code);
|
void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||||
|
ESyncState state);
|
||||||
|
|
||||||
// user should implement this function, use "data" to take snapshot into "snapshot"
|
// user should implement this function, use "data" to take snapshot into "snapshot"
|
||||||
int32_t (*FpTakeSnapshot)(SSnapshot* snapshot);
|
int32_t (*FpTakeSnapshot)(SSnapshot* snapshot);
|
||||||
|
@ -157,10 +161,14 @@ void syncCleanUp();
|
||||||
int64_t syncStart(const SSyncInfo* pSyncInfo);
|
int64_t syncStart(const SSyncInfo* pSyncInfo);
|
||||||
void syncStop(int64_t rid);
|
void syncStop(int64_t rid);
|
||||||
int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg);
|
int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg);
|
||||||
int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak); // use this function
|
int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak);
|
||||||
int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak); // just for compatibility
|
|
||||||
ESyncState syncGetMyRole(int64_t rid);
|
ESyncState syncGetMyRole(int64_t rid);
|
||||||
void syncGetNodesRole(int64_t rid, SNodesRole* pNodeRole);
|
|
||||||
|
// propose with sequence number, to implement linearizable semantics
|
||||||
|
int32_t syncPropose2(int64_t rid, const SRpcMsg* pMsg, bool isWeak, uint64_t seqNum);
|
||||||
|
|
||||||
|
// for compatibility, the same as syncPropose
|
||||||
|
int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak);
|
||||||
|
|
||||||
extern int32_t sDebugFlag;
|
extern int32_t sDebugFlag;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ typedef struct SRpcInit {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void * val;
|
void * val;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
void (*free)(void *arg);
|
void (*freeFunc)(const void *arg);
|
||||||
} SRpcCtxVal;
|
} SRpcCtxVal;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -20,12 +20,25 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define tfree(x) \
|
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||||
do { \
|
// When you want to use this feature, you should find or add the same function in the following sectio
|
||||||
if (x) { \
|
#ifndef ALLOW_FORBID_FUNC
|
||||||
free((void *)(x)); \
|
#define malloc MALLOC_FUNC_TAOS_FORBID
|
||||||
(x) = 0; \
|
#define calloc CALLOC_FUNC_TAOS_FORBID
|
||||||
} \
|
#define realloc REALLOC_FUNC_TAOS_FORBID
|
||||||
|
#define free FREE_FUNC_TAOS_FORBID
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void *taosMemoryMalloc(int32_t size);
|
||||||
|
void *taosMemoryCalloc(int32_t num, int32_t size);
|
||||||
|
void *taosMemoryRealloc(void *ptr, int32_t size);
|
||||||
|
void taosMemoryFree(const void *ptr);
|
||||||
|
int32_t taosMemorySize(void *ptr);
|
||||||
|
|
||||||
|
#define taosMemoryFreeClear(ptr) \
|
||||||
|
do { \
|
||||||
|
taosMemoryFree(ptr); \
|
||||||
|
(ptr)=NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -51,10 +51,31 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
#if defined(WINDOWS)
|
||||||
#define htobe64 htonll
|
#define htobe64 htonll
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
|
#define TAOS_EPOLL_WAIT_TIME 100
|
||||||
|
typedef SOCKET eventfd_t;
|
||||||
|
#define eventfd(a, b) -1
|
||||||
|
typedef SOCKET EpollFd;
|
||||||
|
#define EpollClose(pollFd) epoll_close(pollFd)
|
||||||
|
#ifndef EPOLLWAKEUP
|
||||||
|
#define EPOLLWAKEUP (1u << 29)
|
||||||
|
#endif
|
||||||
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
#define TAOS_EPOLL_WAIT_TIME 500
|
||||||
|
typedef int32_t SOCKET;
|
||||||
|
typedef SOCKET EpollFd;
|
||||||
|
#define EpollClose(pollFd) epoll_close(pollFd)
|
||||||
|
#else
|
||||||
|
#define TAOS_EPOLL_WAIT_TIME 500
|
||||||
|
typedef int32_t SOCKET;
|
||||||
|
typedef SOCKET EpollFd;
|
||||||
|
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_DARWIN_64)
|
#if defined(_TD_DARWIN_64)
|
||||||
// #define htobe64 htonll
|
// #define htobe64 htonll
|
||||||
|
|
||||||
|
@ -64,12 +85,12 @@ extern "C" {
|
||||||
# define htole16(x) OSSwapHostToLittleInt16(x)
|
# define htole16(x) OSSwapHostToLittleInt16(x)
|
||||||
# define be16toh(x) OSSwapBigToHostInt16(x)
|
# define be16toh(x) OSSwapBigToHostInt16(x)
|
||||||
# define le16toh(x) OSSwapLittleToHostInt16(x)
|
# define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||||
|
|
||||||
# define htobe32(x) OSSwapHostToBigInt32(x)
|
# define htobe32(x) OSSwapHostToBigInt32(x)
|
||||||
# define htole32(x) OSSwapHostToLittleInt32(x)
|
# define htole32(x) OSSwapHostToLittleInt32(x)
|
||||||
# define be32toh(x) OSSwapBigToHostInt32(x)
|
# define be32toh(x) OSSwapBigToHostInt32(x)
|
||||||
# define le32toh(x) OSSwapLittleToHostInt32(x)
|
# define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||||
|
|
||||||
# define htobe64(x) OSSwapHostToBigInt64(x)
|
# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||||
# define htole64(x) OSSwapHostToLittleInt64(x)
|
# define htole64(x) OSSwapHostToLittleInt64(x)
|
||||||
# define be64toh(x) OSSwapBigToHostInt64(x)
|
# define be64toh(x) OSSwapBigToHostInt64(x)
|
||||||
|
@ -83,6 +104,17 @@ extern "C" {
|
||||||
|
|
||||||
#define TAOS_EPOLL_WAIT_TIME 500
|
#define TAOS_EPOLL_WAIT_TIME 500
|
||||||
|
|
||||||
|
typedef int32_t SocketFd;
|
||||||
|
typedef SocketFd EpollFd;
|
||||||
|
|
||||||
|
typedef struct TdSocket {
|
||||||
|
#if SOCKET_WITH_LOCK
|
||||||
|
TdThreadRwlock rwlock;
|
||||||
|
#endif
|
||||||
|
int refId;
|
||||||
|
SocketFd fd;
|
||||||
|
} *TdSocketPtr, TdSocket;
|
||||||
|
|
||||||
typedef struct TdSocketServer *TdSocketServerPtr;
|
typedef struct TdSocketServer *TdSocketServerPtr;
|
||||||
typedef struct TdSocket *TdSocketPtr;
|
typedef struct TdSocket *TdSocketPtr;
|
||||||
typedef struct TdEpoll *TdEpollPtr;
|
typedef struct TdEpoll *TdEpollPtr;
|
||||||
|
@ -91,6 +123,7 @@ int32_t taosSendto(TdSocketPtr pSocket, void * msg, int len, unsigned int flags,
|
||||||
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);
|
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||||
int32_t taosReadSocket(TdSocketPtr pSocket, void *msg, int len);
|
int32_t taosReadSocket(TdSocketPtr pSocket, void *msg, int len);
|
||||||
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, socklen_t *addrLen);
|
int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t flags, struct sockaddr *destAddr, socklen_t *addrLen);
|
||||||
|
int32_t taosCloseSocketNoCheck1(SocketFd fd);
|
||||||
int32_t taosCloseSocket(TdSocketPtr *ppSocket);
|
int32_t taosCloseSocket(TdSocketPtr *ppSocket);
|
||||||
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer);
|
int32_t taosCloseSocketServer(TdSocketServerPtr *ppSocketServer);
|
||||||
int32_t taosShutDownSocketRD(TdSocketPtr pSocket);
|
int32_t taosShutDownSocketRD(TdSocketPtr pSocket);
|
||||||
|
|
|
@ -274,18 +274,23 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_STREAM_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F1)
|
#define TSDB_CODE_MND_STREAM_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F1)
|
||||||
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
|
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
|
||||||
|
|
||||||
|
// mnode-sma
|
||||||
|
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0400)
|
||||||
|
#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0401)
|
||||||
|
#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0402)
|
||||||
|
|
||||||
// dnode
|
// dnode
|
||||||
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
|
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x04A0)
|
||||||
#define TSDB_CODE_DND_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401)
|
#define TSDB_CODE_DND_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x04A1)
|
||||||
#define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0402)
|
#define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x04A2)
|
||||||
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403)
|
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A3)
|
||||||
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0404)
|
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A4)
|
||||||
#define TSDB_CODE_NODE_PARSE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0405)
|
#define TSDB_CODE_NODE_PARSE_FILE_ERROR TAOS_DEF_ERROR_CODE(0, 0x04A5)
|
||||||
#define TSDB_CODE_NODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0406)
|
#define TSDB_CODE_NODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x04A6)
|
||||||
#define TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0410)
|
#define TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A7)
|
||||||
#define TSDB_CODE_DND_VNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0411)
|
#define TSDB_CODE_DND_VNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A8)
|
||||||
#define TSDB_CODE_DND_VNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x0412)
|
#define TSDB_CODE_DND_VNODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x04A9)
|
||||||
#define TSDB_CODE_DND_VNODE_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0413)
|
#define TSDB_CODE_DND_VNODE_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x04AA)
|
||||||
|
|
||||||
// vnode
|
// vnode
|
||||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
||||||
|
@ -309,7 +314,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513)
|
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513)
|
||||||
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514)
|
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514)
|
||||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
||||||
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0516)
|
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0516)
|
||||||
|
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0517)
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
|
@ -336,8 +342,9 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||||
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x0617)
|
#define TSDB_CODE_TDB_TABLE_RECREATED TAOS_DEF_ERROR_CODE(0, 0x0617)
|
||||||
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0618)
|
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0619)
|
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||||
|
#define TSDB_CODE_TDB_INVALID_SMA_STAT TAOS_DEF_ERROR_CODE(0, 0x0620)
|
||||||
|
|
||||||
// query
|
// query
|
||||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||||
|
@ -468,6 +475,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
||||||
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
||||||
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
||||||
|
#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ static FORCE_INLINE void *taosDecodeString(const void *buf, char **value) {
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
|
|
||||||
buf = taosDecodeVariantU64(buf, &size);
|
buf = taosDecodeVariantU64(buf, &size);
|
||||||
*value = (char *)malloc((size_t)size + 1);
|
*value = (char *)taosMemoryMalloc((size_t)size + 1);
|
||||||
|
|
||||||
if (*value == NULL) return NULL;
|
if (*value == NULL) return NULL;
|
||||||
memcpy(*value, buf, (size_t)size);
|
memcpy(*value, buf, (size_t)size);
|
||||||
|
@ -386,7 +386,7 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) {
|
static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) {
|
||||||
*value = malloc((size_t)valueLen);
|
*value = taosMemoryMalloc((size_t)valueLen);
|
||||||
if (*value == NULL) return NULL;
|
if (*value == NULL) return NULL;
|
||||||
memcpy(*value, buf, (size_t)valueLen);
|
memcpy(*value, buf, (size_t)valueLen);
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,10 @@ enum {
|
||||||
SND_WORKER_TYPE__UNIQUE,
|
SND_WORKER_TYPE__UNIQUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MND_VGID -1
|
||||||
|
#define QND_VGID 1
|
||||||
|
#define VND_VGID 0
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -406,7 +406,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uin
|
||||||
if (tDecodeU64v(pDecoder, len) < 0) return -1;
|
if (tDecodeU64v(pDecoder, len) < 0) return -1;
|
||||||
|
|
||||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1;
|
if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1;
|
||||||
*val = malloc(*len);
|
*val = taosMemoryMalloc(*len);
|
||||||
if (*val == NULL) return -1;
|
if (*val == NULL) return -1;
|
||||||
memcpy(*val, TD_CODER_CURRENT(pDecoder), *len);
|
memcpy(*val, TD_CODER_CURRENT(pDecoder), *len);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef TD_SLIST(SFreeListNode) SFreeList;
|
||||||
|
|
||||||
#define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \
|
#define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \
|
||||||
do { \
|
do { \
|
||||||
void *ptr = malloc((SIZE) + sizeof(struct SFreeListNode)); \
|
void *ptr = taosMemoryMalloc((SIZE) + sizeof(struct SFreeListNode)); \
|
||||||
if (ptr) { \
|
if (ptr) { \
|
||||||
TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \
|
TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \
|
||||||
ptr = ((struct SFreeListNode *)ptr)->payload; \
|
ptr = ((struct SFreeListNode *)ptr)->payload; \
|
||||||
|
@ -49,7 +49,7 @@ static FORCE_INLINE void tFreeListClear(SFreeList *pFL) {
|
||||||
pNode = TD_SLIST_HEAD(pFL);
|
pNode = TD_SLIST_HEAD(pFL);
|
||||||
if (pNode == NULL) break;
|
if (pNode == NULL) break;
|
||||||
TD_SLIST_POP(pFL);
|
TD_SLIST_POP(pFL);
|
||||||
free(pNode);
|
taosMemoryFree(pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ typedef struct {
|
||||||
#define listNEles(l) TD_DLIST_NELES(l)
|
#define listNEles(l) TD_DLIST_NELES(l)
|
||||||
#define listEleSize(l) ((l)->eleSize)
|
#define listEleSize(l) ((l)->eleSize)
|
||||||
#define isListEmpty(l) (TD_DLIST_NELES(l) == 0)
|
#define isListEmpty(l) (TD_DLIST_NELES(l) == 0)
|
||||||
#define listNodeFree(n) free(n)
|
#define listNodeFree(n) taosMemoryFree(n)
|
||||||
|
|
||||||
void tdListInit(SList *list, int32_t eleSize);
|
void tdListInit(SList *list, int32_t eleSize);
|
||||||
void tdListEmpty(SList *list);
|
void tdListEmpty(SList *list);
|
||||||
|
|
|
@ -84,6 +84,8 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
|
||||||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||||
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
|
#define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
typedef int32_t VarDataOffsetT;
|
typedef int32_t VarDataOffsetT;
|
||||||
|
|
||||||
typedef struct tstr {
|
typedef struct tstr {
|
||||||
|
|
|
@ -155,6 +155,7 @@ typedef struct SReqResultInfo {
|
||||||
TAOS_FIELD* fields;
|
TAOS_FIELD* fields;
|
||||||
uint32_t numOfCols;
|
uint32_t numOfCols;
|
||||||
int32_t* length;
|
int32_t* length;
|
||||||
|
char** convertBuf;
|
||||||
TAOS_ROW row;
|
TAOS_ROW row;
|
||||||
SResultColumn* pCol;
|
SResultColumn* pCol;
|
||||||
uint32_t numOfRows;
|
uint32_t numOfRows;
|
||||||
|
|
|
@ -115,11 +115,11 @@ void destroyTscObj(void *pObj) {
|
||||||
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||||
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||||
tfree(pTscObj);
|
taosMemoryFreeClear(pTscObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *createTscObj(const char *user, const char *auth, const char *db, SAppInstInfo *pAppInfo) {
|
void *createTscObj(const char *user, const char *auth, const char *db, SAppInstInfo *pAppInfo) {
|
||||||
STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj));
|
STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -143,7 +143,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
|
||||||
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
|
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
|
||||||
assert(pObj != NULL);
|
assert(pObj != NULL);
|
||||||
|
|
||||||
SRequestObj *pRequest = (SRequestObj *)calloc(1, sizeof(SRequestObj));
|
SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||||
if (NULL == pRequest) {
|
if (NULL == pRequest) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -156,7 +156,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
|
||||||
pRequest->type = type;
|
pRequest->type = type;
|
||||||
pRequest->pTscObj = pObj;
|
pRequest->pTscObj = pObj;
|
||||||
pRequest->body.fp = fp; // not used it yet
|
pRequest->body.fp = fp; // not used it yet
|
||||||
pRequest->msgBuf = calloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||||
|
|
||||||
registerRequest(pRequest);
|
registerRequest(pRequest);
|
||||||
|
@ -164,11 +164,18 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||||
tfree(pResInfo->pRspMsg);
|
taosMemoryFreeClear(pResInfo->pRspMsg);
|
||||||
tfree(pResInfo->length);
|
taosMemoryFreeClear(pResInfo->length);
|
||||||
tfree(pResInfo->row);
|
taosMemoryFreeClear(pResInfo->row);
|
||||||
tfree(pResInfo->pCol);
|
taosMemoryFreeClear(pResInfo->pCol);
|
||||||
tfree(pResInfo->fields);
|
taosMemoryFreeClear(pResInfo->fields);
|
||||||
|
|
||||||
|
if (pResInfo->convertBuf != NULL) {
|
||||||
|
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||||
|
taosMemoryFreeClear(pResInfo->convertBuf[i]);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pResInfo->convertBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doDestroyRequest(void *p) {
|
static void doDestroyRequest(void *p) {
|
||||||
|
@ -177,10 +184,10 @@ static void doDestroyRequest(void *p) {
|
||||||
|
|
||||||
assert(RID_VALID(pRequest->self));
|
assert(RID_VALID(pRequest->self));
|
||||||
|
|
||||||
tfree(pRequest->msgBuf);
|
taosMemoryFreeClear(pRequest->msgBuf);
|
||||||
tfree(pRequest->sqlstr);
|
taosMemoryFreeClear(pRequest->sqlstr);
|
||||||
tfree(pRequest->pInfo);
|
taosMemoryFreeClear(pRequest->pInfo);
|
||||||
tfree(pRequest->pDb);
|
taosMemoryFreeClear(pRequest->pDb);
|
||||||
|
|
||||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||||
qDestroyQueryPlan(pRequest->body.pDag);
|
qDestroyQueryPlan(pRequest->body.pDag);
|
||||||
|
@ -190,7 +197,7 @@ static void doDestroyRequest(void *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
deregisterRequest(pRequest);
|
deregisterRequest(pRequest);
|
||||||
tfree(pRequest);
|
taosMemoryFreeClear(pRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyRequest(SRequestObj *pRequest) {
|
void destroyRequest(SRequestObj *pRequest) {
|
||||||
|
@ -349,7 +356,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
|
tscInfo("charset:%s is not valid in locale, charset remains:%s", charset, tsCharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(charset);
|
taosMemoryFree(charset);
|
||||||
} else { // it may be windows system
|
} else { // it may be windows system
|
||||||
tscInfo("charset remains:%s", tsCharset);
|
tscInfo("charset remains:%s", tsCharset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) {
|
static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) {
|
||||||
static int32_t emptyRspNum = 0;
|
static int32_t emptyRspNum = 0;
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tfree(param);
|
taosMemoryFreeClear(param);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +179,12 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code)
|
||||||
SAppInstInfo **pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
SAppInstInfo **pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
||||||
if (pInst == NULL || NULL == *pInst) {
|
if (pInst == NULL || NULL == *pInst) {
|
||||||
tscError("cluster not exist, key:%s", key);
|
tscError("cluster not exist, key:%s", key);
|
||||||
tfree(param);
|
taosMemoryFreeClear(param);
|
||||||
tFreeClientHbBatchRsp(&pRsp);
|
tFreeClientHbBatchRsp(&pRsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(param);
|
taosMemoryFreeClear(param);
|
||||||
|
|
||||||
if (rspNum) {
|
if (rspNum) {
|
||||||
tscDebug("hb got %d rsp, %d empty rsp received before", rspNum,
|
tscDebug("hb got %d rsp, %d empty rsp received before", rspNum,
|
||||||
|
@ -317,7 +317,7 @@ void hbFreeReq(void *req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||||
SClientHbBatchReq *pBatchReq = calloc(1, sizeof(SClientHbBatchReq));
|
SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq));
|
||||||
if (pBatchReq == NULL) {
|
if (pBatchReq == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -346,7 +346,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
|
taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
|
||||||
tfree(pBatchReq);
|
taosMemoryFreeClear(pBatchReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBatchReq;
|
return pBatchReq;
|
||||||
|
@ -387,7 +387,7 @@ static void *hbThreadFunc(void *param) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq);
|
int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq);
|
||||||
void *buf = malloc(tlen);
|
void *buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tFreeClientHbBatchReq(pReq, false);
|
tFreeClientHbBatchReq(pReq, false);
|
||||||
|
@ -396,13 +396,13 @@ static void *hbThreadFunc(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSClientHbBatchReq(buf, tlen, pReq);
|
tSerializeSClientHbBatchReq(buf, tlen, pReq);
|
||||||
SMsgSendInfo *pInfo = calloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
|
||||||
if (pInfo == NULL) {
|
if (pInfo == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tFreeClientHbBatchReq(pReq, false);
|
tFreeClientHbBatchReq(pReq, false);
|
||||||
hbClearReqInfo(pAppHbMgr);
|
hbClearReqInfo(pAppHbMgr);
|
||||||
free(buf);
|
taosMemoryFree(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pInfo->fp = hbAsyncCallBack;
|
pInfo->fp = hbAsyncCallBack;
|
||||||
|
@ -458,7 +458,7 @@ static void hbStopThread() {
|
||||||
|
|
||||||
SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
hbMgrInit();
|
hbMgrInit();
|
||||||
SAppHbMgr *pAppHbMgr = malloc(sizeof(SAppHbMgr));
|
SAppHbMgr *pAppHbMgr = taosMemoryMalloc(sizeof(SAppHbMgr));
|
||||||
if (pAppHbMgr == NULL) {
|
if (pAppHbMgr == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -478,7 +478,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
|
|
||||||
if (pAppHbMgr->activeInfo == NULL) {
|
if (pAppHbMgr->activeInfo == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
free(pAppHbMgr);
|
taosMemoryFree(pAppHbMgr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
|
|
||||||
if (pAppHbMgr->connInfo == NULL) {
|
if (pAppHbMgr->connInfo == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
free(pAppHbMgr);
|
taosMemoryFree(pAppHbMgr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int3
|
||||||
|
|
||||||
switch (hbType) {
|
switch (hbType) {
|
||||||
case HEARTBEAT_TYPE_QUERY: {
|
case HEARTBEAT_TYPE_QUERY: {
|
||||||
int64_t *pClusterId = malloc(sizeof(int64_t));
|
int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t));
|
||||||
*pClusterId = clusterId;
|
*pClusterId = clusterId;
|
||||||
|
|
||||||
info.param = pClusterId;
|
info.param = pClusterId;
|
||||||
|
|
|
@ -100,7 +100,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
|
||||||
pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
pInst = taosHashGet(appInfo.pInstMap, key, strlen(key));
|
||||||
SAppInstInfo* p = NULL;
|
SAppInstInfo* p = NULL;
|
||||||
if (pInst == NULL) {
|
if (pInst == NULL) {
|
||||||
p = calloc(1, sizeof(struct SAppInstInfo));
|
p = taosMemoryCalloc(1, sizeof(struct SAppInstInfo));
|
||||||
p->mgmtEp = epSet;
|
p->mgmtEp = epSet;
|
||||||
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores);
|
||||||
p->pAppHbMgr = appHbMgrInit(p, key);
|
p->pAppHbMgr = appHbMgrInit(p, key);
|
||||||
|
@ -111,7 +111,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
|
||||||
|
|
||||||
taosThreadMutexUnlock(&appInfo.mutex);
|
taosThreadMutexUnlock(&appInfo.mutex);
|
||||||
|
|
||||||
tfree(key);
|
taosMemoryFreeClear(key);
|
||||||
return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst);
|
return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pRequest)->sqlstr = malloc(sqlLen + 1);
|
(*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1);
|
||||||
if ((*pRequest)->sqlstr == NULL) {
|
if ((*pRequest)->sqlstr == NULL) {
|
||||||
tscError("0x%" PRIx64 " failed to prepare sql string buffer", (*pRequest)->self);
|
tscError("0x%" PRIx64 " failed to prepare sql string buffer", (*pRequest)->self);
|
||||||
(*pRequest)->msgBuf = strdup("failed to prepare sql string buffer");
|
(*pRequest)->msgBuf = strdup("failed to prepare sql string buffer");
|
||||||
|
@ -212,7 +212,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
||||||
assert(pSchema != NULL && numOfCols > 0);
|
assert(pSchema != NULL && numOfCols > 0);
|
||||||
|
|
||||||
pResInfo->numOfCols = numOfCols;
|
pResInfo->numOfCols = numOfCols;
|
||||||
pResInfo->fields = calloc(numOfCols, sizeof(pSchema[0]));
|
pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(pSchema[0]));
|
||||||
|
|
||||||
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||||
pResInfo->fields[i].bytes = pSchema[i].bytes;
|
pResInfo->fields[i].bytes = pSchema[i].bytes;
|
||||||
|
@ -421,7 +421,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
||||||
}
|
}
|
||||||
|
|
||||||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
if (pMsgSendInfo == NULL) {
|
if (pMsgSendInfo == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -441,14 +441,14 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
if (db != NULL) {
|
if (db != NULL) {
|
||||||
tstrncpy(connectReq.db, db, sizeof(connectReq.db));
|
tstrncpy(connectReq.db, db, sizeof(connectReq.db));
|
||||||
}
|
}
|
||||||
tfree(db);
|
taosMemoryFreeClear(db);
|
||||||
|
|
||||||
connectReq.pid = htonl(appInfo.pid);
|
connectReq.pid = htonl(appInfo.pid);
|
||||||
connectReq.startTime = htobe64(appInfo.startTime);
|
connectReq.startTime = htobe64(appInfo.startTime);
|
||||||
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
|
tstrncpy(connectReq.app, appInfo.appName, sizeof(connectReq.app));
|
||||||
|
|
||||||
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
int32_t contLen = tSerializeSConnectReq(NULL, 0, &connectReq);
|
||||||
void* pReq = malloc(contLen);
|
void* pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSConnectReq(pReq, contLen, &connectReq);
|
tSerializeSConnectReq(pReq, contLen, &connectReq);
|
||||||
|
|
||||||
pMsgSendInfo->msgInfo.len = contLen;
|
pMsgSendInfo->msgInfo.len = contLen;
|
||||||
|
@ -458,8 +458,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||||
|
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||||
assert(pMsgBody != NULL);
|
assert(pMsgBody != NULL);
|
||||||
tfree(pMsgBody->msgInfo.pData);
|
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||||
tfree(pMsgBody);
|
taosMemoryFreeClear(pMsgBody);
|
||||||
}
|
}
|
||||||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) {
|
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) {
|
||||||
return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP || msgType == TDMT_VND_QUERY_HEARTBEAT_RSP;
|
return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP || msgType == TDMT_VND_QUERY_HEARTBEAT_RSP;
|
||||||
|
@ -500,7 +500,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->handle};
|
SDataBuf buf = {.len = pMsg->contLen, .pData = NULL, .handle = pMsg->handle};
|
||||||
|
|
||||||
if (pMsg->contLen > 0) {
|
if (pMsg->contLen > 0) {
|
||||||
buf.pData = calloc(1, pMsg->contLen);
|
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
|
||||||
if (buf.pData == NULL) {
|
if (buf.pData == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -592,7 +592,7 @@ void* doFetchRow(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SVgroupInfo* pVgroupInfo = taosArrayGet(pShowReqInfo->pArray, pShowReqInfo->currentIndex);
|
SVgroupInfo* pVgroupInfo = taosArrayGet(pShowReqInfo->pArray, pShowReqInfo->currentIndex);
|
||||||
SVShowTablesReq* pShowReq = calloc(1, sizeof(SVShowTablesReq));
|
SVShowTablesReq* pShowReq = taosMemoryCalloc(1, sizeof(SVShowTablesReq));
|
||||||
pShowReq->head.vgId = htonl(pVgroupInfo->vgId);
|
pShowReq->head.vgId = htonl(pVgroupInfo->vgId);
|
||||||
|
|
||||||
pRequest->body.requestMsg.len = sizeof(SVShowTablesReq);
|
pRequest->body.requestMsg.len = sizeof(SVShowTablesReq);
|
||||||
|
@ -634,18 +634,30 @@ _return:
|
||||||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||||
SResultColumn* pCol = &pResultInfo->pCol[i];
|
SResultColumn* pCol = &pResultInfo->pCol[i];
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
if (pCol->offset[pResultInfo->current] != -1) {
|
if (pCol->offset[pResultInfo->current] != -1) {
|
||||||
char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData;
|
char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData;
|
||||||
|
|
||||||
pResultInfo->length[i] = varDataLen(pStart);
|
pResultInfo->length[i] = varDataLen(pStart);
|
||||||
pResultInfo->row[i] = varDataVal(pStart);
|
pResultInfo->row[i] = varDataVal(pStart);
|
||||||
|
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(pResultInfo->convertBuf[i]));
|
||||||
|
ASSERT(len <= bytes);
|
||||||
|
|
||||||
|
pResultInfo->row[i] = varDataVal(pResultInfo->convertBuf[i]);
|
||||||
|
varDataSetLen(pResultInfo->convertBuf[i], len);
|
||||||
|
pResultInfo->length[i] = len;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pResultInfo->row[i] = NULL;
|
pResultInfo->row[i] = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) {
|
if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) {
|
||||||
pResultInfo->row[i] = pResultInfo->pCol[i].pData + pResultInfo->fields[i].bytes * pResultInfo->current;
|
pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current;
|
||||||
} else {
|
} else {
|
||||||
pResultInfo->row[i] = NULL;
|
pResultInfo->row[i] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -658,16 +670,23 @@ _return:
|
||||||
|
|
||||||
static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
||||||
if (pResInfo->row == NULL) {
|
if (pResInfo->row == NULL) {
|
||||||
pResInfo->row = calloc(pResInfo->numOfCols, POINTER_BYTES);
|
pResInfo->row = taosMemoryCalloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||||
pResInfo->pCol = calloc(pResInfo->numOfCols, sizeof(SResultColumn));
|
pResInfo->pCol = taosMemoryCalloc(pResInfo->numOfCols, sizeof(SResultColumn));
|
||||||
pResInfo->length = calloc(pResInfo->numOfCols, sizeof(int32_t));
|
pResInfo->length = taosMemoryCalloc(pResInfo->numOfCols, sizeof(int32_t));
|
||||||
|
pResInfo->convertBuf = taosMemoryCalloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||||
|
|
||||||
|
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||||
|
if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
pResInfo->convertBuf[i] = taosMemoryCalloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL) {
|
return TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
} else {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) {
|
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
return code;
|
return code;
|
||||||
|
@ -77,13 +77,13 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||||
pTscObj->pAppInfo->numOfConns);
|
pTscObj->pAppInfo->numOfConns);
|
||||||
|
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
|
SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
|
||||||
SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
|
||||||
pMsgSendInfo->requestObjRefId = pRequest->self;
|
pMsgSendInfo->requestObjRefId = pRequest->self;
|
||||||
pMsgSendInfo->requestId = pRequest->requestId;
|
pMsgSendInfo->requestId = pRequest->requestId;
|
||||||
|
@ -96,13 +96,13 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
|
||||||
retrieveReq.showId = pRequest->body.showInfo.execId;
|
retrieveReq.showId = pRequest->body.showInfo.execId;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq);
|
int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq);
|
||||||
void* pReq = malloc(contLen);
|
void* pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq);
|
tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq);
|
||||||
pMsgSendInfo->msgInfo.pData = pReq;
|
pMsgSendInfo->msgInfo.pData = pReq;
|
||||||
pMsgSendInfo->msgInfo.len = contLen;
|
pMsgSendInfo->msgInfo.len = contLen;
|
||||||
pMsgSendInfo->msgInfo.handle = NULL;
|
pMsgSendInfo->msgInfo.handle = NULL;
|
||||||
} else {
|
} else {
|
||||||
SVShowTablesFetchReq* pFetchMsg = calloc(1, sizeof(SVShowTablesFetchReq));
|
SVShowTablesFetchReq* pFetchMsg = taosMemoryCalloc(1, sizeof(SVShowTablesFetchReq));
|
||||||
if (pFetchMsg == NULL) {
|
if (pFetchMsg == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
tDeserializeSShowRsp(pMsg->pData, pMsg->len, &showRsp);
|
tDeserializeSShowRsp(pMsg->pData, pMsg->len, &showRsp);
|
||||||
STableMetaRsp *pMetaMsg = &showRsp.tableMeta;
|
STableMetaRsp *pMetaMsg = &showRsp.tableMeta;
|
||||||
|
|
||||||
tfree(pRequest->body.resInfo.pRspMsg);
|
taosMemoryFreeClear(pRequest->body.resInfo.pRspMsg);
|
||||||
pRequest->body.resInfo.pRspMsg = pMsg->pData;
|
pRequest->body.resInfo.pRspMsg = pMsg->pData;
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
if (pResInfo->fields == NULL) {
|
if (pResInfo->fields == NULL) {
|
||||||
TAOS_FIELD* pFields = calloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
|
TAOS_FIELD* pFields = taosMemoryCalloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
|
||||||
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
||||||
SSchema* pSchema = &pMetaMsg->pSchemas[i];
|
SSchema* pSchema = &pMetaMsg->pSchemas[i];
|
||||||
tstrncpy(pFields[i].name, pSchema->name, tListLen(pFields[i].name));
|
tstrncpy(pFields[i].name, pSchema->name, tListLen(pFields[i].name));
|
||||||
|
@ -171,7 +171,7 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj *pRequest = param;
|
SRequestObj *pRequest = param;
|
||||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||||
tfree(pResInfo->pRspMsg);
|
taosMemoryFreeClear(pResInfo->pRspMsg);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
@ -204,7 +204,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
|
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||||
tfree(pResInfo->pRspMsg);
|
taosMemoryFreeClear(pResInfo->pRspMsg);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
|
@ -237,7 +237,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
// todo rsp with the vnode id list
|
// todo rsp with the vnode id list
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
return code;
|
return code;
|
||||||
|
@ -284,7 +284,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
|
if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash);
|
||||||
tfree(output.dbVgroup);
|
taosMemoryFreeClear(output.dbVgroup);
|
||||||
|
|
||||||
tscError("failed to build use db output since %s", terrstr());
|
tscError("failed to build use db output since %s", terrstr());
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,7 +304,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
tNameGetDbName(&name, db);
|
tNameGetDbName(&name, db);
|
||||||
|
|
||||||
setConnectionDB(pRequest->pTscObj, db);
|
setConnectionDB(pRequest->pTscObj, db);
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
assert(pMsg != NULL && param != NULL);
|
assert(pMsg != NULL && param != NULL);
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
|
|
||||||
free(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
setErrno(pRequest, code);
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
|
|
@ -136,14 +136,14 @@ typedef struct {
|
||||||
} SMqCommitCbParam;
|
} SMqCommitCbParam;
|
||||||
|
|
||||||
tmq_conf_t* tmq_conf_new() {
|
tmq_conf_t* tmq_conf_new() {
|
||||||
tmq_conf_t* conf = calloc(1, sizeof(tmq_conf_t));
|
tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t));
|
||||||
conf->auto_commit = false;
|
conf->auto_commit = false;
|
||||||
conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST;
|
conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST;
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmq_conf_destroy(tmq_conf_t* conf) {
|
void tmq_conf_destroy(tmq_conf_t* conf) {
|
||||||
if (conf) free(conf);
|
if (conf) taosMemoryFree(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) {
|
tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) {
|
||||||
|
@ -184,7 +184,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
||||||
}
|
}
|
||||||
|
|
||||||
tmq_list_t* tmq_list_new() {
|
tmq_list_t* tmq_list_new() {
|
||||||
tmq_list_t* ptr = malloc(sizeof(tmq_list_t) + 8 * sizeof(char*));
|
tmq_list_t* ptr = taosMemoryMalloc(sizeof(tmq_list_t) + 8 * sizeof(char*));
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ tmq_resp_err_t tmq_unsubscribe(tmq_t* tmq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
tmq_t* pTmq = calloc(sizeof(tmq_t), 1);
|
tmq_t* pTmq = taosMemoryCalloc(sizeof(tmq_t), 1);
|
||||||
if (pTmq == NULL) {
|
if (pTmq == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
||||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
void* buf = malloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
tCoderClear(&encoder);
|
tCoderClear(&encoder);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -333,7 +333,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
tscError("failed to malloc request");
|
tscError("failed to malloc request");
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqCommitCbParam* pParam = malloc(sizeof(SMqCommitCbParam));
|
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
}
|
}
|
||||||
|
|
||||||
tsem_destroy(&pParam->rspSem);
|
tsem_destroy(&pParam->rspSem);
|
||||||
free(pParam);
|
taosMemoryFree(pParam);
|
||||||
|
|
||||||
if (pArray) {
|
if (pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
|
@ -394,7 +394,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
|
||||||
tNameSetDbName(&name, tmq->pTscObj->acctId, dbName, strlen(dbName));
|
tNameSetDbName(&name, tmq->pTscObj->acctId, dbName, strlen(dbName));
|
||||||
tNameFromString(&name, topicName, T_NAME_TABLE);
|
tNameFromString(&name, topicName, T_NAME_TABLE);
|
||||||
|
|
||||||
char* topicFname = calloc(1, TSDB_TOPIC_FNAME_LEN);
|
char* topicFname = taosMemoryCalloc(1, TSDB_TOPIC_FNAME_LEN);
|
||||||
if (topicFname == NULL) {
|
if (topicFname == NULL) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -405,11 +405,11 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
|
||||||
topic.vgs = taosArrayInit(0, sizeof(SMqClientVg));
|
topic.vgs = taosArrayInit(0, sizeof(SMqClientVg));
|
||||||
taosArrayPush(tmq->clientTopics, &topic);
|
taosArrayPush(tmq->clientTopics, &topic);
|
||||||
taosArrayPush(req.topicNames, &topicFname);
|
taosArrayPush(req.topicNames, &topicFname);
|
||||||
free(dbName);
|
taosMemoryFree(dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlen = tSerializeSCMSubscribeReq(NULL, &req);
|
int tlen = tSerializeSCMSubscribeReq(NULL, &req);
|
||||||
void* buf = malloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -505,10 +505,10 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
|
||||||
.sql = (char*)sql,
|
.sql = (char*)sql,
|
||||||
};
|
};
|
||||||
tNameExtractFullName(&name, req.name);
|
tNameExtractFullName(&name, req.name);
|
||||||
strcpy(req.outputTbName, tbName);
|
strcpy(req.outputSTbName, tbName);
|
||||||
|
|
||||||
int tlen = tSerializeSCMCreateStreamReq(NULL, 0, &req);
|
int tlen = tSerializeSCMCreateStreamReq(NULL, 0, &req);
|
||||||
void* buf = malloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
|
||||||
tsem_wait(&pRequest->body.rspSem);
|
tsem_wait(&pRequest->body.rspSem);
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
tfree(astStr);
|
taosMemoryFreeClear(astStr);
|
||||||
qDestroyQuery(pQueryNode);
|
qDestroyQuery(pQueryNode);
|
||||||
/*if (sendInfo != NULL) {*/
|
/*if (sendInfo != NULL) {*/
|
||||||
/*destroySendMsgInfo(sendInfo);*/
|
/*destroySendMsgInfo(sendInfo);*/
|
||||||
|
@ -594,7 +594,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
tNameExtractFullName(&name, req.name);
|
tNameExtractFullName(&name, req.name);
|
||||||
|
|
||||||
int tlen = tSerializeSCMCreateTopicReq(NULL, 0, &req);
|
int tlen = tSerializeSCMCreateTopicReq(NULL, 0, &req);
|
||||||
void* buf = malloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +618,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
|
||||||
tsem_wait(&pRequest->body.rspSem);
|
tsem_wait(&pRequest->body.rspSem);
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
tfree(astStr);
|
taosMemoryFreeClear(astStr);
|
||||||
qDestroyQuery(pQueryNode);
|
qDestroyQuery(pQueryNode);
|
||||||
/*if (sendInfo != NULL) {*/
|
/*if (sendInfo != NULL) {*/
|
||||||
/*destroySendMsgInfo(sendInfo);*/
|
/*destroySendMsgInfo(sendInfo);*/
|
||||||
|
@ -757,7 +757,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (pParam->sync == 1) {
|
if (pParam->sync == 1) {
|
||||||
/**pParam->msg = malloc(sizeof(tmq_message_t));*/
|
/**pParam->msg = taosMemoryMalloc(sizeof(tmq_message_t));*/
|
||||||
*pParam->msg = taosAllocateQitem(sizeof(tmq_message_t));
|
*pParam->msg = taosAllocateQitem(sizeof(tmq_message_t));
|
||||||
if (*pParam->msg) {
|
if (*pParam->msg) {
|
||||||
memcpy(*pParam->msg, pMsg->pData, sizeof(SMqRspHead));
|
memcpy(*pParam->msg, pMsg->pData, sizeof(SMqRspHead));
|
||||||
|
@ -774,7 +774,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*SMqConsumeRsp* pRsp = calloc(1, sizeof(SMqConsumeRsp));*/
|
/*SMqConsumeRsp* pRsp = taosMemoryCalloc(1, sizeof(SMqConsumeRsp));*/
|
||||||
tmq_message_t* pRsp = taosAllocateQitem(sizeof(tmq_message_t));
|
tmq_message_t* pRsp = taosAllocateQitem(sizeof(tmq_message_t));
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
goto WRITE_QUEUE_FAIL;
|
goto WRITE_QUEUE_FAIL;
|
||||||
|
@ -884,7 +884,7 @@ END:
|
||||||
|
|
||||||
int32_t tmqAskEp(tmq_t* tmq, bool sync) {
|
int32_t tmqAskEp(tmq_t* tmq, bool sync) {
|
||||||
int32_t tlen = sizeof(SMqCMGetSubEpReq);
|
int32_t tlen = sizeof(SMqCMGetSubEpReq);
|
||||||
SMqCMGetSubEpReq* req = malloc(tlen);
|
SMqCMGetSubEpReq* req = taosMemoryMalloc(tlen);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
tscError("failed to malloc get subscribe ep buf");
|
tscError("failed to malloc get subscribe ep buf");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -893,21 +893,21 @@ int32_t tmqAskEp(tmq_t* tmq, bool sync) {
|
||||||
req->epoch = htonl(tmq->epoch);
|
req->epoch = htonl(tmq->epoch);
|
||||||
strcpy(req->cgroup, tmq->groupId);
|
strcpy(req->cgroup, tmq->groupId);
|
||||||
|
|
||||||
SMqAskEpCbParam* pParam = malloc(sizeof(SMqAskEpCbParam));
|
SMqAskEpCbParam* pParam = taosMemoryMalloc(sizeof(SMqAskEpCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
tscError("failed to malloc subscribe param");
|
tscError("failed to malloc subscribe param");
|
||||||
free(req);
|
taosMemoryFree(req);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pParam->tmq = tmq;
|
pParam->tmq = tmq;
|
||||||
pParam->sync = sync;
|
pParam->sync = sync;
|
||||||
tsem_init(&pParam->rspSem, 0, 0);
|
tsem_init(&pParam->rspSem, 0, 0);
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo));
|
SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
|
||||||
if (sendInfo == NULL) {
|
if (sendInfo == NULL) {
|
||||||
tsem_destroy(&pParam->rspSem);
|
tsem_destroy(&pParam->rspSem);
|
||||||
free(pParam);
|
taosMemoryFree(pParam);
|
||||||
free(req);
|
taosMemoryFree(req);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClientTo
|
||||||
reqOffset = tmq->resetOffsetCfg;
|
reqOffset = tmq->resetOffsetCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqPollReq* pReq = malloc(sizeof(SMqPollReq));
|
SMqPollReq* pReq = taosMemoryMalloc(sizeof(SMqPollReq));
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqPollCbParam* pParam = malloc(sizeof(SMqPollCbParam));
|
SMqPollCbParam* pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||||
// TODO: out of mem
|
// TODO: out of mem
|
||||||
|
@ -1016,7 +1016,7 @@ tmq_message_t* tmqSyncPollImpl(tmq_t* tmq, int64_t blockingTime) {
|
||||||
pParam->msg = &msg;
|
pParam->msg = &msg;
|
||||||
tsem_init(&pParam->rspSem, 0, 0);
|
tsem_init(&pParam->rspSem, 0, 0);
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo));
|
SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
|
||||||
if (sendInfo == NULL) {
|
if (sendInfo == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1071,9 +1071,9 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SMqPollCbParam* pParam = malloc(sizeof(SMqPollCbParam));
|
SMqPollCbParam* pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1083,10 +1083,10 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
|
||||||
pParam->epoch = tmq->epoch;
|
pParam->epoch = tmq->epoch;
|
||||||
pParam->sync = 0;
|
pParam->sync = 0;
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = malloc(sizeof(SMsgSendInfo));
|
SMsgSendInfo* sendInfo = taosMemoryMalloc(sizeof(SMsgSendInfo));
|
||||||
if (sendInfo == NULL) {
|
if (sendInfo == NULL) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
free(pParam);
|
taosMemoryFree(pParam);
|
||||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||||
tsem_post(&tmq->rspSem);
|
tsem_post(&tmq->rspSem);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1258,7 +1258,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqPollCbParam* param = malloc(sizeof(SMqPollCbParam));
|
SMqPollCbParam* param = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
taosMsleep(blocking_time);
|
taosMsleep(blocking_time);
|
||||||
|
@ -1289,7 +1289,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
||||||
|
|
||||||
tsem_wait(¶m->rspSem);
|
tsem_wait(¶m->rspSem);
|
||||||
tsem_destroy(¶m->rspSem);
|
tsem_destroy(¶m->rspSem);
|
||||||
free(param);
|
taosMemoryFree(param);
|
||||||
|
|
||||||
if (tmq_message == NULL) {
|
if (tmq_message == NULL) {
|
||||||
if (beginVgIdx == pTopic->nextVgIdx) {
|
if (beginVgIdx == pTopic->nextVgIdx) {
|
||||||
|
@ -1331,7 +1331,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_v
|
||||||
|
|
||||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
||||||
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
|
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
|
||||||
SMqCommitCbParam* pParam = malloc(sizeof(SMqCommitCbParam));
|
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1360,7 +1360,7 @@ void tmq_message_destroy(tmq_message_t* tmq_message) {
|
||||||
if (tmq_message == NULL) return;
|
if (tmq_message == NULL) return;
|
||||||
SMqPollRsp* pRsp = &tmq_message->msg;
|
SMqPollRsp* pRsp = &tmq_message->msg;
|
||||||
tDeleteSMqConsumeRsp(pRsp);
|
tDeleteSMqConsumeRsp(pRsp);
|
||||||
/*free(tmq_message);*/
|
/*taosMemoryFree(tmq_message);*/
|
||||||
taosFreeQitem(tmq_message);
|
taosFreeQitem(tmq_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1403,7 +1403,7 @@ char* tmq_get_topic_name(tmq_message_t* message) { return "not implemented yet";
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) {
|
tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) {
|
||||||
tmq_t* pTmq = malloc(sizeof(tmq_t));
|
tmq_t* pTmq = taosMemoryMalloc(sizeof(tmq_t));
|
||||||
if (pTmq == NULL) {
|
if (pTmq == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1417,7 @@ tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) {
|
||||||
|
|
||||||
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
||||||
assert(pMsgBody != NULL);
|
assert(pMsgBody != NULL);
|
||||||
tfree(pMsgBody->msgInfo.pData);
|
taosMemoryFreeClear(pMsgBody->msgInfo.pData);
|
||||||
tfree(pMsgBody);
|
taosMemoryFreeClear(pMsgBody);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,7 +52,7 @@ TEST(testCase, driverInit_Test) {
|
||||||
// taosInitGlobalCfg();
|
// taosInitGlobalCfg();
|
||||||
// taos_init();
|
// taos_init();
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
TEST(testCase, connect_Test) {
|
TEST(testCase, connect_Test) {
|
||||||
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
|
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
|
||||||
|
|
||||||
|
@ -652,6 +652,7 @@ TEST(testCase, projection_query_stables) {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(testCase, agg_query_tables) {
|
TEST(testCase, agg_query_tables) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
@ -660,7 +661,7 @@ TEST(testCase, agg_query_tables) {
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "select count(*), sum(k),min(k),max(k) from tu");
|
pRes = taos_query(pConn, "select count(*) from tu");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
|
@ -115,7 +115,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
|
||||||
newSize = newSize * 1.5;
|
newSize = newSize * 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* buf = realloc(pColumnInfoData->pData, newSize);
|
char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
|
||||||
uint32_t total = numOfRow1 + numOfRow2;
|
uint32_t total = numOfRow1 + numOfRow2;
|
||||||
|
|
||||||
if (BitmapLen(numOfRow1) < BitmapLen(total)) {
|
if (BitmapLen(numOfRow1) < BitmapLen(total)) {
|
||||||
char* tmp = realloc(pColumnInfoData->nullbitmap, BitmapLen(total));
|
char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(total));
|
||||||
uint32_t extend = BitmapLen(total) - BitmapLen(numOfRow1);
|
uint32_t extend = BitmapLen(total) - BitmapLen(numOfRow1);
|
||||||
memset(tmp + BitmapLen(numOfRow1), 0, extend);
|
memset(tmp + BitmapLen(numOfRow1), 0, extend);
|
||||||
pColumnInfoData->nullbitmap = tmp;
|
pColumnInfoData->nullbitmap = tmp;
|
||||||
|
@ -218,7 +218,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
// Handle the bitmap
|
// Handle the bitmap
|
||||||
char* p = realloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
|
char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
|
||||||
uint32_t len = pSource->varmeta.length;
|
uint32_t len = pSource->varmeta.length;
|
||||||
uint32_t oldLen = pColumnInfoData->varmeta.length;
|
uint32_t oldLen = pColumnInfoData->varmeta.length;
|
||||||
if (pColumnInfoData->varmeta.allocLen < len + oldLen) {
|
if (pColumnInfoData->varmeta.allocLen < len + oldLen) {
|
||||||
char* tmp = realloc(pColumnInfoData->pData, len + oldLen);
|
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, len + oldLen);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
|
||||||
doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2);
|
doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2);
|
||||||
|
|
||||||
int32_t newSize = (numOfRow1 + numOfRow2) * pColumnInfoData->info.bytes;
|
int32_t newSize = (numOfRow1 + numOfRow2) * pColumnInfoData->info.bytes;
|
||||||
char* tmp = realloc(pColumnInfoData->pData, newSize);
|
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -268,16 +268,16 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
// Handle the bitmap
|
// Handle the bitmap
|
||||||
char* p = realloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * numOfRows);
|
char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * numOfRows);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumnInfoData->varmeta.offset = (int32_t*) p;
|
pColumnInfoData->varmeta.offset = (int32_t*)p;
|
||||||
memcpy(pColumnInfoData->varmeta.offset, pSource->varmeta.offset, sizeof(int32_t) * numOfRows);
|
memcpy(pColumnInfoData->varmeta.offset, pSource->varmeta.offset, sizeof(int32_t) * numOfRows);
|
||||||
|
|
||||||
if (pColumnInfoData->varmeta.allocLen < pSource->varmeta.length) {
|
if (pColumnInfoData->varmeta.allocLen < pSource->varmeta.length) {
|
||||||
char* tmp = realloc(pColumnInfoData->pData, pSource->varmeta.length);
|
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, pSource->varmeta.length);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
||||||
memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length);
|
memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length);
|
||||||
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
pColumnInfoData->varmeta.length = pSource->varmeta.length;
|
||||||
} else {
|
} else {
|
||||||
char* tmp = realloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows));
|
char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(numOfRows));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
|
||||||
memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows));
|
memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows));
|
||||||
|
|
||||||
int32_t newSize = numOfRows * pColumnInfoData->info.bytes;
|
int32_t newSize = numOfRows * pColumnInfoData->info.bytes;
|
||||||
tmp = realloc(pColumnInfoData->pData, newSize);
|
tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) {
|
||||||
uint32_t newLen = colDataGetLength(pCol1, pSrc->info.rows);
|
uint32_t newLen = colDataGetLength(pCol1, pSrc->info.rows);
|
||||||
|
|
||||||
int32_t newSize = oldLen + newLen;
|
int32_t newSize = oldLen + newLen;
|
||||||
char* tmp = realloc(pCol2->pData, newSize);
|
char* tmp = taosMemoryRealloc(pCol2->pData, newSize);
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
pCol2->pData = tmp;
|
pCol2->pData = tmp;
|
||||||
colDataMergeCol(pCol2, pDest->info.rows, pCol1, pSrc->info.rows);
|
colDataMergeCol(pCol2, pDest->info.rows, pCol1, pSrc->info.rows);
|
||||||
|
@ -453,7 +453,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* pDst = calloc(1, sizeof(SSDataBlock));
|
SSDataBlock* pDst = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
if (pDst == NULL) {
|
if (pDst == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -470,10 +470,10 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pSrcCol->info.type)) {
|
if (IS_VAR_DATA_TYPE(pSrcCol->info.type)) {
|
||||||
SVarColAttr* pAttr = &colInfo.varmeta;
|
SVarColAttr* pAttr = &colInfo.varmeta;
|
||||||
pAttr->offset = calloc(rowCount, sizeof(int32_t));
|
pAttr->offset = taosMemoryCalloc(rowCount, sizeof(int32_t));
|
||||||
} else {
|
} else {
|
||||||
colInfo.nullbitmap = calloc(1, BitmapLen(rowCount));
|
colInfo.nullbitmap = taosMemoryCalloc(1, BitmapLen(rowCount));
|
||||||
colInfo.pData = calloc(rowCount, colInfo.info.bytes);
|
colInfo.pData = taosMemoryCalloc(rowCount, colInfo.info.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pDst->pDataBlock, &colInfo);
|
taosArrayPush(pDst->pDataBlock, &colInfo);
|
||||||
|
@ -562,7 +562,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
||||||
if (pCol->varmeta.allocLen < colLength) {
|
if (pCol->varmeta.allocLen < colLength) {
|
||||||
char* tmp = realloc(pCol->pData, colLength);
|
char* tmp = taosMemoryRealloc(pCol->pData, colLength);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -587,11 +587,11 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) {
|
||||||
if (pBlock->info.rowSize == 0) {
|
if (pBlock->info.rowSize == 0) {
|
||||||
size_t rowSize = 0;
|
size_t rowSize = 0;
|
||||||
|
|
||||||
size_t numOfCols = pBlock->info.numOfCols;
|
size_t numOfCols = pBlock->info.numOfCols;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
rowSize += pColInfo->info.bytes;
|
rowSize += pColInfo->info.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.rowSize = rowSize;
|
pBlock->info.rowSize = rowSize;
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols) {
|
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols) {
|
||||||
SSchema* pSchema = calloc(pBlock->info.numOfCols, sizeof(SSchema));
|
SSchema* pSchema = taosMemoryCalloc(pBlock->info.numOfCols, sizeof(SSchema));
|
||||||
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
pSchema[i].bytes = pColInfoData->info.bytes;
|
pSchema[i].bytes = pColInfoData->info.bytes;
|
||||||
|
@ -637,7 +637,7 @@ double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||||
if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
||||||
rowSize += sizeof(int32_t);
|
rowSize += sizeof(int32_t);
|
||||||
} else {
|
} else {
|
||||||
rowSize += 1/8.0; // one bit for each record
|
rowSize += 1 / 8.0; // one bit for each record
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) {
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
int32_t numOfCols = pDataBlock->info.numOfCols;
|
int32_t numOfCols = pDataBlock->info.numOfCols;
|
||||||
|
|
||||||
SColumnInfoData* pCols = calloc(numOfCols, sizeof(SColumnInfoData));
|
SColumnInfoData* pCols = taosMemoryCalloc(numOfCols, sizeof(SColumnInfoData));
|
||||||
if (pCols == NULL) {
|
if (pCols == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -829,14 +829,14 @@ static SColumnInfoData* createHelpColInfoData(const SSDataBlock* pDataBlock) {
|
||||||
pCols[i].info = pColInfoData->info;
|
pCols[i].info = pColInfoData->info;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pCols[i].info.type)) {
|
if (IS_VAR_DATA_TYPE(pCols[i].info.type)) {
|
||||||
pCols[i].varmeta.offset = calloc(rows, sizeof(int32_t));
|
pCols[i].varmeta.offset = taosMemoryCalloc(rows, sizeof(int32_t));
|
||||||
pCols[i].pData = calloc(1, pColInfoData->varmeta.length);
|
pCols[i].pData = taosMemoryCalloc(1, pColInfoData->varmeta.length);
|
||||||
|
|
||||||
pCols[i].varmeta.length = pColInfoData->varmeta.length;
|
pCols[i].varmeta.length = pColInfoData->varmeta.length;
|
||||||
pCols[i].varmeta.allocLen = pCols[i].varmeta.length;
|
pCols[i].varmeta.allocLen = pCols[i].varmeta.length;
|
||||||
} else {
|
} else {
|
||||||
pCols[i].nullbitmap = calloc(1, BitmapLen(rows));
|
pCols[i].nullbitmap = taosMemoryCalloc(1, BitmapLen(rows));
|
||||||
pCols[i].pData = calloc(rows, pCols[i].info.bytes);
|
pCols[i].pData = taosMemoryCalloc(rows, pCols[i].info.bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,22 +851,22 @@ static void copyBackToBlock(SSDataBlock* pDataBlock, SColumnInfoData* pCols) {
|
||||||
pColInfoData->info = pCols[i].info;
|
pColInfoData->info = pCols[i].info;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
tfree(pColInfoData->varmeta.offset);
|
taosMemoryFreeClear(pColInfoData->varmeta.offset);
|
||||||
pColInfoData->varmeta = pCols[i].varmeta;
|
pColInfoData->varmeta = pCols[i].varmeta;
|
||||||
} else {
|
} else {
|
||||||
tfree(pColInfoData->nullbitmap);
|
taosMemoryFreeClear(pColInfoData->nullbitmap);
|
||||||
pColInfoData->nullbitmap = pCols[i].nullbitmap;
|
pColInfoData->nullbitmap = pCols[i].nullbitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pColInfoData->pData);
|
taosMemoryFreeClear(pColInfoData->pData);
|
||||||
pColInfoData->pData = pCols[i].pData;
|
pColInfoData->pData = pCols[i].pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pCols);
|
taosMemoryFreeClear(pCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t* createTupleIndex(size_t rows) {
|
static int32_t* createTupleIndex(size_t rows) {
|
||||||
int32_t* index = calloc(rows, sizeof(int32_t));
|
int32_t* index = taosMemoryCalloc(rows, sizeof(int32_t));
|
||||||
if (index == NULL) {
|
if (index == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -878,7 +878,7 @@ static int32_t* createTupleIndex(size_t rows) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyTupleIndex(int32_t* index) { tfree(index); }
|
static void destroyTupleIndex(int32_t* index) { taosMemoryFreeClear(index); }
|
||||||
|
|
||||||
static __compar_fn_t getComparFn(int32_t type, int32_t order) {
|
static __compar_fn_t getComparFn(int32_t type, int32_t order) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -1019,8 +1019,8 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock*
|
||||||
|
|
||||||
size_t len = sortValLengthPerRow * pBlock->info.rows;
|
size_t len = sortValLengthPerRow * pBlock->info.rows;
|
||||||
|
|
||||||
char* buf = calloc(1, len);
|
char* buf = taosMemoryCalloc(1, len);
|
||||||
SHelper* phelper = calloc(numOfRows, sizeof(SHelper));
|
SHelper* phelper = taosMemoryCalloc(numOfRows, sizeof(SHelper));
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
phelper[i].index = i;
|
phelper[i].index = i;
|
||||||
phelper[i].pData = buf + sortValLengthPerRow * i;
|
phelper[i].pData = buf + sortValLengthPerRow * i;
|
||||||
|
@ -1163,7 +1163,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumn->info.type)) {
|
||||||
char* tmp = realloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows);
|
char* tmp = taosMemoryRealloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1173,9 +1173,9 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
|
||||||
|
|
||||||
pColumn->varmeta.length = 0;
|
pColumn->varmeta.length = 0;
|
||||||
pColumn->varmeta.allocLen = 0;
|
pColumn->varmeta.allocLen = 0;
|
||||||
tfree(pColumn->pData);
|
taosMemoryFreeClear(pColumn->pData);
|
||||||
} else {
|
} else {
|
||||||
char* tmp = realloc(pColumn->nullbitmap, BitmapLen(numOfRows));
|
char* tmp = taosMemoryRealloc(pColumn->nullbitmap, BitmapLen(numOfRows));
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1183,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo
|
||||||
pColumn->nullbitmap = tmp;
|
pColumn->nullbitmap = tmp;
|
||||||
memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows));
|
memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows));
|
||||||
assert(pColumn->info.bytes);
|
assert(pColumn->info.bytes);
|
||||||
tmp = realloc(pColumn->pData, numOfRows * pColumn->info.bytes);
|
tmp = taosMemoryRealloc(pColumn->pData, numOfRows * pColumn->info.bytes);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1214,14 +1214,14 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDestroyInner(pBlock);
|
blockDestroyInner(pBlock);
|
||||||
tfree(pBlock);
|
taosMemoryFreeClear(pBlock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
|
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
|
||||||
int32_t numOfCols = pDataBlock->info.numOfCols;
|
int32_t numOfCols = pDataBlock->info.numOfCols;
|
||||||
|
|
||||||
SSDataBlock* pBlock = calloc(1, sizeof(SSDataBlock));
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
pBlock->info.numOfCols = numOfCols;
|
pBlock->info.numOfCols = numOfCols;
|
||||||
|
@ -1318,12 +1318,97 @@ int32_t tEncodeDataBlocks(void** buf, const SArray* blocks) {
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* tDecodeDataBlocks(const void* buf, SArray* blocks) {
|
void* tDecodeDataBlocks(const void* buf, SArray** blocks) {
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
buf = taosDecodeFixedI32(buf, &sz);
|
buf = taosDecodeFixedI32(buf, &sz);
|
||||||
|
|
||||||
|
*blocks = taosArrayInit(sz, sizeof(SSDataBlock));
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SSDataBlock pBlock = {0};
|
SSDataBlock pBlock = {0};
|
||||||
buf = tDecodeDataBlock(buf, &pBlock);
|
buf = tDecodeDataBlock(buf, &pBlock);
|
||||||
|
taosArrayPush(*blocks, &pBlock);
|
||||||
}
|
}
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
|
time_t tt;
|
||||||
|
int32_t ms = 0;
|
||||||
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
tt = (time_t)(val / 1000000000);
|
||||||
|
ms = val % 1000000000;
|
||||||
|
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
tt = (time_t)(val / 1000000);
|
||||||
|
ms = val % 1000000;
|
||||||
|
} else {
|
||||||
|
tt = (time_t)(val / 1000);
|
||||||
|
ms = val % 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* comment out as it make testcases like select_with_tags.sim fail.
|
||||||
|
but in windows, this may cause the call to localtime crash if tt < 0,
|
||||||
|
need to find a better solution.
|
||||||
|
if (tt < 0) {
|
||||||
|
tt = 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
if (tt < 0) tt = 0;
|
||||||
|
#endif
|
||||||
|
if (tt <= 0 && ms < 0) {
|
||||||
|
tt--;
|
||||||
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
ms += 1000000000;
|
||||||
|
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
ms += 1000000;
|
||||||
|
} else {
|
||||||
|
ms += 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm* ptm = localtime(&tt);
|
||||||
|
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
||||||
|
|
||||||
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
sprintf(buf + pos, ".%09d", ms);
|
||||||
|
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||||
|
sprintf(buf + pos, ".%06d", ms);
|
||||||
|
} else {
|
||||||
|
sprintf(buf + pos, ".%03d", ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
void blockDebugShowData(SArray* dataBlocks) {
|
||||||
|
char pBuf[128];
|
||||||
|
int32_t sz = taosArrayGetSize(dataBlocks);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(dataBlocks, i);
|
||||||
|
int32_t colNum = pDataBlock->info.numOfCols;
|
||||||
|
int32_t rows = pDataBlock->info.rows;
|
||||||
|
for (int32_t j = 0; j < rows; j++) {
|
||||||
|
printf("|");
|
||||||
|
for (int32_t k = 0; k < colNum; k++) {
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
|
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||||
|
switch (pColInfoData->info.type) {
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
formatTimestamp(pBuf, *(uint64_t*)var, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
printf(" %25s |", pBuf);
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
case TSDB_DATA_TYPE_UINT:
|
||||||
|
printf(" %15d |", *(int32_t*)var);
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
|
printf(" %15ld |", *(int64_t*)var);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pCol->spaceSize < spaceNeeded) {
|
if (pCol->spaceSize < spaceNeeded) {
|
||||||
void *ptr = realloc(pCol->pData, spaceNeeded);
|
void *ptr = taosMemoryRealloc(pCol->pData, spaceNeeded);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded, strerror(errno));
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)spaceNeeded, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -66,7 +66,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
*/
|
*/
|
||||||
STSchema *tdDupSchema(const STSchema *pSchema) {
|
STSchema *tdDupSchema(const STSchema *pSchema) {
|
||||||
int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema);
|
int tlen = sizeof(STSchema) + sizeof(STColumn) * schemaNCols(pSchema);
|
||||||
STSchema *tSchema = (STSchema *)malloc(tlen);
|
STSchema *tSchema = (STSchema *)taosMemoryMalloc(tlen);
|
||||||
if (tSchema == NULL) return NULL;
|
if (tSchema == NULL) return NULL;
|
||||||
|
|
||||||
memcpy((void *)tSchema, (void *)pSchema, tlen);
|
memcpy((void *)tSchema, (void *)pSchema, tlen);
|
||||||
|
@ -127,7 +127,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
|
||||||
if (pBuilder == NULL) return -1;
|
if (pBuilder == NULL) return -1;
|
||||||
|
|
||||||
pBuilder->tCols = 256;
|
pBuilder->tCols = 256;
|
||||||
pBuilder->columns = (STColumn *)malloc(sizeof(STColumn) * pBuilder->tCols);
|
pBuilder->columns = (STColumn *)taosMemoryMalloc(sizeof(STColumn) * pBuilder->tCols);
|
||||||
if (pBuilder->columns == NULL) return -1;
|
if (pBuilder->columns == NULL) return -1;
|
||||||
|
|
||||||
tdResetTSchemaBuilder(pBuilder, version);
|
tdResetTSchemaBuilder(pBuilder, version);
|
||||||
|
@ -136,7 +136,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
|
||||||
|
|
||||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
|
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
|
||||||
if (pBuilder) {
|
if (pBuilder) {
|
||||||
tfree(pBuilder->columns);
|
taosMemoryFreeClear(pBuilder->columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int1
|
||||||
|
|
||||||
if (pBuilder->nCols >= pBuilder->tCols) {
|
if (pBuilder->nCols >= pBuilder->tCols) {
|
||||||
pBuilder->tCols *= 2;
|
pBuilder->tCols *= 2;
|
||||||
STColumn *columns = (STColumn *)realloc(pBuilder->columns, sizeof(STColumn) * pBuilder->tCols);
|
STColumn *columns = (STColumn *)taosMemoryRealloc(pBuilder->columns, sizeof(STColumn) * pBuilder->tCols);
|
||||||
if (columns == NULL) return -1;
|
if (columns == NULL) return -1;
|
||||||
pBuilder->columns = columns;
|
pBuilder->columns = columns;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) {
|
||||||
|
|
||||||
int tlen = sizeof(STSchema) + sizeof(STColumn) * pBuilder->nCols;
|
int tlen = sizeof(STSchema) + sizeof(STColumn) * pBuilder->nCols;
|
||||||
|
|
||||||
STSchema *pSchema = (STSchema *)malloc(tlen);
|
STSchema *pSchema = (STSchema *)taosMemoryMalloc(tlen);
|
||||||
if (pSchema == NULL) return NULL;
|
if (pSchema == NULL) return NULL;
|
||||||
|
|
||||||
schemaVersion(pSchema) = pBuilder->version;
|
schemaVersion(pSchema) = pBuilder->version;
|
||||||
|
@ -221,7 +221,7 @@ void tdInitDataRow(SDataRow row, STSchema *pSchema) {
|
||||||
SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
|
SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
|
||||||
int32_t size = dataRowMaxBytesFromSchema(pSchema);
|
int32_t size = dataRowMaxBytesFromSchema(pSchema);
|
||||||
|
|
||||||
SDataRow row = malloc(size);
|
SDataRow row = taosMemoryMalloc(size);
|
||||||
if (row == NULL) return NULL;
|
if (row == NULL) return NULL;
|
||||||
|
|
||||||
tdInitDataRow(row, pSchema);
|
tdInitDataRow(row, pSchema);
|
||||||
|
@ -232,11 +232,11 @@ SDataRow tdNewDataRowFromSchema(STSchema *pSchema) {
|
||||||
* Free the SDataRow object
|
* Free the SDataRow object
|
||||||
*/
|
*/
|
||||||
void tdFreeDataRow(SDataRow row) {
|
void tdFreeDataRow(SDataRow row) {
|
||||||
if (row) free(row);
|
if (row) taosMemoryFree(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataRow tdDataRowDup(SDataRow row) {
|
SDataRow tdDataRowDup(SDataRow row) {
|
||||||
SDataRow trow = malloc(dataRowLen(row));
|
SDataRow trow = taosMemoryMalloc(dataRowLen(row));
|
||||||
if (trow == NULL) return NULL;
|
if (trow == NULL) return NULL;
|
||||||
|
|
||||||
dataRowCpy(trow, row);
|
dataRowCpy(trow, row);
|
||||||
|
@ -244,7 +244,7 @@ SDataRow tdDataRowDup(SDataRow row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMemRow tdMemRowDup(SMemRow row) {
|
SMemRow tdMemRowDup(SMemRow row) {
|
||||||
SMemRow trow = malloc(memRowTLen(row));
|
SMemRow trow = taosMemoryMalloc(memRowTLen(row));
|
||||||
if (trow == NULL) return NULL;
|
if (trow == NULL) return NULL;
|
||||||
|
|
||||||
memRowCpy(trow, row);
|
memRowCpy(trow, row);
|
||||||
|
@ -348,7 +348,7 @@ void *dataColSetOffset(SDataCol *pCol, int nEle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataCols *tdNewDataCols(int maxCols, int maxRows) {
|
SDataCols *tdNewDataCols(int maxCols, int maxRows) {
|
||||||
SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols));
|
SDataCols *pCols = (SDataCols *)taosMemoryCalloc(1, sizeof(SDataCols));
|
||||||
if (pCols == NULL) {
|
if (pCols == NULL) {
|
||||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno));
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -360,7 +360,7 @@ SDataCols *tdNewDataCols(int maxCols, int maxRows) {
|
||||||
pCols->numOfCols = 0;
|
pCols->numOfCols = 0;
|
||||||
|
|
||||||
if (maxCols > 0) {
|
if (maxCols > 0) {
|
||||||
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol));
|
pCols->cols = (SDataCol *)taosMemoryCalloc(maxCols, sizeof(SDataCol));
|
||||||
if (pCols->cols == NULL) {
|
if (pCols->cols == NULL) {
|
||||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols,
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -384,7 +384,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
|
||||||
int oldMaxCols = pCols->maxCols;
|
int oldMaxCols = pCols->maxCols;
|
||||||
if (schemaNCols(pSchema) > oldMaxCols) {
|
if (schemaNCols(pSchema) > oldMaxCols) {
|
||||||
pCols->maxCols = schemaNCols(pSchema);
|
pCols->maxCols = schemaNCols(pSchema);
|
||||||
void *ptr = (SDataCol *)realloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols);
|
void *ptr = (SDataCol *)taosMemoryRealloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols);
|
||||||
if (ptr == NULL) return -1;
|
if (ptr == NULL) return -1;
|
||||||
pCols->cols = ptr;
|
pCols->cols = ptr;
|
||||||
for (i = oldMaxCols; i < pCols->maxCols; i++) {
|
for (i = oldMaxCols; i < pCols->maxCols; i++) {
|
||||||
|
@ -411,16 +411,17 @@ SDataCols *tdFreeDataCols(SDataCols *pCols) {
|
||||||
int maxCols = pCols->maxCols;
|
int maxCols = pCols->maxCols;
|
||||||
for (i = 0; i < maxCols; i++) {
|
for (i = 0; i < maxCols; i++) {
|
||||||
SDataCol *pCol = &pCols->cols[i];
|
SDataCol *pCol = &pCols->cols[i];
|
||||||
tfree(pCol->pData);
|
taosMemoryFreeClear(pCol->pData);
|
||||||
}
|
}
|
||||||
free(pCols->cols);
|
taosMemoryFree(pCols->cols);
|
||||||
pCols->cols = NULL;
|
pCols->cols = NULL;
|
||||||
}
|
}
|
||||||
free(pCols);
|
taosMemoryFree(pCols);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
SDataCols *pRet = tdNewDataCols(pDataCols->maxCols, pDataCols->maxPoints);
|
SDataCols *pRet = tdNewDataCols(pDataCols->maxCols, pDataCols->maxPoints);
|
||||||
if (pRet == NULL) return NULL;
|
if (pRet == NULL) return NULL;
|
||||||
|
@ -454,6 +455,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
|
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tdResetDataCols(SDataCols *pCols) {
|
void tdResetDataCols(SDataCols *pCols) {
|
||||||
if (pCols != NULL) {
|
if (pCols != NULL) {
|
||||||
|
@ -639,7 +641,7 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SKVRow tdKVRowDup(SKVRow row) {
|
SKVRow tdKVRowDup(SKVRow row) {
|
||||||
SKVRow trow = malloc(kvRowLen(row));
|
SKVRow trow = taosMemoryMalloc(kvRowLen(row));
|
||||||
if (trow == NULL) return NULL;
|
if (trow == NULL) return NULL;
|
||||||
|
|
||||||
kvRowCpy(trow, row);
|
kvRowCpy(trow, row);
|
||||||
|
@ -672,7 +674,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
||||||
int oRowCols = kvRowNCols(row);
|
int oRowCols = kvRowNCols(row);
|
||||||
|
|
||||||
ASSERT(diff > 0);
|
ASSERT(diff > 0);
|
||||||
nrow = malloc(nRowLen);
|
nrow = taosMemoryMalloc(nRowLen);
|
||||||
if (nrow == NULL) return -1;
|
if (nrow == NULL) return -1;
|
||||||
|
|
||||||
kvRowSetLen(nrow, nRowLen);
|
kvRowSetLen(nrow, nRowLen);
|
||||||
|
@ -690,7 +692,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
||||||
tdSortKVRowByColIdx(nrow);
|
tdSortKVRowByColIdx(nrow);
|
||||||
|
|
||||||
*orow = nrow;
|
*orow = nrow;
|
||||||
free(row);
|
taosMemoryFree(row);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(((SColIdx *)ptr)->colId == colId);
|
ASSERT(((SColIdx *)ptr)->colId == colId);
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
@ -701,7 +703,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
||||||
} else { // need to reallocate the memory
|
} else { // need to reallocate the memory
|
||||||
int16_t nlen = kvRowLen(row) + (varDataTLen(value) - varDataTLen(pOldVal));
|
int16_t nlen = kvRowLen(row) + (varDataTLen(value) - varDataTLen(pOldVal));
|
||||||
ASSERT(nlen > 0);
|
ASSERT(nlen > 0);
|
||||||
nrow = malloc(nlen);
|
nrow = taosMemoryMalloc(nlen);
|
||||||
if (nrow == NULL) return -1;
|
if (nrow == NULL) return -1;
|
||||||
|
|
||||||
kvRowSetLen(nrow, nlen);
|
kvRowSetLen(nrow, nlen);
|
||||||
|
@ -726,7 +728,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
*orow = nrow;
|
*orow = nrow;
|
||||||
free(row);
|
taosMemoryFree(row);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]);
|
memcpy(kvRowColVal(row, (SColIdx *)ptr), value, TYPE_BYTES[type]);
|
||||||
|
@ -755,21 +757,21 @@ void *tdDecodeKVRow(void *buf, SKVRow *row) {
|
||||||
int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
|
int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
pBuilder->tCols = 128;
|
pBuilder->tCols = 128;
|
||||||
pBuilder->nCols = 0;
|
pBuilder->nCols = 0;
|
||||||
pBuilder->pColIdx = (SColIdx *)malloc(sizeof(SColIdx) * pBuilder->tCols);
|
pBuilder->pColIdx = (SColIdx *)taosMemoryMalloc(sizeof(SColIdx) * pBuilder->tCols);
|
||||||
if (pBuilder->pColIdx == NULL) return -1;
|
if (pBuilder->pColIdx == NULL) return -1;
|
||||||
pBuilder->alloc = 1024;
|
pBuilder->alloc = 1024;
|
||||||
pBuilder->size = 0;
|
pBuilder->size = 0;
|
||||||
pBuilder->buf = malloc(pBuilder->alloc);
|
pBuilder->buf = taosMemoryMalloc(pBuilder->alloc);
|
||||||
if (pBuilder->buf == NULL) {
|
if (pBuilder->buf == NULL) {
|
||||||
free(pBuilder->pColIdx);
|
taosMemoryFree(pBuilder->pColIdx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
|
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
tfree(pBuilder->pColIdx);
|
taosMemoryFreeClear(pBuilder->pColIdx);
|
||||||
tfree(pBuilder->buf);
|
taosMemoryFreeClear(pBuilder->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
|
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
|
@ -783,7 +785,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) {
|
||||||
|
|
||||||
tlen += TD_KV_ROW_HEAD_SIZE;
|
tlen += TD_KV_ROW_HEAD_SIZE;
|
||||||
|
|
||||||
SKVRow row = malloc(tlen);
|
SKVRow row = taosMemoryMalloc(tlen);
|
||||||
if (row == NULL) return NULL;
|
if (row == NULL) return NULL;
|
||||||
|
|
||||||
kvRowSetNCols(row, pBuilder->nCols);
|
kvRowSetNCols(row, pBuilder->nCols);
|
||||||
|
|
|
@ -132,6 +132,9 @@ bool tsdbForceKeepFile = false;
|
||||||
int32_t tsDiskCfgNum = 0;
|
int32_t tsDiskCfgNum = 0;
|
||||||
SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0};
|
SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0};
|
||||||
|
|
||||||
|
// stream scheduler
|
||||||
|
bool tsStreamSchedV = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* minimum scale for whole system, millisecond by default
|
* minimum scale for whole system, millisecond by default
|
||||||
* for TSDB_TIME_PRECISION_MILLI: 86400000L
|
* for TSDB_TIME_PRECISION_MILLI: 86400000L
|
||||||
|
@ -177,6 +180,10 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
|
||||||
memcpy(&tsDiskCfg[index], pCfg, sizeof(SDiskCfg));
|
memcpy(&tsDiskCfg[index], pCfg, sizeof(SDiskCfg));
|
||||||
if (pCfg->level == 0 && pCfg->primary == 1) {
|
if (pCfg->level == 0 && pCfg->primary == 1) {
|
||||||
tstrncpy(tsDataDir, pCfg->dir, PATH_MAX);
|
tstrncpy(tsDataDir, pCfg->dir, PATH_MAX);
|
||||||
|
if (taosMkDir(tsDataDir) != 0) {
|
||||||
|
uError("failed to create dataDir:%s since %s", tsDataDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (taosMkDir(pCfg->dir) != 0) {
|
if (taosMkDir(pCfg->dir) != 0) {
|
||||||
uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr());
|
uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr());
|
||||||
|
@ -585,4 +592,4 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
|
||||||
taosResetLog();
|
taosResetLog();
|
||||||
cfgDumpCfg(tsCfg, 1, false);
|
cfgDumpCfg(tsCfg, 1, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#undef TD_MSG_SEG_CODE_
|
#undef TD_MSG_SEG_CODE_
|
||||||
#include "tmsgdef.h"
|
#include "tmsgdef.h"
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
int32_t tInitSubmitMsgIter(const 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;
|
||||||
|
@ -287,6 +287,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
||||||
|
tlen += taosEncodeString(buf, pReq->dbFName);
|
||||||
tlen += taosEncodeString(buf, pReq->name);
|
tlen += taosEncodeString(buf, pReq->name);
|
||||||
tlen += taosEncodeFixedU32(buf, pReq->ttl);
|
tlen += taosEncodeFixedU32(buf, pReq->ttl);
|
||||||
tlen += taosEncodeFixedU32(buf, pReq->keep);
|
tlen += taosEncodeFixedU32(buf, pReq->keep);
|
||||||
|
@ -313,12 +314,12 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
||||||
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pBSmaCols[i]);
|
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pBSmaCols[i]);
|
||||||
}
|
}
|
||||||
if(pReq->rollup && NULL != pReq->stbCfg.pRSmaParam) {
|
if (pReq->rollup && pReq->stbCfg.pRSmaParam) {
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
||||||
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
||||||
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
||||||
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
||||||
for(int8_t i=0; i< param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
||||||
}
|
}
|
||||||
tlen += taosEncodeFixedI64(buf, param->delay);
|
tlen += taosEncodeFixedI64(buf, param->delay);
|
||||||
|
@ -336,16 +337,16 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->ntbCfg.pSchema[i].bytes);
|
tlen += taosEncodeFixedI32(buf, pReq->ntbCfg.pSchema[i].bytes);
|
||||||
tlen += taosEncodeString(buf, pReq->ntbCfg.pSchema[i].name);
|
tlen += taosEncodeString(buf, pReq->ntbCfg.pSchema[i].name);
|
||||||
}
|
}
|
||||||
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nBSmaCols);
|
tlen += taosEncodeFixedI16(buf, pReq->ntbCfg.nBSmaCols);
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
for (col_id_t i = 0; i < pReq->ntbCfg.nBSmaCols; ++i) {
|
||||||
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pBSmaCols[i]);
|
tlen += taosEncodeFixedI16(buf, pReq->ntbCfg.pBSmaCols[i]);
|
||||||
}
|
}
|
||||||
if(pReq->rollup && NULL != pReq->stbCfg.pRSmaParam) {
|
if (pReq->rollup && pReq->ntbCfg.pRSmaParam) {
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
||||||
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
tlen += taosEncodeFixedU32(buf, (uint32_t)param->xFilesFactor);
|
||||||
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
tlen += taosEncodeFixedI8(buf, param->delayUnit);
|
||||||
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
tlen += taosEncodeFixedI8(buf, param->nFuncIds);
|
||||||
for(int8_t i=0; i< param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
tlen += taosEncodeFixedI32(buf, param->pFuncIds[i]);
|
||||||
}
|
}
|
||||||
tlen += taosEncodeFixedI64(buf, param->delay);
|
tlen += taosEncodeFixedI64(buf, param->delay);
|
||||||
|
@ -360,6 +361,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
|
|
||||||
void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
buf = taosDecodeFixedI64(buf, &(pReq->ver));
|
buf = taosDecodeFixedI64(buf, &(pReq->ver));
|
||||||
|
buf = taosDecodeString(buf, &(pReq->dbFName));
|
||||||
buf = taosDecodeString(buf, &(pReq->name));
|
buf = taosDecodeString(buf, &(pReq->name));
|
||||||
buf = taosDecodeFixedU32(buf, &(pReq->ttl));
|
buf = taosDecodeFixedU32(buf, &(pReq->ttl));
|
||||||
buf = taosDecodeFixedU32(buf, &(pReq->keep));
|
buf = taosDecodeFixedU32(buf, &(pReq->keep));
|
||||||
|
@ -369,7 +371,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
case TD_SUPER_TABLE:
|
case TD_SUPER_TABLE:
|
||||||
buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid));
|
buf = taosDecodeFixedI64(buf, &(pReq->stbCfg.suid));
|
||||||
buf = taosDecodeFixedU32(buf, &(pReq->stbCfg.nCols));
|
buf = taosDecodeFixedU32(buf, &(pReq->stbCfg.nCols));
|
||||||
pReq->stbCfg.pSchema = (SSchema *)malloc(pReq->stbCfg.nCols * sizeof(SSchema));
|
pReq->stbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nCols * sizeof(SSchema));
|
||||||
for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) {
|
for (uint32_t i = 0; i < pReq->stbCfg.nCols; i++) {
|
||||||
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type));
|
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pSchema[i].type));
|
||||||
buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].colId));
|
buf = taosDecodeFixedI32(buf, &(pReq->stbCfg.pSchema[i].colId));
|
||||||
|
@ -377,7 +379,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name);
|
buf = taosDecodeStringTo(buf, pReq->stbCfg.pSchema[i].name);
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedU32(buf, &pReq->stbCfg.nTagCols);
|
buf = taosDecodeFixedU32(buf, &pReq->stbCfg.nTagCols);
|
||||||
pReq->stbCfg.pTagSchema = (SSchema *)malloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
|
pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
|
||||||
for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) {
|
for (uint32_t i = 0; i < pReq->stbCfg.nTagCols; i++) {
|
||||||
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
|
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].colId);
|
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].colId);
|
||||||
|
@ -385,22 +387,22 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols));
|
buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols));
|
||||||
if(pReq->stbCfg.nBSmaCols > 0) {
|
if (pReq->stbCfg.nBSmaCols > 0) {
|
||||||
pReq->stbCfg.pBSmaCols = (col_id_t *)malloc(pReq->stbCfg.nBSmaCols * sizeof(col_id_t));
|
pReq->stbCfg.pBSmaCols = (col_id_t *)taosMemoryMalloc(pReq->stbCfg.nBSmaCols * sizeof(col_id_t));
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
||||||
buf = taosDecodeFixedI16(buf, pReq->stbCfg.pBSmaCols + i);
|
buf = taosDecodeFixedI16(buf, pReq->stbCfg.pBSmaCols + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pReq->stbCfg.pBSmaCols = NULL;
|
pReq->stbCfg.pBSmaCols = NULL;
|
||||||
}
|
}
|
||||||
if(pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
pReq->stbCfg.pRSmaParam = (SRSmaParam *)malloc(sizeof(SRSmaParam));
|
pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
||||||
buf = taosDecodeFixedU32(buf, (uint32_t*)¶m->xFilesFactor);
|
buf = taosDecodeFixedU32(buf, (uint32_t *)¶m->xFilesFactor);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
||||||
if(param->nFuncIds > 0) {
|
if (param->nFuncIds > 0) {
|
||||||
for (int8_t i = 0; i< param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -417,30 +419,30 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
break;
|
break;
|
||||||
case TD_NORMAL_TABLE:
|
case TD_NORMAL_TABLE:
|
||||||
buf = taosDecodeFixedU32(buf, &pReq->ntbCfg.nCols);
|
buf = taosDecodeFixedU32(buf, &pReq->ntbCfg.nCols);
|
||||||
pReq->ntbCfg.pSchema = (SSchema *)malloc(pReq->ntbCfg.nCols * sizeof(SSchema));
|
pReq->ntbCfg.pSchema = (SSchema *)taosMemoryMalloc(pReq->ntbCfg.nCols * sizeof(SSchema));
|
||||||
for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) {
|
for (uint32_t i = 0; i < pReq->ntbCfg.nCols; i++) {
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type);
|
buf = taosDecodeFixedI8(buf, &pReq->ntbCfg.pSchema[i].type);
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].colId);
|
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].colId);
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].bytes);
|
buf = taosDecodeFixedI32(buf, &pReq->ntbCfg.pSchema[i].bytes);
|
||||||
buf = taosDecodeStringTo(buf, pReq->ntbCfg.pSchema[i].name);
|
buf = taosDecodeStringTo(buf, pReq->ntbCfg.pSchema[i].name);
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedI16(buf, &(pReq->stbCfg.nBSmaCols));
|
buf = taosDecodeFixedI16(buf, &(pReq->ntbCfg.nBSmaCols));
|
||||||
if(pReq->stbCfg.nBSmaCols > 0) {
|
if (pReq->ntbCfg.nBSmaCols > 0) {
|
||||||
pReq->stbCfg.pBSmaCols = (col_id_t *)malloc(pReq->stbCfg.nBSmaCols * sizeof(col_id_t));
|
pReq->ntbCfg.pBSmaCols = (col_id_t *)taosMemoryMalloc(pReq->ntbCfg.nBSmaCols * sizeof(col_id_t));
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nBSmaCols; ++i) {
|
for (col_id_t i = 0; i < pReq->ntbCfg.nBSmaCols; ++i) {
|
||||||
buf = taosDecodeFixedI16(buf, pReq->stbCfg.pBSmaCols + i);
|
buf = taosDecodeFixedI16(buf, pReq->ntbCfg.pBSmaCols + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pReq->stbCfg.pBSmaCols = NULL;
|
pReq->ntbCfg.pBSmaCols = NULL;
|
||||||
}
|
}
|
||||||
if(pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
pReq->stbCfg.pRSmaParam = (SRSmaParam *)malloc(sizeof(SRSmaParam));
|
pReq->ntbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam));
|
||||||
SRSmaParam *param = pReq->stbCfg.pRSmaParam;
|
SRSmaParam *param = pReq->ntbCfg.pRSmaParam;
|
||||||
buf = taosDecodeFixedU32(buf, (uint32_t*)¶m->xFilesFactor);
|
buf = taosDecodeFixedU32(buf, (uint32_t *)¶m->xFilesFactor);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
buf = taosDecodeFixedI8(buf, ¶m->delayUnit);
|
||||||
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
buf = taosDecodeFixedI8(buf, ¶m->nFuncIds);
|
||||||
if(param->nFuncIds > 0) {
|
if (param->nFuncIds > 0) {
|
||||||
for (int8_t i = 0; i< param->nFuncIds; ++i) {
|
for (int8_t i = 0; i < param->nFuncIds; ++i) {
|
||||||
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
buf = taosDecodeFixedI32(buf, param->pFuncIds + i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -448,7 +450,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
}
|
}
|
||||||
buf = taosDecodeFixedI64(buf, ¶m->delay);
|
buf = taosDecodeFixedI64(buf, ¶m->delay);
|
||||||
} else {
|
} else {
|
||||||
pReq->stbCfg.pRSmaParam = NULL;
|
pReq->ntbCfg.pRSmaParam = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -478,7 +480,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
|
||||||
buf = taosDecodeFixedU32(buf, &nsize);
|
buf = taosDecodeFixedU32(buf, &nsize);
|
||||||
pReq->pArray = taosArrayInit(nsize, sizeof(SVCreateTbReq));
|
pReq->pArray = taosArrayInit(nsize, sizeof(SVCreateTbReq));
|
||||||
for (size_t i = 0; i < nsize; i++) {
|
for (size_t i = 0; i < nsize; i++) {
|
||||||
SVCreateTbReq req;
|
SVCreateTbReq req = {0};
|
||||||
buf = tDeserializeSVCreateTbReq(buf, &req);
|
buf = tDeserializeSVCreateTbReq(buf, &req);
|
||||||
taosArrayPush(pReq->pArray, &req);
|
taosArrayPush(pReq->pArray, &req);
|
||||||
}
|
}
|
||||||
|
@ -508,8 +510,14 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||||
|
if (tEncodeFloat(&encoder, pReq->xFilesFactor) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->aggregationMethod) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->delay) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->numOfSmas) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->commentLen) < 0) return -1;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pReq->numOfColumns; ++i) {
|
||||||
SField *pField = taosArrayGet(pReq->pColumns, i);
|
SField *pField = taosArrayGet(pReq->pColumns, i);
|
||||||
|
@ -525,7 +533,16 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
||||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tEncodeCStr(&encoder, pReq->comment) < 0) return -1;
|
for (int32_t i = 0; i < pReq->numOfSmas; ++i) {
|
||||||
|
SField *pField = taosArrayGet(pReq->pSmas, i);
|
||||||
|
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pReq->commentLen > 0) {
|
||||||
|
if (tEncodeBinary(&encoder, pReq->comment, pReq->commentLen) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -540,12 +557,19 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||||
|
if (tDecodeFloat(&decoder, &pReq->xFilesFactor) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->aggregationMethod) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->delay) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->numOfSmas) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->commentLen) < 0) return -1;
|
||||||
|
|
||||||
pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField));
|
pReq->pColumns = taosArrayInit(pReq->numOfColumns, sizeof(SField));
|
||||||
pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField));
|
pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField));
|
||||||
if (pReq->pColumns == NULL || pReq->pTags == NULL) {
|
pReq->pSmas = taosArrayInit(pReq->numOfSmas, sizeof(SField));
|
||||||
|
if (pReq->pColumns == NULL || pReq->pTags == NULL || pReq->pSmas == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -572,7 +596,23 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1;
|
for (int32_t i = 0; i < pReq->numOfSmas; ++i) {
|
||||||
|
SField field = {0};
|
||||||
|
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pSmas, &field) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pReq->commentLen > 0) {
|
||||||
|
pReq->comment = taosMemoryMalloc(pReq->commentLen);
|
||||||
|
if (pReq->comment == NULL) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->comment) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tCoderClear(&decoder);
|
||||||
|
@ -582,8 +622,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
||||||
void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
|
void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
|
||||||
taosArrayDestroy(pReq->pColumns);
|
taosArrayDestroy(pReq->pColumns);
|
||||||
taosArrayDestroy(pReq->pTags);
|
taosArrayDestroy(pReq->pTags);
|
||||||
|
taosArrayDestroy(pReq->pSmas);
|
||||||
|
taosMemoryFreeClear(pReq->comment);
|
||||||
pReq->pColumns = NULL;
|
pReq->pColumns = NULL;
|
||||||
pReq->pTags = NULL;
|
pReq->pTags = NULL;
|
||||||
|
pReq->pSmas = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
|
int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
|
||||||
|
@ -669,6 +712,123 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
|
||||||
pReq->pFields = NULL;
|
pReq->pFields = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->stb) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->intervalUnit) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->slidingUnit) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->timezone) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->dstVgId) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->interval) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->offset) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->astLen) < 0) return -1;
|
||||||
|
if (pReq->exprLen > 0) {
|
||||||
|
if (tEncodeBinary(&encoder, pReq->expr, pReq->exprLen) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->tagsFilterLen > 0) {
|
||||||
|
if (tEncodeBinary(&encoder, pReq->tagsFilter, pReq->tagsFilterLen) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->sqlLen > 0) {
|
||||||
|
if (tEncodeBinary(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->astLen > 0) {
|
||||||
|
if (tEncodeBinary(&encoder, pReq->ast, pReq->astLen) < 0) return -1;
|
||||||
|
}
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->stb) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->intervalUnit) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->slidingUnit) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->timezone) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dstVgId) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->astLen) < 0) return -1;
|
||||||
|
if (pReq->exprLen > 0) {
|
||||||
|
pReq->expr = taosMemoryMalloc(pReq->exprLen);
|
||||||
|
if (pReq->expr == NULL) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->expr) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->tagsFilterLen > 0) {
|
||||||
|
pReq->tagsFilter = taosMemoryMalloc(pReq->tagsFilterLen);
|
||||||
|
if (pReq->tagsFilter == NULL) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->tagsFilter) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->sqlLen > 0) {
|
||||||
|
pReq->sql = taosMemoryMalloc(pReq->sqlLen);
|
||||||
|
if (pReq->sql == NULL) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->astLen > 0) {
|
||||||
|
pReq->ast = taosMemoryMalloc(pReq->astLen);
|
||||||
|
if (pReq->ast == NULL) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSMCreateSmaReq(SMCreateSmaReq *pReq) {
|
||||||
|
taosMemoryFreeClear(pReq->expr);
|
||||||
|
taosMemoryFreeClear(pReq->tagsFilter);
|
||||||
|
taosMemoryFreeClear(pReq->sql);
|
||||||
|
taosMemoryFreeClear(pReq->ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
@ -1384,6 +1544,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
||||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
|
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
||||||
|
if (tEncodeI32(&encoder, pRetension->freq) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pRetension->keep) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -1417,12 +1585,36 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
||||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1;
|
||||||
|
pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention));
|
||||||
|
if (pReq->pRetensions == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
|
SRetention rentension = {0};
|
||||||
|
if (tDecodeI32(&decoder, &rentension.freq) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &rentension.keep) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tCoderClear(&decoder);
|
tCoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tFreeSCreateDbReq(SCreateDbReq *pReq) {
|
||||||
|
taosArrayDestroy(pReq->pRetensions);
|
||||||
|
pReq->pRetensions = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
@ -1795,7 +1987,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->payloadLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->payloadLen) < 0) return -1;
|
||||||
if (pReq->payloadLen > 0) {
|
if (pReq->payloadLen > 0) {
|
||||||
pReq->payload = malloc(pReq->payloadLen);
|
pReq->payload = taosMemoryMalloc(pReq->payloadLen);
|
||||||
if (pReq->payload == NULL) return -1;
|
if (pReq->payload == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->payload) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->payload) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
@ -1805,7 +1997,7 @@ int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tFreeSShowReq(SShowReq *pReq) { tfree(pReq->payload); }
|
void tFreeSShowReq(SShowReq *pReq) { taosMemoryFreeClear(pReq->payload); }
|
||||||
|
|
||||||
int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq *pReq) {
|
int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
|
@ -1879,7 +2071,7 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) {
|
||||||
if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1;
|
||||||
|
|
||||||
int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns;
|
int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns;
|
||||||
pRsp->pSchemas = malloc(sizeof(SSchema) * totalCols);
|
pRsp->pSchemas = taosMemoryMalloc(sizeof(SSchema) * totalCols);
|
||||||
if (pRsp->pSchemas == NULL) return -1;
|
if (pRsp->pSchemas == NULL) return -1;
|
||||||
|
|
||||||
for (int32_t i = 0; i < totalCols; ++i) {
|
for (int32_t i = 0; i < totalCols; ++i) {
|
||||||
|
@ -1960,7 +2152,7 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { tfree(pRsp->pSchemas); }
|
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
|
||||||
|
|
||||||
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp *pRsp) {
|
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp *pRsp) {
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
||||||
|
@ -2112,13 +2304,13 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
||||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||||
|
|
||||||
if (sqlLen > 0) {
|
if (sqlLen > 0) {
|
||||||
pReq->sql = calloc(1, sqlLen + 1);
|
pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
|
||||||
if (pReq->sql == NULL) return -1;
|
if (pReq->sql == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (astLen > 0) {
|
if (astLen > 0) {
|
||||||
pReq->ast = calloc(1, astLen + 1);
|
pReq->ast = taosMemoryCalloc(1, astLen + 1);
|
||||||
if (pReq->ast == NULL) return -1;
|
if (pReq->ast == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
@ -2130,8 +2322,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
||||||
}
|
}
|
||||||
|
|
||||||
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
|
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
|
||||||
tfree(pReq->sql);
|
taosMemoryFreeClear(pReq->sql);
|
||||||
tfree(pReq->ast);
|
taosMemoryFreeClear(pReq->ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) {
|
int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) {
|
||||||
|
@ -2300,6 +2492,14 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
SReplica *pReplica = &pReq->replicas[i];
|
SReplica *pReplica = &pReq->replicas[i];
|
||||||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
|
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
||||||
|
if (tEncodeI32(&encoder, pRetension->freq) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pRetension->keep) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2344,11 +2544,35 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
|
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1;
|
||||||
|
pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention));
|
||||||
|
if (pReq->pRetensions == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
|
SRetention rentension = {0};
|
||||||
|
if (tDecodeI32(&decoder, &rentension.freq) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &rentension.keep) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
||||||
|
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tCoderClear(&decoder);
|
tCoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq *pReq) {
|
||||||
|
taosArrayDestroy(pReq->pRetensions);
|
||||||
|
pReq->pRetensions = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq) {
|
int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
@ -2709,7 +2933,7 @@ int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRsp->code) < 0) return -1;
|
if (tEncodeI32(&encoder, pRsp->code) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2736,13 +2960,13 @@ int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchR
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (pRsp->rspList) {
|
if (pRsp->rspList) {
|
||||||
int32_t num = taosArrayGetSize(pRsp->rspList);
|
int32_t num = taosArrayGetSize(pRsp->rspList);
|
||||||
if (tEncodeI32(&encoder, num) < 0) return -1;
|
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SVCreateTbRsp *rsp = taosArrayGet(pRsp->rspList, i);
|
SVCreateTbRsp *rsp = taosArrayGet(pRsp->rspList, i);
|
||||||
if (tEncodeI32(&encoder, rsp->code) < 0) return -1;
|
if (tEncodeI32(&encoder, rsp->code) < 0) return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tEncodeI32(&encoder, 0) < 0) return -1;
|
if (tEncodeI32(&encoder, 0) < 0) return -1;
|
||||||
}
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -2752,7 +2976,7 @@ int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchR
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) {
|
int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) {
|
||||||
SCoder decoder = {0};
|
SCoder decoder = {0};
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
@ -2775,7 +2999,6 @@ int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t tSerializeSVCreateTSmaReq(void **buf, SVCreateTSmaReq *pReq) {
|
int32_t tSerializeSVCreateTSmaReq(void **buf, SVCreateTSmaReq *pReq) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
|
||||||
|
@ -2822,9 +3045,10 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->outputTbName) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->outputSTbName) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
||||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||||
|
|
||||||
|
@ -2844,19 +3068,19 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->outputTbName) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->outputSTbName) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||||
|
|
||||||
if (sqlLen > 0) {
|
if (sqlLen > 0) {
|
||||||
pReq->sql = calloc(1, sqlLen + 1);
|
pReq->sql = taosMemoryCalloc(1, sqlLen + 1);
|
||||||
if (pReq->sql == NULL) return -1;
|
if (pReq->sql == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (astLen > 0) {
|
if (astLen > 0) {
|
||||||
pReq->ast = calloc(1, astLen + 1);
|
pReq->ast = taosMemoryCalloc(1, astLen + 1);
|
||||||
if (pReq->ast == NULL) return -1;
|
if (pReq->ast == NULL) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
@ -2867,41 +3091,6 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
}
|
}
|
||||||
|
|
||||||
void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
|
void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) {
|
||||||
tfree(pReq->sql);
|
taosMemoryFreeClear(pReq->sql);
|
||||||
tfree(pReq->ast);
|
taosMemoryFreeClear(pReq->ast);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) {
|
|
||||||
if (tStartEncode(pEncoder) < 0) return -1;
|
|
||||||
if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1;
|
|
||||||
if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1;
|
|
||||||
if (tEncodeI32(pEncoder, pTask->level) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pTask->status) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pTask->pipeSink) < 0) return -1;
|
|
||||||
// if (tEncodeI8(pEncoder, pTask->numOfRunners) < 0) return -1;
|
|
||||||
if (tEncodeSEpSet(pEncoder, &pTask->NextOpEp) < 0) return -1;
|
|
||||||
if (tEncodeCStr(pEncoder, pTask->qmsg) < 0) return -1;
|
|
||||||
tEndEncode(pEncoder);
|
|
||||||
return pEncoder->pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) {
|
|
||||||
if (tStartDecode(pDecoder) < 0) return -1;
|
|
||||||
if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1;
|
|
||||||
if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1;
|
|
||||||
if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pTask->pipeSink) < 0) return -1;
|
|
||||||
// if (tDecodeI8(pDecoder, &pTask->numOfRunners) < 0) return -1;
|
|
||||||
if (tDecodeSEpSet(pDecoder, &pTask->NextOpEp) < 0) return -1;
|
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pTask->qmsg) < 0) return -1;
|
|
||||||
tEndDecode(pDecoder);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tFreeSStreamTask(SStreamTask *pTask) {
|
|
||||||
// TODO
|
|
||||||
/*free(pTask->qmsg);*/
|
|
||||||
/*free(pTask->executor);*/
|
|
||||||
/*free(pTask);*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnFilterInfo* pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo));
|
SColumnFilterInfo* pFilter = taosMemoryCalloc(1, numOfFilters * sizeof(SColumnFilterInfo));
|
||||||
|
|
||||||
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
|
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
|
||||||
for (int32_t j = 0; j < numOfFilters; ++j) {
|
for (int32_t j = 0; j < numOfFilters; ++j) {
|
||||||
if (pFilter[j].filterstr) {
|
if (pFilter[j].filterstr) {
|
||||||
size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE;
|
size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE;
|
||||||
pFilter[j].pz = (int64_t) calloc(1, len);
|
pFilter[j].pz = (int64_t) taosMemoryCalloc(1, len);
|
||||||
|
|
||||||
memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len);
|
memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ bool tNameIsValid(const SName* name) {
|
||||||
SName* tNameDup(const SName* name) {
|
SName* tNameDup(const SName* name) {
|
||||||
assert(name != NULL);
|
assert(name != NULL);
|
||||||
|
|
||||||
SName* p = malloc(sizeof(SName));
|
SName* p = taosMemoryMalloc(sizeof(SName));
|
||||||
memcpy(p, name, sizeof(SName));
|
memcpy(p, name, sizeof(SName));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ static FORCE_INLINE void dataColSetNoneAt(SDataCol *pCol, int index, bool setBit
|
||||||
setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * index), pCol->type, pCol->bytes);
|
setNull(POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * index), pCol->type, pCol->bytes);
|
||||||
pCol->len += TYPE_BYTES[pCol->type];
|
pCol->len += TYPE_BYTES[pCol->type];
|
||||||
}
|
}
|
||||||
if(setBitmap) {
|
if (setBitmap) {
|
||||||
tdSetBitmapValType(pCol->pBitmap, index, TD_VTYPE_NONE);
|
tdSetBitmapValType(pCol->pBitmap, index, TD_VTYPE_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,8 @@ int trbWriteCol(SRowBuilder *pRB, void *pData, col_id_t cid) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STSRow* tdRowDup(STSRow *row) {
|
STSRow *tdRowDup(STSRow *row) {
|
||||||
STSRow* trow = malloc(TD_ROW_LEN(row));
|
STSRow *trow = taosMemoryMalloc(TD_ROW_LEN(row));
|
||||||
if (trow == NULL) return NULL;
|
if (trow == NULL) return NULL;
|
||||||
|
|
||||||
tdRowCpy(trow, row);
|
tdRowCpy(trow, row);
|
||||||
|
@ -176,7 +176,7 @@ static int32_t tdAppendTpRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols
|
||||||
|
|
||||||
SDataCol *pDataCol = &(pCols->cols[0]);
|
SDataCol *pDataCol = &(pCols->cols[0]);
|
||||||
if (pDataCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (pDataCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
tdAppendValToDataCol(pDataCol, TD_VTYPE_NORM, &pRow->ts, pCols->numOfRows, pCols->maxPoints);
|
tdAppendValToDataCol(pDataCol, TD_VTYPE_NORM, &pRow->ts, pCols->numOfRows, pCols->maxPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (dcol < pCols->numOfCols) {
|
while (dcol < pCols->numOfCols) {
|
||||||
|
@ -378,9 +378,7 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STSRow *mergeTwoRows(void *buffer, STSRow *row1, STSRow *row2, STSchema *pSchema1, STSchema *pSchema2) {
|
||||||
|
|
||||||
STSRow* mergeTwoRows(void *buffer, STSRow* row1, STSRow *row2, STSchema *pSchema1, STSchema *pSchema2) {
|
|
||||||
#if 0
|
#if 0
|
||||||
ASSERT(TD_ROW_KEY(row1) == TD_ROW_KEY(row2));
|
ASSERT(TD_ROW_KEY(row1) == TD_ROW_KEY(row2));
|
||||||
ASSERT(schemaVersion(pSchema1) == TD_ROW_SVER(row1));
|
ASSERT(schemaVersion(pSchema1) == TD_ROW_SVER(row1));
|
||||||
|
@ -473,6 +471,44 @@ STSRow* mergeTwoRows(void *buffer, STSRow* row1, STSRow *row2, STSchema *pSchema
|
||||||
}
|
}
|
||||||
taosArrayDestroy(stashRow);
|
taosArrayDestroy(stashRow);
|
||||||
return buffer;
|
return buffer;
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
|
SDataCols *pRet = tdNewDataCols(pDataCols->maxCols, pDataCols->maxPoints);
|
||||||
|
if (pRet == NULL) return NULL;
|
||||||
|
|
||||||
|
pRet->numOfCols = pDataCols->numOfCols;
|
||||||
|
pRet->sversion = pDataCols->sversion;
|
||||||
|
if (keepData) pRet->numOfRows = pDataCols->numOfRows;
|
||||||
|
|
||||||
|
for (int i = 0; i < pDataCols->numOfCols; i++) {
|
||||||
|
pRet->cols[i].type = pDataCols->cols[i].type;
|
||||||
|
pRet->cols[i].bitmap = pDataCols->cols[i].bitmap;
|
||||||
|
pRet->cols[i].colId = pDataCols->cols[i].colId;
|
||||||
|
pRet->cols[i].bytes = pDataCols->cols[i].bytes;
|
||||||
|
pRet->cols[i].offset = pDataCols->cols[i].offset;
|
||||||
|
|
||||||
|
if (keepData) {
|
||||||
|
if (pDataCols->cols[i].len > 0) {
|
||||||
|
if (tdAllocMemForCol(&pRet->cols[i], pRet->maxPoints) < 0) {
|
||||||
|
tdFreeDataCols(pRet);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pRet->cols[i].len = pDataCols->cols[i].len;
|
||||||
|
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
|
||||||
|
if (IS_VAR_DATA_TYPE(pRet->cols[i].type)) {
|
||||||
|
int dataOffSize = sizeof(VarDataOffsetT) * pDataCols->maxPoints;
|
||||||
|
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, dataOffSize);
|
||||||
|
}
|
||||||
|
if (!TD_COL_ROWS_NORM(pRet->cols + i)) {
|
||||||
|
int32_t nBitmapBytes = (int32_t)TD_BITMAP_BYTES(pDataCols->maxPoints);
|
||||||
|
memcpy(pRet->cols[i].pBitmap, pDataCols->cols[i].pBitmap, nBitmapBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pRet;
|
||||||
|
}
|
|
@ -458,16 +458,21 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
if (unit == 'y') {
|
|
||||||
duration *= 12;
|
if (unit != 'n' && unit != 'y') {
|
||||||
} else if (unit != 'n') {
|
|
||||||
return t + duration;
|
return t + duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following code handles the y/n time duration
|
||||||
|
int64_t numOfMonth = duration;
|
||||||
|
if (unit == 'y') {
|
||||||
|
numOfMonth *= 12;
|
||||||
|
}
|
||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||||
taosLocalTime(&tt, &tm);
|
taosLocalTime(&tt, &tm);
|
||||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)duration;
|
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||||
tm.tm_year = mon / 12;
|
tm.tm_year = mon / 12;
|
||||||
tm.tm_mon = mon % 12;
|
tm.tm_mon = mon % 12;
|
||||||
|
|
||||||
|
@ -557,8 +562,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
||||||
|
|
||||||
// not enough time range
|
// not enough time range
|
||||||
if (start < 0 || INT64_MAX - start > pInterval->interval - 1) {
|
if (start < 0 || INT64_MAX - start > pInterval->interval - 1) {
|
||||||
end = start + pInterval->interval - 1;
|
end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||||
|
|
||||||
while (end < t && ((start + pInterval->sliding) <= INT64_MAX)) { // move forward to the correct time window
|
while (end < t && ((start + pInterval->sliding) <= INT64_MAX)) { // move forward to the correct time window
|
||||||
start += pInterval->sliding;
|
start += pInterval->sliding;
|
||||||
|
|
||||||
|
@ -574,12 +578,23 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(pInterval->offset >= 0);
|
||||||
|
|
||||||
if (pInterval->offset > 0) {
|
if (pInterval->offset > 0) {
|
||||||
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
|
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
|
||||||
if (start > t) {
|
if (start > t) {
|
||||||
start = taosTimeAdd(start, -pInterval->interval, pInterval->intervalUnit, precision);
|
start = taosTimeAdd(start, -pInterval->interval, pInterval->intervalUnit, precision);
|
||||||
|
} else {
|
||||||
|
// try to move current window to the left-hande-side, due to the offset effect.
|
||||||
|
int64_t end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||||
|
ASSERT(end >= t);
|
||||||
|
end = taosTimeAdd(end, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||||
|
if (end >= t) {
|
||||||
|
start = taosTimeAdd(start, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
STSBuf* pTSBuf = calloc(1, sizeof(STSBuf));
|
STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
|
||||||
if (pTSBuf == NULL) {
|
if (pTSBuf == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
|
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
|
||||||
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
|
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
|
||||||
if (pTSBuf->pFile == NULL) {
|
if (pTSBuf->pFile == NULL) {
|
||||||
free(pTSBuf);
|
taosMemoryFree(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
STSBuf* pTSBuf = calloc(1, sizeof(STSBuf));
|
STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
|
||||||
if (pTSBuf == NULL) {
|
if (pTSBuf == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
// pTSBuf->pFile = fopen(pTSBuf->path, "rb+");
|
// pTSBuf->pFile = fopen(pTSBuf->path, "rb+");
|
||||||
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_WRITE | TD_FILE_READ);
|
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_WRITE | TD_FILE_READ);
|
||||||
if (pTSBuf->pFile == NULL) {
|
if (pTSBuf->pFile == NULL) {
|
||||||
free(pTSBuf);
|
taosMemoryFree(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
|
|
||||||
if (header.numOfGroup > pTSBuf->numOfAlloc) {
|
if (header.numOfGroup > pTSBuf->numOfAlloc) {
|
||||||
pTSBuf->numOfAlloc = header.numOfGroup;
|
pTSBuf->numOfAlloc = header.numOfGroup;
|
||||||
STSGroupBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * pTSBuf->numOfAlloc);
|
STSGroupBlockInfoEx* tmp = taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * pTSBuf->numOfAlloc);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -122,7 +122,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
|
|
||||||
size_t infoSize = sizeof(STSGroupBlockInfo) * pTSBuf->numOfGroups;
|
size_t infoSize = sizeof(STSGroupBlockInfo) * pTSBuf->numOfGroups;
|
||||||
|
|
||||||
STSGroupBlockInfo* buf = (STSGroupBlockInfo*)calloc(1, infoSize);
|
STSGroupBlockInfo* buf = (STSGroupBlockInfo*)taosMemoryCalloc(1, infoSize);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
STSGroupBlockInfoEx* pBlockList = &pTSBuf->pData[i];
|
STSGroupBlockInfoEx* pBlockList = &pTSBuf->pData[i];
|
||||||
memcpy(&pBlockList->info, &buf[i], sizeof(STSGroupBlockInfo));
|
memcpy(&pBlockList->info, &buf[i], sizeof(STSGroupBlockInfo));
|
||||||
}
|
}
|
||||||
free(buf);
|
taosMemoryFree(buf);
|
||||||
|
|
||||||
ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_END);
|
ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_END);
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
|
@ -166,11 +166,11 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pTSBuf->assistBuf);
|
taosMemoryFreeClear(pTSBuf->assistBuf);
|
||||||
tfree(pTSBuf->tsData.rawBuf);
|
taosMemoryFreeClear(pTSBuf->tsData.rawBuf);
|
||||||
|
|
||||||
tfree(pTSBuf->pData);
|
taosMemoryFreeClear(pTSBuf->pData);
|
||||||
tfree(pTSBuf->block.payload);
|
taosMemoryFreeClear(pTSBuf->block.payload);
|
||||||
|
|
||||||
if (!pTSBuf->remainOpen) {
|
if (!pTSBuf->remainOpen) {
|
||||||
taosCloseFile(&pTSBuf->pFile);
|
taosCloseFile(&pTSBuf->pFile);
|
||||||
|
@ -184,7 +184,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosVariantDestroy(&pTSBuf->block.tag);
|
taosVariantDestroy(&pTSBuf->block.tag);
|
||||||
free(pTSBuf);
|
taosMemoryFree(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
|
||||||
uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5);
|
uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5);
|
||||||
assert((int32_t)newSize > pTSBuf->numOfAlloc);
|
assert((int32_t)newSize > pTSBuf->numOfAlloc);
|
||||||
|
|
||||||
STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)realloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
|
STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
|
||||||
static void shrinkBuffer(STSList* ptsData) {
|
static void shrinkBuffer(STSList* ptsData) {
|
||||||
// shrink tmp buffer size if it consumes too many memory compared to the pre-defined size
|
// shrink tmp buffer size if it consumes too many memory compared to the pre-defined size
|
||||||
if (ptsData->allocSize >= ptsData->threshold * 2) {
|
if (ptsData->allocSize >= ptsData->threshold * 2) {
|
||||||
char* rawBuf = realloc(ptsData->rawBuf, MEM_BUF_SIZE);
|
char* rawBuf = taosMemoryRealloc(ptsData->rawBuf, MEM_BUF_SIZE);
|
||||||
if (rawBuf) {
|
if (rawBuf) {
|
||||||
ptsData->rawBuf = rawBuf;
|
ptsData->rawBuf = rawBuf;
|
||||||
ptsData->allocSize = MEM_BUF_SIZE;
|
ptsData->allocSize = MEM_BUF_SIZE;
|
||||||
|
@ -322,7 +322,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
||||||
static void expandBuffer(STSList* ptsData, int32_t inputSize) {
|
static void expandBuffer(STSList* ptsData, int32_t inputSize) {
|
||||||
if (ptsData->allocSize - ptsData->len < inputSize) {
|
if (ptsData->allocSize - ptsData->len < inputSize) {
|
||||||
int32_t newSize = inputSize + ptsData->len;
|
int32_t newSize = inputSize + ptsData->len;
|
||||||
char* tmp = realloc(ptsData->rawBuf, (size_t)newSize);
|
char* tmp = taosMemoryRealloc(ptsData->rawBuf, (size_t)newSize);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
||||||
// NOTE: mix types tags are not supported
|
// NOTE: mix types tags are not supported
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
|
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
char* tp = realloc(pBlock->tag.pz, pBlock->tag.nLen + 1);
|
char* tp = taosMemoryRealloc(pBlock->tag.pz, pBlock->tag.nLen + 1);
|
||||||
assert(tp != NULL);
|
assert(tp != NULL);
|
||||||
|
|
||||||
memset(tp, 0, pBlock->tag.nLen + 1);
|
memset(tp, 0, pBlock->tag.nLen + 1);
|
||||||
|
@ -812,7 +812,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
|
||||||
if (pDestBuf->numOfAlloc < newSize) {
|
if (pDestBuf->numOfAlloc < newSize) {
|
||||||
pDestBuf->numOfAlloc = newSize;
|
pDestBuf->numOfAlloc = newSize;
|
||||||
|
|
||||||
STSGroupBlockInfoEx* tmp = realloc(pDestBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
|
STSGroupBlockInfoEx* tmp = taosMemoryRealloc(pDestBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1028,13 +1028,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
|
||||||
const int32_t INITIAL_GROUPINFO_SIZE = 4;
|
const int32_t INITIAL_GROUPINFO_SIZE = 4;
|
||||||
|
|
||||||
pTSBuf->numOfAlloc = INITIAL_GROUPINFO_SIZE;
|
pTSBuf->numOfAlloc = INITIAL_GROUPINFO_SIZE;
|
||||||
pTSBuf->pData = calloc(pTSBuf->numOfAlloc, sizeof(STSGroupBlockInfoEx));
|
pTSBuf->pData = taosMemoryCalloc(pTSBuf->numOfAlloc, sizeof(STSGroupBlockInfoEx));
|
||||||
if (pTSBuf->pData == NULL) {
|
if (pTSBuf->pData == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTSBuf->tsData.rawBuf = malloc(MEM_BUF_SIZE);
|
pTSBuf->tsData.rawBuf = taosMemoryMalloc(MEM_BUF_SIZE);
|
||||||
if (pTSBuf->tsData.rawBuf == NULL) {
|
if (pTSBuf->tsData.rawBuf == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1044,13 +1044,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
|
||||||
pTSBuf->tsData.threshold = MEM_BUF_SIZE;
|
pTSBuf->tsData.threshold = MEM_BUF_SIZE;
|
||||||
pTSBuf->tsData.allocSize = MEM_BUF_SIZE;
|
pTSBuf->tsData.allocSize = MEM_BUF_SIZE;
|
||||||
|
|
||||||
pTSBuf->assistBuf = malloc(MEM_BUF_SIZE);
|
pTSBuf->assistBuf = taosMemoryMalloc(MEM_BUF_SIZE);
|
||||||
if (pTSBuf->assistBuf == NULL) {
|
if (pTSBuf->assistBuf == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTSBuf->block.payload = malloc(MEM_BUF_SIZE);
|
pTSBuf->block.payload = taosMemoryMalloc(MEM_BUF_SIZE);
|
||||||
if (pTSBuf->block.payload == NULL) {
|
if (pTSBuf->block.payload == NULL) {
|
||||||
tsBufDestroy(pTSBuf);
|
tsBufDestroy(pTSBuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1079,7 +1079,7 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*id) = malloc(tsBufGetNumOfGroup(pTSBuf) * sizeof(int32_t));
|
(*id) = taosMemoryMalloc(tsBufGetNumOfGroup(pTSBuf) * sizeof(int32_t));
|
||||||
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
(*id)[i] = pTSBuf->pData[i].info.id;
|
(*id)[i] = pTSBuf->pData[i].info.id;
|
||||||
|
|
|
@ -199,14 +199,14 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
||||||
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
|
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
|
||||||
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
||||||
|
|
||||||
pVar->ucs4 = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
||||||
memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
||||||
pVar->nLen = (int32_t)len;
|
pVar->nLen = (int32_t)len;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method
|
case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method
|
||||||
pVar->pz = calloc(len + 1, sizeof(char));
|
pVar->pz = taosMemoryCalloc(len + 1, sizeof(char));
|
||||||
memcpy(pVar->pz, pz, len);
|
memcpy(pVar->pz, pz, len);
|
||||||
pVar->nLen = (int32_t)len;
|
pVar->nLen = (int32_t)len;
|
||||||
break;
|
break;
|
||||||
|
@ -224,7 +224,7 @@ void taosVariantDestroy(SVariant *pVar) {
|
||||||
if (pVar == NULL) return;
|
if (pVar == NULL) return;
|
||||||
|
|
||||||
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
|
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
tfree(pVar->pz);
|
taosMemoryFreeClear(pVar->pz);
|
||||||
pVar->nLen = 0;
|
pVar->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ void taosVariantDestroy(SVariant *pVar) {
|
||||||
size_t num = taosArrayGetSize(pVar->arr);
|
size_t num = taosArrayGetSize(pVar->arr);
|
||||||
for (size_t i = 0; i < num; i++) {
|
for (size_t i = 0; i < num; i++) {
|
||||||
void *p = taosArrayGetP(pVar->arr, i);
|
void *p = taosArrayGetP(pVar->arr, i);
|
||||||
free(p);
|
taosMemoryFree(p);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pVar->arr);
|
taosArrayDestroy(pVar->arr);
|
||||||
pVar->arr = NULL;
|
pVar->arr = NULL;
|
||||||
|
@ -254,7 +254,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
|
||||||
pDst->nType = pSrc->nType;
|
pDst->nType = pSrc->nType;
|
||||||
if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) {
|
if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE;
|
int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE;
|
||||||
char *p = realloc(pDst->pz, len);
|
char *p = taosMemoryRealloc(pDst->pz, len);
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
memset(p, 0, len);
|
memset(p, 0, len);
|
||||||
|
@ -402,18 +402,18 @@ static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||||
|
|
||||||
// it is a in-place convert type for SVariant, local buffer is needed
|
// it is a in-place convert type for SVariant, local buffer is needed
|
||||||
if (*pDest == pVariant->pz) {
|
if (*pDest == pVariant->pz) {
|
||||||
pBuf = calloc(1, INITIAL_ALLOC_SIZE);
|
pBuf = taosMemoryCalloc(1, INITIAL_ALLOC_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE;
|
size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE;
|
||||||
if (pBuf != NULL) {
|
if (pBuf != NULL) {
|
||||||
if (newSize >= INITIAL_ALLOC_SIZE) {
|
if (newSize >= INITIAL_ALLOC_SIZE) {
|
||||||
pBuf = realloc(pBuf, newSize + 1);
|
pBuf = taosMemoryRealloc(pBuf, newSize + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf);
|
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf);
|
||||||
free(pVariant->ucs4);
|
taosMemoryFree(pVariant->ucs4);
|
||||||
pBuf[newSize] = 0;
|
pBuf[newSize] = 0;
|
||||||
} else {
|
} else {
|
||||||
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest);
|
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest);
|
||||||
|
@ -460,23 +460,23 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*pDest == pVariant->pz) {
|
if (*pDest == pVariant->pz) {
|
||||||
TdUcs4 *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
||||||
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
tfree(pWStr);
|
taosMemoryFreeClear(pWStr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the binary buffer in the first place
|
// free the binary buffer in the first place
|
||||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||||
free(pVariant->ucs4);
|
taosMemoryFree(pVariant->ucs4);
|
||||||
}
|
}
|
||||||
|
|
||||||
pVariant->ucs4 = pWStr;
|
pVariant->ucs4 = pWStr;
|
||||||
*pDestSize = taosUcs4len(pVariant->ucs4);
|
*pDestSize = taosUcs4len(pVariant->ucs4);
|
||||||
|
|
||||||
// shrink the allocate memory, no need to check here.
|
// shrink the allocate memory, no need to check here.
|
||||||
char *tmp = realloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE);
|
char *tmp = taosMemoryRealloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE);
|
||||||
assert(tmp != NULL);
|
assert(tmp != NULL);
|
||||||
|
|
||||||
pVariant->ucs4 = (TdUcs4 *)tmp;
|
pVariant->ucs4 = (TdUcs4 *)tmp;
|
||||||
|
@ -526,7 +526,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
|
|
||||||
if (token.type == TK_NULL) {
|
if (token.type == TK_NULL) {
|
||||||
if (releaseVariantPtr) {
|
if (releaseVariantPtr) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->nLen = 0;
|
pVariant->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
}
|
}
|
||||||
|
|
||||||
if (releaseVariantPtr) {
|
if (releaseVariantPtr) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->nLen = 0;
|
pVariant->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
if (token.type == TK_FLOAT) {
|
if (token.type == TK_FLOAT) {
|
||||||
double v = wcstod(pVariant->ucs4, &endPtr);
|
double v = wcstod(pVariant->ucs4, &endPtr);
|
||||||
if (releaseVariantPtr) {
|
if (releaseVariantPtr) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->nLen = 0;
|
pVariant->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
*result = (int64_t)v;
|
*result = (int64_t)v;
|
||||||
} else if (token.type == TK_NULL) {
|
} else if (token.type == TK_NULL) {
|
||||||
if (releaseVariantPtr) {
|
if (releaseVariantPtr) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->nLen = 0;
|
pVariant->nLen = 0;
|
||||||
}
|
}
|
||||||
setNull((char *)result, type, tDataTypes[type].bytes);
|
setNull((char *)result, type, tDataTypes[type].bytes);
|
||||||
|
@ -585,7 +585,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
} else {
|
} else {
|
||||||
int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10);
|
int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10);
|
||||||
if (releaseVariantPtr) {
|
if (releaseVariantPtr) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->nLen = 0;
|
pVariant->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,21 +971,21 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
double v = strtod(pVariant->pz, NULL);
|
double v = strtod(pVariant->pz, NULL);
|
||||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->d = v;
|
pVariant->d = v;
|
||||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
double v = wcstod(pVariant->ucs4, NULL);
|
double v = wcstod(pVariant->ucs4, NULL);
|
||||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pVariant->pz);
|
taosMemoryFree(pVariant->pz);
|
||||||
pVariant->d = v;
|
pVariant->d = v;
|
||||||
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
||||||
double tmp = (double)pVariant->i;
|
double tmp = (double)pVariant->i;
|
||||||
|
|
|
@ -99,7 +99,7 @@ TEST(testCase, toInteger_test) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, Datablock_test) {
|
TEST(testCase, Datablock_test) {
|
||||||
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock)));
|
SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
|
||||||
b->info.numOfCols = 2;
|
b->info.numOfCols = 2;
|
||||||
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ TEST(testCase, Datablock_test) {
|
||||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||||
infoData.info.colId = 1;
|
infoData.info.colId = 1;
|
||||||
|
|
||||||
infoData.pData = (char*) calloc(40, infoData.info.bytes);
|
infoData.pData = (char*) taosMemoryCalloc(40, infoData.info.bytes);
|
||||||
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (40/8));
|
infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (40/8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData);
|
taosArrayPush(b->pDataBlock, &infoData);
|
||||||
|
|
||||||
SColumnInfoData infoData1 = {0};
|
SColumnInfoData infoData1 = {0};
|
||||||
|
@ -117,7 +117,7 @@ TEST(testCase, Datablock_test) {
|
||||||
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
||||||
infoData1.info.colId = 2;
|
infoData1.info.colId = 2;
|
||||||
|
|
||||||
infoData1.varmeta.offset = (int32_t*) calloc(40, sizeof(uint32_t));
|
infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(40, sizeof(uint32_t));
|
||||||
taosArrayPush(b->pDataBlock, &infoData1);
|
taosArrayPush(b->pDataBlock, &infoData1);
|
||||||
|
|
||||||
char* str = "the value of: %d";
|
char* str = "the value of: %d";
|
||||||
|
@ -178,7 +178,7 @@ TEST(testCase, Datablock_test) {
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
TEST(testCase, non_var_dataBlock_split_test) {
|
TEST(testCase, non_var_dataBlock_split_test) {
|
||||||
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock)));
|
SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
|
||||||
b->info.numOfCols = 2;
|
b->info.numOfCols = 2;
|
||||||
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
@ -189,8 +189,8 @@ TEST(testCase, non_var_dataBlock_split_test) {
|
||||||
|
|
||||||
int32_t numOfRows = 1000000;
|
int32_t numOfRows = 1000000;
|
||||||
|
|
||||||
infoData.pData = (char*) calloc(numOfRows, infoData.info.bytes);
|
infoData.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
|
||||||
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8));
|
infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData);
|
taosArrayPush(b->pDataBlock, &infoData);
|
||||||
|
|
||||||
SColumnInfoData infoData1 = {0};
|
SColumnInfoData infoData1 = {0};
|
||||||
|
@ -198,8 +198,8 @@ TEST(testCase, non_var_dataBlock_split_test) {
|
||||||
infoData1.info.type = TSDB_DATA_TYPE_TINYINT;
|
infoData1.info.type = TSDB_DATA_TYPE_TINYINT;
|
||||||
infoData1.info.colId = 2;
|
infoData1.info.colId = 2;
|
||||||
|
|
||||||
infoData1.pData = (char*) calloc(numOfRows, infoData.info.bytes);
|
infoData1.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
|
||||||
infoData1.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8));
|
infoData1.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData1);
|
taosArrayPush(b->pDataBlock, &infoData1);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfRows; ++i) {
|
for(int32_t i = 0; i < numOfRows; ++i) {
|
||||||
|
@ -233,7 +233,7 @@ TEST(testCase, non_var_dataBlock_split_test) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(testCase, var_dataBlock_split_test) {
|
TEST(testCase, var_dataBlock_split_test) {
|
||||||
SSDataBlock* b = static_cast<SSDataBlock*>(calloc(1, sizeof(SSDataBlock)));
|
SSDataBlock* b = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
|
||||||
b->info.numOfCols = 2;
|
b->info.numOfCols = 2;
|
||||||
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
b->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
@ -244,8 +244,8 @@ TEST(testCase, var_dataBlock_split_test) {
|
||||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||||
infoData.info.colId = 1;
|
infoData.info.colId = 1;
|
||||||
|
|
||||||
infoData.pData = (char*) calloc(numOfRows, infoData.info.bytes);
|
infoData.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
|
||||||
infoData.nullbitmap = (char*) calloc(1, sizeof(char) * (numOfRows/8));
|
infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData);
|
taosArrayPush(b->pDataBlock, &infoData);
|
||||||
|
|
||||||
SColumnInfoData infoData1 = {0};
|
SColumnInfoData infoData1 = {0};
|
||||||
|
@ -253,7 +253,7 @@ TEST(testCase, var_dataBlock_split_test) {
|
||||||
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
||||||
infoData1.info.colId = 2;
|
infoData1.info.colId = 2;
|
||||||
|
|
||||||
infoData1.varmeta.offset = (int32_t*) calloc(numOfRows, sizeof(uint32_t));
|
infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(numOfRows, sizeof(uint32_t));
|
||||||
taosArrayPush(b->pDataBlock, &infoData1);
|
taosArrayPush(b->pDataBlock, &infoData1);
|
||||||
|
|
||||||
char buf[41] = {0};
|
char buf[41] = {0};
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#include "bndInt.h"
|
#include "bndInt.h"
|
||||||
|
|
||||||
SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) {
|
SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) {
|
||||||
SBnode *pBnode = calloc(1, sizeof(SBnode));
|
SBnode *pBnode = taosMemoryCalloc(1, sizeof(SBnode));
|
||||||
pBnode->msgCb = pOption->msgCb;
|
pBnode->msgCb = pOption->msgCb;
|
||||||
return pBnode;
|
return pBnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bndClose(SBnode *pBnode) { free(pBnode); }
|
void bndClose(SBnode *pBnode) { taosMemoryFree(pBnode); }
|
||||||
|
|
||||||
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
|
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ int32_t bmDrop(SMgmtWrapper *pWrapper) {
|
||||||
bmCloseImp(pMgmt);
|
bmCloseImp(pMgmt);
|
||||||
taosRemoveDir(pMgmt->path);
|
taosRemoveDir(pMgmt->path);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("bnode-mgmt is dropped");
|
dInfo("bnode-mgmt is dropped");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ static void bmClose(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("bnode-mgmt start to cleanup");
|
dInfo("bnode-mgmt start to cleanup");
|
||||||
bmCloseImp(pMgmt);
|
bmCloseImp(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("bnode-mgmt is cleaned up");
|
dInfo("bnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bmOpen(SMgmtWrapper *pWrapper) {
|
int32_t bmOpen(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("bnode-mgmt start to init");
|
dInfo("bnode-mgmt start to init");
|
||||||
SBnodeMgmt *pMgmt = calloc(1, sizeof(SBnodeMgmt));
|
SBnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SBnodeMgmt));
|
||||||
if (pMgmt == NULL) {
|
if (pMgmt == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -77,7 +77,11 @@ int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dDebug("bnode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bmStopWorker(SBnodeMgmt *pMgmt) { tMultiWorkerCleanup(&pMgmt->writeWorker); }
|
void bmStopWorker(SBnodeMgmt *pMgmt) {
|
||||||
|
tMultiWorkerCleanup(&pMgmt->writeWorker);
|
||||||
|
dDebug("bnode workers are closed");
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "monitor.h"
|
|
||||||
#include "tcache.h"
|
#include "tcache.h"
|
||||||
#include "tcrc32c.h"
|
#include "tcrc32c.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
@ -36,8 +35,7 @@
|
||||||
#include "tworker.h"
|
#include "tworker.h"
|
||||||
|
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "tfs.h"
|
#include "monitor.h"
|
||||||
#include "wal.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -53,7 +51,6 @@ extern "C" {
|
||||||
typedef enum { DNODE, VNODES, QNODE, SNODE, MNODE, BNODE, NODE_MAX } ENodeType;
|
typedef enum { DNODE, VNODES, QNODE, SNODE, MNODE, BNODE, NODE_MAX } ENodeType;
|
||||||
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EDndStatus;
|
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EDndStatus;
|
||||||
typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANUP } EEnvStatus;
|
typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANUP } EEnvStatus;
|
||||||
typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EWorkerType;
|
|
||||||
typedef enum { PROC_SINGLE, PROC_CHILD, PROC_PARENT } EProcType;
|
typedef enum { PROC_SINGLE, PROC_CHILD, PROC_PARENT } EProcType;
|
||||||
|
|
||||||
typedef struct SMgmtFp SMgmtFp;
|
typedef struct SMgmtFp SMgmtFp;
|
||||||
|
@ -75,10 +72,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
||||||
typedef int32_t (*RequireNodeFp)(SMgmtWrapper *pWrapper, bool *required);
|
typedef int32_t (*RequireNodeFp)(SMgmtWrapper *pWrapper, bool *required);
|
||||||
|
|
||||||
typedef struct SMsgHandle {
|
typedef struct SMsgHandle {
|
||||||
int32_t vgId;
|
SMgmtWrapper *pQndWrapper;
|
||||||
NodeMsgFp vgIdMsgFp;
|
SMgmtWrapper *pMndWrapper;
|
||||||
SMgmtWrapper *pVgIdWrapper; // Handle the case where the same message type is distributed to qnode or vnode
|
|
||||||
NodeMsgFp msgFp;
|
|
||||||
SMgmtWrapper *pWrapper;
|
SMgmtWrapper *pWrapper;
|
||||||
} SMsgHandle;
|
} SMsgHandle;
|
||||||
|
|
||||||
|
@ -129,29 +124,30 @@ typedef struct SDnode {
|
||||||
bool dropped;
|
bool dropped;
|
||||||
EDndStatus status;
|
EDndStatus status;
|
||||||
EDndEvent event;
|
EDndEvent event;
|
||||||
EProcType procType;
|
|
||||||
SStartupReq startup;
|
SStartupReq startup;
|
||||||
TdFilePtr pLockFile;
|
TdFilePtr pLockFile;
|
||||||
STransMgmt trans;
|
STransMgmt trans;
|
||||||
SMgmtWrapper wrappers[NODE_MAX];
|
SMgmtWrapper wrappers[NODE_MAX];
|
||||||
} SDnode;
|
} SDnode;
|
||||||
|
|
||||||
EDndStatus dndGetStatus(SDnode *pDnode);
|
EDndStatus dndGetStatus(SDnode *pDnode);
|
||||||
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
||||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
||||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||||
void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc);
|
void dndSendMonitorReport(SDnode *pDnode);
|
||||||
void dndSendMonitorReport(SDnode *pDnode);
|
|
||||||
|
|
||||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg);
|
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp);
|
void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp);
|
||||||
|
|
||||||
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
||||||
|
|
||||||
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
||||||
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed);
|
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed);
|
||||||
|
|
||||||
|
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
||||||
|
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
|
||||||
|
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,7 +34,7 @@ int32_t dndInit();
|
||||||
void dndCleanup();
|
void dndCleanup();
|
||||||
const char *dndStatStr(EDndStatus stat);
|
const char *dndStatStr(EDndStatus stat);
|
||||||
void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup);
|
void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup);
|
||||||
TdFilePtr dndCheckRunning(char *dataDir);
|
TdFilePtr dndCheckRunning(const char *dataDir);
|
||||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
|
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dndMsg.c
|
// dndMsg.c
|
||||||
|
@ -50,10 +50,6 @@ SDnode *dndCreate(const SDnodeOpt *pOption);
|
||||||
void dndClose(SDnode *pDnode);
|
void dndClose(SDnode *pDnode);
|
||||||
void dndHandleEvent(SDnode *pDnode, EDndEvent event);
|
void dndHandleEvent(SDnode *pDnode, EDndEvent event);
|
||||||
|
|
||||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
|
||||||
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
|
|
||||||
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
|
|
||||||
|
|
||||||
// dndTransport.c
|
// dndTransport.c
|
||||||
int32_t dndInitServer(SDnode *pDnode);
|
int32_t dndInitServer(SDnode *pDnode);
|
||||||
void dndCleanupServer(SDnode *pDnode);
|
void dndCleanupServer(SDnode *pDnode);
|
||||||
|
|
|
@ -50,16 +50,23 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
|
dDebug("node:%s, start to close", pWrapper->name);
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosWLockLatch(&pWrapper->latch);
|
||||||
if (pWrapper->deployed) {
|
if (pWrapper->deployed) {
|
||||||
(*pWrapper->fp.closeFp)(pWrapper);
|
(*pWrapper->fp.closeFp)(pWrapper);
|
||||||
pWrapper->deployed = false;
|
pWrapper->deployed = false;
|
||||||
}
|
}
|
||||||
|
taosWUnLockLatch(&pWrapper->latch);
|
||||||
|
|
||||||
|
while (pWrapper->refCount > 0) {
|
||||||
|
taosMsleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
if (pWrapper->pProc) {
|
if (pWrapper->pProc) {
|
||||||
taosProcCleanup(pWrapper->pProc);
|
taosProcCleanup(pWrapper->pProc);
|
||||||
pWrapper->pProc = NULL;
|
pWrapper->pProc = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pWrapper->latch);
|
dDebug("node:%s, has been closed", pWrapper->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
|
@ -132,7 +139,7 @@ static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRsp, int32_t
|
||||||
dTrace("msg:%p, get from parent queue", pRsp);
|
dTrace("msg:%p, get from parent queue", pRsp);
|
||||||
pRsp->pCont = pCont;
|
pRsp->pCont = pCont;
|
||||||
dndSendRpcRsp(pWrapper, pRsp);
|
dndSendRpcRsp(pWrapper, pRsp);
|
||||||
free(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
|
@ -167,8 +174,8 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
.childFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
||||||
.parentQueueSize = 1024 * 1024 * 2, // size will be a configuration item
|
.parentQueueSize = 1024 * 1024 * 2, // size will be a configuration item
|
||||||
.parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue,
|
.parentConsumeFp = (ProcConsumeFp)dndConsumeParentQueue,
|
||||||
.parentdMallocHeadFp = (ProcMallocFp)malloc,
|
.parentdMallocHeadFp = (ProcMallocFp)taosMemoryMalloc,
|
||||||
.parentFreeHeadFp = (ProcFreeFp)free,
|
.parentFreeHeadFp = (ProcFreeFp)taosMemoryFree,
|
||||||
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
.parentMallocBodyFp = (ProcMallocFp)rpcMallocCont,
|
||||||
.parentFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
.parentFreeBodyFp = (ProcFreeFp)rpcFreeCont,
|
||||||
.testFlag = 0,
|
.testFlag = 0,
|
||||||
|
|
|
@ -20,7 +20,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
|
||||||
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 1024;
|
int32_t maxLen = 1024;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
|
@ -57,7 +57,7 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
|
||||||
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (content != NULL) free(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 1024;
|
int32_t maxLen = 1024;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
|
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
|
||||||
|
@ -87,7 +87,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
|
||||||
taosWriteFile(pFile, content, len);
|
taosWriteFile(pFile, content, len);
|
||||||
taosFsyncFile(pFile);
|
taosFsyncFile(pFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
free(content);
|
taosMemoryFree(content);
|
||||||
|
|
||||||
char realfile[PATH_MAX];
|
char realfile[PATH_MAX];
|
||||||
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
|
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dndInt.h"
|
#include "dndInt.h"
|
||||||
|
#include "wal.h"
|
||||||
|
|
||||||
static int8_t once = DND_ENV_INIT;
|
static int8_t once = DND_ENV_INIT;
|
||||||
|
|
||||||
int32_t dndInit() {
|
int32_t dndInit() {
|
||||||
dDebug("start to init dnode env");
|
dInfo("start to init dnode env");
|
||||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||||
terrno = TSDB_CODE_REPEAT_INIT;
|
terrno = TSDB_CODE_REPEAT_INIT;
|
||||||
dError("failed to init dnode env since %s", terrstr());
|
dError("failed to init dnode env since %s", terrstr());
|
||||||
|
@ -52,7 +53,7 @@ int32_t dndInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCleanup() {
|
void dndCleanup() {
|
||||||
dDebug("start to cleanup dnode env");
|
dInfo("start to cleanup dnode env");
|
||||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||||
dError("dnode env is already cleaned up");
|
dError("dnode env is already cleaned up");
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +93,7 @@ const char *dndStatStr(EDndStatus status) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc) {
|
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
||||||
SStartupReq *pStartup = &pDnode->startup;
|
SStartupReq *pStartup = &pDnode->startup;
|
||||||
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
||||||
tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN);
|
tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN);
|
||||||
|
@ -104,21 +105,21 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
|
||||||
pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING);
|
pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
TdFilePtr dndCheckRunning(char *dataDir) {
|
TdFilePtr dndCheckRunning(const char *dataDir) {
|
||||||
char filepath[PATH_MAX] = {0};
|
char filepath[PATH_MAX] = {0};
|
||||||
snprintf(filepath, sizeof(filepath), "%s/.running", dataDir);
|
snprintf(filepath, sizeof(filepath), "%s/.running", dataDir);
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
dError("failed to lock file:%s since %s", filepath, terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = taosLockFile(pFile);
|
int32_t ret = taosLockFile(pFile);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
dError("failed to lock file:%s since %s", filepath, terrstr());
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +130,10 @@ TdFilePtr dndCheckRunning(char *dataDir) {
|
||||||
|
|
||||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
dDebug("startup req is received");
|
dDebug("startup req is received");
|
||||||
|
|
||||||
SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq));
|
SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq));
|
||||||
dndGetStartup(pDnode, pStartup);
|
dndGetStartup(pDnode, pStartup);
|
||||||
|
|
||||||
dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {.handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq)};
|
SRpcMsg rpcRsp = {.handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq)};
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,12 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
|
||||||
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
||||||
pInfo->tempdir.size = tsTempSpace.size;
|
pInfo->tempdir.size = tsTempSpace.size;
|
||||||
|
|
||||||
return vmMonitorTfsInfo(dndAcquireWrapper(pDnode, VNODES), pInfo);
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||||
|
if (pWrapper != NULL) {
|
||||||
|
vmMonitorTfsInfo(pWrapper, pInfo);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||||
|
@ -45,8 +50,17 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
||||||
taosGetCardInfo(&pInfo->net_in, &pInfo->net_out);
|
taosGetCardInfo(&pInfo->net_in, &pInfo->net_out);
|
||||||
taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
||||||
|
|
||||||
vmMonitorVnodeReqs(dndAcquireWrapper(pDnode, VNODES), pInfo);
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||||
pInfo->has_mnode = (dndAcquireWrapper(pDnode, MNODE)->required);
|
if (pWrapper != NULL) {
|
||||||
|
vmMonitorVnodeReqs(pWrapper, pInfo);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||||
|
if (pWrapper != NULL) {
|
||||||
|
pInfo->has_mnode = pWrapper->required;
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndSendMonitorReport(SDnode *pDnode) {
|
void dndSendMonitorReport(SDnode *pDnode) {
|
||||||
|
@ -63,10 +77,15 @@ void dndSendMonitorReport(SDnode *pDnode) {
|
||||||
SMonClusterInfo clusterInfo = {0};
|
SMonClusterInfo clusterInfo = {0};
|
||||||
SMonVgroupInfo vgroupInfo = {0};
|
SMonVgroupInfo vgroupInfo = {0};
|
||||||
SMonGrantInfo grantInfo = {0};
|
SMonGrantInfo grantInfo = {0};
|
||||||
if (mmMonitorMnodeInfo(dndAcquireWrapper(pDnode, MNODE), &clusterInfo, &vgroupInfo, &grantInfo) == 0) {
|
|
||||||
monSetClusterInfo(pMonitor, &clusterInfo);
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||||
monSetVgroupInfo(pMonitor, &vgroupInfo);
|
if (pWrapper != NULL) {
|
||||||
monSetGrantInfo(pMonitor, &grantInfo);
|
if (mmMonitorMnodeInfo(pWrapper, &clusterInfo, &vgroupInfo, &grantInfo) == 0) {
|
||||||
|
monSetClusterInfo(pMonitor, &clusterInfo);
|
||||||
|
monSetVgroupInfo(pMonitor, &vgroupInfo);
|
||||||
|
monSetGrantInfo(pMonitor, &grantInfo);
|
||||||
|
}
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonDnodeInfo dnodeInfo = {0};
|
SMonDnodeInfo dnodeInfo = {0};
|
||||||
|
|
|
@ -20,8 +20,8 @@ static void dndUpdateMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||||
if (pWrapper != NULL) {
|
if (pWrapper != NULL) {
|
||||||
dmUpdateMnodeEpSet(pWrapper->pMgmt, pEpSet);
|
dmUpdateMnodeEpSet(pWrapper->pMgmt, pEpSet);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
dndReleaseWrapper(pWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
|
|
@ -39,29 +39,29 @@ static int32_t dndInitMemory(SDnode *pDnode, const SDnodeOpt *pOption) {
|
||||||
static void dndClearMemory(SDnode *pDnode) {
|
static void dndClearMemory(SDnode *pDnode) {
|
||||||
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
for (ENodeType n = 0; n < NODE_MAX; ++n) {
|
||||||
SMgmtWrapper *pMgmt = &pDnode->wrappers[n];
|
SMgmtWrapper *pMgmt = &pDnode->wrappers[n];
|
||||||
tfree(pMgmt->path);
|
taosMemoryFreeClear(pMgmt->path);
|
||||||
}
|
}
|
||||||
if (pDnode->pLockFile != NULL) {
|
if (pDnode->pLockFile != NULL) {
|
||||||
taosUnLockFile(pDnode->pLockFile);
|
taosUnLockFile(pDnode->pLockFile);
|
||||||
taosCloseFile(&pDnode->pLockFile);
|
taosCloseFile(&pDnode->pLockFile);
|
||||||
pDnode->pLockFile = NULL;
|
pDnode->pLockFile = NULL;
|
||||||
}
|
}
|
||||||
tfree(pDnode->localEp);
|
taosMemoryFreeClear(pDnode->localEp);
|
||||||
tfree(pDnode->localFqdn);
|
taosMemoryFreeClear(pDnode->localFqdn);
|
||||||
tfree(pDnode->firstEp);
|
taosMemoryFreeClear(pDnode->firstEp);
|
||||||
tfree(pDnode->secondEp);
|
taosMemoryFreeClear(pDnode->secondEp);
|
||||||
tfree(pDnode->dataDir);
|
taosMemoryFreeClear(pDnode->dataDir);
|
||||||
free(pDnode);
|
taosMemoryFree(pDnode);
|
||||||
dDebug("dnode object memory is cleared, data:%p", pDnode);
|
dDebug("dnode object memory is cleared, data:%p", pDnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnode *dndCreate(const SDnodeOpt *pOption) {
|
SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||||
dInfo("start to create dnode object");
|
dInfo("start to create dnode object");
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX] = {0};
|
||||||
SDnode *pDnode = NULL;
|
SDnode *pDnode = NULL;
|
||||||
|
|
||||||
pDnode = calloc(1, sizeof(SDnode));
|
pDnode = taosMemoryCalloc(1, sizeof(SDnode));
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && pDnode) {
|
if (code != 0 && pDnode) {
|
||||||
dndClearMemory(pDnode);
|
dndClearMemory(pDnode);
|
||||||
|
pDnode = NULL;
|
||||||
dError("failed to create dnode object since %s", terrstr());
|
dError("failed to create dnode object since %s", terrstr());
|
||||||
} else {
|
} else {
|
||||||
dInfo("dnode object is created, data:%p", pDnode);
|
dInfo("dnode object is created, data:%p", pDnode);
|
||||||
|
|
|
@ -20,13 +20,15 @@
|
||||||
#define INTERNAL_CKEY "_key"
|
#define INTERNAL_CKEY "_key"
|
||||||
#define INTERNAL_SECRET "_pwd"
|
#define INTERNAL_SECRET "_pwd"
|
||||||
|
|
||||||
static inline void dndProcessQVnodeRpcMsg(SMsgHandle *pHandle, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
static inline void dndProcessQMVnodeRpcMsg(SMsgHandle *pHandle, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
int32_t vgId = htonl(pHead->vgId);
|
int32_t vgId = htonl(pHead->vgId);
|
||||||
|
|
||||||
SMgmtWrapper *pWrapper = pHandle->pWrapper;
|
SMgmtWrapper *pWrapper = pHandle->pWrapper;
|
||||||
if (vgId == pHandle->vgId && pHandle->pVgIdWrapper != NULL) {
|
if (vgId == QND_VGID) {
|
||||||
pWrapper = pHandle->pVgIdWrapper;
|
pWrapper = pHandle->pQndWrapper;
|
||||||
|
} else if (vgId == MND_VGID) {
|
||||||
|
pWrapper = pHandle->pMndWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%s will be processed by %s, handle:%p app:%p vgId:%d", TMSG_INFO(pMsg->msgType), pWrapper->name,
|
dTrace("msg:%s will be processed by %s, handle:%p app:%p vgId:%d", TMSG_INFO(pMsg->msgType), pWrapper->name,
|
||||||
|
@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
||||||
if (pHandle->msgFp != NULL) {
|
if (pHandle->pWrapper != NULL) {
|
||||||
if (pHandle->vgId == 0) {
|
if (pHandle->pMndWrapper == NULL && pHandle->pQndWrapper == NULL) {
|
||||||
dTrace("rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s", TMSG_INFO(msgType),
|
dTrace("rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s", TMSG_INFO(msgType),
|
||||||
pHandle->pWrapper->name, pRsp->handle, pRsp->ahandle, pRsp->code & 0XFFFF, tstrerror(pRsp->code));
|
pHandle->pWrapper->name, pRsp->handle, pRsp->ahandle, pRsp->code & 0XFFFF, tstrerror(pRsp->code));
|
||||||
dndProcessRpcMsg(pHandle->pWrapper, pRsp, pEpSet);
|
dndProcessRpcMsg(pHandle->pWrapper, pRsp, pEpSet);
|
||||||
} else {
|
} else {
|
||||||
dndProcessQVnodeRpcMsg(pHandle, pRsp, pEpSet);
|
dndProcessQMVnodeRpcMsg(pHandle, pRsp, pEpSet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dError("rsp:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pRsp->handle, pRsp->ahandle);
|
dError("rsp:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pRsp->handle, pRsp->ahandle);
|
||||||
|
@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
||||||
if (pHandle->msgFp != NULL) {
|
if (pHandle->pWrapper != NULL) {
|
||||||
if (pHandle->vgId == 0) {
|
if (pHandle->pMndWrapper == NULL && pHandle->pQndWrapper == NULL) {
|
||||||
dTrace("req:%s will be processed by %s, handle:%p app:%p", TMSG_INFO(msgType), pHandle->pWrapper->name,
|
dTrace("req:%s will be processed by %s, handle:%p app:%p", TMSG_INFO(msgType), pHandle->pWrapper->name,
|
||||||
pReq->handle, pReq->ahandle);
|
pReq->handle, pReq->ahandle);
|
||||||
dndProcessRpcMsg(pHandle->pWrapper, pReq, pEpSet);
|
dndProcessRpcMsg(pHandle->pWrapper, pReq, pEpSet);
|
||||||
} else {
|
} else {
|
||||||
dndProcessQVnodeRpcMsg(pHandle, pReq, pEpSet);
|
dndProcessQMVnodeRpcMsg(pHandle, pReq, pEpSet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dError("req:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pReq->handle, pReq->ahandle);
|
dError("req:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pReq->handle, pReq->ahandle);
|
||||||
|
@ -144,9 +146,14 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
|
||||||
|
|
||||||
static void dndSendMsgToMnodeRecv(SDnode *pDnode, SRpcMsg *pRpcMsg, SRpcMsg *pRpcRsp) {
|
static void dndSendMsgToMnodeRecv(SDnode *pDnode, SRpcMsg *pRpcMsg, SRpcMsg *pRpcRsp) {
|
||||||
STransMgmt *pMgmt = &pDnode->trans;
|
STransMgmt *pMgmt = &pDnode->trans;
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
|
||||||
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||||
|
if (pWrapper != NULL) {
|
||||||
|
dmGetMnodeEpSet(pWrapper->pMgmt, &epSet);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
SEpSet epSet = {0};
|
|
||||||
dmGetMnodeEpSet(dndAcquireWrapper(pDnode, DNODE)->pMgmt, &epSet);
|
|
||||||
rpcSendRecv(pMgmt->clientRpc, &epSet, pRpcMsg, pRpcRsp);
|
rpcSendRecv(pMgmt->clientRpc, &epSet, pRpcMsg, pRpcRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,9 +187,14 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmGetUserAuth(dndAcquireWrapper(pDnode, MNODE), user, spi, encrypt, secret, ckey) == 0) {
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||||
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
if (pWrapper != NULL) {
|
||||||
return 0;
|
if (mmGetUserAuth(pWrapper, user, spi, encrypt, secret, ckey) == 0) {
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_APP_NOT_READY) {
|
if (terrno != TSDB_CODE_APP_NOT_READY) {
|
||||||
|
@ -269,21 +281,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
|
||||||
int32_t vgId = pWrapper->msgVgIds[msgIndex];
|
int32_t vgId = pWrapper->msgVgIds[msgIndex];
|
||||||
if (msgFp == NULL) continue;
|
if (msgFp == NULL) continue;
|
||||||
|
|
||||||
|
// dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId);
|
||||||
|
|
||||||
SMsgHandle *pHandle = &pMgmt->msgHandles[msgIndex];
|
SMsgHandle *pHandle = &pMgmt->msgHandles[msgIndex];
|
||||||
if (pHandle->msgFp != NULL && pHandle->vgId == vgId) {
|
if (vgId == QND_VGID) {
|
||||||
dError("msg:%s has multiple process nodes, prev node:%s:%d, curr node:%s:%d", tMsgInfo[msgIndex],
|
if (pHandle->pQndWrapper != NULL) {
|
||||||
pHandle->pWrapper->name, pHandle->pWrapper->msgVgIds[msgIndex], pWrapper->name, vgId);
|
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId);
|
|
||||||
if (vgId == 0) {
|
|
||||||
pHandle->msgFp = msgFp;
|
|
||||||
pHandle->pWrapper = pWrapper;
|
|
||||||
} else {
|
|
||||||
pHandle->vgId = vgId;
|
|
||||||
pHandle->vgIdMsgFp = msgFp;
|
|
||||||
pHandle->pVgIdWrapper = pWrapper;
|
|
||||||
}
|
}
|
||||||
|
pHandle->pQndWrapper = pWrapper;
|
||||||
|
} else if (vgId == MND_VGID) {
|
||||||
|
if (pHandle->pMndWrapper != NULL) {
|
||||||
|
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pHandle->pMndWrapper = pWrapper;
|
||||||
|
} else {
|
||||||
|
if (pHandle->pWrapper != NULL) {
|
||||||
|
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pHandle->pWrapper = pWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,7 +338,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
STransMgmt *pTrans = &pDnode->trans;
|
STransMgmt *pTrans = &pDnode->trans;
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dmGetMnodeEpSet(dndAcquireWrapper(pDnode, DNODE)->pMgmt, &epSet);
|
|
||||||
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||||
|
if (pWrapper != NULL) {
|
||||||
|
dmGetMnodeEpSet(pWrapper->pMgmt, &epSet);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
return dndSendRpcReq(pTrans, &epSet, pReq);
|
return dndSendRpcReq(pTrans, &epSet, pReq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +351,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
||||||
void dndSendRpcRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
void dndSendRpcRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
||||||
if (pRsp->code == TSDB_CODE_APP_NOT_READY) {
|
if (pRsp->code == TSDB_CODE_APP_NOT_READY) {
|
||||||
SMgmtWrapper *pDnodeWrapper = dndAcquireWrapper(pWrapper->pDnode, DNODE);
|
SMgmtWrapper *pDnodeWrapper = dndAcquireWrapper(pWrapper->pDnode, DNODE);
|
||||||
dmSendRedirectRsp(pDnodeWrapper->pMgmt, pRsp);
|
if (pDnodeWrapper != NULL) {
|
||||||
|
dmSendRedirectRsp(pDnodeWrapper->pMgmt, pRsp);
|
||||||
|
dndReleaseWrapper(pDnodeWrapper);
|
||||||
|
} else {
|
||||||
|
rpcSendResponse(pRsp);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rpcSendResponse(pRsp);
|
rpcSendResponse(pRsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) {
|
||||||
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 256 * 1024;
|
int32_t maxLen = 256 * 1024;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
|
@ -134,7 +134,7 @@ int32_t dmReadFile(SDnodeMgmt *pMgmt) {
|
||||||
dmPrintDnodes(pMgmt);
|
dmPrintDnodes(pMgmt);
|
||||||
|
|
||||||
PRASE_DNODE_OVER:
|
PRASE_DNODE_OVER:
|
||||||
if (content != NULL) free(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 256 * 1024;
|
int32_t maxLen = 256 * 1024;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pDnode->dnodeId);
|
len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d,\n", pDnode->dnodeId);
|
||||||
|
@ -197,7 +197,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
|
||||||
taosWriteFile(pFile, content, len);
|
taosWriteFile(pFile, content, len);
|
||||||
taosFsyncFile(pFile);
|
taosFsyncFile(pFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
free(content);
|
taosMemoryFree(content);
|
||||||
|
|
||||||
char realfile[PATH_MAX];
|
char realfile[PATH_MAX];
|
||||||
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
||||||
|
@ -209,7 +209,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pMgmt->updateTime = taosGetTimestampMs();
|
pMgmt->updateTime = taosGetTimestampMs();
|
||||||
dDebug("successed to write %s", file);
|
dDebug("successed to write %s", realfile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,14 +74,14 @@ void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmStart(SMgmtWrapper *pWrapper) {
|
static int32_t dmStart(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("dnode mgmt start to run");
|
dDebug("dnode-mgmt start to run");
|
||||||
return dmStartThread(pWrapper->pMgmt);
|
return dmStartThread(pWrapper->pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmInit(SMgmtWrapper *pWrapper) {
|
int32_t dmInit(SMgmtWrapper *pWrapper) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
SDnodeMgmt *pMgmt = calloc(1, sizeof(SDnodeMgmt));
|
SDnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SDnodeMgmt));
|
||||||
dInfo("dnode-mgmt is initialized");
|
dInfo("dnode-mgmt start to init");
|
||||||
|
|
||||||
pDnode->dnodeId = 0;
|
pDnode->dnodeId = 0;
|
||||||
pDnode->dropped = 0;
|
pDnode->dropped = 0;
|
||||||
|
@ -138,7 +138,7 @@ void dmCleanup(SMgmtWrapper *pWrapper) {
|
||||||
|
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosWUnLockLatch(&pMgmt->latch);
|
||||||
|
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
dInfo("dnode-mgmt is cleaned up");
|
dInfo("dnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosRUnLockLatch(&pMgmt->latch);
|
||||||
|
|
||||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||||
vmMonitorVnodeLoads(dndAcquireWrapper(pDnode, VNODES), req.pVloads);
|
if (pWrapper != NULL) {
|
||||||
|
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||||
|
vmMonitorVnodeLoads(pWrapper, req.pVloads);
|
||||||
|
dndReleaseWrapper(pWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
@ -114,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void dmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void dmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by DNODE
|
// Requests handled by DNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dDebug("dnode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
|
||||||
taosDestoryThread(pMgmt->threadId);
|
taosDestoryThread(pMgmt->threadId);
|
||||||
pMgmt->threadId = NULL;
|
pMgmt->threadId = NULL;
|
||||||
}
|
}
|
||||||
|
dDebug("dnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
@ -144,6 +146,6 @@ int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
pWorker = &pMgmt->statusWorker;
|
pWorker = &pMgmt->statusWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
dTrace("msg:%p, will be written to worker %s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||||
return taosWriteQitem(pWorker->queue, pMsg);
|
return taosWriteQitem(pWorker->queue, pMsg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
|
||||||
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 4096;
|
int32_t maxLen = 4096;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
|
@ -97,7 +97,7 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
|
||||||
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
||||||
|
|
||||||
PRASE_MNODE_OVER:
|
PRASE_MNODE_OVER:
|
||||||
if (content != NULL) free(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 4096;
|
int32_t maxLen = 4096;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", deployed);
|
len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", deployed);
|
||||||
|
@ -139,7 +139,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
|
||||||
taosWriteFile(pFile, content, len);
|
taosWriteFile(pFile, content, len);
|
||||||
taosFsyncFile(pFile);
|
taosFsyncFile(pFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
free(content);
|
taosMemoryFree(content);
|
||||||
|
|
||||||
char realfile[PATH_MAX];
|
char realfile[PATH_MAX];
|
||||||
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mmInt.h"
|
#include "mmInt.h"
|
||||||
|
#include "wal.h"
|
||||||
|
|
||||||
static bool mmDeployRequired(SDnode *pDnode) {
|
static bool mmDeployRequired(SDnode *pDnode) {
|
||||||
if (pDnode->dnodeId > 0) return false;
|
if (pDnode->dnodeId > 0) return false;
|
||||||
|
@ -176,7 +177,7 @@ int32_t mmDrop(SMgmtWrapper *pWrapper) {
|
||||||
mmCloseImp(pMgmt);
|
mmCloseImp(pMgmt);
|
||||||
taosRemoveDir(pMgmt->path);
|
taosRemoveDir(pMgmt->path);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("mnode-mgmt is dropped");
|
dInfo("mnode-mgmt is dropped");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +189,7 @@ static void mmClose(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("mnode-mgmt start to cleanup");
|
dInfo("mnode-mgmt start to cleanup");
|
||||||
mmCloseImp(pMgmt);
|
mmCloseImp(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("mnode-mgmt is cleaned up");
|
dInfo("mnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ int32_t mmOpenFromMsg(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnodeMgmt *pMgmt = calloc(1, sizeof(SMnodeMgmt));
|
SMnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SMnodeMgmt));
|
||||||
if (pMgmt == NULL) {
|
if (pMgmt == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -226,7 +227,7 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mmStart(SMgmtWrapper *pWrapper) {
|
static int32_t mmStart(SMgmtWrapper *pWrapper) {
|
||||||
dDebug("mnode mgmt start to run");
|
dDebug("mnode-mgmt start to run");
|
||||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
return mndStart(pMgmt->pMnode);
|
return mndStart(pMgmt->pMnode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,78 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by DNODE
|
// Requests handled by DNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||||
|
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dDebug("mnode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,4 +116,5 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
|
||||||
tSingleWorkerCleanup(&pMgmt->readWorker);
|
tSingleWorkerCleanup(&pMgmt->readWorker);
|
||||||
tSingleWorkerCleanup(&pMgmt->writeWorker);
|
tSingleWorkerCleanup(&pMgmt->writeWorker);
|
||||||
tSingleWorkerCleanup(&pMgmt->syncWorker);
|
tSingleWorkerCleanup(&pMgmt->syncWorker);
|
||||||
|
dDebug("mnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ int32_t qmDrop(SMgmtWrapper *pWrapper) {
|
||||||
qmCloseImp(pMgmt);
|
qmCloseImp(pMgmt);
|
||||||
taosRemoveDir(pMgmt->path);
|
taosRemoveDir(pMgmt->path);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("qnode-mgmt is dropped");
|
dInfo("qnode-mgmt is dropped");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,13 @@ static void qmClose(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("qnode-mgmt start to cleanup");
|
dInfo("qnode-mgmt start to cleanup");
|
||||||
qmCloseImp(pMgmt);
|
qmCloseImp(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("qnode-mgmt is cleaned up");
|
dInfo("qnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmOpen(SMgmtWrapper *pWrapper) {
|
int32_t qmOpen(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("qnode-mgmt start to init");
|
dInfo("qnode-mgmt start to init");
|
||||||
SQnodeMgmt *pMgmt = calloc(1, sizeof(SQnodeMgmt));
|
SQnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SQnodeMgmt));
|
||||||
if (pMgmt == NULL) {
|
if (pMgmt == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void qmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void qmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, 1);
|
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,10 +132,12 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dDebug("qnode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmStopWorker(SQnodeMgmt *pMgmt) {
|
void qmStopWorker(SQnodeMgmt *pMgmt) {
|
||||||
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
||||||
tSingleWorkerCleanup(&pMgmt->fetchWorker);
|
tSingleWorkerCleanup(&pMgmt->fetchWorker);
|
||||||
|
dDebug("qnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ int32_t smDrop(SMgmtWrapper *pWrapper) {
|
||||||
smCloseImp(pMgmt);
|
smCloseImp(pMgmt);
|
||||||
taosRemoveDir(pMgmt->path);
|
taosRemoveDir(pMgmt->path);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("snode-mgmt is dropped");
|
dInfo("snode-mgmt is dropped");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ static void smClose(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("snode-mgmt start to cleanup");
|
dInfo("snode-mgmt start to cleanup");
|
||||||
smCloseImp(pMgmt);
|
smCloseImp(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
dInfo("snode-mgmt is cleaned up");
|
dInfo("snode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smOpen(SMgmtWrapper *pWrapper) {
|
int32_t smOpen(SMgmtWrapper *pWrapper) {
|
||||||
dInfo("snode-mgmt start to init");
|
dInfo("snode-mgmt start to init");
|
||||||
SSnodeMgmt *pMgmt = calloc(1, sizeof(SSnodeMgmt));
|
SSnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SSnodeMgmt));
|
||||||
if (pMgmt == NULL) {
|
if (pMgmt == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void smInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void smInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by SNODE
|
// Requests handled by SNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, VND_VGID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) {
|
for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) {
|
||||||
SMultiWorker *pUniqueWorker = malloc(sizeof(SMultiWorker));
|
SMultiWorker *pUniqueWorker = taosMemoryMalloc(sizeof(SMultiWorker));
|
||||||
if (pUniqueWorker == NULL) {
|
if (pUniqueWorker == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -80,6 +80,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dDebug("snode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,18 +91,20 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pMgmt->uniqueWorkers);
|
taosArrayDestroy(pMgmt->uniqueWorkers);
|
||||||
tSingleWorkerCleanup(&pMgmt->sharedWorker);
|
tSingleWorkerCleanup(&pMgmt->sharedWorker);
|
||||||
|
dDebug("snode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t smGetSWIdFromMsg(SRpcMsg *pMsg) {
|
static FORCE_INLINE int32_t smGetSWIdFromMsg(SRpcMsg *pMsg) {
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
pHead->streamTaskId = htonl(pHead->streamTaskId);
|
pHead->vgId = htonl(pHead->vgId);
|
||||||
return pHead->streamTaskId % SND_UNIQUE_THREAD_NUM;
|
return pHead->vgId % SND_UNIQUE_THREAD_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) {
|
static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) {
|
||||||
SStreamExecMsgHead *pHead = pMsg->pCont;
|
/*SMsgHead *pHead = pMsg->pCont;*/
|
||||||
pHead->workerType = htonl(pHead->workerType);
|
/*pHead->workerType = htonl(pHead->workerType);*/
|
||||||
return pHead->workerType;
|
/*return pHead->workerType;*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t smProcessMgmtMsg(SSnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Testbase {
|
||||||
|
|
||||||
#define CheckBinaryByte(b, len) \
|
#define CheckBinaryByte(b, len) \
|
||||||
{ \
|
{ \
|
||||||
char* bytes = (char*)calloc(1, len); \
|
char* bytes = (char*)taosMemoryCalloc(1, len); \
|
||||||
for (int32_t i = 0; i < len - 1; ++i) { \
|
for (int32_t i = 0; i < len - 1; ++i) { \
|
||||||
bytes[i] = b; \
|
bytes[i] = b; \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -25,9 +25,9 @@ static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) {
|
||||||
|
|
||||||
void TestClient::SetRpcRsp(SRpcMsg* rsp) {
|
void TestClient::SetRpcRsp(SRpcMsg* rsp) {
|
||||||
if (this->pRsp) {
|
if (this->pRsp) {
|
||||||
free(this->pRsp);
|
taosMemoryFree(this->pRsp);
|
||||||
}
|
}
|
||||||
this->pRsp = (SRpcMsg*)calloc(1, sizeof(SRpcMsg));
|
this->pRsp = (SRpcMsg*)taosMemoryCalloc(1, sizeof(SRpcMsg));
|
||||||
this->pRsp->msgType = rsp->msgType;
|
this->pRsp->msgType = rsp->msgType;
|
||||||
this->pRsp->code = rsp->code;
|
this->pRsp->code = rsp->code;
|
||||||
this->pRsp->pCont = rsp->pCont;
|
this->pRsp->pCont = rsp->pCont;
|
||||||
|
|
|
@ -158,6 +158,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
|
||||||
for (int i = 0; i < 1; ++i) {
|
for (int i = 0; i < 1; ++i) {
|
||||||
SVCreateTbReq req = {0};
|
SVCreateTbReq req = {0};
|
||||||
req.ver = 0;
|
req.ver = 0;
|
||||||
|
req.dbFName = (char*)"1.db1";
|
||||||
req.name = (char*)"stb1";
|
req.name = (char*)"stb1";
|
||||||
req.ttl = 0;
|
req.ttl = 0;
|
||||||
req.keep = 0;
|
req.keep = 0;
|
||||||
|
@ -229,6 +230,7 @@ TEST_F(DndTestVnode, 04_Alter_Stb) {
|
||||||
for (int i = 0; i < 1; ++i) {
|
for (int i = 0; i < 1; ++i) {
|
||||||
SVCreateTbReq req = {0};
|
SVCreateTbReq req = {0};
|
||||||
req.ver = 0;
|
req.ver = 0;
|
||||||
|
req.dbFName = (char*)"1.db1";
|
||||||
req.name = (char*)"stb1";
|
req.name = (char*)"stb1";
|
||||||
req.ttl = 0;
|
req.ttl = 0;
|
||||||
req.keep = 0;
|
req.keep = 0;
|
||||||
|
|
|
@ -33,6 +33,7 @@ typedef struct SVnodesMgmt {
|
||||||
SQWorkerPool fetchPool;
|
SQWorkerPool fetchPool;
|
||||||
SWWorkerPool syncPool;
|
SWWorkerPool syncPool;
|
||||||
SWWorkerPool writePool;
|
SWWorkerPool writePool;
|
||||||
|
SWWorkerPool mergePool;
|
||||||
const char *path;
|
const char *path;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
SMgmtWrapper *pWrapper;
|
SMgmtWrapper *pWrapper;
|
||||||
|
@ -63,6 +64,7 @@ typedef struct {
|
||||||
STaosQueue *pApplyQ;
|
STaosQueue *pApplyQ;
|
||||||
STaosQueue *pQueryQ;
|
STaosQueue *pQueryQ;
|
||||||
STaosQueue *pFetchQ;
|
STaosQueue *pFetchQ;
|
||||||
|
STaosQueue *pMergeQ;
|
||||||
SMgmtWrapper *pWrapper;
|
SMgmtWrapper *pWrapper;
|
||||||
} SVnodeObj;
|
} SVnodeObj;
|
||||||
|
|
||||||
|
@ -110,10 +112,11 @@ int32_t vmProcessWriteMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessSyncMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
|
int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DND_VNODES_INT_H_*/
|
#endif /*_TD_DND_VNODES_INT_H_*/
|
||||||
|
|
|
@ -21,7 +21,7 @@ SVnodeObj **vmGetVnodesFromHash(SVnodesMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
int32_t size = taosHashGetSize(pMgmt->hash);
|
int32_t size = taosHashGetSize(pMgmt->hash);
|
||||||
SVnodeObj **pVnodes = calloc(size, sizeof(SVnodeObj *));
|
SVnodeObj **pVnodes = taosMemoryCalloc(size, sizeof(SVnodeObj *));
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
|
@ -48,7 +48,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
|
||||||
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
int32_t code = TSDB_CODE_NODE_PARSE_FILE_ERROR;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 30000;
|
int32_t maxLen = 30000;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
|
@ -85,7 +85,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
|
||||||
|
|
||||||
int32_t vnodesNum = cJSON_GetArraySize(vnodes);
|
int32_t vnodesNum = cJSON_GetArraySize(vnodes);
|
||||||
if (vnodesNum > 0) {
|
if (vnodesNum > 0) {
|
||||||
pCfgs = calloc(vnodesNum, sizeof(SWrapperCfg));
|
pCfgs = taosMemoryCalloc(vnodesNum, sizeof(SWrapperCfg));
|
||||||
if (pCfgs == NULL) {
|
if (pCfgs == NULL) {
|
||||||
dError("failed to read %s since out of memory", file);
|
dError("failed to read %s since out of memory", file);
|
||||||
goto PRASE_VNODE_OVER;
|
goto PRASE_VNODE_OVER;
|
||||||
|
@ -140,7 +140,7 @@ int32_t vmGetVnodesFromFile(SVnodesMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *n
|
||||||
dInfo("succcessed to read file %s", file);
|
dInfo("succcessed to read file %s", file);
|
||||||
|
|
||||||
PRASE_VNODE_OVER:
|
PRASE_VNODE_OVER:
|
||||||
if (content != NULL) free(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 65536;
|
int32_t maxLen = 65536;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n");
|
len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n");
|
||||||
|
@ -190,7 +190,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
|
||||||
taosWriteFile(pFile, content, len);
|
taosWriteFile(pFile, content, len);
|
||||||
taosFsyncFile(pFile);
|
taosFsyncFile(pFile);
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
free(content);
|
taosMemoryFree(content);
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
|
@ -199,7 +199,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnodes != NULL) {
|
if (pVnodes != NULL) {
|
||||||
free(pVnodes);
|
taosMemoryFree(pVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("successed to write %s", realfile);
|
dDebug("successed to write %s", realfile);
|
||||||
|
|
|
@ -46,7 +46,7 @@ void vmReleaseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
SVnodeObj *pVnode = calloc(1, sizeof(SVnodeObj));
|
SVnodeObj *pVnode = taosMemoryCalloc(1, sizeof(SVnodeObj));
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -107,9 +107,9 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
vnodeDestroy(pVnode->path);
|
vnodeDestroy(pVnode->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pVnode->path);
|
taosMemoryFree(pVnode->path);
|
||||||
free(pVnode->db);
|
taosMemoryFree(pVnode->db);
|
||||||
free(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vmOpenVnodeFunc(void *param) {
|
static void *vmOpenVnodeFunc(void *param) {
|
||||||
|
@ -183,11 +183,11 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) {
|
||||||
#endif
|
#endif
|
||||||
int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
|
int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
|
||||||
|
|
||||||
SVnodeThread *threads = calloc(threadNum, sizeof(SVnodeThread));
|
SVnodeThread *threads = taosMemoryCalloc(threadNum, sizeof(SVnodeThread));
|
||||||
for (int32_t t = 0; t < threadNum; ++t) {
|
for (int32_t t = 0; t < threadNum; ++t) {
|
||||||
threads[t].threadIndex = t;
|
threads[t].threadIndex = t;
|
||||||
threads[t].pMgmt = pMgmt;
|
threads[t].pMgmt = pMgmt;
|
||||||
threads[t].pCfgs = calloc(vnodesPerThread, sizeof(SWrapperCfg));
|
threads[t].pCfgs = taosMemoryCalloc(vnodesPerThread, sizeof(SWrapperCfg));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t v = 0; v < numOfVnodes; ++v) {
|
for (int32_t v = 0; v < numOfVnodes; ++v) {
|
||||||
|
@ -217,10 +217,10 @@ static int32_t vmOpenVnodes(SVnodesMgmt *pMgmt) {
|
||||||
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
|
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
|
||||||
taosThreadJoin(pThread->thread, NULL);
|
taosThreadJoin(pThread->thread, NULL);
|
||||||
}
|
}
|
||||||
free(pThread->pCfgs);
|
taosMemoryFree(pThread->pCfgs);
|
||||||
}
|
}
|
||||||
free(threads);
|
taosMemoryFree(threads);
|
||||||
free(pCfgs);
|
taosMemoryFree(pCfgs);
|
||||||
|
|
||||||
if (pMgmt->state.openVnodes != pMgmt->state.totalVnodes) {
|
if (pMgmt->state.openVnodes != pMgmt->state.totalVnodes) {
|
||||||
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
|
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
|
||||||
|
@ -242,7 +242,7 @@ static void vmCloseVnodes(SVnodesMgmt *pMgmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVnodes != NULL) {
|
if (pVnodes != NULL) {
|
||||||
free(pVnodes);
|
taosMemoryFree(pVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMgmt->hash != NULL) {
|
if (pMgmt->hash != NULL) {
|
||||||
|
@ -257,22 +257,22 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
|
||||||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
if (pMgmt == NULL) return;
|
if (pMgmt == NULL) return;
|
||||||
|
|
||||||
dInfo("vnodes-mgmt start to cleanup");
|
dInfo("vnode-mgmt start to cleanup");
|
||||||
vmCloseVnodes(pMgmt);
|
vmCloseVnodes(pMgmt);
|
||||||
vmStopWorker(pMgmt);
|
vmStopWorker(pMgmt);
|
||||||
vnodeCleanup();
|
vnodeCleanup();
|
||||||
// walCleanUp();
|
// walCleanUp();
|
||||||
free(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
dInfo("vnodes-mgmt is cleaned up");
|
dInfo("vnode-mgmt is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
||||||
SDnode *pDnode = pWrapper->pDnode;
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
SVnodesMgmt *pMgmt = calloc(1, sizeof(SVnodesMgmt));
|
SVnodesMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SVnodesMgmt));
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
dInfo("vnodes-mgmt start to init");
|
dInfo("vnode-mgmt start to init");
|
||||||
if (pMgmt == NULL) goto _OVER;
|
if (pMgmt == NULL) goto _OVER;
|
||||||
|
|
||||||
pMgmt->path = pWrapper->path;
|
pMgmt->path = pWrapper->path;
|
||||||
|
@ -312,7 +312,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmOpenVnodes(pMgmt) != 0) {
|
if (vmOpenVnodes(pMgmt) != 0) {
|
||||||
dError("failed to open vnodes since %s", terrstr());
|
dError("failed to open vnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,43 +244,49 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||||
// Requests handled by VNODE
|
// Requests handled by VNODE
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_EXEC, (NodeMsgFp)vmProcessFetchMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, VND_VGID);
|
||||||
|
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||||
|
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
if (pRsp != NULL) {
|
if (pRsp != NULL) {
|
||||||
pRsp->ahandle = pRpc->ahandle;
|
pRsp->ahandle = pRpc->ahandle;
|
||||||
dndSendRsp(pVnode->pWrapper, pRsp);
|
dndSendRsp(pVnode->pWrapper, pRsp);
|
||||||
free(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
} else {
|
} else {
|
||||||
if (code != 0 && terrno != 0) code = terrno;
|
if (code != 0 && terrno != 0) code = terrno;
|
||||||
vmSendRsp(pVnode->pWrapper, pMsg, code);
|
vmSendRsp(pVnode->pWrapper, pMsg, code);
|
||||||
|
@ -191,6 +191,10 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp
|
||||||
dTrace("msg:%p, will be written into vnode-sync queue", pMsg);
|
dTrace("msg:%p, will be written into vnode-sync queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pSyncQ, pMsg);
|
code = taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case MERGE_QUEUE:
|
||||||
|
dTrace("msg:%p, will be written into vnode-merge queue", pMsg);
|
||||||
|
code = taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
break;
|
break;
|
||||||
|
@ -208,6 +212,8 @@ int32_t vmProcessQueryMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNode
|
||||||
|
|
||||||
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); }
|
int32_t vmProcessFetchMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); }
|
||||||
|
|
||||||
|
int32_t vmProcessMergeMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return vmPutNodeMsgToQueue(pMgmt, pMsg, MERGE_QUEUE); }
|
||||||
|
|
||||||
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
int32_t vmProcessMgmtMsg(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
||||||
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
||||||
|
@ -239,6 +245,10 @@ static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueT
|
||||||
dTrace("msg:%p, will be put into vnode-apply queue", pMsg);
|
dTrace("msg:%p, will be put into vnode-apply queue", pMsg);
|
||||||
code = taosWriteQitem(pVnode->pApplyQ, pMsg);
|
code = taosWriteQitem(pVnode->pApplyQ, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case MERGE_QUEUE:
|
||||||
|
dTrace("msg:%p, will be put into vnode-merge queue", pMsg);
|
||||||
|
code = taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
break;
|
break;
|
||||||
|
@ -260,6 +270,10 @@ int32_t vmPutMsgToApplyQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
return vmPutRpcMsgToQueue(pWrapper, pRpc, APPLY_QUEUE);
|
return vmPutRpcMsgToQueue(pWrapper, pRpc, APPLY_QUEUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vmPutMsgToMergeQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||||
|
return vmPutRpcMsgToQueue(pWrapper, pRpc, MERGE_QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
|
int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
|
||||||
int32_t size = -1;
|
int32_t size = -1;
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pWrapper->pMgmt, vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pWrapper->pMgmt, vgId);
|
||||||
|
@ -280,6 +294,9 @@ int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
|
||||||
case APPLY_QUEUE:
|
case APPLY_QUEUE:
|
||||||
size = taosQueueSize(pVnode->pApplyQ);
|
size = taosQueueSize(pVnode->pApplyQ);
|
||||||
break;
|
break;
|
||||||
|
case MERGE_QUEUE:
|
||||||
|
size = taosQueueSize(pVnode->pMergeQ);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -291,12 +308,13 @@ int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
|
||||||
int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessWriteQueue);
|
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessWriteQueue);
|
||||||
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessApplyQueue);
|
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode, (FItems)vmProcessApplyQueue);
|
||||||
|
pVnode->pMergeQ = tWWorkerAllocQueue(&pMgmt->mergePool, pVnode, (FItems)vmProcessMergeMsg);
|
||||||
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)vmProcessSyncQueue);
|
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)vmProcessSyncQueue);
|
||||||
pVnode->pFetchQ = tQWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItem)vmProcessFetchQueue);
|
pVnode->pFetchQ = tQWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItem)vmProcessFetchQueue);
|
||||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||||
|
|
||||||
if (pVnode->pApplyQ == NULL || pVnode->pWriteQ == NULL || pVnode->pSyncQ == NULL || pVnode->pFetchQ == NULL ||
|
if (pVnode->pApplyQ == NULL || pVnode->pWriteQ == NULL || pVnode->pSyncQ == NULL || pVnode->pFetchQ == NULL ||
|
||||||
pVnode->pQueryQ == NULL) {
|
pVnode->pQueryQ == NULL || pVnode->pMergeQ == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -310,12 +328,14 @@ void vmFreeQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
tQWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
tQWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
||||||
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pWriteQ);
|
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pWriteQ);
|
||||||
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pApplyQ);
|
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pApplyQ);
|
||||||
|
tWWorkerFreeQueue(&pMgmt->mergePool, pVnode->pMergeQ);
|
||||||
tWWorkerFreeQueue(&pMgmt->syncPool, pVnode->pSyncQ);
|
tWWorkerFreeQueue(&pMgmt->syncPool, pVnode->pSyncQ);
|
||||||
pVnode->pWriteQ = NULL;
|
pVnode->pWriteQ = NULL;
|
||||||
pVnode->pApplyQ = NULL;
|
pVnode->pApplyQ = NULL;
|
||||||
pVnode->pSyncQ = NULL;
|
pVnode->pSyncQ = NULL;
|
||||||
pVnode->pFetchQ = NULL;
|
pVnode->pFetchQ = NULL;
|
||||||
pVnode->pQueryQ = NULL;
|
pVnode->pQueryQ = NULL;
|
||||||
|
pVnode->pMergeQ = NULL;
|
||||||
dDebug("vgId:%d, vnode queue is freed", pVnode->vgId);
|
dDebug("vgId:%d, vnode queue is freed", pVnode->vgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,6 +346,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
||||||
int32_t maxQueryThreads = minQueryThreads;
|
int32_t maxQueryThreads = minQueryThreads;
|
||||||
int32_t maxWriteThreads = TMAX(tsNumOfCores, 1);
|
int32_t maxWriteThreads = TMAX(tsNumOfCores, 1);
|
||||||
int32_t maxSyncThreads = TMAX(tsNumOfCores / 2, 1);
|
int32_t maxSyncThreads = TMAX(tsNumOfCores / 2, 1);
|
||||||
|
int32_t maxMergeThreads = 1;
|
||||||
|
|
||||||
SQWorkerPool *pQPool = &pMgmt->queryPool;
|
SQWorkerPool *pQPool = &pMgmt->queryPool;
|
||||||
pQPool->name = "vnode-query";
|
pQPool->name = "vnode-query";
|
||||||
|
@ -349,6 +370,11 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
||||||
pWPool->max = maxSyncThreads;
|
pWPool->max = maxSyncThreads;
|
||||||
if (tWWorkerInit(pWPool) != 0) return -1;
|
if (tWWorkerInit(pWPool) != 0) return -1;
|
||||||
|
|
||||||
|
pWPool = &pMgmt->mergePool;
|
||||||
|
pWPool->name = "vnode-merge";
|
||||||
|
pWPool->max = maxMergeThreads;
|
||||||
|
if (tWWorkerInit(pWPool) != 0) return -1;
|
||||||
|
|
||||||
SSingleWorkerCfg cfg = {
|
SSingleWorkerCfg cfg = {
|
||||||
.minNum = 1, .maxNum = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
.minNum = 1, .maxNum = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
||||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
||||||
|
@ -356,7 +382,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("vnode workers is initialized");
|
dDebug("vnode workers are initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,5 +392,6 @@ void vmStopWorker(SVnodesMgmt *pMgmt) {
|
||||||
tQWorkerCleanup(&pMgmt->queryPool);
|
tQWorkerCleanup(&pMgmt->queryPool);
|
||||||
tWWorkerCleanup(&pMgmt->writePool);
|
tWWorkerCleanup(&pMgmt->writePool);
|
||||||
tWWorkerCleanup(&pMgmt->syncPool);
|
tWWorkerCleanup(&pMgmt->syncPool);
|
||||||
dDebug("vnode workers is closed");
|
tWWorkerCleanup(&pMgmt->mergePool);
|
||||||
|
dDebug("vnode workers are closed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ target_include_directories(
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mnode scheduler sdb wal transport cjson sync monitor
|
mnode scheduler sdb wal transport cjson sync monitor stream parser
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
#include "tstream.h"
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
@ -103,6 +104,8 @@ typedef enum {
|
||||||
TRN_TYPE_CREATE_STB = 4001,
|
TRN_TYPE_CREATE_STB = 4001,
|
||||||
TRN_TYPE_ALTER_STB = 4002,
|
TRN_TYPE_ALTER_STB = 4002,
|
||||||
TRN_TYPE_DROP_STB = 4003,
|
TRN_TYPE_DROP_STB = 4003,
|
||||||
|
TRN_TYPE_CREATE_SMA = 4004,
|
||||||
|
TRN_TYPE_DROP_SMA = 4005,
|
||||||
TRN_TYPE_STB_SCOPE_END,
|
TRN_TYPE_STB_SCOPE_END,
|
||||||
} ETrnType;
|
} ETrnType;
|
||||||
|
|
||||||
|
@ -265,6 +268,8 @@ typedef struct {
|
||||||
int8_t update;
|
int8_t update;
|
||||||
int8_t cacheLastRow;
|
int8_t cacheLastRow;
|
||||||
int8_t streamMode;
|
int8_t streamMode;
|
||||||
|
int32_t numOfRetensions;
|
||||||
|
SArray* pRetensions;
|
||||||
} SDbCfg;
|
} SDbCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -305,6 +310,31 @@ typedef struct {
|
||||||
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
||||||
} SVgObj;
|
} SVgObj;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
|
char stb[TSDB_TABLE_FNAME_LEN];
|
||||||
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
int64_t createdTime;
|
||||||
|
int64_t uid;
|
||||||
|
int64_t stbUid;
|
||||||
|
int64_t dbUid;
|
||||||
|
int8_t intervalUnit;
|
||||||
|
int8_t slidingUnit;
|
||||||
|
int8_t timezone;
|
||||||
|
int32_t dstVgId; // for stream
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
int32_t exprLen; // strlen + 1
|
||||||
|
int32_t tagsFilterLen;
|
||||||
|
int32_t sqlLen;
|
||||||
|
int32_t astLen;
|
||||||
|
char* expr;
|
||||||
|
char* tagsFilter;
|
||||||
|
char* sql;
|
||||||
|
char* ast;
|
||||||
|
} SSmaObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -314,12 +344,19 @@ typedef struct {
|
||||||
int64_t dbUid;
|
int64_t dbUid;
|
||||||
int32_t version;
|
int32_t version;
|
||||||
int32_t nextColId;
|
int32_t nextColId;
|
||||||
|
float xFilesFactor;
|
||||||
|
int32_t aggregationMethod;
|
||||||
|
int32_t delay;
|
||||||
|
int32_t ttl;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
|
int32_t numOfSmas;
|
||||||
|
int32_t commentLen;
|
||||||
SSchema* pColumns;
|
SSchema* pColumns;
|
||||||
SSchema* pTags;
|
SSchema* pTags;
|
||||||
|
SSchema* pSmas;
|
||||||
|
char* comment;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
char comment[TSDB_STB_COMMENT_LEN];
|
|
||||||
} SStbObj;
|
} SStbObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -405,7 +442,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerEp(void** buf, SMqConsumerEp* pConsu
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSMqConsumerEp(SMqConsumerEp* pConsumerEp) {
|
static FORCE_INLINE void tDeleteSMqConsumerEp(SMqConsumerEp* pConsumerEp) {
|
||||||
if (pConsumerEp) {
|
if (pConsumerEp) {
|
||||||
tfree(pConsumerEp->qmsg);
|
taosMemoryFreeClear(pConsumerEp->qmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +511,7 @@ typedef struct {
|
||||||
} SMqSubscribeObj;
|
} SMqSubscribeObj;
|
||||||
|
|
||||||
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
|
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
|
||||||
SMqSubscribeObj* pSub = calloc(1, sizeof(SMqSubscribeObj));
|
SMqSubscribeObj* pSub = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
|
||||||
if (pSub == NULL) {
|
if (pSub == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -501,10 +538,10 @@ static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
|
||||||
return pSub;
|
return pSub;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tfree(pSub->consumers);
|
taosMemoryFreeClear(pSub->consumers);
|
||||||
tfree(pSub->lostConsumers);
|
taosMemoryFreeClear(pSub->lostConsumers);
|
||||||
tfree(pSub->unassignedVg);
|
taosMemoryFreeClear(pSub->unassignedVg);
|
||||||
tfree(pSub);
|
taosMemoryFreeClear(pSub);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,6 +721,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
char db[TSDB_DB_FNAME_LEN];
|
||||||
|
char outputSTbName[TSDB_TABLE_FNAME_LEN];
|
||||||
int64_t createTime;
|
int64_t createTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
|
@ -692,17 +730,20 @@ typedef struct {
|
||||||
int32_t vgNum;
|
int32_t vgNum;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
int8_t sourceType;
|
||||||
|
int8_t sinkType;
|
||||||
// int32_t sqlLen;
|
// int32_t sqlLen;
|
||||||
|
int32_t sinkVgId; // 0 for automatic
|
||||||
char* sql;
|
char* sql;
|
||||||
char* logicalPlan;
|
char* logicalPlan;
|
||||||
char* physicalPlan;
|
char* physicalPlan;
|
||||||
SArray* tasks; // SArray<SArray<SStreamTask>>
|
SArray* tasks; // SArray<SArray<SStreamTask>>
|
||||||
|
SArray* ColAlias; // SArray<char*>
|
||||||
} SStreamObj;
|
} SStreamObj;
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj);
|
int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj);
|
||||||
int32_t tDecodeSStreamObj(SCoder* pDecoder, SStreamObj* pObj);
|
int32_t tDecodeSStreamObj(SCoder* pDecoder, SStreamObj* pObj);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -122,9 +122,9 @@ typedef struct SMnode {
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
} SMnode;
|
} SMnode;
|
||||||
|
|
||||||
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
||||||
uint64_t mndGenerateUid(char *name, int32_t len);
|
int64_t mndGenerateUid(char *name, int32_t len);
|
||||||
void mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
void mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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_MND_SMA_H_
|
||||||
|
#define _TD_MND_SMA_H_
|
||||||
|
|
||||||
|
#include "mndInt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t mndInitSma(SMnode *pMnode);
|
||||||
|
void mndCleanupSma(SMnode *pMnode);
|
||||||
|
SSmaObj *mndAcquireSma(SMnode *pMnode, char *smaName);
|
||||||
|
void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_MND_SMA_H_*/
|
|
@ -31,6 +31,8 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||||
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
|
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,7 +158,7 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) {
|
||||||
ACCT_DECODE_OVER:
|
ACCT_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr());
|
mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw) {
|
||||||
BNODE_DECODE_OVER:
|
BNODE_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("bnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
mError("bnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
createReq.dnodeId = pDnode->id;
|
createReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -206,7 +206,7 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
dropReq.dnodeId = pDnode->id;
|
dropReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -233,7 +233,7 @@ static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
|
||||||
dropReq.dnodeId = pDnode->id;
|
dropReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -356,7 +356,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
|
||||||
CLUSTER_DECODE_OVER:
|
CLUSTER_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr());
|
mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
|
||||||
void mndCleanupConsumer(SMnode *pMnode) {}
|
void mndCleanupConsumer(SMnode *pMnode) {}
|
||||||
|
|
||||||
SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup) {
|
SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup) {
|
||||||
SMqConsumerObj *pConsumer = calloc(1, sizeof(SMqConsumerObj));
|
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
|
||||||
if (pConsumer == NULL) {
|
if (pConsumer == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -79,7 +79,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size);
|
||||||
if (pRaw == NULL) goto CM_ENCODE_OVER;
|
if (pRaw == NULL) goto CM_ENCODE_OVER;
|
||||||
|
|
||||||
buf = malloc(tlen);
|
buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) goto CM_ENCODE_OVER;
|
if (buf == NULL) goto CM_ENCODE_OVER;
|
||||||
|
|
||||||
void *abuf = buf;
|
void *abuf = buf;
|
||||||
|
@ -94,7 +94,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
CM_ENCODE_OVER:
|
CM_ENCODE_OVER:
|
||||||
tfree(buf);
|
taosMemoryFreeClear(buf);
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
@ -126,7 +126,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
SDB_GET_INT32(pRaw, dataPos, &len, CM_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &len, CM_DECODE_OVER);
|
||||||
buf = malloc(len);
|
buf = taosMemoryMalloc(len);
|
||||||
if (buf == NULL) goto CM_DECODE_OVER;
|
if (buf == NULL) goto CM_DECODE_OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, buf, len, CM_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, buf, len, CM_DECODE_OVER);
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE, CM_DECODE_OVER);
|
SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE, CM_DECODE_OVER);
|
||||||
|
@ -138,10 +138,10 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
CM_DECODE_OVER:
|
CM_DECODE_OVER:
|
||||||
tfree(buf);
|
taosMemoryFreeClear(buf);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,15 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.quorum, DB_ENCODE_OVER)
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.quorum, DB_ENCODE_OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, DB_ENCODE_OVER)
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, DB_ENCODE_OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, DB_ENCODE_OVER)
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, DB_ENCODE_OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, DB_ENCODE_OVER)
|
||||||
|
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||||
|
SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i);
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pRetension->freq, DB_ENCODE_OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pRetension->keep, DB_ENCODE_OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pRetension->freqUnit, DB_ENCODE_OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, DB_ENCODE_OVER)
|
||||||
|
}
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_ENCODE_OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_ENCODE_OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, DB_ENCODE_OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, DB_ENCODE_OVER)
|
||||||
|
|
||||||
|
@ -161,6 +170,22 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.quorum, DB_DECODE_OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.quorum, DB_DECODE_OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, DB_DECODE_OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, DB_DECODE_OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, DB_DECODE_OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, DB_DECODE_OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, DB_DECODE_OVER)
|
||||||
|
if (pDb->cfg.numOfRetensions > 0) {
|
||||||
|
pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention));
|
||||||
|
if (pDb->cfg.pRetensions == NULL) goto DB_DECODE_OVER;
|
||||||
|
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||||
|
SRetention retension = {0};
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &retension.freq, DB_DECODE_OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &retension.keep, DB_DECODE_OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, DB_DECODE_OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, DB_DECODE_OVER)
|
||||||
|
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) {
|
||||||
|
goto DB_DECODE_OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_DECODE_OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, TSDB_DB_RESERVE_SIZE, DB_DECODE_OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -168,7 +193,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
DB_DECODE_OVER:
|
DB_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr());
|
mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +208,7 @@ static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb) {
|
||||||
|
|
||||||
static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) {
|
static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) {
|
||||||
mTrace("db:%s, perform delete action, row:%p", pDb->name, pDb);
|
mTrace("db:%s, perform delete action, row:%p", pDb->name, pDb);
|
||||||
|
taosArrayDestroy(pDb->cfg.pRetensions);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +370,7 @@ static int32_t mndSetCreateDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
action.msgType = TDMT_DND_CREATE_VNODE;
|
action.msgType = TDMT_DND_CREATE_VNODE;
|
||||||
action.acceptableCode = TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,7 +401,7 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
action.msgType = TDMT_DND_DROP_VNODE;
|
action.msgType = TDMT_DND_DROP_VNODE;
|
||||||
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,6 +443,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
||||||
.streamMode = pCreate->streamMode,
|
.streamMode = pCreate->streamMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
||||||
|
dbObj.cfg.pRetensions = pCreate->pRetensions;
|
||||||
|
pCreate = NULL;
|
||||||
|
|
||||||
mndSetDefaultDbCfg(&dbObj.cfg);
|
mndSetDefaultDbCfg(&dbObj.cfg);
|
||||||
|
|
||||||
if (mndCheckDbName(dbObj.name, pUser) != 0) {
|
if (mndCheckDbName(dbObj.name, pUser) != 0) {
|
||||||
|
@ -453,7 +483,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
CREATE_DB_OVER:
|
CREATE_DB_OVER:
|
||||||
free(pVgroups);
|
taosMemoryFree(pVgroups);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -505,6 +535,7 @@ CREATE_DB_OVER:
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
tFreeSCreateDbReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +622,7 @@ static int32_t mndBuildUpdateVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_DND_ALTER_VNODE;
|
action.msgType = TDMT_DND_ALTER_VNODE;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -771,7 +802,7 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
action.msgType = TDMT_DND_DROP_VNODE;
|
action.msgType = TDMT_DND_DROP_VNODE;
|
||||||
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -814,7 +845,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
|
||||||
if (useRpcMalloc) {
|
if (useRpcMalloc) {
|
||||||
pRsp = rpcMallocCont(rspLen);
|
pRsp = rpcMallocCont(rspLen);
|
||||||
} else {
|
} else {
|
||||||
pRsp = malloc(rspLen);
|
pRsp = taosMemoryMalloc(rspLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
|
@ -1125,7 +1156,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSUseDbBatchRsp(NULL, 0, &batchUseRsp);
|
int32_t rspLen = tSerializeSUseDbBatchRsp(NULL, 0, &batchUseRsp);
|
||||||
void *pRsp = malloc(rspLen);
|
void *pRsp = taosMemoryMalloc(rspLen);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tFreeSUseDbBatchRsp(&batchUseRsp);
|
tFreeSUseDbBatchRsp(&batchUseRsp);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "mndDef.h"
|
#include "mndDef.h"
|
||||||
|
|
||||||
int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
||||||
|
int32_t sz = 0;
|
||||||
|
int32_t outputNameSz = 0;
|
||||||
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->name) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->db) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->db) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->createTime) < 0) return -1;
|
||||||
|
@ -29,19 +31,27 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
||||||
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1;
|
||||||
// TODO encode tasks
|
// TODO encode tasks
|
||||||
if (pObj->tasks) {
|
if (pObj->tasks) {
|
||||||
int32_t sz = taosArrayGetSize(pObj->tasks);
|
sz = taosArrayGetSize(pObj->tasks);
|
||||||
tEncodeI32(pEncoder, sz);
|
}
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
if (tEncodeI32(pEncoder, sz) < 0) return -1;
|
||||||
SArray *pArray = taosArrayGet(pObj->tasks, i);
|
|
||||||
int32_t innerSz = taosArrayGetSize(pArray);
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
tEncodeI32(pEncoder, innerSz);
|
SArray *pArray = taosArrayGet(pObj->tasks, i);
|
||||||
for (int32_t j = 0; j < innerSz; j++) {
|
int32_t innerSz = taosArrayGetSize(pArray);
|
||||||
SStreamTask *pTask = taosArrayGet(pArray, j);
|
if (tEncodeI32(pEncoder, innerSz) < 0) return -1;
|
||||||
tEncodeSStreamTask(pEncoder, pTask);
|
for (int32_t j = 0; j < innerSz; j++) {
|
||||||
}
|
SStreamTask *pTask = taosArrayGet(pArray, j);
|
||||||
|
if (tEncodeSStreamTask(pEncoder, pTask) < 0) return -1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
tEncodeI32(pEncoder, 0);
|
|
||||||
|
if (pObj->ColAlias != NULL) {
|
||||||
|
outputNameSz = taosArrayGetSize(pObj->ColAlias);
|
||||||
|
}
|
||||||
|
if (tEncodeI32(pEncoder, outputNameSz) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < outputNameSz; i++) {
|
||||||
|
char *name = taosArrayGetP(pObj->ColAlias, i);
|
||||||
|
if (tEncodeCStr(pEncoder, name) < 0) return -1;
|
||||||
}
|
}
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +68,7 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1;
|
||||||
|
pObj->tasks = NULL;
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
if (tDecodeI32(pDecoder, &sz) < 0) return -1;
|
if (tDecodeI32(pDecoder, &sz) < 0) return -1;
|
||||||
if (sz != 0) {
|
if (sz != 0) {
|
||||||
|
@ -73,8 +84,19 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
||||||
}
|
}
|
||||||
taosArrayPush(pObj->tasks, pArray);
|
taosArrayPush(pObj->tasks, pArray);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
pObj->tasks = NULL;
|
int32_t outputNameSz;
|
||||||
|
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
|
||||||
|
if (outputNameSz != 0) {
|
||||||
|
pObj->ColAlias = taosArrayInit(outputNameSz, sizeof(void *));
|
||||||
|
if (pObj->ColAlias == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < outputNameSz; i++) {
|
||||||
|
char *name;
|
||||||
|
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
|
||||||
|
taosArrayPush(pObj->ColAlias, &name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
|
||||||
DNODE_DECODE_OVER:
|
DNODE_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("dnode:%d, failed to decode from raw:%p since %s", pDnode->id, pRaw, terrstr());
|
mError("dnode:%d, failed to decode from raw:%p since %s", pDnode->id, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, FUNC_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pFunc->commentSize, FUNC_DECODE_OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, FUNC_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pFunc->codeSize, FUNC_DECODE_OVER)
|
||||||
|
|
||||||
pFunc->pComment = calloc(1, pFunc->commentSize);
|
pFunc->pComment = taosMemoryCalloc(1, pFunc->commentSize);
|
||||||
pFunc->pCode = calloc(1, pFunc->codeSize);
|
pFunc->pCode = taosMemoryCalloc(1, pFunc->codeSize);
|
||||||
if (pFunc->pComment == NULL || pFunc->pCode == NULL) {
|
if (pFunc->pComment == NULL || pFunc->pCode == NULL) {
|
||||||
goto FUNC_DECODE_OVER;
|
goto FUNC_DECODE_OVER;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
|
||||||
FUNC_DECODE_OVER:
|
FUNC_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr());
|
mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +157,8 @@ static int32_t mndFuncActionInsert(SSdb *pSdb, SFuncObj *pFunc) {
|
||||||
|
|
||||||
static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
|
static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
|
||||||
mTrace("func:%s, perform delete action, row:%p", pFunc->name, pFunc);
|
mTrace("func:%s, perform delete action, row:%p", pFunc->name, pFunc);
|
||||||
tfree(pFunc->pCode);
|
taosMemoryFreeClear(pFunc->pCode);
|
||||||
tfree(pFunc->pComment);
|
taosMemoryFreeClear(pFunc->pComment);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +196,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
|
||||||
func.signature = pCreate->signature;
|
func.signature = pCreate->signature;
|
||||||
func.commentSize = pCreate->commentSize;
|
func.commentSize = pCreate->commentSize;
|
||||||
func.codeSize = pCreate->codeSize;
|
func.codeSize = pCreate->codeSize;
|
||||||
func.pComment = malloc(func.commentSize);
|
func.pComment = taosMemoryMalloc(func.commentSize);
|
||||||
func.pCode = malloc(func.codeSize);
|
func.pCode = taosMemoryMalloc(func.codeSize);
|
||||||
if (func.pCode == NULL || func.pCode == NULL) {
|
if (func.pCode == NULL || func.pCode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto CREATE_FUNC_OVER;
|
goto CREATE_FUNC_OVER;
|
||||||
|
@ -228,8 +228,8 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
CREATE_FUNC_OVER:
|
CREATE_FUNC_OVER:
|
||||||
free(func.pCode);
|
taosMemoryFree(func.pCode);
|
||||||
free(func.pComment);
|
taosMemoryFree(func.pComment);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ static const SInfosTableMeta infosMeta[] = {{TSDB_INS_TABLE_DNODES, dnodesSchema
|
||||||
|
|
||||||
//connection/application/
|
//connection/application/
|
||||||
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||||
SSchema *schema = calloc(colNum, sizeof(SSchema));
|
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||||
if (NULL == schema) {
|
if (NULL == schema) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -210,7 +210,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
||||||
|
|
||||||
*pRsp = *meta;
|
*pRsp = *meta;
|
||||||
|
|
||||||
pRsp->pSchemas = calloc(meta->numOfColumns, sizeof(SSchema));
|
pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
|
||||||
if (pRsp->pSchemas == NULL) {
|
if (pRsp->pSchemas == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
pRsp->pSchemas = NULL;
|
pRsp->pSchemas = NULL;
|
||||||
|
@ -241,7 +241,7 @@ void mndCleanupInfos(SMnode *pMnode) {
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
||||||
|
|
||||||
tfree(meta->pSchemas);
|
taosMemoryFreeClear(meta->pSchemas);
|
||||||
|
|
||||||
pIter = taosHashIterate(pMnode->infosMeta, pIter);
|
pIter = taosHashIterate(pMnode->infosMeta, pIter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) {
|
||||||
MNODE_DECODE_OVER:
|
MNODE_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
|
||||||
|
|
||||||
createReq.dnodeId = pMObj->id;
|
createReq.dnodeId = pMObj->id;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
|
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
action.epSet = mndGetDnodeEpset(pMObj->pDnode);
|
action.epSet = mndGetDnodeEpset(pMObj->pDnode);
|
||||||
|
@ -323,7 +323,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
sdbRelease(pSdb, pMObj);
|
sdbRelease(pSdb, pMObj);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -338,7 +338,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
|
||||||
|
|
||||||
createReq.dnodeId = pObj->id;
|
createReq.dnodeId = pObj->id;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
|
tSerializeSDCreateMnodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
action.epSet = mndGetDnodeEpset(pDnode);
|
action.epSet = mndGetDnodeEpset(pDnode);
|
||||||
|
@ -347,7 +347,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
|
||||||
action.msgType = TDMT_DND_CREATE_MNODE;
|
action.msgType = TDMT_DND_CREATE_MNODE;
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
|
|
||||||
alterReq.dnodeId = pMObj->id;
|
alterReq.dnodeId = pMObj->id;
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq);
|
tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq);
|
||||||
|
|
||||||
action.epSet = mndGetDnodeEpset(pMObj->pDnode);
|
action.epSet = mndGetDnodeEpset(pMObj->pDnode);
|
||||||
|
@ -493,7 +493,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
sdbRelease(pSdb, pMObj);
|
sdbRelease(pSdb, pMObj);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -510,7 +510,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
SDDropMnodeReq dropReq = {0};
|
SDDropMnodeReq dropReq = {0};
|
||||||
dropReq.dnodeId = pObj->id;
|
dropReq.dnodeId = pObj->id;
|
||||||
int32_t contLen = tSerializeSMCreateDropMnodeReq(NULL, 0, &dropReq);
|
int32_t contLen = tSerializeSMCreateDropMnodeReq(NULL, 0, &dropReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
tSerializeSMCreateDropMnodeReq(pReq, contLen, &dropReq);
|
tSerializeSMCreateDropMnodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
action.epSet = mndGetDnodeEpset(pDnode);
|
action.epSet = mndGetDnodeEpset(pDnode);
|
||||||
|
@ -519,7 +519,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
action.msgType = TDMT_DND_DROP_MNODE;
|
action.msgType = TDMT_DND_DROP_MNODE;
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) {
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_OFFSET, MND_OFFSET_VER_NUMBER, size);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_OFFSET, MND_OFFSET_VER_NUMBER, size);
|
||||||
if (pRaw == NULL) goto OFFSET_ENCODE_OVER;
|
if (pRaw == NULL) goto OFFSET_ENCODE_OVER;
|
||||||
|
|
||||||
buf = malloc(tlen);
|
buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) goto OFFSET_ENCODE_OVER;
|
if (buf == NULL) goto OFFSET_ENCODE_OVER;
|
||||||
|
|
||||||
void *abuf = buf;
|
void *abuf = buf;
|
||||||
|
@ -74,7 +74,7 @@ SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
OFFSET_ENCODE_OVER:
|
OFFSET_ENCODE_OVER:
|
||||||
tfree(buf);
|
taosMemoryFreeClear(buf);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
mError("offset:%s, failed to encode to raw:%p since %s", pOffset->key, pRaw, terrstr());
|
mError("offset:%s, failed to encode to raw:%p since %s", pOffset->key, pRaw, terrstr());
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
@ -107,7 +107,7 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
int32_t tlen;
|
int32_t tlen;
|
||||||
SDB_GET_INT32(pRaw, dataPos, &tlen, OFFSET_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &tlen, OFFSET_DECODE_OVER);
|
||||||
buf = malloc(tlen + 1);
|
buf = taosMemoryMalloc(tlen + 1);
|
||||||
if (buf == NULL) goto OFFSET_DECODE_OVER;
|
if (buf == NULL) goto OFFSET_DECODE_OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_DECODE_OVER);
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_DECODE_OVER);
|
SDB_GET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_DECODE_OVER);
|
||||||
|
@ -119,10 +119,10 @@ SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
OFFSET_DECODE_OVER:
|
OFFSET_DECODE_OVER:
|
||||||
tfree(buf);
|
taosMemoryFreeClear(buf);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
mError("offset:%s, failed to decode from raw:%p since %s", pOffset->key, pRaw, terrstr());
|
mError("offset:%s, failed to decode from raw:%p since %s", pOffset->key, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndFreeConn(SConnObj *pConn) {
|
static void mndFreeConn(SConnObj *pConn) {
|
||||||
tfree(pConn->pQueries);
|
taosMemoryFreeClear(pConn->pQueries);
|
||||||
mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn);
|
mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
|
||||||
|
|
||||||
if (numOfQueries > 0) {
|
if (numOfQueries > 0) {
|
||||||
if (pConn->pQueries == NULL) {
|
if (pConn->pQueries == NULL) {
|
||||||
pConn->pQueries = calloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE);
|
pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries);
|
pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries);
|
||||||
|
@ -276,7 +276,7 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
|
||||||
|
|
||||||
static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
||||||
#if 0
|
#if 0
|
||||||
SClientHbRsp* pRsp = malloc(sizeof(SClientHbRsp));
|
SClientHbRsp* pRsp = taosMemoryMalloc(sizeof(SClientHbRsp));
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -292,7 +292,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
||||||
SHashObj* pObj = pReq->info;
|
SHashObj* pObj = pReq->info;
|
||||||
SKv* pKv = taosHashGet(pObj, "mq-tmp", strlen("mq-tmp") + 1);
|
SKv* pKv = taosHashGet(pObj, "mq-tmp", strlen("mq-tmp") + 1);
|
||||||
if (pKv == NULL) {
|
if (pKv == NULL) {
|
||||||
free(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SMqHbMsg mqHb;
|
SMqHbMsg mqHb;
|
||||||
|
@ -325,7 +325,7 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
|
||||||
taosArrayPush(batchRsp.batchRsps, &innerBatchRsp);
|
taosArrayPush(batchRsp.batchRsps, &innerBatchRsp);
|
||||||
}
|
}
|
||||||
int32_t tlen = taosEncodeSMqHbBatchRsp(NULL, &batchRsp);
|
int32_t tlen = taosEncodeSMqHbBatchRsp(NULL, &batchRsp);
|
||||||
void* buf = malloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
//TODO
|
//TODO
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -402,7 +402,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
||||||
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
|
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
|
||||||
if (pRsp != NULL) {
|
if (pRsp != NULL) {
|
||||||
taosArrayPush(batchRsp.rsps, pRsp);
|
taosArrayPush(batchRsp.rsps, pRsp);
|
||||||
free(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
|
||||||
int32_t kvNum = (rsp->info) ? taosArrayGetSize(rsp->info) : 0;
|
int32_t kvNum = (rsp->info) ? taosArrayGetSize(rsp->info) : 0;
|
||||||
for (int32_t n = 0; n < kvNum; ++n) {
|
for (int32_t n = 0; n < kvNum; ++n) {
|
||||||
SKv *kv = taosArrayGet(rsp->info, n);
|
SKv *kv = taosArrayGet(rsp->info, n);
|
||||||
tfree(kv->value);
|
taosMemoryFreeClear(kv->value);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(rsp->info);
|
taosArrayDestroy(rsp->info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) {
|
||||||
QNODE_DECODE_OVER:
|
QNODE_DECODE_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("qnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
mError("qnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr());
|
||||||
tfree(pRow);
|
taosMemoryFreeClear(pRow);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
createReq.dnodeId = pDnode->id;
|
createReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -208,7 +208,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
dropReq.dnodeId = pDnode->id;
|
dropReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -235,7 +235,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
|
||||||
dropReq.dnodeId = pDnode->id;
|
dropReq.dnodeId = pDnode->id;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
void *pReq = malloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -358,7 +358,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
|
||||||
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
free(pReq);
|
taosMemoryFree(pReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ static int32_t mndProcessQnodeListReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp);
|
int32_t rspLen = tSerializeSQnodeListRsp(NULL, 0, &qlistRsp);
|
||||||
void *pRsp = malloc(rspLen);
|
void *pRsp = taosMemoryMalloc(rspLen);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto QNODE_LIST_OVER;
|
goto QNODE_LIST_OVER;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue