Merge branch '3.0' of https://github.com/taosdata/TDengine into enh/TD-30987-11
This commit is contained in:
commit
a4689e792c
|
@ -272,11 +272,11 @@ int32_t taosCfgDynamicOptions(SConfig *pCfg, const char *name, bool forServer);
|
||||||
|
|
||||||
struct SConfig *taosGetCfg();
|
struct SConfig *taosGetCfg();
|
||||||
|
|
||||||
void taosSetGlobalDebugFlag(int32_t flag);
|
int32_t taosSetGlobalDebugFlag(int32_t flag);
|
||||||
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
int32_t taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||||
int8_t taosGranted(int8_t type);
|
int8_t taosGranted(int8_t type);
|
||||||
int32_t taosSetSlowLogScope(char *pScope);
|
int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -3636,7 +3636,7 @@ static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ve
|
||||||
|
|
||||||
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
|
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
|
||||||
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
||||||
int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
||||||
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||||
int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||||
void tOffsetDestroy(void* pVal);
|
void tOffsetDestroy(void* pVal);
|
||||||
|
|
|
@ -211,7 +211,7 @@ const char* qExtractTbnameFromTask(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
void* qExtractReaderFromStreamScanner(void* scanner);
|
void* qExtractReaderFromStreamScanner(void* scanner);
|
||||||
|
|
||||||
int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner);
|
void qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner);
|
||||||
|
|
||||||
int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo);
|
int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo);
|
||||||
int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow);
|
int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow);
|
||||||
|
|
|
@ -218,10 +218,10 @@ typedef struct SStoreTqReader {
|
||||||
int32_t (*tqGetStreamExecProgress)();
|
int32_t (*tqGetStreamExecProgress)();
|
||||||
|
|
||||||
void (*tqReaderSetColIdList)();
|
void (*tqReaderSetColIdList)();
|
||||||
int32_t (*tqReaderSetQueryTableList)();
|
void (*tqReaderSetQueryTableList)();
|
||||||
|
|
||||||
int32_t (*tqReaderAddTables)();
|
void (*tqReaderAddTables)();
|
||||||
int32_t (*tqReaderRemoveTables)();
|
void (*tqReaderRemoveTables)();
|
||||||
|
|
||||||
void (*tqSetTablePrimaryKey)();
|
void (*tqSetTablePrimaryKey)();
|
||||||
bool (*tqGetTablePrimaryKey)();
|
bool (*tqGetTablePrimaryKey)();
|
||||||
|
@ -239,8 +239,8 @@ typedef struct SStoreSnapshotFn {
|
||||||
bool (*taosXGetTablePrimaryKey)(SSnapContext* ctx);
|
bool (*taosXGetTablePrimaryKey)(SSnapContext* ctx);
|
||||||
void (*taosXSetTablePrimaryKey)(SSnapContext* ctx, int64_t uid);
|
void (*taosXSetTablePrimaryKey)(SSnapContext* ctx, int64_t uid);
|
||||||
int32_t (*setForSnapShot)(SSnapContext* ctx, int64_t uid);
|
int32_t (*setForSnapShot)(SSnapContext* ctx, int64_t uid);
|
||||||
int32_t (*destroySnapshot)(SSnapContext* ctx);
|
void (*destroySnapshot)(SSnapContext* ctx);
|
||||||
SMetaTableInfo (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx);
|
int32_t (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx, SMetaTableInfo* info);
|
||||||
int32_t (*getTableInfoFromSnapshot)(SSnapContext* ctx, void** pBuf, int32_t* contLen, int16_t* type, int64_t* uid);
|
int32_t (*getTableInfoFromSnapshot)(SSnapContext* ctx, void** pBuf, int32_t* contLen, int16_t* type, int64_t* uid);
|
||||||
} SStoreSnapshotFn;
|
} SStoreSnapshotFn;
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,9 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
|
|
||||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||||
|
|
||||||
|
#define TAOS_GET_TERRNO(code) \
|
||||||
|
(terrno == 0 ? code : terrno)
|
||||||
|
|
||||||
#define TAOS_RETURN(CODE) \
|
#define TAOS_RETURN(CODE) \
|
||||||
do { \
|
do { \
|
||||||
return (terrno = (CODE)); \
|
return (terrno = (CODE)); \
|
||||||
|
|
|
@ -484,7 +484,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
|
|
||||||
end:
|
end:
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
||||||
(void)taosArrayDestroy(pTagVals);
|
taosArrayDestroy(pTagVals);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs, cJSON** pJson) {
|
static void buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs, cJSON** pJson) {
|
||||||
|
@ -588,7 +588,7 @@ end:
|
||||||
tDecoderClear(&decoder[i]);
|
tDecoderClear(&decoder[i]);
|
||||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||||
if (pCreateReq[i].type == TSDB_CHILD_TABLE) {
|
if (pCreateReq[i].type == TSDB_CHILD_TABLE) {
|
||||||
(void)taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(decoder);
|
taosMemoryFree(decoder);
|
||||||
|
@ -1097,7 +1097,7 @@ typedef struct SVgroupCreateTableBatch {
|
||||||
|
|
||||||
static void destroyCreateTbReqBatch(void* data) {
|
static void destroyCreateTbReqBatch(void* data) {
|
||||||
SVgroupCreateTableBatch* pTbBatch = (SVgroupCreateTableBatch*)data;
|
SVgroupCreateTableBatch* pTbBatch = (SVgroupCreateTableBatch*)data;
|
||||||
(void)taosArrayDestroy(pTbBatch->req.pArray);
|
taosArrayDestroy(pTbBatch->req.pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
|
@ -1252,7 +1252,7 @@ typedef struct SVgroupDropTableBatch {
|
||||||
|
|
||||||
static void destroyDropTbReqBatch(void* data) {
|
static void destroyDropTbReqBatch(void* data) {
|
||||||
SVgroupDropTableBatch* pTbBatch = (SVgroupDropTableBatch*)data;
|
SVgroupDropTableBatch* pTbBatch = (SVgroupDropTableBatch*)data;
|
||||||
(void)taosArrayDestroy(pTbBatch->req.pArray);
|
taosArrayDestroy(pTbBatch->req.pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
|
@ -1518,7 +1518,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
uDebug(LOG_ID_TAG " alter table return, meta:%p, len:%d, msg:%s", LOG_ID_VALUE, meta, metaLen, tstrerror(code));
|
uDebug(LOG_ID_TAG " alter table return, meta:%p, len:%d, msg:%s", LOG_ID_VALUE, meta, metaLen, tstrerror(code));
|
||||||
(void)taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
||||||
taosMemoryFreeClear(pVgData);
|
taosMemoryFreeClear(pVgData);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
|
|
|
@ -197,8 +197,8 @@ static void smlDestroySTableMeta(void *para) {
|
||||||
SSmlSTableMeta *meta = *(SSmlSTableMeta **)para;
|
SSmlSTableMeta *meta = *(SSmlSTableMeta **)para;
|
||||||
taosHashCleanup(meta->tagHash);
|
taosHashCleanup(meta->tagHash);
|
||||||
taosHashCleanup(meta->colHash);
|
taosHashCleanup(meta->colHash);
|
||||||
(void)taosArrayDestroy(meta->tags);
|
taosArrayDestroy(meta->tags);
|
||||||
(void)taosArrayDestroy(meta->cols);
|
taosArrayDestroy(meta->cols);
|
||||||
taosMemoryFreeClear(meta->tableMeta);
|
taosMemoryFreeClear(meta->tableMeta);
|
||||||
taosMemoryFree(meta);
|
taosMemoryFree(meta);
|
||||||
}
|
}
|
||||||
|
@ -568,7 +568,7 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable) {
|
||||||
if (code != TSDB_CODE_SUCCESS){
|
if (code != TSDB_CODE_SUCCESS){
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
(void)taosArrayDestroy(dst);
|
taosArrayDestroy(dst);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1198,25 +1198,25 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField));
|
SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField));
|
||||||
if (pTags == NULL) {
|
if (pTags == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1271,7 +1271,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
SArray *pTags =
|
SArray *pTags =
|
||||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||||
if (pTags == NULL){
|
if (pTags == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1282,15 +1282,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||||
if (taosArrayPush(pColumns, &field) == NULL){
|
if (taosArrayPush(pColumns, &field) == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (taosArrayPush(pTags, &field) == NULL){
|
if (taosArrayPush(pTags, &field) == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1300,28 +1300,28 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
pTableMeta->tableInfo.numOfColumns, true);
|
pTableMeta->tableInfo.numOfColumns, true);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
||||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
||||||
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
||||||
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1367,7 +1367,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
SArray *pTags =
|
SArray *pTags =
|
||||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||||
if (pTags == NULL){
|
if (pTags == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1378,15 +1378,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||||
if (taosArrayPush(pColumns, &field) == NULL){
|
if (taosArrayPush(pColumns, &field) == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (taosArrayPush(pTags, &field) == NULL){
|
if (taosArrayPush(pTags, &field) == NULL){
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1397,21 +1397,21 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
pTableMeta->tableInfo.numOfColumns, false);
|
pTableMeta->tableInfo.numOfColumns, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
||||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
(void)taosArrayDestroy(pTags);
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||||
(void)taosArrayDestroy(pColumns);
|
taosArrayDestroy(pColumns);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1555,7 +1555,7 @@ void smlDestroyTableInfo(void *para) {
|
||||||
taosHashCleanup(kvHash);
|
taosHashCleanup(kvHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosArrayDestroy(tag->cols);
|
taosArrayDestroy(tag->cols);
|
||||||
taosArrayDestroyEx(tag->tags, freeSSmlKv);
|
taosArrayDestroyEx(tag->tags, freeSSmlKv);
|
||||||
taosMemoryFree(tag);
|
taosMemoryFree(tag);
|
||||||
}
|
}
|
||||||
|
@ -1581,13 +1581,13 @@ void smlDestroyInfo(SSmlHandle *info) {
|
||||||
cJSON *tags = (cJSON *)taosArrayGetP(info->tagJsonArray, i);
|
cJSON *tags = (cJSON *)taosArrayGetP(info->tagJsonArray, i);
|
||||||
cJSON_Delete(tags);
|
cJSON_Delete(tags);
|
||||||
}
|
}
|
||||||
(void)taosArrayDestroy(info->tagJsonArray);
|
taosArrayDestroy(info->tagJsonArray);
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(info->valueJsonArray); i++) {
|
for (int i = 0; i < taosArrayGetSize(info->valueJsonArray); i++) {
|
||||||
cJSON *value = (cJSON *)taosArrayGetP(info->valueJsonArray, i);
|
cJSON *value = (cJSON *)taosArrayGetP(info->valueJsonArray, i);
|
||||||
cJSON_Delete(value);
|
cJSON_Delete(value);
|
||||||
}
|
}
|
||||||
(void)taosArrayDestroy(info->valueJsonArray);
|
taosArrayDestroy(info->valueJsonArray);
|
||||||
|
|
||||||
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
|
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
|
||||||
|
|
||||||
|
|
|
@ -583,16 +583,10 @@ static int32_t asyncCommitOffset(tmq_t* tmq, char* pTopicName, int32_t vgId, STq
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
code = tFormatOffset(offsetBuf, tListLen(offsetBuf), offsetVal);
|
tFormatOffset(offsetBuf, tListLen(offsetBuf), offsetVal);
|
||||||
if (code != 0) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
char commitBuf[TSDB_OFFSET_LEN] = {0};
|
char commitBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
code = tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
||||||
if (code != 0) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMqCommitCbParamSet* pParamSet = NULL;
|
SMqCommitCbParamSet* pParamSet = NULL;
|
||||||
code = prepareCommitCbParamSet(tmq, pCommitFp, userParam, 0, &pParamSet);
|
code = prepareCommitCbParamSet(tmq, pCommitFp, userParam, 0, &pParamSet);
|
||||||
|
@ -694,10 +688,10 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us
|
||||||
if (pVg->offsetInfo.endOffset.type > 0 &&
|
if (pVg->offsetInfo.endOffset.type > 0 &&
|
||||||
!tOffsetEqual(&pVg->offsetInfo.endOffset, &pVg->offsetInfo.committedOffset)) {
|
!tOffsetEqual(&pVg->offsetInfo.endOffset, &pVg->offsetInfo.committedOffset)) {
|
||||||
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(offsetBuf, tListLen(offsetBuf), &pVg->offsetInfo.endOffset);
|
tFormatOffset(offsetBuf, tListLen(offsetBuf), &pVg->offsetInfo.endOffset);
|
||||||
|
|
||||||
char commitBuf[TSDB_OFFSET_LEN] = {0};
|
char commitBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
||||||
|
|
||||||
code = doSendCommitMsg(tmq, pVg->vgId, &pVg->epSet, &pVg->offsetInfo.endOffset, pTopic->topicName, pParamSet);
|
code = doSendCommitMsg(tmq, pVg->vgId, &pVg->epSet, &pVg->offsetInfo.endOffset, pTopic->topicName, pParamSet);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -865,7 +859,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
||||||
offRows->offset = pVg->offsetInfo.endOffset;
|
offRows->offset = pVg->offsetInfo.endOffset;
|
||||||
offRows->ever = pVg->offsetInfo.walVerEnd == -1 ? 0 : pVg->offsetInfo.walVerEnd;
|
offRows->ever = pVg->offsetInfo.walVerEnd == -1 ? 0 : pVg->offsetInfo.walVerEnd;
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset);
|
||||||
tscDebug("consumer:0x%" PRIx64 ",report offset, group:%s vgId:%d, offset:%s/%" PRId64 ", rows:%" PRId64,
|
tscDebug("consumer:0x%" PRIx64 ",report offset, group:%s vgId:%d, offset:%s/%" PRId64 ", rows:%" PRId64,
|
||||||
tmq->consumerId, tmq->groupId, offRows->vgId, buf, offRows->ever, offRows->rows);
|
tmq->consumerId, tmq->groupId, offRows->vgId, buf, offRows->ever, offRows->rows);
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1253,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
}
|
}
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
STqOffsetVal offset = {.type = pTmq->resetOffsetCfg};
|
STqOffsetVal offset = {.type = pTmq->resetOffsetCfg};
|
||||||
(void)tFormatOffset(buf, tListLen(buf), &offset);
|
tFormatOffset(buf, tListLen(buf), &offset);
|
||||||
tscInfo("consumer:0x%" PRIx64 " is setup, refId:%" PRId64
|
tscInfo("consumer:0x%" PRIx64 " is setup, refId:%" PRId64
|
||||||
", groupId:%s, snapshot:%d, autoCommit:%d, commitInterval:%dms, offset:%s",
|
", groupId:%s, snapshot:%d, autoCommit:%d, commitInterval:%dms, offset:%s",
|
||||||
pTmq->consumerId, pTmq->refId, pTmq->groupId, pTmq->useSnapshot, pTmq->autoCommit, pTmq->autoCommitInterval,
|
pTmq->consumerId, pTmq->refId, pTmq->groupId, pTmq->useSnapshot, pTmq->autoCommit, pTmq->autoCommitInterval,
|
||||||
|
@ -1517,7 +1511,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
(void)memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
(void)memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.common.rspOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.common.rspOffset);
|
||||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
||||||
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
|
@ -1695,7 +1689,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
||||||
(void)sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId);
|
(void)sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId);
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &pVgCur->offsetInfo.endOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVgCur->offsetInfo.endOffset);
|
||||||
tscInfo("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, pVgCur->vgId,
|
tscInfo("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, pVgCur->vgId,
|
||||||
vgKey, buf);
|
vgKey, buf);
|
||||||
|
|
||||||
|
@ -1959,7 +1953,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.endOffset);
|
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.endOffset);
|
||||||
code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||||
tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
||||||
pTmq->consumerId, pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId);
|
pTmq->consumerId, pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId);
|
||||||
|
@ -2130,7 +2124,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
tmq->consumerId, pDataRsp->blockNum != 0);
|
tmq->consumerId, pDataRsp->blockNum != 0);
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset);
|
||||||
if (pDataRsp->blockNum == 0) {
|
if (pDataRsp->blockNum == 0) {
|
||||||
tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64
|
tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64
|
||||||
", total:%" PRId64 ", reqId:0x%" PRIx64,
|
", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||||
|
@ -2287,7 +2281,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
tmq->totalRows += numOfRows;
|
tmq->totalRows += numOfRows;
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
||||||
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows, tmq->totalRows,
|
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows, tmq->totalRows,
|
||||||
|
@ -3401,7 +3395,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
(void)tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pClientVg->offsetInfo.beginOffset);
|
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pClientVg->offsetInfo.beginOffset);
|
||||||
|
|
||||||
tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||||
|
|
|
@ -65,7 +65,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
|
|
||||||
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
||||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
// case 2 false
|
// case 2 false
|
||||||
|
@ -74,7 +74,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
// case 4 tag is null
|
// case 4 tag is null
|
||||||
|
@ -95,7 +95,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
|
|
||||||
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
ASSERT_EQ(elements.timestamp, sql + elements.measureTagsLen + 1 + elements.colsLen + 1);
|
||||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
// case 5 tag is null
|
// case 5 tag is null
|
||||||
|
@ -115,7 +115,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
|
|
||||||
ASSERT_EQ(elements.timestamp, sql + 1 + elements.measureTagsLen + 3 + elements.colsLen + 2);
|
ASSERT_EQ(elements.timestamp, sql + 1 + elements.measureTagsLen + 3 + elements.colsLen + 2);
|
||||||
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
ASSERT_EQ(elements.timestampLen, strlen("1626006833639000000"));
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
// case 6
|
// case 6
|
||||||
|
@ -124,7 +124,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
ASSERT_EQ(smlClearForRerun(info), 0);
|
ASSERT_EQ(smlClearForRerun(info), 0);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
// case 8 false
|
// case 8 false
|
||||||
|
@ -143,7 +143,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
||||||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
elements.colArray = nullptr;
|
elements.colArray = nullptr;
|
||||||
|
|
||||||
taosMemoryFree(sql);
|
taosMemoryFree(sql);
|
||||||
|
@ -250,7 +250,7 @@ TEST(testCase, smlParseCols_Error_Test) {
|
||||||
// printf("i:%d\n", i);
|
// printf("i:%d\n", i);
|
||||||
ASSERT_NE(ret, TSDB_CODE_SUCCESS);
|
ASSERT_NE(ret, TSDB_CODE_SUCCESS);
|
||||||
taosMemoryFree(sql);
|
taosMemoryFree(sql);
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
}
|
}
|
||||||
smlDestroyInfo(info);
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
ASSERT_EQ(kv->length, 4);
|
ASSERT_EQ(kv->length, 4);
|
||||||
ASSERT_EQ(strncasecmp(kv->value, "iuwq", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->value, "iuwq", 4), 0);
|
||||||
|
|
||||||
(void)taosArrayDestroy(elements.colArray);
|
taosArrayDestroy(elements.colArray);
|
||||||
taosMemoryFree(sql);
|
taosMemoryFree(sql);
|
||||||
smlDestroyInfo(info);
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1510,6 +1510,9 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockDataFreeRes(SSDataBlock* pBlock) {
|
void blockDataFreeRes(SSDataBlock* pBlock) {
|
||||||
|
if (pBlock == NULL){
|
||||||
|
return;
|
||||||
|
}
|
||||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9180,7 +9180,7 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
void tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
||||||
if (pVal->type == TMQ_OFFSET__RESET_NONE) {
|
if (pVal->type == TMQ_OFFSET__RESET_NONE) {
|
||||||
(void)snprintf(buf, maxLen, "none");
|
(void)snprintf(buf, maxLen, "none");
|
||||||
} else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) {
|
} else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||||
|
@ -9201,11 +9201,7 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
||||||
(void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%" PRId64, pVal->uid, pVal->ts,
|
(void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%" PRId64, pVal->uid, pVal->ts,
|
||||||
pVal->primaryKey.type, pVal->primaryKey.val);
|
pVal->primaryKey.type, pVal->primaryKey.val);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return TSDB_CODE_INVALID_PARA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||||
|
|
|
@ -1252,13 +1252,13 @@ static bool isSeperatorChar(char c) {
|
||||||
return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9'));
|
return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseTsFormat(const char* formatStr, SArray* formats) {
|
static int32_t parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
TSFormatNode* lastOtherFormat = NULL;
|
TSFormatNode* lastOtherFormat = NULL;
|
||||||
while (*formatStr) {
|
while (*formatStr) {
|
||||||
const TSFormatKeyWord* key = keywordSearch(formatStr);
|
const TSFormatKeyWord* key = keywordSearch(formatStr);
|
||||||
if (key) {
|
if (key) {
|
||||||
TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD};
|
TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD};
|
||||||
taosArrayPush(formats, &format);
|
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
formatStr += key->len;
|
formatStr += key->len;
|
||||||
lastOtherFormat = NULL;
|
lastOtherFormat = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1286,7 +1286,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL};
|
TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL};
|
||||||
format.c = formatStr;
|
format.c = formatStr;
|
||||||
format.len = 1;
|
format.len = 1;
|
||||||
taosArrayPush(formats, &format);
|
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
formatStr++;
|
formatStr++;
|
||||||
last = taosArrayGetLast(formats);
|
last = taosArrayGetLast(formats);
|
||||||
}
|
}
|
||||||
|
@ -1314,13 +1314,14 @@ static void parseTsFormat(const char* formatStr, SArray* formats) {
|
||||||
.key = NULL};
|
.key = NULL};
|
||||||
format.c = formatStr;
|
format.c = formatStr;
|
||||||
format.len = 1;
|
format.len = 1;
|
||||||
taosArrayPush(formats, &format);
|
if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
formatStr++;
|
formatStr++;
|
||||||
if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats);
|
if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) {
|
static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) {
|
||||||
|
@ -1488,7 +1489,7 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
||||||
s += 6;
|
s += 6;
|
||||||
break;
|
break;
|
||||||
case TSFKW_NS:
|
case TSFKW_NS:
|
||||||
sprintf(s, "%09" PRId64, tm->fsec);
|
(void)sprintf(s, "%09" PRId64, tm->fsec);
|
||||||
s += 9;
|
s += 9;
|
||||||
break;
|
break;
|
||||||
case TSFKW_TZH:
|
case TSFKW_TZH:
|
||||||
|
@ -1925,7 +1926,7 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr
|
||||||
if (!*formats){
|
if (!*formats){
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
parseTsFormat(format, *formats);
|
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||||
}
|
}
|
||||||
struct STm tm;
|
struct STm tm;
|
||||||
TAOS_CHECK_RETURN(taosTs2Tm(ts, precision, &tm));
|
TAOS_CHECK_RETURN(taosTs2Tm(ts, precision, &tm));
|
||||||
|
@ -1941,7 +1942,7 @@ int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int
|
||||||
if (!*formats) {
|
if (!*formats) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
parseTsFormat(format, *formats);
|
TAOS_CHECK_RETURN(parseTsFormat(format, *formats));
|
||||||
}
|
}
|
||||||
int32_t code = char2ts(tsStr, *formats, ts, precision, &sErrPos, &fErrIdx);
|
int32_t code = char2ts(tsStr, *formats, ts, precision, &sErrPos, &fErrIdx);
|
||||||
if (code == -1) {
|
if (code == -1) {
|
||||||
|
@ -1966,7 +1967,7 @@ int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* ou
|
||||||
if (!formats) {
|
if (!formats) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
parseTsFormat(format, formats);
|
TAOS_CHECK_RETURN(parseTsFormat(format, formats));
|
||||||
struct STm tm;
|
struct STm tm;
|
||||||
TAOS_CHECK_GOTO(taosTs2Tm(ts, precision, &tm), NULL, _exit);
|
TAOS_CHECK_GOTO(taosTs2Tm(ts, precision, &tm), NULL, _exit);
|
||||||
TAOS_CHECK_GOTO(tm2char(formats, &tm, out, outLen), NULL, _exit);
|
TAOS_CHECK_GOTO(tm2char(formats, &tm, out, outLen), NULL, _exit);
|
||||||
|
@ -1980,11 +1981,11 @@ int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const c
|
||||||
const char* sErrPos;
|
const char* sErrPos;
|
||||||
int32_t fErrIdx;
|
int32_t fErrIdx;
|
||||||
SArray* formats = taosArrayInit(4, sizeof(TSFormatNode));
|
SArray* formats = taosArrayInit(4, sizeof(TSFormatNode));
|
||||||
parseTsFormat(format, formats);
|
TAOS_CHECK_RETURN(parseTsFormat(format, formats));
|
||||||
int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx);
|
int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx);
|
||||||
if (code == -1) {
|
if (code == -1) {
|
||||||
printf("failed position: %s\n", sErrPos);
|
(void)printf("failed position: %s\n", sErrPos);
|
||||||
printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name);
|
(void)printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(formats);
|
taosArrayDestroy(formats);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -175,7 +175,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
memcpy(val, src, len);
|
(void)memcpy(val, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -426,7 +426,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
||||||
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
||||||
|
|
||||||
pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
||||||
memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
(void)memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
||||||
pVar->nLen = (int32_t)len;
|
pVar->nLen = (int32_t)len;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -435,7 +435,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
case TSDB_DATA_TYPE_GEOMETRY: { // todo refactor, extract a method
|
case TSDB_DATA_TYPE_GEOMETRY: { // todo refactor, extract a method
|
||||||
pVar->pz = taosMemoryCalloc(len + 1, sizeof(char));
|
pVar->pz = taosMemoryCalloc(len + 1, sizeof(char));
|
||||||
memcpy(pVar->pz, pz, len);
|
(void)memcpy(pVar->pz, pz, len);
|
||||||
pVar->nLen = (int32_t)len;
|
pVar->nLen = (int32_t)len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -470,10 +470,10 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
|
||||||
char *p = taosMemoryRealloc(pDst->pz, len);
|
char *p = taosMemoryRealloc(pDst->pz, len);
|
||||||
ASSERT(p);
|
ASSERT(p);
|
||||||
|
|
||||||
memset(p, 0, len);
|
(void)memset(p, 0, len);
|
||||||
pDst->pz = p;
|
pDst->pz = p;
|
||||||
|
|
||||||
memcpy(pDst->pz, pSrc->pz, pSrc->nLen);
|
(void)memcpy(pDst->pz, pSrc->pz, pSrc->nLen);
|
||||||
pDst->nLen = pSrc->nLen;
|
pDst->nLen = pSrc->nLen;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,16 +733,17 @@ TEST(AlreadyAddGroupIdTest, GroupIdAddedWithDifferentLength) {
|
||||||
#define SLOW_LOG_TYPE_OTHERS 0x4
|
#define SLOW_LOG_TYPE_OTHERS 0x4
|
||||||
#define SLOW_LOG_TYPE_ALL 0x7
|
#define SLOW_LOG_TYPE_ALL 0x7
|
||||||
|
|
||||||
static int32_t taosSetSlowLogScope(char *pScope) {
|
static int32_t taosSetSlowLogScope(char* pScopeStr, int32_t* pScope) {
|
||||||
if (NULL == pScope || 0 == strlen(pScope)) {
|
if (NULL == pScopeStr || 0 == strlen(pScopeStr)) {
|
||||||
return SLOW_LOG_TYPE_QUERY;
|
*pScope = SLOW_LOG_TYPE_QUERY;
|
||||||
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t slowScope = 0;
|
int32_t slowScope = 0;
|
||||||
|
|
||||||
char* scope = NULL;
|
char* scope = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
while((scope = strsep(&pScope, "|")) != NULL){
|
while((scope = strsep(&pScopeStr, "|")) != NULL){
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
tmp = taosStrdup(scope);
|
tmp = taosStrdup(scope);
|
||||||
strtrim(tmp);
|
strtrim(tmp);
|
||||||
|
@ -772,73 +773,94 @@ static int32_t taosSetSlowLogScope(char *pScope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
uError("Invalid slowLog scope value:%s", pScope);
|
uError("Invalid slowLog scope value:%s", pScopeStr);
|
||||||
terrno = TSDB_CODE_INVALID_CFG_VALUE;
|
TAOS_RETURN(TSDB_CODE_INVALID_CFG_VALUE);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*pScope = slowScope;
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
return slowScope;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, NullPointerInput) {
|
TEST(TaosSetSlowLogScopeTest, NullPointerInput) {
|
||||||
char *pScope = NULL;
|
char* pScopeStr = NULL;
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, EmptyStringInput) {
|
TEST(TaosSetSlowLogScopeTest, EmptyStringInput) {
|
||||||
char pScope[1] = "";
|
char pScopeStr[1] = "";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, AllScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, AllScopeInput) {
|
||||||
char pScope[] = "all";
|
char pScopeStr[] = "all";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_ALL);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, QueryScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, QueryScopeInput) {
|
||||||
char pScope[] = " query";
|
char pScopeStr[] = " query";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_QUERY);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, InsertScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, InsertScopeInput) {
|
||||||
char pScope[] = "insert";
|
char pScopeStr[] = "insert";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_INSERT);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_INSERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, OthersScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, OthersScopeInput) {
|
||||||
char pScope[] = "others";
|
char pScopeStr[] = "others";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_OTHERS);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_OTHERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, NoneScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, NoneScopeInput) {
|
||||||
char pScope[] = "none";
|
char pScopeStr[] = "none";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, SLOW_LOG_TYPE_NULL);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, SLOW_LOG_TYPE_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, InvalidScopeInput) {
|
TEST(TaosSetSlowLogScopeTest, InvalidScopeInput) {
|
||||||
char pScope[] = "invalid";
|
char pScopeStr[] = "invalid";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, -1);
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, MixedScopesInput) {
|
TEST(TaosSetSlowLogScopeTest, MixedScopesInput) {
|
||||||
char pScope[] = "query|insert|others|none";
|
char pScopeStr[] = "query|insert|others|none";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TaosSetSlowLogScopeTest, MixedScopesInputWithSpaces) {
|
TEST(TaosSetSlowLogScopeTest, MixedScopesInputWithSpaces) {
|
||||||
char pScope[] = "query | insert | others ";
|
char pScopeStr[] = "query | insert | others ";
|
||||||
int32_t result = taosSetSlowLogScope(pScope);
|
int32_t scope = 0;
|
||||||
EXPECT_EQ(result, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
int32_t result = taosSetSlowLogScope(pScopeStr, &scope);
|
||||||
|
EXPECT_EQ(result, TSDB_CODE_SUCCESS);
|
||||||
|
EXPECT_EQ(scope, (SLOW_LOG_TYPE_QUERY | SLOW_LOG_TYPE_INSERT | SLOW_LOG_TYPE_OTHERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
|
@ -74,7 +74,7 @@ static struct {
|
||||||
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetGlobalDebugFlag(143); }
|
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { (void)taosSetGlobalDebugFlag(143); }
|
||||||
static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert = 1; }
|
static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert = 1; }
|
||||||
|
|
||||||
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pGroup) {
|
||||||
|
|
||||||
void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
||||||
ASSERT(pVgObj->replica == 2);
|
ASSERT(pVgObj->replica == 2);
|
||||||
memset(outGroup, 0, sizeof(SArbGroup));
|
(void)memset(outGroup, 0, sizeof(SArbGroup));
|
||||||
outGroup->dbUid = pVgObj->dbUid;
|
outGroup->dbUid = pVgObj->dbUid;
|
||||||
outGroup->vgId = pVgObj->vgId;
|
outGroup->vgId = pVgObj->vgId;
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
|
@ -223,7 +223,7 @@ static int32_t mndArbGroupActionInsert(SSdb *pSdb, SArbGroup *pGroup) {
|
||||||
static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup) {
|
static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup) {
|
||||||
mTrace("arbgroup:%d, perform delete action, row:%p", pGroup->vgId, pGroup);
|
mTrace("arbgroup:%d, perform delete action, row:%p", pGroup->vgId, pGroup);
|
||||||
if (pGroup->mutexInited) {
|
if (pGroup->mutexInited) {
|
||||||
taosThreadMutexDestroy(&pGroup->mutex);
|
(void)taosThreadMutexDestroy(&pGroup->mutex);
|
||||||
pGroup->mutexInited = false;
|
pGroup->mutexInited = false;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -231,7 +231,7 @@ static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup) {
|
||||||
|
|
||||||
static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *pNew) {
|
static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *pNew) {
|
||||||
mTrace("arbgroup:%d, perform update action, old row:%p new row:%p", pOld->vgId, pOld, pNew);
|
mTrace("arbgroup:%d, perform update action, old row:%p new row:%p", pOld->vgId, pOld, pNew);
|
||||||
taosThreadMutexLock(&pOld->mutex);
|
(void)taosThreadMutexLock(&pOld->mutex);
|
||||||
|
|
||||||
if (pOld->version != pNew->version) {
|
if (pOld->version != pNew->version) {
|
||||||
mInfo("arbgroup:%d, skip to perform update action, old row:%p new row:%p, old version:%" PRId64
|
mInfo("arbgroup:%d, skip to perform update action, old row:%p new row:%p, old version:%" PRId64
|
||||||
|
@ -241,18 +241,18 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
memcpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
(void)memcpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
pOld->isSync = pNew->isSync;
|
pOld->isSync = pNew->isSync;
|
||||||
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId;
|
||||||
memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
(void)memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
pOld->assignedLeader.acked = pNew->assignedLeader.acked;
|
||||||
pOld->version++;
|
pOld->version++;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosThreadMutexUnlock(&pOld->mutex);
|
(void)taosThreadMutexUnlock(&pOld->mutex);
|
||||||
|
|
||||||
taosHashRemove(arbUpdateHash, &pOld->vgId, sizeof(int32_t));
|
(void)taosHashRemove(arbUpdateHash, &pOld->vgId, sizeof(int32_t));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
||||||
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
taosThreadMutexLock(&pArbGroup->mutex);
|
(void)taosThreadMutexLock(&pArbGroup->mutex);
|
||||||
|
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
SArbGroupMember *pMember = &pArbGroup->members[i];
|
SArbGroupMember *pMember = &pArbGroup->members[i];
|
||||||
|
@ -400,13 +400,13 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
||||||
hbMembers = *(SArray **)pObj;
|
hbMembers = *(SArray **)pObj;
|
||||||
} else {
|
} else {
|
||||||
hbMembers = taosArrayInit(16, sizeof(SVArbHbReqMember));
|
hbMembers = taosArrayInit(16, sizeof(SVArbHbReqMember));
|
||||||
taosHashPut(pDnodeHash, &dnodeId, sizeof(int32_t), &hbMembers, POINTER_BYTES);
|
(void)taosHashPut(pDnodeHash, &dnodeId, sizeof(int32_t), &hbMembers, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
SVArbHbReqMember reqMember = {.vgId = pArbGroup->vgId, .hbSeq = pMember->state.nextHbSeq++};
|
SVArbHbReqMember reqMember = {.vgId = pArbGroup->vgId, .hbSeq = pMember->state.nextHbSeq++};
|
||||||
taosArrayPush(hbMembers, &reqMember);
|
(void)taosArrayPush(hbMembers, &reqMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pArbGroup->mutex);
|
(void)taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||||
sdbRelease(pSdb, pArbGroup);
|
sdbRelease(pSdb, pArbGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,9 +602,9 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
||||||
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
taosThreadMutexLock(&pArbGroup->mutex);
|
(void)taosThreadMutexLock(&pArbGroup->mutex);
|
||||||
mndArbGroupDupObj(pArbGroup, &arbGroupDup);
|
mndArbGroupDupObj(pArbGroup, &arbGroupDup);
|
||||||
taosThreadMutexUnlock(&pArbGroup->mutex);
|
(void)taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||||
|
|
||||||
int32_t vgId = arbGroupDup.vgId;
|
int32_t vgId = arbGroupDup.vgId;
|
||||||
|
|
||||||
|
@ -668,7 +668,10 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
||||||
SArbGroup newGroup = {0};
|
SArbGroup newGroup = {0};
|
||||||
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
||||||
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
||||||
taosArrayPush(pUpdateArray, &newGroup);
|
if (taosArrayPush(pUpdateArray, &newGroup) == NULL) {
|
||||||
|
taosArrayDestroy(pUpdateArray);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pArbGroup);
|
sdbRelease(pSdb, pArbGroup);
|
||||||
}
|
}
|
||||||
|
@ -722,7 +725,7 @@ static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
||||||
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
||||||
|
|
||||||
SArray *pArray = taosArrayInit(1, sizeof(SMArbUpdateGroup));
|
SArray *pArray = taosArrayInit(1, sizeof(SMArbUpdateGroup));
|
||||||
taosArrayPush(pArray, &newGroup);
|
if (taosArrayPush(pArray, &newGroup) == NULL) goto _OVER;
|
||||||
|
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
void *pHead = mndBuildArbUpdateGroupBatchReq(&contLen, pArray);
|
void *pHead = mndBuildArbUpdateGroupBatchReq(&contLen, pArray);
|
||||||
|
@ -736,7 +739,7 @@ static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
||||||
ret = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
ret = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
if (ret != 0) goto _OVER;
|
if (ret != 0) goto _OVER;
|
||||||
|
|
||||||
taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0);
|
if ((ret = taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0)) != 0) goto _OVER;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
|
@ -758,8 +761,8 @@ static int32_t mndPullupArbUpdateGroupBatch(SMnode *pMnode, SArray *newGroupArra
|
||||||
SMArbUpdateGroup newGroup = {0};
|
SMArbUpdateGroup newGroup = {0};
|
||||||
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
||||||
|
|
||||||
taosArrayPush(pArray, &newGroup);
|
if (taosArrayPush(pArray, &newGroup) == NULL) goto _OVER;
|
||||||
taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0);
|
if (taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0) != 0) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pArray) == 0) {
|
if (taosArrayGetSize(pArray) == 0) {
|
||||||
|
@ -784,7 +787,7 @@ _OVER:
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
for (size_t i = 0; i < sz; i++) {
|
for (size_t i = 0; i < sz; i++) {
|
||||||
SArbGroup *pNewGroup = taosArrayGet(newGroupArray, i);
|
SArbGroup *pNewGroup = taosArrayGet(newGroupArray, i);
|
||||||
taosHashRemove(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId));
|
(void)taosHashRemove(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,19 +819,19 @@ static int32_t mndProcessArbUpdateGroupBatchReq(SRpcMsg *pReq) {
|
||||||
newGroup.dbUid = pUpdateGroup->dbUid;
|
newGroup.dbUid = pUpdateGroup->dbUid;
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
newGroup.members[i].info.dnodeId = pUpdateGroup->members[i].dnodeId;
|
||||||
memcpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
(void)memcpy(newGroup.members[i].state.token, pUpdateGroup->members[i].token, TSDB_ARB_TOKEN_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroup.isSync = pUpdateGroup->isSync;
|
newGroup.isSync = pUpdateGroup->isSync;
|
||||||
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
newGroup.assignedLeader.dnodeId = pUpdateGroup->assignedLeader.dnodeId;
|
||||||
memcpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
(void)memcpy(newGroup.assignedLeader.token, pUpdateGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
newGroup.assignedLeader.acked = pUpdateGroup->assignedLeader.acked;
|
||||||
newGroup.version = pUpdateGroup->version;
|
newGroup.version = pUpdateGroup->version;
|
||||||
|
|
||||||
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
||||||
if (!pOldGroup) {
|
if (!pOldGroup) {
|
||||||
mInfo("vgId:%d, arb skip to update arbgroup, since no obj found", newGroup.vgId);
|
mInfo("vgId:%d, arb skip to update arbgroup, since no obj found", newGroup.vgId);
|
||||||
taosHashRemove(arbUpdateHash, &newGroup.vgId, sizeof(int32_t));
|
(void)taosHashRemove(arbUpdateHash, &newGroup.vgId, sizeof(int32_t));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,7 +861,7 @@ _OVER:
|
||||||
// failed to update arbgroup
|
// failed to update arbgroup
|
||||||
for (size_t i = 0; i < sz; i++) {
|
for (size_t i = 0; i < sz; i++) {
|
||||||
SMArbUpdateGroup *pUpdateGroup = taosArrayGet(req.updateArray, i);
|
SMArbUpdateGroup *pUpdateGroup = taosArrayGet(req.updateArray, i);
|
||||||
taosHashRemove(arbUpdateHash, &pUpdateGroup->vgId, sizeof(int32_t));
|
(void)taosHashRemove(arbUpdateHash, &pUpdateGroup->vgId, sizeof(int32_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,20 +871,20 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndArbGroupDupObj(SArbGroup *pGroup, SArbGroup *pNew) {
|
static void mndArbGroupDupObj(SArbGroup *pGroup, SArbGroup *pNew) {
|
||||||
memcpy(pNew, pGroup, offsetof(SArbGroup, mutexInited));
|
(void)memcpy(pNew, pGroup, offsetof(SArbGroup, mutexInited));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) {
|
static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) {
|
||||||
SArbGroupMember *pMember = &pGroup->members[index];
|
SArbGroupMember *pMember = &pGroup->members[index];
|
||||||
|
|
||||||
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
pGroup->assignedLeader.dnodeId = pMember->info.dnodeId;
|
||||||
strncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
(void)strncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE);
|
||||||
pGroup->assignedLeader.acked = false;
|
pGroup->assignedLeader.acked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup) {
|
static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup) {
|
||||||
pGroup->assignedLeader.dnodeId = 0;
|
pGroup->assignedLeader.dnodeId = 0;
|
||||||
memset(pGroup->assignedLeader.token, 0, TSDB_ARB_TOKEN_SIZE);
|
(void)memset(pGroup->assignedLeader.token, 0, TSDB_ARB_TOKEN_SIZE);
|
||||||
pGroup->assignedLeader.acked = false;
|
pGroup->assignedLeader.acked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +926,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
||||||
bool updateToken = false;
|
bool updateToken = false;
|
||||||
SArbGroupMember *pMember = NULL;
|
SArbGroupMember *pMember = NULL;
|
||||||
|
|
||||||
taosThreadMutexLock(&pGroup->mutex);
|
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (; index < TSDB_ARB_GROUP_MEMBER_NUM; index++) {
|
for (; index < TSDB_ARB_GROUP_MEMBER_NUM; index++) {
|
||||||
|
@ -957,7 +960,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
||||||
|
|
||||||
// update token
|
// update token
|
||||||
mndArbGroupDupObj(pGroup, pNewGroup);
|
mndArbGroupDupObj(pGroup, pNewGroup);
|
||||||
memcpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
(void)memcpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE);
|
||||||
pNewGroup->isSync = false;
|
pNewGroup->isSync = false;
|
||||||
|
|
||||||
bool resetAssigned = false;
|
bool resetAssigned = false;
|
||||||
|
@ -970,7 +973,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
||||||
mInfo("dnodeId:%d vgId:%d, arb token updating, resetAssigned:%d", dnodeId, pRspMember->vgId, resetAssigned);
|
mInfo("dnodeId:%d vgId:%d, arb token updating, resetAssigned:%d", dnodeId, pRspMember->vgId, resetAssigned);
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosThreadMutexUnlock(&pGroup->mutex);
|
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||||
return updateToken;
|
return updateToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,7 +994,7 @@ static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *me
|
||||||
|
|
||||||
bool updateToken = mndUpdateArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup);
|
bool updateToken = mndUpdateArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup);
|
||||||
if (updateToken) {
|
if (updateToken) {
|
||||||
taosArrayPush(pUpdateArray, &newGroup);
|
(void)taosArrayPush(pUpdateArray, &newGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pGroup);
|
sdbRelease(pMnode->pSdb, pGroup);
|
||||||
|
@ -1007,7 +1010,7 @@ bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0
|
||||||
bool newIsSync, SArbGroup *pNewGroup) {
|
bool newIsSync, SArbGroup *pNewGroup) {
|
||||||
bool updateIsSync = false;
|
bool updateIsSync = false;
|
||||||
|
|
||||||
taosThreadMutexLock(&pGroup->mutex);
|
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||||
|
|
||||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
@ -1033,7 +1036,7 @@ bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0
|
||||||
}
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosThreadMutexUnlock(&pGroup->mutex);
|
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||||
return updateIsSync;
|
return updateIsSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1148,7 +1151,7 @@ bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char
|
||||||
SArbGroup *pNewGroup) {
|
SArbGroup *pNewGroup) {
|
||||||
bool updateAssigned = false;
|
bool updateAssigned = false;
|
||||||
|
|
||||||
taosThreadMutexLock(&pGroup->mutex);
|
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||||
if (mndArbCheckToken(pGroup->assignedLeader.token, memberToken) != 0) {
|
if (mndArbCheckToken(pGroup->assignedLeader.token, memberToken) != 0) {
|
||||||
mInfo("skip update arb assigned for vgId:%d, member token mismatch, local:[%s] msg:[%s]", vgId,
|
mInfo("skip update arb assigned for vgId:%d, member token mismatch, local:[%s] msg:[%s]", vgId,
|
||||||
pGroup->assignedLeader.token, memberToken);
|
pGroup->assignedLeader.token, memberToken);
|
||||||
|
@ -1171,7 +1174,7 @@ bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char
|
||||||
}
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
taosThreadMutexUnlock(&pGroup->mutex);
|
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||||
return updateAssigned;
|
return updateAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1241,43 +1244,43 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
pShow->pIter = sdbFetch(pSdb, SDB_ARBGROUP, pShow->pIter, (void **)&pGroup);
|
pShow->pIter = sdbFetch(pSdb, SDB_ARBGROUP, pShow->pIter, (void **)&pGroup);
|
||||||
if (pShow->pIter == NULL) break;
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
taosThreadMutexLock(&pGroup->mutex);
|
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||||
|
|
||||||
cols = 0;
|
cols = 0;
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
SVgObj *pVgObj = sdbAcquire(pSdb, SDB_VGROUP, &pGroup->vgId);
|
SVgObj *pVgObj = sdbAcquire(pSdb, SDB_VGROUP, &pGroup->vgId);
|
||||||
if (!pVgObj) {
|
if (!pVgObj) {
|
||||||
taosThreadMutexUnlock(&pGroup->mutex);
|
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||||
sdbRelease(pSdb, pGroup);
|
sdbRelease(pSdb, pGroup);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pVgObj->dbName), TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pVgObj->dbName), TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->vgId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->vgId, false);
|
||||||
|
|
||||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||||
SArbGroupMember *pMember = &pGroup->members[i];
|
SArbGroupMember *pMember = &pGroup->members[i];
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pMember->info.dnodeId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pMember->info.dnodeId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
||||||
|
|
||||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false);
|
||||||
|
|
||||||
char token[TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE] = {0};
|
char token[TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)token, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)token, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.acked, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.acked, false);
|
||||||
} else {
|
} else {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
|
@ -1289,7 +1292,7 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pGroup->mutex);
|
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pVgObj);
|
sdbRelease(pSdb, pVgObj);
|
||||||
|
|
|
@ -243,7 +243,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
||||||
|
|
||||||
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
strcpy(clusterObj.name, "tdengine3.0");
|
(void)strcpy(clusterObj.name, "tdengine3.0");
|
||||||
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||||
if (pCluster != NULL) {
|
if (pCluster != NULL) {
|
||||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
(void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||||
clusterObj.upTime += tsUptimeInterval;
|
clusterObj.upTime += tsUptimeInterval;
|
||||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
|
||||||
if (pCluster) mndReleaseCluster(pMnode, pCluster, pIter);
|
if (pCluster) mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
(void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||||
|
|
||||||
if (strncmp(cfgReq.config, GRANT_ACTIVE_CODE, TSDB_DNODE_CONFIG_LEN) == 0) {
|
if (strncmp(cfgReq.config, GRANT_ACTIVE_CODE, TSDB_DNODE_CONFIG_LEN) == 0) {
|
||||||
|
|
|
@ -231,7 +231,7 @@ int32_t mndAddCompactToTran(SMnode *pMnode, STrans *pTrans, SCompactObj *pCompac
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
pCompact->compactId = tGenIdPI32();
|
pCompact->compactId = tGenIdPI32();
|
||||||
|
|
||||||
strcpy(pCompact->dbname, pDb->name);
|
(void)strcpy(pCompact->dbname, pDb->name);
|
||||||
|
|
||||||
pCompact->startTime = taosGetTimestampMs();
|
pCompact->startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
@ -283,21 +283,21 @@ int32_t mndRetrieveCompact(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock,
|
||||||
char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->compactId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->compactId, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
if (pDb != NULL || !IS_SYS_DBNAME(pCompact->dbname)) {
|
if (pDb != NULL || !IS_SYS_DBNAME(pCompact->dbname)) {
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB);
|
(void)tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB);
|
||||||
tNameGetDbName(&name, varDataVal(tmpBuf));
|
(void)tNameGetDbName(&name, varDataVal(tmpBuf));
|
||||||
} else {
|
} else {
|
||||||
strncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
(void)strncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
||||||
}
|
}
|
||||||
varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf)));
|
varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf)));
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->startTime, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->startTime, false);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pCompact);
|
sdbRelease(pSdb, pCompact);
|
||||||
|
@ -334,7 +334,7 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
||||||
pHead->contLen = htonl(contLen);
|
pHead->contLen = htonl(contLen);
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req);
|
(void)tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req);
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ int32_t mndProcessKillCompactReq(SRpcMsg *pReq) {
|
||||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
char obj[TSDB_INT32_ID_LEN] = {0};
|
char obj[TSDB_INT32_ID_LEN] = {0};
|
||||||
sprintf(obj, "%d", pCompact->compactId);
|
(void)sprintf(obj, "%d", pCompact->compactId);
|
||||||
|
|
||||||
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql, killCompactReq.sqlLen);
|
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql, killCompactReq.sqlLen);
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
||||||
pHead->contLen = htonl(contLen);
|
pHead->contLen = htonl(contLen);
|
||||||
pHead->vgId = htonl(pDetail->vgId);
|
pHead->vgId = htonl(pDetail->vgId);
|
||||||
|
|
||||||
tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req);
|
(void)tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, .contLen = contLen};
|
SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, .contLen = contLen};
|
||||||
|
|
||||||
|
@ -602,7 +602,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
||||||
|
|
||||||
mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail);
|
mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail);
|
||||||
|
|
||||||
tmsgSendReq(&epSet, &rpcMsg);
|
if (tmsgSendReq(&epSet, &rpcMsg) < 0) {
|
||||||
|
sdbRelease(pMnode->pSdb, pDetail);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pDetail);
|
sdbRelease(pMnode->pSdb, pDetail);
|
||||||
|
@ -806,7 +809,7 @@ void mndCompactPullup(SMnode *pMnode) {
|
||||||
SCompactObj *pCompact = NULL;
|
SCompactObj *pCompact = NULL;
|
||||||
pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact);
|
pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
taosArrayPush(pArray, &pCompact->compactId);
|
(void)taosArrayPush(pArray, &pCompact->compactId);
|
||||||
sdbRelease(pSdb, pCompact);
|
sdbRelease(pSdb, pCompact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,22 +68,22 @@ int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->compactId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->compactId, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->dnodeId, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->dnodeId, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->finished, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->finished, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false);
|
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pCompactDetail);
|
sdbRelease(pSdb, pCompactDetail);
|
||||||
|
|
|
@ -946,7 +946,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
STqOffsetVal pVal = {.type = pConsumer->resetOffsetCfg};
|
STqOffsetVal pVal = {.type = pConsumer->resetOffsetCfg};
|
||||||
MND_TMQ_RETURN_CHECK(tFormatOffset(buf, TSDB_OFFSET_LEN, &pVal));
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVal);
|
||||||
|
|
||||||
char parasStr[64 + TSDB_OFFSET_LEN + VARSTR_HEADER_SIZE] = {0};
|
char parasStr[64 + TSDB_OFFSET_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
(void)sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
(void)sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
||||||
|
|
|
@ -1375,7 +1375,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
||||||
if (data) {
|
if (data) {
|
||||||
// vg id
|
// vg id
|
||||||
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
||||||
MND_TMQ_RETURN_CHECK(tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset));
|
tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset);
|
||||||
(void)sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
(void)sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
||||||
varDataSetLen(buf, strlen(varDataVal(buf)));
|
varDataSetLen(buf, strlen(varDataVal(buf)));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
@ -223,9 +223,9 @@ bool tqGetTablePrimaryKey(STqReader *pReader);
|
||||||
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
||||||
|
|
||||||
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||||
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
void tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
||||||
int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
void tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
||||||
int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
void tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
||||||
|
|
||||||
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
||||||
bool tqCurrentBlockConsumed(const STqReader *pReader);
|
bool tqCurrentBlockConsumed(const STqReader *pReader);
|
||||||
|
@ -261,9 +261,9 @@ void taosXSetTablePrimaryKey(SSnapContext *ctx, int64_t uid);
|
||||||
int32_t buildSnapContext(SVnode *pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
int32_t buildSnapContext(SVnode *pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
||||||
SSnapContext **ctxRet);
|
SSnapContext **ctxRet);
|
||||||
int32_t getTableInfoFromSnapshot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
int32_t getTableInfoFromSnapshot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
||||||
SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext *ctx);
|
int32_t getMetaTableInfoFromSnapshot(SSnapContext *ctx, SMetaTableInfo* info);
|
||||||
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
||||||
int32_t destroySnapContext(SSnapContext *ctx);
|
void destroySnapContext(SSnapContext *ctx);
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
struct STsdbCfg {
|
struct STsdbCfg {
|
||||||
|
|
|
@ -85,18 +85,18 @@ typedef struct {
|
||||||
TXN* pTxn;
|
TXN* pTxn;
|
||||||
} STtlDelTtlCtx;
|
} STtlDelTtlCtx;
|
||||||
|
|
||||||
int ttlMgrOpen(STtlManger** ppTtlMgr, TDB* pEnv, int8_t rollback, const char* logPrefix, int32_t flushThreshold);
|
int32_t ttlMgrOpen(STtlManger** ppTtlMgr, TDB* pEnv, int8_t rollback, const char* logPrefix, int32_t flushThreshold);
|
||||||
void ttlMgrClose(STtlManger* pTtlMgr);
|
void ttlMgrClose(STtlManger* pTtlMgr);
|
||||||
|
|
||||||
bool ttlMgrNeedUpgrade(TDB* pEnv);
|
bool ttlMgrNeedUpgrade(TDB* pEnv);
|
||||||
int ttlMgrUpgrade(STtlManger* pTtlMgr, void* pMeta);
|
int32_t ttlMgrUpgrade(STtlManger* pTtlMgr, void* pMeta);
|
||||||
|
|
||||||
int ttlMgrInsertTtl(STtlManger* pTtlMgr, const STtlUpdTtlCtx* pUpdCtx);
|
int32_t ttlMgrInsertTtl(STtlManger* pTtlMgr, const STtlUpdTtlCtx* pUpdCtx);
|
||||||
int ttlMgrDeleteTtl(STtlManger* pTtlMgr, const STtlDelTtlCtx* pDelCtx);
|
int32_t ttlMgrDeleteTtl(STtlManger* pTtlMgr, const STtlDelTtlCtx* pDelCtx);
|
||||||
int ttlMgrUpdateChangeTime(STtlManger* pTtlMgr, const STtlUpdCtimeCtx* pUpdCtimeCtx);
|
int32_t ttlMgrUpdateChangeTime(STtlManger* pTtlMgr, const STtlUpdCtimeCtx* pUpdCtimeCtx);
|
||||||
|
|
||||||
int ttlMgrFlush(STtlManger* pTtlMgr, TXN* pTxn);
|
int32_t ttlMgrFlush(STtlManger* pTtlMgr, TXN* pTxn);
|
||||||
int ttlMgrFindExpired(STtlManger* pTtlMgr, int64_t timePointMs, SArray* pTbUids, int32_t ttlDropMaxCount);
|
int32_t ttlMgrFindExpired(STtlManger* pTtlMgr, int64_t timePointMs, SArray* pTbUids, int32_t ttlDropMaxCount);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,11 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||||
int32_t type, int32_t vgId);
|
int32_t type, int32_t vgId);
|
||||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||||
|
|
||||||
// tqMeta
|
// tqMeta
|
||||||
int32_t tqMetaOpen(STQ* pTq);
|
int32_t tqMetaOpen(STQ* pTq);
|
||||||
int32_t tqMetaClose(STQ* pTq);
|
void tqMetaClose(STQ* pTq);
|
||||||
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle);
|
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle);
|
||||||
int32_t tqMetaSaveInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen, const void* value, int32_t vLen);
|
int32_t tqMetaSaveInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen, const void* value, int32_t vLen);
|
||||||
int32_t tqMetaDeleteInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen);
|
int32_t tqMetaDeleteInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen);
|
||||||
|
@ -133,7 +133,7 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle);
|
||||||
int32_t tqMetaDecodeCheckInfo(STqCheckInfo *info, void *pVal, int32_t vLen);
|
int32_t tqMetaDecodeCheckInfo(STqCheckInfo *info, void *pVal, int32_t vLen);
|
||||||
int32_t tqMetaDecodeOffsetInfo(STqOffset *info, void *pVal, int32_t vLen);
|
int32_t tqMetaDecodeOffsetInfo(STqOffset *info, void *pVal, int32_t vLen);
|
||||||
int32_t tqMetaGetHandle(STQ* pTq, const char* key, STqHandle** pHandle);
|
int32_t tqMetaGetHandle(STQ* pTq, const char* key, STqHandle** pHandle);
|
||||||
void* tqMetaGetOffset(STQ* pTq, const char* subkey);
|
int32_t tqMetaGetOffset(STQ* pTq, const char* subkey, STqOffset** pOffset);
|
||||||
int32_t tqMetaTransform(STQ* pTq);
|
int32_t tqMetaTransform(STQ* pTq);
|
||||||
// tqSink
|
// tqSink
|
||||||
int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq,
|
int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq,
|
||||||
|
@ -166,12 +166,12 @@ int32_t buildAutoCreateTableReq(const char* stbFullName, int64_t suid, int32_t n
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TQ_ERR_RETURN(c) \
|
#define TQ_NULL_GO_TO_END(c) \
|
||||||
do { \
|
do { \
|
||||||
code = c; \
|
if (c == NULL) { \
|
||||||
if (code != TSDB_CODE_SUCCESS) { \
|
code = (terrno == 0 ? TSDB_CODE_OUT_OF_MEMORY : terrno); \
|
||||||
return code; \
|
goto END; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TQ_SUBSCRIBE_NAME "subscribe"
|
#define TQ_SUBSCRIBE_NAME "subscribe"
|
||||||
|
|
|
@ -239,12 +239,12 @@ int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||||
int64_t tsdbGetEarliestTs(STsdb* pTsdb);
|
int64_t tsdbGetEarliestTs(STsdb* pTsdb);
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode);
|
int32_t tqOpen(const char* path, SVnode* pVnode);
|
||||||
void tqNotifyClose(STQ*);
|
void tqNotifyClose(STQ*);
|
||||||
void tqClose(STQ*);
|
void tqClose(STQ*);
|
||||||
int tqPushMsg(STQ*, tmsg_t msgType);
|
int tqPushMsg(STQ*, tmsg_t msgType);
|
||||||
int tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg);
|
int tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg);
|
||||||
int tqUnregisterPushHandle(STQ* pTq, void* pHandle);
|
void tqUnregisterPushHandle(STQ* pTq, void* pHandle);
|
||||||
int tqScanWalAsync(STQ* pTq, bool ckPause);
|
int tqScanWalAsync(STQ* pTq, bool ckPause);
|
||||||
int32_t tqStopStreamTasksAsync(STQ* pTq);
|
int32_t tqStopStreamTasksAsync(STQ* pTq);
|
||||||
int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp);
|
int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp);
|
||||||
|
@ -345,7 +345,7 @@ int32_t tsdbSnapRAWWriterPrepareClose(STsdbSnapRAWWriter* pWriter);
|
||||||
int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** ppWriter, int8_t rollback);
|
int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** ppWriter, int8_t rollback);
|
||||||
// STqSnapshotReader ==
|
// STqSnapshotReader ==
|
||||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader);
|
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader);
|
||||||
int32_t tqSnapReaderClose(STqSnapReader** ppReader);
|
void tqSnapReaderClose(STqSnapReader** ppReader);
|
||||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData);
|
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData);
|
||||||
// STqSnapshotWriter ======================================
|
// STqSnapshotWriter ======================================
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter);
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter);
|
||||||
|
|
|
@ -219,50 +219,91 @@ static void destroySTableInfoForChildTable(void* data) {
|
||||||
tDeleteSchemaWrapper(pData->tagRow);
|
tDeleteSchemaWrapper(pData->tagRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MoveToSnapShotVersion(SSnapContext* ctx) {
|
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||||
tdbTbcClose((TBC*)ctx->pCur);
|
int32_t code = 0;
|
||||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||||
|
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
STbDbKey key = {.version = ctx->snapVersion, .uid = INT64_MAX};
|
STbDbKey key = {.version = ctx->snapVersion, .uid = INT64_MAX};
|
||||||
int c = 0;
|
int c = 0;
|
||||||
tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
|
code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
|
||||||
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
tdbTbcMoveToPrev((TBC*)ctx->pCur);
|
tdbTbcMoveToPrev((TBC*)ctx->pCur);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
||||||
tdbTbcClose((TBC*)ctx->pCur);
|
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
STbDbKey key = {.version = ver, .uid = uid};
|
STbDbKey key = {.version = ver, .uid = uid};
|
||||||
int c = 0;
|
int c = 0;
|
||||||
tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
|
code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c);
|
||||||
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MoveToFirst(SSnapContext* ctx) {
|
static int32_t MoveToFirst(SSnapContext* ctx) {
|
||||||
tdbTbcClose((TBC*)ctx->pCur);
|
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
tdbTbcMoveToFirst((TBC*)ctx->pCur);
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
|
code = tdbTbcMoveToFirst((TBC*)ctx->pCur);
|
||||||
|
if (code != 0){
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInfo) {
|
static int32_t saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInfo) {
|
||||||
STableInfoForChildTable* data = (STableInfoForChildTable*)taosHashGet(suidInfo, &me->uid, sizeof(tb_uid_t));
|
STableInfoForChildTable* data = (STableInfoForChildTable*)taosHashGet(suidInfo, &me->uid, sizeof(tb_uid_t));
|
||||||
if (data) {
|
if (data) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int32_t code = 0;
|
||||||
STableInfoForChildTable dataTmp = {0};
|
STableInfoForChildTable dataTmp = {0};
|
||||||
dataTmp.tableName = taosStrdup(me->name);
|
dataTmp.tableName = taosStrdup(me->name);
|
||||||
|
if (dataTmp.tableName == NULL){
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
|
dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
|
||||||
|
if (dataTmp.schemaRow == NULL){
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag);
|
dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag);
|
||||||
taosHashPut(suidInfo, &me->uid, sizeof(tb_uid_t), &dataTmp, sizeof(STableInfoForChildTable));
|
if (dataTmp.tagRow == NULL){
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
code = taosHashPut(suidInfo, &me->uid, sizeof(tb_uid_t), &dataTmp, sizeof(STableInfoForChildTable));
|
||||||
|
if (code != 0){
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
END:
|
||||||
|
destroySTableInfoForChildTable(&dataTmp);
|
||||||
|
return TAOS_GET_TERRNO(code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta,
|
||||||
SSnapContext** ctxRet) {
|
SSnapContext** ctxRet) {
|
||||||
SSnapContext* ctx = taosMemoryCalloc(1, sizeof(SSnapContext));
|
SSnapContext* ctx = taosMemoryCalloc(1, sizeof(SSnapContext));
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL){
|
||||||
return terrno;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
*ctxRet = ctx;
|
*ctxRet = ctx;
|
||||||
ctx->pMeta = pVnode->pMeta;
|
ctx->pMeta = pVnode->pMeta;
|
||||||
|
@ -273,23 +314,29 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
ctx->withMeta = withMeta;
|
ctx->withMeta = withMeta;
|
||||||
ctx->idVersion = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
ctx->idVersion = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
if (ctx->idVersion == NULL) {
|
if (ctx->idVersion == NULL) {
|
||||||
return terrno;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
if (ctx->suidInfo == NULL) {
|
if (ctx->suidInfo == NULL) {
|
||||||
return terrno;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||||
}
|
}
|
||||||
taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);
|
taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);
|
||||||
|
|
||||||
ctx->index = 0;
|
ctx->index = 0;
|
||||||
ctx->idList = taosArrayInit(100, sizeof(int64_t));
|
ctx->idList = taosArrayInit(100, sizeof(int64_t));
|
||||||
|
if (ctx->idList == NULL){
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||||
|
}
|
||||||
void* pKey = NULL;
|
void* pKey = NULL;
|
||||||
void* pVal = NULL;
|
void* pVal = NULL;
|
||||||
int vLen = 0, kLen = 0;
|
int vLen = 0, kLen = 0;
|
||||||
|
|
||||||
metaDebug("tmqsnap init snapVersion:%" PRIi64, ctx->snapVersion);
|
metaDebug("tmqsnap init snapVersion:%" PRIi64, ctx->snapVersion);
|
||||||
MoveToFirst(ctx);
|
int32_t code = MoveToFirst(ctx);
|
||||||
|
if (code != 0){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t ret = tdbTbcNext((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
int32_t ret = tdbTbcNext((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||||
if (ret < 0) break;
|
if (ret < 0) break;
|
||||||
|
@ -301,15 +348,18 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) <
|
if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) < 0) { // check if table exist for now, need optimize later
|
||||||
0) { // check if table exist for now, need optimize later
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
tDecoderInit(&dc, pVal, vLen);
|
tDecoderInit(&dc, pVal, vLen);
|
||||||
metaDecodeEntry(&dc, &me);
|
ret = metaDecodeEntry(&dc, &me);
|
||||||
|
if (ret < 0){
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
|
if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
if ((me.uid != ctx->suid && me.type == TSDB_SUPER_TABLE) ||
|
if ((me.uid != ctx->suid && me.type == TSDB_SUPER_TABLE) ||
|
||||||
(me.ctbEntry.suid != ctx->suid && me.type == TSDB_CHILD_TABLE)) {
|
(me.ctbEntry.suid != ctx->suid && me.type == TSDB_CHILD_TABLE)) {
|
||||||
|
@ -318,16 +368,24 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(ctx->idList, &tmp->uid);
|
if (taosArrayPush(ctx->idList, &tmp->uid) == NULL){
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
metaDebug("tmqsnap init idlist name:%s, uid:%" PRIi64, me.name, tmp->uid);
|
metaDebug("tmqsnap init idlist name:%s, uid:%" PRIi64, me.name, tmp->uid);
|
||||||
SIdInfo info = {0};
|
|
||||||
taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
|
|
||||||
|
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
|
SIdInfo info = {0};
|
||||||
|
if (taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo)) != 0) {
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosHashClear(ctx->idVersion);
|
taosHashClear(ctx->idVersion);
|
||||||
|
|
||||||
MoveToSnapShotVersion(ctx);
|
code = MoveToSnapShotVersion(ctx);
|
||||||
|
if (code != 0){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t ret = tdbTbcPrev((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
int32_t ret = tdbTbcPrev((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||||
if (ret < 0) break;
|
if (ret < 0) break;
|
||||||
|
@ -338,12 +396,20 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SIdInfo info = {.version = tmp->version, .index = 0};
|
SIdInfo info = {.version = tmp->version, .index = 0};
|
||||||
taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
|
ret = taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
|
||||||
|
if (ret != 0) {
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
|
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
tDecoderInit(&dc, pVal, vLen);
|
tDecoderInit(&dc, pVal, vLen);
|
||||||
metaDecodeEntry(&dc, &me);
|
ret = metaDecodeEntry(&dc, &me);
|
||||||
|
if (ret < 0){
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
|
if (ctx->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
if ((me.uid != ctx->suid && me.type == TSDB_SUPER_TABLE) ||
|
if ((me.uid != ctx->suid && me.type == TSDB_SUPER_TABLE) ||
|
||||||
(me.ctbEntry.suid != ctx->suid && me.type == TSDB_CHILD_TABLE)) {
|
(me.ctbEntry.suid != ctx->suid && me.type == TSDB_CHILD_TABLE)) {
|
||||||
|
@ -354,17 +420,24 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
|
|
||||||
if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
|
if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
|
||||||
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.uid == ctx->suid)) {
|
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.uid == ctx->suid)) {
|
||||||
saveSuperTableInfoForChildTable(&me, ctx->suidInfo);
|
ret = saveSuperTableInfoForChildTable(&me, ctx->suidInfo);
|
||||||
|
if (ret != 0){
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) {
|
for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) {
|
||||||
int64_t* uid = taosArrayGet(ctx->idList, i);
|
int64_t* uid = taosArrayGet(ctx->idList, i);
|
||||||
|
if (uid == NULL){
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t));
|
SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t));
|
||||||
if (!idData) {
|
if (!idData) {
|
||||||
metaError("meta/snap: null idData");
|
metaError("meta/snap: null idData");
|
||||||
return TSDB_CODE_FAILED;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
idData->index = i;
|
idData->index = i;
|
||||||
|
@ -377,13 +450,12 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t destroySnapContext(SSnapContext* ctx) {
|
void destroySnapContext(SSnapContext* ctx) {
|
||||||
tdbTbcClose((TBC*)ctx->pCur);
|
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||||
taosArrayDestroy(ctx->idList);
|
taosArrayDestroy(ctx->idList);
|
||||||
taosHashCleanup(ctx->idVersion);
|
taosHashCleanup(ctx->idVersion);
|
||||||
taosHashCleanup(ctx->suidInfo);
|
taosHashCleanup(ctx->suidInfo);
|
||||||
taosMemoryFree(ctx);
|
taosMemoryFree(ctx);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildNormalChildTableInfo(SVCreateTbReq* req, void** pBuf, int32_t* contLen) {
|
static int32_t buildNormalChildTableInfo(SVCreateTbReq* req, void** pBuf, int32_t* contLen) {
|
||||||
|
@ -392,32 +464,36 @@ static int32_t buildNormalChildTableInfo(SVCreateTbReq* req, void** pBuf, int32_
|
||||||
|
|
||||||
reqs.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
|
reqs.pArray = taosArrayInit(1, sizeof(struct SVCreateTbReq));
|
||||||
if (NULL == reqs.pArray) {
|
if (NULL == reqs.pArray) {
|
||||||
ret = -1;
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(reqs.pArray, req) == NULL){
|
||||||
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
taosArrayPush(reqs.pArray, req);
|
|
||||||
reqs.nReqs = 1;
|
reqs.nReqs = 1;
|
||||||
|
|
||||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqs, *contLen, ret);
|
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqs, *contLen, ret);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -1;
|
ret = TAOS_GET_TERRNO(ret);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
*contLen += sizeof(SMsgHead);
|
*contLen += sizeof(SMsgHead);
|
||||||
*pBuf = taosMemoryMalloc(*contLen);
|
*pBuf = taosMemoryMalloc(*contLen);
|
||||||
if (NULL == *pBuf) {
|
if (NULL == *pBuf) {
|
||||||
ret = -1;
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
SEncoder coder = {0};
|
SEncoder coder = {0};
|
||||||
tEncoderInit(&coder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
tEncoderInit(&coder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
||||||
if (tEncodeSVCreateTbBatchReq(&coder, &reqs) < 0) {
|
ret = tEncodeSVCreateTbBatchReq(&coder, &reqs);
|
||||||
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
taosMemoryFreeClear(*pBuf);
|
taosMemoryFreeClear(*pBuf);
|
||||||
tEncoderClear(&coder);
|
ret = TAOS_GET_TERRNO(ret);
|
||||||
ret = -1;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
tEncoderClear(&coder);
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
taosArrayDestroy(reqs.pArray);
|
taosArrayDestroy(reqs.pArray);
|
||||||
|
@ -428,48 +504,46 @@ static int32_t buildSuperTableInfo(SVCreateStbReq* req, void** pBuf, int32_t* co
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVCreateStbReq, req, *contLen, ret);
|
tEncodeSize(tEncodeSVCreateStbReq, req, *contLen, ret);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return TAOS_GET_TERRNO(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
*contLen += sizeof(SMsgHead);
|
*contLen += sizeof(SMsgHead);
|
||||||
*pBuf = taosMemoryMalloc(*contLen);
|
*pBuf = taosMemoryMalloc(*contLen);
|
||||||
if (NULL == *pBuf) {
|
if (NULL == *pBuf) {
|
||||||
return terrno;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
tEncoderInit(&encoder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
||||||
if ((ret = tEncodeSVCreateStbReq(&encoder, req)) < 0) {
|
ret = tEncodeSVCreateStbReq(&encoder, req);
|
||||||
taosMemoryFreeClear(*pBuf);
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
if (ret < 0) {
|
||||||
|
taosMemoryFreeClear(*pBuf);
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setForSnapShot(SSnapContext* ctx, int64_t uid) {
|
int32_t setForSnapShot(SSnapContext* ctx, int64_t uid) {
|
||||||
int c = 0;
|
|
||||||
|
|
||||||
if (uid == 0) {
|
if (uid == 0) {
|
||||||
ctx->index = 0;
|
ctx->index = 0;
|
||||||
return c;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &uid, sizeof(tb_uid_t));
|
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &uid, sizeof(tb_uid_t));
|
||||||
if (!idInfo) {
|
if (idInfo == NULL) {
|
||||||
return -1;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->index = idInfo->index;
|
ctx->index = idInfo->index;
|
||||||
|
|
||||||
return c;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid) {
|
void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid){
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
SSchemaWrapper* schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1);
|
SSchemaWrapper *schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1);
|
||||||
if (schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
|
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
tDeleteSchemaWrapper(schema);
|
tDeleteSchemaWrapper(schema);
|
||||||
|
@ -493,11 +567,15 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||||
|
if (uidTmp == NULL) {
|
||||||
|
metaError("tmqsnap get meta null uid");
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
ctx->index++;
|
ctx->index++;
|
||||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||||
if (!idInfo) {
|
if (!idInfo) {
|
||||||
metaError("meta/snap: null idInfo");
|
metaError("meta/snap: null idInfo");
|
||||||
return TSDB_CODE_FAILED;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
*uid = *uidTmp;
|
*uid = *uidTmp;
|
||||||
|
@ -508,11 +586,18 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
||||||
metaDebug("tmqsnap get meta not exist uid:%" PRIi64 " version:%" PRIi64, *uid, idInfo->version);
|
metaDebug("tmqsnap get meta not exist uid:%" PRIi64 " version:%" PRIi64, *uid, idInfo->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
|
ret = tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
|
||||||
|
if (ret < 0) {
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
tDecoderInit(&dc, pVal, vLen);
|
tDecoderInit(&dc, pVal, vLen);
|
||||||
metaDecodeEntry(&dc, &me);
|
ret = metaDecodeEntry(&dc, &me);
|
||||||
|
if (ret < 0) {
|
||||||
|
ret = TAOS_GET_TERRNO(ret);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
metaDebug("tmqsnap get meta uid:%" PRIi64 " name:%s index:%d", *uid, me.name, ctx->index - 1);
|
metaDebug("tmqsnap get meta uid:%" PRIi64 " name:%s index:%d", *uid, me.name, ctx->index - 1);
|
||||||
|
|
||||||
if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
|
if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) ||
|
||||||
|
@ -528,14 +613,14 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
||||||
|
|
||||||
ret = buildSuperTableInfo(&req, pBuf, contLen);
|
ret = buildSuperTableInfo(&req, pBuf, contLen);
|
||||||
*type = TDMT_VND_CREATE_STB;
|
*type = TDMT_VND_CREATE_STB;
|
||||||
|
|
||||||
} else if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) ||
|
} else if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) ||
|
||||||
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) {
|
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) {
|
||||||
STableInfoForChildTable* data =
|
STableInfoForChildTable* data =
|
||||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
metaError("meta/snap: null data");
|
metaError("meta/snap: null data");
|
||||||
return TSDB_CODE_FAILED;
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVCreateTbReq req = {0};
|
SVCreateTbReq req = {0};
|
||||||
|
@ -549,46 +634,48 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
||||||
req.ctb.stbName = data->tableName;
|
req.ctb.stbName = data->tableName;
|
||||||
|
|
||||||
SArray* tagName = taosArrayInit(req.ctb.tagNum, TSDB_COL_NAME_LEN);
|
SArray* tagName = taosArrayInit(req.ctb.tagNum, TSDB_COL_NAME_LEN);
|
||||||
|
if (tagName == NULL) {
|
||||||
|
metaError("meta/snap: init tag name failed.");
|
||||||
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
STag* p = (STag*)me.ctbEntry.pTags;
|
STag* p = (STag*)me.ctbEntry.pTags;
|
||||||
if (tTagIsJson(p)) {
|
if (tTagIsJson(p)) {
|
||||||
if (p->nTag != 0) {
|
if (p->nTag != 0) {
|
||||||
SSchema* schema = &data->tagRow->pSchema[0];
|
SSchema* schema = &data->tagRow->pSchema[0];
|
||||||
taosArrayPush(tagName, schema->name);
|
if (taosArrayPush(tagName, schema->name) == NULL) {
|
||||||
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SArray* pTagVals = NULL;
|
SArray* pTagVals = NULL;
|
||||||
if (tTagToValArray((const STag*)p, &pTagVals) != 0) {
|
ret = tTagToValArray((const STag*)p, &pTagVals);
|
||||||
|
if (ret != 0) {
|
||||||
metaError("meta/snap: tag to val array failed.");
|
metaError("meta/snap: tag to val array failed.");
|
||||||
return TSDB_CODE_FAILED;
|
taosArrayDestroy(pTagVals);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
|
goto END;
|
||||||
}
|
}
|
||||||
int16_t nCols = taosArrayGetSize(pTagVals);
|
int16_t nCols = taosArrayGetSize(pTagVals);
|
||||||
for (int j = 0; j < nCols; ++j) {
|
for (int j = 0; j < nCols; ++j) {
|
||||||
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
|
STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
|
||||||
for (int i = 0; i < data->tagRow->nCols; i++) {
|
for (int i = 0; pTagVal && i < data->tagRow->nCols; i++) {
|
||||||
SSchema* schema = &data->tagRow->pSchema[i];
|
SSchema* schema = &data->tagRow->pSchema[i];
|
||||||
if (schema->colId == pTagVal->cid) {
|
if (schema->colId == pTagVal->cid) {
|
||||||
taosArrayPush(tagName, schema->name);
|
if (taosArrayPush(tagName, schema->name) == NULL) {
|
||||||
|
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
taosArrayDestroy(pTagVals);
|
||||||
|
taosArrayDestroy(tagName);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pTagVals);
|
taosArrayDestroy(pTagVals);
|
||||||
}
|
}
|
||||||
// SIdInfo* sidInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
|
||||||
// if(sidInfo->version >= idInfo->version){
|
|
||||||
// // need parse tag
|
|
||||||
// STag* p = (STag*)me.ctbEntry.pTags;
|
|
||||||
// SArray* pTagVals = NULL;
|
|
||||||
// if (tTagToValArray((const STag*)p, &pTagVals) != 0) {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int16_t nCols = taosArrayGetSize(pTagVals);
|
|
||||||
// for (int j = 0; j < nCols; ++j) {
|
|
||||||
// STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j);
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
req.ctb.pTag = me.ctbEntry.pTags;
|
req.ctb.pTag = me.ctbEntry.pTags;
|
||||||
// }
|
|
||||||
|
|
||||||
req.ctb.tagName = tagName;
|
req.ctb.tagName = tagName;
|
||||||
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
||||||
*type = TDMT_VND_CREATE_TABLE;
|
*type = TDMT_VND_CREATE_TABLE;
|
||||||
|
@ -605,15 +692,15 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
||||||
*type = TDMT_VND_CREATE_TABLE;
|
*type = TDMT_VND_CREATE_TABLE;
|
||||||
} else {
|
} else {
|
||||||
metaError("meta/snap: invalid topic sub type: %" PRId8 " get meta from snap failed.", ctx->subType);
|
metaError("meta/snap: invalid topic sub type: %" PRId8 " get meta from snap failed.", ctx->subType);
|
||||||
ret = -1;
|
ret = TSDB_CODE_SDB_INVALID_TABLE_TYPE;
|
||||||
}
|
}
|
||||||
tDecoderClear(&dc);
|
|
||||||
|
|
||||||
|
END:
|
||||||
|
tDecoderClear(&dc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) {
|
||||||
SMetaTableInfo result = {0};
|
|
||||||
void* pKey = NULL;
|
void* pKey = NULL;
|
||||||
void* pVal = NULL;
|
void* pVal = NULL;
|
||||||
int vLen, kLen;
|
int vLen, kLen;
|
||||||
|
@ -621,14 +708,17 @@ SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (ctx->index >= taosArrayGetSize(ctx->idList)) {
|
if (ctx->index >= taosArrayGetSize(ctx->idList)) {
|
||||||
metaDebug("tmqsnap get uid info end");
|
metaDebug("tmqsnap get uid info end");
|
||||||
return result;
|
return 0;
|
||||||
}
|
}
|
||||||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||||
|
if (uidTmp == NULL){
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
ctx->index++;
|
ctx->index++;
|
||||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||||
if (!idInfo) {
|
if (!idInfo) {
|
||||||
metaError("meta/snap: null idInfo");
|
metaError("meta/snap: null idInfo");
|
||||||
return result;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
int32_t ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
||||||
|
@ -637,44 +727,46 @@ SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
||||||
idInfo->version);
|
idInfo->version);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
|
ret = tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen);
|
||||||
|
if (ret != 0){
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
tDecoderInit(&dc, pVal, vLen);
|
tDecoderInit(&dc, pVal, vLen);
|
||||||
metaDecodeEntry(&dc, &me);
|
ret = metaDecodeEntry(&dc, &me);
|
||||||
|
if (ret != 0){
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
return TAOS_GET_TERRNO(ret);
|
||||||
|
}
|
||||||
metaDebug("tmqsnap get uid info uid:%" PRIi64 " name:%s index:%d", me.uid, me.name, ctx->index - 1);
|
metaDebug("tmqsnap get uid info uid:%" PRIi64 " name:%s index:%d", me.uid, me.name, ctx->index - 1);
|
||||||
|
|
||||||
if (ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) {
|
if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) ||
|
||||||
|
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)){
|
||||||
STableInfoForChildTable* data =
|
STableInfoForChildTable* data =
|
||||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||||
result.uid = me.uid;
|
if (data == NULL) {
|
||||||
result.suid = me.ctbEntry.suid;
|
tDecoderClear(&dc);
|
||||||
result.schema = tCloneSSchemaWrapper(data->schemaRow);
|
metaError("meta/snap: null data");
|
||||||
strcpy(result.tbName, me.name);
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
tDecoderClear(&dc);
|
}
|
||||||
break;
|
result->suid = me.ctbEntry.suid;
|
||||||
|
result->schema = tCloneSSchemaWrapper(data->schemaRow);
|
||||||
} else if (ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_NORMAL_TABLE) {
|
} else if (ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_NORMAL_TABLE) {
|
||||||
result.uid = me.uid;
|
result->suid = 0;
|
||||||
result.suid = 0;
|
result->schema = tCloneSSchemaWrapper(&me.ntbEntry.schemaRow);
|
||||||
strcpy(result.tbName, me.name);
|
|
||||||
result.schema = tCloneSSchemaWrapper(&me.ntbEntry.schemaRow);
|
|
||||||
tDecoderClear(&dc);
|
|
||||||
break;
|
|
||||||
} else if (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid) {
|
|
||||||
STableInfoForChildTable* data =
|
|
||||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
|
||||||
result.uid = me.uid;
|
|
||||||
result.suid = me.ctbEntry.suid;
|
|
||||||
strcpy(result.tbName, me.name);
|
|
||||||
result.schema = tCloneSSchemaWrapper(data->schemaRow);
|
|
||||||
tDecoderClear(&dc);
|
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
metaDebug("tmqsnap get uid continue");
|
metaDebug("tmqsnap get uid continue");
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
result->uid = me.uid;
|
||||||
|
tstrncpy(result->tbName, me.name, TSDB_TABLE_NAME_LEN);
|
||||||
|
tDecoderClear(&dc);
|
||||||
|
if(result->schema == NULL){
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,39 +46,38 @@ static bool ttlMgrNeedFlush(STtlManger *pTtlMgr);
|
||||||
const char *ttlTbname = "ttl.idx";
|
const char *ttlTbname = "ttl.idx";
|
||||||
const char *ttlV1Tbname = "ttlv1.idx";
|
const char *ttlV1Tbname = "ttlv1.idx";
|
||||||
|
|
||||||
int ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback, const char *logPrefix, int32_t flushThreshold) {
|
int32_t ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback, const char *logPrefix, int32_t flushThreshold) {
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int64_t startNs = taosGetTimestampNs();
|
int64_t startNs = taosGetTimestampNs();
|
||||||
|
|
||||||
*ppTtlMgr = NULL;
|
*ppTtlMgr = NULL;
|
||||||
|
|
||||||
STtlManger *pTtlMgr = (STtlManger *)tdbOsCalloc(1, sizeof(*pTtlMgr));
|
STtlManger *pTtlMgr = (STtlManger *)tdbOsCalloc(1, sizeof(*pTtlMgr));
|
||||||
if (pTtlMgr == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (pTtlMgr == NULL) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
|
||||||
char *logBuffer = (char *)tdbOsCalloc(1, strlen(logPrefix) + 1);
|
char *logBuffer = (char *)tdbOsCalloc(1, strlen(logPrefix) + 1);
|
||||||
if (logBuffer == NULL) {
|
if (logBuffer == NULL) {
|
||||||
tdbOsFree(pTtlMgr);
|
tdbOsFree(pTtlMgr);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
strcpy(logBuffer, logPrefix);
|
(void)strcpy(logBuffer, logPrefix);
|
||||||
pTtlMgr->logPrefix = logBuffer;
|
pTtlMgr->logPrefix = logBuffer;
|
||||||
pTtlMgr->flushThreshold = flushThreshold;
|
pTtlMgr->flushThreshold = flushThreshold;
|
||||||
|
|
||||||
ret = tdbTbOpen(ttlV1Tbname, TDB_VARIANT_LEN, TDB_VARIANT_LEN, ttlIdxKeyV1Cmpr, pEnv, &pTtlMgr->pTtlIdx, rollback);
|
code = tdbTbOpen(ttlV1Tbname, TDB_VARIANT_LEN, TDB_VARIANT_LEN, ttlIdxKeyV1Cmpr, pEnv, &pTtlMgr->pTtlIdx, rollback);
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, failed to open %s since %s", pTtlMgr->logPrefix, ttlV1Tbname, tstrerror(terrno));
|
metaError("%s, failed to open %s since %s", pTtlMgr->logPrefix, ttlV1Tbname, tstrerror(code));
|
||||||
tdbOsFree(pTtlMgr);
|
tdbOsFree(pTtlMgr);
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTtlMgr->pTtlCache = taosHashInit(8192, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
pTtlMgr->pTtlCache = taosHashInit(8192, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
pTtlMgr->pDirtyUids = taosHashInit(8192, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
pTtlMgr->pDirtyUids = taosHashInit(8192, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
|
|
||||||
ret = ttlMgrFillCache(pTtlMgr);
|
if ((code = ttlMgrFillCache(pTtlMgr)) != TSDB_CODE_SUCCESS) {
|
||||||
if (ret < 0) {
|
|
||||||
metaError("%s, failed to fill hash since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, failed to fill hash since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
||||||
ttlMgrCleanup(pTtlMgr);
|
ttlMgrCleanup(pTtlMgr);
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t endNs = taosGetTimestampNs();
|
int64_t endNs = taosGetTimestampNs();
|
||||||
|
@ -86,7 +85,7 @@ int ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback, const char *lo
|
||||||
taosHashGetSize(pTtlMgr->pTtlCache), endNs - startNs);
|
taosHashGetSize(pTtlMgr->pTtlCache), endNs - startNs);
|
||||||
|
|
||||||
*ppTtlMgr = pTtlMgr;
|
*ppTtlMgr = pTtlMgr;
|
||||||
return TSDB_CODE_SUCCESS;
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ttlMgrClose(STtlManger *pTtlMgr) { ttlMgrCleanup(pTtlMgr); }
|
void ttlMgrClose(STtlManger *pTtlMgr) { ttlMgrCleanup(pTtlMgr); }
|
||||||
|
@ -99,37 +98,34 @@ bool ttlMgrNeedUpgrade(TDB *pEnv) {
|
||||||
return needUpgrade;
|
return needUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrUpgrade(STtlManger *pTtlMgr, void *pMeta) {
|
int32_t ttlMgrUpgrade(STtlManger *pTtlMgr, void *pMeta) {
|
||||||
SMeta *meta = (SMeta *)pMeta;
|
SMeta *meta = (SMeta *)pMeta;
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (!tdbTbExist(ttlTbname, meta->pEnv)) return TSDB_CODE_SUCCESS;
|
if (!tdbTbExist(ttlTbname, meta->pEnv)) TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
metaInfo("%s, ttl mgr start upgrade", pTtlMgr->logPrefix);
|
metaInfo("%s, ttl mgr start upgrade", pTtlMgr->logPrefix);
|
||||||
|
|
||||||
int64_t startNs = taosGetTimestampNs();
|
int64_t startNs = taosGetTimestampNs();
|
||||||
|
|
||||||
ret = tdbTbOpen(ttlTbname, sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, meta->pEnv, &pTtlMgr->pOldTtlIdx, 0);
|
code = tdbTbOpen(ttlTbname, sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, meta->pEnv, &pTtlMgr->pOldTtlIdx, 0);
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, failed to open %s index since %s", pTtlMgr->logPrefix, ttlTbname, tstrerror(terrno));
|
metaError("%s, failed to open %s index since %s", pTtlMgr->logPrefix, ttlTbname, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ttlMgrConvert(pTtlMgr->pOldTtlIdx, pTtlMgr->pTtlIdx, pMeta);
|
if ((code = ttlMgrConvert(pTtlMgr->pOldTtlIdx, pTtlMgr->pTtlIdx, pMeta)) != TSDB_CODE_SUCCESS) {
|
||||||
if (ret < 0) {
|
metaError("%s, failed to convert ttl index since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
metaError("%s, failed to convert ttl index since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tdbTbDropByName(ttlTbname, meta->pEnv, meta->txn);
|
if ((code = tdbTbDropByName(ttlTbname, meta->pEnv, meta->txn)) != TSDB_CODE_SUCCESS) {
|
||||||
if (ret < 0) {
|
metaError("%s, failed to drop old ttl index since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
metaError("%s, failed to drop old ttl index since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ttlMgrFillCache(pTtlMgr);
|
if ((code = ttlMgrFillCache(pTtlMgr)) != TSDB_CODE_SUCCESS) {
|
||||||
if (ret < 0) {
|
metaError("%s, failed to fill hash since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
metaError("%s, failed to fill hash since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,14 +137,14 @@ _out:
|
||||||
tdbTbClose(pTtlMgr->pOldTtlIdx);
|
tdbTbClose(pTtlMgr->pOldTtlIdx);
|
||||||
pTtlMgr->pOldTtlIdx = NULL;
|
pTtlMgr->pOldTtlIdx = NULL;
|
||||||
|
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ttlMgrCleanup(STtlManger *pTtlMgr) {
|
static void ttlMgrCleanup(STtlManger *pTtlMgr) {
|
||||||
taosMemoryFree(pTtlMgr->logPrefix);
|
taosMemoryFree(pTtlMgr->logPrefix);
|
||||||
taosHashCleanup(pTtlMgr->pTtlCache);
|
taosHashCleanup(pTtlMgr->pTtlCache);
|
||||||
taosHashCleanup(pTtlMgr->pDirtyUids);
|
taosHashCleanup(pTtlMgr->pDirtyUids);
|
||||||
tdbTbClose(pTtlMgr->pTtlIdx);
|
(void)tdbTbClose(pTtlMgr->pTtlIdx);
|
||||||
taosMemoryFree(pTtlMgr);
|
taosMemoryFree(pTtlMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,30 +211,30 @@ static int32_t ttlMgrFillCacheOneEntry(const void *pKey, int keyLen, const void
|
||||||
return taosHashPut(pCache, &uid, sizeof(uid), &data, sizeof(data));
|
return taosHashPut(pCache, &uid, sizeof(uid), &data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ttlMgrConvertOneEntry(const void *pKey, int keyLen, const void *pVal, int valLen, void *pConvertData) {
|
static int32_t ttlMgrConvertOneEntry(const void *pKey, int keyLen, const void *pVal, int valLen, void *pConvertData) {
|
||||||
SConvertData *pData = (SConvertData *)pConvertData;
|
SConvertData *pData = (SConvertData *)pConvertData;
|
||||||
|
|
||||||
STtlIdxKey *ttlKey = (STtlIdxKey *)pKey;
|
STtlIdxKey *ttlKey = (STtlIdxKey *)pKey;
|
||||||
tb_uid_t uid = ttlKey->uid;
|
tb_uid_t uid = ttlKey->uid;
|
||||||
int64_t ttlDays = 0;
|
int64_t ttlDays = 0;
|
||||||
|
|
||||||
int ret = metaGetTableTtlByUid(pData->pMeta, uid, &ttlDays);
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (ret < 0) {
|
if ((code = metaGetTableTtlByUid(pData->pMeta, uid, &ttlDays)) != TSDB_CODE_SUCCESS) {
|
||||||
metaError("ttlMgr convert failed to get ttl since %s", tstrerror(terrno));
|
metaError("ttlMgr convert failed to get ttl since %s", tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
STtlIdxKeyV1 ttlKeyV1 = {.deleteTimeMs = ttlKey->deleteTimeSec * 1000, .uid = uid};
|
STtlIdxKeyV1 ttlKeyV1 = {.deleteTimeMs = ttlKey->deleteTimeSec * 1000, .uid = uid};
|
||||||
ret = tdbTbUpsert(pData->pNewTtlIdx, &ttlKeyV1, sizeof(ttlKeyV1), &ttlDays, sizeof(ttlDays), pData->pMeta->txn);
|
code = tdbTbUpsert(pData->pNewTtlIdx, &ttlKeyV1, sizeof(ttlKeyV1), &ttlDays, sizeof(ttlDays), pData->pMeta->txn);
|
||||||
if (ret < 0) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
metaError("ttlMgr convert failed to upsert since %s", tstrerror(terrno));
|
metaError("ttlMgr convert failed to upsert since %s", tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t ttlMgrFindExpiredOneEntry(const void *pKey, int keyLen, const void *pVal, int valLen,
|
static int32_t ttlMgrFindExpiredOneEntry(const void *pKey, int keyLen, const void *pVal, int valLen,
|
||||||
|
@ -248,7 +244,10 @@ static int32_t ttlMgrFindExpiredOneEntry(const void *pKey, int keyLen, const voi
|
||||||
|
|
||||||
int c = ttlIdxKeyV1Cmpr(&pCtx->expiredKey, sizeof(pCtx->expiredKey), pKey, keyLen);
|
int c = ttlIdxKeyV1Cmpr(&pCtx->expiredKey, sizeof(pCtx->expiredKey), pKey, keyLen);
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
taosArrayPush(pCtx->pTbUids, &((STtlIdxKeyV1 *)pKey)->uid);
|
if (NULL == taosArrayPush(pCtx->pTbUids, &((STtlIdxKeyV1 *)pKey)->uid)) {
|
||||||
|
metaError("ttlMgr find expired failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
pCtx->count++;
|
pCtx->count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,16 +261,16 @@ static int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta) {
|
||||||
|
|
||||||
SConvertData cvData = {.pNewTtlIdx = pNewTtlIdx, .pMeta = meta};
|
SConvertData cvData = {.pNewTtlIdx = pNewTtlIdx, .pMeta = meta};
|
||||||
|
|
||||||
int ret = tdbTbTraversal(pOldTtlIdx, &cvData, ttlMgrConvertOneEntry);
|
int code = TSDB_CODE_SUCCESS;
|
||||||
if (ret < 0) {
|
if ((code = tdbTbTraversal(pOldTtlIdx, &cvData, ttlMgrConvertOneEntry)) != TSDB_CODE_SUCCESS) {
|
||||||
metaError("failed to convert since %s", tstrerror(terrno));
|
metaError("failed to convert since %s", tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
metaInfo("ttlMgr convert end.");
|
metaInfo("ttlMgr convert end.");
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrInsertTtl(STtlManger *pTtlMgr, const STtlUpdTtlCtx *updCtx) {
|
int32_t ttlMgrInsertTtl(STtlManger *pTtlMgr, const STtlUpdTtlCtx *updCtx) {
|
||||||
if (updCtx->ttlDays == 0) return 0;
|
if (updCtx->ttlDays == 0) return 0;
|
||||||
|
|
||||||
STtlCacheEntry cacheEntry = {.ttlDays = updCtx->ttlDays,
|
STtlCacheEntry cacheEntry = {.ttlDays = updCtx->ttlDays,
|
||||||
|
@ -280,56 +279,55 @@ int ttlMgrInsertTtl(STtlManger *pTtlMgr, const STtlUpdTtlCtx *updCtx) {
|
||||||
.changeTimeMsDirty = updCtx->changeTimeMs};
|
.changeTimeMsDirty = updCtx->changeTimeMs};
|
||||||
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT};
|
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT};
|
||||||
|
|
||||||
int ret = taosHashPut(pTtlMgr->pTtlCache, &updCtx->uid, sizeof(updCtx->uid), &cacheEntry, sizeof(cacheEntry));
|
int32_t code = taosHashPut(pTtlMgr->pTtlCache, &updCtx->uid, sizeof(updCtx->uid), &cacheEntry, sizeof(cacheEntry));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr insert failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr insert failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = taosHashPut(pTtlMgr->pDirtyUids, &updCtx->uid, sizeof(updCtx->uid), &dirtryEntry, sizeof(dirtryEntry));
|
code = taosHashPut(pTtlMgr->pDirtyUids, &updCtx->uid, sizeof(updCtx->uid), &dirtryEntry, sizeof(dirtryEntry));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr insert failed to update dirty uids since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr insert failed to update dirty uids since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttlMgrNeedFlush(pTtlMgr)) {
|
if (ttlMgrNeedFlush(pTtlMgr)) {
|
||||||
ttlMgrFlush(pTtlMgr, updCtx->pTxn);
|
(void)ttlMgrFlush(pTtlMgr, updCtx->pTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
metaTrace("%s, ttl mgr insert ttl, uid: %" PRId64 ", ctime: %" PRId64 ", ttlDays: %" PRId64, pTtlMgr->logPrefix,
|
metaTrace("%s, ttl mgr insert ttl, uid: %" PRId64 ", ctime: %" PRId64 ", ttlDays: %" PRId64, pTtlMgr->logPrefix,
|
||||||
updCtx->uid, updCtx->changeTimeMs, updCtx->ttlDays);
|
updCtx->uid, updCtx->changeTimeMs, updCtx->ttlDays);
|
||||||
|
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrDeleteTtl(STtlManger *pTtlMgr, const STtlDelTtlCtx *delCtx) {
|
int32_t ttlMgrDeleteTtl(STtlManger *pTtlMgr, const STtlDelTtlCtx *delCtx) {
|
||||||
if (delCtx->ttlDays == 0) return 0;
|
if (delCtx->ttlDays == 0) return 0;
|
||||||
|
|
||||||
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_DELETE};
|
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_DELETE};
|
||||||
|
|
||||||
int ret = taosHashPut(pTtlMgr->pDirtyUids, &delCtx->uid, sizeof(delCtx->uid), &dirtryEntry, sizeof(dirtryEntry));
|
int32_t code = taosHashPut(pTtlMgr->pDirtyUids, &delCtx->uid, sizeof(delCtx->uid), &dirtryEntry, sizeof(dirtryEntry));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr del failed to update dirty uids since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr del failed to update dirty uids since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttlMgrNeedFlush(pTtlMgr)) {
|
if (ttlMgrNeedFlush(pTtlMgr)) {
|
||||||
ttlMgrFlush(pTtlMgr, delCtx->pTxn);
|
(void)ttlMgrFlush(pTtlMgr, delCtx->pTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
metaTrace("%s, ttl mgr delete ttl, uid: %" PRId64, pTtlMgr->logPrefix, delCtx->uid);
|
metaTrace("%s, ttl mgr delete ttl, uid: %" PRId64, pTtlMgr->logPrefix, delCtx->uid);
|
||||||
|
TAOS_RETURN(code);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrUpdateChangeTime(STtlManger *pTtlMgr, const STtlUpdCtimeCtx *pUpdCtimeCtx) {
|
int32_t ttlMgrUpdateChangeTime(STtlManger *pTtlMgr, const STtlUpdCtimeCtx *pUpdCtimeCtx) {
|
||||||
int ret = 0;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
STtlCacheEntry *oldData = taosHashGet(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid));
|
STtlCacheEntry *oldData = taosHashGet(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid));
|
||||||
if (oldData == NULL) {
|
if (oldData == NULL) {
|
||||||
|
@ -342,43 +340,39 @@ int ttlMgrUpdateChangeTime(STtlManger *pTtlMgr, const STtlUpdCtimeCtx *pUpdCtime
|
||||||
.changeTimeMsDirty = pUpdCtimeCtx->changeTimeMs};
|
.changeTimeMsDirty = pUpdCtimeCtx->changeTimeMs};
|
||||||
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT};
|
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT};
|
||||||
|
|
||||||
ret = taosHashPut(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &cacheEntry, sizeof(cacheEntry));
|
code = taosHashPut(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &cacheEntry, sizeof(cacheEntry));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr update ctime failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr update ctime failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = taosHashPut(pTtlMgr->pDirtyUids, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &dirtryEntry,
|
code = taosHashPut(pTtlMgr->pDirtyUids, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &dirtryEntry,
|
||||||
sizeof(dirtryEntry));
|
sizeof(dirtryEntry));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr update ctime failed to update dirty uids since %s", pTtlMgr->logPrefix,
|
metaError("%s, ttlMgr update ctime failed to update dirty uids since %s", pTtlMgr->logPrefix,
|
||||||
tstrerror(terrno));
|
tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttlMgrNeedFlush(pTtlMgr)) {
|
if (ttlMgrNeedFlush(pTtlMgr)) {
|
||||||
ttlMgrFlush(pTtlMgr, pUpdCtimeCtx->pTxn);
|
(void)ttlMgrFlush(pTtlMgr, pUpdCtimeCtx->pTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
metaTrace("%s, ttl mgr update ctime, uid: %" PRId64 ", ctime: %" PRId64, pTtlMgr->logPrefix, pUpdCtimeCtx->uid,
|
metaTrace("%s, ttl mgr update ctime, uid: %" PRId64 ", ctime: %" PRId64, pTtlMgr->logPrefix, pUpdCtimeCtx->uid,
|
||||||
pUpdCtimeCtx->changeTimeMs);
|
pUpdCtimeCtx->changeTimeMs);
|
||||||
|
TAOS_RETURN(code);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrFindExpired(STtlManger *pTtlMgr, int64_t timePointMs, SArray *pTbUids, int32_t ttlDropMaxCount) {
|
int32_t ttlMgrFindExpired(STtlManger *pTtlMgr, int64_t timePointMs, SArray *pTbUids, int32_t ttlDropMaxCount) {
|
||||||
int ret = -1;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
STtlIdxKeyV1 ttlKey = {.deleteTimeMs = timePointMs, .uid = INT64_MAX};
|
STtlIdxKeyV1 ttlKey = {.deleteTimeMs = timePointMs, .uid = INT64_MAX};
|
||||||
STtlExpiredCtx expiredCtx = {
|
STtlExpiredCtx expiredCtx = {
|
||||||
.ttlDropMaxCount = ttlDropMaxCount, .count = 0, .expiredKey = ttlKey, .pTbUids = pTbUids};
|
.ttlDropMaxCount = ttlDropMaxCount, .count = 0, .expiredKey = ttlKey, .pTbUids = pTbUids};
|
||||||
ret = tdbTbTraversal(pTtlMgr->pTtlIdx, &expiredCtx, ttlMgrFindExpiredOneEntry);
|
TAOS_CHECK_GOTO(tdbTbTraversal(pTtlMgr->pTtlIdx, &expiredCtx, ttlMgrFindExpiredOneEntry), NULL, _out);
|
||||||
if (ret) {
|
|
||||||
goto _out;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t vIdx = 0;
|
size_t vIdx = 0;
|
||||||
for (size_t i = 0; i < pTbUids->size; i++) {
|
for (size_t i = 0; i < pTbUids->size; i++) {
|
||||||
|
@ -393,20 +387,20 @@ int ttlMgrFindExpired(STtlManger *pTtlMgr, int64_t timePointMs, SArray *pTbUids,
|
||||||
taosArrayPopTailBatch(pTbUids, pTbUids->size - vIdx);
|
taosArrayPopTailBatch(pTbUids, pTbUids->size - vIdx);
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ttlMgrNeedFlush(STtlManger *pTtlMgr) {
|
static bool ttlMgrNeedFlush(STtlManger *pTtlMgr) {
|
||||||
return pTtlMgr->flushThreshold > 0 && taosHashGetSize(pTtlMgr->pDirtyUids) > pTtlMgr->flushThreshold;
|
return pTtlMgr->flushThreshold > 0 && taosHashGetSize(pTtlMgr->pDirtyUids) > pTtlMgr->flushThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
|
int32_t ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
|
||||||
int64_t startNs = taosGetTimestampNs();
|
int64_t startNs = taosGetTimestampNs();
|
||||||
int64_t endNs = startNs;
|
int64_t endNs = startNs;
|
||||||
|
|
||||||
metaTrace("%s, ttl mgr flush start. dirty uids:%d", pTtlMgr->logPrefix, taosHashGetSize(pTtlMgr->pDirtyUids));
|
metaTrace("%s, ttl mgr flush start. dirty uids:%d", pTtlMgr->logPrefix, taosHashGetSize(pTtlMgr->pDirtyUids));
|
||||||
|
|
||||||
int ret = -1;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pTtlMgr->pDirtyUids, NULL);
|
void *pIter = taosHashIterate(pTtlMgr->pDirtyUids, NULL);
|
||||||
while (pIter != NULL) {
|
while (pIter != NULL) {
|
||||||
|
@ -415,8 +409,8 @@ int ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
|
||||||
|
|
||||||
STtlCacheEntry *cacheEntry = taosHashGet(pTtlMgr->pTtlCache, pUid, sizeof(*pUid));
|
STtlCacheEntry *cacheEntry = taosHashGet(pTtlMgr->pTtlCache, pUid, sizeof(*pUid));
|
||||||
if (cacheEntry == NULL) {
|
if (cacheEntry == NULL) {
|
||||||
metaError("%s, ttlMgr flush failed to get ttl cache since %s, uid: %" PRId64 ", type: %d", pTtlMgr->logPrefix,
|
metaError("%s, ttlMgr flush failed to get ttl cache, uid: %" PRId64 ", type: %d", pTtlMgr->logPrefix, *pUid,
|
||||||
tstrerror(terrno), *pUid, pEntry->type);
|
pEntry->type);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,26 +422,26 @@ int ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
|
||||||
|
|
||||||
if (pEntry->type == ENTRY_TYPE_UPSERT) {
|
if (pEntry->type == ENTRY_TYPE_UPSERT) {
|
||||||
// delete old key & upsert new key
|
// delete old key & upsert new key
|
||||||
tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn); // maybe first insert, ignore error
|
(void)tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn); // maybe first insert, ignore error
|
||||||
ret = tdbTbUpsert(pTtlMgr->pTtlIdx, &ttlKeyDirty, sizeof(ttlKeyDirty), &cacheEntry->ttlDaysDirty,
|
code = tdbTbUpsert(pTtlMgr->pTtlIdx, &ttlKeyDirty, sizeof(ttlKeyDirty), &cacheEntry->ttlDaysDirty,
|
||||||
sizeof(cacheEntry->ttlDaysDirty), pTxn);
|
sizeof(cacheEntry->ttlDaysDirty), pTxn);
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr flush failed to upsert since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr flush failed to upsert since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheEntry->ttlDays = cacheEntry->ttlDaysDirty;
|
cacheEntry->ttlDays = cacheEntry->ttlDaysDirty;
|
||||||
cacheEntry->changeTimeMs = cacheEntry->changeTimeMsDirty;
|
cacheEntry->changeTimeMs = cacheEntry->changeTimeMsDirty;
|
||||||
} else if (pEntry->type == ENTRY_TYPE_DELETE) {
|
} else if (pEntry->type == ENTRY_TYPE_DELETE) {
|
||||||
ret = tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn);
|
code = tdbTbDelete(pTtlMgr->pTtlIdx, &ttlKey, sizeof(ttlKey), pTxn);
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr flush failed to delete since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr flush failed to delete since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = taosHashRemove(pTtlMgr->pTtlCache, pUid, sizeof(*pUid));
|
code = taosHashRemove(pTtlMgr->pTtlCache, pUid, sizeof(*pUid));
|
||||||
if (ret < 0) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
metaError("%s, ttlMgr flush failed to remove cache since %s", pTtlMgr->logPrefix, tstrerror(terrno));
|
metaError("%s, ttlMgr flush failed to remove cache since %s", pTtlMgr->logPrefix, tstrerror(code));
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -457,16 +451,16 @@ int ttlMgrFlush(STtlManger *pTtlMgr, TXN *pTxn) {
|
||||||
|
|
||||||
void *pIterTmp = pIter;
|
void *pIterTmp = pIter;
|
||||||
pIter = taosHashIterate(pTtlMgr->pDirtyUids, pIterTmp);
|
pIter = taosHashIterate(pTtlMgr->pDirtyUids, pIterTmp);
|
||||||
taosHashRemove(pTtlMgr->pDirtyUids, pUid, sizeof(tb_uid_t));
|
(void)taosHashRemove(pTtlMgr->pDirtyUids, pUid, sizeof(tb_uid_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashClear(pTtlMgr->pDirtyUids);
|
taosHashClear(pTtlMgr->pDirtyUids);
|
||||||
|
|
||||||
ret = 0;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
endNs = taosGetTimestampNs();
|
endNs = taosGetTimestampNs();
|
||||||
metaTrace("%s, ttl mgr flush end, time consumed: %" PRId64 " ns", pTtlMgr->logPrefix, endNs - startNs);
|
metaTrace("%s, ttl mgr flush end, time consumed: %" PRId64 " ns", pTtlMgr->logPrefix, endNs - startNs);
|
||||||
|
|
||||||
return ret;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,35 +60,41 @@ static bool tqOffsetEqual(const STqOffset* pLeft, const STqOffset* pRight) {
|
||||||
pLeft->val.version == pRight->val.version;
|
pLeft->val.version == pRight->val.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode) {
|
int32_t tqOpen(const char* path, SVnode* pVnode) {
|
||||||
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
|
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
|
||||||
if (pTq == NULL) {
|
if (pTq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
pVnode->pTq = pTq;
|
||||||
pTq->path = taosStrdup(path);
|
pTq->path = taosStrdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
|
|
||||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
|
if (pTq->pHandle == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
taosHashSetFreeFp(pTq->pHandle, tqDestroyTqHandle);
|
taosHashSetFreeFp(pTq->pHandle, tqDestroyTqHandle);
|
||||||
|
|
||||||
taosInitRWLatch(&pTq->lock);
|
taosInitRWLatch(&pTq->lock);
|
||||||
|
|
||||||
pTq->pPushMgr = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
pTq->pPushMgr = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
||||||
|
if (pTq->pPushMgr == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
pTq->pCheckInfo = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
pTq->pCheckInfo = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||||
|
if (pTq->pCheckInfo == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
taosHashSetFreeFp(pTq->pCheckInfo, (FDelete)tDeleteSTqCheckInfo);
|
taosHashSetFreeFp(pTq->pCheckInfo, (FDelete)tDeleteSTqCheckInfo);
|
||||||
|
|
||||||
pTq->pOffset = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_ENTRY_LOCK);
|
pTq->pOffset = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_ENTRY_LOCK);
|
||||||
|
if (pTq->pOffset == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
taosHashSetFreeFp(pTq->pOffset, (FDelete)tDeleteSTqOffset);
|
taosHashSetFreeFp(pTq->pOffset, (FDelete)tDeleteSTqOffset);
|
||||||
|
|
||||||
int32_t code = tqInitialize(pTq);
|
return tqInitialize(pTq);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
tqClose(pTq);
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
return pTq;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqInitialize(STQ* pTq) {
|
int32_t tqInitialize(STQ* pTq) {
|
||||||
|
@ -102,11 +108,7 @@ int32_t tqInitialize(STQ* pTq) {
|
||||||
|
|
||||||
streamMetaLoadAllTasks(pTq->pStreamMeta);
|
streamMetaLoadAllTasks(pTq->pStreamMeta);
|
||||||
|
|
||||||
if (tqMetaOpen(pTq) < 0) {
|
return tqMetaOpen(pTq);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqClose(STQ* pTq) {
|
void tqClose(STQ* pTq) {
|
||||||
|
@ -150,25 +152,32 @@ void tqNotifyClose(STQ* pTq) {
|
||||||
streamMetaNotifyClose(pTq->pStreamMeta);
|
streamMetaNotifyClose(pTq->pStreamMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
|
int32_t code = 0;
|
||||||
SMqPollReq req = {0};
|
SMqPollReq req = {0};
|
||||||
if (tDeserializeSMqPollReq(pHandle->msg->pCont, pHandle->msg->contLen, &req) < 0) {
|
code = tDeserializeSMqPollReq(pHandle->msg->pCont, pHandle->msg->contLen, &req);
|
||||||
tqError("tDeserializeSMqPollReq %d failed", pHandle->msg->contLen);
|
if (code < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
tqError("tDeserializeSMqPollReq %d failed, code:%d", pHandle->msg->contLen, code);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||||
|
if (code != 0) {
|
||||||
|
tqError("tqInitDataRsp failed, code:%d", code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
dataRsp.common.blockNum = 0;
|
dataRsp.common.blockNum = 0;
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset);
|
||||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf,
|
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf,
|
||||||
req.reqId);
|
req.reqId);
|
||||||
|
|
||||||
tqSendDataRsp(pHandle, pHandle->msg, &req, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pHandle->msg, &req, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
if (code != 0) {
|
||||||
|
tqError("tqSendDataRsp failed, code:%d", code);
|
||||||
|
}
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||||
|
@ -176,8 +185,6 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq*
|
||||||
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(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type, sver, ever);
|
|
||||||
|
|
||||||
char buf1[TSDB_OFFSET_LEN] = {0};
|
char buf1[TSDB_OFFSET_LEN] = {0};
|
||||||
char buf2[TSDB_OFFSET_LEN] = {0};
|
char buf2[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
||||||
|
@ -186,7 +193,7 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq*
|
||||||
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
||||||
vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId);
|
vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId);
|
||||||
|
|
||||||
return 0;
|
return tqDoSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type, sver, ever);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
|
@ -217,8 +224,9 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
STqOffset* pSavedOffset = (STqOffset*)tqMetaGetOffset(pTq, pOffset->subKey);
|
STqOffset* pSavedOffset = NULL;
|
||||||
if (pSavedOffset != NULL && tqOffsetEqual(pOffset, pSavedOffset)) {
|
code = tqMetaGetOffset(pTq, pOffset->subKey, &pSavedOffset);
|
||||||
|
if (code == 0 && tqOffsetEqual(pOffset, pSavedOffset)) {
|
||||||
tqInfo("not update the offset, vgId:%d sub:%s since committed:%" PRId64 " less than/equal to existed:%" PRId64,
|
tqInfo("not update the offset, vgId:%d sub:%s since committed:%" PRId64 " less than/equal to existed:%" PRId64,
|
||||||
vgId, pOffset->subKey, pOffset->val.version, pSavedOffset->val.version);
|
vgId, pOffset->subKey, pOffset->val.version, pSavedOffset->val.version);
|
||||||
goto end; // no need to update the offset value
|
goto end; // no need to update the offset value
|
||||||
|
@ -328,7 +336,7 @@ int32_t tqProcessPollPush(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
.pCont = pHandle->msg->pCont,
|
.pCont = pHandle->msg->pCont,
|
||||||
.contLen = pHandle->msg->contLen,
|
.contLen = pHandle->msg->contLen,
|
||||||
.info = pHandle->msg->info};
|
.info = pHandle->msg->info};
|
||||||
tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
(void)tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||||
taosMemoryFree(pHandle->msg);
|
taosMemoryFree(pHandle->msg);
|
||||||
pHandle->msg = NULL;
|
pHandle->msg = NULL;
|
||||||
}
|
}
|
||||||
|
@ -434,18 +442,16 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
STqOffset* pSavedOffset = (STqOffset*)tqMetaGetOffset(pTq, vgOffset.offset.subKey);
|
STqOffset* pSavedOffset = NULL;
|
||||||
if (pSavedOffset == NULL) {
|
int32_t code = tqMetaGetOffset(pTq, vgOffset.offset.subKey, &pSavedOffset);
|
||||||
terrno = TSDB_CODE_TMQ_NO_COMMITTED;
|
if (code != 0) {
|
||||||
return terrno;
|
return TSDB_CODE_TMQ_NO_COMMITTED;
|
||||||
}
|
}
|
||||||
vgOffset.offset = *pSavedOffset;
|
vgOffset.offset = *pSavedOffset;
|
||||||
|
|
||||||
int32_t code = 0;
|
|
||||||
tEncodeSize(tEncodeMqVgOffset, &vgOffset, len, code);
|
tEncodeSize(tEncodeMqVgOffset, &vgOffset, len, code);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
return TAOS_GET_TERRNO(TSDB_CODE_INVALID_PARA);
|
||||||
return terrno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = rpcMallocCont(len);
|
void* buf = rpcMallocCont(len);
|
||||||
|
@ -455,8 +461,12 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
}
|
}
|
||||||
SEncoder encoder;
|
SEncoder encoder;
|
||||||
tEncoderInit(&encoder, buf, len);
|
tEncoderInit(&encoder, buf, len);
|
||||||
tEncodeMqVgOffset(&encoder, &vgOffset);
|
code = tEncodeMqVgOffset(&encoder, &vgOffset);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
if (code < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_INVALID_PARA);
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg rsp = {.info = pMsg->info, .pCont = buf, .contLen = len, .code = 0};
|
SRpcMsg rsp = {.info = pMsg->info, .pCont = buf, .contLen = len, .code = 0};
|
||||||
|
|
||||||
|
@ -465,11 +475,11 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
int32_t code = 0;
|
||||||
SMqPollReq req = {0};
|
SMqPollReq req = {0};
|
||||||
if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||||
tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen);
|
tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t consumerId = req.consumerId;
|
int64_t consumerId = req.consumerId;
|
||||||
|
@ -481,18 +491,17 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
|
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s not found", consumerId, vgId, req.subKey);
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s not found", consumerId, vgId, req.subKey);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
return -1;
|
return TSDB_CODE_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. check rebalance status
|
// 2. check rebalance status
|
||||||
if (pHandle->consumerId != consumerId) {
|
if (pHandle->consumerId != consumerId) {
|
||||||
tqDebug("ERROR consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
tqDebug("ERROR consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||||
consumerId, vgId, req.subKey, pHandle->consumerId);
|
consumerId, vgId, req.subKey, pHandle->consumerId);
|
||||||
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
return -1;
|
return TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
|
@ -500,13 +509,15 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.useSnapshot == true) {
|
if (req.useSnapshot == true) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
goto END;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
||||||
|
@ -514,13 +525,13 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||||
dataRsp.common.rspOffset.version = reqOffset.version;
|
dataRsp.common.rspOffset.version = reqOffset.version;
|
||||||
} else if (reqOffset.type < 0) {
|
} else if (reqOffset.type < 0) {
|
||||||
STqOffset* pOffset = (STqOffset*)(STqOffset*)tqMetaGetOffset(pTq, req.subKey);
|
STqOffset* pOffset = NULL;
|
||||||
if (pOffset != NULL) {
|
code = tqMetaGetOffset(pTq, req.subKey, &pOffset);
|
||||||
|
if (code == 0) {
|
||||||
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s, no valid wal info", consumerId, vgId, req.subKey);
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s, no valid wal info", consumerId, vgId, req.subKey);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
goto END;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.common.rspOffset.version = pOffset->val.version;
|
dataRsp.common.rspOffset.version = pOffset->val.version;
|
||||||
|
@ -538,14 +549,15 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
} else {
|
} else {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||||
reqOffset.type);
|
reqOffset.type);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
goto END;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDoSendDataRsp(&pMsg->info, &dataRsp, req.epoch, req.consumerId, TMQ_MSG_TYPE__WALINFO_RSP, sver, ever);
|
code = tqDoSendDataRsp(&pMsg->info, &dataRsp, req.epoch, req.consumerId, TMQ_MSG_TYPE__WALINFO_RSP, sver, ever);
|
||||||
|
|
||||||
|
END:
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
|
@ -568,9 +580,7 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
taosMsleep(10);
|
taosMsleep(10);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqUnregisterPushHandle(pTq, pHandle);
|
tqUnregisterPushHandle(pTq, pHandle);
|
||||||
|
|
||||||
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
|
||||||
|
@ -598,33 +608,25 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
|
|
||||||
int32_t tqProcessAddCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessAddCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
STqCheckInfo info = {0};
|
STqCheckInfo info = {0};
|
||||||
if(tqMetaDecodeCheckInfo(&info, msg, msgLen) != 0){
|
int32_t code = tqMetaDecodeCheckInfo(&info, msg, msgLen);
|
||||||
return -1;
|
if(code != 0){
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) {
|
code = taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo));
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
if (code != 0) {
|
||||||
tDeleteSTqCheckInfo(&info);
|
tDeleteSTqCheckInfo(&info);
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
if (tqMetaSaveInfo(pTq, pTq->pCheckStore, info.topic, strlen(info.topic), msg, msgLen) < 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
return tqMetaSaveInfo(pTq, pTq->pCheckStore, info.topic, strlen(info.topic), msg, msgLen);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
if (taosHashRemove(pTq->pCheckInfo, msg, strlen(msg)) < 0) {
|
if (taosHashRemove(pTq->pCheckInfo, msg, strlen(msg)) < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
if (tqMetaDeleteInfo(pTq, pTq->pCheckStore, msg, strlen(msg)) < 0) {
|
return tqMetaDeleteInfo(pTq, pTq->pCheckStore, msg, strlen(msg));
|
||||||
tqError("cannot process tq delete check info req %s, since no such check info", msg);
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -633,12 +635,10 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
|
||||||
tDecoderInit(&dc, (uint8_t*)msg, msgLen);
|
tDecoderInit(&dc, (uint8_t*)msg, msgLen);
|
||||||
|
ret = tDecodeSMqRebVgReq(&dc, &req);
|
||||||
// decode req
|
// decode req
|
||||||
if (tDecodeSMqRebVgReq(&dc, &req) < 0) {
|
if (ret < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
goto end;
|
||||||
tDecoderClear(&dc);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tqInfo("vgId:%d, tq process sub req:%s, Id:0x%" PRIx64 " -> Id:0x%" PRIx64, pTq->pVnode->config.vgId, req.subKey,
|
tqInfo("vgId:%d, tq process sub req:%s, Id:0x%" PRIx64 " -> Id:0x%" PRIx64, pTq->pVnode->config.vgId, req.subKey,
|
||||||
|
@ -777,18 +777,14 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) { return tqStreamTaskProcessCheckReq(pTq->pStreamMeta, pMsg); }
|
int32_t tqProcessTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
|
return tqStreamTaskProcessCheckReq(pTq->pStreamMeta, pMsg); }
|
||||||
|
|
||||||
int32_t tqProcessTaskCheckRsp(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessTaskCheckRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
return tqStreamTaskProcessCheckRsp(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
return tqStreamTaskProcessCheckRsp(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||||
// if (!pTq->pVnode->restored) {
|
|
||||||
// tqDebug("vgId:%d not restored, ignore the stream task deploy msg", TD_VID(pTq->pVnode));
|
|
||||||
// return TSDB_CODE_SUCCESS;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return tqStreamTaskProcessDeployReq(pTq->pStreamMeta, &pTq->pVnode->msgCb, sversion, msg, msgLen,
|
return tqStreamTaskProcessDeployReq(pTq->pStreamMeta, &pTq->pVnode->msgCb, sversion, msg, msgLen,
|
||||||
vnodeIsRoleLeader(pTq->pVnode), pTq->pVnode->restored);
|
vnodeIsRoleLeader(pTq->pVnode), pTq->pVnode->restored);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,13 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
||||||
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||||
pHandle->execHandle.execDb.pFilterOutTbUid =
|
pHandle->execHandle.execDb.pFilterOutTbUid =
|
||||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||||
|
if (pHandle->execHandle.execDb.pFilterOutTbUid == NULL) return -1;
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (tDecodeI32(pDecoder, &size) < 0) return -1;
|
if (tDecodeI32(pDecoder, &size) < 0) return -1;
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
int64_t tbUid = 0;
|
int64_t tbUid = 0;
|
||||||
if (tDecodeI64(pDecoder, &tbUid) < 0) return -1;
|
if (tDecodeI64(pDecoder, &tbUid) < 0) return -1;
|
||||||
taosHashPut(pHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
if (taosHashPut(pHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0) != 0) return -1;
|
||||||
}
|
}
|
||||||
} 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;
|
||||||
|
@ -79,11 +80,12 @@ int32_t tqMetaDecodeCheckInfo(STqCheckInfo* info, void* pVal, int32_t vLen) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||||
int32_t code = tDecodeSTqCheckInfo(&decoder, info);
|
int32_t code = tDecodeSTqCheckInfo(&decoder, info);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tDeleteSTqCheckInfo(info);
|
tDeleteSTqCheckInfo(info);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,11 +93,12 @@ int32_t tqMetaDecodeOffsetInfo(STqOffset* info, void* pVal, int32_t vLen) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||||
int32_t code = tDecodeSTqOffset(&decoder, info);
|
int32_t code = tDecodeSTqOffset(&decoder, info);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tDeleteSTqOffset(info);
|
tDeleteSTqOffset(info);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,32 +134,36 @@ END:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* tqMetaGetOffset(STQ* pTq, const char* subkey) {
|
int32_t tqMetaGetOffset(STQ* pTq, const char* subkey, STqOffset** pOffset){
|
||||||
void* data = taosHashGet(pTq->pOffset, subkey, strlen(subkey));
|
void* data = taosHashGet(pTq->pOffset, subkey, strlen(subkey));
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
if (tdbTbGet(pTq->pOffsetStore, subkey, strlen(subkey), &data, &vLen) < 0) {
|
if (tdbTbGet(pTq->pOffsetStore, subkey, strlen(subkey), &data, &vLen) < 0) {
|
||||||
tdbFree(data);
|
tdbFree(data);
|
||||||
return NULL;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
STqOffset offset = {0};
|
STqOffset offset = {0};
|
||||||
if (tqMetaDecodeOffsetInfo(&offset, data, vLen) != TDB_CODE_SUCCESS) {
|
if (tqMetaDecodeOffsetInfo(&offset, data, vLen) != TDB_CODE_SUCCESS) {
|
||||||
tdbFree(data);
|
tdbFree(data);
|
||||||
return NULL;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(pTq->pOffset, subkey, strlen(subkey), &offset, sizeof(STqOffset)) != 0) {
|
if (taosHashPut(pTq->pOffset, subkey, strlen(subkey), &offset, sizeof(STqOffset)) != 0) {
|
||||||
tDeleteSTqOffset(&offset);
|
tDeleteSTqOffset(&offset);
|
||||||
tdbFree(data);
|
tdbFree(data);
|
||||||
return NULL;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
tdbFree(data);
|
tdbFree(data);
|
||||||
|
|
||||||
return taosHashGet(pTq->pOffset, subkey, strlen(subkey));
|
*pOffset = taosHashGet(pTq->pOffset, subkey, strlen(subkey));
|
||||||
|
if(*pOffset == NULL){
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return data;
|
*pOffset = data;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
||||||
|
@ -199,10 +206,9 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
|
||||||
int32_t vgId = TD_VID(pVnode);
|
int32_t vgId = TD_VID(pVnode);
|
||||||
|
|
||||||
handle->pRef = walOpenRef(pVnode->pWal);
|
handle->pRef = walOpenRef(pVnode->pWal);
|
||||||
if (handle->pRef == NULL) {
|
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TQ_NULL_GO_TO_END(handle->pRef);
|
||||||
}
|
TQ_ERR_GO_TO_END(walSetRefVer(handle->pRef, handle->snapshotVer));
|
||||||
TQ_ERR_RETURN(walSetRefVer(handle->pRef, handle->snapshotVer));
|
|
||||||
|
|
||||||
SReadHandle reader = {
|
SReadHandle reader = {
|
||||||
.vnode = pVnode,
|
.vnode = pVnode,
|
||||||
|
@ -214,43 +220,36 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
|
||||||
initStorageAPI(&reader.api);
|
initStorageAPI(&reader.api);
|
||||||
|
|
||||||
if (handle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (handle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
handle->execHandle.task = qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId,
|
handle->execHandle.task =
|
||||||
&handle->execHandle.numOfCols, handle->consumerId);
|
qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId, &handle->execHandle.numOfCols, handle->consumerId);
|
||||||
if (handle->execHandle.task == NULL) {
|
TQ_NULL_GO_TO_END(handle->execHandle.task);
|
||||||
tqError("cannot create exec task for %s", handle->subKey);
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
void* scanner = NULL;
|
void* scanner = NULL;
|
||||||
(void)qExtractStreamScanner(handle->execHandle.task, &scanner);
|
qExtractStreamScanner(handle->execHandle.task, &scanner);
|
||||||
if (scanner == NULL) {
|
TQ_NULL_GO_TO_END(scanner);
|
||||||
tqError("cannot extract stream scanner for %s", handle->subKey);
|
|
||||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
handle->execHandle.pTqReader = qExtractReaderFromStreamScanner(scanner);
|
handle->execHandle.pTqReader = qExtractReaderFromStreamScanner(scanner);
|
||||||
if (handle->execHandle.pTqReader == NULL) {
|
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||||
tqError("cannot extract exec reader for %s", handle->subKey);
|
|
||||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||||
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
||||||
|
TQ_NULL_GO_TO_END(handle->pWalReader);
|
||||||
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
||||||
|
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||||
buildSnapContext(reader.vnode, reader.version, 0, handle->execHandle.subType, handle->fetchMeta,
|
TQ_ERR_GO_TO_END(buildSnapContext(reader.vnode, reader.version, 0, handle->execHandle.subType, handle->fetchMeta,
|
||||||
(SSnapContext**)(&reader.sContext));
|
(SSnapContext**)(&reader.sContext)));
|
||||||
handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId);
|
handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId);
|
||||||
|
TQ_NULL_GO_TO_END(handle->execHandle.task);
|
||||||
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
||||||
|
TQ_NULL_GO_TO_END(handle->pWalReader);
|
||||||
if (handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) {
|
if(handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) {
|
||||||
if (nodesStringToNode(handle->execHandle.execTb.qmsg, &handle->execHandle.execTb.node) != 0) {
|
if (nodesStringToNode(handle->execHandle.execTb.qmsg, &handle->execHandle.execTb.node) != 0) {
|
||||||
tqError("nodesStringToNode error in sub stable, since %s", terrstr());
|
tqError("nodesStringToNode error in sub stable, since %s", terrstr());
|
||||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildSnapContext(reader.vnode, reader.version, handle->execHandle.execTb.suid, handle->execHandle.subType,
|
TQ_ERR_GO_TO_END(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, handle->consumerId);
|
handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId);
|
||||||
|
TQ_NULL_GO_TO_END(handle->execHandle.task);
|
||||||
SArray* tbUidList = NULL;
|
SArray* tbUidList = NULL;
|
||||||
int ret = qGetTableList(handle->execHandle.execTb.suid, pVnode, handle->execHandle.execTb.node, &tbUidList,
|
int ret = qGetTableList(handle->execHandle.execTb.suid, pVnode, handle->execHandle.execTb.node, &tbUidList,
|
||||||
handle->execHandle.task);
|
handle->execHandle.task);
|
||||||
|
@ -262,10 +261,13 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
|
||||||
tqInfo("vgId:%d, tq try to get ctb for stb subscribe, suid:%" PRId64, pVnode->config.vgId,
|
tqInfo("vgId:%d, tq try to get ctb for stb subscribe, suid:%" PRId64, pVnode->config.vgId,
|
||||||
handle->execHandle.execTb.suid);
|
handle->execHandle.execTb.suid);
|
||||||
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
||||||
|
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||||
tqReaderSetTbUidList(handle->execHandle.pTqReader, tbUidList, NULL);
|
tqReaderSetTbUidList(handle->execHandle.pTqReader, tbUidList, NULL);
|
||||||
taosArrayDestroy(tbUidList);
|
taosArrayDestroy(tbUidList);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
END:
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqMetaRestoreHandle(STQ* pTq, void* pVal, int vLen, STqHandle* handle) {
|
static int32_t tqMetaRestoreHandle(STQ* pTq, void* pVal, int vLen, STqHandle* handle) {
|
||||||
|
@ -287,7 +289,7 @@ END:
|
||||||
int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
|
int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
|
|
||||||
memcpy(handle->subKey, req->subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
(void)memcpy(handle->subKey, req->subKey, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
handle->consumerId = req->newConsumerId;
|
handle->consumerId = req->newConsumerId;
|
||||||
|
|
||||||
handle->execHandle.subType = req->subType;
|
handle->execHandle.subType = req->subType;
|
||||||
|
@ -297,15 +299,19 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
|
||||||
} else if (req->subType == TOPIC_SUB_TYPE__DB) {
|
} else if (req->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
handle->execHandle.execDb.pFilterOutTbUid =
|
handle->execHandle.execDb.pFilterOutTbUid =
|
||||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||||
} else if (req->subType == TOPIC_SUB_TYPE__TABLE) {
|
if(handle->execHandle.execDb.pFilterOutTbUid == NULL){
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}else if(req->subType == TOPIC_SUB_TYPE__TABLE){
|
||||||
handle->execHandle.execTb.suid = req->suid;
|
handle->execHandle.execTb.suid = req->suid;
|
||||||
handle->execHandle.execTb.qmsg = taosStrdup(req->qmsg);
|
handle->execHandle.execTb.qmsg = taosStrdup(req->qmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->snapshotVer = walGetCommittedVer(pTq->pVnode->pWal);
|
handle->snapshotVer = walGetCommittedVer(pTq->pVnode->pWal);
|
||||||
|
|
||||||
if (tqMetaInitHandle(pTq, handle) < 0) {
|
int32_t code = tqMetaInitHandle(pTq, handle);
|
||||||
return -1;
|
if (code != 0){
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
tqInfo("tqMetaCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey,
|
tqInfo("tqMetaCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey,
|
||||||
handle->consumerId, vgId, handle->snapshotVer);
|
handle->consumerId, vgId, handle->snapshotVer);
|
||||||
|
@ -377,10 +383,12 @@ END:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t replaceTqPath(char** path) {
|
static int32_t replaceTqPath(char** path){
|
||||||
char* tpath = NULL;
|
char* tpath = NULL;
|
||||||
int32_t code = TDB_CODE_SUCCESS;
|
int32_t code = tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME);
|
||||||
TQ_ERR_RETURN(tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME));
|
if (code != 0){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
taosMemoryFree(*path);
|
taosMemoryFree(*path);
|
||||||
*path = tpath;
|
*path = tpath;
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
|
@ -407,7 +415,7 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
||||||
END:
|
END:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
tdbTbcClose(pCur);
|
(void)tdbTbcClose(pCur);
|
||||||
tDeleteSTqCheckInfo(&info);
|
tDeleteSTqCheckInfo(&info);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +488,7 @@ END:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaClose(STQ* pTq) {
|
void tqMetaClose(STQ* pTq) {
|
||||||
if (pTq->pExecStore) {
|
if (pTq->pExecStore) {
|
||||||
(void)tdbTbClose(pTq->pExecStore);
|
(void)tdbTbClose(pTq->pExecStore);
|
||||||
}
|
}
|
||||||
|
@ -491,5 +499,4 @@ int32_t tqMetaClose(STQ* pTq) {
|
||||||
(void)tdbTbClose(pTq->pOffsetStore);
|
(void)tdbTbClose(pTq->pOffsetStore);
|
||||||
}
|
}
|
||||||
(void)tdbClose(pTq->pMetaDB);
|
(void)tdbClose(pTq->pMetaDB);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,28 @@ int32_t tqProcessSubmitReqForSubscribe(STQ* pTq) {
|
||||||
}
|
}
|
||||||
SRpcMsg msg = {.msgType = TDMT_VND_TMQ_CONSUME_PUSH};
|
SRpcMsg msg = {.msgType = TDMT_VND_TMQ_CONSUME_PUSH};
|
||||||
msg.pCont = rpcMallocCont(sizeof(SMsgHead));
|
msg.pCont = rpcMallocCont(sizeof(SMsgHead));
|
||||||
|
if (msg.pCont == NULL) {
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
msg.contLen = sizeof(SMsgHead);
|
msg.contLen = sizeof(SMsgHead);
|
||||||
SMsgHead *pHead = msg.pCont;
|
SMsgHead *pHead = msg.pCont;
|
||||||
pHead->vgId = TD_VID(pTq->pVnode);
|
pHead->vgId = TD_VID(pTq->pVnode);
|
||||||
pHead->contLen = msg.contLen;
|
pHead->contLen = msg.contLen;
|
||||||
tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
int32_t code = tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||||
return 0;
|
if (code != 0){
|
||||||
|
tqError("vgId:%d failed to push msg to queue, code:%d", TD_VID(pTq->pVnode), code);
|
||||||
|
rpcFreeCont(msg.pCont);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) {
|
int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) {
|
||||||
|
int32_t code = 0;
|
||||||
if (msgType == TDMT_VND_SUBMIT) {
|
if (msgType == TDMT_VND_SUBMIT) {
|
||||||
tqProcessSubmitReqForSubscribe(pTq);
|
code = tqProcessSubmitReqForSubscribe(pTq);
|
||||||
|
if (code != 0){
|
||||||
|
tqError("vgId:%d failed to process submit request for subscribe, code:%d", TD_VID(pTq->pVnode), code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaRLock(pTq->pStreamMeta);
|
streamMetaRLock(pTq->pStreamMeta);
|
||||||
|
@ -46,10 +57,10 @@ int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) {
|
||||||
// 2. the vnode should be the leader.
|
// 2. the vnode should be the leader.
|
||||||
// 3. the stream is not suspended yet.
|
// 3. the stream is not suspended yet.
|
||||||
if ((!tsDisableStream) && (numOfTasks > 0)) {
|
if ((!tsDisableStream) && (numOfTasks > 0)) {
|
||||||
tqScanWalAsync(pTq, true);
|
code = tqScanWalAsync(pTq, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
|
int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
|
||||||
|
@ -58,43 +69,52 @@ int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
|
||||||
|
|
||||||
if (pHandle->msg == NULL) {
|
if (pHandle->msg == NULL) {
|
||||||
pHandle->msg = taosMemoryCalloc(1, sizeof(SRpcMsg));
|
pHandle->msg = taosMemoryCalloc(1, sizeof(SRpcMsg));
|
||||||
memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
if (pHandle->msg == NULL) {
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
(void)memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||||
pHandle->msg->pCont = rpcMallocCont(pMsg->contLen);
|
pHandle->msg->pCont = rpcMallocCont(pMsg->contLen);
|
||||||
|
if (pHandle->msg->pCont == NULL) {
|
||||||
|
taosMemoryFree(pHandle->msg);
|
||||||
|
pHandle->msg = NULL;
|
||||||
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// tqPushDataRsp(pHandle, vgId);
|
|
||||||
tqPushEmptyDataRsp(pHandle, vgId);
|
tqPushEmptyDataRsp(pHandle, vgId);
|
||||||
|
|
||||||
void* tmp = pHandle->msg->pCont;
|
void* tmp = pHandle->msg->pCont;
|
||||||
memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
(void)memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||||
pHandle->msg->pCont = tmp;
|
pHandle->msg->pCont = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pHandle->msg->pCont, pMsg->pCont, pMsg->contLen);
|
(void)memcpy(pHandle->msg->pCont, pMsg->pCont, pMsg->contLen);
|
||||||
pHandle->msg->contLen = pMsg->contLen;
|
pHandle->msg->contLen = pMsg->contLen;
|
||||||
int32_t ret = taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey), &pHandle, POINTER_BYTES);
|
int32_t ret = taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey), &pHandle, POINTER_BYTES);
|
||||||
tqDebug("vgId:%d data is over, ret:%d, consumerId:0x%" PRIx64 ", register to pHandle:%p, pCont:%p, len:%d", vgId, ret,
|
tqDebug("vgId:%d data is over, ret:%d, consumerId:0x%" PRIx64 ", register to pHandle:%p, pCont:%p, len:%d", vgId, ret,
|
||||||
pHandle->consumerId, pHandle, pHandle->msg->pCont, pHandle->msg->contLen);
|
pHandle->consumerId, pHandle, pHandle->msg->pCont, pHandle->msg->contLen);
|
||||||
return 0;
|
if (ret != 0) {
|
||||||
|
rpcFreeCont(pHandle->msg->pCont);
|
||||||
|
taosMemoryFree(pHandle->msg);
|
||||||
|
pHandle->msg = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tqUnregisterPushHandle(STQ* pTq, void *handle) {
|
void tqUnregisterPushHandle(STQ* pTq, void *handle) {
|
||||||
STqHandle *pHandle = (STqHandle*)handle;
|
STqHandle *pHandle = (STqHandle*)handle;
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
|
|
||||||
if(taosHashGetSize(pTq->pPushMgr) <= 0) {
|
if(taosHashGetSize(pTq->pPushMgr) <= 0) {
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
int32_t ret = taosHashRemove(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey));
|
int32_t ret = taosHashRemove(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey));
|
||||||
tqInfo("vgId:%d remove pHandle:%p,ret:%d consumer Id:0x%" PRIx64, vgId, pHandle, ret, pHandle->consumerId);
|
tqInfo("vgId:%d remove pHandle:%p,ret:%d consumer Id:0x%" PRIx64, vgId, pHandle, ret, pHandle->consumerId);
|
||||||
|
|
||||||
if(ret == 0 && pHandle->msg != NULL) {
|
if(ret == 0 && pHandle->msg != NULL) {
|
||||||
// tqPushDataRsp(pHandle, vgId);
|
|
||||||
tqPushEmptyDataRsp(pHandle, vgId);
|
tqPushEmptyDataRsp(pHandle, vgId);
|
||||||
|
|
||||||
rpcFreeCont(pHandle->msg->pCont);
|
rpcFreeCont(pHandle->msg->pCont);
|
||||||
taosMemoryFree(pHandle->msg);
|
taosMemoryFree(pHandle->msg);
|
||||||
pHandle->msg = NULL;
|
pHandle->msg = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,26 +27,26 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
|
|
||||||
int64_t tbSuid = pHandle->execHandle.execTb.suid;
|
int64_t tbSuid = pHandle->execHandle.execTb.suid;
|
||||||
int64_t realTbSuid = 0;
|
int64_t realTbSuid = 0;
|
||||||
SDecoder coder;
|
SDecoder dcoder = {0};
|
||||||
void* data = POINTER_SHIFT(body, sizeof(SMsgHead));
|
void* data = POINTER_SHIFT(body, sizeof(SMsgHead));
|
||||||
int32_t len = bodyLen - sizeof(SMsgHead);
|
int32_t len = bodyLen - sizeof(SMsgHead);
|
||||||
tDecoderInit(&coder, data, len);
|
tDecoderInit(&dcoder, data, len);
|
||||||
|
|
||||||
if (msgType == TDMT_VND_CREATE_STB || msgType == TDMT_VND_ALTER_STB) {
|
if (msgType == TDMT_VND_CREATE_STB || msgType == TDMT_VND_ALTER_STB) {
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
|
if (tDecodeSVCreateStbReq(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
realTbSuid = req.suid;
|
realTbSuid = req.suid;
|
||||||
} else if (msgType == TDMT_VND_DROP_STB) {
|
} else if (msgType == TDMT_VND_DROP_STB) {
|
||||||
SVDropStbReq req = {0};
|
SVDropStbReq req = {0};
|
||||||
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
|
if (tDecodeSVDropStbReq(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
realTbSuid = req.suid;
|
realTbSuid = req.suid;
|
||||||
} else if (msgType == TDMT_VND_CREATE_TABLE) {
|
} else if (msgType == TDMT_VND_CREATE_TABLE) {
|
||||||
SVCreateTbBatchReq req = {0};
|
SVCreateTbBatchReq req = {0};
|
||||||
if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) {
|
if (tDecodeSVCreateTbBatchReq(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,34 +66,42 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
realTbSuid = tbSuid;
|
realTbSuid = tbSuid;
|
||||||
SVCreateTbBatchReq reqNew = {0};
|
SVCreateTbBatchReq reqNew = {0};
|
||||||
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(struct SVCreateTbReq));
|
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(struct SVCreateTbReq));
|
||||||
|
if (reqNew.pArray == NULL) {
|
||||||
|
tDeleteSVCreateTbBatchReq(&req);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pCreateReq = req.pReqs + iReq;
|
pCreateReq = req.pReqs + iReq;
|
||||||
if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) {
|
if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) {
|
||||||
reqNew.nReqs++;
|
reqNew.nReqs++;
|
||||||
taosArrayPush(reqNew.pArray, pCreateReq);
|
if (taosArrayPush(reqNew.pArray, pCreateReq) == NULL){
|
||||||
|
taosArrayDestroy(reqNew.pArray);
|
||||||
|
tDeleteSVCreateTbBatchReq(&req);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlen;
|
int tlen = 0;
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret);
|
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret);
|
||||||
void* buf = taosMemoryMalloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
taosArrayDestroy(reqNew.pArray);
|
taosArrayDestroy(reqNew.pArray);
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
tDeleteSVCreateTbBatchReq(&req);
|
||||||
pCreateReq = req.pReqs + iReq;
|
|
||||||
taosMemoryFreeClear(pCreateReq->comment);
|
|
||||||
if (pCreateReq->type == TSDB_CHILD_TABLE) {
|
|
||||||
taosArrayDestroy(pCreateReq->ctb.tagName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
SEncoder coderNew = {0};
|
SEncoder coderNew = {0};
|
||||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||||
tEncodeSVCreateTbBatchReq(&coderNew, &reqNew);
|
ret = tEncodeSVCreateTbBatchReq(&coderNew, &reqNew);
|
||||||
tEncoderClear(&coderNew);
|
tEncoderClear(&coderNew);
|
||||||
memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
if (ret < 0) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
taosArrayDestroy(reqNew.pArray);
|
||||||
|
tDeleteSVCreateTbBatchReq(&req);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
(void)memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
||||||
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosArrayDestroy(reqNew.pArray);
|
taosArrayDestroy(reqNew.pArray);
|
||||||
|
@ -103,7 +111,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
} else if (msgType == TDMT_VND_ALTER_TABLE) {
|
} else if (msgType == TDMT_VND_ALTER_TABLE) {
|
||||||
SVAlterTbReq req = {0};
|
SVAlterTbReq req = {0};
|
||||||
|
|
||||||
if (tDecodeSVAlterTbReq(&coder, &req) < 0) {
|
if (tDecodeSVAlterTbReq(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +127,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
} else if (msgType == TDMT_VND_DROP_TABLE) {
|
} else if (msgType == TDMT_VND_DROP_TABLE) {
|
||||||
SVDropTbBatchReq req = {0};
|
SVDropTbBatchReq req = {0};
|
||||||
|
|
||||||
if (tDecodeSVDropTbBatchReq(&coder, &req) < 0) {
|
if (tDecodeSVDropTbBatchReq(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,15 +148,21 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
realTbSuid = tbSuid;
|
realTbSuid = tbSuid;
|
||||||
SVDropTbBatchReq reqNew = {0};
|
SVDropTbBatchReq reqNew = {0};
|
||||||
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq));
|
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq));
|
||||||
|
if (reqNew.pArray == NULL) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pDropReq = req.pReqs + iReq;
|
pDropReq = req.pReqs + iReq;
|
||||||
if (pDropReq->suid == tbSuid) {
|
if (pDropReq->suid == tbSuid) {
|
||||||
reqNew.nReqs++;
|
reqNew.nReqs++;
|
||||||
taosArrayPush(reqNew.pArray, pDropReq);
|
if (taosArrayPush(reqNew.pArray, pDropReq) == NULL){
|
||||||
|
taosArrayDestroy(reqNew.pArray);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlen;
|
int tlen = 0;
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret);
|
tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret);
|
||||||
void* buf = taosMemoryMalloc(tlen);
|
void* buf = taosMemoryMalloc(tlen);
|
||||||
|
@ -158,23 +172,28 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
||||||
}
|
}
|
||||||
SEncoder coderNew = {0};
|
SEncoder coderNew = {0};
|
||||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||||
tEncodeSVDropTbBatchReq(&coderNew, &reqNew);
|
ret = tEncodeSVDropTbBatchReq(&coderNew, &reqNew);
|
||||||
tEncoderClear(&coderNew);
|
tEncoderClear(&coderNew);
|
||||||
memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
if (ret != 0) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
taosArrayDestroy(reqNew.pArray);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
(void)memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
||||||
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosArrayDestroy(reqNew.pArray);
|
taosArrayDestroy(reqNew.pArray);
|
||||||
}
|
}
|
||||||
} else if (msgType == TDMT_VND_DELETE) {
|
} else if (msgType == TDMT_VND_DELETE) {
|
||||||
SDeleteRes req = {0};
|
SDeleteRes req = {0};
|
||||||
if (tDecodeDeleteRes(&coder, &req) < 0) {
|
if (tDecodeDeleteRes(&dcoder, &req) < 0) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
realTbSuid = req.suid;
|
realTbSuid = req.suid;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&dcoder);
|
||||||
return tbSuid == realTbSuid;
|
return tbSuid == realTbSuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,10 +261,10 @@ END:
|
||||||
|
|
||||||
bool tqGetTablePrimaryKey(STqReader* pReader) { return pReader->hasPrimaryKey; }
|
bool tqGetTablePrimaryKey(STqReader* pReader) { return pReader->hasPrimaryKey; }
|
||||||
|
|
||||||
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid) {
|
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid){
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
SSchemaWrapper* schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
SSchemaWrapper *schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
||||||
if (schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
|
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
tDeleteSchemaWrapper(schema);
|
tDeleteSchemaWrapper(schema);
|
||||||
|
@ -333,7 +352,7 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(data, pBody, len);
|
(void)memcpy(data, pBody, len);
|
||||||
SPackedData data1 = (SPackedData){.ver = ver, .msgLen = len, .msgStr = data};
|
SPackedData data1 = (SPackedData){.ver = ver, .msgLen = len, .msgStr = data};
|
||||||
|
|
||||||
code = streamDataSubmitNew(&data1, STREAM_INPUT__DATA_SUBMIT, (SStreamDataSubmit**)pItem);
|
code = streamDataSubmitNew(&data1, STREAM_INPUT__DATA_SUBMIT, (SStreamDataSubmit**)pItem);
|
||||||
|
@ -379,6 +398,11 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) {
|
||||||
pReader->msg.ver);
|
pReader->msg.ver);
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
if (pSubmitTbData == NULL) {
|
||||||
|
tqError("tq reader next data block %d/%d, len:%d %" PRId64, pReader->nextBlk, numOfBlocks, pReader->msg.msgLen,
|
||||||
|
pReader->msg.ver);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ((pSubmitTbData->flags & sourceExcluded) != 0) {
|
if ((pSubmitTbData->flags & sourceExcluded) != 0) {
|
||||||
pReader->nextBlk += 1;
|
pReader->nextBlk += 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -412,7 +436,9 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) {
|
||||||
void* pBody = POINTER_SHIFT(pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg));
|
void* pBody = POINTER_SHIFT(pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg));
|
||||||
int32_t bodyLen = pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg);
|
int32_t bodyLen = pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg);
|
||||||
int64_t ver = pWalReader->pHead->head.version;
|
int64_t ver = pWalReader->pHead->head.version;
|
||||||
tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver);
|
if (tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
pReader->nextBlk = 0;
|
pReader->nextBlk = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,13 +449,14 @@ int32_t tqReaderSetSubmitMsg(STqReader* pReader, void* msgStr, int32_t msgLen, i
|
||||||
pReader->msg.ver = ver;
|
pReader->msg.ver = ver;
|
||||||
|
|
||||||
tqDebug("tq reader set msg %p %d", msgStr, msgLen);
|
tqDebug("tq reader set msg %p %d", msgStr, msgLen);
|
||||||
SDecoder decoder;
|
SDecoder decoder = {0};
|
||||||
|
|
||||||
tDecoderInit(&decoder, pReader->msg.msgStr, pReader->msg.msgLen);
|
tDecoderInit(&decoder, pReader->msg.msgStr, pReader->msg.msgLen);
|
||||||
if (tDecodeSubmitReq(&decoder, &pReader->submit) < 0) {
|
int32_t code = tDecodeSubmitReq(&decoder, &pReader->submit);
|
||||||
|
if (code != 0) {
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
tqError("DecodeSSubmitReq2 error, msgLen:%d, ver:%" PRId64, msgLen, ver);
|
tqError("DecodeSSubmitReq2 error, msgLen:%d, ver:%" PRId64, msgLen, ver);
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -453,6 +480,9 @@ bool tqNextBlockImpl(STqReader* pReader, const char* idstr) {
|
||||||
(pReader->nextBlk + 1), numOfBlocks, idstr);
|
(pReader->nextBlk + 1), numOfBlocks, idstr);
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
if (pSubmitTbData == NULL){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (pReader->tbIdHash == NULL) {
|
if (pReader->tbIdHash == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -482,6 +512,7 @@ bool tqNextDataBlockFilterOut(STqReader* pReader, SHashObj* filterOutUids) {
|
||||||
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||||
while (pReader->nextBlk < blockSz) {
|
while (pReader->nextBlk < blockSz) {
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
if (pSubmitTbData == NULL) return false;
|
||||||
if (filterOutUids == NULL) return true;
|
if (filterOutUids == NULL) return true;
|
||||||
|
|
||||||
void* ret = taosHashGet(filterOutUids, &pSubmitTbData->uid, sizeof(int64_t));
|
void* ret = taosHashGet(filterOutUids, &pSubmitTbData->uid, sizeof(int64_t));
|
||||||
|
@ -499,7 +530,7 @@ bool tqNextDataBlockFilterOut(STqReader* pReader, SHashObj* filterOutUids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrapper* pSrc, char* mask) {
|
int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrapper* pSrc, char* mask) {
|
||||||
int32_t code;
|
int32_t code = 0;
|
||||||
|
|
||||||
int32_t cnt = 0;
|
int32_t cnt = 0;
|
||||||
for (int32_t i = 0; i < pSrc->nCols; i++) {
|
for (int32_t i = 0; i < pSrc->nCols; i++) {
|
||||||
|
@ -509,7 +540,7 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap
|
||||||
pDst->nCols = cnt;
|
pDst->nCols = cnt;
|
||||||
pDst->pSchema = taosMemoryCalloc(cnt, sizeof(SSchema));
|
pDst->pSchema = taosMemoryCalloc(cnt, sizeof(SSchema));
|
||||||
if (pDst->pSchema == NULL) {
|
if (pDst->pSchema == NULL) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t j = 0;
|
int32_t j = 0;
|
||||||
|
@ -520,7 +551,7 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap
|
||||||
createColumnInfoData(pSrc->pSchema[i].type, pSrc->pSchema[i].bytes, pSrc->pSchema[i].colId);
|
createColumnInfoData(pSrc->pSchema[i].type, pSrc->pSchema[i].bytes, pSrc->pSchema[i].colId);
|
||||||
code = blockDataAppendColInfo(pBlock, &colInfo);
|
code = blockDataAppendColInfo(pBlock, &colInfo);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,10 +587,13 @@ static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema,
|
||||||
SSchema* pColSchema = &pSchema->pSchema[i];
|
SSchema* pColSchema = &pSchema->pSchema[i];
|
||||||
col_id_t colIdSchema = pColSchema->colId;
|
col_id_t colIdSchema = pColSchema->colId;
|
||||||
|
|
||||||
col_id_t colIdNeed = *(col_id_t*)taosArrayGet(pColIdList, j);
|
col_id_t* pColIdNeed = (col_id_t*)taosArrayGet(pColIdList, j);
|
||||||
if (colIdSchema < colIdNeed) {
|
if (pColIdNeed == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (colIdSchema < *pColIdNeed) {
|
||||||
i++;
|
i++;
|
||||||
} else if (colIdSchema > colIdNeed) {
|
} else if (colIdSchema > *pColIdNeed) {
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
SColumnInfoData colInfo = createColumnInfoData(pColSchema->type, pColSchema->bytes, pColSchema->colId);
|
SColumnInfoData colInfo = createColumnInfoData(pColSchema->type, pColSchema->bytes, pColSchema->colId);
|
||||||
|
@ -583,7 +617,7 @@ static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SCol
|
||||||
char val[65535 + 2] = {0};
|
char val[65535 + 2] = {0};
|
||||||
if (COL_VAL_IS_VALUE(pColVal)) {
|
if (COL_VAL_IS_VALUE(pColVal)) {
|
||||||
if (pColVal->value.pData != NULL) {
|
if (pColVal->value.pData != NULL) {
|
||||||
memcpy(varDataVal(val), pColVal->value.pData, pColVal->value.nData);
|
(void)memcpy(varDataVal(val), pColVal->value.pData, pColVal->value.nData);
|
||||||
}
|
}
|
||||||
varDataSetLen(val, pColVal->value.nData);
|
varDataSetLen(val, pColVal->value.nData);
|
||||||
code = colDataSetVal(pColumnInfoData, rowIndex, val, false);
|
code = colDataSetVal(pColumnInfoData, rowIndex, val, false);
|
||||||
|
@ -599,8 +633,11 @@ 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) {
|
||||||
tqTrace("tq reader retrieve data block %p, index:%d", pReader->msg.msgStr, pReader->nextBlk);
|
tqTrace("tq reader retrieve data block %p, index:%d", pReader->msg.msgStr, pReader->nextBlk);
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
|
STSchema* pTSchema = NULL;
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk++);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk++);
|
||||||
|
TSDB_CHECK_NULL(pSubmitTbData, code, line, END, terrno);
|
||||||
SSDataBlock* pBlock = pReader->pResBlock;
|
SSDataBlock* pBlock = pReader->pResBlock;
|
||||||
*pRes = pBlock;
|
*pRes = pBlock;
|
||||||
|
|
||||||
|
@ -625,8 +662,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
"version %d, possibly dropped table",
|
"version %d, possibly dropped table",
|
||||||
vgId, suid, uid, pReader->cachedSchemaVer);
|
vgId, suid, uid, pReader->cachedSchemaVer);
|
||||||
pReader->cachedSchemaSuid = 0;
|
pReader->cachedSchemaSuid = 0;
|
||||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
return TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->cachedSchemaUid = uid;
|
pReader->cachedSchemaUid = uid;
|
||||||
|
@ -635,29 +671,23 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
|
|
||||||
ASSERT(pReader->cachedSchemaVer == pReader->pSchemaWrapper->version);
|
ASSERT(pReader->cachedSchemaVer == pReader->pSchemaWrapper->version);
|
||||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
if (blockDataGetNumOfCols(pBlock) == 0) {
|
||||||
int32_t code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
tqError("vgId:%d failed to build data block, code:%s", vgId, tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||||
SColData* pCol = taosArrayGet(pSubmitTbData->aCol, 0);
|
SColData* pCol = taosArrayGet(pSubmitTbData->aCol, 0);
|
||||||
|
TSDB_CHECK_NULL(pCol, code, line, END, terrno);
|
||||||
numOfRows = pCol->nVal;
|
numOfRows = pCol->nVal;
|
||||||
} else {
|
} else {
|
||||||
numOfRows = taosArrayGetSize(pSubmitTbData->aRowP);
|
numOfRows = taosArrayGetSize(pSubmitTbData->aRowP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockDataEnsureCapacity(pBlock, numOfRows) < 0) {
|
code = blockDataEnsureCapacity(pBlock, numOfRows);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBlock->info.rows = numOfRows;
|
pBlock->info.rows = numOfRows;
|
||||||
|
|
||||||
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
||||||
|
|
||||||
// convert and scan one block
|
// convert and scan one block
|
||||||
|
@ -668,7 +698,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
int32_t sourceIdx = 0;
|
int32_t sourceIdx = 0;
|
||||||
while (targetIdx < colActual) {
|
while (targetIdx < colActual) {
|
||||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
||||||
|
TSDB_CHECK_NULL(pColData, code, line, END, terrno);
|
||||||
if (sourceIdx >= numOfCols) {
|
if (sourceIdx >= numOfCols) {
|
||||||
tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols);
|
tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols);
|
||||||
colDataSetNNULL(pColData, 0, numOfRows);
|
colDataSetNNULL(pColData, 0, numOfRows);
|
||||||
|
@ -676,20 +706,17 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
||||||
SColVal colVal;
|
TSDB_CHECK_NULL(pCol, code, line, END, terrno);
|
||||||
|
SColVal colVal = {0};
|
||||||
tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual,
|
tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
|
||||||
sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
|
|
||||||
if (pCol->cid < pColData->info.colId) {
|
if (pCol->cid < pColData->info.colId) {
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
} else if (pCol->cid == pColData->info.colId) {
|
} else if (pCol->cid == pColData->info.colId) {
|
||||||
for (int32_t i = 0; i < pCol->nVal; i++) {
|
for (int32_t i = 0; i < pCol->nVal; i++) {
|
||||||
tColDataGetValue(pCol, i, &colVal);
|
tColDataGetValue(pCol, i, &colVal);
|
||||||
int32_t code = doSetVal(pColData, i, &colVal);
|
code = doSetVal(pColData, i, &colVal);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
targetIdx++;
|
targetIdx++;
|
||||||
|
@ -701,26 +728,28 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
} else {
|
} else {
|
||||||
SArray* pRows = pSubmitTbData->aRowP;
|
SArray* pRows = pSubmitTbData->aRowP;
|
||||||
SSchemaWrapper* pWrapper = pReader->pSchemaWrapper;
|
SSchemaWrapper* pWrapper = pReader->pSchemaWrapper;
|
||||||
STSchema* pTSchema = tBuildTSchema(pWrapper->pSchema, pWrapper->nCols, pWrapper->version);
|
pTSchema = tBuildTSchema(pWrapper->pSchema, pWrapper->nCols, pWrapper->version);
|
||||||
|
TSDB_CHECK_NULL(pTSchema, code, line, END, terrno);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
SRow* pRow = taosArrayGetP(pRows, i);
|
SRow* pRow = taosArrayGetP(pRows, i);
|
||||||
|
TSDB_CHECK_NULL(pRow, code, line, END, terrno);
|
||||||
int32_t sourceIdx = 0;
|
int32_t sourceIdx = 0;
|
||||||
|
|
||||||
for (int32_t j = 0; j < colActual; j++) {
|
for (int32_t j = 0; j < colActual; j++) {
|
||||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
||||||
|
TSDB_CHECK_NULL(pColData, code, line, END, terrno);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SColVal colVal;
|
SColVal colVal = {0};
|
||||||
tRowGet(pRow, pTSchema, sourceIdx, &colVal);
|
code = tRowGet(pRow, pTSchema, sourceIdx, &colVal);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
if (colVal.cid < pColData->info.colId) {
|
if (colVal.cid < pColData->info.colId) {
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
continue;
|
continue;
|
||||||
} else if (colVal.cid == pColData->info.colId) {
|
} else if (colVal.cid == pColData->info.colId) {
|
||||||
int32_t code = doSetVal(pColData, i, &colVal);
|
code = doSetVal(pColData, i, &colVal);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceIdx++;
|
sourceIdx++;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -731,17 +760,196 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pTSchema);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
END:
|
||||||
|
if (code != 0){
|
||||||
|
tqError("tqRetrieveDataBlock failed, line:%d, code:%d", line, code);
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pTSchema);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PROCESS_VAL \
|
||||||
|
if (curRow == 0) {\
|
||||||
|
assigned[j] = !COL_VAL_IS_NONE(&colVal);\
|
||||||
|
buildNew = true;\
|
||||||
|
} else {\
|
||||||
|
bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);\
|
||||||
|
if (currentRowAssigned != assigned[j]) {\
|
||||||
|
assigned[j] = currentRowAssigned;\
|
||||||
|
buildNew = true;\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SET_DATA \
|
||||||
|
if (colVal.cid < pColData->info.colId) {\
|
||||||
|
sourceIdx++;\
|
||||||
|
} else if (colVal.cid == pColData->info.colId) {\
|
||||||
|
TQ_ERR_GO_TO_END(doSetVal(pColData, curRow - lastRow, &colVal));\
|
||||||
|
sourceIdx++;\
|
||||||
|
targetIdx++;\
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t processBuildNew(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks,
|
||||||
|
SArray* schemas, SSchemaWrapper* pSchemaWrapper, char* assigned,
|
||||||
|
int32_t numOfRows, int32_t curRow, int32_t* lastRow){
|
||||||
|
int32_t code = 0;
|
||||||
|
SSchemaWrapper* pSW = NULL;
|
||||||
|
SSDataBlock* block = NULL;
|
||||||
|
if (taosArrayGetSize(blocks) > 0) {
|
||||||
|
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
||||||
|
TQ_NULL_GO_TO_END(pLastBlock);
|
||||||
|
pLastBlock->info.rows = curRow - *lastRow;
|
||||||
|
*lastRow = curRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
TQ_NULL_GO_TO_END(block);
|
||||||
|
|
||||||
|
pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
||||||
|
TQ_NULL_GO_TO_END(pSW);
|
||||||
|
|
||||||
|
TQ_ERR_GO_TO_END(tqMaskBlock(pSW, block, pSchemaWrapper, assigned));
|
||||||
|
tqTrace("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
|
||||||
|
(int32_t)taosArrayGetSize(block->pDataBlock));
|
||||||
|
|
||||||
|
block->info.id.uid = pSubmitTbData->uid;
|
||||||
|
block->info.version = pReader->msg.ver;
|
||||||
|
TQ_ERR_GO_TO_END(blockDataEnsureCapacity(block, numOfRows - curRow));
|
||||||
|
TQ_NULL_GO_TO_END(taosArrayPush(blocks, block));
|
||||||
|
TQ_NULL_GO_TO_END(taosArrayPush(schemas, &pSW));
|
||||||
|
pSW = NULL;
|
||||||
|
taosMemoryFreeClear(block);
|
||||||
|
|
||||||
|
END:
|
||||||
|
tDeleteSchemaWrapper(pSW);
|
||||||
|
blockDataFreeRes(block);
|
||||||
|
taosMemoryFree(block);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas){
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t curRow = 0;
|
||||||
|
int32_t lastRow = 0;
|
||||||
|
|
||||||
|
SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
|
||||||
|
char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols);
|
||||||
|
TQ_NULL_GO_TO_END(assigned);
|
||||||
|
|
||||||
|
SArray* pCols = pSubmitTbData->aCol;
|
||||||
|
SColData* pCol = taosArrayGet(pCols, 0);
|
||||||
|
TQ_NULL_GO_TO_END(pCol);
|
||||||
|
int32_t numOfRows = pCol->nVal;
|
||||||
|
int32_t numOfCols = taosArrayGetSize(pCols);
|
||||||
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
|
bool buildNew = false;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < numOfCols; j++) {
|
||||||
|
pCol = taosArrayGet(pCols, j);
|
||||||
|
TQ_NULL_GO_TO_END(pCol);
|
||||||
|
SColVal colVal = {0};
|
||||||
|
tColDataGetValue(pCol, i, &colVal);
|
||||||
|
PROCESS_VAL
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildNew) {
|
||||||
|
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows, curRow, &lastRow));
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
||||||
|
TQ_NULL_GO_TO_END(pBlock);
|
||||||
|
|
||||||
|
tqTrace("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
|
||||||
|
(int32_t)taosArrayGetSize(blocks));
|
||||||
|
|
||||||
|
int32_t targetIdx = 0;
|
||||||
|
int32_t sourceIdx = 0;
|
||||||
|
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
||||||
|
while (targetIdx < colActual) {
|
||||||
|
pCol = taosArrayGet(pCols, sourceIdx);
|
||||||
|
TQ_NULL_GO_TO_END(pCol);
|
||||||
|
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
||||||
|
TQ_NULL_GO_TO_END(pColData);
|
||||||
|
SColVal colVal = {0};
|
||||||
|
tColDataGetValue(pCol, i, &colVal);
|
||||||
|
SET_DATA
|
||||||
|
}
|
||||||
|
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
||||||
|
pLastBlock->info.rows = curRow - lastRow;
|
||||||
|
|
||||||
|
END:
|
||||||
|
taosMemoryFree(assigned);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqProcessRowData(STqReader* pReader, SSubmitTbData* pSubmitTbData, SArray* blocks, SArray* schemas){
|
||||||
|
int32_t code = 0;
|
||||||
|
STSchema* pTSchema = NULL;
|
||||||
|
|
||||||
|
SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
|
||||||
|
char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols);
|
||||||
|
TQ_NULL_GO_TO_END(assigned);
|
||||||
|
|
||||||
|
int32_t curRow = 0;
|
||||||
|
int32_t lastRow = 0;
|
||||||
|
SArray* pRows = pSubmitTbData->aRowP;
|
||||||
|
int32_t numOfRows = taosArrayGetSize(pRows);
|
||||||
|
pTSchema = tBuildTSchema(pSchemaWrapper->pSchema, pSchemaWrapper->nCols, pSchemaWrapper->version);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfRows; i++) {
|
||||||
|
bool buildNew = false;
|
||||||
|
SRow* pRow = taosArrayGetP(pRows, i);
|
||||||
|
TQ_NULL_GO_TO_END(pRow);
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < pTSchema->numOfCols; j++) {
|
||||||
|
SColVal colVal = {0};
|
||||||
|
TQ_ERR_GO_TO_END(tRowGet(pRow, pTSchema, j, &colVal));
|
||||||
|
PROCESS_VAL
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildNew) {
|
||||||
|
TQ_ERR_GO_TO_END(processBuildNew(pReader, pSubmitTbData, blocks, schemas, pSchemaWrapper, assigned, numOfRows, curRow, &lastRow));
|
||||||
|
}
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
||||||
|
TQ_NULL_GO_TO_END(pBlock);
|
||||||
|
|
||||||
|
tqTrace("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
|
||||||
|
(int32_t)taosArrayGetSize(blocks));
|
||||||
|
|
||||||
|
int32_t targetIdx = 0;
|
||||||
|
int32_t sourceIdx = 0;
|
||||||
|
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
||||||
|
while (targetIdx < colActual) {
|
||||||
|
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
||||||
|
SColVal colVal = {0};
|
||||||
|
TQ_ERR_GO_TO_END(tRowGet(pRow, pTSchema, sourceIdx, &colVal));
|
||||||
|
SET_DATA
|
||||||
|
}
|
||||||
|
|
||||||
|
curRow++;
|
||||||
|
}
|
||||||
|
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
||||||
|
pLastBlock->info.rows = curRow - lastRow;
|
||||||
|
|
||||||
|
END:
|
||||||
|
taosMemoryFreeClear(pTSchema);
|
||||||
|
taosMemoryFree(assigned);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor:
|
|
||||||
int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas, SSubmitTbData** pSubmitTbDataRet) {
|
int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas, SSubmitTbData** pSubmitTbDataRet) {
|
||||||
tqDebug("tq reader retrieve data block %p, %d", pReader->msg.msgStr, pReader->nextBlk);
|
tqDebug("tq reader retrieve data block %p, %d", pReader->msg.msgStr, pReader->nextBlk);
|
||||||
|
SSDataBlock* block = NULL;
|
||||||
|
|
||||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||||
|
if(pSubmitTbData == NULL){
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
pReader->nextBlk++;
|
pReader->nextBlk++;
|
||||||
|
|
||||||
if (pSubmitTbDataRet) {
|
if (pSubmitTbDataRet) {
|
||||||
|
@ -758,248 +966,57 @@ int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas
|
||||||
tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table",
|
tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table",
|
||||||
pReader->pWalReader->pWal->cfg.vgId, uid, pReader->cachedSchemaVer);
|
pReader->pWalReader->pWal->cfg.vgId, uid, pReader->cachedSchemaVer);
|
||||||
pReader->cachedSchemaSuid = 0;
|
pReader->cachedSchemaSuid = 0;
|
||||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
return TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
|
|
||||||
int32_t numOfRows = 0;
|
|
||||||
|
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||||
SArray* pCols = pSubmitTbData->aCol;
|
return tqProcessColData(pReader, pSubmitTbData, blocks, schemas);
|
||||||
SColData* pCol = taosArrayGet(pCols, 0);
|
|
||||||
numOfRows = pCol->nVal;
|
|
||||||
} else {
|
} else {
|
||||||
SArray* pRows = pSubmitTbData->aRowP;
|
return tqProcessRowData(pReader, pSubmitTbData, blocks, schemas);
|
||||||
numOfRows = taosArrayGetSize(pRows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t curRow = 0;
|
|
||||||
int32_t lastRow = 0;
|
|
||||||
char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols);
|
|
||||||
if (assigned == NULL) return -1;
|
|
||||||
|
|
||||||
// convert and scan one block
|
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
|
||||||
SArray* pCols = pSubmitTbData->aCol;
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pCols);
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
|
||||||
bool buildNew = false;
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfCols; j++) {
|
|
||||||
SColData* pCol = taosArrayGet(pCols, j);
|
|
||||||
SColVal colVal;
|
|
||||||
tColDataGetValue(pCol, i, &colVal);
|
|
||||||
if (curRow == 0) {
|
|
||||||
assigned[j] = !COL_VAL_IS_NONE(&colVal);
|
|
||||||
buildNew = true;
|
|
||||||
} else {
|
|
||||||
bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);
|
|
||||||
if (currentRowAssigned != assigned[j]) {
|
|
||||||
assigned[j] = currentRowAssigned;
|
|
||||||
buildNew = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildNew) {
|
|
||||||
if (taosArrayGetSize(blocks) > 0) {
|
|
||||||
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
|
||||||
pLastBlock->info.rows = curRow - lastRow;
|
|
||||||
lastRow = curRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock block = {0};
|
|
||||||
SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
|
||||||
if (pSW == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tqMaskBlock(pSW, &block, pSchemaWrapper, assigned) < 0) {
|
|
||||||
blockDataFreeRes(&block);
|
|
||||||
tDeleteSchemaWrapper(pSW);
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
tqTrace("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
|
|
||||||
(int32_t)taosArrayGetSize(block.pDataBlock));
|
|
||||||
|
|
||||||
block.info.id.uid = uid;
|
|
||||||
block.info.version = pReader->msg.ver;
|
|
||||||
if (blockDataEnsureCapacity(&block, numOfRows - curRow) < 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
blockDataFreeRes(&block);
|
|
||||||
tDeleteSchemaWrapper(pSW);
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
taosArrayPush(blocks, &block);
|
|
||||||
taosArrayPush(schemas, &pSW);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
|
||||||
|
|
||||||
tqTrace("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
|
|
||||||
(int32_t)taosArrayGetSize(blocks));
|
|
||||||
|
|
||||||
int32_t targetIdx = 0;
|
|
||||||
int32_t sourceIdx = 0;
|
|
||||||
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
|
||||||
while (targetIdx < colActual) {
|
|
||||||
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
|
||||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
|
||||||
SColVal colVal;
|
|
||||||
|
|
||||||
if (pCol->cid < pColData->info.colId) {
|
|
||||||
sourceIdx++;
|
|
||||||
} else if (pCol->cid == pColData->info.colId) {
|
|
||||||
tColDataGetValue(pCol, i, &colVal);
|
|
||||||
if (doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS) {
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
sourceIdx++;
|
|
||||||
targetIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
curRow++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SSchemaWrapper* pWrapper = pReader->pSchemaWrapper;
|
|
||||||
STSchema* pTSchema = tBuildTSchema(pWrapper->pSchema, pWrapper->nCols, pWrapper->version);
|
|
||||||
SArray* pRows = pSubmitTbData->aRowP;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRows; i++) {
|
|
||||||
SRow* pRow = taosArrayGetP(pRows, i);
|
|
||||||
bool buildNew = false;
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < pTSchema->numOfCols; j++) {
|
|
||||||
SColVal colVal;
|
|
||||||
tRowGet(pRow, pTSchema, j, &colVal);
|
|
||||||
if (curRow == 0) {
|
|
||||||
assigned[j] = !COL_VAL_IS_NONE(&colVal);
|
|
||||||
buildNew = true;
|
|
||||||
} else {
|
|
||||||
bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);
|
|
||||||
if (currentRowAssigned != assigned[j]) {
|
|
||||||
assigned[j] = currentRowAssigned;
|
|
||||||
buildNew = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildNew) {
|
|
||||||
if (taosArrayGetSize(blocks) > 0) {
|
|
||||||
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
|
||||||
pLastBlock->info.rows = curRow - lastRow;
|
|
||||||
lastRow = curRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock block = {0};
|
|
||||||
SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
|
||||||
if (pSW == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tqMaskBlock(pSW, &block, pSchemaWrapper, assigned) < 0) {
|
|
||||||
blockDataFreeRes(&block);
|
|
||||||
tDeleteSchemaWrapper(pSW);
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
tqTrace("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
|
|
||||||
(int32_t)taosArrayGetSize(block.pDataBlock));
|
|
||||||
|
|
||||||
block.info.id.uid = uid;
|
|
||||||
block.info.version = pReader->msg.ver;
|
|
||||||
if (blockDataEnsureCapacity(&block, numOfRows - curRow) < 0) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
blockDataFreeRes(&block);
|
|
||||||
tDeleteSchemaWrapper(pSW);
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
taosArrayPush(blocks, &block);
|
|
||||||
taosArrayPush(schemas, &pSW);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
|
||||||
|
|
||||||
tqTrace("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
|
|
||||||
(int32_t)taosArrayGetSize(blocks));
|
|
||||||
|
|
||||||
int32_t targetIdx = 0;
|
|
||||||
int32_t sourceIdx = 0;
|
|
||||||
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
|
||||||
while (targetIdx < colActual) {
|
|
||||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
|
||||||
SColVal colVal;
|
|
||||||
tRowGet(pRow, pTSchema, sourceIdx, &colVal);
|
|
||||||
|
|
||||||
if (colVal.cid < pColData->info.colId) {
|
|
||||||
sourceIdx++;
|
|
||||||
} else if (colVal.cid == pColData->info.colId) {
|
|
||||||
if (doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS) {
|
|
||||||
goto FAIL;
|
|
||||||
}
|
|
||||||
sourceIdx++;
|
|
||||||
targetIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
curRow++;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFreeClear(pTSchema);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
|
||||||
pLastBlock->info.rows = curRow - lastRow;
|
|
||||||
|
|
||||||
taosMemoryFree(assigned);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
FAIL:
|
|
||||||
taosMemoryFree(assigned);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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, const char* id) {
|
void tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList, const char* id) {
|
||||||
if (pReader->tbIdHash) {
|
if (pReader->tbIdHash) {
|
||||||
taosHashClear(pReader->tbIdHash);
|
taosHashClear(pReader->tbIdHash);
|
||||||
} else {
|
} else {
|
||||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||||
}
|
if (pReader->tbIdHash == NULL) {
|
||||||
|
tqError("s-task:%s failed to init hash table", id);
|
||||||
if (pReader->tbIdHash == NULL) {
|
return;
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
for (int i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||||
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
if (pKey && taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0) != 0) {
|
||||||
|
tqError("s-task:%s failed to add table uid:%" PRId64 " to hash", id, *pKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("s-task:%s %d tables are set to be queried target table", id, (int32_t)taosArrayGetSize(tbUidList));
|
tqDebug("s-task:%s %d tables are set to be queried target table", id, (int32_t)taosArrayGetSize(tbUidList));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tqReaderAddTbUidList(STqReader* pReader, const SArray* pTableUidList) {
|
void tqReaderAddTbUidList(STqReader* pReader, const SArray* pTableUidList) {
|
||||||
if (pReader->tbIdHash == NULL) {
|
if (pReader->tbIdHash == NULL) {
|
||||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||||
if (pReader->tbIdHash == NULL) {
|
if (pReader->tbIdHash == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
tqError("failed to init hash table");
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTables = taosArrayGetSize(pTableUidList);
|
int32_t numOfTables = taosArrayGetSize(pTableUidList);
|
||||||
for (int i = 0; i < numOfTables; i++) {
|
for (int i = 0; i < numOfTables; i++) {
|
||||||
int64_t* pKey = (int64_t*)taosArrayGet(pTableUidList, i);
|
int64_t* pKey = (int64_t*)taosArrayGet(pTableUidList, i);
|
||||||
taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0);
|
if (taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0) != 0) {
|
||||||
|
tqError("failed to add table uid:%" PRId64 " to hash", *pKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tqReaderIsQueriedTable(STqReader* pReader, uint64_t uid) {
|
bool tqReaderIsQueriedTable(STqReader* pReader, uint64_t uid) {
|
||||||
|
@ -1008,16 +1025,15 @@ bool tqReaderIsQueriedTable(STqReader* pReader, uint64_t uid) {
|
||||||
|
|
||||||
bool tqCurrentBlockConsumed(const STqReader* pReader) { return pReader->msg.msgStr == NULL; }
|
bool tqCurrentBlockConsumed(const STqReader* pReader) { return pReader->msg.msgStr == NULL; }
|
||||||
|
|
||||||
int tqReaderRemoveTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
void tqReaderRemoveTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||||
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
int64_t* pKey = (int64_t*)taosArrayGet(tbUidList, i);
|
||||||
taosHashRemove(pReader->tbIdHash, pKey, sizeof(int64_t));
|
if (pKey && taosHashRemove(pReader->tbIdHash, pKey, sizeof(int64_t)) != 0){
|
||||||
|
tqError("failed to remove table uid:%" PRId64 " from hash", *pKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo update the table list in wal reader
|
|
||||||
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
|
@ -1041,8 +1057,11 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
||||||
if (!isAdd) {
|
if (!isAdd) {
|
||||||
int32_t sz = taosArrayGetSize(tbUidList);
|
int32_t sz = taosArrayGetSize(tbUidList);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
int64_t* tbUid = (int64_t*)taosArrayGet(tbUidList, i);
|
||||||
taosHashPut(pTqHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
if (tbUid && taosHashPut(pTqHandle->execHandle.execDb.pFilterOutTbUid, tbUid, sizeof(int64_t), NULL, 0) != 0){
|
||||||
|
tqError("failed to add table uid:%" PRId64 " to hash", *tbUid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pTqHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
} else if (pTqHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
|
|
|
@ -30,8 +30,14 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
||||||
|
|
||||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||||
actualLen += sizeof(SRetrieveTableRspForTmq);
|
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen);
|
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen) == NULL){
|
||||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf);
|
taosMemoryFree(buf);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf) == NULL) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -39,9 +45,11 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
||||||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, void* pRsp) {
|
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, void* pRsp) {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
||||||
if (pSW == NULL) {
|
if (pSW == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockSchema, &pSW) == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockSchema, &pSW);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,15 +57,17 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
||||||
|
|
||||||
// TODO add reference to gurantee success
|
int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid);
|
||||||
if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) {
|
if (code < 0) {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < n; i++) {
|
for (int32_t i = 0; i < n; i++) {
|
||||||
char* tbName = taosStrdup(mr.me.name);
|
char* tbName = taosStrdup(mr.me.name);
|
||||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName);
|
if(taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName) == NULL){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -71,8 +81,7 @@ int32_t getDataBlock(qTaskInfo_t task, const STqHandle* pHandle, int32_t vgId, S
|
||||||
int32_t code = qExecTask(task, res, &ts);
|
int32_t code = qExecTask(task, res, &ts);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d, task exec error since %s", pHandle->consumerId, vgId, tstrerror(code));
|
tqError("consumer:0x%" PRIx64 " vgId:%d, task exec error since %s", pHandle->consumerId, vgId, tstrerror(code));
|
||||||
terrno = code;
|
return code;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq one task end executed, pDataBlock:%p", pHandle->consumerId, vgId, *res);
|
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq one task end executed, pDataBlock:%p", pHandle->consumerId, vgId, *res);
|
||||||
|
@ -82,22 +91,20 @@ int32_t getDataBlock(qTaskInfo_t task, const STqHandle* pHandle, int32_t vgId, S
|
||||||
int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset, const SMqPollReq* pRequest) {
|
int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset, const SMqPollReq* pRequest) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
int32_t totalRows = 0;
|
int32_t totalRows = 0;
|
||||||
|
|
||||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
qTaskInfo_t task = pExec->task;
|
qTaskInfo_t task = pExec->task;
|
||||||
|
|
||||||
if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) {
|
code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
||||||
return -1;
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
}
|
|
||||||
|
|
||||||
qStreamSetSourceExcluded(task, pRequest->sourceExcluded);
|
qStreamSetSourceExcluded(task, pRequest->sourceExcluded);
|
||||||
while (1) {
|
while (1) {
|
||||||
SSDataBlock* pDataBlock = NULL;
|
SSDataBlock* pDataBlock = NULL;
|
||||||
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
||||||
if (code != 0) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRequest->enableReplay) {
|
if (pRequest->enableReplay) {
|
||||||
if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type) && pHandle->block != NULL) {
|
if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type) && pHandle->block != NULL) {
|
||||||
|
@ -111,27 +118,23 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
STqOffsetVal offset = {0};
|
STqOffsetVal offset = {0};
|
||||||
qStreamExtractOffset(task, &offset);
|
qStreamExtractOffset(task, &offset);
|
||||||
pHandle->block = createOneDataBlock(pDataBlock, true);
|
pHandle->block = createOneDataBlock(pDataBlock, true);
|
||||||
|
TSDB_CHECK_NULL(pDataBlock, code, line, END, terrno);
|
||||||
pHandle->blockTime = offset.ts;
|
pHandle->blockTime = offset.ts;
|
||||||
tOffsetDestroy(&offset);
|
tOffsetDestroy(&offset);
|
||||||
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
||||||
if (code != 0) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tqAddBlockDataToRsp(pHandle->block, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
code = tqAddBlockDataToRsp(pHandle->block, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
tqError("vgId:%d, failed to add block to rsp msg", vgId);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRsp->common.blockNum++;
|
pRsp->common.blockNum++;
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
blockDataDestroy(pHandle->block);
|
blockDataDestroy(pHandle->block);
|
||||||
pHandle->block = NULL;
|
pHandle->block = NULL;
|
||||||
} else {
|
} else {
|
||||||
copyDataBlock(pHandle->block, pDataBlock);
|
code = copyDataBlock(pHandle->block, pDataBlock);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
STqOffsetVal offset = {0};
|
STqOffsetVal offset = {0};
|
||||||
qStreamExtractOffset(task, &offset);
|
qStreamExtractOffset(task, &offset);
|
||||||
pRsp->sleepTime = offset.ts - pHandle->blockTime;
|
pRsp->sleepTime = offset.ts - pHandle->blockTime;
|
||||||
|
@ -144,10 +147,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
tqError("vgId:%d, failed to add block to rsp msg", vgId);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRsp->common.blockNum++;
|
pRsp->common.blockNum++;
|
||||||
totalRows += pDataBlock->info.rows;
|
totalRows += pDataBlock->info.rows;
|
||||||
|
@ -160,15 +160,19 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
||||||
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
||||||
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
return 0;
|
END:
|
||||||
|
if ( code!= 0){
|
||||||
|
tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line, code);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* pOffset) {
|
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatchMetaRsp* pBatchMetaRsp, STqOffsetVal* pOffset) {
|
||||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
qTaskInfo_t task = pExec->task;
|
qTaskInfo_t task = pExec->task;
|
||||||
|
int code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
||||||
if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) {
|
if (code != 0) {
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rowCnt = 0;
|
int32_t rowCnt = 0;
|
||||||
|
@ -176,11 +180,10 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
SSDataBlock* pDataBlock = NULL;
|
SSDataBlock* pDataBlock = NULL;
|
||||||
uint64_t ts = 0;
|
uint64_t ts = 0;
|
||||||
tqDebug("tmqsnap task start to execute");
|
tqDebug("tmqsnap task start to execute");
|
||||||
int code = qExecTask(task, &pDataBlock, &ts);
|
code = qExecTask(task, &pDataBlock, &ts);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tqError("vgId:%d, task exec error since %s", pTq->pVnode->config.vgId, tstrerror(code));
|
tqError("vgId:%d, task exec error since %s", pTq->pVnode->config.vgId, tstrerror(code));
|
||||||
terrno = code;
|
return code;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
||||||
|
@ -190,24 +193,37 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
||||||
|
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
||||||
taosArrayPush(pRsp->common.blockTbName, &tbName);
|
if (taosArrayPush(pRsp->common.blockTbName, &tbName) == NULL){
|
||||||
|
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pRsp->common.withSchema) {
|
if (pRsp->common.withSchema) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
tqAddBlockSchemaToRsp(pExec, pRsp);
|
if (tqAddBlockSchemaToRsp(pExec, pRsp) != 0){
|
||||||
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
||||||
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
if(taosArrayPush(pRsp->common.blockSchema, &pSW) == NULL){
|
||||||
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
if (tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||||
pTq->pVnode->config.tsdbCfg.precision);
|
pTq->pVnode->config.tsdbCfg.precision) != 0) {
|
||||||
|
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pRsp->common.blockNum++;
|
pRsp->common.blockNum++;
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -222,7 +238,6 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
if (taosArrayGetSize(tmp->batchMetaReq) > 0) {
|
if (taosArrayGetSize(tmp->batchMetaReq) > 0) {
|
||||||
qStreamExtractOffset(task, &tmp->rspOffset);
|
qStreamExtractOffset(task, &tmp->rspOffset);
|
||||||
*pBatchMetaRsp = *tmp;
|
*pBatchMetaRsp = *tmp;
|
||||||
|
|
||||||
tqDebug("tmqsnap task get meta");
|
tqDebug("tmqsnap task get meta");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -248,150 +263,135 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void tqProcessSubData(STQ* pTq, STqHandle* pHandle, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded){
|
||||||
|
int32_t code = 0;
|
||||||
|
STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
|
STqReader* pReader = pExec->pTqReader;
|
||||||
|
SArray* pBlocks = NULL;
|
||||||
|
SArray* pSchemas = NULL;
|
||||||
|
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||||
|
if (pBlocks == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
pSchemas = taosArrayInit(0, sizeof(void*));
|
||||||
|
if(pSchemas == NULL){
|
||||||
|
code = terrno;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSubmitTbData* pSubmitTbDataRet = NULL;
|
||||||
|
code = tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas, &pSubmitTbDataRet);
|
||||||
|
if (code != 0) {
|
||||||
|
tqError("vgId:%d, failed to retrieve block", pTq->pVnode->config.vgId);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
if (pRsp->common.withTbName) {
|
||||||
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
|
code = tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks));
|
||||||
|
if (code != 0) {
|
||||||
|
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pHandle->fetchMeta != WITH_DATA && pSubmitTbDataRet->pCreateTbReq != NULL) {
|
||||||
|
if (pRsp->createTableNum == 0) {
|
||||||
|
pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
|
||||||
|
if (pRsp->createTableLen == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
|
||||||
|
if (pRsp->createTableReq == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t len = 0;
|
||||||
|
tEncodeSize(tEncodeSVCreateTbReq, pSubmitTbDataRet->pCreateTbReq, len, code);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
void* createReq = taosMemoryCalloc(1, len);
|
||||||
|
if (createReq == NULL){
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, createReq, len);
|
||||||
|
code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
if (code < 0) {
|
||||||
|
taosMemoryFree(createReq);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(pRsp->createTableLen, &len) == NULL){
|
||||||
|
taosMemoryFree(createReq);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(pRsp->createTableReq, &createReq) == NULL){
|
||||||
|
taosMemoryFree(createReq);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
pRsp->createTableNum++;
|
||||||
|
}
|
||||||
|
if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
|
||||||
|
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
||||||
|
if (pBlock == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||||
|
pTq->pVnode->config.tsdbCfg.precision) != 0){
|
||||||
|
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*totalRows += pBlock->info.rows;
|
||||||
|
blockDataFreeRes(pBlock);
|
||||||
|
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||||
|
if (taosArrayPush(pRsp->common.blockSchema, &pSW) == NULL){
|
||||||
|
tqError("vgId:%d, failed to add schema to rsp msg", pTq->pVnode->config.vgId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pRsp->common.blockNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pBlocks);
|
||||||
|
taosArrayDestroy(pSchemas);
|
||||||
|
return;
|
||||||
|
|
||||||
|
END:
|
||||||
|
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
|
||||||
|
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSchemaWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows,
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows,
|
||||||
int8_t sourceExcluded) {
|
int8_t sourceExcluded) {
|
||||||
STqExecHandle* pExec = &pHandle->execHandle;
|
STqExecHandle* pExec = &pHandle->execHandle;
|
||||||
SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
int32_t code = 0;
|
||||||
SArray* pSchemas = taosArrayInit(0, sizeof(void*));
|
STqReader* pReader = pExec->pTqReader;
|
||||||
|
code = tqReaderSetSubmitMsg(pReader, submit.msgStr, submit.msgLen, submit.ver);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
STqReader* pReader = pExec->pTqReader;
|
|
||||||
tqReaderSetSubmitMsg(pReader, submit.msgStr, submit.msgLen, submit.ver);
|
|
||||||
while (tqNextBlockImpl(pReader, NULL)) {
|
while (tqNextBlockImpl(pReader, NULL)) {
|
||||||
taosArrayClear(pBlocks);
|
tqProcessSubData(pTq, pHandle, pRsp, totalRows, sourceExcluded);
|
||||||
taosArrayClear(pSchemas);
|
|
||||||
SSubmitTbData* pSubmitTbDataRet = NULL;
|
|
||||||
if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) {
|
|
||||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_table;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
|
||||||
goto loop_table;
|
|
||||||
}
|
|
||||||
if (pRsp->common.withTbName) {
|
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
|
||||||
goto loop_table;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pHandle->fetchMeta != WITH_DATA && pSubmitTbDataRet->pCreateTbReq != NULL) {
|
|
||||||
if (pRsp->createTableNum == 0) {
|
|
||||||
pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
|
|
||||||
pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
uint32_t len = 0;
|
|
||||||
tEncodeSize(tEncodeSVCreateTbReq, pSubmitTbDataRet->pCreateTbReq, len, code);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
goto loop_table;
|
|
||||||
}
|
|
||||||
void* createReq = taosMemoryCalloc(1, len);
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, createReq, len);
|
|
||||||
code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq);
|
|
||||||
if (code < 0) {
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
taosMemoryFree(createReq);
|
|
||||||
goto loop_table;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayPush(pRsp->createTableLen, &len);
|
|
||||||
taosArrayPush(pRsp->createTableReq, &createReq);
|
|
||||||
pRsp->createTableNum++;
|
|
||||||
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
}
|
|
||||||
if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL) {
|
|
||||||
goto loop_table;
|
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
|
|
||||||
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
|
||||||
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
|
||||||
pTq->pVnode->config.tsdbCfg.precision);
|
|
||||||
*totalRows += pBlock->info.rows;
|
|
||||||
blockDataFreeRes(pBlock);
|
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
|
||||||
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
|
||||||
pRsp->common.blockNum++;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
loop_table:
|
|
||||||
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
|
|
||||||
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSchemaWrapper);
|
|
||||||
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
|
||||||
pSchemas = taosArrayInit(0, sizeof(void*));
|
|
||||||
}
|
}
|
||||||
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
STqReader* pReader = pExec->pTqReader;
|
|
||||||
tqReaderSetSubmitMsg(pReader, submit.msgStr, submit.msgLen, submit.ver);
|
|
||||||
while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) {
|
while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) {
|
||||||
taosArrayClear(pBlocks);
|
tqProcessSubData(pTq, pHandle, pRsp, totalRows, sourceExcluded);
|
||||||
taosArrayClear(pSchemas);
|
|
||||||
SSubmitTbData* pSubmitTbDataRet = NULL;
|
|
||||||
if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) {
|
|
||||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_db;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
|
||||||
goto loop_db;
|
|
||||||
}
|
|
||||||
if (pRsp->common.withTbName) {
|
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
|
||||||
goto loop_db;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pHandle->fetchMeta != WITH_DATA && pSubmitTbDataRet->pCreateTbReq != NULL) {
|
|
||||||
if (pRsp->createTableNum == 0) {
|
|
||||||
pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
|
|
||||||
pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
uint32_t len = 0;
|
|
||||||
tEncodeSize(tEncodeSVCreateTbReq, pSubmitTbDataRet->pCreateTbReq, len, code);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
goto loop_db;
|
|
||||||
}
|
|
||||||
void* createReq = taosMemoryCalloc(1, len);
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, createReq, len);
|
|
||||||
code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq);
|
|
||||||
if (code < 0) {
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
taosMemoryFree(createReq);
|
|
||||||
goto loop_db;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayPush(pRsp->createTableLen, &len);
|
|
||||||
taosArrayPush(pRsp->createTableReq, &createReq);
|
|
||||||
pRsp->createTableNum++;
|
|
||||||
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
}
|
|
||||||
if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL) {
|
|
||||||
goto loop_db;
|
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
|
|
||||||
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
|
||||||
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
|
||||||
pTq->pVnode->config.tsdbCfg.precision);
|
|
||||||
*totalRows += pBlock->info.rows;
|
|
||||||
blockDataFreeRes(pBlock);
|
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
|
||||||
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
|
||||||
pRsp->common.blockNum++;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
loop_db:
|
|
||||||
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
|
|
||||||
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSchemaWrapper);
|
|
||||||
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
|
||||||
pSchemas = taosArrayInit(0, sizeof(void*));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pBlocks);
|
|
||||||
taosArrayDestroy(pSchemas);
|
return code;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,14 +76,10 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapReaderClose(STqSnapReader** ppReader) {
|
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||||
int32_t code = 0;
|
(void)tdbTbcClose((*ppReader)->pCur);
|
||||||
|
|
||||||
tdbTbcClose((*ppReader)->pCur);
|
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
@ -99,14 +95,14 @@ int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
|
||||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||||
if (*ppData == NULL) {
|
if (*ppData == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||||
pHdr->type = pReader->type;
|
pHdr->type = pReader->type;
|
||||||
pHdr->size = vLen;
|
pHdr->size = vLen;
|
||||||
memcpy(pHdr->data, pVal, vLen);
|
(void)memcpy(pHdr->data, pVal, vLen);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
|
@ -131,20 +127,20 @@ struct STqSnapWriter {
|
||||||
|
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STqSnapWriter* pWriter;
|
STqSnapWriter* pWriter = NULL;
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||||
if (pWriter == NULL) {
|
if (pWriter == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pWriter->pTq = pTq;
|
pWriter->pTq = pTq;
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
||||||
code = -1;
|
if (code < 0) {
|
||||||
taosMemoryFree(pWriter);
|
taosMemoryFree(pWriter);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +160,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
(void)tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
@ -207,7 +203,8 @@ int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nD
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
STqCheckInfo info = {0};
|
STqCheckInfo info = {0};
|
||||||
if(tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)) != 0){
|
code = tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
|
if(code != 0){
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +214,7 @@ int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nD
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +224,8 @@ int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
|
|
||||||
STqOffset info = {0};
|
STqOffset info = {0};
|
||||||
if(tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)) != 0){
|
code = tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
|
if(code != 0){
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,16 +21,15 @@ static int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, c
|
||||||
const SMqBatchMetaRsp* pRsp, int32_t vgId);
|
const SMqBatchMetaRsp* pRsp, int32_t vgId);
|
||||||
|
|
||||||
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||||
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
|
||||||
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
|
||||||
|
|
||||||
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
||||||
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
||||||
|
|
||||||
if (pRsp->blockData == NULL || pRsp->blockDataLen == NULL) {
|
if (pRsp->blockData == NULL || pRsp->blockDataLen == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
||||||
|
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
||||||
pRsp->withTbName = 0;
|
pRsp->withTbName = 0;
|
||||||
pRsp->withSchema = false;
|
pRsp->withSchema = false;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -72,7 +71,7 @@ static int32_t tqInitTaosxRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||||
taosArrayDestroy(pRsp->blockSchema);
|
taosArrayDestroy(pRsp->blockSchema);
|
||||||
pRsp->blockSchema = NULL;
|
pRsp->blockSchema = NULL;
|
||||||
}
|
}
|
||||||
return -1;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,12 +80,13 @@ static int32_t tqInitTaosxRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||||
static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||||
SRpcMsg* pMsg, bool* pBlockReturned) {
|
SRpcMsg* pMsg, bool* pBlockReturned) {
|
||||||
uint64_t consumerId = pRequest->consumerId;
|
uint64_t consumerId = pRequest->consumerId;
|
||||||
STqOffset* pOffset = (STqOffset*)tqMetaGetOffset(pTq, pRequest->subKey);
|
STqOffset* pOffset = NULL;
|
||||||
|
int32_t code = tqMetaGetOffset(pTq, pRequest->subKey, &pOffset);
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
|
|
||||||
*pBlockReturned = false;
|
*pBlockReturned = false;
|
||||||
// In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value.
|
// In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value.
|
||||||
if (pOffset != NULL) {
|
if (code == 0) {
|
||||||
tOffsetCopy(pOffsetVal, &pOffset->val);
|
tOffsetCopy(pOffsetVal, &pOffset->val);
|
||||||
|
|
||||||
char formatBuf[TSDB_OFFSET_LEN] = {0};
|
char formatBuf[TSDB_OFFSET_LEN] = {0};
|
||||||
|
@ -116,10 +116,13 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||||
|
|
||||||
tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
code = tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
||||||
|
if (code != 0){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
||||||
pHandle->subKey, vgId, dataRsp.common.rspOffset.version);
|
pHandle->subKey, vgId, dataRsp.common.rspOffset.version);
|
||||||
int32_t code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
|
|
||||||
*pBlockReturned = true;
|
*pBlockReturned = true;
|
||||||
|
@ -128,8 +131,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
||||||
tqError("tmq poll: subkey:%s, no offset committed for consumer:0x%" PRIx64
|
tqError("tmq poll: subkey:%s, no offset committed for consumer:0x%" PRIx64
|
||||||
" in vg %d, subkey %s, reset none failed",
|
" in vg %d, subkey %s, reset none failed",
|
||||||
pHandle->subKey, consumerId, vgId, pRequest->subKey);
|
pHandle->subKey, consumerId, vgId, pRequest->subKey);
|
||||||
terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
return TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +145,13 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp.common, *pOffset);
|
int code = tqInitDataRsp(&dataRsp.common, *pOffset);
|
||||||
|
if (code != 0) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||||
int code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
||||||
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -201,17 +206,14 @@ static void tDeleteCommon(void* parm) {}
|
||||||
|
|
||||||
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||||
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
||||||
int code = 0;
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
STaosxRsp taosxRsp = {0};
|
||||||
STaosxRsp taosxRsp = {0};
|
SMqBatchMetaRsp btMetaRsp = {0};
|
||||||
SMqBatchMetaRsp btMetaRsp = {0};
|
int32_t code = 0;
|
||||||
tqInitTaosxRsp(&taosxRsp.common, *offset);
|
|
||||||
|
|
||||||
|
TQ_ERR_GO_TO_END(tqInitTaosxRsp(&taosxRsp.common, *offset));
|
||||||
if (offset->type != TMQ_OFFSET__LOG) {
|
if (offset->type != TMQ_OFFSET__LOG) {
|
||||||
if (tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset) < 0) {
|
TQ_ERR_GO_TO_END(tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset));
|
||||||
code = -1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayGetSize(btMetaRsp.batchMetaReq) > 0) {
|
if (taosArrayGetSize(btMetaRsp.batchMetaReq) > 0) {
|
||||||
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||||
|
@ -219,8 +221,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
",ts:%" PRId64,
|
",ts:%" PRId64,
|
||||||
pRequest->consumerId, pHandle->subKey, vgId, btMetaRsp.rspOffset.type, btMetaRsp.rspOffset.uid,
|
pRequest->consumerId, pHandle->subKey, vgId, btMetaRsp.rspOffset.type, btMetaRsp.rspOffset.uid,
|
||||||
btMetaRsp.rspOffset.ts);
|
btMetaRsp.rspOffset.ts);
|
||||||
tDeleteMqBatchMetaRsp(&btMetaRsp);
|
goto END;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
||||||
|
@ -229,7 +230,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
||||||
if (taosxRsp.common.blockNum > 0) {
|
if (taosxRsp.common.blockNum > 0) {
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
tOffsetCopy(offset, &taosxRsp.common.rspOffset);
|
tOffsetCopy(offset, &taosxRsp.common.rspOffset);
|
||||||
}
|
}
|
||||||
|
@ -249,15 +250,15 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
|
if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
|
||||||
if (totalMetaRows > 0) {
|
if (totalMetaRows > 0) {
|
||||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||||
ASSERT(totalRows == 0);
|
ASSERT(totalRows == 0);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWalCont* pHead = &pHandle->pWalReader->pHead->head;
|
SWalCont* pHead = &pHandle->pWalReader->pHead->head;
|
||||||
|
@ -271,7 +272,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pRequest->sourceExcluded & TD_REQ_FROM_TAOX) != 0) {
|
if ((pRequest->sourceExcluded & TD_REQ_FROM_TAOX) != 0) {
|
||||||
|
@ -295,12 +296,20 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
metaRsp.metaRspLen = pHead->bodyLen;
|
metaRsp.metaRspLen = pHead->bodyLen;
|
||||||
metaRsp.metaRsp = pHead->body;
|
metaRsp.metaRsp = pHead->body;
|
||||||
code = tqSendMetaPollRsp(pHandle, pMsg, pRequest, &metaRsp, vgId);
|
code = tqSendMetaPollRsp(pHandle, pMsg, pRequest, &metaRsp, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!btMetaRsp.batchMetaReq) {
|
if (!btMetaRsp.batchMetaReq) {
|
||||||
btMetaRsp.batchMetaReq = taosArrayInit(4, POINTER_BYTES);
|
btMetaRsp.batchMetaReq = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
if (btMetaRsp.batchMetaReq == NULL) {
|
||||||
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
btMetaRsp.batchMetaLen = taosArrayInit(4, sizeof(int32_t));
|
btMetaRsp.batchMetaLen = taosArrayInit(4, sizeof(int32_t));
|
||||||
|
if (btMetaRsp.batchMetaLen == NULL) {
|
||||||
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fetchVer++;
|
fetchVer++;
|
||||||
|
|
||||||
|
@ -316,30 +325,40 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
}
|
}
|
||||||
int32_t tLen = sizeof(SMqRspHead) + len;
|
int32_t tLen = sizeof(SMqRspHead) + len;
|
||||||
void* tBuf = taosMemoryCalloc(1, tLen);
|
void* tBuf = taosMemoryCalloc(1, tLen);
|
||||||
|
if (tBuf == NULL){
|
||||||
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
void* metaBuff = POINTER_SHIFT(tBuf, sizeof(SMqRspHead));
|
void* metaBuff = POINTER_SHIFT(tBuf, sizeof(SMqRspHead));
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, metaBuff, len);
|
tEncoderInit(&encoder, metaBuff, len);
|
||||||
code = tEncodeMqMetaRsp(&encoder, &tmpMetaRsp);
|
code = tEncodeMqMetaRsp(&encoder, &tmpMetaRsp);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tEncoderClear(&encoder);
|
|
||||||
tqError("tmq extract meta from log, tEncodeMqMetaRsp error");
|
tqError("tmq extract meta from log, tEncodeMqMetaRsp error");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
taosArrayPush(btMetaRsp.batchMetaReq, &tBuf);
|
if (taosArrayPush(btMetaRsp.batchMetaReq, &tBuf) == NULL){
|
||||||
taosArrayPush(btMetaRsp.batchMetaLen, &tLen);
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
totalMetaRows++;
|
goto END;
|
||||||
|
}
|
||||||
|
if (taosArrayPush(btMetaRsp.batchMetaLen, &tLen) == NULL){
|
||||||
|
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
if ((taosArrayGetSize(btMetaRsp.batchMetaReq) >= tmqRowSize) || (taosGetTimestampMs() - st > 1000)) {
|
if ((taosArrayGetSize(btMetaRsp.batchMetaReq) >= tmqRowSize) || (taosGetTimestampMs() - st > 1000)) {
|
||||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalMetaRows > 0) {
|
if (totalMetaRows > 0) {
|
||||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process data
|
// process data
|
||||||
|
@ -353,7 +372,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId,
|
tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId,
|
||||||
pRequest->subKey);
|
pRequest->subKey);
|
||||||
goto end;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||||
|
@ -361,14 +380,14 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, &taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
fetchVer++;
|
fetchVer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
END:
|
||||||
tDeleteMqBatchMetaRsp(&btMetaRsp);
|
tDeleteMqBatchMetaRsp(&btMetaRsp);
|
||||||
tDeleteSTaosxRsp(&taosxRsp);
|
tDeleteSTaosxRsp(&taosxRsp);
|
||||||
return code;
|
return code;
|
||||||
|
@ -423,12 +442,12 @@ int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SM
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
tEncodeSize(tEncodeMqBatchMetaRsp, pRsp, len, code);
|
tEncodeSize(tEncodeMqBatchMetaRsp, pRsp, len, code);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(code);
|
||||||
}
|
}
|
||||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||||
void* buf = rpcMallocCont(tlen);
|
void* buf = rpcMallocCont(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
|
@ -439,9 +458,12 @@ int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SM
|
||||||
|
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, abuf, len);
|
tEncoderInit(&encoder, abuf, len);
|
||||||
tEncodeMqBatchMetaRsp(&encoder, pRsp);
|
code = tEncodeMqBatchMetaRsp(&encoder, pRsp);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
if (code < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
|
SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
|
||||||
|
|
||||||
tmsgSendRsp(&resp);
|
tmsgSendRsp(&resp);
|
||||||
|
@ -457,12 +479,12 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
tEncodeSize(tEncodeMqMetaRsp, pRsp, len, code);
|
tEncodeSize(tEncodeMqMetaRsp, pRsp, len, code);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(code);
|
||||||
}
|
}
|
||||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||||
void* buf = rpcMallocCont(tlen);
|
void* buf = rpcMallocCont(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
|
@ -473,8 +495,12 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
||||||
|
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, abuf, len);
|
tEncoderInit(&encoder, abuf, len);
|
||||||
tEncodeMqMetaRsp(&encoder, pRsp);
|
code = tEncodeMqMetaRsp(&encoder, pRsp);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
if (code < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
|
SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
|
||||||
|
|
||||||
|
@ -497,13 +523,13 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||||
void* buf = rpcMallocCont(tlen);
|
void* buf = rpcMallocCont(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqRspHead* pHead = (SMqRspHead*)buf;
|
SMqRspHead* pHead = (SMqRspHead*)buf;
|
||||||
|
@ -515,12 +541,15 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp,
|
||||||
tEncoderInit(&encoder, abuf, len);
|
tEncoderInit(&encoder, abuf, len);
|
||||||
|
|
||||||
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
||||||
tEncodeMqDataRsp(&encoder, pRsp);
|
code = tEncodeMqDataRsp(&encoder, pRsp);
|
||||||
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||||
tEncodeSTaosxRsp(&encoder, pRsp);
|
code = tEncodeSTaosxRsp(&encoder, pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
if (code < 0) {
|
||||||
|
rpcFreeCont(buf);
|
||||||
|
return TAOS_GET_TERRNO(code);
|
||||||
|
}
|
||||||
SRpcMsg rsp = {.info = *pRpcHandleInfo, .pCont = buf, .contLen = tlen, .code = 0};
|
SRpcMsg rsp = {.info = *pRpcHandleInfo, .pCont = buf, .contLen = tlen, .code = 0};
|
||||||
|
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
|
@ -528,49 +557,61 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp,
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type) {
|
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type) {
|
||||||
int32_t code;
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
SDecoder* pCoder = &(SDecoder){0};
|
SDecoder* pCoder = &(SDecoder){0};
|
||||||
SDeleteRes* pRes = &(SDeleteRes){0};
|
SDeleteRes* pRes = &(SDeleteRes){0};
|
||||||
|
|
||||||
*pRefBlock = NULL;
|
*pRefBlock = NULL;
|
||||||
|
|
||||||
pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t));
|
pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t));
|
||||||
if (pRes->uidList == NULL) {
|
TSDB_CHECK_NULL(pRes->uidList, code, line, END, terrno)
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
tDecoderInit(pCoder, (uint8_t*)pData, len);
|
tDecoderInit(pCoder, (uint8_t*)pData, len);
|
||||||
tDecodeDeleteRes(pCoder, pRes);
|
code = tDecodeDeleteRes(pCoder, pRes);
|
||||||
tDecoderClear(pCoder);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
int32_t numOfTables = taosArrayGetSize(pRes->uidList);
|
int32_t numOfTables = taosArrayGetSize(pRes->uidList);
|
||||||
if (numOfTables == 0 || pRes->affectedRows == 0) {
|
if (numOfTables == 0 || pRes->affectedRows == 0) {
|
||||||
taosArrayDestroy(pRes->uidList);
|
goto END;
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
|
SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
|
||||||
blockDataEnsureCapacity(pDelBlock, numOfTables);
|
TSDB_CHECK_NULL(pDelBlock, code, line, END, terrno)
|
||||||
|
code = blockDataEnsureCapacity(pDelBlock, numOfTables);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
pDelBlock->info.rows = numOfTables;
|
pDelBlock->info.rows = numOfTables;
|
||||||
pDelBlock->info.version = ver;
|
pDelBlock->info.version = ver;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTables; i++) {
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
// start key column
|
// start key column
|
||||||
SColumnInfoData* pStartCol = taosArrayGet(pDelBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
SColumnInfoData* pStartCol = taosArrayGet(pDelBlock->pDataBlock, START_TS_COLUMN_INDEX);
|
||||||
colDataSetVal(pStartCol, i, (const char*)&pRes->skey, false); // end key column
|
TSDB_CHECK_NULL(pStartCol, code, line, END, terrno)
|
||||||
|
code = colDataSetVal(pStartCol, i, (const char*)&pRes->skey, false); // end key column
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
SColumnInfoData* pEndCol = taosArrayGet(pDelBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
SColumnInfoData* pEndCol = taosArrayGet(pDelBlock->pDataBlock, END_TS_COLUMN_INDEX);
|
||||||
colDataSetVal(pEndCol, i, (const char*)&pRes->ekey, false);
|
TSDB_CHECK_NULL(pEndCol, code, line, END, terrno)
|
||||||
|
code = colDataSetVal(pEndCol, i, (const char*)&pRes->ekey, false);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
// uid column
|
// uid column
|
||||||
SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX);
|
SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||||
int64_t* pUid = taosArrayGet(pRes->uidList, i);
|
TSDB_CHECK_NULL(pUidCol, code, line, END, terrno)
|
||||||
colDataSetVal(pUidCol, i, (const char*)pUid, false);
|
|
||||||
|
|
||||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX), i);
|
int64_t* pUid = taosArrayGet(pRes->uidList, i);
|
||||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX), i);
|
code = colDataSetVal(pUidCol, i, (const char*)pUid, false);
|
||||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX), i);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
void* tmp = taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX);
|
||||||
|
TSDB_CHECK_NULL(tmp, code, line, END, terrno)
|
||||||
|
colDataSetNULL(tmp, i);
|
||||||
|
tmp = taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
|
||||||
|
TSDB_CHECK_NULL(tmp, code, line, END, terrno)
|
||||||
|
colDataSetNULL(tmp, i);
|
||||||
|
tmp = taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
|
||||||
|
TSDB_CHECK_NULL(tmp, code, line, END, terrno)
|
||||||
|
colDataSetNULL(tmp, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pRes->uidList);
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
code = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0, pRefBlock);
|
code = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0, pRefBlock);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -587,7 +628,13 @@ int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void*
|
||||||
ASSERTS(0, "unknown type:%d", type);
|
ASSERTS(0, "unknown type:%d", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
END:
|
||||||
|
if (code != 0){
|
||||||
|
tqError("failed to extract delete data block, line:%d code:%d", line, code);
|
||||||
|
}
|
||||||
|
tDecoderClear(pCoder);
|
||||||
|
taosArrayDestroy(pRes->uidList);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished) {
|
int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished) {
|
||||||
|
@ -612,6 +659,9 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||||
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||||
|
if (pId == NULL){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (pId->streamId != streamId) {
|
if (pId->streamId != streamId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,8 +459,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
||||||
}
|
}
|
||||||
|
|
||||||
// sma required the tq is initialized before the vnode open
|
// sma required the tq is initialized before the vnode open
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode);
|
if (tqOpen(tdir, pVnode)) {
|
||||||
if (pVnode->pTq == NULL) {
|
|
||||||
vError("vgId:%d, failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d, failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,8 +370,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
goto _exit;
|
goto _exit;
|
||||||
} else {
|
} else {
|
||||||
pReader->tqHandleDone = 1;
|
pReader->tqHandleDone = 1;
|
||||||
code = tqSnapReaderClose(&pReader->pTqSnapReader);
|
tqSnapReaderClose(&pReader->pTqSnapReader);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pReader->tqCheckInfoDone) {
|
if (!pReader->tqCheckInfoDone) {
|
||||||
|
@ -387,8 +386,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
goto _exit;
|
goto _exit;
|
||||||
} else {
|
} else {
|
||||||
pReader->tqCheckInfoDone = 1;
|
pReader->tqCheckInfoDone = 1;
|
||||||
code = tqSnapReaderClose(&pReader->pTqCheckInfoReader);
|
tqSnapReaderClose(&pReader->pTqCheckInfoReader);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pReader->tqOffsetDone) {
|
if (!pReader->tqOffsetDone) {
|
||||||
|
@ -404,8 +402,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
goto _exit;
|
goto _exit;
|
||||||
} else {
|
} else {
|
||||||
pReader->tqOffsetDone = 1;
|
pReader->tqOffsetDone = 1;
|
||||||
code = tqSnapReaderClose(&pReader->pTqOffsetReader);
|
tqSnapReaderClose(&pReader->pTqOffsetReader);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -827,9 +827,7 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosCfgDynamicOptions(tsCfg, pStmt->config, false)) {
|
TAOS_CHECK_RETURN(taosCfgDynamicOptions(tsCfg, pStmt->config, false));
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
|
|
|
@ -470,11 +470,7 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
||||||
}
|
}
|
||||||
int32_t numOfQualifiedTables = taosArrayGetSize(qa);
|
int32_t numOfQualifiedTables = taosArrayGetSize(qa);
|
||||||
qDebug("%d qualified child tables added into stream scanner, %s", numOfQualifiedTables, id);
|
qDebug("%d qualified child tables added into stream scanner, %s", numOfQualifiedTables, id);
|
||||||
code = pTaskInfo->storageAPI.tqReaderFn.tqReaderAddTables(pScanInfo->tqReader, qa);
|
pTaskInfo->storageAPI.tqReaderFn.tqReaderAddTables(pScanInfo->tqReader, qa);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosArrayDestroy(qa);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool assignUid = false;
|
bool assignUid = false;
|
||||||
size_t bufLen = (pScanInfo->pGroupTags != NULL) ? getTableTagsBufLen(pScanInfo->pGroupTags) : 0;
|
size_t bufLen = (pScanInfo->pGroupTags != NULL) ? getTableTagsBufLen(pScanInfo->pGroupTags) : 0;
|
||||||
|
@ -528,7 +524,7 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
||||||
} else { // remove the table id in current list
|
} else { // remove the table id in current list
|
||||||
qDebug("%d remove child tables from the stream scanner, %s", (int32_t)taosArrayGetSize(tableIdList), id);
|
qDebug("%d remove child tables from the stream scanner, %s", (int32_t)taosArrayGetSize(tableIdList), id);
|
||||||
taosWLockLatch(&pTaskInfo->lock);
|
taosWLockLatch(&pTaskInfo->lock);
|
||||||
code = pTaskInfo->storageAPI.tqReaderFn.tqReaderRemoveTables(pScanInfo->tqReader, tableIdList);
|
pTaskInfo->storageAPI.tqReaderFn.tqReaderRemoveTables(pScanInfo->tqReader, tableIdList);
|
||||||
taosWUnLockLatch(&pTaskInfo->lock);
|
taosWUnLockLatch(&pTaskInfo->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,7 +954,7 @@ int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList) {
|
||||||
return getOperatorExplainExecInfo(pTaskInfo->pRoot, pExecInfoList);
|
return getOperatorExplainExecInfo(pTaskInfo->pRoot, pExecInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
void qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
SOperatorInfo* pOperator = pTaskInfo->pRoot;
|
SOperatorInfo* pOperator = pTaskInfo->pRoot;
|
||||||
|
|
||||||
|
@ -966,7 +962,7 @@ int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
||||||
uint16_t type = pOperator->operatorType;
|
uint16_t type = pOperator->operatorType;
|
||||||
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
*scanner = pOperator->info;
|
*scanner = pOperator->info;
|
||||||
return 0;
|
break;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(pOperator->numOfDownstream == 1);
|
ASSERT(pOperator->numOfDownstream == 1);
|
||||||
pOperator = pOperator->pDownstream[0];
|
pOperator = pOperator->pDownstream[0];
|
||||||
|
@ -1215,7 +1211,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
if (subType == TOPIC_SUB_TYPE__COLUMN && pOffset->type == TMQ_OFFSET__LOG) {
|
if (subType == TOPIC_SUB_TYPE__COLUMN && pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id);
|
pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id);
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
SStreamScanInfo* pInfo = pOperator->info;
|
SStreamScanInfo* pInfo = pOperator->info;
|
||||||
SStoreTqReader* pReaderAPI = &pTaskInfo->storageAPI.tqReaderFn;
|
SStoreTqReader* pReaderAPI = &pTaskInfo->storageAPI.tqReaderFn;
|
||||||
|
@ -1230,7 +1226,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
if (subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id);
|
pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id);
|
||||||
if (pOperator == NULL) {
|
if (pOperator == NULL) {
|
||||||
return -1;
|
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamScanInfo* pInfo = pOperator->info;
|
SStreamScanInfo* pInfo = pOperator->info;
|
||||||
|
@ -1245,9 +1241,10 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
SStoreTqReader* pReaderAPI = &pTaskInfo->storageAPI.tqReaderFn;
|
SStoreTqReader* pReaderAPI = &pTaskInfo->storageAPI.tqReaderFn;
|
||||||
SWalReader* pWalReader = pReaderAPI->tqReaderGetWalReader(pInfo->tqReader);
|
SWalReader* pWalReader = pReaderAPI->tqReaderGetWalReader(pInfo->tqReader);
|
||||||
walReaderVerifyOffset(pWalReader, pOffset);
|
walReaderVerifyOffset(pWalReader, pOffset);
|
||||||
if (pReaderAPI->tqReaderSeek(pInfo->tqReader, pOffset->version, id) < 0) {
|
code = pReaderAPI->tqReaderSeek(pInfo->tqReader, pOffset->version, id);
|
||||||
|
if (code < 0) {
|
||||||
qError("tqReaderSeek failed ver:%" PRId64 ", %s", pOffset->version, id);
|
qError("tqReaderSeek failed ver:%" PRId64 ", %s", pOffset->version, id);
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||||
// iterate all tables from tableInfoList, and retrieve rows from each table one-by-one
|
// iterate all tables from tableInfoList, and retrieve rows from each table one-by-one
|
||||||
|
@ -1262,15 +1259,14 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
|
|
||||||
if (uid == 0) {
|
if (uid == 0) {
|
||||||
if (numOfTables != 0) {
|
if (numOfTables != 0) {
|
||||||
STableKeyInfo* pTableInfo = tableListGetInfo(pTableListInfo, 0);
|
STableKeyInfo* tmp = tableListGetInfo(pTableListInfo, 0);
|
||||||
uid = pTableInfo->uid;
|
if (tmp) uid = tmp->uid;
|
||||||
ts = INT64_MIN;
|
ts = INT64_MIN;
|
||||||
pScanInfo->currentTable = 0;
|
pScanInfo->currentTable = 0;
|
||||||
} else {
|
} else {
|
||||||
taosRUnLockLatch(&pTaskInfo->lock);
|
taosRUnLockLatch(&pTaskInfo->lock);
|
||||||
qError("no table in table list, %s", id);
|
qError("no table in table list, %s", id);
|
||||||
terrno = TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
return TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pTaskInfo->storageAPI.tqReaderFn.tqSetTablePrimaryKey(pInfo->tqReader, uid);
|
pTaskInfo->storageAPI.tqReaderFn.tqSetTablePrimaryKey(pInfo->tqReader, uid);
|
||||||
|
@ -1290,8 +1286,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
} else {
|
} else {
|
||||||
qError("vgId:%d uid:%" PRIu64 " not found in table list, total:%d, index:%d %s", pTaskInfo->id.vgId, uid,
|
qError("vgId:%d uid:%" PRIu64 " not found in table list, total:%d, index:%d %s", pTaskInfo->id.vgId, uid,
|
||||||
numOfTables, pScanInfo->currentTable, id);
|
numOfTables, pScanInfo->currentTable, id);
|
||||||
terrno = TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
return TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo keyInfo = {.uid = uid};
|
STableKeyInfo keyInfo = {.uid = uid};
|
||||||
|
@ -1311,8 +1306,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
(void**)&pScanBaseInfo->dataReader, id, NULL);
|
(void**)&pScanBaseInfo->dataReader, id, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id);
|
qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id);
|
||||||
terrno = code;
|
return code;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("tsdb reader created with offset(snapshot) uid:%" PRId64 " ts:%" PRId64 " table index:%d, total:%d, %s",
|
qDebug("tsdb reader created with offset(snapshot) uid:%" PRId64 " ts:%" PRId64 " table index:%d, total:%d, %s",
|
||||||
|
@ -1337,8 +1331,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
pScanBaseInfo->cond.twindows.skey = oldSkey;
|
pScanBaseInfo->cond.twindows.skey = oldSkey;
|
||||||
} else {
|
} else {
|
||||||
qError("invalid pOffset->type:%d, %s", pOffset->type, id);
|
qError("invalid pOffset->type:%d, %s", pOffset->type, id);
|
||||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // subType == TOPIC_SUB_TYPE__TABLE/TOPIC_SUB_TYPE__DB
|
} else { // subType == TOPIC_SUB_TYPE__TABLE/TOPIC_SUB_TYPE__DB
|
||||||
|
@ -1351,11 +1344,14 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
|
|
||||||
if (pAPI->snapshotFn.setForSnapShot(sContext, pOffset->uid) != 0) {
|
if (pAPI->snapshotFn.setForSnapShot(sContext, pOffset->uid) != 0) {
|
||||||
qError("setDataForSnapShot error. uid:%" PRId64 " , %s", pOffset->uid, id);
|
qError("setDataForSnapShot error. uid:%" PRId64 " , %s", pOffset->uid, id);
|
||||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SMetaTableInfo mtInfo = pTaskInfo->storageAPI.snapshotFn.getMetaTableInfoFromSnapshot(sContext);
|
SMetaTableInfo mtInfo = {0};
|
||||||
|
code = pTaskInfo->storageAPI.snapshotFn.getMetaTableInfoFromSnapshot(sContext, &mtInfo);
|
||||||
|
if (code != 0){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
pTaskInfo->storageAPI.tsdReader.tsdReaderClose(pInfo->dataReader);
|
pTaskInfo->storageAPI.tsdReader.tsdReaderClose(pInfo->dataReader);
|
||||||
pInfo->dataReader = NULL;
|
pInfo->dataReader = NULL;
|
||||||
|
|
||||||
|
@ -1363,6 +1359,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
tableListClear(pTableListInfo);
|
tableListClear(pTableListInfo);
|
||||||
|
|
||||||
if (mtInfo.uid == 0) {
|
if (mtInfo.uid == 0) {
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
goto end; // no data
|
goto end; // no data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1370,6 +1367,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
code = initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
code = initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (pAPI->snapshotFn.taosXGetTablePrimaryKey(sContext)) {
|
if (pAPI->snapshotFn.taosXGetTablePrimaryKey(sContext)) {
|
||||||
|
@ -1380,6 +1378,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
|
|
||||||
code = tableListAddTableInfo(pTableListInfo, mtInfo.uid, 0);
|
code = tableListAddTableInfo(pTableListInfo, mtInfo.uid, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1391,11 +1390,12 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
NULL, (void**)&pInfo->dataReader, NULL, NULL);
|
NULL, (void**)&pInfo->dataReader, NULL, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
||||||
strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName);
|
tstrncpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
tDeleteSchemaWrapper(pTaskInfo->streamInfo.schema);
|
tDeleteSchemaWrapper(pTaskInfo->streamInfo.schema);
|
||||||
pTaskInfo->streamInfo.schema = mtInfo.schema;
|
pTaskInfo->streamInfo.schema = mtInfo.schema;
|
||||||
|
|
||||||
|
@ -1403,10 +1403,10 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) {
|
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||||
SStreamRawScanInfo* pInfo = pOperator->info;
|
SStreamRawScanInfo* pInfo = pOperator->info;
|
||||||
SSnapContext* sContext = pInfo->sContext;
|
SSnapContext* sContext = pInfo->sContext;
|
||||||
if (pTaskInfo->storageAPI.snapshotFn.setForSnapShot(sContext, pOffset->uid) != 0) {
|
code = pTaskInfo->storageAPI.snapshotFn.setForSnapShot(sContext, pOffset->uid);
|
||||||
|
if (code != 0) {
|
||||||
qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version);
|
qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version);
|
||||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
return code;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64 " %s", pOffset->uid, pOffset->ts,
|
qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64 " %s", pOffset->uid, pOffset->ts,
|
||||||
id);
|
id);
|
||||||
|
|
|
@ -3457,7 +3457,13 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SMetaTableInfo mtInfo = pAPI->snapshotFn.getMetaTableInfoFromSnapshot(pInfo->sContext);
|
SMetaTableInfo mtInfo = {0};
|
||||||
|
code = pAPI->snapshotFn.getMetaTableInfoFromSnapshot(pInfo->sContext, &mtInfo);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
if (code != 0) {
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
STqOffsetVal offset = {0};
|
STqOffsetVal offset = {0};
|
||||||
if (mtInfo.uid == 0 || pInfo->sContext->withMeta == ONLY_META) { // read snapshot done, change to get data from wal
|
if (mtInfo.uid == 0 || pInfo->sContext->withMeta == ONLY_META) { // read snapshot done, change to get data from wal
|
||||||
qDebug("tmqsnap read snapshot done, change to get data from wal");
|
qDebug("tmqsnap read snapshot done, change to get data from wal");
|
||||||
|
@ -3467,9 +3473,9 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
||||||
tqOffsetResetToData(&offset, mtInfo.uid, INT64_MIN, val);
|
tqOffsetResetToData(&offset, mtInfo.uid, INT64_MIN, val);
|
||||||
qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid);
|
qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid);
|
||||||
}
|
}
|
||||||
|
tDeleteSchemaWrapper(mtInfo.schema);
|
||||||
code = qStreamPrepareScan(pTaskInfo, &offset, pInfo->sContext->subType);
|
code = qStreamPrepareScan(pTaskInfo, &offset, pInfo->sContext->subType);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
tDeleteSchemaWrapper(mtInfo.schema);
|
|
||||||
(*ppRes) = NULL;
|
(*ppRes) = NULL;
|
||||||
return code;
|
return code;
|
||||||
} else if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_META) {
|
} else if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||||
|
@ -3560,7 +3566,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
|
||||||
static void destroyRawScanOperatorInfo(void* param) {
|
static void destroyRawScanOperatorInfo(void* param) {
|
||||||
SStreamRawScanInfo* pRawScan = (SStreamRawScanInfo*)param;
|
SStreamRawScanInfo* pRawScan = (SStreamRawScanInfo*)param;
|
||||||
pRawScan->pAPI->tsdReader.tsdReaderClose(pRawScan->dataReader);
|
pRawScan->pAPI->tsdReader.tsdReaderClose(pRawScan->dataReader);
|
||||||
(void)pRawScan->pAPI->snapshotFn.destroySnapshot(pRawScan->sContext);
|
pRawScan->pAPI->snapshotFn.destroySnapshot(pRawScan->sContext);
|
||||||
tableListDestroy(pRawScan->pTableListInfo);
|
tableListDestroy(pRawScan->pTableListInfo);
|
||||||
taosMemoryFree(pRawScan);
|
taosMemoryFree(pRawScan);
|
||||||
}
|
}
|
||||||
|
@ -3890,13 +3896,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
SArray* tableIdList = NULL;
|
SArray* tableIdList = NULL;
|
||||||
code = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo, &tableIdList);
|
code = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo, &tableIdList);
|
||||||
QUERY_CHECK_CODE(code, lino, _error);
|
QUERY_CHECK_CODE(code, lino, _error);
|
||||||
|
pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList, idstr);
|
||||||
code = pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList, idstr);
|
|
||||||
if (code != 0) {
|
|
||||||
taosArrayDestroy(tableIdList);
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(tableIdList);
|
taosArrayDestroy(tableIdList);
|
||||||
memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond));
|
memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ void geosFreeBuffer(void *buffer) {
|
||||||
|
|
||||||
void geosErrMsgeHandler(const char *errMsg, void *userData) {
|
void geosErrMsgeHandler(const char *errMsg, void *userData) {
|
||||||
char *targetErrMsg = userData;
|
char *targetErrMsg = userData;
|
||||||
snprintf(targetErrMsg, 512, "%s", errMsg);
|
(void)snprintf(targetErrMsg, 512, "%s", errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initCtxMakePoint() {
|
int32_t initCtxMakePoint() {
|
||||||
|
@ -94,7 +94,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(
|
(void)sprintf(
|
||||||
wktPatternWithSpace,
|
wktPatternWithSpace,
|
||||||
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
|
||||||
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\)))|linestring( *)z?m?( "
|
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\)))|linestring( *)z?m?( "
|
||||||
|
@ -264,7 +264,7 @@ int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT)
|
||||||
SGeosContext *geosCtx = getThreadLocalGeosCtx();
|
SGeosContext *geosCtx = getThreadLocalGeosCtx();
|
||||||
|
|
||||||
GEOSGeometry *geom = NULL;
|
GEOSGeometry *geom = NULL;
|
||||||
unsigned char *wkt = NULL;
|
char *wkt = NULL;
|
||||||
|
|
||||||
geom = GEOSWKBReader_read_r(geosCtx->handle, geosCtx->WKBReader, inputGeom, size);
|
geom = GEOSWKBReader_read_r(geosCtx->handle, geosCtx->WKBReader, inputGeom, size);
|
||||||
if (geom == NULL) {
|
if (geom == NULL) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url);
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
int32_t cfgInit(SConfig ** ppCfg) {
|
int32_t cfgInit(SConfig **ppCfg) {
|
||||||
SConfig *pCfg = taosMemoryCalloc(1, sizeof(SConfig));
|
SConfig *pCfg = taosMemoryCalloc(1, sizeof(SConfig));
|
||||||
if (pCfg == NULL) {
|
if (pCfg == NULL) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -54,7 +54,7 @@ int32_t cfgInit(SConfig ** ppCfg) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexInit(&pCfg->lock, NULL);
|
TAOS_CHECK_RETURN(taosThreadMutexInit(&pCfg->lock, NULL));
|
||||||
*ppCfg = pCfg;
|
*ppCfg = pCfg;
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ void cfgCleanup(SConfig *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pCfg->array);
|
taosArrayDestroy(pCfg->array);
|
||||||
taosThreadMutexDestroy(&pCfg->lock);
|
(void)taosThreadMutexDestroy(&pCfg->lock);
|
||||||
taosMemoryFree(pCfg);
|
taosMemoryFree(pCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,17 +244,17 @@ static int32_t doSetConf(SConfigItem *pItem, const char *value, ECfgSrcType styp
|
||||||
|
|
||||||
static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||||
TAOS_CHECK_RETURN(doSetConf(pItem, value, stype));
|
TAOS_CHECK_RETURN(doSetConf(pItem, value, stype));
|
||||||
osSetTimezone(value);
|
TAOS_CHECK_RETURN(osSetTimezone(value));
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, const char *level, const char *primary,
|
static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, const char *level, const char *primary,
|
||||||
const char *disable, ECfgSrcType stype) {
|
const char *disable, ECfgSrcType stype) {
|
||||||
taosThreadMutexLock(&pCfg->lock);
|
(void)taosThreadMutexLock(&pCfg->lock);
|
||||||
|
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
||||||
if (pItem == NULL) {
|
if (pItem == NULL) {
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
|
||||||
if (pItem->array == NULL) {
|
if (pItem->array == NULL) {
|
||||||
pItem->array = taosArrayInit(16, sizeof(SDiskCfg));
|
pItem->array = taosArrayInit(16, sizeof(SDiskCfg));
|
||||||
if (pItem->array == NULL) {
|
if (pItem->array == NULL) {
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
@ -275,13 +275,13 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
|
||||||
cfg.disable = disable ? atoi(disable) : 0;
|
cfg.disable = disable ? atoi(disable) : 0;
|
||||||
void *ret = taosArrayPush(pItem->array, &cfg);
|
void *ret = taosArrayPush(pItem->array, &cfg);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool rese
|
||||||
if (pDebugFlagItem == NULL) return -1;
|
if (pDebugFlagItem == NULL) return -1;
|
||||||
if (pDebugFlagItem->array != NULL) {
|
if (pDebugFlagItem->array != NULL) {
|
||||||
SLogVar logVar = {0};
|
SLogVar logVar = {0};
|
||||||
strncpy(logVar.name, name, TSDB_LOG_VAR_LEN - 1);
|
(void)strncpy(logVar.name, name, TSDB_LOG_VAR_LEN - 1);
|
||||||
if (NULL == taosArrayPush(pDebugFlagItem->array, &logVar)) {
|
if (NULL == taosArrayPush(pDebugFlagItem->array, &logVar)) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
@ -317,15 +317,15 @@ static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool rese
|
||||||
|
|
||||||
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype, bool lock) {
|
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype, bool lock) {
|
||||||
// GRANT_CFG_SET;
|
// GRANT_CFG_SET;
|
||||||
int32_t code = 0;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadMutexLock(&pCfg->lock);
|
(void)taosThreadMutexLock(&pCfg->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
SConfigItem *pItem = cfgGetItem(pCfg, name);
|
||||||
if (pItem == NULL) {
|
if (pItem == NULL) {
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
@ -398,12 +398,10 @@ void cfgLock(SConfig *pCfg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexLock(&pCfg->lock);
|
(void)taosThreadMutexLock(&pCfg->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfgUnLock(SConfig *pCfg) {
|
void cfgUnLock(SConfig *pCfg) { (void)taosThreadMutexUnlock(&pCfg->lock); }
|
||||||
taosThreadMutexUnlock(&pCfg->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer) {
|
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer) {
|
||||||
ECfgDynType dynType = isServer ? CFG_DYN_SERVER : CFG_DYN_CLIENT;
|
ECfgDynType dynType = isServer ? CFG_DYN_SERVER : CFG_DYN_CLIENT;
|
||||||
|
@ -420,11 +418,13 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_STRING: {
|
case CFG_DTYPE_STRING: {
|
||||||
if (strcasecmp(name, "slowLogScope") == 0) {
|
if (strcasecmp(name, "slowLogScope") == 0) {
|
||||||
char *tmp = taosStrdup(pVal);
|
char *tmp = taosStrdup(pVal);
|
||||||
if (taosSetSlowLogScope(tmp) < 0) {
|
int32_t scope = 0;
|
||||||
|
int32_t code = taosSetSlowLogScope(tmp, &scope);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
cfgUnLock(pCfg);
|
cfgUnLock(pCfg);
|
||||||
taosMemoryFree(tmp);
|
taosMemoryFree(tmp);
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
taosMemoryFree(tmp);
|
taosMemoryFree(tmp);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
|
||||||
|
|
||||||
int32_t len = strlen(name);
|
int32_t len = strlen(name);
|
||||||
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
|
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
|
||||||
strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len));
|
(void)strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len));
|
||||||
|
|
||||||
if (taosArrayPush(pCfg->array, pItem) == NULL) {
|
if (taosArrayPush(pCfg->array, pItem) == NULL) {
|
||||||
if (pItem->dtype == CFG_DTYPE_STRING) {
|
if (pItem->dtype == CFG_DTYPE_STRING) {
|
||||||
|
@ -721,10 +721,10 @@ int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t
|
||||||
|
|
||||||
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf(" s3 config");
|
(void)printf(" s3 config");
|
||||||
printf("\n");
|
(void)printf("\n");
|
||||||
printf("=================================================================");
|
(void)printf("=================================================================");
|
||||||
printf("\n");
|
(void)printf("\n");
|
||||||
} else {
|
} else {
|
||||||
uInfo(" s3 config");
|
uInfo(" s3 config");
|
||||||
uInfo("=================================================================");
|
uInfo("=================================================================");
|
||||||
|
@ -752,7 +752,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %u\n", src, name, pItem->bval);
|
(void)printf("%s %s %u\n", src, name, pItem->bval);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %u", src, name, pItem->bval);
|
uInfo("%s %s %u", src, name, pItem->bval);
|
||||||
}
|
}
|
||||||
|
@ -760,14 +760,14 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %d\n", src, name, pItem->i32);
|
(void)printf("%s %s %d\n", src, name, pItem->i32);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %d", src, name, pItem->i32);
|
uInfo("%s %s %d", src, name, pItem->i32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %" PRId64 "\n", src, name, pItem->i64);
|
(void)printf("%s %s %" PRId64 "\n", src, name, pItem->i64);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
case CFG_DTYPE_DOUBLE:
|
case CFG_DTYPE_DOUBLE:
|
||||||
case CFG_DTYPE_FLOAT:
|
case CFG_DTYPE_FLOAT:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %.2f\n", src, name, pItem->fval);
|
(void)printf("%s %s %.2f\n", src, name, pItem->fval);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %.2f", src, name, pItem->fval);
|
uInfo("%s %s %.2f", src, name, pItem->fval);
|
||||||
}
|
}
|
||||||
|
@ -787,7 +787,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
case CFG_DTYPE_TIMEZONE:
|
case CFG_DTYPE_TIMEZONE:
|
||||||
case CFG_DTYPE_NONE:
|
case CFG_DTYPE_NONE:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %s\n", src, name, pItem->str);
|
(void)printf("%s %s %s\n", src, name, pItem->str);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %s", src, name, pItem->str);
|
uInfo("%s %s %s", src, name, pItem->str);
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("=================================================================\n");
|
(void)printf("=================================================================\n");
|
||||||
} else {
|
} else {
|
||||||
uInfo("=================================================================");
|
uInfo("=================================================================");
|
||||||
}
|
}
|
||||||
|
@ -804,10 +804,10 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf(" global config");
|
(void)printf(" global config");
|
||||||
printf("\n");
|
(void)printf("\n");
|
||||||
printf("=================================================================");
|
(void)printf("=================================================================");
|
||||||
printf("\n");
|
(void)printf("\n");
|
||||||
} else {
|
} else {
|
||||||
uInfo(" global config");
|
uInfo(" global config");
|
||||||
uInfo("=================================================================");
|
uInfo("=================================================================");
|
||||||
|
@ -834,7 +834,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %u\n", src, name, pItem->bval);
|
(void)printf("%s %s %u\n", src, name, pItem->bval);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %u", src, name, pItem->bval);
|
uInfo("%s %s %u", src, name, pItem->bval);
|
||||||
}
|
}
|
||||||
|
@ -842,14 +842,14 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %d\n", src, name, pItem->i32);
|
(void)printf("%s %s %d\n", src, name, pItem->i32);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %d", src, name, pItem->i32);
|
uInfo("%s %s %d", src, name, pItem->i32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %" PRId64 "\n", src, name, pItem->i64);
|
(void)printf("%s %s %" PRId64 "\n", src, name, pItem->i64);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
||||||
}
|
}
|
||||||
|
@ -857,7 +857,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
case CFG_DTYPE_DOUBLE:
|
case CFG_DTYPE_DOUBLE:
|
||||||
case CFG_DTYPE_FLOAT:
|
case CFG_DTYPE_FLOAT:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %.2f\n", src, name, pItem->fval);
|
(void)printf("%s %s %.2f\n", src, name, pItem->fval);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %.2f", src, name, pItem->fval);
|
uInfo("%s %s %.2f", src, name, pItem->fval);
|
||||||
}
|
}
|
||||||
|
@ -869,7 +869,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
case CFG_DTYPE_TIMEZONE:
|
case CFG_DTYPE_TIMEZONE:
|
||||||
case CFG_DTYPE_NONE:
|
case CFG_DTYPE_NONE:
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("%s %s %s\n", src, name, pItem->str);
|
(void)printf("%s %s %s\n", src, name, pItem->str);
|
||||||
} else {
|
} else {
|
||||||
uInfo("%s %s %s", src, name, pItem->str);
|
uInfo("%s %s %s", src, name, pItem->str);
|
||||||
}
|
}
|
||||||
|
@ -878,7 +878,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf("=================================================================\n");
|
(void)printf("=================================================================\n");
|
||||||
} else {
|
} else {
|
||||||
uInfo("=================================================================");
|
uInfo("=================================================================");
|
||||||
}
|
}
|
||||||
|
@ -900,21 +900,21 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
||||||
pEnv++;
|
pEnv++;
|
||||||
(void)taosEnvToCfg(line, line);
|
(void)taosEnvToCfg(line, line);
|
||||||
|
|
||||||
paGetToken(line, &name, &olen);
|
(void)paGetToken(line, &name, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
name[olen] = 0;
|
name[olen] = 0;
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
(void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
(void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
if (vlen2 != 0) {
|
if (vlen2 != 0) {
|
||||||
value2[vlen2] = 0;
|
value2[vlen2] = 0;
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
(void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
if (vlen3 != 0) {
|
if (vlen3 != 0) {
|
||||||
value3[vlen3] = 0;
|
value3[vlen3] = 0;
|
||||||
paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
(void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
||||||
if (vlen4 != 0) value4[vlen4] = 0;
|
if (vlen4 != 0) value4[vlen4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,21 +947,21 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
|
||||||
name = value = value2 = value3 = value4 = NULL;
|
name = value = value2 = value3 = value4 = NULL;
|
||||||
olen = vlen = vlen2 = vlen3 = vlen4 = 0;
|
olen = vlen = vlen2 = vlen3 = vlen4 = 0;
|
||||||
|
|
||||||
paGetToken(buf, &name, &olen);
|
(void)paGetToken(buf, &name, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
name[olen] = 0;
|
name[olen] = 0;
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
(void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
(void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
if (vlen2 != 0) {
|
if (vlen2 != 0) {
|
||||||
value2[vlen2] = 0;
|
value2[vlen2] = 0;
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
(void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
if (vlen3 != 0) {
|
if (vlen3 != 0) {
|
||||||
value3[vlen3] = 0;
|
value3[vlen3] = 0;
|
||||||
paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
(void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
||||||
if (vlen4 != 0) value4[vlen4] = 0;
|
if (vlen4 != 0) value4[vlen4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1015,21 +1015,21 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
|
||||||
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
||||||
(void)taosEnvToCfg(line, line);
|
(void)taosEnvToCfg(line, line);
|
||||||
|
|
||||||
paGetToken(line, &name, &olen);
|
(void)paGetToken(line, &name, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
name[olen] = 0;
|
name[olen] = 0;
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
(void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
(void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
if (vlen2 != 0) {
|
if (vlen2 != 0) {
|
||||||
value2[vlen2] = 0;
|
value2[vlen2] = 0;
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
(void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
if (vlen3 != 0) {
|
if (vlen3 != 0) {
|
||||||
value3[vlen3] = 0;
|
value3[vlen3] = 0;
|
||||||
paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
(void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
||||||
if (vlen4 != 0) value4[vlen4] = 0;
|
if (vlen4 != 0) value4[vlen4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1043,7 +1043,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
|
|
||||||
uInfo("load from env cfg file %s success", filepath);
|
uInfo("load from env cfg file %s success", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
@ -1079,11 +1079,11 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
|
|
||||||
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
||||||
|
|
||||||
paGetToken(line, &name, &olen);
|
(void)paGetToken(line, &name, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
name[olen] = 0;
|
name[olen] = 0;
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
(void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
|
@ -1096,7 +1096,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
|
|
||||||
int32_t count = 1;
|
int32_t count = 1;
|
||||||
while (vlen < 1024) {
|
while (vlen < 1024) {
|
||||||
paGetToken(value + vlen + 1 * count, &tmp, &len);
|
(void)paGetToken(value + vlen + 1 * count, &tmp, &len);
|
||||||
if (len == 0) break;
|
if (len == 0) break;
|
||||||
tmp[len] = 0;
|
tmp[len] = 0;
|
||||||
strcpy(newValue + vlen, tmp);
|
strcpy(newValue + vlen, tmp);
|
||||||
|
@ -1107,13 +1107,13 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
code = cfgSetItem(pConfig, name, newValue, CFG_STYPE_CFG_FILE, true);
|
code = cfgSetItem(pConfig, name, newValue, CFG_STYPE_CFG_FILE, true);
|
||||||
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
||||||
} else {
|
} else {
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
(void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
if (vlen2 != 0) {
|
if (vlen2 != 0) {
|
||||||
value2[vlen2] = 0;
|
value2[vlen2] = 0;
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
(void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
if (vlen3 != 0) {
|
if (vlen3 != 0) {
|
||||||
value3[vlen3] = 0;
|
value3[vlen3] = 0;
|
||||||
paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
(void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
||||||
if (vlen4 != 0) value4[vlen4] = 0;
|
if (vlen4 != 0) value4[vlen4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1136,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code || TSDB_CODE_CFG_NOT_FOUND == code) {
|
if (TSDB_CODE_SUCCESS == code || TSDB_CODE_CFG_NOT_FOUND == code) {
|
||||||
uInfo("load from cfg file %s success", filepath);
|
uInfo("load from cfg file %s success", filepath);
|
||||||
|
@ -1177,18 +1177,18 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
|
|
||||||
// if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
// if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
||||||
|
|
||||||
// paGetToken(line, &name, &olen);
|
// (void)paGetToken(line, &name, &olen);
|
||||||
// if (olen == 0) continue;
|
// if (olen == 0) continue;
|
||||||
// name[olen] = 0;
|
// name[olen] = 0;
|
||||||
|
|
||||||
// paGetToken(name + olen + 1, &value, &vlen);
|
// (void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
// if (vlen == 0) continue;
|
// if (vlen == 0) continue;
|
||||||
// value[vlen] = 0;
|
// value[vlen] = 0;
|
||||||
|
|
||||||
// paGetToken(value + vlen + 1, &value2, &vlen2);
|
// (void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
// if (vlen2 != 0) {
|
// if (vlen2 != 0) {
|
||||||
// value2[vlen2] = 0;
|
// value2[vlen2] = 0;
|
||||||
// paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
// (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
// if (vlen3 != 0) value3[vlen3] = 0;
|
// if (vlen3 != 0) value3[vlen3] = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// taosCloseFile(&pFile);
|
// (void)taosCloseFile(&pFile);
|
||||||
// if (line != NULL) taosMemoryFreeClear(line);
|
// if (line != NULL) taosMemoryFreeClear(line);
|
||||||
|
|
||||||
// if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) {
|
// if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) {
|
||||||
|
@ -1243,20 +1243,20 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
|
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
|
||||||
char *buf = taosMemoryMalloc(fileSize + 1);
|
char *buf = taosMemoryMalloc(fileSize + 1);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
uError("load json file error: %s, failed to alloc memory", filepath);
|
uError("load json file error: %s, failed to alloc memory", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[fileSize] = 0;
|
buf[fileSize] = 0;
|
||||||
taosLSeekFile(pFile, 0, SEEK_SET);
|
(void)taosLSeekFile(pFile, 0, SEEK_SET);
|
||||||
if (taosReadFile(pFile, buf, fileSize) <= 0) {
|
if (taosReadFile(pFile, buf, fileSize) <= 0) {
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
uError("load json file error: %s", filepath);
|
uError("load json file error: %s", filepath);
|
||||||
taosMemoryFreeClear(buf);
|
taosMemoryFreeClear(buf);
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT);
|
TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT);
|
||||||
}
|
}
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
pJson = tjsonParse(buf);
|
pJson = tjsonParse(buf);
|
||||||
if (NULL == pJson) {
|
if (NULL == pJson) {
|
||||||
const char *jsonParseError = tjsonGetError();
|
const char *jsonParseError = tjsonGetError();
|
||||||
|
@ -1284,25 +1284,24 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
goto _err_json;
|
goto _err_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(cfgLineBuf, itemName, itemNameLen);
|
(void)memcpy(cfgLineBuf, itemName, itemNameLen);
|
||||||
cfgLineBuf[itemNameLen] = ' ';
|
cfgLineBuf[itemNameLen] = ' ';
|
||||||
memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen);
|
(void)memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen);
|
||||||
|
(void)paGetToken(cfgLineBuf, &name, &olen);
|
||||||
paGetToken(cfgLineBuf, &name, &olen);
|
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
name[olen] = 0;
|
name[olen] = 0;
|
||||||
|
|
||||||
paGetToken(name + olen + 1, &value, &vlen);
|
(void)paGetToken(name + olen + 1, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
paGetToken(value + vlen + 1, &value2, &vlen2);
|
(void)paGetToken(value + vlen + 1, &value2, &vlen2);
|
||||||
if (vlen2 != 0) {
|
if (vlen2 != 0) {
|
||||||
value2[vlen2] = 0;
|
value2[vlen2] = 0;
|
||||||
paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
(void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3);
|
||||||
if (vlen3 != 0) {
|
if (vlen3 != 0) {
|
||||||
value3[vlen3] = 0;
|
value3[vlen3] = 0;
|
||||||
paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
(void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4);
|
||||||
if (vlen4 != 0) value4[vlen4] = 0;
|
if (vlen4 != 0) value4[vlen4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1346,7 +1345,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl
|
||||||
p++;
|
p++;
|
||||||
p[strlen(p) - 1] = '\0';
|
p[strlen(p) - 1] = '\0';
|
||||||
}
|
}
|
||||||
memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
(void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
||||||
uInfo("get apollo url from env cmd success");
|
uInfo("get apollo url from env cmd success");
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -1368,7 +1367,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl
|
||||||
p++;
|
p++;
|
||||||
p[strlen(p) - 1] = '\0';
|
p[strlen(p) - 1] = '\0';
|
||||||
}
|
}
|
||||||
memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
(void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
||||||
uInfo("get apollo url from env variables success, apolloUrl=%s", apolloUrl);
|
uInfo("get apollo url from env variables success, apolloUrl=%s", apolloUrl);
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -1405,14 +1404,14 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl
|
||||||
p++;
|
p++;
|
||||||
p[strlen(p) - 1] = '\0';
|
p[strlen(p) - 1] = '\0';
|
||||||
}
|
}
|
||||||
memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
(void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
uInfo("get apollo url from env file success");
|
uInfo("get apollo url from env file success");
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("fail get apollo url from cmd env file");
|
uInfo("fail get apollo url from cmd env file");
|
||||||
|
@ -1436,7 +1435,7 @@ int32_t cfgCreateIter(SConfig *pConf, SConfigIter **ppIter) {
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigItem *cfgNextIter(SConfigIter* pIter) {
|
SConfigItem *cfgNextIter(SConfigIter *pIter) {
|
||||||
if (pIter->index < cfgGetSize(pIter->pConf)) {
|
if (pIter->index < cfgGetSize(pIter->pConf)) {
|
||||||
return taosArrayGet(pIter->pConf->array, pIter->index++);
|
return taosArrayGet(pIter->pConf->array, pIter->index++);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue