other: merge 3.0
This commit is contained in:
commit
777c3898db
|
@ -3605,7 +3605,7 @@ static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ve
|
|||
|
||||
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const 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);
|
||||
void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pOffsetVal);
|
||||
void tOffsetDestroy(void* pVal);
|
||||
|
|
|
@ -211,7 +211,7 @@ const char* qExtractTbnameFromTask(qTaskInfo_t tinfo);
|
|||
|
||||
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 qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow);
|
||||
|
|
|
@ -218,10 +218,10 @@ typedef struct SStoreTqReader {
|
|||
int32_t (*tqGetStreamExecProgress)();
|
||||
|
||||
void (*tqReaderSetColIdList)();
|
||||
int32_t (*tqReaderSetQueryTableList)();
|
||||
void (*tqReaderSetQueryTableList)();
|
||||
|
||||
int32_t (*tqReaderAddTables)();
|
||||
int32_t (*tqReaderRemoveTables)();
|
||||
void (*tqReaderAddTables)();
|
||||
void (*tqReaderRemoveTables)();
|
||||
|
||||
void (*tqSetTablePrimaryKey)();
|
||||
bool (*tqGetTablePrimaryKey)();
|
||||
|
@ -239,8 +239,8 @@ typedef struct SStoreSnapshotFn {
|
|||
bool (*taosXGetTablePrimaryKey)(SSnapContext* ctx);
|
||||
void (*taosXSetTablePrimaryKey)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*setForSnapShot)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*destroySnapshot)(SSnapContext* ctx);
|
||||
SMetaTableInfo (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx);
|
||||
void (*destroySnapshot)(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);
|
||||
} SStoreSnapshotFn;
|
||||
|
||||
|
|
|
@ -669,8 +669,14 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916)
|
||||
#define TSDB_CODE_SYN_WRITE_STALL TAOS_DEF_ERROR_CODE(0, 0x0917)
|
||||
#define TSDB_CODE_SYN_NEGOTIATION_WIN_FULL TAOS_DEF_ERROR_CODE(0, 0x0918)
|
||||
#define TSDB_CODE_SYN_WRONG_TERM TAOS_DEF_ERROR_CODE(0, 0x0919)
|
||||
#define TSDB_CODE_SYN_WRONG_FSM_STATE TAOS_DEF_ERROR_CODE(0, 0x091A)
|
||||
#define TSDB_CODE_SYN_WRONG_SYNC_STATE TAOS_DEF_ERROR_CODE(0, 0x091B)
|
||||
#define TSDB_CODE_SYN_WRONG_REF TAOS_DEF_ERROR_CODE(0, 0x091C)
|
||||
#define TSDB_CODE_SYN_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x091D)
|
||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||
|
||||
|
||||
// tq
|
||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||
|
|
|
@ -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 TAOS_GET_TERRNO(code) \
|
||||
(terrno == 0 ? code : terrno)
|
||||
|
||||
#define TAOS_RETURN(CODE) \
|
||||
do { \
|
||||
return (terrno = (CODE)); \
|
||||
|
|
|
@ -484,7 +484,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
|
||||
end:
|
||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
||||
(void)taosArrayDestroy(pTagVals);
|
||||
taosArrayDestroy(pTagVals);
|
||||
}
|
||||
|
||||
static void buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs, cJSON** pJson) {
|
||||
|
@ -588,7 +588,7 @@ end:
|
|||
tDecoderClear(&decoder[i]);
|
||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||
if (pCreateReq[i].type == TSDB_CHILD_TABLE) {
|
||||
(void)taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
||||
taosArrayDestroy(pCreateReq[i].ctb.tagName);
|
||||
}
|
||||
}
|
||||
taosMemoryFree(decoder);
|
||||
|
@ -1097,7 +1097,7 @@ typedef struct SVgroupCreateTableBatch {
|
|||
|
||||
static void destroyCreateTbReqBatch(void* 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) {
|
||||
|
@ -1252,7 +1252,7 @@ typedef struct SVgroupDropTableBatch {
|
|||
|
||||
static void destroyDropTbReqBatch(void* 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) {
|
||||
|
@ -1518,7 +1518,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
end:
|
||||
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);
|
||||
taosMemoryFreeClear(pVgData);
|
||||
destroyRequest(pRequest);
|
||||
|
|
|
@ -197,8 +197,8 @@ static void smlDestroySTableMeta(void *para) {
|
|||
SSmlSTableMeta *meta = *(SSmlSTableMeta **)para;
|
||||
taosHashCleanup(meta->tagHash);
|
||||
taosHashCleanup(meta->colHash);
|
||||
(void)taosArrayDestroy(meta->tags);
|
||||
(void)taosArrayDestroy(meta->cols);
|
||||
taosArrayDestroy(meta->tags);
|
||||
taosArrayDestroy(meta->cols);
|
||||
taosMemoryFreeClear(meta->tableMeta);
|
||||
taosMemoryFree(meta);
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ int32_t smlSetCTableName(SSmlTableInfo *oneTable) {
|
|||
if (code != TSDB_CODE_SUCCESS){
|
||||
return code;
|
||||
}
|
||||
(void)taosArrayDestroy(dst);
|
||||
taosArrayDestroy(dst);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1198,25 +1198,25 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField));
|
||||
if (pTags == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
goto end;
|
||||
}
|
||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1271,7 +1271,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1282,15 +1282,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1300,28 +1300,28 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
||||
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
||||
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1367,7 +1367,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1378,15 +1378,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
tstrncpy(field.name, pTableMeta->schema[i].name, sizeof(field.name));
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1397,21 +1397,21 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
pTableMeta->tableInfo.numOfColumns, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
||||
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
(void)taosArrayDestroy(pTags);
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
goto end;
|
||||
}
|
||||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
(void)taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pColumns);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
|
@ -1555,7 +1555,7 @@ void smlDestroyTableInfo(void *para) {
|
|||
taosHashCleanup(kvHash);
|
||||
}
|
||||
|
||||
(void)taosArrayDestroy(tag->cols);
|
||||
taosArrayDestroy(tag->cols);
|
||||
taosArrayDestroyEx(tag->tags, freeSSmlKv);
|
||||
taosMemoryFree(tag);
|
||||
}
|
||||
|
@ -1581,13 +1581,13 @@ void smlDestroyInfo(SSmlHandle *info) {
|
|||
cJSON *tags = (cJSON *)taosArrayGetP(info->tagJsonArray, i);
|
||||
cJSON_Delete(tags);
|
||||
}
|
||||
(void)taosArrayDestroy(info->tagJsonArray);
|
||||
taosArrayDestroy(info->tagJsonArray);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(info->valueJsonArray); i++) {
|
||||
cJSON *value = (cJSON *)taosArrayGetP(info->valueJsonArray, i);
|
||||
cJSON_Delete(value);
|
||||
}
|
||||
(void)taosArrayDestroy(info->valueJsonArray);
|
||||
taosArrayDestroy(info->valueJsonArray);
|
||||
|
||||
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
|
||||
|
||||
|
|
|
@ -583,16 +583,10 @@ static int32_t asyncCommitOffset(tmq_t* tmq, char* pTopicName, int32_t vgId, STq
|
|||
goto end;
|
||||
}
|
||||
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
||||
code = tFormatOffset(offsetBuf, tListLen(offsetBuf), offsetVal);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
}
|
||||
tFormatOffset(offsetBuf, tListLen(offsetBuf), offsetVal);
|
||||
|
||||
char commitBuf[TSDB_OFFSET_LEN] = {0};
|
||||
code = tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
||||
if (code != 0) {
|
||||
goto end;
|
||||
}
|
||||
tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->offsetInfo.committedOffset);
|
||||
|
||||
SMqCommitCbParamSet* pParamSet = NULL;
|
||||
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 &&
|
||||
!tOffsetEqual(&pVg->offsetInfo.endOffset, &pVg->offsetInfo.committedOffset)) {
|
||||
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};
|
||||
(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);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -865,7 +859,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
offRows->offset = pVg->offsetInfo.endOffset;
|
||||
offRows->ever = pVg->offsetInfo.walVerEnd == -1 ? 0 : pVg->offsetInfo.walVerEnd;
|
||||
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,
|
||||
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};
|
||||
STqOffsetVal offset = {.type = pTmq->resetOffsetCfg};
|
||||
(void)tFormatOffset(buf, tListLen(buf), &offset);
|
||||
tFormatOffset(buf, tListLen(buf), &offset);
|
||||
tscInfo("consumer:0x%" PRIx64 " is setup, refId:%" PRId64
|
||||
", groupId:%s, snapshot:%d, autoCommit:%d, commitInterval:%dms, offset:%s",
|
||||
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));
|
||||
|
||||
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,
|
||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
||||
} 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);
|
||||
|
||||
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,
|
||||
vgKey, buf);
|
||||
|
||||
|
@ -1959,7 +1953,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
|
||||
int64_t transporterId = 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);
|
||||
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);
|
||||
|
@ -2130,7 +2124,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tmq->consumerId, pDataRsp->blockNum != 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) {
|
||||
tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64
|
||||
", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
|
@ -2287,7 +2281,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
|||
tmq->totalRows += numOfRows;
|
||||
|
||||
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
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
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;
|
||||
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,
|
||||
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.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 2 false
|
||||
|
@ -74,7 +74,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// 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.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// 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.timestampLen, strlen("1626006833639000000"));
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 6
|
||||
|
@ -124,7 +124,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_EQ(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
ASSERT_EQ(smlClearForRerun(info), 0);
|
||||
|
||||
|
@ -134,7 +134,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
// case 8 false
|
||||
|
@ -143,7 +143,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
(void)memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(info, sql, sql + strlen(sql), &elements);
|
||||
ASSERT_NE(ret, 0);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
elements.colArray = nullptr;
|
||||
|
||||
taosMemoryFree(sql);
|
||||
|
@ -250,7 +250,7 @@ TEST(testCase, smlParseCols_Error_Test) {
|
|||
// printf("i:%d\n", i);
|
||||
ASSERT_NE(ret, TSDB_CODE_SUCCESS);
|
||||
taosMemoryFree(sql);
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
}
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ TEST(testCase, smlParseCols_Test) {
|
|||
ASSERT_EQ(kv->length, 4);
|
||||
ASSERT_EQ(strncasecmp(kv->value, "iuwq", 4), 0);
|
||||
|
||||
(void)taosArrayDestroy(elements.colArray);
|
||||
taosArrayDestroy(elements.colArray);
|
||||
taosMemoryFree(sql);
|
||||
smlDestroyInfo(info);
|
||||
}
|
||||
|
|
|
@ -1510,6 +1510,9 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
|||
}
|
||||
|
||||
void blockDataFreeRes(SSDataBlock* pBlock) {
|
||||
if (pBlock == NULL){
|
||||
return;
|
||||
}
|
||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
|
|
@ -9195,7 +9195,7 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) {
|
|||
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) {
|
||||
(void)snprintf(buf, maxLen, "none");
|
||||
} else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
|
@ -9207,7 +9207,9 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
|||
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
||||
char *tmp = taosMemoryCalloc(1, pVal->primaryKey.nData + 1);
|
||||
if (tmp == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (tmp == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)memcpy(tmp, pVal->primaryKey.pData, pVal->primaryKey.nData);
|
||||
(void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%s", pVal->uid, pVal->ts,
|
||||
pVal->primaryKey.type, tmp);
|
||||
|
@ -9216,11 +9218,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,
|
||||
pVal->primaryKey.type, pVal->primaryKey.val);
|
||||
}
|
||||
} else {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||
|
@ -9310,7 +9308,7 @@ int32_t tDecodeSTqCheckInfo(SDecoder *pDecoder, STqCheckInfo *pInfo) {
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
int16_t colId = 0;
|
||||
if (tDecodeI16(pDecoder, &colId) < 0) return -1;
|
||||
taosArrayPush(pInfo->colIdList, &colId);
|
||||
if (taosArrayPush(pInfo->colIdList, &colId) == NULL) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pGroup) {
|
|||
|
||||
void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
||||
ASSERT(pVgObj->replica == 2);
|
||||
memset(outGroup, 0, sizeof(SArbGroup));
|
||||
(void)memset(outGroup, 0, sizeof(SArbGroup));
|
||||
outGroup->dbUid = pVgObj->dbUid;
|
||||
outGroup->vgId = pVgObj->vgId;
|
||||
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) {
|
||||
mTrace("arbgroup:%d, perform delete action, row:%p", pGroup->vgId, pGroup);
|
||||
if (pGroup->mutexInited) {
|
||||
taosThreadMutexDestroy(&pGroup->mutex);
|
||||
(void)taosThreadMutexDestroy(&pGroup->mutex);
|
||||
pGroup->mutexInited = false;
|
||||
}
|
||||
return 0;
|
||||
|
@ -231,7 +231,7 @@ static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup) {
|
|||
|
||||
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);
|
||||
taosThreadMutexLock(&pOld->mutex);
|
||||
(void)taosThreadMutexLock(&pOld->mutex);
|
||||
|
||||
if (pOld->version != pNew->version) {
|
||||
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++) {
|
||||
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->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->version++;
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
taosThreadMutexLock(&pArbGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pArbGroup->mutex);
|
||||
|
||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||
SArbGroupMember *pMember = &pArbGroup->members[i];
|
||||
|
@ -400,13 +400,13 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
hbMembers = *(SArray **)pObj;
|
||||
} else {
|
||||
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++};
|
||||
taosArrayPush(hbMembers, &reqMember);
|
||||
(void)taosArrayPush(hbMembers, &reqMember);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
}
|
||||
|
||||
|
@ -602,9 +602,9 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
taosThreadMutexLock(&pArbGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pArbGroup->mutex);
|
||||
mndArbGroupDupObj(pArbGroup, &arbGroupDup);
|
||||
taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pArbGroup->mutex);
|
||||
|
||||
int32_t vgId = arbGroupDup.vgId;
|
||||
|
||||
|
@ -668,7 +668,10 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
SArbGroup newGroup = {0};
|
||||
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
||||
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
||||
taosArrayPush(pUpdateArray, &newGroup);
|
||||
if (taosArrayPush(pUpdateArray, &newGroup) == NULL) {
|
||||
taosArrayDestroy(pUpdateArray);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
}
|
||||
|
@ -722,7 +725,7 @@ static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
|||
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
||||
|
||||
SArray *pArray = taosArrayInit(1, sizeof(SMArbUpdateGroup));
|
||||
taosArrayPush(pArray, &newGroup);
|
||||
if (taosArrayPush(pArray, &newGroup) == NULL) goto _OVER;
|
||||
|
||||
int32_t contLen = 0;
|
||||
void *pHead = mndBuildArbUpdateGroupBatchReq(&contLen, pArray);
|
||||
|
@ -736,7 +739,7 @@ static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) {
|
|||
ret = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
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:
|
||||
taosArrayDestroy(pArray);
|
||||
|
@ -758,8 +761,8 @@ static int32_t mndPullupArbUpdateGroupBatch(SMnode *pMnode, SArray *newGroupArra
|
|||
SMArbUpdateGroup newGroup = {0};
|
||||
mndInitArbUpdateGroup(pNewGroup, &newGroup);
|
||||
|
||||
taosArrayPush(pArray, &newGroup);
|
||||
taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0);
|
||||
if (taosArrayPush(pArray, &newGroup) == NULL) goto _OVER;
|
||||
if (taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pArray) == 0) {
|
||||
|
@ -784,7 +787,7 @@ _OVER:
|
|||
if (ret != 0) {
|
||||
for (size_t i = 0; i < sz; 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;
|
||||
for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) {
|
||||
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.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.version = pUpdateGroup->version;
|
||||
|
||||
SArbGroup *pOldGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &newGroup.vgId);
|
||||
if (!pOldGroup) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -858,7 +861,7 @@ _OVER:
|
|||
// failed to update arbgroup
|
||||
for (size_t i = 0; i < sz; 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) {
|
||||
memcpy(pNew, pGroup, offsetof(SArbGroup, mutexInited));
|
||||
(void)memcpy(pNew, pGroup, offsetof(SArbGroup, mutexInited));
|
||||
}
|
||||
|
||||
static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) {
|
||||
SArbGroupMember *pMember = &pGroup->members[index];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -923,7 +926,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
|||
bool updateToken = false;
|
||||
SArbGroupMember *pMember = NULL;
|
||||
|
||||
taosThreadMutexLock(&pGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||
|
||||
int index = 0;
|
||||
for (; index < TSDB_ARB_GROUP_MEMBER_NUM; index++) {
|
||||
|
@ -957,7 +960,7 @@ bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMembe
|
|||
|
||||
// update token
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
_OVER:
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||
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);
|
||||
if (updateToken) {
|
||||
taosArrayPush(pUpdateArray, &newGroup);
|
||||
(void)taosArrayPush(pUpdateArray, &newGroup);
|
||||
}
|
||||
|
||||
sdbRelease(pMnode->pSdb, pGroup);
|
||||
|
@ -1007,7 +1010,7 @@ bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0
|
|||
bool newIsSync, SArbGroup *pNewGroup) {
|
||||
bool updateIsSync = false;
|
||||
|
||||
taosThreadMutexLock(&pGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||
|
||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
@ -1033,7 +1036,7 @@ bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0
|
|||
}
|
||||
|
||||
_OVER:
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||
return updateIsSync;
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1151,7 @@ bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char
|
|||
SArbGroup *pNewGroup) {
|
||||
bool updateAssigned = false;
|
||||
|
||||
taosThreadMutexLock(&pGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||
if (mndArbCheckToken(pGroup->assignedLeader.token, memberToken) != 0) {
|
||||
mInfo("skip update arb assigned for vgId:%d, member token mismatch, local:[%s] msg:[%s]", vgId,
|
||||
pGroup->assignedLeader.token, memberToken);
|
||||
|
@ -1171,7 +1174,7 @@ bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char
|
|||
}
|
||||
|
||||
_OVER:
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||
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);
|
||||
if (pShow->pIter == NULL) break;
|
||||
|
||||
taosThreadMutexLock(&pGroup->mutex);
|
||||
(void)taosThreadMutexLock(&pGroup->mutex);
|
||||
|
||||
cols = 0;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
SVgObj *pVgObj = sdbAcquire(pSdb, SDB_VGROUP, &pGroup->vgId);
|
||||
if (!pVgObj) {
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||
sdbRelease(pSdb, pGroup);
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
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++) {
|
||||
SArbGroupMember *pMember = &pGroup->members[i];
|
||||
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++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
||||
|
||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||
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};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||
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++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.acked, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.acked, false);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
|
@ -1289,7 +1292,7 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
colDataSetNULL(pColInfo, numOfRows);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
(void)taosThreadMutexUnlock(&pGroup->mutex);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pVgObj);
|
||||
|
|
|
@ -243,7 +243,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
|
||||
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
|||
void *pIter = NULL;
|
||||
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||
if (pCluster != NULL) {
|
||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||
(void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||
clusterObj.upTime += tsUptimeInterval;
|
||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
|
|||
if (pCluster) mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
goto _exit;
|
||||
}
|
||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||
(void)memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
|
||||
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;
|
||||
pCompact->compactId = tGenIdPI32();
|
||||
|
||||
strcpy(pCompact->dbname, pDb->name);
|
||||
(void)strcpy(pCompact->dbname, pDb->name);
|
||||
|
||||
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};
|
||||
|
||||
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++);
|
||||
if (pDb != NULL || !IS_SYS_DBNAME(pCompact->dbname)) {
|
||||
SName name = {0};
|
||||
tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameGetDbName(&name, varDataVal(tmpBuf));
|
||||
(void)tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameGetDbName(&name, varDataVal(tmpBuf));
|
||||
} 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)));
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->startTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->startTime, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pCompact);
|
||||
|
@ -334,7 +334,7 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
|||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
|
||||
tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req);
|
||||
(void)tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req);
|
||||
*pContLen = contLen;
|
||||
return pReq;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ int32_t mndProcessKillCompactReq(SRpcMsg *pReq) {
|
|||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -587,7 +587,7 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
|||
pHead->contLen = htonl(contLen);
|
||||
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};
|
||||
|
||||
|
@ -602,7 +602,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
|||
|
||||
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);
|
||||
|
@ -806,7 +809,7 @@ void mndCompactPullup(SMnode *pMnode) {
|
|||
SCompactObj *pCompact = NULL;
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact);
|
||||
if (pIter == NULL) break;
|
||||
taosArrayPush(pArray, &pCompact->compactId);
|
||||
(void)taosArrayPush(pArray, &pCompact->compactId);
|
||||
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};
|
||||
|
||||
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++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false);
|
||||
|
||||
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++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false);
|
||||
|
||||
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++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pCompactDetail);
|
||||
|
|
|
@ -946,7 +946,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
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};
|
||||
(void)sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
||||
|
|
|
@ -738,15 +738,15 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
int32_t code = 0;
|
||||
SUserObj newUserObj = {0};
|
||||
SDbObj dbObj = {0};
|
||||
memcpy(dbObj.name, pCreate->db, TSDB_DB_FNAME_LEN);
|
||||
memcpy(dbObj.acct, pUser->acct, TSDB_USER_LEN);
|
||||
(void)memcpy(dbObj.name, pCreate->db, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(dbObj.acct, pUser->acct, TSDB_USER_LEN);
|
||||
dbObj.createdTime = taosGetTimestampMs();
|
||||
dbObj.updateTime = dbObj.createdTime;
|
||||
dbObj.uid = mndGenerateUid(dbObj.name, TSDB_DB_FNAME_LEN);
|
||||
dbObj.cfgVersion = 1;
|
||||
dbObj.vgVersion = 1;
|
||||
dbObj.tsmaVersion = 1;
|
||||
memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
|
||||
(void)memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
|
||||
dbObj.cfg = (SDbCfg){
|
||||
.numOfVgroups = pCreate->numOfVgroups,
|
||||
.numOfStables = pCreate->numOfStables,
|
||||
|
@ -820,8 +820,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
SUserObj *pNewUserDuped = NULL;
|
||||
if (!pUser->superUser) {
|
||||
TAOS_CHECK_GOTO(mndUserDupObj(pUser, &newUserObj), NULL, _OVER);
|
||||
taosHashPut(newUserObj.readDbs, dbObj.name, strlen(dbObj.name) + 1, dbObj.name, TSDB_FILENAME_LEN);
|
||||
taosHashPut(newUserObj.writeDbs, dbObj.name, strlen(dbObj.name) + 1, dbObj.name, TSDB_FILENAME_LEN);
|
||||
TAOS_CHECK_GOTO(taosHashPut(newUserObj.readDbs, dbObj.name, strlen(dbObj.name) + 1, dbObj.name, TSDB_FILENAME_LEN),
|
||||
NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(taosHashPut(newUserObj.writeDbs, dbObj.name, strlen(dbObj.name) + 1, dbObj.name, TSDB_FILENAME_LEN),
|
||||
NULL, _OVER);
|
||||
pNewUserDuped = &newUserObj;
|
||||
}
|
||||
|
||||
|
@ -855,17 +857,17 @@ _OVER:
|
|||
|
||||
static void mndBuildAuditDetailInt32(char *detail, char *tmp, char *format, int32_t para) {
|
||||
if (para > 0) {
|
||||
if (strlen(detail) > 0) strcat(detail, ", ");
|
||||
sprintf(tmp, format, para);
|
||||
strcat(detail, tmp);
|
||||
if (strlen(detail) > 0) (void)strcat(detail, ", ");
|
||||
(void)sprintf(tmp, format, para);
|
||||
(void)strcat(detail, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static void mndBuildAuditDetailInt64(char *detail, char *tmp, char *format, int64_t para) {
|
||||
if (para > 0) {
|
||||
if (strlen(detail) > 0) strcat(detail, ", ");
|
||||
sprintf(tmp, format, para);
|
||||
strcat(detail, tmp);
|
||||
if (strlen(detail) > 0) (void)strcat(detail, ", ");
|
||||
(void)sprintf(tmp, format, para);
|
||||
(void)strcat(detail, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -967,7 +969,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, createReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, createReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "createDB", name.dbname, "", createReq.sql, createReq.sqlLen);
|
||||
|
||||
|
@ -1250,7 +1252,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||
(void)memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||
if (dbObj.cfg.pRetensions != NULL) {
|
||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
|
||||
if (dbObj.cfg.pRetensions == NULL) goto _OVER;
|
||||
|
@ -1276,7 +1278,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, alterReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, alterReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "alterDB", name.dbname, "", alterReq.sql, alterReq.sqlLen);
|
||||
|
||||
|
@ -1294,7 +1296,7 @@ _OVER:
|
|||
}
|
||||
|
||||
static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
|
||||
strcpy(cfgRsp->db, pDb->name);
|
||||
(void)strcpy(cfgRsp->db, pDb->name);
|
||||
cfgRsp->dbId = pDb->uid;
|
||||
cfgRsp->cfgVersion = pDb->cfgVersion;
|
||||
cfgRsp->numOfVgroups = pDb->cfg.numOfVgroups;
|
||||
|
@ -1363,7 +1365,7 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSDbCfgRsp(pRsp, contLen, &cfgRsp);
|
||||
(void)tSerializeSDbCfgRsp(pRsp, contLen, &cfgRsp);
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -1537,7 +1539,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
|
|||
int32_t code = 0;
|
||||
SDropDbRsp dropRsp = {0};
|
||||
if (pDb != NULL) {
|
||||
memcpy(dropRsp.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(dropRsp.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
dropRsp.uid = pDb->uid;
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1556,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
tSerializeSDropDbRsp(pRsp, rspLen, &dropRsp);
|
||||
(void)tSerializeSDropDbRsp(pRsp, rspLen, &dropRsp);
|
||||
*pRspLen = rspLen;
|
||||
*ppRsp = pRsp;
|
||||
TAOS_RETURN(code);
|
||||
|
@ -1635,7 +1637,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, dropReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, dropReq.db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "dropDB", name.dbname, "", dropReq.sql, dropReq.sqlLen);
|
||||
|
||||
|
@ -1694,7 +1696,7 @@ void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
|||
SEp *pEp = &vgInfo.epSet.eps[gid];
|
||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||
if (pDnode != NULL) {
|
||||
memcpy(pEp->fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
(void)memcpy(pEp->fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||
pEp->port = pDnode->port;
|
||||
}
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
@ -1703,7 +1705,7 @@ void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
|
|||
}
|
||||
}
|
||||
vindex++;
|
||||
taosArrayPush(pVgList, &vgInfo);
|
||||
(void)taosArrayPush(pVgList, &vgInfo);
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
|
@ -1730,7 +1732,7 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
|
|||
mndBuildDBVgroupInfo(pDb, pMnode, pRsp->pVgroupInfos);
|
||||
}
|
||||
|
||||
memcpy(pRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(pRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
pRsp->uid = pDb->uid;
|
||||
pRsp->vgVersion = pDb->vgVersion;
|
||||
pRsp->stateTs = pDb->stateTs;
|
||||
|
@ -1752,7 +1754,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
|||
|
||||
char *p = strchr(usedbReq.db, '.');
|
||||
if (p && ((0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcmp(p + 1, TSDB_PERFORMANCE_SCHEMA_DB))))) {
|
||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||
if (usedbReq.vgVersion < vgVersion) {
|
||||
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||
|
@ -1768,7 +1770,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
|||
} else {
|
||||
pDb = mndAcquireDb(pMnode, usedbReq.db);
|
||||
if (pDb == NULL) {
|
||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
usedbRsp.uid = usedbReq.dbId;
|
||||
usedbRsp.vgVersion = usedbReq.vgVersion;
|
||||
usedbRsp.errCode = terrno;
|
||||
|
@ -1795,7 +1797,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSUseDbRsp(pRsp, contLen, &usedbRsp);
|
||||
(void)tSerializeSUseDbRsp(pRsp, contLen, &usedbRsp);
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -1839,7 +1841,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
}
|
||||
|
||||
rsp.useDbRsp = taosMemoryCalloc(1, sizeof(SUseDbRsp));
|
||||
memcpy(rsp.useDbRsp->db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(rsp.useDbRsp->db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN);
|
||||
rsp.useDbRsp->pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||
|
||||
mndBuildDBVgroupInfo(NULL, pMnode, rsp.useDbRsp->pVgroupInfos);
|
||||
|
@ -1847,7 +1849,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
|
||||
rsp.useDbRsp->vgNum = taosArrayGetSize(rsp.useDbRsp->pVgroupInfos);
|
||||
|
||||
taosArrayPush(batchRsp.pArray, &rsp);
|
||||
(void)taosArrayPush(batchRsp.pArray, &rsp);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -1856,10 +1858,10 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
if (pDb == NULL) {
|
||||
mTrace("db:%s, no exist", pDbCacheInfo->dbFName);
|
||||
rsp.useDbRsp = taosMemoryCalloc(1, sizeof(SUseDbRsp));
|
||||
memcpy(rsp.useDbRsp->db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(rsp.useDbRsp->db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN);
|
||||
rsp.useDbRsp->uid = pDbCacheInfo->dbId;
|
||||
rsp.useDbRsp->vgVersion = -1;
|
||||
taosArrayPush(batchRsp.pArray, &rsp);
|
||||
(void)taosArrayPush(batchRsp.pArray, &rsp);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1892,7 +1894,11 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
||||
rsp.dbTsmaVersion = pDb->tsmaVersion;
|
||||
bool exist = false;
|
||||
mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
||||
if (mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist) != 0) {
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
mError("db:%s, failed to get db tsmas", pDb->name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1907,7 +1913,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
}
|
||||
|
||||
mndBuildDBVgroupInfo(pDb, pMnode, rsp.useDbRsp->pVgroupInfos);
|
||||
memcpy(rsp.useDbRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
(void)memcpy(rsp.useDbRsp->db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
rsp.useDbRsp->uid = pDb->uid;
|
||||
rsp.useDbRsp->vgVersion = pDb->vgVersion;
|
||||
rsp.useDbRsp->stateTs = pDb->stateTs;
|
||||
|
@ -1917,7 +1923,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
rsp.useDbRsp->hashSuffix = pDb->cfg.hashSuffix;
|
||||
}
|
||||
|
||||
taosArrayPush(batchRsp.pArray, &rsp);
|
||||
(void)taosArrayPush(batchRsp.pArray, &rsp);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1934,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
tFreeSDbHbBatchRsp(&batchRsp);
|
||||
return -1;
|
||||
}
|
||||
tSerializeSDbHbBatchRsp(pRsp, rspLen, &batchRsp);
|
||||
(void)tSerializeSDbHbBatchRsp(pRsp, rspLen, &batchRsp);
|
||||
|
||||
*ppRsp = pRsp;
|
||||
*pRspLen = rspLen;
|
||||
|
@ -1957,7 +1963,7 @@ static int32_t mndTrimDb(SMnode *pMnode, SDbObj *pDb) {
|
|||
}
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), contLen, &trimReq);
|
||||
(void)tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), contLen, &trimReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_TRIM, .pCont = pHead, .contLen = contLen};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
|
@ -2025,7 +2031,7 @@ static int32_t mndS3MigrateDb(SMnode *pMnode, SDbObj *pDb) {
|
|||
}
|
||||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), contLen, &s3migrateReq);
|
||||
(void)tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), contLen, &s3migrateReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_S3MIGRATE, .pCont = pHead, .contLen = contLen};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
|
@ -2250,46 +2256,46 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
for (int32_t i = 0; i < pShow->numOfColumns; ++i) {
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (i == 0) {
|
||||
colDataSetVal(pColInfo, rows, buf, false);
|
||||
(void)colDataSetVal(pColInfo, rows, buf, false);
|
||||
} else if (i == 1) {
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
} else if (i == 3) {
|
||||
colDataSetVal(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
} else if (i == 14) {
|
||||
colDataSetVal(pColInfo, rows, precVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, precVstr, false);
|
||||
} else if (i == 15) {
|
||||
colDataSetVal(pColInfo, rows, statusVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, statusVstr, false);
|
||||
} else {
|
||||
colDataSetNULL(pColInfo, rows);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, buf, false);
|
||||
(void)colDataSetVal(pColInfo, rows, buf, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
const char *strictStr = pDb->cfg.strict ? "on" : "off";
|
||||
char strictVstr[24] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(strictVstr, strictStr, 24);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)strictVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)strictVstr, false);
|
||||
|
||||
char durationVstr[128] = {0};
|
||||
int32_t len = sprintf(&durationVstr[VARSTR_HEADER_SIZE], "%dm", pDb->cfg.daysPerFile);
|
||||
varDataSetLen(durationVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)durationVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)durationVstr, false);
|
||||
|
||||
char keepVstr[128] = {0};
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
|
@ -2301,67 +2307,67 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
}
|
||||
varDataSetLen(keepVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)keepVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)keepVstr, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.buffer, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.buffer, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.pageSize, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.pageSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.pages, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.pages, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)precVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)precVstr, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)statusVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)statusVstr, false);
|
||||
|
||||
char *rentensionVstr = buildRetension(pDb->cfg.pRetensions);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (rentensionVstr == NULL) {
|
||||
colDataSetNULL(pColInfo, rows);
|
||||
} else {
|
||||
colDataSetVal(pColInfo, rows, (const char *)rentensionVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)rentensionVstr, false);
|
||||
taosMemoryFree(rentensionVstr);
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.numOfStables, false);
|
||||
|
||||
const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast);
|
||||
char cacheModelVstr[24] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, 24);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)cacheModelVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)cacheModelVstr, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.cacheLastSize, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.cacheLastSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walFsyncPeriod, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walFsyncPeriod, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walRetentionPeriod, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walRetentionPeriod, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walRetentionSize, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.walRetentionSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.sstTrigger, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.sstTrigger, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
int16_t hashPrefix = pDb->cfg.hashPrefix;
|
||||
|
@ -2370,37 +2376,37 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
} else if (hashPrefix < 0) {
|
||||
hashPrefix = pDb->cfg.hashPrefix + strlen(pDb->name) + 1;
|
||||
}
|
||||
colDataSetVal(pColInfo, rows, (const char *)&hashPrefix, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&hashPrefix, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.hashSuffix, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.hashSuffix, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.tsdbPageSize, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.tsdbPageSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.keepTimeOffset, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.keepTimeOffset, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.s3ChunkSize, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.s3ChunkSize, false);
|
||||
|
||||
char keeplocalVstr[128] = {0};
|
||||
len = sprintf(&keeplocalVstr[VARSTR_HEADER_SIZE], "%dm", pDb->cfg.s3KeepLocal);
|
||||
varDataSetLen(keeplocalVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)keeplocalVstr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)keeplocalVstr, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.s3Compact, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.s3Compact, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false);
|
||||
|
||||
const char *encryptAlgorithmStr = getEncryptAlgorithmStr(pDb->cfg.encryptAlgorithm);
|
||||
char encryptAlgorithmVStr[24] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(encryptAlgorithmVStr, encryptAlgorithmStr, 24);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, rows, (const char *)encryptAlgorithmVStr, false);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)encryptAlgorithmVStr, false);
|
||||
}
|
||||
|
||||
taosMemoryFree(buf);
|
||||
|
|
|
@ -158,10 +158,19 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
|
|||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
taosArrayPush(pArray, &pTask);
|
||||
if (taosArrayPush(pArray, &pTask) == NULL) {
|
||||
taosMemoryFree(pTask);
|
||||
taosArrayDestroy(pArray);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
taosArrayPush(pObj->tasks, &pArray);
|
||||
if (taosArrayPush(pObj->tasks, &pArray) == NULL) {
|
||||
taosArrayDestroy(pArray);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,10 +445,15 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
// current topics
|
||||
buf = taosDecodeFixedI32(buf, &sz);
|
||||
pConsumer->currentTopics = taosArrayInit(sz, sizeof(void *));
|
||||
if (pConsumer->currentTopics == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->currentTopics, &topic);
|
||||
if (taosArrayPush(pConsumer->currentTopics, &topic) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// reb new topics
|
||||
|
@ -448,7 +462,9 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->rebNewTopics, &topic);
|
||||
if (taosArrayPush(pConsumer->rebNewTopics, &topic) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// reb removed topics
|
||||
|
@ -457,7 +473,9 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->rebRemovedTopics, &topic);
|
||||
if (taosArrayPush(pConsumer->rebRemovedTopics, &topic) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// reb removed topics
|
||||
|
@ -466,7 +484,9 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic;
|
||||
buf = taosDecodeString(buf, &topic);
|
||||
taosArrayPush(pConsumer->assignedTopics, &topic);
|
||||
if (taosArrayPush(pConsumer->assignedTopics, &topic) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (sver > 1) {
|
||||
|
@ -597,7 +617,9 @@ int32_t tCloneSubscribeObj(const SMqSubscribeObj *pSub, SMqSubscribeObj **ppSub)
|
|||
.consumerId = pConsumerEp->consumerId,
|
||||
.vgs = taosArrayDup(pConsumerEp->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp),
|
||||
};
|
||||
taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp, sizeof(SMqConsumerEp));
|
||||
if ((code = taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp,
|
||||
sizeof(SMqConsumerEp))) != 0)
|
||||
goto END;
|
||||
}
|
||||
pSubNew->unassignedVgs = taosArrayDup(pSub->unassignedVgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
|
||||
pSubNew->offsetRows = taosArrayDup(pSub->offsetRows, NULL);
|
||||
|
@ -672,7 +694,9 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp consumerEp = {0};
|
||||
buf = tDecodeSMqConsumerEp(buf, &consumerEp, sver);
|
||||
taosHashPut(pSub->consumerHash, &consumerEp.consumerId, sizeof(int64_t), &consumerEp, sizeof(SMqConsumerEp));
|
||||
if (taosHashPut(pSub->consumerHash, &consumerEp.consumerId, sizeof(int64_t), &consumerEp, sizeof(SMqConsumerEp)) !=
|
||||
0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = taosDecodeArray(buf, &pSub->unassignedVgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver);
|
||||
|
|
|
@ -152,11 +152,11 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
|||
dnodeObj.port = tsServerPort;
|
||||
tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
|
||||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||
(void)snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort);
|
||||
char *machineId = NULL;
|
||||
code = tGetMachineId(&machineId);
|
||||
if (machineId) {
|
||||
memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN);
|
||||
(void)memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN);
|
||||
taosMemoryFreeClear(machineId);
|
||||
} else {
|
||||
#if defined(TD_ENTERPRISE) && !defined(GRANTS_CFG)
|
||||
|
@ -284,7 +284,7 @@ static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) {
|
|||
pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED;
|
||||
|
||||
char ep[TSDB_EP_LEN] = {0};
|
||||
snprintf(ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port);
|
||||
(void)snprintf(ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port);
|
||||
tstrncpy(pDnode->ep, ep, TSDB_EP_LEN);
|
||||
return 0;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode) {
|
|||
|
||||
SEpSet mndGetDnodeEpset(SDnodeObj *pDnode) {
|
||||
SEpSet epSet = {0};
|
||||
addEpIntoEpSet(&epSet, pDnode->fqdn, pDnode->port);
|
||||
terrno = addEpIntoEpSet(&epSet, pDnode->fqdn, pDnode->port);
|
||||
return epSet;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ static void mndGetDnodeEps(SMnode *pMnode, SArray *pDnodeEps) {
|
|||
if (mndIsMnode(pMnode, pDnode->id)) {
|
||||
dnodeEp.isMnode = 1;
|
||||
}
|
||||
taosArrayPush(pDnodeEps, &dnodeEp);
|
||||
(void)taosArrayPush(pDnodeEps, &dnodeEp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
if (statusReq.mload.roleTimeMs == 0) {
|
||||
statusReq.mload.roleTimeMs = statusReq.rebootTime;
|
||||
}
|
||||
mndUpdateMnodeState(pObj, &statusReq.mload);
|
||||
(void)mndUpdateMnodeState(pObj, &statusReq.mload);
|
||||
mndReleaseMnode(pMnode, pObj);
|
||||
}
|
||||
|
||||
|
@ -808,7 +808,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
pDnode->encryptionKeyChksum = statusReq.clusterCfg.encryptionKeyChksum;
|
||||
if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) {
|
||||
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
mndUpdateDnodeObj(pMnode, pDnode);
|
||||
if ((terrno = mndUpdateDnodeObj(pMnode, pDnode)) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
SStatusRsp statusRsp = {0};
|
||||
|
@ -827,7 +829,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
|
||||
int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp);
|
||||
void *pHead = rpcMallocCont(contLen);
|
||||
tSerializeSStatusRsp(pHead, contLen, &statusRsp);
|
||||
(void)tSerializeSStatusRsp(pHead, contLen, &statusRsp);
|
||||
taosArrayDestroy(statusRsp.pDnodeEps);
|
||||
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -841,7 +843,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
_OVER:
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
taosArrayDestroy(statusReq.pVloads);
|
||||
mndUpdClusterInfo(pReq);
|
||||
(void)mndUpdClusterInfo(pReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -873,7 +875,7 @@ static int32_t mndProcessNotifyReq(SRpcMsg *pReq) {
|
|||
mndReleaseVgroup(pMnode, pVgroup);
|
||||
}
|
||||
}
|
||||
mndUpdClusterInfo(pReq);
|
||||
code = mndUpdClusterInfo(pReq);
|
||||
_OVER:
|
||||
tFreeSNotifyReq(¬ifyReq);
|
||||
return code;
|
||||
|
@ -890,7 +892,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
dnodeObj.updateTime = dnodeObj.createdTime;
|
||||
dnodeObj.port = pCreate->port;
|
||||
tstrncpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
|
||||
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", pCreate->fqdn, pCreate->port);
|
||||
(void)snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", pCreate->fqdn, pCreate->port);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||
if (pTrans == NULL) {
|
||||
|
@ -957,7 +959,7 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSDnodeListRsp(pRsp, rspLen, &rsp);
|
||||
(void)tSerializeSDnodeListRsp(pRsp, rspLen, &rsp);
|
||||
|
||||
pReq->info.rspLen = rspLen;
|
||||
pReq->info.rsp = pRsp;
|
||||
|
@ -976,26 +978,26 @@ _OVER:
|
|||
|
||||
static void getSlowLogScopeString(int32_t scope, char* result){
|
||||
if(scope == SLOW_LOG_TYPE_NULL) {
|
||||
strcat(result, "NONE");
|
||||
(void)strcat(result, "NONE");
|
||||
return;
|
||||
}
|
||||
while(scope > 0){
|
||||
if(scope & SLOW_LOG_TYPE_QUERY) {
|
||||
strcat(result, "QUERY");
|
||||
(void)strcat(result, "QUERY");
|
||||
scope &= ~SLOW_LOG_TYPE_QUERY;
|
||||
} else if(scope & SLOW_LOG_TYPE_INSERT) {
|
||||
strcat(result, "INSERT");
|
||||
(void)strcat(result, "INSERT");
|
||||
scope &= ~SLOW_LOG_TYPE_INSERT;
|
||||
} else if(scope & SLOW_LOG_TYPE_OTHERS) {
|
||||
strcat(result, "OTHERS");
|
||||
(void)strcat(result, "OTHERS");
|
||||
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
||||
} else{
|
||||
printf("invalid slow log scope:%d", scope);
|
||||
(void)printf("invalid slow log scope:%d", scope);
|
||||
return;
|
||||
}
|
||||
|
||||
if(scope > 0) {
|
||||
strcat(result, "|");
|
||||
(void)strcat(result, "|");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1017,52 +1019,79 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
|
||||
SVariablesInfo info = {0};
|
||||
|
||||
strcpy(info.name, "statusInterval");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "statusInterval");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "timezone");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
|
||||
strcpy(info.scope, "both");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "timezone");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
|
||||
(void)strcpy(info.scope, "both");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "locale");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
|
||||
strcpy(info.scope, "both");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "locale");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
|
||||
(void)strcpy(info.scope, "both");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "charset");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
|
||||
strcpy(info.scope, "both");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "charset");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
|
||||
(void)strcpy(info.scope, "both");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "monitor");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "monitor");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "monitorInterval");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "monitorInterval");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "slowLogThreshold");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "slowLogThreshold");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
strcpy(info.name, "slowLogMaxLen");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "slowLogMaxLen");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
char scopeStr[64] = {0};
|
||||
getSlowLogScopeString(tsSlowLogScope, scopeStr);
|
||||
strcpy(info.name, "slowLogScope");
|
||||
snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
|
||||
strcpy(info.scope, "server");
|
||||
taosArrayPush(rsp.variables, &info);
|
||||
(void)strcpy(info.name, "slowLogScope");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
|
||||
(void)strcpy(info.scope, "server");
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
|
@ -1071,7 +1100,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp);
|
||||
(void)tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp);
|
||||
|
||||
pReq->info.rspLen = rspLen;
|
||||
pReq->info.rsp = pRsp;
|
||||
|
@ -1108,7 +1137,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
char ep[TSDB_EP_LEN];
|
||||
snprintf(ep, TSDB_EP_LEN, "%s:%d", createReq.fqdn, createReq.port);
|
||||
(void)snprintf(ep, TSDB_EP_LEN, "%s:%d", createReq.fqdn, createReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode != NULL) {
|
||||
code = TSDB_CODE_MND_DNODE_ALREADY_EXIST;
|
||||
|
@ -1122,7 +1151,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
char obj[200] = {0};
|
||||
sprintf(obj, "%s:%d", createReq.fqdn, createReq.port);
|
||||
(void)sprintf(obj, "%s:%d", createReq.fqdn, createReq.port);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "createDnode", "", obj, createReq.sql, createReq.sqlLen);
|
||||
|
||||
|
@ -1261,7 +1290,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
if (pDnode == NULL) {
|
||||
int32_t err = terrno;
|
||||
char ep[TSDB_EP_LEN + 1] = {0};
|
||||
snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||
(void)snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode == NULL) {
|
||||
code = err;
|
||||
|
@ -1305,7 +1334,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
char obj1[30] = {0};
|
||||
sprintf(obj1, "%d", dropReq.dnodeId);
|
||||
(void)sprintf(obj1, "%d", dropReq.dnodeId);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "dropDnode", "", obj1, dropReq.sql, dropReq.sqlLen);
|
||||
|
||||
|
@ -1333,17 +1362,17 @@ static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
|||
}
|
||||
|
||||
size_t optLen = p - pMCfgReq->config;
|
||||
strncpy(pDCfgReq->config, pMCfgReq->config, optLen);
|
||||
(void)strncpy(pDCfgReq->config, pMCfgReq->config, optLen);
|
||||
pDCfgReq->config[optLen] = 0;
|
||||
|
||||
if (' ' == pMCfgReq->config[optLen]) {
|
||||
// 'key value'
|
||||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||
strcpy(pDCfgReq->value, p + 1);
|
||||
(void)strcpy(pDCfgReq->value, p + 1);
|
||||
} else {
|
||||
// 'key' 'value'
|
||||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||
strcpy(pDCfgReq->value, pMCfgReq->value);
|
||||
(void)strcpy(pDCfgReq->value, pMCfgReq->value);
|
||||
}
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
@ -1369,11 +1398,10 @@ static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq
|
|||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
|
||||
tmsgSendReq(&epSet, &rpcMsg);
|
||||
code = 0;
|
||||
code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1428,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
SDCfgDnodeReq dcfgReq = {0};
|
||||
if (strcasecmp(cfgReq.config, "resetlog") == 0) {
|
||||
strcpy(dcfgReq.config, "resetlog");
|
||||
(void)strcpy(dcfgReq.config, "resetlog");
|
||||
#ifdef TD_ENTERPRISE
|
||||
} else if (strncasecmp(cfgReq.config, "s3blocksize", 11) == 0) {
|
||||
int32_t optLen = strlen("s3blocksize");
|
||||
|
@ -1435,7 +1463,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
{ // audit
|
||||
char obj[50] = {0};
|
||||
sprintf(obj, "%d", cfgReq.dnodeId);
|
||||
(void)sprintf(obj, "%d", cfgReq.dnodeId);
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen);
|
||||
}
|
||||
|
@ -1510,10 +1538,10 @@ static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId,
|
|||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen};
|
||||
if (0 == tmsgSendReq(&epSet, &rpcMsg)) {
|
||||
atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);
|
||||
(void)atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1597,41 +1625,41 @@ static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
int32_t cols = 0;
|
||||
|
||||
cfgOpts[totalRows] = "statusInterval";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "timezone";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "locale";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "charset";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "monitor";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "monitorInterval";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "slowLogThreshold";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[totalRows] = "slowLogMaxLen";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
|
||||
totalRows++;
|
||||
|
||||
char scopeStr[64] = {0};
|
||||
getSlowLogScopeString(tsSlowLogScope, scopeStr);
|
||||
cfgOpts[totalRows] = "slowLogScope";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
|
||||
(void)snprintf(cfgVals[totalRows], TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
|
||||
totalRows++;
|
||||
|
||||
char buf[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
|
@ -1642,11 +1670,11 @@ static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, cfgOpts[i], TSDB_CONFIG_OPTION_LEN);
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)buf, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)buf, false);
|
||||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(bufVal, cfgVals[i], TSDB_CONFIG_VALUE_LEN);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)bufVal, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)bufVal, false);
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
@ -1675,19 +1703,19 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
cols = 0;
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->id, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->id, false);
|
||||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
int16_t id = mndGetVnodesNum(pMnode, pDnode->id);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&id, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&id, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->numOfSupportVnodes, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->numOfSupportVnodes, false);
|
||||
|
||||
const char *status = "ready";
|
||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||
|
@ -1703,19 +1731,19 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
|
||||
STR_TO_VARSTR(buf, status);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->createdTime, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->rebootTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->rebootTime, false);
|
||||
|
||||
char *b = taosMemoryCalloc(VARSTR_HEADER_SIZE + strlen(offlineReason[pDnode->offlineReason]) + 1, 1);
|
||||
STR_TO_VARSTR(b, online ? "" : offlineReason[pDnode->offlineReason]);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, b, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, b, false);
|
||||
taosMemoryFreeClear(b);
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
@ -1772,7 +1800,7 @@ SArray *mndGetAllDnodeFqdns(SMnode *pMnode) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
char *fqdn = taosStrdup(pObj->fqdn);
|
||||
taosArrayPush(fqdns, &fqdn);
|
||||
(void)taosArrayPush(fqdns, &fqdn);
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
return fqdns;
|
||||
|
|
|
@ -41,7 +41,7 @@ int32_t sendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
|
||||
char *i642str(int64_t val) {
|
||||
static char str[24] = {0};
|
||||
snprintf(str, sizeof(str), "%" PRId64, val);
|
||||
(void)snprintf(str, sizeof(str), "%" PRId64, val);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -55,18 +55,18 @@ void dumpFunc(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", pObj->name);
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "funcType", i642str(pObj->funcType));
|
||||
tjsonAddStringToObject(item, "scriptType", i642str(pObj->scriptType));
|
||||
tjsonAddStringToObject(item, "align", i642str(pObj->align));
|
||||
tjsonAddStringToObject(item, "outputType", i642str(pObj->outputType));
|
||||
tjsonAddStringToObject(item, "outputLen", i642str(pObj->outputLen));
|
||||
tjsonAddStringToObject(item, "bufSize", i642str(pObj->bufSize));
|
||||
tjsonAddStringToObject(item, "signature", i642str(pObj->signature));
|
||||
tjsonAddStringToObject(item, "commentSize", i642str(pObj->commentSize));
|
||||
tjsonAddStringToObject(item, "codeSize", i642str(pObj->codeSize));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", pObj->name);
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "funcType", i642str(pObj->funcType));
|
||||
(void)tjsonAddStringToObject(item, "scriptType", i642str(pObj->scriptType));
|
||||
(void)tjsonAddStringToObject(item, "align", i642str(pObj->align));
|
||||
(void)tjsonAddStringToObject(item, "outputType", i642str(pObj->outputType));
|
||||
(void)tjsonAddStringToObject(item, "outputLen", i642str(pObj->outputLen));
|
||||
(void)tjsonAddStringToObject(item, "bufSize", i642str(pObj->bufSize));
|
||||
(void)tjsonAddStringToObject(item, "signature", i642str(pObj->signature));
|
||||
(void)tjsonAddStringToObject(item, "commentSize", i642str(pObj->commentSize));
|
||||
(void)tjsonAddStringToObject(item, "codeSize", i642str(pObj->codeSize));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -84,56 +84,56 @@ void dumpDb(SSdb *pSdb, SJson *json) {
|
|||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToObject(items, "db", item);
|
||||
|
||||
tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
tjsonAddStringToObject(item, "createUser", pObj->createUser);
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
tjsonAddStringToObject(item, "cfgVersion", i642str(pObj->cfgVersion));
|
||||
tjsonAddStringToObject(item, "vgVersion", i642str(pObj->vgVersion));
|
||||
tjsonAddStringToObject(item, "numOfVgroups", i642str(pObj->cfg.numOfVgroups));
|
||||
tjsonAddStringToObject(item, "numOfStables", i642str(pObj->cfg.numOfStables));
|
||||
tjsonAddStringToObject(item, "buffer", i642str(pObj->cfg.buffer));
|
||||
tjsonAddStringToObject(item, "pageSize", i642str(pObj->cfg.pageSize));
|
||||
tjsonAddStringToObject(item, "pages", i642str(pObj->cfg.pages));
|
||||
tjsonAddStringToObject(item, "cacheLastSize", i642str(pObj->cfg.cacheLastSize));
|
||||
tjsonAddStringToObject(item, "daysPerFile", i642str(pObj->cfg.daysPerFile));
|
||||
tjsonAddStringToObject(item, "daysToKeep0", i642str(pObj->cfg.daysToKeep0));
|
||||
tjsonAddStringToObject(item, "daysToKeep1", i642str(pObj->cfg.daysToKeep1));
|
||||
tjsonAddStringToObject(item, "daysToKeep2", i642str(pObj->cfg.daysToKeep2));
|
||||
tjsonAddStringToObject(item, "minRows", i642str(pObj->cfg.minRows));
|
||||
tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows));
|
||||
tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision));
|
||||
tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
|
||||
tjsonAddStringToObject(item, "encryptAlgorithm", i642str(pObj->cfg.encryptAlgorithm));
|
||||
tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
|
||||
tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
|
||||
tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
|
||||
tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod));
|
||||
tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix));
|
||||
tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix));
|
||||
tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger));
|
||||
tjsonAddStringToObject(item, "tsdbPageSize", i642str(pObj->cfg.tsdbPageSize));
|
||||
tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless));
|
||||
tjsonAddStringToObject(item, "walLevel", i642str(pObj->cfg.walLevel));
|
||||
tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod));
|
||||
tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod));
|
||||
tjsonAddStringToObject(item, "walRetentionSize", i642str(pObj->cfg.walRetentionSize));
|
||||
tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod));
|
||||
tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize));
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
(void)tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
(void)tjsonAddStringToObject(item, "createUser", pObj->createUser);
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
(void)tjsonAddStringToObject(item, "cfgVersion", i642str(pObj->cfgVersion));
|
||||
(void)tjsonAddStringToObject(item, "vgVersion", i642str(pObj->vgVersion));
|
||||
(void)tjsonAddStringToObject(item, "numOfVgroups", i642str(pObj->cfg.numOfVgroups));
|
||||
(void)tjsonAddStringToObject(item, "numOfStables", i642str(pObj->cfg.numOfStables));
|
||||
(void)tjsonAddStringToObject(item, "buffer", i642str(pObj->cfg.buffer));
|
||||
(void)tjsonAddStringToObject(item, "pageSize", i642str(pObj->cfg.pageSize));
|
||||
(void)tjsonAddStringToObject(item, "pages", i642str(pObj->cfg.pages));
|
||||
(void)tjsonAddStringToObject(item, "cacheLastSize", i642str(pObj->cfg.cacheLastSize));
|
||||
(void)tjsonAddStringToObject(item, "daysPerFile", i642str(pObj->cfg.daysPerFile));
|
||||
(void)tjsonAddStringToObject(item, "daysToKeep0", i642str(pObj->cfg.daysToKeep0));
|
||||
(void)tjsonAddStringToObject(item, "daysToKeep1", i642str(pObj->cfg.daysToKeep1));
|
||||
(void)tjsonAddStringToObject(item, "daysToKeep2", i642str(pObj->cfg.daysToKeep2));
|
||||
(void)tjsonAddStringToObject(item, "minRows", i642str(pObj->cfg.minRows));
|
||||
(void)tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows));
|
||||
(void)tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision));
|
||||
(void)tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
|
||||
(void)tjsonAddStringToObject(item, "encryptAlgorithm", i642str(pObj->cfg.encryptAlgorithm));
|
||||
(void)tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
|
||||
(void)tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
|
||||
(void)tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
|
||||
(void)tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod));
|
||||
(void)tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix));
|
||||
(void)tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix));
|
||||
(void)tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger));
|
||||
(void)tjsonAddStringToObject(item, "tsdbPageSize", i642str(pObj->cfg.tsdbPageSize));
|
||||
(void)tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless));
|
||||
(void)tjsonAddStringToObject(item, "walLevel", i642str(pObj->cfg.walLevel));
|
||||
(void)tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod));
|
||||
(void)tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod));
|
||||
(void)tjsonAddStringToObject(item, "walRetentionSize", i642str(pObj->cfg.walRetentionSize));
|
||||
(void)tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod));
|
||||
(void)tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize));
|
||||
|
||||
tjsonAddStringToObject(item, "numOfRetensions", i642str(pObj->cfg.numOfRetensions));
|
||||
(void)tjsonAddStringToObject(item, "numOfRetensions", i642str(pObj->cfg.numOfRetensions));
|
||||
for (int32_t i = 0; i < pObj->cfg.numOfRetensions; ++i) {
|
||||
SJson *rentensions = tjsonAddArrayToObject(item, "rentensions");
|
||||
SJson *rentension = tjsonCreateObject();
|
||||
tjsonAddItemToArray(rentensions, rentension);
|
||||
(void)tjsonAddItemToArray(rentensions, rentension);
|
||||
|
||||
SRetention *pRetension = taosArrayGet(pObj->cfg.pRetensions, i);
|
||||
tjsonAddStringToObject(item, "freq", i642str(pRetension->freq));
|
||||
tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit));
|
||||
tjsonAddStringToObject(item, "keep", i642str(pRetension->keep));
|
||||
tjsonAddStringToObject(item, "keepUnit", i642str(pRetension->keepUnit));
|
||||
(void)tjsonAddStringToObject(item, "freq", i642str(pRetension->freq));
|
||||
(void)tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit));
|
||||
(void)tjsonAddStringToObject(item, "keep", i642str(pRetension->keep));
|
||||
(void)tjsonAddStringToObject(item, "keepUnit", i642str(pRetension->keepUnit));
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pObj);
|
||||
|
@ -150,55 +150,55 @@ void dumpStb(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name));
|
||||
tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
tjsonAddStringToObject(item, "tagVer", i642str(pObj->tagVer));
|
||||
tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer));
|
||||
tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer));
|
||||
tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId));
|
||||
tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0]));
|
||||
tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1]));
|
||||
tjsonAddStringToObject(item, "maxdelay0", i642str(pObj->maxdelay[0]));
|
||||
tjsonAddStringToObject(item, "maxdelay1", i642str(pObj->maxdelay[1]));
|
||||
tjsonAddStringToObject(item, "ttl", i642str(pObj->ttl));
|
||||
tjsonAddStringToObject(item, "numOfFuncs", i642str(pObj->numOfFuncs));
|
||||
tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen));
|
||||
tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len));
|
||||
tjsonAddStringToObject(item, "ast2Len", i642str(pObj->ast2Len));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name));
|
||||
(void)tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
(void)tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
(void)tjsonAddStringToObject(item, "tagVer", i642str(pObj->tagVer));
|
||||
(void)tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer));
|
||||
(void)tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer));
|
||||
(void)tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId));
|
||||
(void)tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0]));
|
||||
(void)tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1]));
|
||||
(void)tjsonAddStringToObject(item, "maxdelay0", i642str(pObj->maxdelay[0]));
|
||||
(void)tjsonAddStringToObject(item, "maxdelay1", i642str(pObj->maxdelay[1]));
|
||||
(void)tjsonAddStringToObject(item, "ttl", i642str(pObj->ttl));
|
||||
(void)tjsonAddStringToObject(item, "numOfFuncs", i642str(pObj->numOfFuncs));
|
||||
(void)tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen));
|
||||
(void)tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len));
|
||||
(void)tjsonAddStringToObject(item, "ast2Len", i642str(pObj->ast2Len));
|
||||
|
||||
tjsonAddStringToObject(item, "numOfColumns", i642str(pObj->numOfColumns));
|
||||
(void)tjsonAddStringToObject(item, "numOfColumns", i642str(pObj->numOfColumns));
|
||||
SJson *columns = tjsonAddArrayToObject(item, "columns");
|
||||
for (int32_t i = 0; i < pObj->numOfColumns; ++i) {
|
||||
SJson *column = tjsonCreateObject();
|
||||
tjsonAddItemToArray(columns, column);
|
||||
(void)tjsonAddItemToArray(columns, column);
|
||||
|
||||
SSchema *pColumn = &pObj->pColumns[i];
|
||||
tjsonAddStringToObject(column, "type", i642str(pColumn->type));
|
||||
tjsonAddStringToObject(column, "typestr", tDataTypes[pColumn->type].name);
|
||||
tjsonAddStringToObject(column, "flags", i642str(pColumn->flags));
|
||||
tjsonAddStringToObject(column, "colId", i642str(pColumn->colId));
|
||||
tjsonAddStringToObject(column, "bytes", i642str(pColumn->bytes));
|
||||
tjsonAddStringToObject(column, "name", pColumn->name);
|
||||
(void)tjsonAddStringToObject(column, "type", i642str(pColumn->type));
|
||||
(void)tjsonAddStringToObject(column, "typestr", tDataTypes[pColumn->type].name);
|
||||
(void)tjsonAddStringToObject(column, "flags", i642str(pColumn->flags));
|
||||
(void)tjsonAddStringToObject(column, "colId", i642str(pColumn->colId));
|
||||
(void)tjsonAddStringToObject(column, "bytes", i642str(pColumn->bytes));
|
||||
(void)tjsonAddStringToObject(column, "name", pColumn->name);
|
||||
}
|
||||
|
||||
tjsonAddStringToObject(item, "numOfTags", i642str(pObj->numOfTags));
|
||||
(void)tjsonAddStringToObject(item, "numOfTags", i642str(pObj->numOfTags));
|
||||
SJson *tags = tjsonAddArrayToObject(item, "tags");
|
||||
for (int32_t i = 0; i < pObj->numOfTags; ++i) {
|
||||
SJson *tag = tjsonCreateObject();
|
||||
tjsonAddItemToArray(tags, tag);
|
||||
(void)tjsonAddItemToArray(tags, tag);
|
||||
|
||||
SSchema *pTag = &pObj->pTags[i];
|
||||
tjsonAddStringToObject(tag, "type", i642str(pTag->type));
|
||||
tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name);
|
||||
tjsonAddStringToObject(tag, "flags", i642str(pTag->flags));
|
||||
tjsonAddStringToObject(tag, "colId", i642str(pTag->colId));
|
||||
tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes));
|
||||
tjsonAddStringToObject(tag, "name", pTag->name);
|
||||
(void)tjsonAddStringToObject(tag, "type", i642str(pTag->type));
|
||||
(void)tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name);
|
||||
(void)tjsonAddStringToObject(tag, "flags", i642str(pTag->flags));
|
||||
(void)tjsonAddStringToObject(tag, "colId", i642str(pTag->colId));
|
||||
(void)tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes));
|
||||
(void)tjsonAddStringToObject(tag, "name", pTag->name);
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pObj);
|
||||
|
@ -215,27 +215,27 @@ void dumpSma(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name));
|
||||
tjsonAddStringToObject(item, "stb", mndGetStbStr(pObj->stb));
|
||||
tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db));
|
||||
tjsonAddStringToObject(item, "dstTbName", mndGetStbStr(pObj->dstTbName));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid));
|
||||
tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit));
|
||||
tjsonAddStringToObject(item, "slidingUnit", i642str(pObj->slidingUnit));
|
||||
tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone));
|
||||
tjsonAddStringToObject(item, "dstVgId", i642str(pObj->dstVgId));
|
||||
tjsonAddStringToObject(item, "interval", i642str(pObj->interval));
|
||||
tjsonAddStringToObject(item, "offset", i642str(pObj->offset));
|
||||
tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding));
|
||||
tjsonAddStringToObject(item, "exprLen", i642str(pObj->exprLen));
|
||||
tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen));
|
||||
tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetStbStr(pObj->name));
|
||||
(void)tjsonAddStringToObject(item, "stb", mndGetStbStr(pObj->stb));
|
||||
(void)tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->db));
|
||||
(void)tjsonAddStringToObject(item, "dstTbName", mndGetStbStr(pObj->dstTbName));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
(void)tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
(void)tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
(void)tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid));
|
||||
(void)tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit));
|
||||
(void)tjsonAddStringToObject(item, "slidingUnit", i642str(pObj->slidingUnit));
|
||||
(void)tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone));
|
||||
(void)tjsonAddStringToObject(item, "dstVgId", i642str(pObj->dstVgId));
|
||||
(void)tjsonAddStringToObject(item, "interval", i642str(pObj->interval));
|
||||
(void)tjsonAddStringToObject(item, "offset", i642str(pObj->offset));
|
||||
(void)tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding));
|
||||
(void)tjsonAddStringToObject(item, "exprLen", i642str(pObj->exprLen));
|
||||
(void)tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen));
|
||||
(void)tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
(void)tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -250,22 +250,22 @@ void dumpVgroup(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin));
|
||||
tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd));
|
||||
tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName));
|
||||
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma));
|
||||
tjsonAddStringToObject(item, "replica", i642str(pObj->replica));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
(void)tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin));
|
||||
(void)tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd));
|
||||
(void)tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName));
|
||||
(void)tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
(void)tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma));
|
||||
(void)tjsonAddStringToObject(item, "replica", i642str(pObj->replica));
|
||||
for (int32_t i = 0; i < pObj->replica; ++i) {
|
||||
SJson *replicas = tjsonAddArrayToObject(item, "replicas");
|
||||
SJson *replica = tjsonCreateObject();
|
||||
tjsonAddItemToArray(replicas, replica);
|
||||
tjsonAddStringToObject(replica, "dnodeId", i642str(pObj->vnodeGid[i].dnodeId));
|
||||
(void)tjsonAddItemToArray(replicas, replica);
|
||||
(void)tjsonAddStringToObject(replica, "dnodeId", i642str(pObj->vnodeGid[i].dnodeId));
|
||||
}
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
|
@ -281,23 +281,23 @@ void dumpTopic(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->db));
|
||||
tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
tjsonAddStringToObject(item, "subType", i642str(pObj->subType));
|
||||
tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta));
|
||||
tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
tjsonAddStringToObject(item, "stbName", mndGetStableStr(pObj->stbName));
|
||||
tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
|
||||
tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid));
|
||||
tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->db));
|
||||
(void)tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
(void)tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
(void)tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
(void)tjsonAddStringToObject(item, "subType", i642str(pObj->subType));
|
||||
(void)tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta));
|
||||
(void)tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
(void)tjsonAddStringToObject(item, "stbName", mndGetStableStr(pObj->stbName));
|
||||
(void)tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
(void)tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
|
||||
(void)tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
|
||||
(void)tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid));
|
||||
(void)tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -312,9 +312,9 @@ void dumpConsumer(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "consumerId", i642str(pObj->consumerId));
|
||||
tjsonAddStringToObject(item, "cgroup", pObj->cgroup);
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "consumerId", i642str(pObj->consumerId));
|
||||
(void)tjsonAddStringToObject(item, "cgroup", pObj->cgroup);
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -329,10 +329,10 @@ void dumpSubscribe(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "key", pObj->key);
|
||||
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "key", pObj->key);
|
||||
(void)tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
|
||||
(void)tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -347,26 +347,26 @@ void dumpStream(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel));
|
||||
tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId));
|
||||
tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
tjsonAddStringToObject(item, "status", i642str(pObj->status));
|
||||
tjsonAddStringToObject(item, "igExpired", i642str(pObj->conf.igExpired));
|
||||
tjsonAddStringToObject(item, "trigger", i642str(pObj->conf.trigger));
|
||||
tjsonAddStringToObject(item, "triggerParam", i642str(pObj->conf.triggerParam));
|
||||
tjsonAddStringToObject(item, "watermark", i642str(pObj->conf.watermark));
|
||||
tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid));
|
||||
tjsonAddStringToObject(item, "targetDbUid", i642str(pObj->targetDbUid));
|
||||
tjsonAddStringToObject(item, "sourceDb", mndGetDbStr(pObj->sourceDb));
|
||||
tjsonAddStringToObject(item, "targetDb", mndGetDbStr(pObj->targetDb));
|
||||
tjsonAddStringToObject(item, "targetSTbName", mndGetStbStr(pObj->targetSTbName));
|
||||
tjsonAddStringToObject(item, "targetStbUid", i642str(pObj->targetStbUid));
|
||||
tjsonAddStringToObject(item, "fixedSinkVgId", i642str(pObj->fixedSinkVgId));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name));
|
||||
(void)tjsonAddStringToObject(item, "createTime", i642str(pObj->createTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "version", i642str(pObj->version));
|
||||
(void)tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel));
|
||||
(void)tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId));
|
||||
(void)tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
|
||||
(void)tjsonAddStringToObject(item, "status", i642str(pObj->status));
|
||||
(void)tjsonAddStringToObject(item, "igExpired", i642str(pObj->conf.igExpired));
|
||||
(void)tjsonAddStringToObject(item, "trigger", i642str(pObj->conf.trigger));
|
||||
(void)tjsonAddStringToObject(item, "triggerParam", i642str(pObj->conf.triggerParam));
|
||||
(void)tjsonAddStringToObject(item, "watermark", i642str(pObj->conf.watermark));
|
||||
(void)tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid));
|
||||
(void)tjsonAddStringToObject(item, "targetDbUid", i642str(pObj->targetDbUid));
|
||||
(void)tjsonAddStringToObject(item, "sourceDb", mndGetDbStr(pObj->sourceDb));
|
||||
(void)tjsonAddStringToObject(item, "targetDb", mndGetDbStr(pObj->targetDb));
|
||||
(void)tjsonAddStringToObject(item, "targetSTbName", mndGetStbStr(pObj->targetSTbName));
|
||||
(void)tjsonAddStringToObject(item, "targetStbUid", i642str(pObj->targetStbUid));
|
||||
(void)tjsonAddStringToObject(item, "fixedSinkVgId", i642str(pObj->fixedSinkVgId));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -381,11 +381,11 @@ void dumpAcct(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "acctId", i642str(pObj->acctId));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "acctId", i642str(pObj->acctId));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -404,16 +404,16 @@ void dumpUser(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "name", pObj->user);
|
||||
tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "superUser", i642str(pObj->superUser));
|
||||
tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion));
|
||||
tjsonAddStringToObject(item, "passVersion", i642str(pObj->passVersion));
|
||||
tjsonAddStringToObject(item, "numOfReadDbs", i642str(taosHashGetSize(pObj->readDbs)));
|
||||
tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs)));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "name", pObj->user);
|
||||
(void)tjsonAddStringToObject(item, "acct", pObj->acct);
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "superUser", i642str(pObj->superUser));
|
||||
(void)tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion));
|
||||
(void)tjsonAddStringToObject(item, "passVersion", i642str(pObj->passVersion));
|
||||
(void)tjsonAddStringToObject(item, "numOfReadDbs", i642str(taosHashGetSize(pObj->readDbs)));
|
||||
(void)tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs)));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -428,12 +428,12 @@ void dumpDnode(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "port", i642str(pObj->port));
|
||||
tjsonAddStringToObject(item, "fqdn", pObj->fqdn);
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "port", i642str(pObj->port));
|
||||
(void)tjsonAddStringToObject(item, "fqdn", pObj->fqdn);
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -448,10 +448,10 @@ void dumpSnode(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -466,10 +466,10 @@ void dumpQnode(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -484,10 +484,10 @@ void dumpMnode(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -502,11 +502,11 @@ void dumpCluster(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
tjsonAddStringToObject(item, "name", pObj->name);
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
|
||||
(void)tjsonAddStringToObject(item, "name", pObj->name);
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
@ -521,29 +521,29 @@ void dumpTrans(SSdb *pSdb, SJson *json) {
|
|||
if (pIter == NULL) break;
|
||||
|
||||
SJson *item = tjsonCreateObject();
|
||||
tjsonAddItemToArray(items, item);
|
||||
tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
tjsonAddStringToObject(item, "stage", i642str(pObj->stage));
|
||||
tjsonAddStringToObject(item, "policy", i642str(pObj->policy));
|
||||
tjsonAddStringToObject(item, "conflict", i642str(pObj->conflict));
|
||||
tjsonAddStringToObject(item, "exec", i642str(pObj->exec));
|
||||
tjsonAddStringToObject(item, "oper", i642str(pObj->oper));
|
||||
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
tjsonAddStringToObject(item, "dbname", pObj->dbname);
|
||||
tjsonAddStringToObject(item, "stbname", pObj->stbname);
|
||||
tjsonAddStringToObject(item, "opername", pObj->opername);
|
||||
tjsonAddStringToObject(item, "commitLogNum", i642str(taosArrayGetSize(pObj->commitActions)));
|
||||
tjsonAddStringToObject(item, "redoActionNum", i642str(taosArrayGetSize(pObj->redoActions)));
|
||||
tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions)));
|
||||
(void)tjsonAddItemToArray(items, item);
|
||||
(void)tjsonAddStringToObject(item, "id", i642str(pObj->id));
|
||||
(void)tjsonAddStringToObject(item, "stage", i642str(pObj->stage));
|
||||
(void)tjsonAddStringToObject(item, "policy", i642str(pObj->policy));
|
||||
(void)tjsonAddStringToObject(item, "conflict", i642str(pObj->conflict));
|
||||
(void)tjsonAddStringToObject(item, "exec", i642str(pObj->exec));
|
||||
(void)tjsonAddStringToObject(item, "oper", i642str(pObj->oper));
|
||||
(void)tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
|
||||
(void)tjsonAddStringToObject(item, "dbname", pObj->dbname);
|
||||
(void)tjsonAddStringToObject(item, "stbname", pObj->stbname);
|
||||
(void)tjsonAddStringToObject(item, "opername", pObj->opername);
|
||||
(void)tjsonAddStringToObject(item, "commitLogNum", i642str(taosArrayGetSize(pObj->commitActions)));
|
||||
(void)tjsonAddStringToObject(item, "redoActionNum", i642str(taosArrayGetSize(pObj->redoActions)));
|
||||
(void)tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions)));
|
||||
sdbRelease(pSdb, pObj);
|
||||
}
|
||||
}
|
||||
|
||||
void dumpHeader(SSdb *pSdb, SJson *json) {
|
||||
tjsonAddStringToObject(json, "sver", i642str(1));
|
||||
tjsonAddStringToObject(json, "applyIndex", i642str(pSdb->applyIndex));
|
||||
tjsonAddStringToObject(json, "applyTerm", i642str(pSdb->applyTerm));
|
||||
tjsonAddStringToObject(json, "applyConfig", i642str(pSdb->applyConfig));
|
||||
(void)tjsonAddStringToObject(json, "sver", i642str(1));
|
||||
(void)tjsonAddStringToObject(json, "applyIndex", i642str(pSdb->applyIndex));
|
||||
(void)tjsonAddStringToObject(json, "applyTerm", i642str(pSdb->applyTerm));
|
||||
(void)tjsonAddStringToObject(json, "applyConfig", i642str(pSdb->applyConfig));
|
||||
|
||||
SJson *maxIdsJson = tjsonCreateObject();
|
||||
tjsonAddItemToObject(json, "maxIds", maxIdsJson);
|
||||
|
@ -553,7 +553,7 @@ void dumpHeader(SSdb *pSdb, SJson *json) {
|
|||
if (i < SDB_MAX) {
|
||||
maxId = pSdb->maxId[i];
|
||||
}
|
||||
tjsonAddStringToObject(maxIdsJson, sdbTableName(i), i642str(maxId));
|
||||
(void)tjsonAddStringToObject(maxIdsJson, sdbTableName(i), i642str(maxId));
|
||||
}
|
||||
|
||||
SJson *tableVersJson = tjsonCreateObject();
|
||||
|
@ -563,7 +563,7 @@ void dumpHeader(SSdb *pSdb, SJson *json) {
|
|||
if (i < SDB_MAX) {
|
||||
tableVer = pSdb->tableVer[i];
|
||||
}
|
||||
tjsonAddStringToObject(tableVersJson, sdbTableName(i), i642str(tableVer));
|
||||
(void)tjsonAddStringToObject(tableVersJson, sdbTableName(i), i642str(tableVer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ void mndDumpSdb() {
|
|||
mInfo("start to dump sdb info to sdb.json");
|
||||
|
||||
char path[PATH_MAX * 2] = {0};
|
||||
snprintf(path, sizeof(path), "%s%smnode", tsDataDir, TD_DIRSEP);
|
||||
(void)snprintf(path, sizeof(path), "%s%smnode", tsDataDir, TD_DIRSEP);
|
||||
|
||||
SMsgCb msgCb = {0};
|
||||
msgCb.reportStartupFp = reportStartup;
|
||||
|
|
|
@ -205,7 +205,7 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
|||
if (pNew->commentSize > 0 && pNew->pComment != NULL) {
|
||||
pOld->commentSize = pNew->commentSize;
|
||||
pOld->pComment = taosMemoryMalloc(pOld->commentSize);
|
||||
memcpy(pOld->pComment, pNew->pComment, pOld->commentSize);
|
||||
(void)memcpy(pOld->pComment, pNew->pComment, pOld->commentSize);
|
||||
}
|
||||
|
||||
if (pOld->pCode != NULL) {
|
||||
|
@ -215,7 +215,7 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
|
|||
if (pNew->codeSize > 0 && pNew->pCode != NULL) {
|
||||
pOld->codeSize = pNew->codeSize;
|
||||
pOld->pCode = taosMemoryMalloc(pOld->codeSize);
|
||||
memcpy(pOld->pCode, pNew->pCode, pOld->codeSize);
|
||||
(void)memcpy(pOld->pCode, pNew->pCode, pOld->codeSize);
|
||||
}
|
||||
|
||||
pOld->scriptType = pNew->scriptType;
|
||||
|
@ -250,7 +250,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
}
|
||||
|
||||
SFuncObj func = {0};
|
||||
memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
|
||||
(void)memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
|
||||
func.createdTime = taosGetTimestampMs();
|
||||
func.funcType = pCreate->funcType;
|
||||
func.scriptType = pCreate->scriptType;
|
||||
|
@ -270,9 +270,9 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
|||
}
|
||||
|
||||
if (func.commentSize > 0) {
|
||||
memcpy(func.pComment, pCreate->pComment, func.commentSize);
|
||||
(void)memcpy(func.pComment, pCreate->pComment, func.commentSize);
|
||||
}
|
||||
memcpy(func.pCode, pCreate->pCode, func.codeSize);
|
||||
(void)memcpy(func.pCode, pCreate->pCode, func.codeSize);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func");
|
||||
if (pTrans == NULL) {
|
||||
|
@ -548,7 +548,7 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
SFuncInfo funcInfo = {0};
|
||||
memcpy(funcInfo.name, pFunc->name, TSDB_FUNC_NAME_LEN);
|
||||
(void)memcpy(funcInfo.name, pFunc->name, TSDB_FUNC_NAME_LEN);
|
||||
funcInfo.funcType = pFunc->funcType;
|
||||
funcInfo.scriptType = pFunc->scriptType;
|
||||
funcInfo.outputType = pFunc->outputType;
|
||||
|
@ -566,21 +566,27 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
memcpy(funcInfo.pCode, pFunc->pCode, pFunc->codeSize);
|
||||
(void)memcpy(funcInfo.pCode, pFunc->pCode, pFunc->codeSize);
|
||||
if (funcInfo.commentSize > 0) {
|
||||
funcInfo.pComment = taosMemoryCalloc(1, funcInfo.commentSize);
|
||||
if (funcInfo.pComment == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
memcpy(funcInfo.pComment, pFunc->pComment, pFunc->commentSize);
|
||||
(void)memcpy(funcInfo.pComment, pFunc->pComment, pFunc->commentSize);
|
||||
}
|
||||
}
|
||||
taosArrayPush(retrieveRsp.pFuncInfos, &funcInfo);
|
||||
if (taosArrayPush(retrieveRsp.pFuncInfos, &funcInfo) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
SFuncExtraInfo extraInfo = {0};
|
||||
extraInfo.funcVersion = pFunc->funcVersion;
|
||||
extraInfo.funcCreatedTime = pFunc->createdTime;
|
||||
taosArrayPush(retrieveRsp.pFuncExtraInfos, &extraInfo);
|
||||
if (taosArrayPush(retrieveRsp.pFuncExtraInfos, &extraInfo) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto RETRIEVE_FUNC_OVER;
|
||||
}
|
||||
|
||||
mndReleaseFunc(pMnode, pFunc);
|
||||
}
|
||||
|
@ -616,7 +622,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int32_t le
|
|||
type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
int32_t bytes = len > 0 ? (int32_t)(len - VARSTR_HEADER_SIZE) : len;
|
||||
|
||||
snprintf(buf, buflen - 1, "%s(%d)", tDataTypes[type].name, type == TSDB_DATA_TYPE_NCHAR ? bytes / 4 : bytes);
|
||||
(void)snprintf(buf, buflen - 1, "%s(%d)", tDataTypes[type].name, type == TSDB_DATA_TYPE_NCHAR ? bytes / 4 : bytes);
|
||||
buf[buflen - 1] = 0;
|
||||
|
||||
return buf;
|
||||
|
@ -643,40 +649,40 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pFunc->name, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)b1, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false);
|
||||
|
||||
if (pFunc->pComment) {
|
||||
char *b2 = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
||||
taosMemoryFree(b2);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, NULL, true);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, NULL, true);
|
||||
}
|
||||
|
||||
int32_t isAgg = (pFunc->funcType == TSDB_FUNC_TYPE_AGGREGATE) ? 1 : 0;
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&isAgg, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&isAgg, false);
|
||||
|
||||
char b3[TSDB_TYPE_STR_MAX_LEN + 1] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, mnodeGenTypeStr(buf, TSDB_TYPE_STR_MAX_LEN, pFunc->outputType, pFunc->outputLen),
|
||||
pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->createdTime, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->codeSize, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->codeSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
char *language = "";
|
||||
|
@ -688,20 +694,20 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
char varLang[TSDB_TYPE_STR_MAX_LEN + 1] = {0};
|
||||
varDataSetLen(varLang, strlen(language));
|
||||
strcpy(varDataVal(varLang), language);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
int32_t varCodeLen = (pFunc->codeSize + VARSTR_HEADER_SIZE) > TSDB_MAX_BINARY_LEN
|
||||
? TSDB_MAX_BINARY_LEN
|
||||
: pFunc->codeSize + VARSTR_HEADER_SIZE;
|
||||
char *b4 = taosMemoryMalloc(varCodeLen);
|
||||
memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
|
||||
(void)memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
|
||||
varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
||||
taosMemoryFree(b4);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pFunc);
|
||||
|
|
|
@ -1375,7 +1375,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
if (data) {
|
||||
// vg id
|
||||
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);
|
||||
varDataSetLen(buf, strlen(varDataVal(buf)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -223,9 +223,9 @@ bool tqGetTablePrimaryKey(STqReader *pReader);
|
|||
void tqSetTablePrimaryKey(STqReader *pReader, int64_t uid);
|
||||
|
||||
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
||||
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
||||
int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
||||
int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
||||
void tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList, const char *id);
|
||||
void tqReaderAddTbUidList(STqReader *pReader, const SArray *pTableUidList);
|
||||
void tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
||||
|
||||
bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid);
|
||||
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,
|
||||
SSnapContext **ctxRet);
|
||||
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 destroySnapContext(SSnapContext *ctx);
|
||||
void destroySnapContext(SSnapContext *ctx);
|
||||
|
||||
// structs
|
||||
struct STsdbCfg {
|
||||
|
|
|
@ -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 tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||
int32_t type, int32_t vgId);
|
||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
|
||||
// tqMeta
|
||||
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 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);
|
||||
|
@ -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 tqMetaDecodeOffsetInfo(STqOffset *info, void *pVal, int32_t vLen);
|
||||
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);
|
||||
// tqSink
|
||||
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)
|
||||
|
||||
#define TQ_ERR_RETURN(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
return code; \
|
||||
} \
|
||||
#define TQ_NULL_GO_TO_END(c) \
|
||||
do { \
|
||||
if (c == NULL) { \
|
||||
code = (terrno == 0 ? TSDB_CODE_OUT_OF_MEMORY : terrno); \
|
||||
goto END; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TQ_SUBSCRIBE_NAME "subscribe"
|
||||
|
|
|
@ -239,12 +239,12 @@ int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
|||
int64_t tsdbGetEarliestTs(STsdb* pTsdb);
|
||||
|
||||
// tq
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode);
|
||||
int32_t tqOpen(const char* path, SVnode* pVnode);
|
||||
void tqNotifyClose(STQ*);
|
||||
void tqClose(STQ*);
|
||||
int tqPushMsg(STQ*, tmsg_t msgType);
|
||||
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);
|
||||
int32_t tqStopStreamTasksAsync(STQ* pTq);
|
||||
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);
|
||||
// STqSnapshotReader ==
|
||||
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);
|
||||
// STqSnapshotWriter ======================================
|
||||
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);
|
||||
}
|
||||
|
||||
static void MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||
int32_t code = 0;
|
||||
(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};
|
||||
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) {
|
||||
tdbTbcMoveToPrev((TBC*)ctx->pCur);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
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};
|
||||
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;
|
||||
}
|
||||
|
||||
static void MoveToFirst(SSnapContext* ctx) {
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
tdbTbcMoveToFirst((TBC*)ctx->pCur);
|
||||
static int32_t MoveToFirst(SSnapContext* ctx) {
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
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));
|
||||
if (data) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
int32_t code = 0;
|
||||
STableInfoForChildTable dataTmp = {0};
|
||||
dataTmp.tableName = taosStrdup(me->name);
|
||||
|
||||
if (dataTmp.tableName == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto END;
|
||||
}
|
||||
dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
|
||||
if (dataTmp.schemaRow == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto END;
|
||||
}
|
||||
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,
|
||||
SSnapContext** ctxRet) {
|
||||
SSnapContext* ctx = taosMemoryCalloc(1, sizeof(SSnapContext));
|
||||
if (ctx == NULL) {
|
||||
return terrno;
|
||||
if (ctx == NULL){
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
*ctxRet = ctx;
|
||||
ctx->pMeta = pVnode->pMeta;
|
||||
|
@ -273,23 +314,29 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
ctx->withMeta = withMeta;
|
||||
ctx->idVersion = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
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);
|
||||
if (ctx->suidInfo == NULL) {
|
||||
return terrno;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||
}
|
||||
taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);
|
||||
|
||||
ctx->index = 0;
|
||||
ctx->idList = taosArrayInit(100, sizeof(int64_t));
|
||||
if (ctx->idList == NULL){
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||
}
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int vLen = 0, kLen = 0;
|
||||
|
||||
metaDebug("tmqsnap init snapVersion:%" PRIi64, ctx->snapVersion);
|
||||
MoveToFirst(ctx);
|
||||
int32_t code = MoveToFirst(ctx);
|
||||
if (code != 0){
|
||||
return code;
|
||||
}
|
||||
while (1) {
|
||||
int32_t ret = tdbTbcNext((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||
if (ret < 0) break;
|
||||
|
@ -301,15 +348,18 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
continue;
|
||||
}
|
||||
|
||||
if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) <
|
||||
0) { // check if table exist for now, need optimize later
|
||||
if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) < 0) { // check if table exist for now, need optimize later
|
||||
continue;
|
||||
}
|
||||
|
||||
SDecoder dc = {0};
|
||||
SMetaEntry me = {0};
|
||||
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 ((me.uid != ctx->suid && me.type == TSDB_SUPER_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);
|
||||
SIdInfo info = {0};
|
||||
taosHashPut(ctx->idVersion, &tmp->uid, sizeof(tb_uid_t), &info, sizeof(SIdInfo));
|
||||
|
||||
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);
|
||||
|
||||
MoveToSnapShotVersion(ctx);
|
||||
code = MoveToSnapShotVersion(ctx);
|
||||
if (code != 0){
|
||||
return code;
|
||||
}
|
||||
while (1) {
|
||||
int32_t ret = tdbTbcPrev((TBC*)ctx->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||
if (ret < 0) break;
|
||||
|
@ -338,12 +396,20 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
continue;
|
||||
}
|
||||
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};
|
||||
SMetaEntry me = {0};
|
||||
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 ((me.uid != ctx->suid && me.type == TSDB_SUPER_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) ||
|
||||
(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);
|
||||
}
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(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));
|
||||
if (!idData) {
|
||||
metaError("meta/snap: null idData");
|
||||
return TSDB_CODE_FAILED;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
idData->index = i;
|
||||
|
@ -377,13 +450,12 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
return TDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t destroySnapContext(SSnapContext* ctx) {
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
void destroySnapContext(SSnapContext* ctx) {
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
taosArrayDestroy(ctx->idList);
|
||||
taosHashCleanup(ctx->idVersion);
|
||||
taosHashCleanup(ctx->suidInfo);
|
||||
taosMemoryFree(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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));
|
||||
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;
|
||||
}
|
||||
taosArrayPush(reqs.pArray, req);
|
||||
reqs.nReqs = 1;
|
||||
|
||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqs, *contLen, ret);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
ret = TAOS_GET_TERRNO(ret);
|
||||
goto end;
|
||||
}
|
||||
*contLen += sizeof(SMsgHead);
|
||||
*pBuf = taosMemoryMalloc(*contLen);
|
||||
if (NULL == *pBuf) {
|
||||
ret = -1;
|
||||
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto end;
|
||||
}
|
||||
SEncoder coder = {0};
|
||||
tEncoderInit(&coder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
||||
if (tEncodeSVCreateTbBatchReq(&coder, &reqs) < 0) {
|
||||
ret = tEncodeSVCreateTbBatchReq(&coder, &reqs);
|
||||
tEncoderClear(&coder);
|
||||
|
||||
if (ret < 0) {
|
||||
taosMemoryFreeClear(*pBuf);
|
||||
tEncoderClear(&coder);
|
||||
ret = -1;
|
||||
ret = TAOS_GET_TERRNO(ret);
|
||||
goto end;
|
||||
}
|
||||
tEncoderClear(&coder);
|
||||
|
||||
end:
|
||||
taosArrayDestroy(reqs.pArray);
|
||||
|
@ -428,48 +504,46 @@ static int32_t buildSuperTableInfo(SVCreateStbReq* req, void** pBuf, int32_t* co
|
|||
int32_t ret = 0;
|
||||
tEncodeSize(tEncodeSVCreateStbReq, req, *contLen, ret);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
return TAOS_GET_TERRNO(ret);
|
||||
}
|
||||
|
||||
*contLen += sizeof(SMsgHead);
|
||||
*pBuf = taosMemoryMalloc(*contLen);
|
||||
if (NULL == *pBuf) {
|
||||
return terrno;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, POINTER_SHIFT(*pBuf, sizeof(SMsgHead)), *contLen);
|
||||
if ((ret = tEncodeSVCreateStbReq(&encoder, req)) < 0) {
|
||||
taosMemoryFreeClear(*pBuf);
|
||||
tEncoderClear(&encoder);
|
||||
return ret;
|
||||
}
|
||||
ret = tEncodeSVCreateStbReq(&encoder, req);
|
||||
tEncoderClear(&encoder);
|
||||
if (ret < 0) {
|
||||
taosMemoryFreeClear(*pBuf);
|
||||
return TAOS_GET_TERRNO(ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t setForSnapShot(SSnapContext* ctx, int64_t uid) {
|
||||
int c = 0;
|
||||
|
||||
if (uid == 0) {
|
||||
ctx->index = 0;
|
||||
return c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &uid, sizeof(tb_uid_t));
|
||||
if (!idInfo) {
|
||||
return -1;
|
||||
if (idInfo == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
ctx->index = idInfo->index;
|
||||
|
||||
return c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid) {
|
||||
bool ret = false;
|
||||
SSchemaWrapper* schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1);
|
||||
if (schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
|
||||
void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid){
|
||||
bool ret = false;
|
||||
SSchemaWrapper *schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1);
|
||||
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){
|
||||
ret = true;
|
||||
}
|
||||
tDeleteSchemaWrapper(schema);
|
||||
|
@ -493,11 +567,15 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
|||
}
|
||||
|
||||
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++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
if (!idInfo) {
|
||||
metaError("meta/snap: null idInfo");
|
||||
return TSDB_CODE_FAILED;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
*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);
|
||||
}
|
||||
|
||||
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};
|
||||
SMetaEntry me = {0};
|
||||
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);
|
||||
|
||||
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);
|
||||
*type = TDMT_VND_CREATE_STB;
|
||||
|
||||
} 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)) {
|
||||
STableInfoForChildTable* data =
|
||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||
if (!data) {
|
||||
metaError("meta/snap: null data");
|
||||
return TSDB_CODE_FAILED;
|
||||
ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto END;
|
||||
}
|
||||
|
||||
SVCreateTbReq req = {0};
|
||||
|
@ -549,46 +634,48 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
|||
req.ctb.stbName = data->tableName;
|
||||
|
||||
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;
|
||||
if (tTagIsJson(p)) {
|
||||
if (p->nTag != 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 {
|
||||
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.");
|
||||
return TSDB_CODE_FAILED;
|
||||
taosArrayDestroy(pTagVals);
|
||||
taosArrayDestroy(tagName);
|
||||
goto END;
|
||||
}
|
||||
int16_t nCols = taosArrayGetSize(pTagVals);
|
||||
for (int j = 0; j < nCols; ++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];
|
||||
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);
|
||||
}
|
||||
// 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.tagName = tagName;
|
||||
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
||||
*type = TDMT_VND_CREATE_TABLE;
|
||||
|
@ -605,15 +692,15 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe
|
|||
*type = TDMT_VND_CREATE_TABLE;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
||||
SMetaTableInfo result = {0};
|
||||
int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) {
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int vLen, kLen;
|
||||
|
@ -621,14 +708,17 @@ SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
|||
while (1) {
|
||||
if (ctx->index >= taosArrayGetSize(ctx->idList)) {
|
||||
metaDebug("tmqsnap get uid info end");
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||
if (uidTmp == NULL){
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
ctx->index++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
if (!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);
|
||||
|
@ -637,44 +727,46 @@ SMetaTableInfo getMetaTableInfoFromSnapshot(SSnapContext* ctx) {
|
|||
idInfo->version);
|
||||
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};
|
||||
SMetaEntry me = {0};
|
||||
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);
|
||||
|
||||
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*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||
result.uid = me.uid;
|
||||
result.suid = me.ctbEntry.suid;
|
||||
result.schema = tCloneSSchemaWrapper(data->schemaRow);
|
||||
strcpy(result.tbName, me.name);
|
||||
tDecoderClear(&dc);
|
||||
break;
|
||||
if (data == NULL) {
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/snap: null data");
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
result->suid = me.ctbEntry.suid;
|
||||
result->schema = tCloneSSchemaWrapper(data->schemaRow);
|
||||
} else if (ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_NORMAL_TABLE) {
|
||||
result.uid = me.uid;
|
||||
result.suid = 0;
|
||||
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;
|
||||
result->suid = 0;
|
||||
result->schema = tCloneSSchemaWrapper(&me.ntbEntry.schemaRow);
|
||||
} else {
|
||||
metaDebug("tmqsnap get uid continue");
|
||||
tDecoderClear(&dc);
|
||||
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 result;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -60,35 +60,41 @@ static bool tqOffsetEqual(const STqOffset* pLeft, const STqOffset* pRight) {
|
|||
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));
|
||||
if (pTq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pVnode->pTq = pTq;
|
||||
pTq->path = taosStrdup(path);
|
||||
pTq->pVnode = pVnode;
|
||||
|
||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
if (pTq->pHandle == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashSetFreeFp(pTq->pHandle, tqDestroyTqHandle);
|
||||
|
||||
taosInitRWLatch(&pTq->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);
|
||||
if (pTq->pCheckInfo == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashSetFreeFp(pTq->pCheckInfo, (FDelete)tDeleteSTqCheckInfo);
|
||||
|
||||
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);
|
||||
|
||||
int32_t code = tqInitialize(pTq);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tqClose(pTq);
|
||||
return NULL;
|
||||
} else {
|
||||
return pTq;
|
||||
}
|
||||
return tqInitialize(pTq);
|
||||
}
|
||||
|
||||
int32_t tqInitialize(STQ* pTq) {
|
||||
|
@ -102,11 +108,7 @@ int32_t tqInitialize(STQ* pTq) {
|
|||
|
||||
streamMetaLoadAllTasks(pTq->pStreamMeta);
|
||||
|
||||
if (tqMetaOpen(pTq) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return tqMetaOpen(pTq);
|
||||
}
|
||||
|
||||
void tqClose(STQ* pTq) {
|
||||
|
@ -150,25 +152,32 @@ void tqNotifyClose(STQ* pTq) {
|
|||
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};
|
||||
if (tDeserializeSMqPollReq(pHandle->msg->pCont, pHandle->msg->contLen, &req) < 0) {
|
||||
tqError("tDeserializeSMqPollReq %d failed", pHandle->msg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
code = tDeserializeSMqPollReq(pHandle->msg->pCont, pHandle->msg->contLen, &req);
|
||||
if (code < 0) {
|
||||
tqError("tDeserializeSMqPollReq %d failed, code:%d", pHandle->msg->contLen, code);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
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,
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
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 buf2[TSDB_OFFSET_LEN] = {0};
|
||||
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,
|
||||
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) {
|
||||
|
@ -217,8 +224,9 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t
|
|||
goto end;
|
||||
}
|
||||
|
||||
STqOffset* pSavedOffset = (STqOffset*)tqMetaGetOffset(pTq, pOffset->subKey);
|
||||
if (pSavedOffset != NULL && tqOffsetEqual(pOffset, pSavedOffset)) {
|
||||
STqOffset* pSavedOffset = NULL;
|
||||
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,
|
||||
vgId, pOffset->subKey, pOffset->val.version, pSavedOffset->val.version);
|
||||
goto end; // no need to update the offset value
|
||||
|
@ -328,7 +336,7 @@ int32_t tqProcessPollPush(STQ* pTq, SRpcMsg* pMsg) {
|
|||
.pCont = pHandle->msg->pCont,
|
||||
.contLen = pHandle->msg->contLen,
|
||||
.info = pHandle->msg->info};
|
||||
tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||
(void)tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||
taosMemoryFree(pHandle->msg);
|
||||
pHandle->msg = NULL;
|
||||
}
|
||||
|
@ -434,18 +442,16 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
STqOffset* pSavedOffset = (STqOffset*)tqMetaGetOffset(pTq, vgOffset.offset.subKey);
|
||||
if (pSavedOffset == NULL) {
|
||||
terrno = TSDB_CODE_TMQ_NO_COMMITTED;
|
||||
return terrno;
|
||||
STqOffset* pSavedOffset = NULL;
|
||||
int32_t code = tqMetaGetOffset(pTq, vgOffset.offset.subKey, &pSavedOffset);
|
||||
if (code != 0) {
|
||||
return TSDB_CODE_TMQ_NO_COMMITTED;
|
||||
}
|
||||
vgOffset.offset = *pSavedOffset;
|
||||
|
||||
int32_t code = 0;
|
||||
tEncodeSize(tEncodeMqVgOffset, &vgOffset, len, code);
|
||||
if (code < 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
void* buf = rpcMallocCont(len);
|
||||
|
@ -455,8 +461,12 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, buf, len);
|
||||
tEncodeMqVgOffset(&encoder, &vgOffset);
|
||||
code = tEncodeMqVgOffset(&encoder, &vgOffset);
|
||||
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};
|
||||
|
||||
|
@ -465,11 +475,11 @@ int32_t tqProcessVgCommittedInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
|
||||
int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
int32_t code = 0;
|
||||
SMqPollReq req = {0};
|
||||
if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
|
||||
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));
|
||||
if (pHandle == NULL) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s not found", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
taosRUnLockLatch(&pTq->lock);
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
|
||||
// 2. check rebalance status
|
||||
if (pHandle->consumerId != consumerId) {
|
||||
tqDebug("ERROR consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||
consumerId, vgId, req.subKey, pHandle->consumerId);
|
||||
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
taosRUnLockLatch(&pTq->lock);
|
||||
return -1;
|
||||
return TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
|
||||
}
|
||||
|
||||
int64_t sver = 0, ever = 0;
|
||||
|
@ -500,13 +509,15 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
taosRUnLockLatch(&pTq->lock);
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||
code = tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (req.useSnapshot == true) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto END;
|
||||
}
|
||||
|
||||
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
||||
|
@ -514,13 +525,13 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
dataRsp.common.rspOffset.version = reqOffset.version;
|
||||
} else if (reqOffset.type < 0) {
|
||||
STqOffset* pOffset = (STqOffset*)(STqOffset*)tqMetaGetOffset(pTq, req.subKey);
|
||||
if (pOffset != NULL) {
|
||||
STqOffset* pOffset = NULL;
|
||||
code = tqMetaGetOffset(pTq, req.subKey, &pOffset);
|
||||
if (code == 0) {
|
||||
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s, no valid wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto END;
|
||||
}
|
||||
|
||||
dataRsp.common.rspOffset.version = pOffset->val.version;
|
||||
|
@ -538,14 +549,15 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
} else {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||
reqOffset.type);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto END;
|
||||
}
|
||||
|
||||
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);
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
||||
tqUnregisterPushHandle(pTq, pHandle);
|
||||
|
||||
code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||
if (code != 0) {
|
||||
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) {
|
||||
STqCheckInfo info = {0};
|
||||
if(tqMetaDecodeCheckInfo(&info, msg, msgLen) != 0){
|
||||
return -1;
|
||||
int32_t code = tqMetaDecodeCheckInfo(&info, msg, msgLen);
|
||||
if(code != 0){
|
||||
return code;
|
||||
}
|
||||
|
||||
if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo));
|
||||
if (code != 0) {
|
||||
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 -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return tqMetaSaveInfo(pTq, pTq->pCheckStore, info.topic, strlen(info.topic), msg, msgLen);
|
||||
}
|
||||
|
||||
int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||
if (taosHashRemove(pTq->pCheckInfo, msg, strlen(msg)) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
if (tqMetaDeleteInfo(pTq, pTq->pCheckStore, msg, strlen(msg)) < 0) {
|
||||
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;
|
||||
return tqMetaDeleteInfo(pTq, pTq->pCheckStore, msg, strlen(msg));
|
||||
}
|
||||
|
||||
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};
|
||||
|
||||
tDecoderInit(&dc, (uint8_t*)msg, msgLen);
|
||||
|
||||
ret = tDecodeSMqRebVgReq(&dc, &req);
|
||||
// decode req
|
||||
if (tDecodeSMqRebVgReq(&dc, &req) < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
tDecoderClear(&dc);
|
||||
return -1;
|
||||
if (ret < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
return tqStreamTaskProcessCheckRsp(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode));
|
||||
}
|
||||
|
||||
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,
|
||||
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) {
|
||||
pHandle->execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (pHandle->execHandle.execDb.pFilterOutTbUid == NULL) return -1;
|
||||
int32_t size = 0;
|
||||
if (tDecodeI32(pDecoder, &size) < 0) return -1;
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
int64_t tbUid = 0;
|
||||
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) {
|
||||
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};
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
int32_t code = tDecodeSTqCheckInfo(&decoder, info);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (code != 0) {
|
||||
tDeleteSTqCheckInfo(info);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -91,11 +93,12 @@ int32_t tqMetaDecodeOffsetInfo(STqOffset* info, void* pVal, int32_t vLen) {
|
|||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
int32_t code = tDecodeSTqOffset(&decoder, info);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (code != 0) {
|
||||
tDeleteSTqOffset(info);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -131,32 +134,36 @@ END:
|
|||
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));
|
||||
if (data == NULL) {
|
||||
int vLen = 0;
|
||||
if (tdbTbGet(pTq->pOffsetStore, subkey, strlen(subkey), &data, &vLen) < 0) {
|
||||
tdbFree(data);
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
STqOffset offset = {0};
|
||||
if (tqMetaDecodeOffsetInfo(&offset, data, vLen) != TDB_CODE_SUCCESS) {
|
||||
tdbFree(data);
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (taosHashPut(pTq->pOffset, subkey, strlen(subkey), &offset, sizeof(STqOffset)) != 0) {
|
||||
tDeleteSTqOffset(&offset);
|
||||
tdbFree(data);
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
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 {
|
||||
return data;
|
||||
*pOffset = data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
handle->pRef = walOpenRef(pVnode->pWal);
|
||||
if (handle->pRef == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TQ_ERR_RETURN(walSetRefVer(handle->pRef, handle->snapshotVer));
|
||||
|
||||
TQ_NULL_GO_TO_END(handle->pRef);
|
||||
TQ_ERR_GO_TO_END(walSetRefVer(handle->pRef, handle->snapshotVer));
|
||||
|
||||
SReadHandle reader = {
|
||||
.vnode = pVnode,
|
||||
|
@ -214,43 +220,36 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
|
|||
initStorageAPI(&reader.api);
|
||||
|
||||
if (handle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
handle->execHandle.task = qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId,
|
||||
&handle->execHandle.numOfCols, handle->consumerId);
|
||||
if (handle->execHandle.task == NULL) {
|
||||
tqError("cannot create exec task for %s", handle->subKey);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
handle->execHandle.task =
|
||||
qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId, &handle->execHandle.numOfCols, handle->consumerId);
|
||||
TQ_NULL_GO_TO_END(handle->execHandle.task);
|
||||
void* scanner = NULL;
|
||||
(void)qExtractStreamScanner(handle->execHandle.task, &scanner);
|
||||
if (scanner == NULL) {
|
||||
tqError("cannot extract stream scanner for %s", handle->subKey);
|
||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
||||
}
|
||||
qExtractStreamScanner(handle->execHandle.task, &scanner);
|
||||
TQ_NULL_GO_TO_END(scanner);
|
||||
handle->execHandle.pTqReader = qExtractReaderFromStreamScanner(scanner);
|
||||
if (handle->execHandle.pTqReader == NULL) {
|
||||
tqError("cannot extract exec reader for %s", handle->subKey);
|
||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
||||
}
|
||||
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
||||
TQ_NULL_GO_TO_END(handle->pWalReader);
|
||||
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
||||
|
||||
buildSnapContext(reader.vnode, reader.version, 0, handle->execHandle.subType, handle->fetchMeta,
|
||||
(SSnapContext**)(&reader.sContext));
|
||||
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||
TQ_ERR_GO_TO_END(buildSnapContext(reader.vnode, reader.version, 0, handle->execHandle.subType, handle->fetchMeta,
|
||||
(SSnapContext**)(&reader.sContext)));
|
||||
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) {
|
||||
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
|
||||
|
||||
if (handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) {
|
||||
TQ_NULL_GO_TO_END(handle->pWalReader);
|
||||
if(handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) {
|
||||
if (nodesStringToNode(handle->execHandle.execTb.qmsg, &handle->execHandle.execTb.node) != 0) {
|
||||
tqError("nodesStringToNode error in sub stable, since %s", terrstr());
|
||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
buildSnapContext(reader.vnode, reader.version, handle->execHandle.execTb.suid, handle->execHandle.subType,
|
||||
handle->fetchMeta, (SSnapContext**)(&reader.sContext));
|
||||
TQ_ERR_GO_TO_END(buildSnapContext(reader.vnode, reader.version, handle->execHandle.execTb.suid, handle->execHandle.subType,
|
||||
handle->fetchMeta, (SSnapContext**)(&reader.sContext)));
|
||||
handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId);
|
||||
|
||||
TQ_NULL_GO_TO_END(handle->execHandle.task);
|
||||
SArray* tbUidList = NULL;
|
||||
int ret = qGetTableList(handle->execHandle.execTb.suid, pVnode, handle->execHandle.execTb.node, &tbUidList,
|
||||
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,
|
||||
handle->execHandle.execTb.suid);
|
||||
handle->execHandle.pTqReader = tqReaderOpen(pVnode);
|
||||
TQ_NULL_GO_TO_END(handle->execHandle.pTqReader);
|
||||
tqReaderSetTbUidList(handle->execHandle.pTqReader, tbUidList, NULL);
|
||||
taosArrayDestroy(tbUidList);
|
||||
}
|
||||
return 0;
|
||||
|
||||
END:
|
||||
return code;
|
||||
}
|
||||
|
||||
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 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->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) {
|
||||
handle->execHandle.execDb.pFilterOutTbUid =
|
||||
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.qmsg = taosStrdup(req->qmsg);
|
||||
}
|
||||
|
||||
handle->snapshotVer = walGetCommittedVer(pTq->pVnode->pWal);
|
||||
|
||||
if (tqMetaInitHandle(pTq, handle) < 0) {
|
||||
return -1;
|
||||
int32_t code = tqMetaInitHandle(pTq, handle);
|
||||
if (code != 0){
|
||||
return code;
|
||||
}
|
||||
tqInfo("tqMetaCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey,
|
||||
handle->consumerId, vgId, handle->snapshotVer);
|
||||
|
@ -377,10 +383,12 @@ END:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t replaceTqPath(char** path) {
|
||||
char* tpath = NULL;
|
||||
int32_t code = TDB_CODE_SUCCESS;
|
||||
TQ_ERR_RETURN(tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME));
|
||||
static int32_t replaceTqPath(char** path){
|
||||
char* tpath = NULL;
|
||||
int32_t code = tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME);
|
||||
if (code != 0){
|
||||
return code;
|
||||
}
|
||||
taosMemoryFree(*path);
|
||||
*path = tpath;
|
||||
return TDB_CODE_SUCCESS;
|
||||
|
@ -407,7 +415,7 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
|||
END:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
tdbTbcClose(pCur);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tDeleteSTqCheckInfo(&info);
|
||||
return code;
|
||||
}
|
||||
|
@ -480,7 +488,7 @@ END:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tqMetaClose(STQ* pTq) {
|
||||
void tqMetaClose(STQ* pTq) {
|
||||
if (pTq->pExecStore) {
|
||||
(void)tdbTbClose(pTq->pExecStore);
|
||||
}
|
||||
|
@ -491,5 +499,4 @@ int32_t tqMetaClose(STQ* pTq) {
|
|||
(void)tdbTbClose(pTq->pOffsetStore);
|
||||
}
|
||||
(void)tdbClose(pTq->pMetaDB);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,17 +22,28 @@ int32_t tqProcessSubmitReqForSubscribe(STQ* pTq) {
|
|||
}
|
||||
SRpcMsg msg = {.msgType = TDMT_VND_TMQ_CONSUME_PUSH};
|
||||
msg.pCont = rpcMallocCont(sizeof(SMsgHead));
|
||||
if (msg.pCont == NULL) {
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
msg.contLen = sizeof(SMsgHead);
|
||||
SMsgHead *pHead = msg.pCont;
|
||||
pHead->vgId = TD_VID(pTq->pVnode);
|
||||
pHead->contLen = msg.contLen;
|
||||
tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||
return 0;
|
||||
int32_t code = tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
|
||||
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 code = 0;
|
||||
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);
|
||||
|
@ -46,10 +57,10 @@ int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) {
|
|||
// 2. the vnode should be the leader.
|
||||
// 3. the stream is not suspended yet.
|
||||
if ((!tsDisableStream) && (numOfTasks > 0)) {
|
||||
tqScanWalAsync(pTq, true);
|
||||
code = tqScanWalAsync(pTq, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
if (pHandle->msg->pCont == NULL) {
|
||||
taosMemoryFree(pHandle->msg);
|
||||
pHandle->msg = NULL;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
} else {
|
||||
// tqPushDataRsp(pHandle, vgId);
|
||||
tqPushEmptyDataRsp(pHandle, vgId);
|
||||
|
||||
void* tmp = pHandle->msg->pCont;
|
||||
memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||
(void)memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||
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;
|
||||
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,
|
||||
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;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
|
||||
if(taosHashGetSize(pTq->pPushMgr) <= 0) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
if(ret == 0 && pHandle->msg != NULL) {
|
||||
// tqPushDataRsp(pHandle, vgId);
|
||||
tqPushEmptyDataRsp(pHandle, vgId);
|
||||
|
||||
rpcFreeCont(pHandle->msg->pCont);
|
||||
taosMemoryFree(pHandle->msg);
|
||||
pHandle->msg = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,26 +27,26 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
|
||||
int64_t tbSuid = pHandle->execHandle.execTb.suid;
|
||||
int64_t realTbSuid = 0;
|
||||
SDecoder coder;
|
||||
SDecoder dcoder = {0};
|
||||
void* data = POINTER_SHIFT(body, 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) {
|
||||
SVCreateStbReq req = {0};
|
||||
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
|
||||
if (tDecodeSVCreateStbReq(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
} else if (msgType == TDMT_VND_DROP_STB) {
|
||||
SVDropStbReq req = {0};
|
||||
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
|
||||
if (tDecodeSVDropStbReq(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
} else if (msgType == TDMT_VND_CREATE_TABLE) {
|
||||
SVCreateTbBatchReq req = {0};
|
||||
if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) {
|
||||
if (tDecodeSVCreateTbBatchReq(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -66,34 +66,42 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
realTbSuid = tbSuid;
|
||||
SVCreateTbBatchReq reqNew = {0};
|
||||
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++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
if (pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid) {
|
||||
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;
|
||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret);
|
||||
void* buf = taosMemoryMalloc(tlen);
|
||||
if (NULL == buf) {
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFreeClear(pCreateReq->comment);
|
||||
if (pCreateReq->type == TSDB_CHILD_TABLE) {
|
||||
taosArrayDestroy(pCreateReq->ctb.tagName);
|
||||
}
|
||||
}
|
||||
tDeleteSVCreateTbBatchReq(&req);
|
||||
goto end;
|
||||
}
|
||||
SEncoder coderNew = {0};
|
||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||
tEncodeSVCreateTbBatchReq(&coderNew, &reqNew);
|
||||
ret = tEncodeSVCreateTbBatchReq(&coderNew, &reqNew);
|
||||
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);
|
||||
taosMemoryFree(buf);
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
|
@ -103,7 +111,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
} else if (msgType == TDMT_VND_ALTER_TABLE) {
|
||||
SVAlterTbReq req = {0};
|
||||
|
||||
if (tDecodeSVAlterTbReq(&coder, &req) < 0) {
|
||||
if (tDecodeSVAlterTbReq(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -119,7 +127,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
} else if (msgType == TDMT_VND_DROP_TABLE) {
|
||||
SVDropTbBatchReq req = {0};
|
||||
|
||||
if (tDecodeSVDropTbBatchReq(&coder, &req) < 0) {
|
||||
if (tDecodeSVDropTbBatchReq(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -140,15 +148,21 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
realTbSuid = tbSuid;
|
||||
SVDropTbBatchReq reqNew = {0};
|
||||
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq));
|
||||
if (reqNew.pArray == NULL) {
|
||||
goto end;
|
||||
}
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pDropReq = req.pReqs + iReq;
|
||||
if (pDropReq->suid == tbSuid) {
|
||||
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;
|
||||
tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret);
|
||||
void* buf = taosMemoryMalloc(tlen);
|
||||
|
@ -158,23 +172,28 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
|
|||
}
|
||||
SEncoder coderNew = {0};
|
||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||
tEncodeSVDropTbBatchReq(&coderNew, &reqNew);
|
||||
ret = tEncodeSVDropTbBatchReq(&coderNew, &reqNew);
|
||||
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);
|
||||
taosMemoryFree(buf);
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
}
|
||||
} else if (msgType == TDMT_VND_DELETE) {
|
||||
SDeleteRes req = {0};
|
||||
if (tDecodeDeleteRes(&coder, &req) < 0) {
|
||||
if (tDecodeDeleteRes(&dcoder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
}
|
||||
|
||||
end:
|
||||
tDecoderClear(&coder);
|
||||
tDecoderClear(&dcoder);
|
||||
return tbSuid == realTbSuid;
|
||||
}
|
||||
|
||||
|
@ -242,10 +261,10 @@ END:
|
|||
|
||||
bool tqGetTablePrimaryKey(STqReader* pReader) { return pReader->hasPrimaryKey; }
|
||||
|
||||
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid) {
|
||||
bool ret = false;
|
||||
SSchemaWrapper* schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
||||
if (schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) {
|
||||
void tqSetTablePrimaryKey(STqReader* pReader, int64_t uid){
|
||||
bool ret = false;
|
||||
SSchemaWrapper *schema = metaGetTableSchema(pReader->pVnodeMeta, uid, -1, 1);
|
||||
if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){
|
||||
ret = true;
|
||||
}
|
||||
tDeleteSchemaWrapper(schema);
|
||||
|
@ -333,7 +352,7 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con
|
|||
return code;
|
||||
}
|
||||
|
||||
memcpy(data, pBody, len);
|
||||
(void)memcpy(data, pBody, len);
|
||||
SPackedData data1 = (SPackedData){.ver = ver, .msgLen = len, .msgStr = data};
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
pReader->nextBlk += 1;
|
||||
continue;
|
||||
|
@ -412,7 +436,9 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) {
|
|||
void* pBody = POINTER_SHIFT(pWalReader->pHead->head.body, sizeof(SSubmitReq2Msg));
|
||||
int32_t bodyLen = pWalReader->pHead->head.bodyLen - sizeof(SSubmitReq2Msg);
|
||||
int64_t ver = pWalReader->pHead->head.version;
|
||||
tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver);
|
||||
if (tqReaderSetSubmitMsg(pReader, pBody, bodyLen, ver) != 0) {
|
||||
return false;
|
||||
}
|
||||
pReader->nextBlk = 0;
|
||||
}
|
||||
}
|
||||
|
@ -423,13 +449,14 @@ int32_t tqReaderSetSubmitMsg(STqReader* pReader, void* msgStr, int32_t msgLen, i
|
|||
pReader->msg.ver = ver;
|
||||
|
||||
tqDebug("tq reader set msg %p %d", msgStr, msgLen);
|
||||
SDecoder decoder;
|
||||
SDecoder decoder = {0};
|
||||
|
||||
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);
|
||||
tqError("DecodeSSubmitReq2 error, msgLen:%d, ver:%" PRId64, msgLen, ver);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
@ -453,6 +480,9 @@ bool tqNextBlockImpl(STqReader* pReader, const char* idstr) {
|
|||
(pReader->nextBlk + 1), numOfBlocks, idstr);
|
||||
|
||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||
if (pSubmitTbData == NULL){
|
||||
return false;
|
||||
}
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
@ -482,6 +512,7 @@ bool tqNextDataBlockFilterOut(STqReader* pReader, SHashObj* filterOutUids) {
|
|||
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
|
||||
while (pReader->nextBlk < blockSz) {
|
||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||
if (pSubmitTbData == NULL) return false;
|
||||
if (filterOutUids == NULL) return true;
|
||||
|
||||
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 code;
|
||||
int32_t code = 0;
|
||||
|
||||
int32_t cnt = 0;
|
||||
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->pSchema = taosMemoryCalloc(cnt, sizeof(SSchema));
|
||||
if (pDst->pSchema == NULL) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
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);
|
||||
code = blockDataAppendColInfo(pBlock, &colInfo);
|
||||
if (code != 0) {
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -556,10 +587,13 @@ static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema,
|
|||
SSchema* pColSchema = &pSchema->pSchema[i];
|
||||
col_id_t colIdSchema = pColSchema->colId;
|
||||
|
||||
col_id_t colIdNeed = *(col_id_t*)taosArrayGet(pColIdList, j);
|
||||
if (colIdSchema < colIdNeed) {
|
||||
col_id_t* pColIdNeed = (col_id_t*)taosArrayGet(pColIdList, j);
|
||||
if (pColIdNeed == NULL) {
|
||||
break;
|
||||
}
|
||||
if (colIdSchema < *pColIdNeed) {
|
||||
i++;
|
||||
} else if (colIdSchema > colIdNeed) {
|
||||
} else if (colIdSchema > *pColIdNeed) {
|
||||
j++;
|
||||
} else {
|
||||
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};
|
||||
if (COL_VAL_IS_VALUE(pColVal)) {
|
||||
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);
|
||||
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) {
|
||||
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++);
|
||||
|
||||
TSDB_CHECK_NULL(pSubmitTbData, code, line, END, terrno);
|
||||
SSDataBlock* pBlock = pReader->pResBlock;
|
||||
*pRes = pBlock;
|
||||
|
||||
|
@ -625,8 +662,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
"version %d, possibly dropped table",
|
||||
vgId, suid, uid, pReader->cachedSchemaVer);
|
||||
pReader->cachedSchemaSuid = 0;
|
||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
return -1;
|
||||
return TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
}
|
||||
|
||||
pReader->cachedSchemaUid = uid;
|
||||
|
@ -635,29 +671,23 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
|
||||
ASSERT(pReader->cachedSchemaVer == pReader->pSchemaWrapper->version);
|
||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
||||
int32_t code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tqError("vgId:%d failed to build data block, code:%s", vgId, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numOfRows = 0;
|
||||
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||
SColData* pCol = taosArrayGet(pSubmitTbData->aCol, 0);
|
||||
TSDB_CHECK_NULL(pCol, code, line, END, terrno);
|
||||
numOfRows = pCol->nVal;
|
||||
} else {
|
||||
numOfRows = taosArrayGetSize(pSubmitTbData->aRowP);
|
||||
}
|
||||
|
||||
if (blockDataEnsureCapacity(pBlock, numOfRows) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
code = blockDataEnsureCapacity(pBlock, numOfRows);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
pBlock->info.rows = numOfRows;
|
||||
|
||||
int32_t colActual = blockDataGetNumOfCols(pBlock);
|
||||
|
||||
// convert and scan one block
|
||||
|
@ -668,7 +698,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
int32_t sourceIdx = 0;
|
||||
while (targetIdx < colActual) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
||||
|
||||
TSDB_CHECK_NULL(pColData, code, line, END, terrno);
|
||||
if (sourceIdx >= numOfCols) {
|
||||
tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols);
|
||||
colDataSetNNULL(pColData, 0, numOfRows);
|
||||
|
@ -676,20 +706,17 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
continue;
|
||||
}
|
||||
|
||||
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
||||
SColVal colVal;
|
||||
|
||||
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);
|
||||
SColData* pCol = taosArrayGet(pCols, sourceIdx);
|
||||
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, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
|
||||
if (pCol->cid < pColData->info.colId) {
|
||||
sourceIdx++;
|
||||
} else if (pCol->cid == pColData->info.colId) {
|
||||
for (int32_t i = 0; i < pCol->nVal; i++) {
|
||||
tColDataGetValue(pCol, i, &colVal);
|
||||
int32_t code = doSetVal(pColData, i, &colVal);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = doSetVal(pColData, i, &colVal);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
sourceIdx++;
|
||||
targetIdx++;
|
||||
|
@ -701,26 +728,28 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
} else {
|
||||
SArray* pRows = pSubmitTbData->aRowP;
|
||||
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++) {
|
||||
SRow* pRow = taosArrayGetP(pRows, i);
|
||||
TSDB_CHECK_NULL(pRow, code, line, END, terrno);
|
||||
int32_t sourceIdx = 0;
|
||||
|
||||
for (int32_t j = 0; j < colActual; j++) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
||||
TSDB_CHECK_NULL(pColData, code, line, END, terrno);
|
||||
|
||||
while (1) {
|
||||
SColVal colVal;
|
||||
tRowGet(pRow, pTSchema, sourceIdx, &colVal);
|
||||
SColVal colVal = {0};
|
||||
code = tRowGet(pRow, pTSchema, sourceIdx, &colVal);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
if (colVal.cid < pColData->info.colId) {
|
||||
sourceIdx++;
|
||||
continue;
|
||||
} else if (colVal.cid == pColData->info.colId) {
|
||||
int32_t code = doSetVal(pColData, i, &colVal);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
code = doSetVal(pColData, i, &colVal);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
sourceIdx++;
|
||||
break;
|
||||
} 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) {
|
||||
tqDebug("tq reader retrieve data block %p, %d", pReader->msg.msgStr, pReader->nextBlk);
|
||||
SSDataBlock* block = NULL;
|
||||
|
||||
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
|
||||
if(pSubmitTbData == NULL){
|
||||
return terrno;
|
||||
}
|
||||
pReader->nextBlk++;
|
||||
|
||||
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",
|
||||
pReader->pWalReader->pWal->cfg.vgId, uid, pReader->cachedSchemaVer);
|
||||
pReader->cachedSchemaSuid = 0;
|
||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
return -1;
|
||||
return TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
}
|
||||
|
||||
SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
|
||||
int32_t numOfRows = 0;
|
||||
|
||||
if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||
SArray* pCols = pSubmitTbData->aCol;
|
||||
SColData* pCol = taosArrayGet(pCols, 0);
|
||||
numOfRows = pCol->nVal;
|
||||
return tqProcessColData(pReader, pSubmitTbData, blocks, schemas);
|
||||
} else {
|
||||
SArray* pRows = pSubmitTbData->aRowP;
|
||||
numOfRows = taosArrayGetSize(pRows);
|
||||
return tqProcessRowData(pReader, pSubmitTbData, blocks, schemas);
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList, const char* id) {
|
||||
void tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList, const char* id) {
|
||||
if (pReader->tbIdHash) {
|
||||
taosHashClear(pReader->tbIdHash);
|
||||
} else {
|
||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
}
|
||||
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
tqError("s-task:%s failed to init hash table", id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tqReaderAddTbUidList(STqReader* pReader, const SArray* pTableUidList) {
|
||||
void tqReaderAddTbUidList(STqReader* pReader, const SArray* pTableUidList) {
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
pReader->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
if (pReader->tbIdHash == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
tqError("failed to init hash table");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numOfTables = taosArrayGetSize(pTableUidList);
|
||||
for (int i = 0; i < numOfTables; 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) {
|
||||
|
@ -1008,16 +1025,15 @@ bool tqReaderIsQueriedTable(STqReader* pReader, uint64_t uid) {
|
|||
|
||||
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++) {
|
||||
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) {
|
||||
void* pIter = NULL;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
|
@ -1041,8 +1057,11 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
|||
if (!isAdd) {
|
||||
int32_t sz = taosArrayGetSize(tbUidList);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
||||
taosHashPut(pTqHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
||||
int64_t* tbUid = (int64_t*)taosArrayGet(tbUidList, i);
|
||||
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) {
|
||||
|
|
|
@ -30,8 +30,14 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
|||
|
||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen);
|
||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf);
|
||||
if (taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen) == NULL){
|
||||
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;
|
||||
}
|
||||
|
@ -39,9 +45,11 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOf
|
|||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, void* pRsp) {
|
||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -49,15 +57,17 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t
|
|||
SMetaReader mr = {0};
|
||||
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
||||
|
||||
// TODO add reference to gurantee success
|
||||
if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) {
|
||||
int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid);
|
||||
if (code < 0) {
|
||||
metaReaderClear(&mr);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
char* tbName = taosStrdup(mr.me.name);
|
||||
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName);
|
||||
if(taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName) == NULL){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
metaReaderClear(&mr);
|
||||
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);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d, task exec error since %s", pHandle->consumerId, vgId, tstrerror(code));
|
||||
terrno = code;
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
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 vgId = TD_VID(pTq->pVnode);
|
||||
int32_t code = 0;
|
||||
int32_t line = 0;
|
||||
int32_t totalRows = 0;
|
||||
|
||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||
qTaskInfo_t task = pExec->task;
|
||||
|
||||
if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) {
|
||||
return -1;
|
||||
}
|
||||
code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
qStreamSetSourceExcluded(task, pRequest->sourceExcluded);
|
||||
while (1) {
|
||||
SSDataBlock* pDataBlock = NULL;
|
||||
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
if (pRequest->enableReplay) {
|
||||
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};
|
||||
qStreamExtractOffset(task, &offset);
|
||||
pHandle->block = createOneDataBlock(pDataBlock, true);
|
||||
TSDB_CHECK_NULL(pDataBlock, code, line, END, terrno);
|
||||
pHandle->blockTime = offset.ts;
|
||||
tOffsetDestroy(&offset);
|
||||
code = getDataBlock(task, pHandle, vgId, &pDataBlock);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
|
||||
code = tqAddBlockDataToRsp(pHandle->block, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tqError("vgId:%d, failed to add block to rsp msg", vgId);
|
||||
return code;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
pRsp->common.blockNum++;
|
||||
if (pDataBlock == NULL) {
|
||||
blockDataDestroy(pHandle->block);
|
||||
pHandle->block = NULL;
|
||||
} else {
|
||||
copyDataBlock(pHandle->block, pDataBlock);
|
||||
|
||||
code = copyDataBlock(pHandle->block, pDataBlock);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
STqOffsetVal offset = {0};
|
||||
qStreamExtractOffset(task, &offset);
|
||||
pRsp->sleepTime = offset.ts - pHandle->blockTime;
|
||||
|
@ -144,10 +147,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
|||
break;
|
||||
}
|
||||
code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tqError("vgId:%d, failed to add block to rsp msg", vgId);
|
||||
return code;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
pRsp->common.blockNum++;
|
||||
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",
|
||||
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
||||
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) {
|
||||
const STqExecHandle* pExec = &pHandle->execHandle;
|
||||
qTaskInfo_t task = pExec->task;
|
||||
|
||||
if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) {
|
||||
return -1;
|
||||
int code = qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t rowCnt = 0;
|
||||
|
@ -176,11 +180,10 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
|||
SSDataBlock* pDataBlock = NULL;
|
||||
uint64_t ts = 0;
|
||||
tqDebug("tmqsnap task start to execute");
|
||||
int code = qExecTask(task, &pDataBlock, &ts);
|
||||
code = qExecTask(task, &pDataBlock, &ts);
|
||||
if (code != 0) {
|
||||
tqError("vgId:%d, task exec error since %s", pTq->pVnode->config.vgId, tstrerror(code));
|
||||
terrno = code;
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
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) {
|
||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
||||
tqError("vgId:%d, failed to add tbname to rsp msg", pTq->pVnode->config.vgId);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
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 (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 {
|
||||
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),
|
||||
pTq->pVnode->config.tsdbCfg.precision);
|
||||
if (tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision) != 0) {
|
||||
tqError("vgId:%d, failed to add block to rsp msg", pTq->pVnode->config.vgId);
|
||||
continue;
|
||||
}
|
||||
pRsp->common.blockNum++;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
continue;
|
||||
|
@ -222,7 +238,6 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
|||
if (taosArrayGetSize(tmp->batchMetaReq) > 0) {
|
||||
qStreamExtractOffset(task, &tmp->rspOffset);
|
||||
*pBatchMetaRsp = *tmp;
|
||||
|
||||
tqDebug("tmqsnap task get meta");
|
||||
break;
|
||||
}
|
||||
|
@ -248,150 +263,135 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
|||
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,
|
||||
int8_t sourceExcluded) {
|
||||
STqExecHandle* pExec = &pHandle->execHandle;
|
||||
SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||
SArray* pSchemas = taosArrayInit(0, sizeof(void*));
|
||||
int32_t code = 0;
|
||||
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) {
|
||||
STqReader* pReader = pExec->pTqReader;
|
||||
tqReaderSetSubmitMsg(pReader, submit.msgStr, submit.msgLen, submit.ver);
|
||||
while (tqNextBlockImpl(pReader, NULL)) {
|
||||
taosArrayClear(pBlocks);
|
||||
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*));
|
||||
tqProcessSubData(pTq, pHandle, pRsp, totalRows, sourceExcluded);
|
||||
}
|
||||
} 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)) {
|
||||
taosArrayClear(pBlocks);
|
||||
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*));
|
||||
tqProcessSubData(pTq, pHandle, pRsp, totalRows, sourceExcluded);
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(pBlocks);
|
||||
taosArrayDestroy(pSchemas);
|
||||
return 0;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -76,14 +76,10 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||
(void)tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
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);
|
||||
if (*ppData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
pHdr->type = pReader->type;
|
||||
pHdr->size = vLen;
|
||||
memcpy(pHdr->data, pVal, vLen);
|
||||
(void)memcpy(pHdr->data, pVal, vLen);
|
||||
|
||||
_exit:
|
||||
tdbFree(pKey);
|
||||
|
@ -131,20 +127,20 @@ struct STqSnapWriter {
|
|||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter;
|
||||
STqSnapWriter* pWriter = NULL;
|
||||
|
||||
// alloc
|
||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);;
|
||||
goto _err;
|
||||
}
|
||||
pWriter->pTq = pTq;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
code = -1;
|
||||
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
||||
if (code < 0) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
@ -164,7 +160,7 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
|||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
(void)tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
|
@ -207,7 +203,8 @@ int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nD
|
|||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -217,7 +214,7 @@ int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nD
|
|||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -227,7 +224,8 @@ int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData
|
|||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,16 +21,15 @@ static int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, c
|
|||
const SMqBatchMetaRsp* pRsp, int32_t vgId);
|
||||
|
||||
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
||||
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
||||
|
||||
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
||||
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
||||
|
||||
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->withSchema = false;
|
||||
return 0;
|
||||
|
@ -72,7 +71,7 @@ static int32_t tqInitTaosxRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
|||
taosArrayDestroy(pRsp->blockSchema);
|
||||
pRsp->blockSchema = NULL;
|
||||
}
|
||||
return -1;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
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,
|
||||
SRpcMsg* pMsg, bool* pBlockReturned) {
|
||||
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);
|
||||
|
||||
*pBlockReturned = false;
|
||||
// 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);
|
||||
|
||||
char formatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
|
@ -116,10 +116,13 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
SMqDataRsp dataRsp = {0};
|
||||
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,
|
||||
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);
|
||||
|
||||
*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
|
||||
" in vg %d, subkey %s, reset none failed",
|
||||
pHandle->subKey, consumerId, vgId, pRequest->subKey);
|
||||
terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
||||
return -1;
|
||||
return TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,10 +145,13 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
terrno = 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);
|
||||
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) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -201,17 +206,14 @@ static void tDeleteCommon(void* parm) {}
|
|||
|
||||
static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
||||
int code = 0;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
STaosxRsp taosxRsp = {0};
|
||||
SMqBatchMetaRsp btMetaRsp = {0};
|
||||
tqInitTaosxRsp(&taosxRsp.common, *offset);
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
STaosxRsp taosxRsp = {0};
|
||||
SMqBatchMetaRsp btMetaRsp = {0};
|
||||
int32_t code = 0;
|
||||
|
||||
TQ_ERR_GO_TO_END(tqInitTaosxRsp(&taosxRsp.common, *offset));
|
||||
if (offset->type != TMQ_OFFSET__LOG) {
|
||||
if (tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset) < 0) {
|
||||
code = -1;
|
||||
goto end;
|
||||
}
|
||||
TQ_ERR_GO_TO_END(tqScanTaosx(pTq, pHandle, &taosxRsp, &btMetaRsp, offset));
|
||||
|
||||
if (taosArrayGetSize(btMetaRsp.batchMetaReq) > 0) {
|
||||
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
|
@ -219,8 +221,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
",ts:%" PRId64,
|
||||
pRequest->consumerId, pHandle->subKey, vgId, btMetaRsp.rspOffset.type, btMetaRsp.rspOffset.uid,
|
||||
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
|
||||
|
@ -229,7 +230,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
||||
if (taosxRsp.common.blockNum > 0) {
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto end;
|
||||
goto END;
|
||||
} else {
|
||||
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 (totalMetaRows > 0) {
|
||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
ASSERT(totalRows == 0);
|
||||
goto end;
|
||||
goto END;
|
||||
}
|
||||
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
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;
|
||||
|
@ -271,7 +272,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
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) {
|
||||
|
@ -295,12 +296,20 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
metaRsp.metaRspLen = pHead->bodyLen;
|
||||
metaRsp.metaRsp = pHead->body;
|
||||
code = tqSendMetaPollRsp(pHandle, pMsg, pRequest, &metaRsp, vgId);
|
||||
goto end;
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (!btMetaRsp.batchMetaReq) {
|
||||
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));
|
||||
if (btMetaRsp.batchMetaLen == NULL) {
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto END;
|
||||
}
|
||||
}
|
||||
fetchVer++;
|
||||
|
||||
|
@ -316,30 +325,40 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
}
|
||||
int32_t tLen = sizeof(SMqRspHead) + len;
|
||||
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));
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, metaBuff, len);
|
||||
code = tEncodeMqMetaRsp(&encoder, &tmpMetaRsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (code < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
tqError("tmq extract meta from log, tEncodeMqMetaRsp error");
|
||||
continue;
|
||||
}
|
||||
taosArrayPush(btMetaRsp.batchMetaReq, &tBuf);
|
||||
taosArrayPush(btMetaRsp.batchMetaLen, &tLen);
|
||||
totalMetaRows++;
|
||||
if (taosArrayPush(btMetaRsp.batchMetaReq, &tBuf) == NULL){
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
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)) {
|
||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
goto end;
|
||||
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
goto END;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalMetaRows > 0) {
|
||||
tqOffsetResetToLog(&btMetaRsp.rspOffset, fetchVer);
|
||||
tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
goto end;
|
||||
code = tqSendBatchMetaPollRsp(pHandle, pMsg, pRequest, &btMetaRsp, vgId);
|
||||
goto END;
|
||||
}
|
||||
|
||||
// process data
|
||||
|
@ -353,7 +372,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
if (code < 0) {
|
||||
tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId,
|
||||
pRequest->subKey);
|
||||
goto end;
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||
|
@ -361,14 +380,14 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
code = tqSendDataRsp(
|
||||
pHandle, pMsg, pRequest, &taosxRsp,
|
||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto end;
|
||||
goto END;
|
||||
} else {
|
||||
fetchVer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
END:
|
||||
tDeleteMqBatchMetaRsp(&btMetaRsp);
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
return code;
|
||||
|
@ -423,12 +442,12 @@ int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SM
|
|||
int32_t code = 0;
|
||||
tEncodeSize(tEncodeMqBatchMetaRsp, pRsp, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||
void* buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
int64_t sver = 0, ever = 0;
|
||||
|
@ -439,9 +458,12 @@ int32_t tqSendBatchMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SM
|
|||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
tEncodeMqBatchMetaRsp(&encoder, pRsp);
|
||||
code = tEncodeMqBatchMetaRsp(&encoder, pRsp);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (code < 0) {
|
||||
rpcFreeCont(buf);
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
SRpcMsg resp = {.info = pMsg->info, .pCont = buf, .contLen = tlen, .code = 0};
|
||||
|
||||
tmsgSendRsp(&resp);
|
||||
|
@ -457,12 +479,12 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
|||
int32_t code = 0;
|
||||
tEncodeSize(tEncodeMqMetaRsp, pRsp, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||
void* buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
int64_t sver = 0, ever = 0;
|
||||
|
@ -473,8 +495,12 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
|||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, abuf, len);
|
||||
tEncodeMqMetaRsp(&encoder, pRsp);
|
||||
code = tEncodeMqMetaRsp(&encoder, pRsp);
|
||||
tEncoderClear(&encoder);
|
||||
if (code < 0) {
|
||||
rpcFreeCont(buf);
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
|
||||
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) {
|
||||
return -1;
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
|
||||
int32_t tlen = sizeof(SMqRspHead) + len;
|
||||
void* buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
return -1;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SMqRspHead* pHead = (SMqRspHead*)buf;
|
||||
|
@ -515,12 +541,15 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp,
|
|||
tEncoderInit(&encoder, abuf, len);
|
||||
|
||||
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) {
|
||||
tEncodeSTaosxRsp(&encoder, pRsp);
|
||||
code = tEncodeSTaosxRsp(&encoder, pRsp);
|
||||
}
|
||||
|
||||
tEncoderClear(&encoder);
|
||||
if (code < 0) {
|
||||
rpcFreeCont(buf);
|
||||
return TAOS_GET_TERRNO(code);
|
||||
}
|
||||
SRpcMsg rsp = {.info = *pRpcHandleInfo, .pCont = buf, .contLen = tlen, .code = 0};
|
||||
|
||||
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 code;
|
||||
int32_t code = 0;
|
||||
int32_t line = 0;
|
||||
SDecoder* pCoder = &(SDecoder){0};
|
||||
SDeleteRes* pRes = &(SDeleteRes){0};
|
||||
|
||||
*pRefBlock = NULL;
|
||||
|
||||
pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t));
|
||||
if (pRes->uidList == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
TSDB_CHECK_NULL(pRes->uidList, code, line, END, terrno)
|
||||
|
||||
tDecoderInit(pCoder, (uint8_t*)pData, len);
|
||||
tDecodeDeleteRes(pCoder, pRes);
|
||||
tDecoderClear(pCoder);
|
||||
code = tDecodeDeleteRes(pCoder, pRes);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
int32_t numOfTables = taosArrayGetSize(pRes->uidList);
|
||||
if (numOfTables == 0 || pRes->affectedRows == 0) {
|
||||
taosArrayDestroy(pRes->uidList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
goto END;
|
||||
}
|
||||
|
||||
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.version = ver;
|
||||
|
||||
for (int32_t i = 0; i < numOfTables; i++) {
|
||||
// start key column
|
||||
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);
|
||||
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
|
||||
SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX);
|
||||
int64_t* pUid = taosArrayGet(pRes->uidList, i);
|
||||
colDataSetVal(pUidCol, i, (const char*)pUid, false);
|
||||
TSDB_CHECK_NULL(pUidCol, code, line, END, terrno)
|
||||
|
||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX), i);
|
||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX), i);
|
||||
colDataSetNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX), i);
|
||||
int64_t* pUid = taosArrayGet(pRes->uidList, i);
|
||||
code = colDataSetVal(pUidCol, i, (const char*)pUid, false);
|
||||
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) {
|
||||
code = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0, pRefBlock);
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -612,6 +659,9 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b
|
|||
|
||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||
SStreamTaskId* pId = taosArrayGet(pMeta->pTaskList, i);
|
||||
if (pId == NULL){
|
||||
continue;
|
||||
}
|
||||
if (pId->streamId != streamId) {
|
||||
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
|
||||
pVnode->pTq = tqOpen(tdir, pVnode);
|
||||
if (pVnode->pTq == NULL) {
|
||||
if (tqOpen(tdir, pVnode)) {
|
||||
vError("vgId:%d, failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
|
|
@ -370,8 +370,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
goto _exit;
|
||||
} else {
|
||||
pReader->tqHandleDone = 1;
|
||||
code = tqSnapReaderClose(&pReader->pTqSnapReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
tqSnapReaderClose(&pReader->pTqSnapReader);
|
||||
}
|
||||
}
|
||||
if (!pReader->tqCheckInfoDone) {
|
||||
|
@ -387,8 +386,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
goto _exit;
|
||||
} else {
|
||||
pReader->tqCheckInfoDone = 1;
|
||||
code = tqSnapReaderClose(&pReader->pTqCheckInfoReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
tqSnapReaderClose(&pReader->pTqCheckInfoReader);
|
||||
}
|
||||
}
|
||||
if (!pReader->tqOffsetDone) {
|
||||
|
@ -404,8 +402,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
goto _exit;
|
||||
} else {
|
||||
pReader->tqOffsetDone = 1;
|
||||
code = tqSnapReaderClose(&pReader->pTqOffsetReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
tqSnapReaderClose(&pReader->pTqOffsetReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,8 +153,8 @@ static FORCE_INLINE SResultRow* getResultRowByPos(SDiskbasedBuf* pBuf, SResultRo
|
|||
return pRow;
|
||||
}
|
||||
|
||||
void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t order);
|
||||
void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo);
|
||||
int32_t initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t order);
|
||||
void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo);
|
||||
|
||||
void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList);
|
||||
bool hasRemainResults(SGroupResInfo* pGroupResInfo);
|
||||
|
|
|
@ -246,7 +246,8 @@ static bool nextGroupedResult(SOperatorInfo* pOperator) {
|
|||
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
|
||||
}
|
||||
|
||||
initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0);
|
||||
code = initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -128,7 +128,9 @@ int32_t resultrowComparAsc(const void* p1, const void* p2) {
|
|||
|
||||
static int32_t resultrowComparDesc(const void* p1, const void* p2) { return resultrowComparAsc(p2, p1); }
|
||||
|
||||
void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t order) {
|
||||
int32_t initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t order) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
if (pGroupResInfo->pRows != NULL) {
|
||||
taosArrayDestroy(pGroupResInfo->pRows);
|
||||
}
|
||||
|
@ -154,6 +156,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
|
|||
}
|
||||
|
||||
pGroupResInfo->pBuf = taosMemoryMalloc(bufLen);
|
||||
QUERY_CHECK_NULL(pGroupResInfo->pBuf, code, lino, _end, terrno);
|
||||
|
||||
iter = 0;
|
||||
while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
|
||||
|
@ -164,7 +167,8 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
|
|||
p->groupId = *(uint64_t*)key;
|
||||
p->pos = *(SResultRowPosition*)pData;
|
||||
memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t));
|
||||
taosArrayPush(pGroupResInfo->pRows, &p);
|
||||
void* tmp = taosArrayPush(pGroupResInfo->pRows, &p);
|
||||
QUERY_CHECK_NULL(pGroupResInfo->pBuf, code, lino, _end, terrno);
|
||||
|
||||
offset += keyLen + sizeof(struct SResultRowPosition);
|
||||
}
|
||||
|
@ -176,6 +180,12 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
|
|||
}
|
||||
|
||||
pGroupResInfo->index = 0;
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) {
|
||||
|
|
|
@ -473,11 +473,7 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
|||
}
|
||||
int32_t numOfQualifiedTables = taosArrayGetSize(qa);
|
||||
qDebug("%d qualified child tables added into stream scanner, %s", numOfQualifiedTables, id);
|
||||
code = pTaskInfo->storageAPI.tqReaderFn.tqReaderAddTables(pScanInfo->tqReader, qa);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(qa);
|
||||
return code;
|
||||
}
|
||||
pTaskInfo->storageAPI.tqReaderFn.tqReaderAddTables(pScanInfo->tqReader, qa);
|
||||
|
||||
bool assignUid = false;
|
||||
size_t bufLen = (pScanInfo->pGroupTags != NULL) ? getTableTagsBufLen(pScanInfo->pGroupTags) : 0;
|
||||
|
@ -531,7 +527,7 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
|
|||
} else { // remove the table id in current list
|
||||
qDebug("%d remove child tables from the stream scanner, %s", (int32_t)taosArrayGetSize(tableIdList), id);
|
||||
taosWLockLatch(&pTaskInfo->lock);
|
||||
code = pTaskInfo->storageAPI.tqReaderFn.tqReaderRemoveTables(pScanInfo->tqReader, tableIdList);
|
||||
pTaskInfo->storageAPI.tqReaderFn.tqReaderRemoveTables(pScanInfo->tqReader, tableIdList);
|
||||
taosWUnLockLatch(&pTaskInfo->lock);
|
||||
}
|
||||
|
||||
|
@ -961,7 +957,7 @@ int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* 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;
|
||||
SOperatorInfo* pOperator = pTaskInfo->pRoot;
|
||||
|
||||
|
@ -969,7 +965,7 @@ int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
|||
uint16_t type = pOperator->operatorType;
|
||||
if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
*scanner = pOperator->info;
|
||||
return 0;
|
||||
break;
|
||||
} else {
|
||||
ASSERT(pOperator->numOfDownstream == 1);
|
||||
pOperator = pOperator->pDownstream[0];
|
||||
|
@ -1249,9 +1245,10 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
SStoreTqReader* pReaderAPI = &pTaskInfo->storageAPI.tqReaderFn;
|
||||
SWalReader* pWalReader = pReaderAPI->tqReaderGetWalReader(pInfo->tqReader);
|
||||
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);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
// iterate all tables from tableInfoList, and retrieve rows from each table one-by-one
|
||||
|
@ -1266,15 +1263,14 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
|
||||
if (uid == 0) {
|
||||
if (numOfTables != 0) {
|
||||
STableKeyInfo* pTableInfo = tableListGetInfo(pTableListInfo, 0);
|
||||
uid = pTableInfo->uid;
|
||||
STableKeyInfo* tmp = tableListGetInfo(pTableListInfo, 0);
|
||||
if (tmp) uid = tmp->uid;
|
||||
ts = INT64_MIN;
|
||||
pScanInfo->currentTable = 0;
|
||||
} else {
|
||||
taosRUnLockLatch(&pTaskInfo->lock);
|
||||
qError("no table in table list, %s", id);
|
||||
terrno = TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||
return -1;
|
||||
return TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||
}
|
||||
}
|
||||
pTaskInfo->storageAPI.tqReaderFn.tqSetTablePrimaryKey(pInfo->tqReader, uid);
|
||||
|
@ -1294,8 +1290,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
} else {
|
||||
qError("vgId:%d uid:%" PRIu64 " not found in table list, total:%d, index:%d %s", pTaskInfo->id.vgId, uid,
|
||||
numOfTables, pScanInfo->currentTable, id);
|
||||
terrno = TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||
return -1;
|
||||
return TSDB_CODE_TMQ_NO_TABLE_QUALIFIED;
|
||||
}
|
||||
|
||||
STableKeyInfo keyInfo = {.uid = uid};
|
||||
|
@ -1315,8 +1310,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
(void**)&pScanBaseInfo->dataReader, id, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id);
|
||||
terrno = code;
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
qDebug("tsdb reader created with offset(snapshot) uid:%" PRId64 " ts:%" PRId64 " table index:%d, total:%d, %s",
|
||||
|
@ -1341,8 +1335,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
pScanBaseInfo->cond.twindows.skey = oldSkey;
|
||||
} else {
|
||||
qError("invalid pOffset->type:%d, %s", pOffset->type, id);
|
||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
return -1;
|
||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
} else { // subType == TOPIC_SUB_TYPE__TABLE/TOPIC_SUB_TYPE__DB
|
||||
|
@ -1363,7 +1356,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
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);
|
||||
pInfo->dataReader = NULL;
|
||||
|
||||
|
@ -1371,6 +1368,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
tableListClear(pTableListInfo);
|
||||
|
||||
if (mtInfo.uid == 0) {
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
goto end; // no data
|
||||
}
|
||||
|
||||
|
@ -1378,6 +1376,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
code = initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
return code;
|
||||
}
|
||||
if (pAPI->snapshotFn.taosXGetTablePrimaryKey(sContext)) {
|
||||
|
@ -1388,6 +1387,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
|
||||
code = tableListAddTableInfo(pTableListInfo, mtInfo.uid, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -1399,11 +1399,12 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
NULL, (void**)&pInfo->dataReader, NULL, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
return code;
|
||||
}
|
||||
|
||||
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
||||
strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName);
|
||||
tstrncpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
tDeleteSchemaWrapper(pTaskInfo->streamInfo.schema);
|
||||
pTaskInfo->streamInfo.schema = mtInfo.schema;
|
||||
|
||||
|
@ -1411,10 +1412,10 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
SStreamRawScanInfo* pInfo = pOperator->info;
|
||||
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);
|
||||
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64 " %s", pOffset->uid, pOffset->ts,
|
||||
id);
|
||||
|
|
|
@ -3480,7 +3480,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};
|
||||
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");
|
||||
|
@ -3490,9 +3496,9 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
tqOffsetResetToData(&offset, mtInfo.uid, INT64_MIN, val);
|
||||
qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid);
|
||||
}
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
code = qStreamPrepareScan(pTaskInfo, &offset, pInfo->sContext->subType);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
(*ppRes) = NULL;
|
||||
return code;
|
||||
} else if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
|
@ -3583,7 +3589,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
|
|||
static void destroyRawScanOperatorInfo(void* param) {
|
||||
SStreamRawScanInfo* pRawScan = (SStreamRawScanInfo*)param;
|
||||
pRawScan->pAPI->tsdReader.tsdReaderClose(pRawScan->dataReader);
|
||||
(void)pRawScan->pAPI->snapshotFn.destroySnapshot(pRawScan->sContext);
|
||||
pRawScan->pAPI->snapshotFn.destroySnapshot(pRawScan->sContext);
|
||||
tableListDestroy(pRawScan->pTableListInfo);
|
||||
taosMemoryFree(pRawScan);
|
||||
}
|
||||
|
@ -3919,13 +3925,7 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode*
|
|||
SArray* tableIdList = NULL;
|
||||
code = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo, &tableIdList);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
code = pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList, idstr);
|
||||
if (code != 0) {
|
||||
taosArrayDestroy(tableIdList);
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pAPI->tqReaderFn.tqReaderSetQueryTableList(pInfo->tqReader, tableIdList, idstr);
|
||||
taosArrayDestroy(tableIdList);
|
||||
memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond));
|
||||
} else {
|
||||
|
@ -5434,7 +5434,12 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock*
|
|||
break;
|
||||
}
|
||||
|
||||
tsortAppendTupleToBlock(pInfo->pSortHandle, pResBlock, pTupleHandle);
|
||||
code = tsortAppendTupleToBlock(pInfo->pSortHandle, pResBlock, pTupleHandle);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
T_LONG_JMP(pOperator->pTaskInfo->env, terrno);
|
||||
}
|
||||
|
||||
if (pResBlock->info.rows >= capacity) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -334,7 +334,8 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
|
||||
SGroupKeys* pkey = taosArrayGet(pSliceInfo->pPrevRow, srcSlot);
|
||||
if (pkey->isNull == false) {
|
||||
colDataSetVal(pDst, rows, pkey->pData, false);
|
||||
code = colDataSetVal(pDst, rows, pkey->pData, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
} else {
|
||||
colDataSetNULL(pDst, rows);
|
||||
}
|
||||
|
|
|
@ -903,7 +903,9 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
|||
if (hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag)) break;
|
||||
}
|
||||
|
||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->binfo.outputTsOrder);
|
||||
code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->binfo.outputTsOrder);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
OPTR_SET_OPENED(pOperator);
|
||||
|
||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||
|
@ -1042,7 +1044,9 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC);
|
||||
code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
|
||||
_end:
|
||||
|
@ -1516,7 +1520,9 @@ static int32_t doSessionWindowAggNext(SOperatorInfo* pOperator, SSDataBlock** pp
|
|||
// restore the value
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
|
||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC);
|
||||
code = initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
code = blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
while (1) {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
//
|
||||
|
||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
||||
int32_t code = 0;
|
||||
SyncAppendEntriesReply* pMsg = (SyncAppendEntriesReply*)pRpcMsg->pCont;
|
||||
int32_t ret = 0;
|
||||
|
||||
|
@ -59,7 +60,7 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
if (pMsg->term > raftStoreGetTerm(ths)) {
|
||||
syncLogRecvAppendEntriesReply(ths, pMsg, "error term");
|
||||
syncNodeStepDown(ths, pMsg->term);
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_WRONG_TERM;
|
||||
}
|
||||
|
||||
ASSERT(pMsg->term == raftStoreGetTerm(ths));
|
||||
|
@ -81,17 +82,19 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
syncNodeStepDown(ths, pMsg->term);
|
||||
}
|
||||
} else {
|
||||
(void)syncLogBufferCommit(ths->pLogBuf, ths, commitIndex);
|
||||
TAOS_CHECK_RETURN(syncLogBufferCommit(ths->pLogBuf, ths, commitIndex));
|
||||
}
|
||||
}
|
||||
|
||||
// replicate log
|
||||
SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(ths, &pMsg->srcId);
|
||||
if (pMgr == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
if (terrno != 0) code = terrno;
|
||||
sError("vgId:%d, failed to get log repl mgr for src addr: 0x%016" PRIx64, ths->vgId, pMsg->srcId.addr);
|
||||
return -1;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)syncLogReplProcessReply(pMgr, ths, pMsg);
|
||||
TAOS_CHECK_RETURN(syncLogReplProcessReply(pMgr, ths, pMsg));
|
||||
}
|
||||
return 0;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
|
|
@ -72,17 +72,25 @@ bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) {
|
|||
}
|
||||
|
||||
int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex) {
|
||||
int32_t code = 0;
|
||||
SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
|
||||
commitIndex = TMAX(commitIndex, ths->commitIndex);
|
||||
ths->commitIndex = TMIN(commitIndex, lastVer);
|
||||
ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex);
|
||||
if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex)) != 0) {
|
||||
// TODO add return when error
|
||||
sError("failed to update commit index since %s", tstrerror(code));
|
||||
}
|
||||
return ths->commitIndex;
|
||||
}
|
||||
|
||||
int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) {
|
||||
int32_t code = 0;
|
||||
if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) {
|
||||
SyncIndex commitIndex = indexLikely;
|
||||
syncNodeUpdateCommitIndex(ths, commitIndex);
|
||||
if ((code = syncNodeUpdateCommitIndex(ths, commitIndex)) != 0) {
|
||||
// TODO add return when error
|
||||
sError("failed to update commit index since %s", tstrerror(code));
|
||||
}
|
||||
sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state,
|
||||
raftStoreGetTerm(ths), commitIndex);
|
||||
}
|
||||
|
@ -90,9 +98,13 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) {
|
|||
}
|
||||
|
||||
int64_t syncNodeUpdateAssignedCommitIndex(SSyncNode* ths, SyncIndex assignedCommitIndex) {
|
||||
int32_t code = 0;
|
||||
SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
|
||||
assignedCommitIndex = TMAX(assignedCommitIndex, ths->assignedCommitIndex);
|
||||
ths->assignedCommitIndex = TMIN(assignedCommitIndex, lastVer);
|
||||
ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex);
|
||||
if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex)) != 0) {
|
||||
// TODO add return when error
|
||||
sError("failed to update commit index since %s", tstrerror(code));
|
||||
}
|
||||
return ths->commitIndex;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static int32_t syncNodeRequestVotePeers(SSyncNode* pNode) {
|
|||
int32_t syncNodeElect(SSyncNode* pSyncNode) {
|
||||
if (pSyncNode->fsmState == SYNC_FSM_STATE_INCOMPLETE) {
|
||||
sNError(pSyncNode, "skip leader election due to incomplete fsm state");
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_WRONG_FSM_STATE;
|
||||
}
|
||||
|
||||
sNInfo(pSyncNode, "begin election");
|
||||
|
@ -86,7 +86,7 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
|
|||
|
||||
if (pSyncNode->state != TAOS_SYNC_STATE_CANDIDATE) {
|
||||
sNError(pSyncNode, "not candidate, can not elect");
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_WRONG_SYNC_STATE;
|
||||
}
|
||||
|
||||
// start election
|
||||
|
|
|
@ -48,14 +48,14 @@ int32_t syncInit() {
|
|||
if (gNodeRefId < 0) {
|
||||
sError("failed to init node ref");
|
||||
syncCleanUp();
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_WRONG_REF;
|
||||
}
|
||||
|
||||
gHbDataRefId = taosOpenRef(200, (RefFp)syncHbTimerDataFree);
|
||||
if (gHbDataRefId < 0) {
|
||||
sError("failed to init hb-data ref");
|
||||
syncCleanUp();
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_WRONG_REF;
|
||||
}
|
||||
|
||||
sDebug("sync rsetId:%d is open", gNodeRefId);
|
||||
|
@ -106,7 +106,7 @@ void syncNodeRelease(SSyncNode *pNode) {
|
|||
|
||||
int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) {
|
||||
pData->rid = taosAddRef(gHbDataRefId, pData);
|
||||
if (pData->rid < 0) return -1;
|
||||
if (pData->rid < 0) return TSDB_CODE_SYN_WRONG_REF;
|
||||
return pData->rid;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ SSyncLogReplMgr *syncNodeGetLogReplMgr(SSyncNode *pNode, SRaftId *pRaftId) {
|
|||
}
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_SYN_INVALID_ID;
|
||||
sError("vgId:%d, indexmgr get replmgr from dnode:%d cluster:%d failed", pNode->vgId, DID(pRaftId), CID(pRaftId));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -110,6 +111,7 @@ SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId)
|
|||
}
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_SYN_INVALID_ID;
|
||||
sError("vgId:%d, indexmgr get index from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId),
|
||||
CID(pRaftId));
|
||||
return SYNC_INDEX_INVALID;
|
||||
|
@ -137,7 +139,8 @@ int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftI
|
|||
|
||||
sError("vgId:%d, indexmgr get start-time from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId),
|
||||
CID(pRaftId));
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_INVALID_ID;
|
||||
;
|
||||
}
|
||||
|
||||
void syncIndexMgrSetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, int64_t recvTime) {
|
||||
|
@ -162,7 +165,7 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId
|
|||
|
||||
sError("vgId:%d, indexmgr get recv-time from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId),
|
||||
CID(pRaftId));
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_INVALID_ID;
|
||||
}
|
||||
|
||||
void syncIndexMgrSetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId, SyncTerm term) {
|
||||
|
@ -187,5 +190,5 @@ SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pIndexMgr, const SRaftId *pRaftId) {
|
|||
|
||||
sError("vgId:%d, indexmgr get term from dnode:%d cluster:%d failed", pIndexMgr->pNode->vgId, DID(pRaftId),
|
||||
CID(pRaftId));
|
||||
return -1;
|
||||
return TSDB_CODE_SYN_INVALID_ID;
|
||||
}
|
||||
|
|
|
@ -528,6 +528,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG, "Sync invalid snapshot
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BUFFER_FULL, "Sync buffer is full")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRITE_STALL, "Sync write stall")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NEGOTIATION_WIN_FULL, "Sync negotiation win is full")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRONG_TERM, "Sync got a wrong term")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRONG_FSM_STATE, "Sync got a wrong fsm state")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRONG_SYNC_STATE, "Sync got a wrong state")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRONG_REF, "Sync got a wrong ref")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_ID, "Sync invalid id")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error")
|
||||
|
||||
//tq
|
||||
|
|
Loading…
Reference in New Issue