other:merge main.
This commit is contained in:
commit
5c115c0900
|
@ -2009,10 +2009,8 @@ typedef struct {
|
||||||
int8_t withMeta;
|
int8_t withMeta;
|
||||||
char* sql;
|
char* sql;
|
||||||
char subDbName[TSDB_DB_FNAME_LEN];
|
char subDbName[TSDB_DB_FNAME_LEN];
|
||||||
union {
|
|
||||||
char* ast;
|
char* ast;
|
||||||
char subStbName[TSDB_TABLE_FNAME_LEN];
|
char subStbName[TSDB_TABLE_FNAME_LEN];
|
||||||
};
|
|
||||||
} SCMCreateTopicReq;
|
} SCMCreateTopicReq;
|
||||||
|
|
||||||
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
|
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
|
||||||
|
@ -2809,37 +2807,49 @@ typedef struct {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
} SMqRebVgReq;
|
} SMqRebVgReq;
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pReq) {
|
static FORCE_INLINE int tEncodeSMqRebVgReq(SEncoder *pCoder, const SMqRebVgReq* pReq) {
|
||||||
int32_t tlen = 0;
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->leftForVer);
|
if (tEncodeI64(pCoder, pReq->leftForVer) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->vgId);
|
if (tEncodeI32(pCoder, pReq->vgId) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->oldConsumerId);
|
if (tEncodeI64(pCoder, pReq->oldConsumerId) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->newConsumerId);
|
if (tEncodeI64(pCoder, pReq->newConsumerId) < 0) return -1;
|
||||||
tlen += taosEncodeString(buf, pReq->subKey);
|
if (tEncodeCStr(pCoder, pReq->subKey) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->subType);
|
if (tEncodeI8(pCoder, pReq->subType) < 0) return -1;
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->withMeta);
|
if (tEncodeI8(pCoder, pReq->withMeta) < 0) return -1;
|
||||||
|
|
||||||
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
if (tEncodeCStr(pCoder, pReq->qmsg) < 0) return -1;
|
||||||
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->suid);
|
if (tEncodeI64(pCoder, pReq->suid) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pCoder, pReq->qmsg) < 0) return -1;
|
||||||
}
|
}
|
||||||
return tlen;
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq) {
|
static FORCE_INLINE int tDecodeSMqRebVgReq(SDecoder *pCoder, SMqRebVgReq* pReq) {
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->leftForVer);
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->vgId);
|
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->oldConsumerId);
|
if (tDecodeI64(pCoder, &pReq->leftForVer) < 0) return -1;
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->newConsumerId);
|
|
||||||
buf = taosDecodeStringTo(buf, pReq->subKey);
|
if (tDecodeI32(pCoder, &pReq->vgId) < 0) return -1;
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->subType);
|
if (tDecodeI64(pCoder, &pReq->oldConsumerId) < 0) return -1;
|
||||||
buf = taosDecodeFixedI8(buf, &pReq->withMeta);
|
if (tDecodeI64(pCoder, &pReq->newConsumerId) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(pCoder, pReq->subKey) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pReq->subType) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pReq->withMeta) < 0) return -1;
|
||||||
|
|
||||||
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
if (tDecodeCStr(pCoder, &pReq->qmsg) < 0) return -1;
|
||||||
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->suid);
|
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
||||||
|
if (!tDecodeIsEnd(pCoder)){
|
||||||
|
if (tDecodeCStr(pCoder, &pReq->qmsg) < 0) return -1;
|
||||||
}
|
}
|
||||||
return (void*)buf;
|
}
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -354,6 +354,7 @@
|
||||||
#define TK_WAL 336
|
#define TK_WAL 336
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
#define TK_NK_ILLEGAL 602
|
#define TK_NK_ILLEGAL 602
|
||||||
|
|
|
@ -82,6 +82,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v
|
||||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols,
|
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols,
|
||||||
uint64_t id);
|
uint64_t id);
|
||||||
|
|
||||||
|
int32_t qGetTableList(int64_t suid, void* pVnode, void* node, SArray **tableList, void* pTaskInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the task Id, usually used by message queue process
|
* set the task Id, usually used by message queue process
|
||||||
* @param tinfo
|
* @param tinfo
|
||||||
|
|
|
@ -364,6 +364,7 @@ typedef struct SCreateTopicStmt {
|
||||||
bool ignoreExists;
|
bool ignoreExists;
|
||||||
bool withMeta;
|
bool withMeta;
|
||||||
SNode* pQuery;
|
SNode* pQuery;
|
||||||
|
SNode* pWhere;
|
||||||
} SCreateTopicStmt;
|
} SCreateTopicStmt;
|
||||||
|
|
||||||
typedef struct SDropTopicStmt {
|
typedef struct SDropTopicStmt {
|
||||||
|
|
|
@ -51,6 +51,12 @@ typedef enum {
|
||||||
TARGET_TYPE_OTHER,
|
TARGET_TYPE_OTHER,
|
||||||
} ETargetType;
|
} ETargetType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TCOL_TYPE_COLUMN = 1,
|
||||||
|
TCOL_TYPE_TAG,
|
||||||
|
TCOL_TYPE_NONE,
|
||||||
|
} ETableColumnType;
|
||||||
|
|
||||||
#define QUERY_POLICY_VNODE 1
|
#define QUERY_POLICY_VNODE 1
|
||||||
#define QUERY_POLICY_HYBRID 2
|
#define QUERY_POLICY_HYBRID 2
|
||||||
#define QUERY_POLICY_QNODE 3
|
#define QUERY_POLICY_QNODE 3
|
||||||
|
@ -253,6 +259,7 @@ void destroyQueryExecRes(SExecResult* pRes);
|
||||||
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
|
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
|
||||||
char* parseTagDatatoJson(void* p);
|
char* parseTagDatatoJson(void* p);
|
||||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||||
|
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
||||||
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
||||||
int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst);
|
int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst);
|
||||||
void freeVgInfo(SDBVgInfo* vgInfo);
|
void freeVgInfo(SDBVgInfo* vgInfo);
|
||||||
|
|
|
@ -346,12 +346,14 @@ typedef struct SStreamMeta {
|
||||||
void* streamBackend;
|
void* streamBackend;
|
||||||
int32_t streamBackendId;
|
int32_t streamBackendId;
|
||||||
int64_t streamBackendRid;
|
int64_t streamBackendRid;
|
||||||
|
SHashObj* pTaskBackendUnique;
|
||||||
} SStreamMeta;
|
} SStreamMeta;
|
||||||
|
|
||||||
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo);
|
||||||
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo);
|
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo);
|
||||||
|
|
||||||
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, int8_t fillHistory, int64_t triggerParam, SArray* pTaskList);
|
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, int8_t fillHistory, int64_t triggerParam,
|
||||||
|
SArray* pTaskList);
|
||||||
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
||||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
||||||
void tFreeStreamTask(SStreamTask* pTask);
|
void tFreeStreamTask(SStreamTask* pTask);
|
||||||
|
|
|
@ -223,6 +223,7 @@ if [ $1 -eq 0 ];then
|
||||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||||
${csudo}rm -f ${lib_link_dir}/librocksdb.* || :
|
${csudo}rm -f ${lib_link_dir}/librocksdb.* || :
|
||||||
|
|
||||||
${csudo}rm -f ${log_link_dir} || :
|
${csudo}rm -f ${log_link_dir} || :
|
||||||
${csudo}rm -f ${data_link_dir} || :
|
${csudo}rm -f ${data_link_dir} || :
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,9 @@ function install_lib() {
|
||||||
${csudo}ln -sf ${install_main_dir}/driver/librocksdb.* ${lib_link_dir}/librocksdb.so.8
|
${csudo}ln -sf ${install_main_dir}/driver/librocksdb.* ${lib_link_dir}/librocksdb.so.8
|
||||||
${csudo}ln -sf ${lib_link_dir}/librocksdb.so.8 ${lib_link_dir}/librocksdb.so
|
${csudo}ln -sf ${lib_link_dir}/librocksdb.so.8 ${lib_link_dir}/librocksdb.so
|
||||||
|
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/librocksdb.* ${lib_link_dir}/librocksdb.so.8
|
||||||
|
${csudo}ln -sf ${lib_link_dir}/librocksdb.so.8 ${lib_link_dir}/librocksdb.so
|
||||||
|
|
||||||
|
|
||||||
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || :
|
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || :
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ fi
|
||||||
if [ "$osType" == "Darwin" ]; then
|
if [ "$osType" == "Darwin" ]; then
|
||||||
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
|
lib_files="${build_dir}/lib/libtaos.${version}.dylib"
|
||||||
wslib_files="${build_dir}/lib/libtaosws.dylib"
|
wslib_files="${build_dir}/lib/libtaosws.dylib"
|
||||||
rocksdb_lib_files="${build_dir}/lib/librocksdb.so.8.1.1"
|
rocksdb_lib_files="${build_dir}/lib/librocksdb.dylib.8.1.1"
|
||||||
else
|
else
|
||||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||||
wslib_files="${build_dir}/lib/libtaosws.so"
|
wslib_files="${build_dir}/lib/libtaosws.so"
|
||||||
|
|
|
@ -207,6 +207,10 @@ function install_lib() {
|
||||||
[ -f ${lib_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib_link_dir}/librocksdb* || :
|
[ -f ${lib_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib_link_dir}/librocksdb* || :
|
||||||
[ -f ${lib64_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib64_link_dir}/librocksdb* || :
|
[ -f ${lib64_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib64_link_dir}/librocksdb* || :
|
||||||
|
|
||||||
|
#rocksdb
|
||||||
|
[ -f ${lib_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib_link_dir}/librocksdb* || :
|
||||||
|
[ -f ${lib64_link_dir}/librocksdb* ] && ${csudo}rm -f ${lib64_link_dir}/librocksdb* || :
|
||||||
|
|
||||||
[ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || :
|
[ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || :
|
||||||
[ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
|
[ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
|
||||||
|
|
||||||
|
|
|
@ -4002,11 +4002,16 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
|
||||||
if (tEncodeI8(&encoder, pReq->withMeta) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->withMeta) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->subDbName) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->subDbName) < 0) return -1;
|
||||||
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
||||||
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
|
||||||
if (tEncodeCStr(&encoder, pReq->subStbName) < 0) return -1;
|
|
||||||
} else {
|
} else {
|
||||||
|
if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
||||||
|
if (tEncodeCStr(&encoder, pReq->subStbName) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (pReq->ast && strlen(pReq->ast) > 0) {
|
||||||
if (tEncodeI32(&encoder, strlen(pReq->ast)) < 0) return -1;
|
if (tEncodeI32(&encoder, strlen(pReq->ast)) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tEncodeI32(&encoder, 0) < 0) return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tEncodeI32(&encoder, strlen(pReq->sql)) < 0) return -1;
|
if (tEncodeI32(&encoder, strlen(pReq->sql)) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||||
|
@ -4032,9 +4037,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
||||||
if (tDecodeI8(&decoder, &pReq->withMeta) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->withMeta) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->subDbName) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->subDbName) < 0) return -1;
|
||||||
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
if (TOPIC_SUB_TYPE__DB == pReq->subType) {
|
||||||
} else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
|
||||||
if (tDecodeCStrTo(&decoder, pReq->subStbName) < 0) return -1;
|
|
||||||
} else {
|
} else {
|
||||||
|
if (TOPIC_SUB_TYPE__TABLE == pReq->subType) {
|
||||||
|
if (tDecodeCStrTo(&decoder, pReq->subStbName) < 0) return -1;
|
||||||
|
}
|
||||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||||
if (astLen > 0) {
|
if (astLen > 0) {
|
||||||
pReq->ast = taosMemoryCalloc(1, astLen + 1);
|
pReq->ast = taosMemoryCalloc(1, astLen + 1);
|
||||||
|
@ -4057,7 +4063,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
|
||||||
|
|
||||||
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
|
void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) {
|
||||||
taosMemoryFreeClear(pReq->sql);
|
taosMemoryFreeClear(pReq->sql);
|
||||||
if (TOPIC_SUB_TYPE__COLUMN == pReq->subType) {
|
if (TOPIC_SUB_TYPE__DB != pReq->subType) {
|
||||||
taosMemoryFreeClear(pReq->ast);
|
taosMemoryFreeClear(pReq->ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,23 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}else if(pTopic->subType == TOPIC_SUB_TYPE__TABLE && pTopic->ast != NULL){
|
||||||
|
SNode *pAst = NULL;
|
||||||
|
if (nodesStringToNode(pTopic->ast, &pAst) != 0) {
|
||||||
|
mError("topic:%s, failed to create since %s", pTopic->name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
|
||||||
|
if (qCreateQueryPlan(&cxt, &pPlan, NULL) != 0) {
|
||||||
|
mError("failed to create topic:%s since %s", pTopic->name, terrstr());
|
||||||
|
nodesDestroyNode(pAst);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
nodesDestroyNode(pAst);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pPlan){
|
||||||
int32_t levelNum = LIST_LENGTH(pPlan->pSubplans);
|
int32_t levelNum = LIST_LENGTH(pPlan->pSubplans);
|
||||||
if (levelNum != 1) {
|
if (levelNum != 1) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
|
@ -554,7 +570,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
||||||
|
|
||||||
mDebug("init subscription %s for topic:%s assign vgId:%d", pSub->key, pTopic->name, pVgEp->vgId);
|
mDebug("init subscription %s for topic:%s assign vgId:%d", pSub->key, pTopic->name, pVgEp->vgId);
|
||||||
|
|
||||||
if (pTopic->subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pSubplan) {
|
||||||
int32_t msgLen;
|
int32_t msgLen;
|
||||||
|
|
||||||
pSubplan->execNode.epSet = pVgEp->epSet;
|
pSubplan->execNode.epSet = pVgEp->epSet;
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName,
|
||||||
|
|
||||||
mInfo("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s",
|
mInfo("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s",
|
||||||
pTopic->name, stbFullName, suid, colId, pTopic->subType, pTopic->sql);
|
pTopic->name, stbFullName, suid, colId, pTopic->subType, pTopic->sql);
|
||||||
if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) {
|
if (pTopic->ast == NULL) {
|
||||||
sdbRelease(pSdb, pTopic);
|
sdbRelease(pSdb, pTopic);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2272,7 +2272,7 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) {
|
if (pTopic->ast == NULL) {
|
||||||
sdbRelease(pSdb, pTopic);
|
sdbRelease(pSdb, pTopic);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,14 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
|
||||||
req.suid = pSub->stbUid;
|
req.suid = pSub->stbUid;
|
||||||
tstrncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
tstrncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
|
|
||||||
int32_t tlen = sizeof(SMsgHead) + tEncodeSMqRebVgReq(NULL, &req);
|
int32_t tlen = 0;
|
||||||
|
int32_t ret = 0;
|
||||||
|
tEncodeSize(tEncodeSMqRebVgReq, &req, tlen, ret);
|
||||||
|
if (ret < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tlen += sizeof(SMsgHead);
|
||||||
void *buf = taosMemoryMalloc(tlen);
|
void *buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -123,8 +130,14 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
|
||||||
pMsgHead->contLen = htonl(tlen);
|
pMsgHead->contLen = htonl(tlen);
|
||||||
pMsgHead->vgId = htonl(pRebVg->pVgEp->vgId);
|
pMsgHead->vgId = htonl(pRebVg->pVgEp->vgId);
|
||||||
|
|
||||||
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
SEncoder encoder = {0};
|
||||||
tEncodeSMqRebVgReq(&abuf, &req);
|
tEncoderInit(&encoder, POINTER_SHIFT(buf, sizeof(SMsgHead)), tlen);
|
||||||
|
if (tEncodeSMqRebVgReq(&encoder, &req) < 0) {
|
||||||
|
taosMemoryFreeClear(buf);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
*pBuf = buf;
|
*pBuf = buf;
|
||||||
*pLen = tlen;
|
*pLen = tlen;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define MND_TOPIC_VER_NUMBER 2
|
#define MND_TOPIC_VER_NUMBER 3
|
||||||
#define MND_TOPIC_RESERVE_SIZE 64
|
#define MND_TOPIC_RESERVE_SIZE 64
|
||||||
|
|
||||||
SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic);
|
SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic);
|
||||||
|
@ -170,7 +170,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER;
|
||||||
|
|
||||||
if (sver != 1 && sver != 2) {
|
if (sver < 1 || sver > MND_TOPIC_VER_NUMBER) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto TOPIC_DECODE_OVER;
|
goto TOPIC_DECODE_OVER;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withMeta, TOPIC_DECODE_OVER);
|
SDB_GET_INT8(pRaw, dataPos, &pTopic->withMeta, TOPIC_DECODE_OVER);
|
||||||
|
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->stbUid, TOPIC_DECODE_OVER);
|
SDB_GET_INT64(pRaw, dataPos, &pTopic->stbUid, TOPIC_DECODE_OVER);
|
||||||
|
if (sver >= 3) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->stbName, TSDB_TABLE_FNAME_LEN, TOPIC_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pTopic->stbName, TSDB_TABLE_FNAME_LEN, TOPIC_DECODE_OVER);
|
||||||
|
}
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||||
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
||||||
if (pTopic->sql == NULL) {
|
if (pTopic->sql == NULL) {
|
||||||
|
@ -422,6 +424,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
mError("failed to create topic:%s since %s", pCreate->name, terrstr());
|
mError("failed to create topic:%s since %s", pCreate->name, terrstr());
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
nodesDestroyNode(pAst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +432,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
if (topicObj.ntbColIds == NULL) {
|
if (topicObj.ntbColIds == NULL) {
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
nodesDestroyNode(pAst);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -444,6 +448,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
nodesDestroyNode(pAst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,6 +470,11 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
strcpy(topicObj.stbName, pCreate->subStbName);
|
strcpy(topicObj.stbName, pCreate->subStbName);
|
||||||
topicObj.stbUid = pStb->uid;
|
topicObj.stbUid = pStb->uid;
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
if(pCreate->ast != NULL){
|
||||||
|
qDebugL("topic:%s ast %s", topicObj.name, pCreate->ast);
|
||||||
|
topicObj.ast = taosStrdup(pCreate->ast);
|
||||||
|
topicObj.astLen = strlen(pCreate->ast) + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*} else if (pCreate->subType == TOPIC_SUB_TYPE__DB) {*/
|
/*} else if (pCreate->subType == TOPIC_SUB_TYPE__DB) {*/
|
||||||
/*topicObj.ast = NULL;*/
|
/*topicObj.ast = NULL;*/
|
||||||
|
@ -914,13 +924,12 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
}else if(pTopic->subType == TOPIC_SUB_TYPE__TABLE){
|
}else if(pTopic->subType == TOPIC_SUB_TYPE__TABLE){
|
||||||
SStbObj *pStb = mndAcquireStb(pMnode, pTopic->stbName);
|
SStbObj *pStb = mndAcquireStb(pMnode, pTopic->stbName);
|
||||||
if (pStb == NULL) {
|
if (pStb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
|
STR_TO_VARSTR(schemaJson, "NULL");
|
||||||
taosMemoryFree(schemaJson);
|
mError("mndRetrieveTopic mndAcquireStb null stbName:%s", pTopic->stbName);
|
||||||
return -1;
|
}else{
|
||||||
}
|
|
||||||
schemaToJson(pStb->pColumns, pStb->numOfColumns, schemaJson);
|
schemaToJson(pStb->pColumns, pStb->numOfColumns, schemaJson);
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
STR_TO_VARSTR(schemaJson, "NULL");
|
STR_TO_VARSTR(schemaJson, "NULL");
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ STqReader *tqReaderOpen(SVnode *pVnode);
|
||||||
void tqReaderClose(STqReader *);
|
void tqReaderClose(STqReader *);
|
||||||
|
|
||||||
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||||
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList);
|
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char* id);
|
||||||
int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
||||||
int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t suid;
|
int64_t suid;
|
||||||
|
char* qmsg; // SubPlanToString
|
||||||
|
SNode* node;
|
||||||
} STqExecTb;
|
} STqExecTb;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -297,6 +297,7 @@ int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter);
|
||||||
// SDelFReader
|
// SDelFReader
|
||||||
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb);
|
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb);
|
||||||
int32_t tsdbDelFReaderClose(SDelFReader **ppReader);
|
int32_t tsdbDelFReaderClose(SDelFReader **ppReader);
|
||||||
|
int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData, int64_t maxVer);
|
||||||
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData);
|
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData);
|
||||||
int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
|
int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
|
||||||
// tsdbRead.c ==============================================================================================
|
// tsdbRead.c ==============================================================================================
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
static int32_t tqInitialize(STQ* pTq);
|
static int32_t tqInitialize(STQ* pTq);
|
||||||
|
|
||||||
static FORCE_INLINE bool tqIsHandleExec(STqHandle* pHandle) { return TMQ_HANDLE_STATUS_EXEC == pHandle->status; }
|
static FORCE_INLINE bool tqIsHandleExec(STqHandle* pHandle) { return TMQ_HANDLE_STATUS_EXEC == pHandle->status; }
|
||||||
static FORCE_INLINE void tqSetHandleExec(STqHandle* pHandle) {pHandle->status = TMQ_HANDLE_STATUS_EXEC;}
|
static FORCE_INLINE void tqSetHandleExec(STqHandle* pHandle) { pHandle->status = TMQ_HANDLE_STATUS_EXEC; }
|
||||||
static FORCE_INLINE void tqSetHandleIdle(STqHandle* pHandle) {pHandle->status = TMQ_HANDLE_STATUS_IDLE;}
|
static FORCE_INLINE void tqSetHandleIdle(STqHandle* pHandle) { pHandle->status = TMQ_HANDLE_STATUS_IDLE; }
|
||||||
|
|
||||||
int32_t tqInit() {
|
int32_t tqInit() {
|
||||||
int8_t old;
|
int8_t old;
|
||||||
|
@ -75,8 +75,10 @@ static void destroyTqHandle(void* data) {
|
||||||
} else if (pData->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pData->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
walCloseReader(pData->pWalReader);
|
walCloseReader(pData->pWalReader);
|
||||||
tqReaderClose(pData->execHandle.pTqReader);
|
tqReaderClose(pData->execHandle.pTqReader);
|
||||||
|
taosMemoryFreeClear(pData->execHandle.execTb.qmsg);
|
||||||
|
nodesDestroyNode(pData->execHandle.execTb.node);
|
||||||
}
|
}
|
||||||
if(pData->msg != NULL) {
|
if (pData->msg != NULL) {
|
||||||
rpcFreeCont(pData->msg->pCont);
|
rpcFreeCont(pData->msg->pCont);
|
||||||
taosMemoryFree(pData->msg);
|
taosMemoryFree(pData->msg);
|
||||||
pData->msg = NULL;
|
pData->msg = NULL;
|
||||||
|
@ -238,14 +240,15 @@ int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
|
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||||
tqDoSendDataRsp(&pHandle->msg->info, &dataRsp, pHandle->epoch, pHandle->consumerId, TMQ_MSG_TYPE__POLL_RSP, sver, ever);
|
tqDoSendDataRsp(&pHandle->msg->info, &dataRsp, pHandle->epoch, pHandle->consumerId, TMQ_MSG_TYPE__POLL_RSP, sver,
|
||||||
|
ever);
|
||||||
|
|
||||||
char buf1[80] = {0};
|
char buf1[80] = {0};
|
||||||
char buf2[80] = {0};
|
char buf2[80] = {0};
|
||||||
tFormatOffset(buf1, tListLen(buf1), &dataRsp.reqOffset);
|
tFormatOffset(buf1, tListLen(buf1), &dataRsp.reqOffset);
|
||||||
tFormatOffset(buf2, tListLen(buf2), &dataRsp.rspOffset);
|
tFormatOffset(buf2, tListLen(buf2), &dataRsp.rspOffset);
|
||||||
tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s",
|
tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s", vgId,
|
||||||
vgId, dataRsp.head.consumerId, dataRsp.head.epoch, dataRsp.blockNum, buf1, buf2);
|
dataRsp.head.consumerId, dataRsp.head.epoch, dataRsp.blockNum, buf1, buf2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,8 +264,8 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq*
|
||||||
tFormatOffset(buf1, 80, &pRsp->reqOffset);
|
tFormatOffset(buf1, 80, &pRsp->reqOffset);
|
||||||
tFormatOffset(buf2, 80, &pRsp->rspOffset);
|
tFormatOffset(buf2, 80, &pRsp->rspOffset);
|
||||||
|
|
||||||
tqDebug("vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
tqDebug("vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64, vgId,
|
||||||
vgId, pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2, pReq->reqId);
|
pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2, pReq->reqId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -334,8 +337,7 @@ int32_t tqProcessSeekReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen)
|
||||||
|
|
||||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, pOffset->subKey, strlen(pOffset->subKey));
|
STqHandle* pHandle = taosHashGet(pTq->pHandle, pOffset->subKey, strlen(pOffset->subKey));
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
tqError("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", vgOffset.consumerId, vgId,
|
tqError("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", vgOffset.consumerId, vgId, pOffset->subKey);
|
||||||
pOffset->subKey);
|
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,7 @@ int32_t tqProcessSeekReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen)
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
//3. check the offset info
|
// 3. check the offset info
|
||||||
STqOffset* pSavedOffset = tqOffsetRead(pTq->pOffsetStore, pOffset->subKey);
|
STqOffset* pSavedOffset = tqOffsetRead(pTq->pOffsetStore, pOffset->subKey);
|
||||||
if (pSavedOffset != NULL) {
|
if (pSavedOffset != NULL) {
|
||||||
if (pSavedOffset->val.type != TMQ_OFFSET__LOG) {
|
if (pSavedOffset->val.type != TMQ_OFFSET__LOG) {
|
||||||
|
@ -379,7 +381,7 @@ int32_t tqProcessSeekReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen)
|
||||||
tqDebug("vgId:%d sub:%s seek to:%" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey, pOffset->val.version,
|
tqDebug("vgId:%d sub:%s seek to:%" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey, pOffset->val.version,
|
||||||
pSavedOffset->val.version);
|
pSavedOffset->val.version);
|
||||||
} else {
|
} else {
|
||||||
tqDebug("vgId:%d sub:%s seek to:%"PRId64" not saved yet", vgId, pOffset->subKey, pOffset->val.version);
|
tqDebug("vgId:%d sub:%s seek to:%" PRId64 " not saved yet", vgId, pOffset->subKey, pOffset->val.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tqOffsetWrite(pTq->pOffsetStore, pOffset) < 0) {
|
if (tqOffsetWrite(pTq->pOffsetStore, pOffset) < 0) {
|
||||||
|
@ -447,7 +449,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
// 2. check re-balance status
|
// 2. check re-balance status
|
||||||
if (pHandle->consumerId != consumerId) {
|
if (pHandle->consumerId != consumerId) {
|
||||||
tqError("ERROR tmq poll: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
tqError("ERROR tmq poll: consumer:0x%" PRIx64
|
||||||
|
" vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||||
consumerId, TD_VID(pTq->pVnode), req.subKey, pHandle->consumerId);
|
consumerId, TD_VID(pTq->pVnode), req.subKey, pHandle->consumerId);
|
||||||
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
|
@ -455,22 +458,26 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exec = tqIsHandleExec(pHandle);
|
bool exec = tqIsHandleExec(pHandle);
|
||||||
if(!exec) {
|
if (!exec) {
|
||||||
tqSetHandleExec(pHandle);
|
tqSetHandleExec(pHandle);
|
||||||
// qSetTaskCode(pHandle->execHandle.task, TDB_CODE_SUCCESS);
|
// qSetTaskCode(pHandle->execHandle.task, TDB_CODE_SUCCESS);
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, set handle exec, pHandle:%p", consumerId, vgId, req.subKey, pHandle);
|
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, set handle exec, pHandle:%p", consumerId, vgId,
|
||||||
|
req.subKey, pHandle);
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, subscription is executing, wait for 10ms and retry, pHandle:%p", consumerId, vgId, req.subKey, pHandle);
|
tqDebug("tmq poll: consumer:0x%" PRIx64
|
||||||
|
"vgId:%d, topic:%s, subscription is executing, wait for 10ms and retry, pHandle:%p",
|
||||||
|
consumerId, vgId, req.subKey, pHandle);
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. update the epoch value
|
// 3. update the epoch value
|
||||||
if (pHandle->epoch < reqEpoch) {
|
if (pHandle->epoch < reqEpoch) {
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " epoch update from %d to %d by poll req", consumerId, pHandle->epoch, reqEpoch);
|
tqDebug("tmq poll: consumer:0x%" PRIx64 " epoch update from %d to %d by poll req", consumerId, pHandle->epoch,
|
||||||
|
reqEpoch);
|
||||||
pHandle->epoch = reqEpoch;
|
pHandle->epoch = reqEpoch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +489,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
code = tqExtractDataForMq(pTq, pHandle, &req, pMsg);
|
code = tqExtractDataForMq(pTq, pHandle, &req, pMsg);
|
||||||
tqSetHandleIdle(pHandle);
|
tqSetHandleIdle(pHandle);
|
||||||
|
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, , set handle idle, pHandle:%p", consumerId, vgId, req.subKey, pHandle);
|
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, , set handle idle, pHandle:%p", consumerId, vgId,
|
||||||
|
req.subKey, pHandle);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +587,8 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
STqHandle* pHandle = taosHashGet(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||||
if (pHandle) {
|
if (pHandle) {
|
||||||
while (tqIsHandleExec(pHandle)) {
|
while (tqIsHandleExec(pHandle)) {
|
||||||
tqDebug("vgId:%d, topic:%s, subscription is executing, wait for 10ms and retry, pHandle:%p", vgId, pHandle->subKey, pHandle);
|
tqDebug("vgId:%d, topic:%s, subscription is executing, wait for 10ms and retry, pHandle:%p", vgId,
|
||||||
|
pHandle->subKey, pHandle);
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +650,16 @@ int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t
|
||||||
int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
SMqRebVgReq req = {0};
|
SMqRebVgReq req = {0};
|
||||||
tDecodeSMqRebVgReq(msg, &req);
|
SDecoder dc = {0};
|
||||||
|
|
||||||
|
tDecoderInit(&dc, msg, msgLen);
|
||||||
|
|
||||||
|
// decode req
|
||||||
|
if (tDecodeSMqRebVgReq(&dc, &req) < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SVnode* pVnode = pTq->pVnode;
|
SVnode* pVnode = pTq->pVnode;
|
||||||
int32_t vgId = TD_VID(pVnode);
|
int32_t vgId = TD_VID(pVnode);
|
||||||
|
@ -664,7 +682,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
STqHandle tqHandle = {0};
|
STqHandle tqHandle = {0};
|
||||||
pHandle = &tqHandle;
|
pHandle = &tqHandle;
|
||||||
|
|
||||||
uint64_t oldConsumerId = pHandle->consumerId;
|
|
||||||
memcpy(pHandle->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(pHandle->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
pHandle->consumerId = req.newConsumerId;
|
pHandle->consumerId = req.newConsumerId;
|
||||||
pHandle->epoch = -1;
|
pHandle->epoch = -1;
|
||||||
|
@ -688,8 +705,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
pHandle->snapshotVer = ver;
|
pHandle->snapshotVer = ver;
|
||||||
|
|
||||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
pHandle->execHandle.execCol.qmsg = req.qmsg;
|
pHandle->execHandle.execCol.qmsg = taosStrdup(req.qmsg);
|
||||||
req.qmsg = NULL;
|
|
||||||
|
|
||||||
pHandle->execHandle.task = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, vgId,
|
pHandle->execHandle.task = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, vgId,
|
||||||
&pHandle->execHandle.numOfCols, req.newConsumerId);
|
&pHandle->execHandle.numOfCols, req.newConsumerId);
|
||||||
|
@ -709,51 +725,63 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
pHandle->pWalReader = walOpenReader(pVnode->pWal, NULL);
|
pHandle->pWalReader = walOpenReader(pVnode->pWal, NULL);
|
||||||
pHandle->execHandle.execTb.suid = req.suid;
|
pHandle->execHandle.execTb.suid = req.suid;
|
||||||
|
pHandle->execHandle.execTb.qmsg = taosStrdup(req.qmsg);
|
||||||
|
|
||||||
SArray* tbUidList = taosArrayInit(0, sizeof(int64_t));
|
if (strcmp(pHandle->execHandle.execTb.qmsg, "") != 0) {
|
||||||
vnodeGetCtbIdList(pVnode, req.suid, tbUidList);
|
if (nodesStringToNode(pHandle->execHandle.execTb.qmsg, &pHandle->execHandle.execTb.node) != 0) {
|
||||||
tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pVnode->config.vgId, req.suid);
|
tqError("nodesStringToNode error in sub stable, since %s, vgId:%d, subkey:%s consumer:0x%" PRIx64, terrstr(),
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
pVnode->config.vgId, req.subKey, pHandle->consumerId);
|
||||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
return -1;
|
||||||
tqDebug("vgId:%d, idx %d, uid:%" PRId64, vgId, i, tbUid);
|
}
|
||||||
}
|
}
|
||||||
pHandle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
|
||||||
tqReaderSetTbUidList(pHandle->execHandle.pTqReader, tbUidList);
|
|
||||||
taosArrayDestroy(tbUidList);
|
|
||||||
|
|
||||||
buildSnapContext(handle.vnode, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta,
|
buildSnapContext(handle.vnode, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta,
|
||||||
(SSnapContext**)(&handle.sContext));
|
(SSnapContext**)(&handle.sContext));
|
||||||
pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId);
|
pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId);
|
||||||
|
|
||||||
|
SArray* tbUidList = NULL;
|
||||||
|
ret = qGetTableList(req.suid, pVnode, pHandle->execHandle.execTb.node, &tbUidList, pHandle->execHandle.task);
|
||||||
|
if (ret != TDB_CODE_SUCCESS) {
|
||||||
|
tqError("qGetTableList error:%d vgId:%d, subkey:%s consumer:0x%" PRIx64, ret, pVnode->config.vgId, req.subKey,
|
||||||
|
pHandle->consumerId);
|
||||||
|
taosArrayDestroy(tbUidList);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
tqDebug("tq try to get ctb for stb subscribe, vgId:%d, subkey:%s consumer:0x%" PRIx64 " suid:%" PRId64,
|
||||||
|
pVnode->config.vgId, req.subKey, pHandle->consumerId, req.suid);
|
||||||
|
pHandle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
||||||
|
tqReaderSetTbUidList(pHandle->execHandle.pTqReader, tbUidList, NULL);
|
||||||
|
taosArrayDestroy(tbUidList);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle));
|
taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle));
|
||||||
tqDebug("try to persist handle %s consumer:0x%" PRIx64 " , old consumer:0x%" PRIx64, req.subKey,
|
tqDebug("try to persist handle %s consumer:0x%" PRIx64, req.subKey, pHandle->consumerId);
|
||||||
pHandle->consumerId, oldConsumerId);
|
|
||||||
ret = tqMetaSaveHandle(pTq, req.subKey, pHandle);
|
ret = tqMetaSaveHandle(pTq, req.subKey, pHandle);
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
taosWLockLatch(&pTq->lock);
|
taosWLockLatch(&pTq->lock);
|
||||||
|
|
||||||
if (pHandle->consumerId == req.newConsumerId) { // do nothing
|
if (pHandle->consumerId == req.newConsumerId) { // do nothing
|
||||||
tqInfo("vgId:%d consumer:0x%" PRIx64 " remains, no switch occurs, should not reach here", req.vgId, req.newConsumerId);
|
tqInfo("vgId:%d consumer:0x%" PRIx64 " remains, no switch occurs, should not reach here", req.vgId,
|
||||||
|
req.newConsumerId);
|
||||||
} else {
|
} else {
|
||||||
tqInfo("vgId:%d switch consumer from Id:0x%" PRIx64 " to Id:0x%" PRIx64, req.vgId, pHandle->consumerId,
|
tqInfo("vgId:%d switch consumer from Id:0x%" PRIx64 " to Id:0x%" PRIx64, req.vgId, pHandle->consumerId,
|
||||||
req.newConsumerId);
|
req.newConsumerId);
|
||||||
atomic_store_64(&pHandle->consumerId, req.newConsumerId);
|
atomic_store_64(&pHandle->consumerId, req.newConsumerId);
|
||||||
}
|
}
|
||||||
// atomic_add_fetch_32(&pHandle->epoch, 1);
|
// atomic_add_fetch_32(&pHandle->epoch, 1);
|
||||||
|
|
||||||
// kill executing task
|
// kill executing task
|
||||||
// if(tqIsHandleExec(pHandle)) {
|
// if(tqIsHandleExec(pHandle)) {
|
||||||
// qTaskInfo_t pTaskInfo = pHandle->execHandle.task;
|
// qTaskInfo_t pTaskInfo = pHandle->execHandle.task;
|
||||||
// if (pTaskInfo != NULL) {
|
// if (pTaskInfo != NULL) {
|
||||||
// qKillTask(pTaskInfo, TSDB_CODE_SUCCESS);
|
// qKillTask(pTaskInfo, TSDB_CODE_SUCCESS);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
// if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
// qStreamCloseTsdbReader(pTaskInfo);
|
// qStreamCloseTsdbReader(pTaskInfo);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// remove if it has been register in the push manager, and return one empty block to consumer
|
// remove if it has been register in the push manager, and return one empty block to consumer
|
||||||
tqUnregisterPushHandle(pTq, pHandle);
|
tqUnregisterPushHandle(pTq, pHandle);
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
|
@ -761,13 +789,11 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
taosMemoryFree(req.qmsg);
|
tDecoderClear(&dc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freePtr(void *ptr) {
|
void freePtr(void* ptr) { taosMemoryFree(*(void**)ptr); }
|
||||||
taosMemoryFree(*(void**)ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
|
@ -790,7 +816,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
||||||
pTask->chkInfo.currentVer = ver;
|
pTask->chkInfo.currentVer = ver;
|
||||||
|
|
||||||
// expand executor
|
// expand executor
|
||||||
pTask->status.taskStatus = (pTask->fillHistory)? TASK_STATUS__WAIT_DOWNSTREAM:TASK_STATUS__NORMAL;
|
pTask->status.taskStatus = (pTask->fillHistory) ? TASK_STATUS__WAIT_DOWNSTREAM : TASK_STATUS__NORMAL;
|
||||||
|
|
||||||
if (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
if (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1);
|
pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1);
|
||||||
|
@ -856,8 +882,8 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
||||||
|
|
||||||
streamSetupTrigger(pTask);
|
streamSetupTrigger(pTask);
|
||||||
|
|
||||||
tqInfo("vgId:%d expand stream task, s-task:%s, checkpoint ver:%" PRId64 " child id:%d, level:%d", vgId, pTask->id.idStr,
|
tqInfo("vgId:%d expand stream task, s-task:%s, checkpoint ver:%" PRId64 " child id:%d, level:%d", vgId,
|
||||||
pTask->chkInfo.version, pTask->selfChildId, pTask->taskLevel);
|
pTask->id.idStr, pTask->chkInfo.version, pTask->selfChildId, pTask->taskLevel);
|
||||||
|
|
||||||
// next valid version will add one
|
// next valid version will add one
|
||||||
pTask->chkInfo.version += 1;
|
pTask->chkInfo.version += 1;
|
||||||
|
@ -970,7 +996,8 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t ms
|
||||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tqError("vgId:%d failed to create stream task due to out of memory, alloc size:%d", vgId, (int32_t) sizeof(SStreamTask));
|
tqError("vgId:%d failed to create stream task due to out of memory, alloc size:%d", vgId,
|
||||||
|
(int32_t)sizeof(SStreamTask));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,7 +1112,7 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t sversion, char* msg, int32_t
|
||||||
|
|
||||||
// do recovery step 2
|
// do recovery step 2
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
tqDebug("s-task:%s start step2 recover, ts:%"PRId64, pTask->id.idStr, st);
|
tqDebug("s-task:%s start step2 recover, ts:%" PRId64, pTask->id.idStr, st);
|
||||||
|
|
||||||
code = streamSourceRecoverScanStep2(pTask, sversion);
|
code = streamSourceRecoverScanStep2(pTask, sversion);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
|
@ -1093,7 +1120,8 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t sversion, char* msg, int32_t
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("s-task:%s set the start wal offset to be:%"PRId64, pTask->id.idStr, sversion);
|
qDebug("s-task:%s set start wal scan start ver:%"PRId64, pTask->id.idStr, sversion);
|
||||||
|
|
||||||
walReaderSeekVer(pTask->exec.pWalReader, sversion);
|
walReaderSeekVer(pTask->exec.pWalReader, sversion);
|
||||||
pTask->chkInfo.currentVer = sversion;
|
pTask->chkInfo.currentVer = sversion;
|
||||||
|
|
||||||
|
@ -1117,7 +1145,7 @@ int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t sversion, char* msg, int32_t
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double el = (taosGetTimestampMs() - st)/ 1000.0;
|
double el = (taosGetTimestampMs() - st) / 1000.0;
|
||||||
tqDebug("s-task:%s step2 recover finished, el:%.2fs", pTask->id.idStr, el);
|
tqDebug("s-task:%s step2 recover finished, el:%.2fs", pTask->id.idStr, el);
|
||||||
|
|
||||||
// dispatch recover finish req to all related downstream task
|
// dispatch recover finish req to all related downstream task
|
||||||
|
@ -1233,8 +1261,8 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||||
if (pTask != NULL) {
|
if (pTask != NULL) {
|
||||||
if (pTask->status.taskStatus == TASK_STATUS__NORMAL) {
|
if (pTask->status.taskStatus == TASK_STATUS__NORMAL) {
|
||||||
tqDebug("vgId:%d s-task:%s start to process block from wal, last chk point:%" PRId64, vgId,
|
tqDebug("vgId:%d s-task:%s start to process block from wal, last chk point:%" PRId64, vgId, pTask->id.idStr,
|
||||||
pTask->id.idStr, pTask->chkInfo.version);
|
pTask->chkInfo.version);
|
||||||
streamProcessRunReq(pTask);
|
streamProcessRunReq(pTask);
|
||||||
} else {
|
} else {
|
||||||
if (streamTaskShouldPause(&pTask->status)) {
|
if (streamTaskShouldPause(&pTask->status)) {
|
||||||
|
|
|
@ -37,6 +37,9 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
|
||||||
}
|
}
|
||||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
if (tEncodeI64(pEncoder, pHandle->execHandle.execTb.suid) < 0) return -1;
|
if (tEncodeI64(pEncoder, pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||||
|
if (pHandle->execHandle.execTb.qmsg != NULL){
|
||||||
|
if (tEncodeCStr(pEncoder, pHandle->execHandle.execTb.qmsg) < 0) return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tEndEncode(pEncoder);
|
tEndEncode(pEncoder);
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
|
@ -64,6 +67,9 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
||||||
}
|
}
|
||||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
if (tDecodeI64(pDecoder, &pHandle->execHandle.execTb.suid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||||
|
if (!tDecodeIsEnd(pDecoder)){
|
||||||
|
if (tDecodeCStrAlloc(pDecoder, &pHandle->execHandle.execTb.qmsg) < 0) return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tEndDecode(pDecoder);
|
tEndDecode(pDecoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -337,20 +343,27 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
||||||
} else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||||
|
|
||||||
SArray* tbUidList = taosArrayInit(0, sizeof(int64_t));
|
if(handle.execHandle.execTb.qmsg != NULL && strcmp(handle.execHandle.execTb.qmsg, "") != 0) {
|
||||||
vnodeGetCtbIdList(pTq->pVnode, handle.execHandle.execTb.suid, tbUidList);
|
if (nodesStringToNode(handle.execHandle.execTb.qmsg, &handle.execHandle.execTb.node) != 0) {
|
||||||
tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid);
|
tqError("nodesStringToNode error in sub stable, since %s", terrstr());
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
return -1;
|
||||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
}
|
||||||
tqDebug("vgId:%d, idx %d, uid:%" PRId64, vgId, i, tbUid);
|
|
||||||
}
|
}
|
||||||
handle.execHandle.pTqReader = tqReaderOpen(pTq->pVnode);
|
|
||||||
tqReaderSetTbUidList(handle.execHandle.pTqReader, tbUidList);
|
|
||||||
taosArrayDestroy(tbUidList);
|
|
||||||
|
|
||||||
buildSnapContext(reader.vnode, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType,
|
buildSnapContext(reader.vnode, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType,
|
||||||
handle.fetchMeta, (SSnapContext**)(&reader.sContext));
|
handle.fetchMeta, (SSnapContext**)(&reader.sContext));
|
||||||
handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0);
|
handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0);
|
||||||
|
|
||||||
|
SArray* tbUidList = NULL;
|
||||||
|
int ret = qGetTableList(handle.execHandle.execTb.suid, pTq->pVnode, handle.execHandle.execTb.node, &tbUidList, handle.execHandle.task);
|
||||||
|
if(ret != TDB_CODE_SUCCESS) {
|
||||||
|
tqError("qGetTableList error:%d handle %s consumer:0x%" PRIx64, ret, handle.subKey, handle.consumerId);
|
||||||
|
taosArrayDestroy(tbUidList);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
tqDebug("vgId:%d, tq try to get ctb for stb subscribe, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid);
|
||||||
|
handle.execHandle.pTqReader = tqReaderOpen(pTq->pVnode);
|
||||||
|
tqReaderSetTbUidList(handle.execHandle.pTqReader, tbUidList, NULL);
|
||||||
|
taosArrayDestroy(tbUidList);
|
||||||
}
|
}
|
||||||
tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, vgId);
|
tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, vgId);
|
||||||
taosHashPut(pTq->pHandle, pKey, kLen, &handle, sizeof(STqHandle));
|
taosHashPut(pTq->pHandle, pKey, kLen, &handle, sizeof(STqHandle));
|
||||||
|
|
|
@ -457,7 +457,7 @@ bool tqNextBlockImpl(STqReader* pReader, const char* idstr) {
|
||||||
|
|
||||||
int32_t numOfBlocks = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
int32_t numOfBlocks = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||||
while (pReader->nextBlk < numOfBlocks) {
|
while (pReader->nextBlk < numOfBlocks) {
|
||||||
tqDebug("tq reader next data block, len:%d ver:%" PRId64 " index:%d/%d, %s", pReader->msg.msgLen, pReader->msg.ver,
|
tqDebug("try next data block, len:%d ver:%" PRId64 " index:%d/%d, %s", pReader->msg.msgLen, pReader->msg.ver,
|
||||||
pReader->nextBlk, numOfBlocks, idstr);
|
pReader->nextBlk, numOfBlocks, idstr);
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
@ -467,10 +467,11 @@ bool tqNextBlockImpl(STqReader* pReader, const char* idstr) {
|
||||||
|
|
||||||
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
tqDebug("tq reader block found, ver:%" PRId64 ", uid:%" PRId64, pReader->msg.ver, pSubmitTbData->uid);
|
tqDebug("block found, ver:%" PRId64 ", uid:%" PRId64", %s", pReader->msg.ver, pSubmitTbData->uid, idstr);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
tqDebug("tq reader discard submit block, uid:%" PRId64 ", continue", pSubmitTbData->uid);
|
tqDebug("discard submit block, uid:%" PRId64 ", total queried tables:%d continue %s", pSubmitTbData->uid,
|
||||||
|
taosHashGetSize(pReader->tbIdHash), idstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->nextBlk++;
|
pReader->nextBlk++;
|
||||||
|
@ -604,7 +605,6 @@ static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SCol
|
||||||
|
|
||||||
int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* id) {
|
int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* id) {
|
||||||
tqDebug("tq reader retrieve data block %p, index:%d", pReader->msg.msgStr, pReader->nextBlk);
|
tqDebug("tq reader retrieve data block %p, index:%d", pReader->msg.msgStr, pReader->nextBlk);
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk++);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk++);
|
||||||
|
|
||||||
SSDataBlock* pBlock = pReader->pResBlock;
|
SSDataBlock* pBlock = pReader->pResBlock;
|
||||||
|
@ -612,6 +612,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
|
|
||||||
blockDataCleanup(pBlock);
|
blockDataCleanup(pBlock);
|
||||||
|
|
||||||
|
int32_t vgId = pReader->pWalReader->pWal->cfg.vgId;
|
||||||
int32_t sversion = pSubmitTbData->sver;
|
int32_t sversion = pSubmitTbData->sver;
|
||||||
int64_t suid = pSubmitTbData->suid;
|
int64_t suid = pSubmitTbData->suid;
|
||||||
int64_t uid = pSubmitTbData->uid;
|
int64_t uid = pSubmitTbData->uid;
|
||||||
|
@ -628,7 +629,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
if (pReader->pSchemaWrapper == NULL) {
|
if (pReader->pSchemaWrapper == NULL) {
|
||||||
tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", uid:%" PRId64
|
tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", uid:%" PRId64
|
||||||
"version %d, possibly dropped table",
|
"version %d, possibly dropped table",
|
||||||
pReader->pWalReader->pWal->cfg.vgId, suid, uid, pReader->cachedSchemaVer);
|
vgId, suid, uid, pReader->cachedSchemaVer);
|
||||||
pReader->cachedSchemaSuid = 0;
|
pReader->cachedSchemaSuid = 0;
|
||||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -642,6 +643,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
if (blockDataGetNumOfCols(pBlock) == 0) {
|
||||||
int32_t code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
int32_t code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tqError("vgId:%d failed to build data block, code:%s", vgId, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -998,7 +1000,7 @@ FAIL:
|
||||||
|
|
||||||
void tqReaderSetColIdList(STqReader* pReader, SArray* pColIdList) { pReader->pColIdList = pColIdList; }
|
void tqReaderSetColIdList(STqReader* pReader, SArray* pColIdList) { pReader->pColIdList = pColIdList; }
|
||||||
|
|
||||||
int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList, const char* id) {
|
||||||
if (pReader->tbIdHash) {
|
if (pReader->tbIdHash) {
|
||||||
taosHashClear(pReader->tbIdHash);
|
taosHashClear(pReader->tbIdHash);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1015,6 +1017,7 @@ int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||||
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tqDebug("s-task:%s %d tables are set to be queried target table", id, (int32_t) taosArrayGetSize(tbUidList));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,34 +1085,15 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
||||||
}
|
}
|
||||||
} else if (pTqHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pTqHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
SArray* qa = taosArrayInit(4, sizeof(tb_uid_t));
|
SArray* list = NULL;
|
||||||
SMetaReader mr = {0};
|
int ret = qGetTableList(pTqHandle->execHandle.execTb.suid, pTq->pVnode, pTqHandle->execHandle.execTb.node, &list, pTqHandle->execHandle.task);
|
||||||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
if(ret != TDB_CODE_SUCCESS) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); ++i) {
|
tqError("qGetTableList in tqUpdateTbUidList error:%d handle %s consumer:0x%" PRIx64, ret, pTqHandle->subKey, pTqHandle->consumerId);
|
||||||
uint64_t* id = (uint64_t*)taosArrayGet(tbUidList, i);
|
taosArrayDestroy(list);
|
||||||
|
return ret;
|
||||||
int32_t code = metaReaderGetTableEntryByUidCache(&mr, *id);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tqError("failed to get table meta, uid:%" PRIu64 " code:%s", *id, tstrerror(terrno));
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
tqReaderSetTbUidList(pTqHandle->execHandle.pTqReader, list, NULL);
|
||||||
tDecoderClear(&mr.coder);
|
taosArrayDestroy(list);
|
||||||
if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != pTqHandle->execHandle.execTb.suid) {
|
|
||||||
tqDebug("table uid %" PRId64 " does not add to tq handle", *id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
tqDebug("table uid %" PRId64 " add to tq handle", *id);
|
|
||||||
taosArrayPush(qa, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
metaReaderClear(&mr);
|
|
||||||
if (taosArrayGetSize(qa) > 0) {
|
|
||||||
tqReaderAddTbUidList(pTqHandle->execHandle.pTqReader, qa);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(qa);
|
|
||||||
} else {
|
} else {
|
||||||
tqReaderRemoveTbUidList(pTqHandle->execHandle.pTqReader, tbUidList);
|
tqReaderRemoveTbUidList(pTqHandle->execHandle.pTqReader, tbUidList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,6 +294,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
||||||
|
|
||||||
char* ctbName = pDataBlock->info.parTbName;
|
char* ctbName = pDataBlock->info.parTbName;
|
||||||
if (!ctbName[0]) {
|
if (!ctbName[0]) {
|
||||||
|
memset(ctbName, 0, TSDB_TABLE_NAME_LEN);
|
||||||
if (res == TSDB_CODE_SUCCESS) {
|
if (res == TSDB_CODE_SUCCESS) {
|
||||||
memcpy(ctbName, pTableSinkInfo->tbName, strlen(pTableSinkInfo->tbName));
|
memcpy(ctbName, pTableSinkInfo->tbName, strlen(pTableSinkInfo->tbName));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1454,7 +1454,7 @@ static int32_t getTableDelDataFromDelIdx(SDelFReader *pDelReader, SDelIdx *pDelI
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pDelIdx) {
|
if (pDelIdx) {
|
||||||
code = tsdbReadDelData(pDelReader, pDelIdx, aDelData);
|
code = tsdbReadDelDatav1(pDelReader, pDelIdx, aDelData, INT64_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -266,7 +266,7 @@ static int32_t tsdbCommitTableDel(SCommitter *pCommitter, STbData *pTbData, SDel
|
||||||
suid = pDelIdx->suid;
|
suid = pDelIdx->suid;
|
||||||
uid = pDelIdx->uid;
|
uid = pDelIdx->uid;
|
||||||
|
|
||||||
code = tsdbReadDelData(pCommitter->pDelFReader, pDelIdx, pCommitter->aDelData);
|
code = tsdbReadDelDatav1(pCommitter->pDelFReader, pDelIdx, pCommitter->aDelData, INT64_MAX);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {
|
||||||
taosArrayClear(pCommitter->aDelData);
|
taosArrayClear(pCommitter->aDelData);
|
||||||
|
|
|
@ -412,7 +412,7 @@ static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbReadDelData(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData);
|
code = tsdbReadDelDatav1(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData, INT64_MAX);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
pIter->delInfo.suid = pDelIdx->suid;
|
pIter->delInfo.suid = pDelIdx->suid;
|
||||||
|
|
|
@ -2967,7 +2967,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
if (pIdx != NULL) {
|
if (pIdx != NULL) {
|
||||||
code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData);
|
code = tsdbReadDelDatav1(pReader->pDelFReader, pIdx, pDelData, pReader->verRange.maxVer);
|
||||||
}
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -2978,7 +2978,10 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
if (pMemTbData != NULL) {
|
if (pMemTbData != NULL) {
|
||||||
p = pMemTbData->pHead;
|
p = pMemTbData->pHead;
|
||||||
while (p) {
|
while (p) {
|
||||||
|
if (p->version <= pReader->verRange.maxVer) {
|
||||||
taosArrayPush(pDelData, p);
|
taosArrayPush(pDelData, p);
|
||||||
|
}
|
||||||
|
|
||||||
p = p->pNext;
|
p = p->pNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2986,7 +2989,9 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
if (piMemTbData != NULL) {
|
if (piMemTbData != NULL) {
|
||||||
p = piMemTbData->pHead;
|
p = piMemTbData->pHead;
|
||||||
while (p) {
|
while (p) {
|
||||||
|
if (p->version <= pReader->verRange.maxVer) {
|
||||||
taosArrayPush(pDelData, p);
|
taosArrayPush(pDelData, p);
|
||||||
|
}
|
||||||
p = p->pNext;
|
p = p->pNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4558,7 +4563,11 @@ int32_t tsdbReaderOpen(void* pVnode, SQueryTableDataCond* pCond, void* pTableLis
|
||||||
|
|
||||||
pReader->pIgnoreTables = pIgnoreTables;
|
pReader->pIgnoreTables = pIgnoreTables;
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
tsdbDebug("%p total numOfTable:%d, window:%" PRId64 " - %" PRId64 ", verRange:%" PRId64 " - %" PRId64
|
||||||
|
" in this query %s",
|
||||||
|
pReader, numOfTables, pReader->window.skey, pReader->window.ekey, pReader->verRange.minVer,
|
||||||
|
pReader->verRange.maxVer, pReader->idStr);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
|
@ -1489,6 +1489,10 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) {
|
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) {
|
||||||
|
return tsdbReadDelDatav1(pReader, pDelIdx, aDelData, INT64_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData, int64_t maxVer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t offset = pDelIdx->offset;
|
int64_t offset = pDelIdx->offset;
|
||||||
int64_t size = pDelIdx->size;
|
int64_t size = pDelIdx->size;
|
||||||
|
@ -1510,11 +1514,15 @@ int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData
|
||||||
SDelData delData;
|
SDelData delData;
|
||||||
n += tGetDelData(pReader->aBuf[0] + n, &delData);
|
n += tGetDelData(pReader->aBuf[0] + n, &delData);
|
||||||
|
|
||||||
|
if (delData.version > maxVer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (taosArrayPush(aDelData, &delData) == NULL) {
|
if (taosArrayPush(aDelData, &delData) == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(n == size);
|
ASSERT(n == size);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -1166,7 +1166,7 @@ static int32_t tsdbSnapWriteDelTableDataStart(STsdbSnapWriter* pWriter, TABLEID*
|
||||||
|
|
||||||
int32_t c = tTABLEIDCmprFn(pDelIdx, &pWriter->tbid);
|
int32_t c = tTABLEIDCmprFn(pDelIdx, &pWriter->tbid);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->pTIter->tIter.aDelData);
|
code = tsdbReadDelDatav1(pWriter->pDelFReader, pDelIdx, pWriter->pTIter->tIter.aDelData, INT64_MAX);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
SDelIdx* pDelIdxNew = taosArrayReserve(pWriter->aDelIdx, 1);
|
SDelIdx* pDelIdxNew = taosArrayReserve(pWriter->aDelIdx, 1);
|
||||||
|
@ -1183,7 +1183,7 @@ static int32_t tsdbSnapWriteDelTableDataStart(STsdbSnapWriter* pWriter, TABLEID*
|
||||||
|
|
||||||
pWriter->pTIter->tIter.iDelIdx++;
|
pWriter->pTIter->tIter.iDelIdx++;
|
||||||
} else if (c == 0) {
|
} else if (c == 0) {
|
||||||
code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
|
code = tsdbReadDelDatav1(pWriter->pDelFReader, pDelIdx, pWriter->aDelData, INT64_MAX);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
pWriter->pTIter->tIter.iDelIdx++;
|
pWriter->pTIter->tIter.iDelIdx++;
|
||||||
|
|
|
@ -456,6 +456,7 @@ typedef struct SStreamIntervalOperatorInfo {
|
||||||
SSHashObj* pUpdatedMap;
|
SSHashObj* pUpdatedMap;
|
||||||
int64_t dataVersion;
|
int64_t dataVersion;
|
||||||
SStateStore statestore;
|
SStateStore statestore;
|
||||||
|
bool recvGetAll;
|
||||||
} SStreamIntervalOperatorInfo;
|
} SStreamIntervalOperatorInfo;
|
||||||
|
|
||||||
typedef struct SDataGroupInfo {
|
typedef struct SDataGroupInfo {
|
||||||
|
|
|
@ -960,6 +960,7 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
|
||||||
SArray* pBlockList = NULL;
|
SArray* pBlockList = NULL;
|
||||||
SSDataBlock* pResBlock = NULL;
|
SSDataBlock* pResBlock = NULL;
|
||||||
SScalarParam output = {0};
|
SScalarParam output = {0};
|
||||||
|
SArray* pUidTagList = NULL;
|
||||||
|
|
||||||
tagFilterAssist ctx = {0};
|
tagFilterAssist ctx = {0};
|
||||||
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||||
|
@ -979,7 +980,7 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
|
||||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||||
|
|
||||||
// int64_t stt = taosGetTimestampUs();
|
// int64_t stt = taosGetTimestampUs();
|
||||||
SArray* pUidTagList = taosArrayInit(10, sizeof(STUidTagInfo));
|
pUidTagList = taosArrayInit(10, sizeof(STUidTagInfo));
|
||||||
copyExistedUids(pUidTagList, pUidList);
|
copyExistedUids(pUidTagList, pUidList);
|
||||||
|
|
||||||
FilterCondType condType = checkTagCond(pTagCond);
|
FilterCondType condType = checkTagCond(pTagCond);
|
||||||
|
@ -1151,6 +1152,21 @@ _end:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qGetTableList(int64_t suid, void* pVnode, void* node, SArray **tableList, void* pTaskInfo){
|
||||||
|
SSubplan *pSubplan = (SSubplan *)node;
|
||||||
|
SScanPhysiNode pNode = {0};
|
||||||
|
pNode.suid = suid;
|
||||||
|
pNode.uid = suid;
|
||||||
|
pNode.tableType = TSDB_SUPER_TABLE;
|
||||||
|
STableListInfo* pTableListInfo = tableListCreate();
|
||||||
|
uint8_t digest[17] = {0};
|
||||||
|
int code = getTableList(pVnode, &pNode, pSubplan ? pSubplan->pTagCond : NULL, pSubplan ? pSubplan->pTagIndexCond : NULL, pTableListInfo, digest, "qGetTableList", &((SExecTaskInfo*)pTaskInfo)->storageAPI);
|
||||||
|
*tableList = pTableListInfo->pTableList;
|
||||||
|
pTableListInfo->pTableList = NULL;
|
||||||
|
tableListDestroy(pTableListInfo);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
size_t getTableTagsBufLen(const SNodeList* pGroups) {
|
size_t getTableTagsBufLen(const SNodeList* pGroups) {
|
||||||
size_t keyLen = 0;
|
size_t keyLen = 0;
|
||||||
|
|
||||||
|
|
|
@ -406,7 +406,7 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), id);
|
qDebug("try to add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// traverse to the stream scanner node to add this table id
|
// traverse to the stream scanner node to add this table id
|
||||||
|
|
|
@ -828,7 +828,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
|
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
|
||||||
uint32_t newSize = pBlock->info.rows + pRow->numOfRows + (numOfRows - i) > 1 ? 1 : 0;
|
uint32_t newSize = pBlock->info.rows + pRow->numOfRows + ((numOfRows - i) > 1 ? 1 : 0);
|
||||||
blockDataEnsureCapacity(pBlock, newSize);
|
blockDataEnsureCapacity(pBlock, newSize);
|
||||||
qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s",
|
qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s",
|
||||||
newSize, pBlock->info.capacity, GET_TASKID(pTaskInfo));
|
newSize, pBlock->info.capacity, GET_TASKID(pTaskInfo));
|
||||||
|
|
|
@ -1059,9 +1059,10 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pBlock = pInfo->pSrcBlock;
|
SSDataBlock* pBlock = pInfo->pSrcBlock;
|
||||||
uint64_t groupId = pBlock->info.id.groupId;
|
uint64_t groupId = pBlock->info.id.groupId;
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
pRes->info.id.groupId = groupId;
|
|
||||||
SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol);
|
SColumnInfoData* pTsCol = taosArrayGet(pInfo->pSrcBlock->pDataBlock, pInfo->primaryTsCol);
|
||||||
TSKEY* tsCol = (TSKEY*)pTsCol->pData;
|
TSKEY* tsCol = (TSKEY*)pTsCol->pData;
|
||||||
|
pRes->info.id.groupId = groupId;
|
||||||
|
pInfo->srcRowIndex++;
|
||||||
|
|
||||||
if (pInfo->srcRowIndex == 0) {
|
if (pInfo->srcRowIndex == 0) {
|
||||||
keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize);
|
keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize);
|
||||||
|
@ -1299,7 +1300,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* fillResult = NULL;
|
SSDataBlock* fillResult = NULL;
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pInfo->srcRowIndex >= pInfo->pSrcBlock->info.rows) {
|
if (pInfo->srcRowIndex >= pInfo->pSrcBlock->info.rows || pInfo->pSrcBlock->info.rows == 0) {
|
||||||
// If there are delete datablocks, we receive them first.
|
// If there are delete datablocks, we receive them first.
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
|
@ -1338,7 +1339,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
||||||
case STREAM_PULL_DATA: {
|
case STREAM_PULL_DATA: {
|
||||||
doApplyStreamScalarCalculation(pOperator, pBlock, pInfo->pSrcBlock);
|
doApplyStreamScalarCalculation(pOperator, pBlock, pInfo->pSrcBlock);
|
||||||
memcpy(pInfo->pSrcBlock->info.parTbName, pBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
memcpy(pInfo->pSrcBlock->info.parTbName, pBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
||||||
pInfo->srcRowIndex = 0;
|
pInfo->srcRowIndex = -1;
|
||||||
} break;
|
} break;
|
||||||
case STREAM_CREATE_CHILD_TABLE: {
|
case STREAM_CREATE_CHILD_TABLE: {
|
||||||
return pBlock;
|
return pBlock;
|
||||||
|
@ -1554,7 +1555,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->srcRowIndex = 0;
|
pInfo->srcRowIndex = -1;
|
||||||
setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo,
|
setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo,
|
||||||
pTaskInfo);
|
pTaskInfo);
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
#include "executorInt.h"
|
#include "executorInt.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
@ -1040,6 +1042,7 @@ static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t grou
|
||||||
|
|
||||||
void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin, uint64_t ver) {
|
void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin, uint64_t ver) {
|
||||||
pTableScanInfo->base.cond.twindows = *pWin;
|
pTableScanInfo->base.cond.twindows = *pWin;
|
||||||
|
pTableScanInfo->base.cond.startVersion = 0;
|
||||||
pTableScanInfo->base.cond.endVersion = ver;
|
pTableScanInfo->base.cond.endVersion = ver;
|
||||||
pTableScanInfo->scanTimes = 0;
|
pTableScanInfo->scanTimes = 0;
|
||||||
pTableScanInfo->currentGroupId = -1;
|
pTableScanInfo->currentGroupId = -1;
|
||||||
|
@ -1162,6 +1165,7 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
STableScanInfo* pTScanInfo = pInfo->pTableScanOp->info;
|
STableScanInfo* pTScanInfo = pInfo->pTableScanOp->info;
|
||||||
|
qDebug("prepare range scan start:%" PRId64 ",end:%" PRId64 ",maxVer:%" PRIu64, win.skey, win.ekey, pInfo->pUpdateInfo->maxDataVersion);
|
||||||
resetTableScanInfo(pInfo->pTableScanOp->info, &win, pInfo->pUpdateInfo->maxDataVersion);
|
resetTableScanInfo(pInfo->pTableScanOp->info, &win, pInfo->pUpdateInfo->maxDataVersion);
|
||||||
pInfo->pTableScanOp->status = OP_OPENED;
|
pInfo->pTableScanOp->status = OP_OPENED;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1861,6 +1865,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex);
|
TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
||||||
} else {
|
} else {
|
||||||
|
pInfo->pUpdateInfo->maxDataVersion = pTaskInfo->streamInfo.fillHistoryVer2;
|
||||||
doCheckUpdate(pInfo, pInfo->pRecoverRes->info.window.ekey, pInfo->pRecoverRes);
|
doCheckUpdate(pInfo, pInfo->pRecoverRes->info.window.ekey, pInfo->pRecoverRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1869,6 +1874,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
printDataBlock(pInfo->pCreateTbRes, "recover createTbl");
|
printDataBlock(pInfo->pCreateTbRes, "recover createTbl");
|
||||||
return pInfo->pCreateTbRes;
|
return pInfo->pCreateTbRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("stream recover scan get block, rows %" PRId64, pInfo->pRecoverRes->info.rows);
|
qDebug("stream recover scan get block, rows %" PRId64, pInfo->pRecoverRes->info.rows);
|
||||||
printDataBlock(pInfo->pRecoverRes, "scan recover");
|
printDataBlock(pInfo->pRecoverRes, "scan recover");
|
||||||
return pInfo->pRecoverRes;
|
return pInfo->pRecoverRes;
|
||||||
|
@ -1977,7 +1983,7 @@ FETCH_NEXT_BLOCK:
|
||||||
// printDataBlock(pBlock, "stream scan recv");
|
// printDataBlock(pBlock, "stream scan recv");
|
||||||
return pBlock;
|
return pBlock;
|
||||||
} else if (pInfo->blockType == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (pInfo->blockType == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
qDebug("scan mode %d", pInfo->scanMode);
|
qDebug("stream scan mode:%d, %s", pInfo->scanMode, id);
|
||||||
switch (pInfo->scanMode) {
|
switch (pInfo->scanMode) {
|
||||||
case STREAM_SCAN_FROM_RES: {
|
case STREAM_SCAN_FROM_RES: {
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||||
|
@ -2061,8 +2067,13 @@ FETCH_NEXT_BLOCK:
|
||||||
|
|
||||||
while (pAPI->tqReaderFn.tqNextBlockImpl(pInfo->tqReader, id)) {
|
while (pAPI->tqReaderFn.tqNextBlockImpl(pInfo->tqReader, id)) {
|
||||||
SSDataBlock* pRes = NULL;
|
SSDataBlock* pRes = NULL;
|
||||||
|
|
||||||
int32_t code = pAPI->tqReaderFn.tqRetrieveBlock(pInfo->tqReader, &pRes, id);
|
int32_t code = pAPI->tqReaderFn.tqRetrieveBlock(pInfo->tqReader, &pRes, id);
|
||||||
|
qDebug("retrieve data from submit completed code:%s, rows:%" PRId64 " %s", tstrerror(code), pRes->info.rows,
|
||||||
|
id);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS || pRes->info.rows == 0) {
|
if (code != TSDB_CODE_SUCCESS || pRes->info.rows == 0) {
|
||||||
|
qDebug("retrieve data failed, try next block in submit block, %s", id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2070,6 +2081,7 @@ FETCH_NEXT_BLOCK:
|
||||||
|
|
||||||
if (pInfo->pCreateTbRes->info.rows > 0) {
|
if (pInfo->pCreateTbRes->info.rows > 0) {
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_RES;
|
pInfo->scanMode = STREAM_SCAN_FROM_RES;
|
||||||
|
qDebug("create table res exists, rows:%"PRId64" return from stream scan, %s", pInfo->pCreateTbRes->info.rows, id);
|
||||||
return pInfo->pCreateTbRes;
|
return pInfo->pCreateTbRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2078,6 +2090,8 @@ FETCH_NEXT_BLOCK:
|
||||||
pBlock->info.dataLoad = 1;
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
|
||||||
|
|
||||||
|
qDebug("%" PRId64 " rows in datablock, update res:%" PRId64 " %s", pBlockInfo->rows,
|
||||||
|
pInfo->pUpdateDataRes->info.rows, id);
|
||||||
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2094,7 +2108,7 @@ FETCH_NEXT_BLOCK:
|
||||||
pInfo->numOfExec++;
|
pInfo->numOfExec++;
|
||||||
pOperator->resultInfo.totalRows += pBlockInfo->rows;
|
pOperator->resultInfo.totalRows += pBlockInfo->rows;
|
||||||
|
|
||||||
qDebug("stream scan get source rows:%" PRId64", %s", pBlockInfo->rows, id);
|
qDebug("stream scan completed, and return source rows:%" PRId64", %s", pBlockInfo->rows, id);
|
||||||
if (pBlockInfo->rows > 0) {
|
if (pBlockInfo->rows > 0) {
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
@ -2281,6 +2295,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo));
|
SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||||
|
const char* idstr = pTaskInfo->id.str;
|
||||||
|
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -2391,7 +2406,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
// set the extract column id to streamHandle
|
// set the extract column id to streamHandle
|
||||||
pAPI->tqReaderFn.tqReaderSetColIdList(pInfo->tqReader, pColIds);
|
pAPI->tqReaderFn.tqReaderSetColIdList(pInfo->tqReader, pColIds);
|
||||||
SArray* tableIdList = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo);
|
SArray* tableIdList = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo);
|
||||||
code = pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList);
|
code = pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList, idstr);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosArrayDestroy(tableIdList);
|
taosArrayDestroy(tableIdList);
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -2441,6 +2456,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
pAPI->stateStore.streamStateGetInfo(pTaskInfo->streamInfo.pState, STREAM_SCAN_OP_NAME, strlen(STREAM_SCAN_OP_NAME), &buff, &len);
|
pAPI->stateStore.streamStateGetInfo(pTaskInfo->streamInfo.pState, STREAM_SCAN_OP_NAME, strlen(STREAM_SCAN_OP_NAME), &buff, &len);
|
||||||
streamScanOperatorDecode(buff, len, pInfo);
|
streamScanOperatorDecode(buff, len, pInfo);
|
||||||
|
taosMemoryFree(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOperatorInfo(pOperator, STREAM_SCAN_OP_NAME, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, false, OP_NOT_OPENED, pInfo,
|
setOperatorInfo(pOperator, STREAM_SCAN_OP_NAME, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||||
|
@ -3455,3 +3471,5 @@ static void destoryTableCountScanOperator(void* param) {
|
||||||
taosArrayDestroy(pTableCountScanInfo->stbUidList);
|
taosArrayDestroy(pTableCountScanInfo->stbUidList);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
|
@ -2439,6 +2439,15 @@ static inline int winPosCmprImpl(const void* pKey1, const void* pKey2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void resetUnCloseWinInfo(SSHashObj* winMap) {
|
||||||
|
void* pIte = NULL;
|
||||||
|
int32_t iter = 0;
|
||||||
|
while ((pIte = tSimpleHashIterate(winMap, pIte, &iter)) != NULL) {
|
||||||
|
SRowBuffPos* pPos = *(SRowBuffPos**)pIte;
|
||||||
|
pPos->beUsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -2472,6 +2481,11 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pInfo->recvGetAll) {
|
||||||
|
pInfo->recvGetAll = false;
|
||||||
|
resetUnCloseWinInfo(pInfo->aggSup.pResultRowHashTable);
|
||||||
|
}
|
||||||
|
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
if (!IS_FINAL_OP(pInfo)) {
|
if (!IS_FINAL_OP(pInfo)) {
|
||||||
clearFunctionContext(&pOperator->exprSupp);
|
clearFunctionContext(&pOperator->exprSupp);
|
||||||
|
@ -2565,6 +2579,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL && IS_FINAL_OP(pInfo)) {
|
} else if (pBlock->info.type == STREAM_GET_ALL && IS_FINAL_OP(pInfo)) {
|
||||||
|
pInfo->recvGetAll = true;
|
||||||
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pInfo->pUpdatedMap);
|
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pInfo->pUpdatedMap);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_OP(pInfo)) {
|
} else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_OP(pInfo)) {
|
||||||
|
@ -2773,6 +2788,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
compareTs, pInfo->pState, pInfo->twAggSup.deleteMark);
|
compareTs, pInfo->pState, pInfo->twAggSup.deleteMark);
|
||||||
pInfo->dataVersion = 0;
|
pInfo->dataVersion = 0;
|
||||||
pInfo->statestore = pTaskInfo->storageAPI.stateStore;
|
pInfo->statestore = pTaskInfo->storageAPI.stateStore;
|
||||||
|
pInfo->recvGetAll = false;
|
||||||
|
|
||||||
pOperator->operatorType = pPhyNode->type;
|
pOperator->operatorType = pPhyNode->type;
|
||||||
pOperator->blocking = true;
|
pOperator->blocking = true;
|
||||||
|
@ -2867,7 +2883,7 @@ void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uin
|
||||||
SStreamScanInfo* pScanInfo = downstream->info;
|
SStreamScanInfo* pScanInfo = downstream->info;
|
||||||
pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = pAggSup->gap, .parentType = type};
|
pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = pAggSup->gap, .parentType = type};
|
||||||
pScanInfo->pState = pAggSup->pState;
|
pScanInfo->pState = pAggSup->pState;
|
||||||
if ((!pScanInfo->igCheckUpdate || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) && !pScanInfo->pUpdateInfo) {
|
if (!pScanInfo->pUpdateInfo) {
|
||||||
pScanInfo->pUpdateInfo = pAggSup->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark);
|
pScanInfo->pUpdateInfo = pAggSup->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark);
|
||||||
}
|
}
|
||||||
pScanInfo->twAggSup = *pTwSup;
|
pScanInfo->twAggSup = *pTwSup;
|
||||||
|
@ -4751,6 +4767,12 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
printDataBlock(pInfo->binfo.pRes, "single interval");
|
printDataBlock(pInfo->binfo.pRes, "single interval");
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pInfo->recvGetAll) {
|
||||||
|
pInfo->recvGetAll = false;
|
||||||
|
resetUnCloseWinInfo(pInfo->aggSup.pResultRowHashTable);
|
||||||
|
}
|
||||||
|
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
if (pInfo->twAggSup.maxTs > 0 &&
|
if (pInfo->twAggSup.maxTs > 0 &&
|
||||||
pInfo->twAggSup.maxTs - pInfo->twAggSup.checkPointInterval > pInfo->twAggSup.checkPointTs) {
|
pInfo->twAggSup.maxTs - pInfo->twAggSup.checkPointInterval > pInfo->twAggSup.checkPointTs) {
|
||||||
|
@ -4790,6 +4812,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
qDebug("===stream===single interval recv|block type STREAM_GET_ALL");
|
qDebug("===stream===single interval recv|block type STREAM_GET_ALL");
|
||||||
|
pInfo->recvGetAll = true;
|
||||||
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pInfo->pUpdatedMap);
|
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pInfo->pUpdatedMap);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_CREATE_CHILD_TABLE) {
|
} else if (pBlock->info.type == STREAM_CREATE_CHILD_TABLE) {
|
||||||
|
@ -4960,6 +4983,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
||||||
destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
pInfo->statestore = pTaskInfo->storageAPI.stateStore;
|
pInfo->statestore = pTaskInfo->storageAPI.stateStore;
|
||||||
|
pInfo->recvGetAll = false;
|
||||||
|
|
||||||
initIntervalDownStream(downstream, pPhyNode->type, pInfo);
|
initIntervalDownStream(downstream, pPhyNode->type, pInfo);
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -921,6 +921,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||||
nodesDestroyNode(((SCreateTopicStmt*)pNode)->pQuery);
|
nodesDestroyNode(((SCreateTopicStmt*)pNode)->pQuery);
|
||||||
|
nodesDestroyNode(((SCreateTopicStmt*)pNode)->pWhere);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_DROP_TOPIC_STMT: // no pointer field
|
case QUERY_NODE_DROP_TOPIC_STMT: // no pointer field
|
||||||
case QUERY_NODE_DROP_CGROUP_STMT: // no pointer field
|
case QUERY_NODE_DROP_CGROUP_STMT: // no pointer field
|
||||||
|
|
|
@ -207,7 +207,7 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists,
|
||||||
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName,
|
SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SToken* pSubDbName,
|
||||||
bool withMeta);
|
bool withMeta);
|
||||||
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
||||||
bool withMeta);
|
bool withMeta, SNode* pWhere);
|
||||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName);
|
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pTopicName);
|
||||||
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, SToken* pTopicName);
|
SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, SToken* pTopicName);
|
||||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||||
|
|
|
@ -115,6 +115,7 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
||||||
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput);
|
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput);
|
||||||
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes);
|
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes);
|
||||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request);
|
void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request);
|
||||||
|
SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,9 +543,9 @@ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C).
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
||||||
WITH META AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, true); }
|
WITH META AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, true); }
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
||||||
AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, false); }
|
AS STABLE full_table_name(C) where_clause_opt(D). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, false, D); }
|
||||||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B)
|
||||||
WITH META AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, true); }
|
WITH META AS STABLE full_table_name(C) where_clause_opt(D). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, true, D); }
|
||||||
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
|
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
|
||||||
cmd ::= DROP CONSUMER GROUP exists_opt(A) cgroup_name(B) ON topic_name(C). { pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); }
|
cmd ::= DROP CONSUMER GROUP exists_opt(A) cgroup_name(B) ON topic_name(C). { pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); }
|
||||||
|
|
||||||
|
|
|
@ -833,16 +833,9 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) {
|
||||||
|
|
||||||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable) {
|
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
SNode* select = createSelectStmtImpl(isDistinct, pProjectionList, pTable);
|
||||||
CHECK_OUT_OF_MEM(select);
|
CHECK_OUT_OF_MEM(select);
|
||||||
select->isDistinct = isDistinct;
|
return select;
|
||||||
select->pProjectionList = pProjectionList;
|
|
||||||
select->pFromTable = pTable;
|
|
||||||
sprintf(select->stmtName, "%p", select);
|
|
||||||
select->isTimeLineResult = true;
|
|
||||||
select->onlyHasKeepOrderFunc = true;
|
|
||||||
select->timeRange = TSWINDOW_INITIALIZER;
|
|
||||||
return (SNode*)select;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setSubquery(SNode* pStmt) {
|
static void setSubquery(SNode* pStmt) {
|
||||||
|
@ -1723,7 +1716,7 @@ SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, ST
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pRealTable,
|
||||||
bool withMeta) {
|
bool withMeta, SNode* pWhere) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
if (!checkTopicName(pCxt, pTopicName)) {
|
if (!checkTopicName(pCxt, pTopicName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1733,6 +1726,8 @@ SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists,
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName);
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
pStmt->withMeta = withMeta;
|
pStmt->withMeta = withMeta;
|
||||||
|
pStmt->pWhere = pWhere;
|
||||||
|
|
||||||
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
|
strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
nodesDestroyNode(pRealTable);
|
nodesDestroyNode(pRealTable);
|
||||||
|
|
|
@ -355,6 +355,11 @@ static int32_t collectMetaKeyFromCreateTopic(SCollectMetaKeyCxt* pCxt, SCreateTo
|
||||||
if (NULL != pStmt->pQuery) {
|
if (NULL != pStmt->pQuery) {
|
||||||
return collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
|
return collectMetaKeyFromQuery(pCxt, pStmt->pQuery);
|
||||||
}
|
}
|
||||||
|
if (NULL != pStmt->pWhere) {
|
||||||
|
int32_t code = collectMetaKeyFromRealTableImpl(pCxt, pStmt->subDbName, pStmt->subSTbName,
|
||||||
|
AUTH_TYPE_READ);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,13 @@ typedef struct STranslateContext {
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
} STranslateContext;
|
} STranslateContext;
|
||||||
|
|
||||||
|
typedef struct SBuildTopicContext {
|
||||||
|
bool colExists;
|
||||||
|
bool colNotFound;
|
||||||
|
STableMeta* pMeta;
|
||||||
|
SNodeList* pTags;
|
||||||
|
} SBuildTopicContext;
|
||||||
|
|
||||||
typedef struct SFullDatabaseName {
|
typedef struct SFullDatabaseName {
|
||||||
char fullDbName[TSDB_DB_FNAME_LEN];
|
char fullDbName[TSDB_DB_FNAME_LEN];
|
||||||
} SFullDatabaseName;
|
} SFullDatabaseName;
|
||||||
|
@ -5825,6 +5832,9 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
|
||||||
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
||||||
tNameGetFullDbName(&name, pReq->subDbName);
|
tNameGetFullDbName(&name, pReq->subDbName);
|
||||||
tNameExtractFullName(&name, pReq->subStbName);
|
tNameExtractFullName(&name, pReq->subStbName);
|
||||||
|
if(pStmt->pQuery != NULL) {
|
||||||
|
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
||||||
|
}
|
||||||
} else if ('\0' != pStmt->subDbName[0]) {
|
} else if ('\0' != pStmt->subDbName[0]) {
|
||||||
pReq->subType = TOPIC_SUB_TYPE__DB;
|
pReq->subType = TOPIC_SUB_TYPE__DB;
|
||||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->subDbName, strlen(pStmt->subDbName));
|
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->subDbName, strlen(pStmt->subDbName));
|
||||||
|
@ -5847,12 +5857,108 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t addTagList(SNodeList** ppList, SNode* pNode) {
|
||||||
|
if (NULL == *ppList) {
|
||||||
|
*ppList = nodesMakeList();
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesListStrictAppend(*ppList, pNode);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EDealRes checkColumnTagsInCond(SNode* pNode, void* pContext) {
|
||||||
|
SBuildTopicContext* pCxt = (SBuildTopicContext*)pContext;
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
|
ETableColumnType type;
|
||||||
|
getColumnTypeFromMeta(pCxt->pMeta, ((SColumnNode*)pNode)->colName, &type);
|
||||||
|
if (type == TCOL_TYPE_COLUMN) {
|
||||||
|
pCxt->colExists = true;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
} else if (type == TCOL_TYPE_TAG) {
|
||||||
|
addTagList(&pCxt->pTags, nodesCloneNode(pNode));
|
||||||
|
} else {
|
||||||
|
pCxt->colNotFound = true;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
} else if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||||
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
|
if (0 == strcasecmp(pFunc->functionName, "tbname")) {
|
||||||
|
addTagList(&pCxt->pTags, nodesCloneNode(pNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt* pStmt, STableMeta* pMeta, SNodeList** ppProjection) {
|
||||||
|
SBuildTopicContext colCxt = {.colExists = false, .colNotFound = false, .pMeta = pMeta, .pTags = NULL};
|
||||||
|
nodesWalkExprPostOrder(pStmt->pWhere, checkColumnTagsInCond, &colCxt);
|
||||||
|
if (colCxt.colNotFound) {
|
||||||
|
nodesDestroyList(colCxt.pTags);
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Invalid column name");
|
||||||
|
} else if (colCxt.colExists) {
|
||||||
|
nodesDestroyList(colCxt.pTags);
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Columns are forbidden in where clause");
|
||||||
|
}
|
||||||
|
if (NULL == colCxt.pTags) { // put one column to select
|
||||||
|
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
|
||||||
|
SSchema* column = &pMeta->schema[0];
|
||||||
|
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
|
strcpy(col->colName, column->name);
|
||||||
|
strcpy(col->node.aliasName, col->colName);
|
||||||
|
strcpy(col->node.userAlias, col->colName);
|
||||||
|
addTagList(&colCxt.pTags, (SNode*)col);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppProjection = colCxt.pTags;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt, SNode** pSelect) {
|
||||||
|
SParseContext* pParCxt = pCxt->pParseCxt;
|
||||||
|
SRequestConnInfo connInfo = {.pTrans = pParCxt->pTransporter,
|
||||||
|
.requestId = pParCxt->requestId,
|
||||||
|
.requestObjRefId = pParCxt->requestRid,
|
||||||
|
.mgmtEps = pParCxt->mgmtEpSet};
|
||||||
|
SName name;
|
||||||
|
STableMeta* pMeta = NULL;
|
||||||
|
int32_t code = getTableMetaImpl(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta);
|
||||||
|
if (code) {
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
if (TSDB_SUPER_TABLE != pMeta->tableType) {
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Only supertable table can be used");
|
||||||
|
}
|
||||||
|
|
||||||
|
SNodeList* pProjection = NULL;
|
||||||
|
code = checkCollectTopicTags(pCxt, pStmt, pMeta, &pProjection);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
SRealTableNode* realTable = (SRealTableNode*)nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||||
|
strcpy(realTable->table.dbName, pStmt->subDbName);
|
||||||
|
strcpy(realTable->table.tableName, pStmt->subSTbName);
|
||||||
|
strcpy(realTable->table.tableAlias, pStmt->subSTbName);
|
||||||
|
*pSelect = createSelectStmtImpl(true, pProjection, (SNode*)realTable);
|
||||||
|
((SSelectStmt*)*pSelect)->pWhere = nodesCloneNode(pStmt->pWhere);
|
||||||
|
pCxt->pParseCxt->topicQuery = true;
|
||||||
|
code = translateQuery(pCxt, *pSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) {
|
static int32_t checkCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) {
|
||||||
if (NULL == pStmt->pQuery) {
|
if (NULL == pStmt->pQuery && NULL == pStmt->pWhere) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_SELECT_STMT == nodeType(pStmt->pQuery)) {
|
if (pStmt->pWhere) {
|
||||||
|
return buildQueryForTableTopic(pCxt, pStmt, &pStmt->pQuery);
|
||||||
|
} else if (QUERY_NODE_SELECT_STMT == nodeType(pStmt->pQuery)) {
|
||||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||||
if (!pSelect->isDistinct &&
|
if (!pSelect->isDistinct &&
|
||||||
(NULL != pSelect->pFromTable && QUERY_NODE_REAL_TABLE == nodeType(pSelect->pFromTable)) &&
|
(NULL != pSelect->pFromTable && QUERY_NODE_REAL_TABLE == nodeType(pSelect->pFromTable)) &&
|
||||||
|
|
|
@ -674,6 +674,22 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable) {
|
||||||
|
SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||||
|
if (NULL == select) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
select->isDistinct = isDistinct;
|
||||||
|
select->pProjectionList = pProjectionList;
|
||||||
|
select->pFromTable = pTable;
|
||||||
|
sprintf(select->stmtName, "%p", select);
|
||||||
|
select->isTimeLineResult = true;
|
||||||
|
select->onlyHasKeepOrderFunc = true;
|
||||||
|
select->timeRange = TSWINDOW_INITIALIZER;
|
||||||
|
return (SNode*)select;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) {
|
static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) {
|
||||||
if (NULL == *pHash) {
|
if (NULL == *pHash) {
|
||||||
*pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
*pHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1145,6 +1145,15 @@ TEST_F(ParserInitialCTest, createTopic) {
|
||||||
setCreateTopicReq("tp1", 1, "create topic if not exists tp1 with meta as stable st1", nullptr, "test", "st1", 1);
|
setCreateTopicReq("tp1", 1, "create topic if not exists tp1 with meta as stable st1", nullptr, "test", "st1", 1);
|
||||||
run("CREATE TOPIC IF NOT EXISTS tp1 WITH META AS STABLE st1");
|
run("CREATE TOPIC IF NOT EXISTS tp1 WITH META AS STABLE st1");
|
||||||
clearCreateTopicReq();
|
clearCreateTopicReq();
|
||||||
|
|
||||||
|
setCreateTopicReq("tp1", 1, "create topic if not exists tp1 as stable st1 where tag1 > 0", nullptr, "test", "st1");
|
||||||
|
run("CREATE TOPIC IF NOT EXISTS tp1 AS STABLE st1 WHERE tag1 > 0");
|
||||||
|
clearCreateTopicReq();
|
||||||
|
|
||||||
|
setCreateTopicReq("tp1", 1, "create topic if not exists tp1 with meta as stable st1 where tag1 > 0", nullptr, "test", "st1", 1);
|
||||||
|
run("CREATE TOPIC IF NOT EXISTS tp1 WITH META AS STABLE st1 WHERE tag1 > 0");
|
||||||
|
clearCreateTopicReq();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -454,6 +454,18 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType) {
|
||||||
|
int32_t nums = pMeta->tableInfo.numOfTags + pMeta->tableInfo.numOfColumns;
|
||||||
|
for (int32_t i = 0; i < nums; ++i) {
|
||||||
|
if (0 == strcmp(pName, pMeta->schema[i].name)) {
|
||||||
|
*pType = (i < pMeta->tableInfo.numOfColumns) ? TCOL_TYPE_COLUMN : TCOL_TYPE_TAG;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*pType = TCOL_TYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void freeVgInfo(SDBVgInfo* vgInfo) {
|
void freeVgInfo(SDBVgInfo* vgInfo) {
|
||||||
if (NULL == vgInfo) {
|
if (NULL == vgInfo) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -296,11 +296,8 @@ int32_t tAppendDataToInputQueue(SStreamTask* pTask, SStreamQueueItem* pItem) {
|
||||||
|
|
||||||
if (type == STREAM_INPUT__DATA_SUBMIT) {
|
if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
SStreamDataSubmit* px = (SStreamDataSubmit*)pItem;
|
SStreamDataSubmit* px = (SStreamDataSubmit*)pItem;
|
||||||
qDebug("s-task:%s submit enqueue msgLen:%d ver:%" PRId64 ", total in queue:%d, size:%.2fMiB", pTask->id.idStr,
|
|
||||||
px->submit.msgLen, px->submit.ver, total, size);
|
|
||||||
|
|
||||||
if ((pTask->taskLevel == TASK_LEVEL__SOURCE) && tInputQueueIsFull(pTask)) {
|
if ((pTask->taskLevel == TASK_LEVEL__SOURCE) && tInputQueueIsFull(pTask)) {
|
||||||
qError("s-task:%s input queue is full, capacity(size:%d num:%dMiB), current(blocks:%d, size:%.2fMiB) abort",
|
qError("s-task:%s input queue is full, capacity(size:%d num:%dMiB), current(blocks:%d, size:%.2fMiB) stop to push data",
|
||||||
pTask->id.idStr, STREAM_TASK_INPUT_QUEUEU_CAPACITY, STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE, total,
|
pTask->id.idStr, STREAM_TASK_INPUT_QUEUEU_CAPACITY, STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE, total,
|
||||||
size);
|
size);
|
||||||
streamDataSubmitDestroy(px);
|
streamDataSubmitDestroy(px);
|
||||||
|
@ -314,9 +311,12 @@ int32_t tAppendDataToInputQueue(SStreamTask* pTask, SStreamQueueItem* pItem) {
|
||||||
taosFreeQitem(pItem);
|
taosFreeQitem(pItem);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("s-task:%s submit enqueue msgLen:%d ver:%" PRId64 ", total in queue:%d, size:%.2fMiB", pTask->id.idStr,
|
||||||
|
px->submit.msgLen, px->submit.ver, total, size + px->submit.msgLen/1048576.0);
|
||||||
} else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE ||
|
} else if (type == STREAM_INPUT__DATA_BLOCK || type == STREAM_INPUT__DATA_RETRIEVE ||
|
||||||
type == STREAM_INPUT__REF_DATA_BLOCK) {
|
type == STREAM_INPUT__REF_DATA_BLOCK) {
|
||||||
if (/*(pTask->taskLevel == TASK_LEVEL__SOURCE) && */(tInputQueueIsFull(pTask))) {
|
if ((pTask->taskLevel == TASK_LEVEL__SOURCE) && (tInputQueueIsFull(pTask))) {
|
||||||
qError("s-task:%s input queue is full, capacity:%d size:%d MiB, current(blocks:%d, size:%.2fMiB) abort",
|
qError("s-task:%s input queue is full, capacity:%d size:%d MiB, current(blocks:%d, size:%.2fMiB) abort",
|
||||||
pTask->id.idStr, STREAM_TASK_INPUT_QUEUEU_CAPACITY, STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE, total,
|
pTask->id.idStr, STREAM_TASK_INPUT_QUEUEU_CAPACITY, STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE, total,
|
||||||
size);
|
size);
|
||||||
|
|
|
@ -87,8 +87,6 @@ void* streamBackendInit(const char* path) {
|
||||||
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
rocksdb_env_t* env = rocksdb_create_default_env(); // rocksdb_envoptions_create();
|
rocksdb_env_t* env = rocksdb_create_default_env(); // rocksdb_envoptions_create();
|
||||||
rocksdb_env_set_low_priority_background_threads(env, 4);
|
|
||||||
rocksdb_env_set_high_priority_background_threads(env, 2);
|
|
||||||
|
|
||||||
rocksdb_cache_t* cache = rocksdb_cache_create_lru(64 << 20);
|
rocksdb_cache_t* cache = rocksdb_cache_create_lru(64 << 20);
|
||||||
|
|
||||||
|
@ -128,7 +126,9 @@ void* streamBackendInit(const char* path) {
|
||||||
*/
|
*/
|
||||||
streamStateOpenBackendCf(pHandle, (char*)path, cfs, nCf);
|
streamStateOpenBackendCf(pHandle, (char*)path, cfs, nCf);
|
||||||
}
|
}
|
||||||
|
if (cfs != NULL) {
|
||||||
rocksdb_list_column_families_destroy(cfs, nCf);
|
rocksdb_list_column_families_destroy(cfs, nCf);
|
||||||
|
}
|
||||||
|
|
||||||
return (void*)pHandle;
|
return (void*)pHandle;
|
||||||
_EXIT:
|
_EXIT:
|
||||||
|
@ -572,9 +572,14 @@ int32_t decodeValueFunc(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
||||||
*dest = NULL;
|
*dest = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int64_t now = taosGetTimestampMs();
|
|
||||||
p = taosDecodeFixedI64(p, &key.unixTimestamp);
|
p = taosDecodeFixedI64(p, &key.unixTimestamp);
|
||||||
p = taosDecodeFixedI32(p, &key.len);
|
p = taosDecodeFixedI32(p, &key.len);
|
||||||
|
if (vlen != (sizeof(int64_t) + sizeof(int32_t) + key.len)) {
|
||||||
|
if (dest != NULL) *dest = NULL;
|
||||||
|
qError("vlen: %d, read len: %d", vlen, key.len);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (key.len == 0) {
|
if (key.len == 0) {
|
||||||
key.data = NULL;
|
key.data = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -582,6 +587,7 @@ int32_t decodeValueFunc(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttl != NULL) {
|
if (ttl != NULL) {
|
||||||
|
int64_t now = taosGetTimestampMs();
|
||||||
*ttl = key.unixTimestamp == 0 ? 0 : key.unixTimestamp - now;
|
*ttl = key.unixTimestamp == 0 ? 0 : key.unixTimestamp - now;
|
||||||
}
|
}
|
||||||
if (dest != NULL) {
|
if (dest != NULL) {
|
||||||
|
@ -719,7 +725,7 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
|
||||||
qDebug("succ to open rocksdb cf");
|
qDebug("succ to open rocksdb cf");
|
||||||
}
|
}
|
||||||
// close default cf
|
// close default cf
|
||||||
rocksdb_column_family_handle_destroy(cfHandle[0]);
|
if (((rocksdb_column_family_handle_t**)cfHandle)[0] != 0) rocksdb_column_family_handle_destroy(cfHandle[0]);
|
||||||
rocksdb_options_destroy(cfOpts[0]);
|
rocksdb_options_destroy(cfOpts[0]);
|
||||||
handle->db = db;
|
handle->db = db;
|
||||||
|
|
||||||
|
@ -1026,10 +1032,10 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
|
||||||
rocksdb_put_cf(db, opts, pHandle, (const char*)buf, klen, (const char*)ttlV, (size_t)ttlVLen, &err); \
|
rocksdb_put_cf(db, opts, pHandle, (const char*)buf, klen, (const char*)ttlV, (size_t)ttlVLen, &err); \
|
||||||
if (err != NULL) { \
|
if (err != NULL) { \
|
||||||
taosMemoryFree(err); \
|
taosMemoryFree(err); \
|
||||||
qDebug("streamState str: %s failed to write to %s, err: %s", toString, funcname, err); \
|
qError("streamState str: %s failed to write to %s, err: %s", toString, funcname, err); \
|
||||||
code = -1; \
|
code = -1; \
|
||||||
} else { \
|
} else { \
|
||||||
qDebug("streamState str:%s succ to write to %s, valLen:%d", toString, funcname, vLen); \
|
qTrace("streamState str:%s succ to write to %s, rowValLen:%d, ttlValLen:%d", toString, funcname, vLen, ttlVLen); \
|
||||||
} \
|
} \
|
||||||
taosMemoryFree(ttlV); \
|
taosMemoryFree(ttlV); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@ -1054,29 +1060,29 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
|
||||||
rocksdb_readoptions_t* opts = pState->pTdbState->readOpts; \
|
rocksdb_readoptions_t* opts = pState->pTdbState->readOpts; \
|
||||||
size_t len = 0; \
|
size_t len = 0; \
|
||||||
char* val = rocksdb_get_cf(db, opts, pHandle, (const char*)buf, klen, (size_t*)&len, &err); \
|
char* val = rocksdb_get_cf(db, opts, pHandle, (const char*)buf, klen, (size_t*)&len, &err); \
|
||||||
if (val == NULL) { \
|
if (val == NULL || len == 0) { \
|
||||||
if (err == NULL) { \
|
if (err == NULL) { \
|
||||||
qDebug("streamState str: %s failed to read from %s_%s, err: not exist", toString, pState->pTdbState->idstr, \
|
qTrace("streamState str: %s failed to read from %s_%s, err: not exist", toString, pState->pTdbState->idstr, \
|
||||||
funcname); \
|
funcname); \
|
||||||
} else { \
|
} else { \
|
||||||
qDebug("streamState str: %s failed to read from %s_%s, err: %s", toString, pState->pTdbState->idstr, funcname, \
|
qError("streamState str: %s failed to read from %s_%s, err: %s", toString, pState->pTdbState->idstr, funcname, \
|
||||||
err); \
|
err); \
|
||||||
taosMemoryFreeClear(err); \
|
taosMemoryFreeClear(err); \
|
||||||
} \
|
} \
|
||||||
code = -1; \
|
code = -1; \
|
||||||
} else { \
|
} else { \
|
||||||
char* p = NULL; \
|
char* p = NULL; \
|
||||||
int32_t len = ginitDict[i].deValueFunc(val, len, NULL, (char**)pVal); \
|
int32_t tlen = ginitDict[i].deValueFunc(val, len, NULL, (char**)pVal); \
|
||||||
if (len < 0) { \
|
if (tlen <= 0) { \
|
||||||
qDebug("streamState str: %s failed to read from %s_%s, err: already ttl ", toString, pState->pTdbState->idstr, \
|
qError("streamState str: %s failed to read from %s_%s, err: already ttl ", toString, pState->pTdbState->idstr, \
|
||||||
funcname); \
|
funcname); \
|
||||||
code = -1; \
|
code = -1; \
|
||||||
} else { \
|
} else { \
|
||||||
qDebug("streamState str: %s succ to read from %s_%s, valLen:%d", toString, pState->pTdbState->idstr, funcname, \
|
qTrace("streamState str: %s succ to read from %s_%s, valLen:%d", toString, pState->pTdbState->idstr, funcname, \
|
||||||
len); \
|
tlen); \
|
||||||
} \
|
} \
|
||||||
taosMemoryFree(val); \
|
taosMemoryFree(val); \
|
||||||
if (vLen != NULL) *vLen = len; \
|
if (vLen != NULL) *vLen = tlen; \
|
||||||
} \
|
} \
|
||||||
if (code == 0) \
|
if (code == 0) \
|
||||||
qDebug("streamState str: %s succ to read from %s_%s", toString, pState->pTdbState->idstr, funcname); \
|
qDebug("streamState str: %s succ to read from %s_%s", toString, pState->pTdbState->idstr, funcname); \
|
||||||
|
@ -1107,7 +1113,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
|
||||||
taosMemoryFree(err); \
|
taosMemoryFree(err); \
|
||||||
code = -1; \
|
code = -1; \
|
||||||
} else { \
|
} else { \
|
||||||
qDebug("streamState str: %s succ to del from %s_%s", toString, pState->pTdbState->idstr, funcname); \
|
qTrace("streamState str: %s succ to del from %s_%s", toString, pState->pTdbState->idstr, funcname); \
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
@ -1134,31 +1140,29 @@ int32_t streamStateDel_rocksdb(SStreamState* pState, const SWinKey* key) {
|
||||||
int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
||||||
qDebug("streamStateClear_rocksdb");
|
qDebug("streamStateClear_rocksdb");
|
||||||
|
|
||||||
SStateKey sKey = {.key = {.ts = 0, .groupId = 0}, .opNum = pState->number};
|
|
||||||
SStateKey eKey = {.key = {.ts = INT64_MAX, .groupId = UINT64_MAX}, .opNum = pState->number};
|
|
||||||
char sKeyStr[128] = {0};
|
char sKeyStr[128] = {0};
|
||||||
char eKeyStr[128] = {0};
|
char eKeyStr[128] = {0};
|
||||||
|
SStateKey sKey = {.key = {.ts = 0, .groupId = 0}, .opNum = pState->number};
|
||||||
|
SStateKey eKey = {.key = {.ts = INT64_MAX, .groupId = UINT64_MAX}, .opNum = pState->number};
|
||||||
|
|
||||||
int sLen = stateKeyEncode(&sKey, sKeyStr);
|
int sLen = stateKeyEncode(&sKey, sKeyStr);
|
||||||
int eLen = stateKeyEncode(&eKey, eKeyStr);
|
int eLen = stateKeyEncode(&eKey, eKeyStr);
|
||||||
|
|
||||||
char toStringStart[128] = {0};
|
|
||||||
char toStringEnd[128] = {0};
|
|
||||||
if (qDebugFlag & DEBUG_TRACE) {
|
|
||||||
stateKeyToString(&sKey, toStringStart);
|
|
||||||
stateKeyToString(&eKey, toStringEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* err = NULL;
|
|
||||||
if (pState->pTdbState->pHandle[1] != NULL) {
|
if (pState->pTdbState->pHandle[1] != NULL) {
|
||||||
|
char* err = NULL;
|
||||||
rocksdb_delete_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->writeOpts, pState->pTdbState->pHandle[1],
|
rocksdb_delete_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->writeOpts, pState->pTdbState->pHandle[1],
|
||||||
sKeyStr, sLen, eKeyStr, eLen, &err);
|
sKeyStr, sLen, eKeyStr, eLen, &err);
|
||||||
}
|
|
||||||
// rocksdb_compact_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->pHandle[0], sKeyStr, sLen, eKeyStr,
|
|
||||||
// eLen);
|
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
|
char toStringStart[128] = {0};
|
||||||
|
char toStringEnd[128] = {0};
|
||||||
|
stateKeyToString(&sKey, toStringStart);
|
||||||
|
stateKeyToString(&eKey, toStringEnd);
|
||||||
|
|
||||||
qWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
|
qWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
|
||||||
taosMemoryFree(err);
|
taosMemoryFree(err);
|
||||||
|
} else {
|
||||||
|
rocksdb_compact_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->pHandle[1], sKeyStr, sLen, eKeyStr, eLen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1924,17 +1928,17 @@ int32_t streamStateGetParName_rocksdb(SStreamState* pState, int64_t groupId, voi
|
||||||
|
|
||||||
int32_t streamDefaultPut_rocksdb(SStreamState* pState, const void* key, void* pVal, int32_t pVLen) {
|
int32_t streamDefaultPut_rocksdb(SStreamState* pState, const void* key, void* pVal, int32_t pVLen) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
STREAM_STATE_PUT_ROCKSDB(pState, "default", &key, pVal, pVLen);
|
STREAM_STATE_PUT_ROCKSDB(pState, "default", key, pVal, pVLen);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
int32_t streamDefaultGet_rocksdb(SStreamState* pState, const void* key, void** pVal, int32_t* pVLen) {
|
int32_t streamDefaultGet_rocksdb(SStreamState* pState, const void* key, void** pVal, int32_t* pVLen) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
STREAM_STATE_GET_ROCKSDB(pState, "default", &key, pVal, pVLen);
|
STREAM_STATE_GET_ROCKSDB(pState, "default", key, pVal, pVLen);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
int32_t streamDefaultDel_rocksdb(SStreamState* pState, const void* key) {
|
int32_t streamDefaultDel_rocksdb(SStreamState* pState, const void* key) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
STREAM_STATE_DEL_ROCKSDB(pState, "default", &key);
|
STREAM_STATE_DEL_ROCKSDB(pState, "default", key);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock)
|
||||||
tEncodeStreamRetrieveReq(&encoder, &req);
|
tEncodeStreamRetrieveReq(&encoder, &req);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = { .code = 0, .msgType = TDMT_STREAM_RETRIEVE, .pCont = buf, .contLen = sizeof(SMsgHead) + len };
|
SRpcMsg rpcMsg = {.code = 0, .msgType = TDMT_STREAM_RETRIEVE, .pCont = buf, .contLen = sizeof(SMsgHead) + len};
|
||||||
if (tmsgSendReq(&pEpInfo->epSet, &rpcMsg) < 0) {
|
if (tmsgSendReq(&pEpInfo->epSet, &rpcMsg) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
goto CLEAR;
|
goto CLEAR;
|
||||||
|
@ -283,7 +283,7 @@ int32_t streamDispatchOneRecoverFinishReq(SStreamTask* pTask, const SStreamRecov
|
||||||
msg.info.noResp = 1;
|
msg.info.noResp = 1;
|
||||||
|
|
||||||
tmsgSendReq(pEpSet, &msg);
|
tmsgSendReq(pEpSet, &msg);
|
||||||
qDebug("s-task:%s dispatch recover finish msg to taskId:%d node %d: recover finish msg", pTask->id.idStr,
|
qDebug("s-task:%s dispatch recover finish msg to downstream taskId:0x%x node %d: recover finish msg", pTask->id.idStr,
|
||||||
pReq->taskId, vgId);
|
pReq->taskId, vgId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -318,7 +318,7 @@ int32_t doSendDispatchMsg(SStreamTask* pTask, const SStreamDispatchReq* pReq, in
|
||||||
msg.pCont = buf;
|
msg.pCont = buf;
|
||||||
msg.msgType = pTask->dispatchMsgType;
|
msg.msgType = pTask->dispatchMsgType;
|
||||||
|
|
||||||
qDebug("dispatch from s-task:%s to taskId:0x%x vgId:%d data msg", pTask->id.idStr, pReq->taskId, vgId);
|
qDebug("s-task:%s dispatch msg to taskId:0x%x vgId:%d data msg", pTask->id.idStr, pReq->taskId, vgId);
|
||||||
tmsgSendReq(pEpSet, &msg);
|
tmsgSendReq(pEpSet, &msg);
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -414,7 +414,7 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
|
|
||||||
req.taskId = downstreamTaskId;
|
req.taskId = downstreamTaskId;
|
||||||
|
|
||||||
qDebug("s-task:%s (child taskId:%d) fix-dispatch blocks:%d to down stream s-task:%d in vgId:%d", pTask->id.idStr,
|
qDebug("s-task:%s (child taskId:%d) fix-dispatch %d block(s) to down stream s-task:0x%x in vgId:%d", pTask->id.idStr,
|
||||||
pTask->selfChildId, numOfBlocks, downstreamTaskId, vgId);
|
pTask->selfChildId, numOfBlocks, downstreamTaskId, vgId);
|
||||||
|
|
||||||
code = doSendDispatchMsg(pTask, &req, vgId, pEpSet);
|
code = doSendDispatchMsg(pTask, &req, vgId, pEpSet);
|
||||||
|
@ -514,7 +514,7 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("s-task:%s start to dispatch msg, output status:%d", pTask->id.idStr, pTask->outputStatus);
|
qDebug("s-task:%s start to dispatch msg, set output status:%d", pTask->id.idStr, pTask->outputStatus);
|
||||||
|
|
||||||
SStreamDataBlock* pDispatchedBlock = streamQueueNextItem(pTask->outputQueue);
|
SStreamDataBlock* pDispatchedBlock = streamQueueNextItem(pTask->outputQueue);
|
||||||
if (pDispatchedBlock == NULL) {
|
if (pDispatchedBlock == NULL) {
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
// maximum allowed processed block batches. One block may include several submit blocks
|
// maximum allowed processed block batches. One block may include several submit blocks
|
||||||
#define MAX_STREAM_EXEC_BATCH_NUM 32
|
#define MAX_STREAM_EXEC_BATCH_NUM 32
|
||||||
#define MIN_STREAM_EXEC_BATCH_NUM 8
|
#define MIN_STREAM_EXEC_BATCH_NUM 4
|
||||||
#define MAX_STREAM_RESULT_DUMP_THRESHOLD 100
|
#define MAX_STREAM_RESULT_DUMP_THRESHOLD 100
|
||||||
|
|
||||||
static int32_t updateCheckPointInfo (SStreamTask* pTask);
|
static int32_t updateCheckPointInfo(SStreamTask* pTask);
|
||||||
|
|
||||||
bool streamTaskShouldStop(const SStreamStatus* pStatus) {
|
bool streamTaskShouldStop(const SStreamStatus* pStatus) {
|
||||||
int32_t status = atomic_load_8((int8_t*)&pStatus->taskStatus);
|
int32_t status = atomic_load_8((int8_t*)&pStatus->taskStatus);
|
||||||
|
@ -44,11 +44,13 @@ static int32_t doDumpResult(SStreamTask* pTask, SStreamQueueItem* pItem, SArray*
|
||||||
if (numOfBlocks > 0) {
|
if (numOfBlocks > 0) {
|
||||||
SStreamDataBlock* pStreamBlocks = createStreamBlockFromResults(pItem, pTask, size, pRes);
|
SStreamDataBlock* pStreamBlocks = createStreamBlockFromResults(pItem, pTask, size, pRes);
|
||||||
if (pStreamBlocks == NULL) {
|
if (pStreamBlocks == NULL) {
|
||||||
|
qError("s-task:%s failed to create result stream data block, code:%s", pTask->id.idStr, tstrerror(terrno));
|
||||||
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("s-task:%s dump stream result data blocks, num:%d, size:%.2fMiB", pTask->id.idStr, numOfBlocks, size/1048576.0);
|
qDebug("s-task:%s dump stream result data blocks, num:%d, size:%.2fMiB", pTask->id.idStr, numOfBlocks,
|
||||||
|
size / 1048576.0);
|
||||||
|
|
||||||
code = streamTaskOutputResultBlock(pTask, pStreamBlocks);
|
code = streamTaskOutputResultBlock(pTask, pStreamBlocks);
|
||||||
if (code == TSDB_CODE_UTIL_QUEUE_OUT_OF_MEMORY) { // back pressure and record position
|
if (code == TSDB_CODE_UTIL_QUEUE_OUT_OF_MEMORY) { // back pressure and record position
|
||||||
|
@ -65,7 +67,8 @@ static int32_t doDumpResult(SStreamTask* pTask, SStreamQueueItem* pItem, SArray*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, int64_t* totalSize, int32_t* totalBlocks) {
|
static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, int64_t* totalSize,
|
||||||
|
int32_t* totalBlocks) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
void* pExecutor = pTask->exec.pExecutor;
|
void* pExecutor = pTask->exec.pExecutor;
|
||||||
|
|
||||||
|
@ -82,7 +85,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamTaskShouldStop(&pTask->status)) {
|
if (streamTaskShouldStop(&pTask->status)) {
|
||||||
taosArrayDestroy(pRes); // memory leak
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +103,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
if (pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
if (pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
|
const SStreamDataBlock* pRetrieveBlock = (const SStreamDataBlock*)pItem;
|
||||||
const SStreamDataBlock* pRetrieveBlock = (const SStreamDataBlock*) pItem;
|
|
||||||
ASSERT(taosArrayGetSize(pRetrieveBlock->blocks) == 1);
|
ASSERT(taosArrayGetSize(pRetrieveBlock->blocks) == 1);
|
||||||
|
|
||||||
assignOneDataBlock(&block, taosArrayGet(pRetrieveBlock->blocks, 0));
|
assignOneDataBlock(&block, taosArrayGet(pRetrieveBlock->blocks, 0));
|
||||||
|
@ -132,7 +134,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i
|
||||||
|
|
||||||
taosArrayPush(pRes, &block);
|
taosArrayPush(pRes, &block);
|
||||||
|
|
||||||
qDebug("s-task:%s (child %d) executed and get block, total blocks:%d, size:%.2fMiB", pTask->id.idStr,
|
qDebug("s-task:%s (child %d) executed and get %d result blocks, size:%.2fMiB", pTask->id.idStr,
|
||||||
pTask->selfChildId, numOfBlocks, size / 1048576.0);
|
pTask->selfChildId, numOfBlocks, size / 1048576.0);
|
||||||
|
|
||||||
// current output should be dispatched to down stream nodes
|
// current output should be dispatched to down stream nodes
|
||||||
|
@ -153,7 +155,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i
|
||||||
ASSERT(numOfBlocks == taosArrayGetSize(pRes));
|
ASSERT(numOfBlocks == taosArrayGetSize(pRes));
|
||||||
code = doDumpResult(pTask, pItem, pRes, size, totalSize, totalBlocks);
|
code = doDumpResult(pTask, pItem, pRes, size, totalSize, totalBlocks);
|
||||||
} else {
|
} else {
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroyEx(pRes, (FDelete)blockDataFreeRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -235,11 +237,11 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) {
|
||||||
taosFreeQitem(qRes);
|
taosFreeQitem(qRes);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
// if (pTask->outputType == TASK_OUTPUT__FIXED_DISPATCH || pTask->outputType == TASK_OUTPUT__SHUFFLE_DISPATCH) {
|
||||||
qDebug("s-task:%s scan exec dispatch blocks:%d", pTask->id.idStr, batchCnt);
|
// qDebug("s-task:%s scan exec dispatch blocks:%d", pTask->id.idStr, batchCnt);
|
||||||
streamDispatchStreamBlock(pTask);
|
// streamDispatchStreamBlock(pTask);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (finished) {
|
if (finished) {
|
||||||
break;
|
break;
|
||||||
|
@ -286,7 +288,7 @@ int32_t streamBatchExec(SStreamTask* pTask, int32_t batchLimit) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t updateCheckPointInfo (SStreamTask* pTask) {
|
int32_t updateCheckPointInfo(SStreamTask* pTask) {
|
||||||
int64_t ckId = 0;
|
int64_t ckId = 0;
|
||||||
int64_t dataVer = 0;
|
int64_t dataVer = 0;
|
||||||
qGetCheckpointVersion(pTask->exec.pExecutor, &dataVer, &ckId);
|
qGetCheckpointVersion(pTask->exec.pExecutor, &dataVer, &ckId);
|
||||||
|
@ -294,7 +296,8 @@ int32_t updateCheckPointInfo (SStreamTask* pTask) {
|
||||||
SCheckpointInfo* pCkInfo = &pTask->chkInfo;
|
SCheckpointInfo* pCkInfo = &pTask->chkInfo;
|
||||||
if (ckId > pCkInfo->id) { // save it since the checkpoint is updated
|
if (ckId > pCkInfo->id) { // save it since the checkpoint is updated
|
||||||
qDebug("s-task:%s exec end, start to update check point, ver from %" PRId64 " to %" PRId64
|
qDebug("s-task:%s exec end, start to update check point, ver from %" PRId64 " to %" PRId64
|
||||||
", checkPoint id:%" PRId64 " -> %" PRId64, pTask->id.idStr, pCkInfo->version, dataVer, pCkInfo->id, ckId);
|
", checkPoint id:%" PRId64 " -> %" PRId64,
|
||||||
|
pTask->id.idStr, pCkInfo->version, dataVer, pCkInfo->id, ckId);
|
||||||
|
|
||||||
pTask->chkInfo = (SCheckpointInfo){.version = dataVer, .id = ckId, .currentVer = pCkInfo->currentVer};
|
pTask->chkInfo = (SCheckpointInfo){.version = dataVer, .id = ckId, .currentVer = pCkInfo->currentVer};
|
||||||
|
|
||||||
|
@ -314,8 +317,13 @@ int32_t updateCheckPointInfo (SStreamTask* pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* todo: the batch of blocks should be tuned dynamic, according to the total elapsed time of each batch of blocks, the
|
||||||
|
* appropriate batch of blocks should be handled in 5 to 10 sec.
|
||||||
|
*/
|
||||||
int32_t streamExecForAll(SStreamTask* pTask) {
|
int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
int32_t code = 0;
|
const char* id = pTask->id.idStr;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t batchSize = 1;
|
int32_t batchSize = 1;
|
||||||
int16_t times = 0;
|
int16_t times = 0;
|
||||||
|
@ -323,7 +331,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
SStreamQueueItem* pInput = NULL;
|
SStreamQueueItem* pInput = NULL;
|
||||||
|
|
||||||
// merge multiple input data if possible in the input queue.
|
// merge multiple input data if possible in the input queue.
|
||||||
qDebug("s-task:%s start to extract data block from inputQ", pTask->id.idStr);
|
qDebug("s-task:%s start to extract data block from inputQ", id);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (streamTaskShouldPause(&pTask->status)) {
|
if (streamTaskShouldPause(&pTask->status)) {
|
||||||
|
@ -338,7 +346,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
if (qItem == NULL) {
|
if (qItem == NULL) {
|
||||||
if (pTask->taskLevel == TASK_LEVEL__SOURCE && batchSize < MIN_STREAM_EXEC_BATCH_NUM && times < 5) {
|
if (pTask->taskLevel == TASK_LEVEL__SOURCE && batchSize < MIN_STREAM_EXEC_BATCH_NUM && times < 5) {
|
||||||
times++;
|
times++;
|
||||||
taosMsleep(1);
|
taosMsleep(10);
|
||||||
qDebug("===stream===try again batchSize:%d", batchSize);
|
qDebug("===stream===try again batchSize:%d", batchSize);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -363,8 +371,10 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
batchSize++;
|
batchSize++;
|
||||||
pInput = newRet;
|
pInput = newRet;
|
||||||
streamQueueProcessSuccess(pTask->inputQueue);
|
streamQueueProcessSuccess(pTask->inputQueue);
|
||||||
|
|
||||||
if (batchSize > MAX_STREAM_EXEC_BATCH_NUM) {
|
if (batchSize > MAX_STREAM_EXEC_BATCH_NUM) {
|
||||||
qDebug("maximum batch limit:%d reached, processing, %s", MAX_STREAM_EXEC_BATCH_NUM, pTask->id.idStr);
|
qDebug("s-task:%s batch size limit:%d reached, start to process blocks", id,
|
||||||
|
MAX_STREAM_EXEC_BATCH_NUM);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,7 +385,6 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
if (pInput) {
|
if (pInput) {
|
||||||
streamFreeQitem(pInput);
|
streamFreeQitem(pInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +394,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
|
|
||||||
if (pTask->taskLevel == TASK_LEVEL__SINK) {
|
if (pTask->taskLevel == TASK_LEVEL__SINK) {
|
||||||
ASSERT(pInput->type == STREAM_INPUT__DATA_BLOCK);
|
ASSERT(pInput->type == STREAM_INPUT__DATA_BLOCK);
|
||||||
qDebug("s-task:%s sink task start to sink %d blocks", pTask->id.idStr, batchSize);
|
qDebug("s-task:%s sink task start to sink %d blocks", id, batchSize);
|
||||||
streamTaskOutputResultBlock(pTask, (SStreamDataBlock*)pInput);
|
streamTaskOutputResultBlock(pTask, (SStreamDataBlock*)pInput);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -394,16 +403,16 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
while (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
while (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
int8_t status = atomic_load_8(&pTask->status.taskStatus);
|
int8_t status = atomic_load_8(&pTask->status.taskStatus);
|
||||||
if (status != TASK_STATUS__NORMAL && status != TASK_STATUS__PAUSE) {
|
if (status != TASK_STATUS__NORMAL && status != TASK_STATUS__PAUSE) {
|
||||||
qError("stream task wait for the end of fill history, s-task:%s, status:%d", pTask->id.idStr,
|
qError("stream task wait for the end of fill history, s-task:%s, status:%d", id,
|
||||||
atomic_load_8(&pTask->status.taskStatus));
|
atomic_load_8(&pTask->status.taskStatus));
|
||||||
taosMsleep(2);
|
taosMsleep(100);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
qDebug("s-task:%s start to execute, block batches:%d", pTask->id.idStr, batchSize);
|
qDebug("s-task:%s start to process batch of blocks, num:%d", id, batchSize);
|
||||||
|
|
||||||
{
|
{
|
||||||
// set input
|
// set input
|
||||||
|
@ -417,21 +426,21 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
ASSERT(pTask->taskLevel == TASK_LEVEL__SOURCE);
|
ASSERT(pTask->taskLevel == TASK_LEVEL__SOURCE);
|
||||||
const SStreamDataSubmit* pSubmit = (const SStreamDataSubmit*)pInput;
|
const SStreamDataSubmit* pSubmit = (const SStreamDataSubmit*)pInput;
|
||||||
qSetMultiStreamInput(pExecutor, &pSubmit->submit, 1, STREAM_INPUT__DATA_SUBMIT);
|
qSetMultiStreamInput(pExecutor, &pSubmit->submit, 1, STREAM_INPUT__DATA_SUBMIT);
|
||||||
qDebug("s-task:%s set submit blocks as source block completed, %p %p len:%d ver:%" PRId64, pTask->id.idStr, pSubmit,
|
qDebug("s-task:%s set submit blocks as source block completed, %p %p len:%d ver:%" PRId64, id, pSubmit,
|
||||||
pSubmit->submit.msgStr, pSubmit->submit.msgLen, pSubmit->submit.ver);
|
pSubmit->submit.msgStr, pSubmit->submit.msgLen, pSubmit->submit.ver);
|
||||||
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||||
const SStreamDataBlock* pBlock = (const SStreamDataBlock*)pInput;
|
const SStreamDataBlock* pBlock = (const SStreamDataBlock*)pInput;
|
||||||
|
|
||||||
SArray* pBlockList = pBlock->blocks;
|
SArray* pBlockList = pBlock->blocks;
|
||||||
int32_t numOfBlocks = taosArrayGetSize(pBlockList);
|
int32_t numOfBlocks = taosArrayGetSize(pBlockList);
|
||||||
qDebug("s-task:%s set sdata blocks as input num:%d, ver:%" PRId64, pTask->id.idStr, numOfBlocks, pBlock->sourceVer);
|
qDebug("s-task:%s set sdata blocks as input num:%d, ver:%" PRId64, id, numOfBlocks, pBlock->sourceVer);
|
||||||
qSetMultiStreamInput(pExecutor, pBlockList->pData, numOfBlocks, STREAM_INPUT__DATA_BLOCK);
|
qSetMultiStreamInput(pExecutor, pBlockList->pData, numOfBlocks, STREAM_INPUT__DATA_BLOCK);
|
||||||
} else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) {
|
} else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
const SStreamMergedSubmit* pMerged = (const SStreamMergedSubmit*)pInput;
|
const SStreamMergedSubmit* pMerged = (const SStreamMergedSubmit*)pInput;
|
||||||
|
|
||||||
SArray* pBlockList = pMerged->submits;
|
SArray* pBlockList = pMerged->submits;
|
||||||
int32_t numOfBlocks = taosArrayGetSize(pBlockList);
|
int32_t numOfBlocks = taosArrayGetSize(pBlockList);
|
||||||
qDebug("s-task:%s %p set submit input (merged), batch num:%d", pTask->id.idStr, pTask, numOfBlocks);
|
qDebug("s-task:%s %p set (merged) submit blocks as a batch, numOfBlocks:%d", id, pTask, numOfBlocks);
|
||||||
qSetMultiStreamInput(pExecutor, pBlockList->pData, numOfBlocks, STREAM_INPUT__MERGED_SUBMIT);
|
qSetMultiStreamInput(pExecutor, pBlockList->pData, numOfBlocks, STREAM_INPUT__MERGED_SUBMIT);
|
||||||
} else if (pItem->type == STREAM_INPUT__REF_DATA_BLOCK) {
|
} else if (pItem->type == STREAM_INPUT__REF_DATA_BLOCK) {
|
||||||
const SStreamRefDataBlock* pRefBlock = (const SStreamRefDataBlock*)pInput;
|
const SStreamRefDataBlock* pRefBlock = (const SStreamRefDataBlock*)pInput;
|
||||||
|
@ -446,7 +455,8 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
||||||
streamTaskExecImpl(pTask, pInput, &resSize, &totalBlocks);
|
streamTaskExecImpl(pTask, pInput, &resSize, &totalBlocks);
|
||||||
|
|
||||||
double el = (taosGetTimestampMs() - st) / 1000.0;
|
double el = (taosGetTimestampMs() - st) / 1000.0;
|
||||||
qDebug("s-task:%s exec end, elapsed time:%.2fs, result size:%.2fMiB, numOfBlocks:%d", pTask->id.idStr, el, resSize / 1048576.0, totalBlocks);
|
qDebug("s-task:%s batch of input blocks exec end, elapsed time:%.2fs, result size:%.2fMiB, numOfBlocks:%d",
|
||||||
|
id, el, resSize / 1048576.0, totalBlocks);
|
||||||
streamFreeQitem(pInput);
|
streamFreeQitem(pInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,8 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||||
|
|
||||||
// add to the ready tasks hash map, not the restored tasks hash map
|
// add to the ready tasks hash map, not the restored tasks hash map
|
||||||
int32_t streamMetaAddDeployedTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask) {
|
int32_t streamMetaAddDeployedTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask) {
|
||||||
|
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
||||||
|
if (p == NULL) {
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
||||||
tFreeStreamTask(pTask);
|
tFreeStreamTask(pTask);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -219,10 +221,9 @@ int32_t streamMetaAddDeployedTask(SStreamMeta* pMeta, int64_t ver, SStreamTask*
|
||||||
tFreeStreamTask(pTask);
|
tFreeStreamTask(pTask);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
|
||||||
if (p == NULL) {
|
|
||||||
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, POINTER_BYTES);
|
taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, POINTER_BYTES);
|
||||||
|
@ -359,22 +360,29 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
||||||
tDecodeStreamTask(&decoder, pTask);
|
tDecodeStreamTask(&decoder, pTask);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
|
// remove duplicate
|
||||||
|
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
||||||
|
if (p == NULL) {
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, pTask->chkInfo.version) < 0) {
|
if (pMeta->expandFunc(pMeta->ahandle, pTask, pTask->chkInfo.version) < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
taosMemoryFree(pTask);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
|
||||||
if (p == NULL) {
|
|
||||||
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
||||||
|
} else {
|
||||||
|
tdbFree(pKey);
|
||||||
|
tdbFree(pVal);
|
||||||
|
tdbTbcClose(pCur);
|
||||||
|
taosMemoryFree(pTask);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, sizeof(void*)) < 0) {
|
if (taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, sizeof(void*)) < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
taosMemoryFree(pTask);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define DEFAULT_FALSE_POSITIVE 0.01
|
#define DEFAULT_FALSE_POSITIVE 0.01
|
||||||
#define DEFAULT_BUCKET_SIZE 1310720
|
#define DEFAULT_BUCKET_SIZE 131072
|
||||||
#define DEFAULT_MAP_CAPACITY 1310720
|
#define DEFAULT_MAP_CAPACITY 131072
|
||||||
#define DEFAULT_MAP_SIZE (DEFAULT_MAP_CAPACITY * 10)
|
#define DEFAULT_MAP_SIZE (DEFAULT_MAP_CAPACITY * 100)
|
||||||
#define ROWS_PER_MILLISECOND 1
|
#define ROWS_PER_MILLISECOND 1
|
||||||
#define MAX_NUM_SCALABLE_BF 100000
|
#define MAX_NUM_SCALABLE_BF 100000
|
||||||
#define MIN_NUM_SCALABLE_BF 10
|
#define MIN_NUM_SCALABLE_BF 10
|
||||||
|
@ -44,8 +44,8 @@ static void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearItemHelper(void* p) {
|
static void clearItemHelper(void *p) {
|
||||||
SScalableBf** pBf = p;
|
SScalableBf **pBf = p;
|
||||||
tScalableBfDestroy(*pBf);
|
tScalableBfDestroy(*pBf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *pInfo) {
|
int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *pInfo) {
|
||||||
if(!pInfo) {
|
if (!pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#include "tstreamFileState.h"
|
#include "tstreamFileState.h"
|
||||||
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "storageapi.h"
|
||||||
#include "streamBackendRocksdb.h"
|
#include "streamBackendRocksdb.h"
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
#include "storageapi.h"
|
|
||||||
|
|
||||||
#define FLUSH_RATIO 0.5
|
#define FLUSH_RATIO 0.5
|
||||||
#define FLUSH_NUM 4
|
#define FLUSH_NUM 4
|
||||||
|
@ -137,7 +137,7 @@ void clearExpiredRowBuff(SStreamFileState* pFileState, TSKEY ts, bool all) {
|
||||||
SListNode* pNode = NULL;
|
SListNode* pNode = NULL;
|
||||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||||
SRowBuffPos* pPos = *(SRowBuffPos**)(pNode->data);
|
SRowBuffPos* pPos = *(SRowBuffPos**)(pNode->data);
|
||||||
if (all || (pFileState->getTs(pPos->pKey) < ts)) {
|
if (all || (pFileState->getTs(pPos->pKey) < ts && !pPos->beUsed)) {
|
||||||
ASSERT(pPos->pRowBuff != NULL);
|
ASSERT(pPos->pRowBuff != NULL);
|
||||||
tdListAppend(pFileState->freeBuffs, &(pPos->pRowBuff));
|
tdListAppend(pFileState->freeBuffs, &(pPos->pRowBuff));
|
||||||
pPos->pRowBuff = NULL;
|
pPos->pRowBuff = NULL;
|
||||||
|
@ -416,10 +416,13 @@ int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
memcpy(buf, taskKey, strlen(taskKey));
|
memcpy(buf, taskKey, strlen(taskKey));
|
||||||
code = streamDefaultGet_rocksdb(pFileState->pFileStore, buf, &val, &len);
|
code = streamDefaultGet_rocksdb(pFileState->pFileStore, buf, &val, &len);
|
||||||
if (code != 0) {
|
if (code != 0 || len == 0 || val == NULL) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
sscanf(val, "%" PRId64 "", &maxCheckPointId);
|
memcpy(val, buf, len);
|
||||||
|
buf[len] = 0;
|
||||||
|
maxCheckPointId = atol((char*)buf);
|
||||||
|
taosMemoryFree(val);
|
||||||
}
|
}
|
||||||
for (int64_t i = maxCheckPointId; i > 0; i--) {
|
for (int64_t i = maxCheckPointId; i > 0; i--) {
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
|
@ -430,13 +433,16 @@ int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
memcpy(val, buf, len);
|
||||||
|
buf[len] = 0;
|
||||||
|
taosMemoryFree(val);
|
||||||
|
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
sscanf(val, "%" PRId64 "", &ts);
|
ts = atol((char*)buf);
|
||||||
if (ts < mark) {
|
if (ts < mark) {
|
||||||
// statekey winkey.ts < mark
|
// statekey winkey.ts < mark
|
||||||
forceRemoveCheckpoint(pFileState, i);
|
forceRemoveCheckpoint(pFileState, i);
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -333,7 +333,7 @@ static int32_t walFetchBodyNew(SWalReader *pReader) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wDebug("vgId:%d, index:%" PRId64 " is fetched, cursor advance", pReader->pWal->cfg.vgId, ver);
|
wDebug("vgId:%d, index:%" PRId64 " is fetched, type:%d, cursor advance", pReader->pWal->cfg.vgId, ver, pReader->pHead->head.msgType);
|
||||||
pReader->curVersion = ver + 1;
|
pReader->curVersion = ver + 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,6 +497,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/db.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/db.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqError.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqError.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/schema.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/schema.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilterWhere.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilter.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilter.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
||||||
|
@ -563,7 +564,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_privilege.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_privilege.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
|
||||||
#,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py
|
||||||
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
|
,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py
|
||||||
|
|
|
@ -108,4 +108,15 @@ if $rows != 6 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql create topic topic_stable_1 as stable stb where t1 > 0
|
||||||
|
sql create topic topic_stable_2 as stable stb where t1 > 0 and t1 < 0
|
||||||
|
sql create topic topic_stable_3 as stable stb where 1 > 0
|
||||||
|
sql create topic topic_stable_4 as stable stb where abs(t1) > 0
|
||||||
|
sql_error create topic topic_stable_5 as stable stb where last(t1) > 0
|
||||||
|
sql_error create topic topic_stable_5 as stable stb where sum(t1) > 0
|
||||||
|
sql create topic topic_stable_6 as stable stb where tbname is not null
|
||||||
|
sql create topic topic_stable_7 as stable stb where tbname > 'a'
|
||||||
|
sql_error create topic topic_stable_8 as stable stb where tbname > 0 and xx < 0
|
||||||
|
sql_error create topic topic_stable_9 as stable stb where tbname > 0 and c1 < 0
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"confirm_parameter_prompt": "no",
|
"confirm_parameter_prompt": "no",
|
||||||
"insert_interval": 0,
|
"insert_interval": 0,
|
||||||
"interlace_rows": 0,
|
"interlace_rows": 0,
|
||||||
"num_of_records_per_req": 100000,
|
"num_of_records_per_req": 10000,
|
||||||
"databases": [
|
"databases": [
|
||||||
{
|
{
|
||||||
"dbinfo": {
|
"dbinfo": {
|
||||||
|
|
|
@ -0,0 +1,227 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.common import *
|
||||||
|
sys.path.append("./7-tmq")
|
||||||
|
from tmqCommon import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def prepareTestEnv(self):
|
||||||
|
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 4,
|
||||||
|
'replica': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 10000,
|
||||||
|
'batchNum': 100,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 2,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1}
|
||||||
|
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
tmqCom.create_database(tsql=tdSql, dbName=paraDict["dbName"],dropFlag=paraDict["dropFlag"], vgroups=paraDict['vgroups'],replica=paraDict['replica'])
|
||||||
|
tdSql.execute("alter database %s wal_retention_period 3600"%(paraDict["dbName"]))
|
||||||
|
tdLog.info("create stb")
|
||||||
|
tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"])
|
||||||
|
tdLog.info("create ctb")
|
||||||
|
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum'])
|
||||||
|
tdLog.info("insert data")
|
||||||
|
tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
|
||||||
|
ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
|
||||||
|
startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
|
||||||
|
return
|
||||||
|
|
||||||
|
def tmqCase_columnError(self, topicName, condition):
|
||||||
|
tdLog.printNoPrefix("======== test case error: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 4,
|
||||||
|
'replica': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 10000,
|
||||||
|
'batchNum': 100,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 2,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1}
|
||||||
|
|
||||||
|
tdLog.info("create topics from stb with column filter")
|
||||||
|
topicString = "create topic %s as stable %s.%s where %s" %(topicName, paraDict['dbName'], paraDict['stbName'], condition)
|
||||||
|
tdLog.info("create topic sql: %s"%topicString)
|
||||||
|
tdSql.error(topicString)
|
||||||
|
|
||||||
|
def tmqCase(self, topicName, condition):
|
||||||
|
tdLog.printNoPrefix("======== test case: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 4,
|
||||||
|
'replica': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 10000,
|
||||||
|
'batchNum': 100,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 2,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1}
|
||||||
|
|
||||||
|
expectRowsList = []
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
|
||||||
|
tdLog.info("create topics from stb with tag filter")
|
||||||
|
topicString = "create topic %s as stable %s.%s where %s" %(topicName, paraDict['dbName'], paraDict['stbName'], condition)
|
||||||
|
tdLog.info("create topic sql: %s"%topicString)
|
||||||
|
tdSql.execute(topicString)
|
||||||
|
|
||||||
|
queryString = "select * from %s.%s where %s" %(paraDict['dbName'], paraDict['stbName'], condition)
|
||||||
|
tdSql.query(queryString)
|
||||||
|
expectRowsList.append(tdSql.getRows())
|
||||||
|
|
||||||
|
# init consume info, and start tmq_sim, then check consume result
|
||||||
|
tdLog.info("insert consume info to consume processor")
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
|
||||||
|
topicList = topicName
|
||||||
|
ifcheckdata = 0
|
||||||
|
ifManualCommit = 1
|
||||||
|
keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'
|
||||||
|
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'])
|
||||||
|
|
||||||
|
tdLog.info("wait the consume result")
|
||||||
|
expectRows = 1
|
||||||
|
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
|
if expectRowsList[0] != resultList[0]:
|
||||||
|
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
|
||||||
|
tdLog.exit("0 tmq consume rows error!")
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case end ...... ")
|
||||||
|
|
||||||
|
def tmqCase_addNewTable_dropTag(self, topicName, condition):
|
||||||
|
tdLog.printNoPrefix("======== test case1: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 4,
|
||||||
|
'replica': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 10000,
|
||||||
|
'batchNum': 100,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 2,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1}
|
||||||
|
|
||||||
|
expectRowsList = []
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
|
||||||
|
tdLog.info("create topics from stb with tag filter")
|
||||||
|
topicString = "create topic %s as stable %s.%s where %s" %(topicName, paraDict['dbName'], paraDict['stbName'], condition)
|
||||||
|
tdLog.info("create topic sql: %s"%topicString)
|
||||||
|
tdSql.execute(topicString)
|
||||||
|
|
||||||
|
queryString = "select * from %s.%s where %s" %(paraDict['dbName'], paraDict['stbName'], condition)
|
||||||
|
tdSql.query(queryString)
|
||||||
|
expectRowsList.append(tdSql.getRows() + 1)
|
||||||
|
|
||||||
|
# init consume info, and start tmq_sim, then check consume result
|
||||||
|
tdLog.info("insert consume info to consume processor")
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
|
||||||
|
topicList = topicName
|
||||||
|
ifcheckdata = 0
|
||||||
|
ifManualCommit = 1
|
||||||
|
keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'
|
||||||
|
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow'])
|
||||||
|
|
||||||
|
#add new table with one data
|
||||||
|
tdLog.info("start insert data")
|
||||||
|
insertString = "insert into %s.tmp using %s.%s tags(1, 1, 1, 't4', 't5') values(now, 1, 1, 1, 'c4', 'c5', now)" %(paraDict['dbName'], paraDict['dbName'], paraDict['stbName'])
|
||||||
|
tdSql.execute(insertString)
|
||||||
|
|
||||||
|
#test drop tag
|
||||||
|
tdSql.error("alter stable %s.%s drop tag t1" %(paraDict['dbName'], paraDict['stbName']))
|
||||||
|
tdSql.execute("alter stable %s.%s drop tag t2" %(paraDict['dbName'], paraDict['stbName']))
|
||||||
|
tdSql.execute("alter stable %s.%s drop column c2" %(paraDict['dbName'], paraDict['stbName']))
|
||||||
|
|
||||||
|
tdLog.info("wait the consume result")
|
||||||
|
expectRows = 1
|
||||||
|
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
|
if expectRowsList[0] != resultList[0]:
|
||||||
|
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0]))
|
||||||
|
tdLog.exit("0 tmq consume rows error!")
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case1 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
self.prepareTestEnv()
|
||||||
|
self.tmqCase_columnError("t1", "c1 = 4 and t1 = 3")
|
||||||
|
self.tmqCase("t2", "2 > 1")
|
||||||
|
self.tmqCase("t3", "t4 = 'beijing'")
|
||||||
|
self.tmqCase("t4", "t4 > t3")
|
||||||
|
self.tmqCase("t5", "t3 = t4")
|
||||||
|
self.tmqCase_addNewTable_dropTag("t6", "t1 = 1")
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
Loading…
Reference in New Issue