other: merge 3.0
This commit is contained in:
commit
cf60900155
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -65,10 +65,16 @@ interp_clause:
|
||||||
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
||||||
|
|
||||||
partition_by_clause:
|
partition_by_clause:
|
||||||
PARTITION BY expr [, expr] ...
|
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
||||||
|
|
||||||
|
partition_by_expr:
|
||||||
|
{expr | position | c_alias}
|
||||||
|
|
||||||
group_by_clause:
|
group_by_clause:
|
||||||
GROUP BY expr [, expr] ... HAVING condition
|
GROUP BY group_by_expr [, group_by_expr] ... HAVING condition
|
||||||
|
|
||||||
|
group_by_expr:
|
||||||
|
{expr | position | c_alias}
|
||||||
|
|
||||||
order_by_clasue:
|
order_by_clasue:
|
||||||
ORDER BY order_expr [, order_expr] ...
|
ORDER BY order_expr [, order_expr] ...
|
||||||
|
@ -274,7 +280,13 @@ If you use a GROUP BY clause, the SELECT list can only include the following ite
|
||||||
|
|
||||||
The GROUP BY clause groups each row of data by the value of the expression following the clause and returns a combined result for each group.
|
The GROUP BY clause groups each row of data by the value of the expression following the clause and returns a combined result for each group.
|
||||||
|
|
||||||
The expressions in a GROUP BY clause can include any column in any table or view. It is not necessary that the expressions appear in the SELECT list.
|
In the GROUP BY clause, columns from a table or view can be grouped by specifying the column name. These columns do not need to be included in the SELECT list.
|
||||||
|
|
||||||
|
You can specify integers in GROUP BY expression to indicate the expressions in the select list used for grouping. For example, 1 indicates the first item in the select list.
|
||||||
|
|
||||||
|
You can specify column names in result set to indicate the expressions in the select list used for grouping.
|
||||||
|
|
||||||
|
When using position and result set column names for grouping in the GROUP BY clause, the corresponding expressions in the select list must not be aggregate functions.
|
||||||
|
|
||||||
The GROUP BY clause does not guarantee that the results are ordered. If you want to ensure that grouped data is ordered, use the ORDER BY clause.
|
The GROUP BY clause does not guarantee that the results are ordered. If you want to ensure that grouped data is ordered, use the ORDER BY clause.
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,16 @@ interp_clause:
|
||||||
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
RANGE(ts_val [, ts_val]) EVERY(every_val) FILL(fill_mod_and_val)
|
||||||
|
|
||||||
partition_by_clause:
|
partition_by_clause:
|
||||||
PARTITION BY expr [, expr] ...
|
PARTITION BY partition_by_expr [, partition_by_expr] ...
|
||||||
|
|
||||||
|
partition_by_expr:
|
||||||
|
{expr | position | c_alias}
|
||||||
|
|
||||||
group_by_clause:
|
group_by_clause:
|
||||||
GROUP BY expr [, expr] ... HAVING condition
|
GROUP BY group_by_expr [, group_by_expr] ... HAVING condition
|
||||||
|
|
||||||
|
group_by_expr:
|
||||||
|
{expr | position | c_alias}
|
||||||
|
|
||||||
order_by_clasue:
|
order_by_clasue:
|
||||||
ORDER BY order_expr [, order_expr] ...
|
ORDER BY order_expr [, order_expr] ...
|
||||||
|
@ -274,7 +280,13 @@ TDengine 支持基于时间戳主键的 INNER JOIN,规则如下:
|
||||||
|
|
||||||
GROUP BY 子句对每行数据按 GROUP BY 后的表达式的值进行分组,并为每个组返回一行汇总信息。
|
GROUP BY 子句对每行数据按 GROUP BY 后的表达式的值进行分组,并为每个组返回一行汇总信息。
|
||||||
|
|
||||||
GROUP BY 子句中的表达式可以包含表或视图中的任何列,这些列不需要出现在 SELECT 列表中。
|
GROUP BY 子句中可以通过指定表或视图的列名来按照表或视图中的任何列分组,这些列不需要出现在 SELECT 列表中。
|
||||||
|
|
||||||
|
GROUP BY 子句中可以使用位置语法,位置标识为正整数,从 1 开始,表示使用 SELECT 列表的第几个表达式进行分组。
|
||||||
|
|
||||||
|
GROUP BY 子句中可以使用结果集列名,表示使用 SELECT 列表的指定表达式进行分组。
|
||||||
|
|
||||||
|
GROUP BY 子句中在使用位置语法和结果集列名进行分组时,其对应的 SELECT 列表中的表达式不能是聚集函数。
|
||||||
|
|
||||||
该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句
|
该子句对行进行分组,但不保证结果集的顺序。若要对分组进行排序,请使用 ORDER BY 子句
|
||||||
|
|
||||||
|
|
|
@ -1763,6 +1763,14 @@ int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
|
||||||
void tFreeSStatusReq(SStatusReq* pReq);
|
void tFreeSStatusReq(SStatusReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t dnodeId;
|
||||||
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
|
} SDnodeInfoReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
|
||||||
|
int32_t tDeserializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MONITOR_TYPE_COUNTER = 0,
|
MONITOR_TYPE_COUNTER = 0,
|
||||||
MONITOR_TYPE_SLOW_LOG = 1,
|
MONITOR_TYPE_SLOW_LOG = 1,
|
||||||
|
@ -1827,12 +1835,18 @@ typedef struct {
|
||||||
int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
|
int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
|
||||||
// int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
|
// int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct SOrphanTask {
|
||||||
int64_t tick;
|
int64_t streamId;
|
||||||
} SMStreamTickReq;
|
int32_t taskId;
|
||||||
|
int32_t nodeId;
|
||||||
|
} SOrphanTask;
|
||||||
|
|
||||||
int32_t tSerializeSMStreamTickMsg(void* buf, int32_t bufLen, SMStreamTickReq* pReq);
|
typedef struct SMStreamDropOrphanMsg {
|
||||||
// int32_t tDeserializeSMStreamTickMsg(void* buf, int32_t bufLen, SMStreamTickReq* pReq);
|
SArray* pList; // SArray<SOrphanTask>
|
||||||
|
} SMStreamDropOrphanMsg;
|
||||||
|
|
||||||
|
int32_t tSerializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
|
||||||
|
int32_t tDeserializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
|
@ -3641,7 +3655,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
|
||||||
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
||||||
void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
||||||
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||||
int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||||
void tOffsetDestroy(void* pVal);
|
void tOffsetDestroy(void* pVal);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -224,9 +224,9 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESTORE_DNODE, "restore-dnode", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_PAUSE_STREAM, "pause-stream", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_RESUME_STREAM, "resume-stream", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_RESUME_STREAM, "resume-stream", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL) // not used
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_CANDIDITATE, "stream-checkpoint-remain", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_CANDIDITATE, "stream-checkpoint-remain", NULL, NULL) // not used
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_NODECHANGE_CHECK, "stream-nodechange-check", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRIM_DB_TIMER, "trim-db-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GRANT_NOTIFY, "grant-notify", NULL, NULL)
|
||||||
|
@ -251,7 +251,9 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_UPDATE_CHKPT_EVT, "stream-update-chkpt-evt", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_UPDATE_CHKPT_EVT, "stream-update-chkpt-evt", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHKPT_REPORT, "stream-chkpt-report", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHKPT_REPORT, "stream-chkpt-report", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CONSEN_TIMER, "stream-consen-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CONSEN_TIMER, "stream-consen-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_DROP_ORPHANTASKS, "stream-drop-orphan-tasks", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_TASK_RESET, "stream-reset-tasks", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_UPDATE_DNODE_INFO, "update-dnode-info", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8
|
||||||
|
|
|
@ -60,6 +60,7 @@ typedef struct SExprNode {
|
||||||
bool orderAlias;
|
bool orderAlias;
|
||||||
bool asAlias;
|
bool asAlias;
|
||||||
bool asParam;
|
bool asParam;
|
||||||
|
bool asPosition;
|
||||||
} SExprNode;
|
} SExprNode;
|
||||||
|
|
||||||
typedef enum EColumnType {
|
typedef enum EColumnType {
|
||||||
|
|
|
@ -489,6 +489,7 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs
|
||||||
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
||||||
if (pInst == NULL) {
|
if (pInst == NULL) {
|
||||||
tscError("failed to get app instance by clusterId:%" PRId64, clusterId);
|
tscError("failed to get app instance by clusterId:%" PRId64, clusterId);
|
||||||
|
taosMemoryFree(fileName);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||||
|
|
|
@ -87,7 +87,7 @@ int32_t getJsonValueLen(const char* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull) {
|
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull) {
|
||||||
if (isNull) {
|
if (isNull || pData == NULL) {
|
||||||
// There is a placehold for each NULL value of binary or nchar type.
|
// There is a placehold for each NULL value of binary or nchar type.
|
||||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
pColumnInfoData->varmeta.offset[rowIndex] = -1; // it is a null value of VAR type.
|
pColumnInfoData->varmeta.offset[rowIndex] = -1; // it is a null value of VAR type.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1457,6 +1457,39 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
|
|
||||||
void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); }
|
void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); }
|
||||||
|
|
||||||
|
int32_t tSerializeSDnodeInfoReq(void *buf, int32_t bufLen, SDnodeInfoReq *pReq) {
|
||||||
|
int32_t code = 0, lino = 0;
|
||||||
|
int32_t tlen = 0;
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->dnodeId));
|
||||||
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->machineId));
|
||||||
|
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
tlen = encoder.pos;
|
||||||
|
_exit:
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return code < 0 ? code : tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSDnodeInfoReq(void *buf, int32_t bufLen, SDnodeInfoReq *pReq) {
|
||||||
|
int32_t code = 0, lino = 0;
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->dnodeId));
|
||||||
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->machineId));
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -5275,12 +5308,22 @@ int32_t tSerializeSMTimerMsg(void *buf, int32_t bufLen, SMTimerReq *pReq) {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int32_t tSerializeSMStreamTickMsg(void *buf, int32_t bufLen, SMStreamTickReq *pReq) {
|
int32_t tSerializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->tick) < 0) return -1;
|
|
||||||
|
int32_t size = taosArrayGetSize(pMsg->pList);
|
||||||
|
if (tEncodeI32(&encoder, size) < 0) return -1;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < size; i++) {
|
||||||
|
SOrphanTask *pTask = taosArrayGet(pMsg->pList, i);
|
||||||
|
if (tEncodeI64(&encoder, pTask->streamId) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pTask->taskId) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pTask->nodeId) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -5288,17 +5331,34 @@ int32_t tSerializeSMStreamTickMsg(void *buf, int32_t bufLen, SMStreamTickReq *pR
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// int32_t tDeserializeSMStreamTickMsg(void *buf, int32_t bufLen, SMStreamTickReq *pReq) {
|
int32_t tDeserializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg) {
|
||||||
// SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
// tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
// if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
// if (tDecodeI64(&decoder, &pReq->tick) < 0) return -1;
|
|
||||||
// tEndDecode(&decoder);
|
|
||||||
|
|
||||||
// tDecoderClear(&decoder);
|
int32_t num = 0;
|
||||||
// return 0;
|
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||||
// }
|
|
||||||
|
if (num > 0) {
|
||||||
|
pMsg->pList = taosArrayInit(num, sizeof(SOrphanTask));
|
||||||
|
if (NULL == pMsg->pList) return -1;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SOrphanTask info = {0};
|
||||||
|
if (tDecodeI64(&decoder, &info.streamId) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &info.taskId) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &info.nodeId) < 0) return -1;
|
||||||
|
|
||||||
|
if (taosArrayPush(pMsg->pList, &info) == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tEncodeSReplica(SEncoder *pEncoder, SReplica *pReplica) {
|
int32_t tEncodeSReplica(SEncoder *pEncoder, SReplica *pReplica) {
|
||||||
if (tEncodeI32(pEncoder, pReplica->id) < 0) return -1;
|
if (tEncodeI32(pEncoder, pReplica->id) < 0) return -1;
|
||||||
|
@ -9238,18 +9298,17 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||||
tOffsetDestroy(pLeft);
|
tOffsetDestroy(pLeft);
|
||||||
*pLeft = *pRight;
|
*pLeft = *pRight;
|
||||||
if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) {
|
if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) {
|
||||||
pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData);
|
pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData);
|
||||||
if (pLeft->primaryKey.pData == NULL) {
|
if (pLeft->primaryKey.pData == NULL) {
|
||||||
uError("failed to allocate memory for offset");
|
uError("failed to allocate memory for offset");
|
||||||
return terrno;
|
return;
|
||||||
}
|
}
|
||||||
(void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData);
|
(void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tOffsetDestroy(void *param) {
|
void tOffsetDestroy(void *param) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
if (pMgmt->pData->ipWhiteVer == ver) {
|
if (pMgmt->pData->ipWhiteVer == ver) {
|
||||||
if (ver == 0) {
|
if (ver == 0) {
|
||||||
dDebug("disable ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver);
|
dDebug("disable ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver);
|
||||||
rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL);
|
(void)rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
dGInfo("dnode:%d, set to dropped since not exist in mnode, statusSeq:%d", pMgmt->pData->dnodeId,
|
dGInfo("dnode:%d, set to dropped since not exist in mnode, statusSeq:%d", pMgmt->pData->dnodeId,
|
||||||
pMgmt->statusSeq);
|
pMgmt->statusSeq);
|
||||||
pMgmt->pData->dropped = 1;
|
pMgmt->pData->dropped = 1;
|
||||||
dmWriteEps(pMgmt->pData);
|
(void)dmWriteEps(pMgmt->pData);
|
||||||
dInfo("dnode will exit since it is in the dropped state");
|
dInfo("dnode will exit since it is in the dropped state");
|
||||||
(void)raise(SIGINT);
|
(void)raise(SIGINT);
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
dError("failed to serialize status req since %s", tstrerror(contLen));
|
dError("failed to serialize status req since %s", tstrerror(contLen));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
tSerializeSStatusReq(pHead, contLen, &req);
|
contLen = tSerializeSStatusReq(pHead, contLen, &req);
|
||||||
if (contLen < 0) {
|
if (contLen < 0) {
|
||||||
rpcFreeCont(pHead);
|
rpcFreeCont(pHead);
|
||||||
dError("failed to serialize status req since %s", tstrerror(contLen));
|
dError("failed to serialize status req since %s", tstrerror(contLen));
|
||||||
|
@ -213,8 +214,17 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) {
|
void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) {
|
||||||
int32_t contLen = tSerializeSNotifyReq(NULL, 0, pReq);
|
int32_t contLen = tSerializeSNotifyReq(NULL, 0, pReq);
|
||||||
|
if (contLen < 0) {
|
||||||
|
dError("failed to serialize notify req since %s", tstrerror(contLen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
tSerializeSNotifyReq(pHead, contLen, pReq);
|
contLen = tSerializeSNotifyReq(pHead, contLen, pReq);
|
||||||
|
if (contLen < 0) {
|
||||||
|
rpcFreeCont(pHead);
|
||||||
|
dError("failed to serialize notify req since %s", tstrerror(contLen));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pHead,
|
SRpcMsg rpcMsg = {.pCont = pHead,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
|
@ -226,7 +236,7 @@ void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) {
|
||||||
|
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
dmGetMnodeEpSet(pMgmt->pData, &epSet);
|
||||||
rpcSendRequest(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, NULL);
|
(void)rpcSendRequest(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
|
|
@ -173,6 +173,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_UPDATE_DNODE_INFO, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -340,7 +340,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
if (vnodeCreate(path, &vnodeCfg, diskPrimary, pMgmt->pTfs) < 0) {
|
if (vnodeCreate(path, &vnodeCfg, diskPrimary, pMgmt->pTfs) < 0) {
|
||||||
dError("vgId:%d, failed to create vnode since %s", req.vgId, terrstr());
|
dError("vgId:%d, failed to create vnode since %s", req.vgId, terrstr());
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
tFreeSCreateVnodeReq(&req);
|
(void)tFreeSCreateVnodeReq(&req);
|
||||||
code = terrno != 0 ? terrno : -1;
|
code = terrno != 0 ? terrno : -1;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,7 @@ void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
} else {
|
} else {
|
||||||
rsp.pCont = rpcMallocCont(contLen);
|
rsp.pCont = rpcMallocCont(contLen);
|
||||||
if (rsp.pCont != NULL) {
|
if (rsp.pCont != NULL) {
|
||||||
tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp);
|
(void)tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp);
|
||||||
rsp.contLen = contLen;
|
rsp.contLen = contLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ _OVER:
|
||||||
if (pWrapper != NULL) {
|
if (pWrapper != NULL) {
|
||||||
dmSendRsp(&rsp);
|
dmSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
rpcSendResponse(&rsp);
|
(void)rpcSendResponse(&rsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) {
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
taosCloseFile(pFile);
|
(void)taosCloseFile(pFile);
|
||||||
*pFile = NULL;
|
*pFile = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
||||||
opts.source = DM_KEY_INDICATOR;
|
opts.source = DM_KEY_INDICATOR;
|
||||||
opts.result = result;
|
opts.result = result;
|
||||||
opts.unitLen = 16;
|
opts.unitLen = 16;
|
||||||
CBC_Encrypt(&opts);
|
(void)CBC_Encrypt(&opts);
|
||||||
|
|
||||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -359,7 +359,7 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
||||||
opts.source = content;
|
opts.source = content;
|
||||||
opts.result = result;
|
opts.result = result;
|
||||||
opts.unitLen = 16;
|
opts.unitLen = 16;
|
||||||
CBC_Decrypt(&opts);
|
(void)CBC_Decrypt(&opts);
|
||||||
|
|
||||||
if (strcmp(opts.result, DM_KEY_INDICATOR) != 0) {
|
if (strcmp(opts.result, DM_KEY_INDICATOR) != 0) {
|
||||||
code = TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED;
|
code = TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED;
|
||||||
|
|
|
@ -57,8 +57,8 @@ void *dmSetMgmtHandle(SArray *pArray, tmsg_t msgType, void *nodeMsgFp, bool need
|
||||||
void dmGetMonitorSystemInfo(SMonSysInfo *pInfo) {
|
void dmGetMonitorSystemInfo(SMonSysInfo *pInfo) {
|
||||||
taosGetCpuUsage(&pInfo->cpu_system, &pInfo->cpu_engine);
|
taosGetCpuUsage(&pInfo->cpu_system, &pInfo->cpu_engine);
|
||||||
taosGetCpuCores(&pInfo->cpu_cores, false);
|
taosGetCpuCores(&pInfo->cpu_cores, false);
|
||||||
taosGetProcMemory(&pInfo->mem_engine);
|
(void)taosGetProcMemory(&pInfo->mem_engine);
|
||||||
taosGetSysMemory(&pInfo->mem_system);
|
(void)taosGetSysMemory(&pInfo->mem_system);
|
||||||
pInfo->mem_total = tsTotalMemoryKB;
|
pInfo->mem_total = tsTotalMemoryKB;
|
||||||
pInfo->disk_engine = 0;
|
pInfo->disk_engine = 0;
|
||||||
pInfo->disk_used = tsDataSpace.size.used;
|
pInfo->disk_used = tsDataSpace.size.used;
|
||||||
|
|
|
@ -52,6 +52,11 @@ typedef struct SStreamTransMgmt {
|
||||||
SHashObj *pDBTrans;
|
SHashObj *pDBTrans;
|
||||||
} SStreamTransMgmt;
|
} SStreamTransMgmt;
|
||||||
|
|
||||||
|
typedef struct SStreamTaskResetMsg {
|
||||||
|
int64_t streamId;
|
||||||
|
int32_t transId;
|
||||||
|
} SStreamTaskResetMsg;
|
||||||
|
|
||||||
typedef struct SStreamExecInfo {
|
typedef struct SStreamExecInfo {
|
||||||
bool initTaskList;
|
bool initTaskList;
|
||||||
SArray *pNodeList;
|
SArray *pNodeList;
|
||||||
|
@ -63,6 +68,7 @@ typedef struct SStreamExecInfo {
|
||||||
SHashObj *pTransferStateStreams;
|
SHashObj *pTransferStateStreams;
|
||||||
SHashObj *pChkptStreams;
|
SHashObj *pChkptStreams;
|
||||||
SHashObj *pStreamConsensus;
|
SHashObj *pStreamConsensus;
|
||||||
|
SArray *pKilledChkptTrans; // SArray<SStreamTaskResetMsg>
|
||||||
} SStreamExecInfo;
|
} SStreamExecInfo;
|
||||||
|
|
||||||
extern SStreamExecInfo execInfo;
|
extern SStreamExecInfo execInfo;
|
||||||
|
@ -75,12 +81,6 @@ typedef struct SNodeEntry {
|
||||||
int64_t hbTimestamp; // second
|
int64_t hbTimestamp; // second
|
||||||
} SNodeEntry;
|
} SNodeEntry;
|
||||||
|
|
||||||
typedef struct SOrphanTask {
|
|
||||||
int64_t streamId;
|
|
||||||
int32_t taskId;
|
|
||||||
int32_t nodeId;
|
|
||||||
} SOrphanTask;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
} SMStreamReqCheckpointRsp, SMStreamUpdateChkptRsp, SMStreamReqConsensChkptRsp;
|
} SMStreamReqCheckpointRsp, SMStreamUpdateChkptRsp, SMStreamReqConsensChkptRsp;
|
||||||
|
@ -152,6 +152,11 @@ void mndAddConsensusTasks(SCheckpointConsensusInfo *pInfo, const SRestoreChec
|
||||||
void mndClearConsensusRspEntry(SCheckpointConsensusInfo *pInfo);
|
void mndClearConsensusRspEntry(SCheckpointConsensusInfo *pInfo);
|
||||||
int64_t mndClearConsensusCheckpointId(SHashObj* pHash, int64_t streamId);
|
int64_t mndClearConsensusCheckpointId(SHashObj* pHash, int64_t streamId);
|
||||||
|
|
||||||
|
int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_t numOfRows);
|
||||||
|
int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SSDataBlock *pBlock, int32_t numOfRows);
|
||||||
|
|
||||||
|
int32_t mndProcessResetStatusReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1892,13 +1892,21 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
||||||
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
||||||
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
||||||
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
||||||
rsp.dbTsmaVersion = pDb->tsmaVersion;
|
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
if (mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist) != 0) {
|
int32_t code = mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
if (code != TSDB_CODE_NEED_RETRY) {
|
||||||
mError("db:%s, failed to get db tsmas", pDb->name);
|
mError("db:%s, failed to get db tsmas", pDb->name);
|
||||||
|
} else {
|
||||||
|
mWarn("db:%s, need retry to get db tsmas", pDb->name);
|
||||||
|
}
|
||||||
|
taosArrayDestroyP(rsp.pTsmaRsp->pTsmas, tFreeAndClearTableTSMAInfo);
|
||||||
|
taosMemoryFreeClear(rsp.pTsmaRsp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
rsp.dbTsmaVersion = pDb->tsmaVersion;
|
||||||
|
mDebug("update tsma version to %d, got tsma num: %ld", pDb->tsmaVersion, rsp.pTsmaRsp->pTsmas->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1909,6 +1917,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
||||||
if (rsp.useDbRsp->pVgroupInfos == NULL) {
|
if (rsp.useDbRsp->pVgroupInfos == NULL) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mError("db:%s, failed to malloc usedb response", pDb->name);
|
mError("db:%s, failed to malloc usedb response", pDb->name);
|
||||||
|
taosArrayDestroyP(rsp.pTsmaRsp->pTsmas, tFreeAndClearTableTSMAInfo);
|
||||||
|
taosMemoryFreeClear(rsp.pTsmaRsp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq);
|
static int32_t mndProcessStatisReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pRsp);
|
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pRsp);
|
||||||
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp);
|
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp);
|
||||||
|
|
||||||
|
@ -126,6 +127,7 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ENCRYPT_KEY, mndProcessCreateEncryptKeyReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ENCRYPT_KEY, mndProcessCreateEncryptKeyReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mndProcessCreateEncryptKeyRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mndProcessCreateEncryptKeyRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_UPDATE_DNODE_INFO, mndProcessUpdateDnodeInfoReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
||||||
|
@ -601,37 +603,78 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0, lino = 0;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj");
|
SDnodeInfoReq infoReq = {0};
|
||||||
|
int32_t contLen = 0;
|
||||||
|
void *pReq = NULL;
|
||||||
|
|
||||||
|
infoReq.dnodeId = pDnode->id;
|
||||||
|
tstrncpy(infoReq.machineId, pDnode->machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||||
|
|
||||||
|
if ((contLen = tSerializeSDnodeInfoReq(NULL, 0, &infoReq)) <= 0) {
|
||||||
|
TAOS_RETURN(contLen ? contLen : TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
pReq = rpcMallocCont(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)tSerializeSDnodeInfoReq(pReq, contLen, &infoReq);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPDATE_DNODE_INFO, .pCont = pReq, .contLen = contLen};
|
||||||
|
TAOS_CHECK_EXIT(tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg));
|
||||||
|
_exit:
|
||||||
|
if (code < 0) {
|
||||||
|
mError("dnode:%d, failed to update dnode info since %s", pDnode->id, tstrerror(code));
|
||||||
|
}
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq) {
|
||||||
|
int32_t code = 0, lino = 0;
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SDnodeInfoReq infoReq = {0};
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
SSdbRaw *pCommitRaw = NULL;
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tDeserializeSDnodeInfoReq(pReq->pCont, pReq->contLen, &infoReq));
|
||||||
|
|
||||||
|
pDnode = mndAcquireDnode(pMnode, infoReq.dnodeId);
|
||||||
|
if (pDnode == NULL) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
|
|
||||||
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj");
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
TAOS_CHECK_EXIT(terrno);
|
||||||
if (terrno != 0) code = terrno;
|
|
||||||
goto _exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pDnode->updateTime = taosGetTimestampMs();
|
pDnode->updateTime = taosGetTimestampMs();
|
||||||
|
|
||||||
SSdbRaw *pCommitRaw = mndDnodeActionEncode(pDnode);
|
if ((pCommitRaw = mndDnodeActionEncode(pDnode)) == NULL) {
|
||||||
if (pCommitRaw == NULL) {
|
TAOS_CHECK_EXIT(terrno);
|
||||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
|
||||||
if (terrno != 0) code = terrno;
|
|
||||||
goto _exit;
|
|
||||||
}
|
}
|
||||||
if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code));
|
mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code));
|
||||||
code = terrno;
|
TAOS_CHECK_EXIT(code);
|
||||||
goto _exit;
|
|
||||||
}
|
}
|
||||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||||
|
pCommitRaw = NULL;
|
||||||
|
|
||||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
||||||
goto _exit;
|
TAOS_CHECK_EXIT(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("dnode:%d, failed to update dnode info at line %d since %s", infoReq.dnodeId, lino, tstrerror(code));
|
||||||
|
}
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
sdbFreeRaw(pCommitRaw);
|
||||||
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ void grantRestore(EGrantType grant, uint64_t value) {}
|
||||||
int64_t grantRemain(EGrantType grant) { return 0; }
|
int64_t grantRemain(EGrantType grant) { return 0; }
|
||||||
int32_t tGetMachineId(char **result) {
|
int32_t tGetMachineId(char **result) {
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
return TSDB_CODE_APP_ERROR;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
|
@ -716,9 +716,9 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||||
void mndPreClose(SMnode *pMnode) {
|
void mndPreClose(SMnode *pMnode) {
|
||||||
if (pMnode != NULL) {
|
if (pMnode != NULL) {
|
||||||
// TODO check return value
|
// TODO check return value
|
||||||
syncLeaderTransfer(pMnode->syncMgmt.sync);
|
(void)syncLeaderTransfer(pMnode->syncMgmt.sync);
|
||||||
syncPreStop(pMnode->syncMgmt.sync);
|
syncPreStop(pMnode->syncMgmt.sync);
|
||||||
sdbWriteFile(pMnode->pSdb, 0);
|
(void)sdbWriteFile(pMnode->pSdb, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,12 +1106,12 @@ int64_t mndGetRoleTimeMs(SMnode *pMnode) {
|
||||||
|
|
||||||
void mndSetRestored(SMnode *pMnode, bool restored) {
|
void mndSetRestored(SMnode *pMnode, bool restored) {
|
||||||
if (restored) {
|
if (restored) {
|
||||||
taosThreadRwlockWrlock(&pMnode->lock);
|
(void)taosThreadRwlockWrlock(&pMnode->lock);
|
||||||
pMnode->restored = true;
|
pMnode->restored = true;
|
||||||
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
||||||
mInfo("mnode set restored:%d", restored);
|
mInfo("mnode set restored:%d", restored);
|
||||||
} else {
|
} else {
|
||||||
taosThreadRwlockWrlock(&pMnode->lock);
|
(void)taosThreadRwlockWrlock(&pMnode->lock);
|
||||||
pMnode->restored = false;
|
pMnode->restored = false;
|
||||||
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
||||||
mInfo("mnode set restored:%d", restored);
|
mInfo("mnode set restored:%d", restored);
|
||||||
|
@ -1125,7 +1125,7 @@ void mndSetRestored(SMnode *pMnode, bool restored) {
|
||||||
bool mndGetRestored(SMnode *pMnode) { return pMnode->restored; }
|
bool mndGetRestored(SMnode *pMnode) { return pMnode->restored; }
|
||||||
|
|
||||||
void mndSetStop(SMnode *pMnode) {
|
void mndSetStop(SMnode *pMnode) {
|
||||||
taosThreadRwlockWrlock(&pMnode->lock);
|
(void)taosThreadRwlockWrlock(&pMnode->lock);
|
||||||
pMnode->stopped = true;
|
pMnode->stopped = true;
|
||||||
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
(void)taosThreadRwlockUnlock(&pMnode->lock);
|
||||||
mInfo("mnode set stopped");
|
mInfo("mnode set stopped");
|
||||||
|
|
|
@ -575,7 +575,10 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
||||||
|
|
||||||
if (needCheck) {
|
if (needCheck) {
|
||||||
SKv kv1 = {.key = HEARTBEAT_KEY_DYN_VIEW, .valueLen = sizeof(*pDynViewVer), .value = pRspVer};
|
SKv kv1 = {.key = HEARTBEAT_KEY_DYN_VIEW, .valueLen = sizeof(*pDynViewVer), .value = pRspVer};
|
||||||
taosArrayPush(hbRsp.info, &kv1);
|
if (taosArrayPush(hbRsp.info, &kv1) == NULL) {
|
||||||
|
if (terrno != 0) code = terrno;
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
};
|
||||||
mTrace("need to check view ver, lastest bootTs:%" PRId64 ", ver:%" PRIu64, pRspVer->svrBootTs,
|
mTrace("need to check view ver, lastest bootTs:%" PRId64 ", ver:%" PRIu64, pRspVer->svrBootTs,
|
||||||
pRspVer->dynViewVer);
|
pRspVer->dynViewVer);
|
||||||
}
|
}
|
||||||
|
@ -703,7 +706,7 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq) {
|
||||||
} else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) {
|
} else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) {
|
||||||
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
|
SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq);
|
||||||
if (pRsp != NULL) {
|
if (pRsp != NULL) {
|
||||||
taosArrayPush(batchRsp.rsps, pRsp);
|
(void)taosArrayPush(batchRsp.rsps, pRsp);
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1760,14 +1760,14 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||||
SDbObj newDb = {0};
|
SDbObj newDb = {0};
|
||||||
memcpy(&newDb, pCxt->pDb, sizeof(SDbObj));
|
memcpy(&newDb, pCxt->pDb, sizeof(SDbObj));
|
||||||
newDb.tsmaVersion++;
|
newDb.tsmaVersion++;
|
||||||
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
|
||||||
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
|
||||||
TAOS_CHECK_GOTO(mndSetCreateSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetCreateSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndSetCreateSmaUndoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetCreateSmaUndoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndSetCreateSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetCreateSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &createStreamRedoAction), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &createStreamRedoAction), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &createStreamUndoAction), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &createStreamUndoAction), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &dropStbUndoAction), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &dropStbUndoAction), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER);
|
||||||
|
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -2030,12 +2030,12 @@ static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) {
|
||||||
SDbObj newDb = {0};
|
SDbObj newDb = {0};
|
||||||
memcpy(&newDb, pCxt->pDb, sizeof(SDbObj));
|
memcpy(&newDb, pCxt->pDb, sizeof(SDbObj));
|
||||||
newDb.tsmaVersion++;
|
newDb.tsmaVersion++;
|
||||||
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
|
||||||
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
|
||||||
TAOS_CHECK_GOTO(mndSetDropSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetDropSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndSetDropSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndSetDropSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStreamRedoAction), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStreamRedoAction), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStbRedoAction), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStbRedoAction), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER);
|
||||||
TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER);
|
TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER);
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -2450,13 +2450,14 @@ static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rs
|
||||||
typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param);
|
typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param);
|
||||||
|
|
||||||
static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) {
|
static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) {
|
||||||
int32_t code = -1;
|
int32_t code = 0;
|
||||||
SSmaObj * pSma = NULL;
|
SSmaObj * pSma = NULL;
|
||||||
SSmaObj * pBaseTsma = NULL;
|
SSmaObj * pBaseTsma = NULL;
|
||||||
SSdb * pSdb = pMnode->pSdb;
|
SSdb * pSdb = pMnode->pSdb;
|
||||||
void * pIter = NULL;
|
void * pIter = NULL;
|
||||||
SStreamObj * pStream = NULL;
|
SStreamObj * pStream = NULL;
|
||||||
SStbObj * pStb = NULL;
|
SStbObj * pStb = NULL;
|
||||||
|
bool shouldRetry = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||||
|
@ -2470,6 +2471,7 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
||||||
pStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
pStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
||||||
if (!pStb) {
|
if (!pStb) {
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
|
shouldRetry = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2478,16 +2480,24 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
||||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
|
mndReleaseStb(pMnode, pStb);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname);
|
sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname);
|
||||||
pStream = NULL;
|
pStream = NULL;
|
||||||
|
|
||||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||||
if (!pStream || (code != 0)) {
|
if (!pStream) {
|
||||||
|
shouldRetry = true;
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
|
mndReleaseStb(pMnode, pStb);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (code != 0) {
|
||||||
|
sdbRelease(pSdb, pSma);
|
||||||
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t streamId = pStream->uid;
|
int64_t streamId = pStream->uid;
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
|
@ -2522,6 +2532,9 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
||||||
}
|
}
|
||||||
*exist = true;
|
*exist = true;
|
||||||
}
|
}
|
||||||
|
if (shouldRetry) {
|
||||||
|
return TSDB_CODE_NEED_RETRY;
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2562,6 +2575,9 @@ static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) {
|
||||||
code = mndGetTSMA(pMnode, tsmaReq.name, &rsp, &exist);
|
code = mndGetTSMA(pMnode, tsmaReq.name, &rsp, &exist);
|
||||||
} else {
|
} else {
|
||||||
code = mndGetTableTSMA(pMnode, tsmaReq.name, &rsp, &exist);
|
code = mndGetTableTSMA(pMnode, tsmaReq.name, &rsp, &exist);
|
||||||
|
if (TSDB_CODE_NEED_RETRY == code) {
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (code) {
|
if (code) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -2629,7 +2629,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
// TODO check return value
|
// TODO check return value
|
||||||
tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
(void)tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
auditRecord(pReq, pMnode->clusterId, "alterStb", name.dbname, name.tname, alterReq.sql, alterReq.sqlLen);
|
auditRecord(pReq, pMnode->clusterId, "alterStb", name.dbname, name.tname, alterReq.sql, alterReq.sqlLen);
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,7 @@ static int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCheckpointReport(SRpcMsg *pReq);
|
static int32_t mndProcessCheckpointReport(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessConsensusInTmr(SRpcMsg *pMsg);
|
static int32_t mndProcessConsensusInTmr(SRpcMsg *pMsg);
|
||||||
static void doSendQuickRsp(SRpcHandleInfo *pInfo, int32_t msgSize, int32_t vgId, int32_t code);
|
static void doSendQuickRsp(SRpcHandleInfo *pInfo, int32_t msgSize, int32_t vgId, int32_t code);
|
||||||
|
static int32_t mndProcessDropOrphanTaskReq(SRpcMsg* pReq);
|
||||||
|
|
||||||
static int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_t numOfRows);
|
|
||||||
|
|
||||||
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList);
|
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList);
|
||||||
|
|
||||||
|
@ -121,6 +119,8 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamCheckpoint);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamCheckpoint);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_DROP_ORPHANTASKS, mndProcessDropOrphanTaskReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_TASK_RESET, mndProcessResetStatusReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_REQ_CHKPT, mndProcessStreamReqCheckpoint);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_REQ_CHKPT, mndProcessStreamReqCheckpoint);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHKPT_REPORT, mndProcessCheckpointReport);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHKPT_REPORT, mndProcessCheckpointReport);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_UPDATE_CHKPT_EVT, mndScanCheckpointReportInfo);
|
mndSetMsgHandle(pMnode, TDMT_MND_STREAM_UPDATE_CHKPT_EVT, mndScanCheckpointReportInfo);
|
||||||
|
@ -154,6 +154,7 @@ int32_t mndInitStream(SMnode *pMnode) {
|
||||||
void mndCleanupStream(SMnode *pMnode) {
|
void mndCleanupStream(SMnode *pMnode) {
|
||||||
taosArrayDestroy(execInfo.pTaskList);
|
taosArrayDestroy(execInfo.pTaskList);
|
||||||
taosArrayDestroy(execInfo.pNodeList);
|
taosArrayDestroy(execInfo.pNodeList);
|
||||||
|
taosArrayDestroy(execInfo.pKilledChkptTrans);
|
||||||
taosHashCleanup(execInfo.pTaskMap);
|
taosHashCleanup(execInfo.pTaskMap);
|
||||||
taosHashCleanup(execInfo.transMgmt.pDBTrans);
|
taosHashCleanup(execInfo.transMgmt.pDBTrans);
|
||||||
taosHashCleanup(execInfo.pTransferStateStreams);
|
taosHashCleanup(execInfo.pTransferStateStreams);
|
||||||
|
@ -271,38 +272,12 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
sdbRelease(pSdb, pStream);
|
sdbRelease(pSdb, pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndShowStreamStatus(char *dst, SStreamObj *pStream) {
|
|
||||||
int8_t status = atomic_load_8(&pStream->status);
|
|
||||||
if (status == STREAM_STATUS__NORMAL) {
|
|
||||||
strcpy(dst, "ready");
|
|
||||||
} else if (status == STREAM_STATUS__STOP) {
|
|
||||||
strcpy(dst, "stop");
|
|
||||||
} else if (status == STREAM_STATUS__FAILED) {
|
|
||||||
strcpy(dst, "failed");
|
|
||||||
} else if (status == STREAM_STATUS__RECOVER) {
|
|
||||||
strcpy(dst, "recover");
|
|
||||||
} else if (status == STREAM_STATUS__PAUSE) {
|
|
||||||
strcpy(dst, "paused");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SSdbRaw *mndStreamSeqActionEncode(SStreamObj *pStream) { return NULL; }
|
SSdbRaw *mndStreamSeqActionEncode(SStreamObj *pStream) { return NULL; }
|
||||||
SSdbRow *mndStreamSeqActionDecode(SSdbRaw *pRaw) { return NULL; }
|
SSdbRow *mndStreamSeqActionDecode(SSdbRaw *pRaw) { return NULL; }
|
||||||
int32_t mndStreamSeqActionInsert(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
|
int32_t mndStreamSeqActionInsert(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
|
||||||
int32_t mndStreamSeqActionDelete(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
|
int32_t mndStreamSeqActionDelete(SSdb *pSdb, SStreamSeq *pStream) { return 0; }
|
||||||
int32_t mndStreamSeqActionUpdate(SSdb *pSdb, SStreamSeq *pOldStream, SStreamSeq *pNewStream) { return 0; }
|
int32_t mndStreamSeqActionUpdate(SSdb *pSdb, SStreamSeq *pOldStream, SStreamSeq *pNewStream) { return 0; }
|
||||||
|
|
||||||
static void mndShowStreamTrigger(char *dst, SStreamObj *pStream) {
|
|
||||||
int8_t trigger = pStream->conf.trigger;
|
|
||||||
if (trigger == STREAM_TRIGGER_AT_ONCE) {
|
|
||||||
strcpy(dst, "at once");
|
|
||||||
} else if (trigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
|
||||||
strcpy(dst, "window close");
|
|
||||||
} else if (trigger == STREAM_TRIGGER_MAX_DELAY) {
|
|
||||||
strcpy(dst, "max delay");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
||||||
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0 || pCreate->sourceDB[0] == 0 ||
|
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0 || pCreate->sourceDB[0] == 0 ||
|
||||||
pCreate->targetStbFullName[0] == 0) {
|
pCreate->targetStbFullName[0] == 0) {
|
||||||
|
@ -873,7 +848,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr(code));
|
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||||
} else {
|
} else {
|
||||||
mDebug("stream:%s create stream completed", createReq.name);
|
mDebug("stream:%s create stream completed", createReq.name);
|
||||||
}
|
}
|
||||||
|
@ -1020,10 +995,10 @@ static int32_t doSetCheckpointAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
||||||
|
|
||||||
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
|
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
|
||||||
int8_t mndTrigger, bool lock) {
|
int8_t mndTrigger, bool lock) {
|
||||||
int32_t code = -1;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int64_t ts = taosGetTimestampMs();
|
int64_t ts = taosGetTimestampMs();
|
||||||
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
||||||
|
@ -1087,13 +1062,11 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
||||||
goto _ERR;
|
goto _ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = mndTransPrepare(pMnode, pTrans)) != TSDB_CODE_SUCCESS) {
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
code = terrno;
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("failed to prepare checkpoint trans since %s", terrstr());
|
mError("failed to prepare checkpoint trans since %s", terrstr());
|
||||||
goto _ERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = 0;
|
|
||||||
_ERR:
|
_ERR:
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
return code;
|
||||||
|
@ -1367,8 +1340,8 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
SMDropStreamReq dropReq = {0};
|
SMDropStreamReq dropReq = {0};
|
||||||
if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) {
|
if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) {
|
||||||
mError("invalid drop stream msg recv, discarded");
|
mError("invalid drop stream msg recv, discarded");
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("recv drop stream:%s msg", dropReq.name);
|
mDebug("recv drop stream:%s msg", dropReq.name);
|
||||||
|
@ -1381,10 +1354,10 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
code = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
mError("stream:%s not exist failed to drop it", dropReq.name);
|
mError("stream:%s not exist failed to drop it", dropReq.name);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,11 +1374,11 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
terrno = TSDB_CODE_TSMA_MUST_BE_DROPPED;
|
code = TSDB_CODE_TSMA_MUST_BE_DROPPED;
|
||||||
|
|
||||||
mError("try to drop sma-related stream:%s, uid:0x%" PRIx64 " code:%s only allowed to be dropped along with sma",
|
mError("try to drop sma-related stream:%s, uid:0x%" PRIx64 " code:%s only allowed to be dropped along with sma",
|
||||||
dropReq.name, pStream->uid, tstrerror(terrno));
|
dropReq.name, pStream->uid, tstrerror(terrno));
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSma) {
|
if (pSma) {
|
||||||
|
@ -1427,7 +1400,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
if (conflict) {
|
if (conflict) {
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
@ -1436,34 +1409,44 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
mError("stream:%s uid:0x%" PRIx64 " failed to drop since %s", dropReq.name, pStream->uid, terrstr());
|
mError("stream:%s uid:0x%" PRIx64 " failed to drop since %s", dropReq.name, pStream->uid, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pStream->uid);
|
code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pStream->uid);
|
||||||
|
if (code) {
|
||||||
// drop all tasks
|
mError("failed to register drop stream trans, code:%s", tstrerror(code));
|
||||||
if (mndStreamSetDropAction(pMnode, pTrans, pStream) < 0) {
|
|
||||||
mError("stream:%s uid:0x%" PRIx64 " failed to drop task since %s", dropReq.name, pStream->uid, terrstr());
|
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop all tasks
|
||||||
|
code = mndStreamSetDropAction(pMnode, pTrans, pStream);
|
||||||
|
if (code) {
|
||||||
|
mError("stream:%s uid:0x%" PRIx64 " failed to drop task since %s", dropReq.name, pStream->uid, tstrerror(code));
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
tFreeMDropStreamReq(&dropReq);
|
||||||
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop stream
|
// drop stream
|
||||||
if (mndPersistTransLog(pStream, pTrans, SDB_STATUS_DROPPED) < 0) {
|
code = mndPersistTransLog(pStream, pTrans, SDB_STATUS_DROPPED);
|
||||||
|
if (code) {
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
tFreeMDropStreamReq(&dropReq);
|
tFreeMDropStreamReq(&dropReq);
|
||||||
return -1;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kill the related checkpoint trans
|
// kill the related checkpoint trans
|
||||||
|
@ -1489,7 +1472,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
return code;
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1571,15 +1554,6 @@ int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void int64ToHexStr(int64_t id, char *pBuf, int32_t bufLen) {
|
|
||||||
memset(pBuf, 0, bufLen);
|
|
||||||
pBuf[2] = '0';
|
|
||||||
pBuf[3] = 'x';
|
|
||||||
|
|
||||||
int32_t len = tintToHex(id, &pBuf[4]);
|
|
||||||
varDataSetLen(pBuf, len + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -1607,379 +1581,6 @@ static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_t numOfRows) {
|
|
||||||
int32_t code = 0;
|
|
||||||
int32_t cols = 0;
|
|
||||||
int32_t lino = 0;
|
|
||||||
|
|
||||||
char streamName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(streamName, mndGetDbStr(pStream->name), sizeof(streamName));
|
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)streamName, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// create time
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pStream->createTime, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// stream id
|
|
||||||
char buf[128] = {0};
|
|
||||||
int64ToHexStr(pStream->uid, buf, tListLen(buf));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// related fill-history stream id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
if (pStream->hTaskUid != 0) {
|
|
||||||
int64ToHexStr(pStream->hTaskUid, buf, tListLen(buf));
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
|
||||||
} else {
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, buf, true);
|
|
||||||
}
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// related fill-history stream id
|
|
||||||
char sql[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(sql, pStream->sql, sizeof(sql));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)sql, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
char status2[20] = {0};
|
|
||||||
mndShowStreamStatus(status2, pStream);
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(status, status2, sizeof(status));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&status, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
char sourceDB[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(sourceDB, mndGetDbStr(pStream->sourceDb), sizeof(sourceDB));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&sourceDB, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
char targetDB[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(targetDB, mndGetDbStr(pStream->targetDb), sizeof(targetDB));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&targetDB, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
if (pStream->targetSTbName[0] == 0) {
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, NULL, true);
|
|
||||||
} else {
|
|
||||||
char targetSTB[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(targetSTB, mndGetStbStr(pStream->targetSTbName), sizeof(targetSTB));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&targetSTB, false);
|
|
||||||
}
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pStream->conf.watermark, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
char trigger[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
char trigger2[20] = {0};
|
|
||||||
mndShowStreamTrigger(trigger2, pStream);
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(trigger, trigger2, sizeof(trigger));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&trigger, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// sink_quota
|
|
||||||
char sinkQuota[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
sinkQuota[0] = '0';
|
|
||||||
char dstStr[20] = {0};
|
|
||||||
STR_TO_VARSTR(dstStr, sinkQuota)
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)dstStr, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint interval
|
|
||||||
char tmp[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
sprintf(varDataVal(tmp), "%d sec", tsStreamCheckpointInterval);
|
|
||||||
varDataSetLen(tmp, strlen(varDataVal(tmp)));
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)tmp, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint backup type
|
|
||||||
char backup[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_TO_VARSTR(backup, "none")
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)backup, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// history scan idle
|
|
||||||
char scanHistoryIdle[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
strcpy(scanHistoryIdle, "100a");
|
|
||||||
|
|
||||||
memset(dstStr, 0, tListLen(dstStr));
|
|
||||||
STR_TO_VARSTR(dstStr, scanHistoryIdle)
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)dstStr, false);
|
|
||||||
|
|
||||||
_end:
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SSDataBlock *pBlock, int32_t numOfRows) {
|
|
||||||
SColumnInfoData *pColInfo;
|
|
||||||
int32_t cols = 0;
|
|
||||||
int32_t code = 0;
|
|
||||||
int32_t lino = 0;
|
|
||||||
|
|
||||||
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
|
||||||
|
|
||||||
STaskStatusEntry *pe = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
|
||||||
if (pe == NULL) {
|
|
||||||
mError("task:0x%" PRIx64 " not exists in any vnodes, streamName:%s, streamId:0x%" PRIx64 " createTs:%" PRId64
|
|
||||||
" no valid status/stage info",
|
|
||||||
id.taskId, pStream->name, pStream->uid, pStream->createTime);
|
|
||||||
return TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
// stream name
|
|
||||||
char streamName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(streamName, mndGetDbStr(pStream->name), sizeof(streamName));
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)streamName, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// task id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
|
|
||||||
char idstr[128] = {0};
|
|
||||||
int64ToHexStr(pTask->id.taskId, idstr, tListLen(idstr));
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, idstr, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// node type
|
|
||||||
char nodeType[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
varDataSetLen(nodeType, 5);
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
if (pTask->info.nodeId > 0) {
|
|
||||||
memcpy(varDataVal(nodeType), "vnode", 5);
|
|
||||||
} else {
|
|
||||||
memcpy(varDataVal(nodeType), "snode", 5);
|
|
||||||
}
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, nodeType, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// node id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
int64_t nodeId = TMAX(pTask->info.nodeId, 0);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&nodeId, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// level
|
|
||||||
char level[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
|
||||||
memcpy(varDataVal(level), "source", 6);
|
|
||||||
varDataSetLen(level, 6);
|
|
||||||
} else if (pTask->info.taskLevel == TASK_LEVEL__AGG) {
|
|
||||||
memcpy(varDataVal(level), "agg", 3);
|
|
||||||
varDataSetLen(level, 3);
|
|
||||||
} else if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
|
||||||
memcpy(varDataVal(level), "sink", 4);
|
|
||||||
varDataSetLen(level, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)level, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// status
|
|
||||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
|
|
||||||
const char *pStatus = streamTaskGetStatusStr(pe->status);
|
|
||||||
STR_TO_VARSTR(status, pStatus);
|
|
||||||
|
|
||||||
// status
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)status, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// stage
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->stage, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// input queue
|
|
||||||
char vbuf[40] = {0};
|
|
||||||
char buf[38] = {0};
|
|
||||||
const char *queueInfoStr = "%4.2f MiB (%6.2f%)";
|
|
||||||
snprintf(buf, tListLen(buf), queueInfoStr, pe->inputQUsed, pe->inputRate);
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// input total
|
|
||||||
const char *formatTotalMb = "%7.2f MiB";
|
|
||||||
const char *formatTotalGb = "%7.2f GiB";
|
|
||||||
if (pe->procsTotal < 1024) {
|
|
||||||
snprintf(buf, tListLen(buf), formatTotalMb, pe->procsTotal);
|
|
||||||
} else {
|
|
||||||
snprintf(buf, tListLen(buf), formatTotalGb, pe->procsTotal / 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(vbuf, 0, tListLen(vbuf));
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// process throughput
|
|
||||||
const char *formatKb = "%7.2f KiB/s";
|
|
||||||
const char *formatMb = "%7.2f MiB/s";
|
|
||||||
if (pe->procsThroughput < 1024) {
|
|
||||||
snprintf(buf, tListLen(buf), formatKb, pe->procsThroughput);
|
|
||||||
} else {
|
|
||||||
snprintf(buf, tListLen(buf), formatMb, pe->procsThroughput / 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(vbuf, 0, tListLen(vbuf));
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// output total
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
|
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
|
||||||
} else {
|
|
||||||
sprintf(buf, formatTotalMb, pe->outputTotal);
|
|
||||||
memset(vbuf, 0, tListLen(vbuf));
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
}
|
|
||||||
|
|
||||||
// output throughput
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
|
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
|
||||||
} else {
|
|
||||||
if (pe->outputThroughput < 1024) {
|
|
||||||
snprintf(buf, tListLen(buf), formatKb, pe->outputThroughput);
|
|
||||||
} else {
|
|
||||||
snprintf(buf, tListLen(buf), formatMb, pe->outputThroughput / 1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(vbuf, 0, tListLen(vbuf));
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
}
|
|
||||||
|
|
||||||
// output queue
|
|
||||||
// sprintf(buf, queueInfoStr, pe->outputQUsed, pe->outputRate);
|
|
||||||
// STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
// colDataSetVal(pColInfo, numOfRows, (const char*)vbuf, false);
|
|
||||||
|
|
||||||
// info
|
|
||||||
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
|
||||||
const char *sinkStr = "%.2f MiB";
|
|
||||||
snprintf(buf, tListLen(buf), sinkStr, pe->sinkDataSize);
|
|
||||||
} else if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
|
||||||
// offset info
|
|
||||||
const char *offsetStr = "%" PRId64 " [%" PRId64 ", %" PRId64 "]";
|
|
||||||
snprintf(buf, tListLen(buf), offsetStr, pe->processedVer, pe->verRange.minVer, pe->verRange.maxVer);
|
|
||||||
} else {
|
|
||||||
memset(buf, 0, tListLen(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
STR_TO_VARSTR(vbuf, buf);
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// start_time
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startTime, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// start id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startCheckpointId, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// start ver
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startCheckpointVer, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint time
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
if (pe->checkpointInfo.latestTime != 0) {
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestTime, false);
|
|
||||||
} else {
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
|
||||||
}
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint_id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestId, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint version
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestVer, false);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// checkpoint size
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
colDataSetNULL(pColInfo, numOfRows);
|
|
||||||
|
|
||||||
// checkpoint backup status
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// ds_err_info
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// history_task_id
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
if (pe->hTaskId != 0) {
|
|
||||||
int64ToHexStr(pe->hTaskId, idstr, tListLen(idstr));
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, idstr, false);
|
|
||||||
} else {
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
|
||||||
}
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
// history_task_status
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
|
||||||
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _end);
|
|
||||||
|
|
||||||
_end:
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -2179,7 +1780,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
||||||
taosWUnLockLatch(&pStream->lock);
|
taosWUnLockLatch(&pStream->lock);
|
||||||
|
|
||||||
code = mndTransPrepare(pMnode, pTrans);
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
if (code) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -2273,7 +1874,8 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pStream->lock);
|
taosWUnLockLatch(&pStream->lock);
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -2434,7 +2036,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndTransPrepare(pMnode, pTrans);
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
if (code) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -3129,7 +2731,7 @@ int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndTransPrepare(pMnode, pTrans);
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
if (code) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -3141,3 +2743,80 @@ int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream,
|
||||||
|
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessDropOrphanTaskReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = 0;
|
||||||
|
SOrphanTask *pTask = NULL;
|
||||||
|
int32_t i = 0;
|
||||||
|
|
||||||
|
SMStreamDropOrphanMsg msg = {0};
|
||||||
|
code = tDeserializeDropOrphanTaskMsg(pReq->pCont, pReq->contLen, &msg);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfTasks = taosArrayGetSize(msg.pList);
|
||||||
|
if (numOfTasks == 0) {
|
||||||
|
mDebug("no orphan tasks to drop, no need to create trans");
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDebug("create trans to drop %d orphan tasks", numOfTasks);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < numOfTasks && ((pTask = taosArrayGet(msg.pList, i)) == NULL)) {
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTask == NULL) {
|
||||||
|
mError("failed to extract entry in drop orphan task list, not create trans to drop orphan-task");
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if it is conflict with other trans in both sourceDb and targetDb.
|
||||||
|
bool conflict = mndStreamTransConflictCheck(pMnode, pTask->streamId, MND_STREAM_DROP_NAME, false);
|
||||||
|
if (conflict) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamObj dummyObj = {.uid = pTask->streamId, .sourceDb = "", .targetSTbName = ""};
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
code = doCreateTrans(pMnode, &dummyObj, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream", &pTrans);
|
||||||
|
if (pTrans == NULL || code != 0) {
|
||||||
|
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pTask->streamId);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop all tasks
|
||||||
|
if ((code = mndStreamSetDropActionFromList(pMnode, pTrans, msg.pList)) < 0) {
|
||||||
|
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop stream
|
||||||
|
if ((code = mndPersistTransLog(&dummyObj, pTrans, SDB_STATUS_DROPPED)) < 0) {
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
mDebug("create drop %d orphan tasks trans succ", numOfTasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return code;
|
||||||
|
}
|
|
@ -22,12 +22,12 @@ typedef struct SFailedCheckpointInfo {
|
||||||
int32_t transId;
|
int32_t transId;
|
||||||
} SFailedCheckpointInfo;
|
} SFailedCheckpointInfo;
|
||||||
|
|
||||||
static void mndStreamStartUpdateCheckpointInfo(SMnode *pMnode);
|
static int32_t mndStreamSendUpdateChkptInfoMsg(SMnode *pMnode);
|
||||||
|
static int32_t mndSendDropOrphanTasksMsg(SMnode *pMnode, SArray *pList);
|
||||||
|
static int32_t mndSendResetFromCheckpointMsg(SMnode *pMnode, int64_t streamId, int32_t transId);
|
||||||
static void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage);
|
static void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage);
|
||||||
static void addIntoCheckpointList(SArray *pList, const SFailedCheckpointInfo *pInfo);
|
static void addIntoCheckpointList(SArray *pList, const SFailedCheckpointInfo *pInfo);
|
||||||
static int32_t mndResetStatusFromCheckpoint(SMnode *pMnode, int64_t streamId, int32_t transId);
|
|
||||||
static int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList);
|
static int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList);
|
||||||
static int32_t mndDropOrphanTasks(SMnode *pMnode, SArray *pList);
|
|
||||||
static int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo *info);
|
static int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo *info);
|
||||||
static bool validateHbMsg(const SArray *pNodeList, int32_t vgId);
|
static bool validateHbMsg(const SArray *pNodeList, int32_t vgId);
|
||||||
static void cleanupAfterProcessHbMsg(SStreamHbMsg *pReq, SArray *pFailedChkptList, SArray *pOrphanTasks);
|
static void cleanupAfterProcessHbMsg(SStreamHbMsg *pReq, SArray *pFailedChkptList, SArray *pOrphanTasks);
|
||||||
|
@ -37,6 +37,10 @@ void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage) {
|
||||||
int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeList);
|
int32_t numOfNodes = taosArrayGetSize(execInfo.pNodeList);
|
||||||
for (int32_t j = 0; j < numOfNodes; ++j) {
|
for (int32_t j = 0; j < numOfNodes; ++j) {
|
||||||
SNodeEntry *pNodeEntry = taosArrayGet(execInfo.pNodeList, j);
|
SNodeEntry *pNodeEntry = taosArrayGet(execInfo.pNodeList, j);
|
||||||
|
if (pNodeEntry == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pNodeEntry->nodeId == pTaskEntry->nodeId) {
|
if (pNodeEntry->nodeId == pTaskEntry->nodeId) {
|
||||||
mInfo("vgId:%d stage updated from %" PRId64 " to %" PRId64 ", nodeUpdate trigger by s-task:0x%" PRIx64,
|
mInfo("vgId:%d stage updated from %" PRId64 " to %" PRId64 ", nodeUpdate trigger by s-task:0x%" PRIx64,
|
||||||
pTaskEntry->nodeId, pTaskEntry->stage, stage, pTaskEntry->id.taskId);
|
pTaskEntry->nodeId, pTaskEntry->stage, stage, pTaskEntry->id.taskId);
|
||||||
|
@ -52,7 +56,7 @@ void addIntoCheckpointList(SArray *pList, const SFailedCheckpointInfo *pInfo) {
|
||||||
int32_t num = taosArrayGetSize(pList);
|
int32_t num = taosArrayGetSize(pList);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SFailedCheckpointInfo *p = taosArrayGet(pList, i);
|
SFailedCheckpointInfo *p = taosArrayGet(pList, i);
|
||||||
if (p->transId == pInfo->transId) {
|
if (p && (p->transId == pInfo->transId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +98,7 @@ int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndTransPrepare(pMnode, pTrans);
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
if (code != 0) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -104,15 +108,110 @@ int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndResetStatusFromCheckpoint(SMnode *pMnode, int64_t streamId, int32_t transId) {
|
int32_t mndSendResetFromCheckpointMsg(SMnode *pMnode, int64_t streamId, int32_t transId) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t size = sizeof(SStreamTaskResetMsg);
|
||||||
mndKillTransImpl(pMnode, transId, "");
|
|
||||||
|
|
||||||
|
int32_t num = taosArrayGetSize(execInfo.pKilledChkptTrans);
|
||||||
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
|
SStreamTaskResetMsg* p = taosArrayGet(execInfo.pKilledChkptTrans, i);
|
||||||
|
if (p == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->transId == transId && p->streamId == streamId) {
|
||||||
|
mDebug("already reset stream:0x%" PRIx64 ", not send reset-msg again for transId:%d", streamId, transId);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num >= 10) {
|
||||||
|
taosArrayRemove(execInfo.pKilledChkptTrans, 0); // remove this first, append new reset trans in the tail
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamTaskResetMsg p = {.streamId = streamId, .transId = transId};
|
||||||
|
|
||||||
|
void *px = taosArrayPush(execInfo.pKilledChkptTrans, &p);
|
||||||
|
if (px == NULL) {
|
||||||
|
mError("failed to push reset-msg trans:%d into the killed chkpt trans list, size:%d", transId, num - 1);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
SStreamTaskResetMsg *pReq = rpcMallocCont(size);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
pReq->streamId = streamId;
|
||||||
|
pReq->transId = transId;
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_TASK_RESET, .pCont = pReq, .contLen = size};
|
||||||
|
int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
if (code) {
|
||||||
|
mError("failed to put reset-task msg into write queue, code:%s", tstrerror(code));
|
||||||
|
} else {
|
||||||
|
mDebug("send reset task status msg for transId:%d succ", transId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndStreamSendUpdateChkptInfoMsg(SMnode *pMnode) { // here reuse the doCheckpointmsg
|
||||||
|
int32_t size = sizeof(SMStreamDoCheckpointMsg);
|
||||||
|
void *pMsg = rpcMallocCont(size);
|
||||||
|
if (pMsg == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_UPDATE_CHKPT_EVT, .pCont = pMsg, .contLen = size};
|
||||||
|
int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
if (code) {
|
||||||
|
mError("failed to put update-checkpoint-info msg into write queue, code:%s", tstrerror(code));
|
||||||
|
} else {
|
||||||
|
mDebug("send update checkpoint-info msg succ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndSendDropOrphanTasksMsg(SMnode *pMnode, SArray *pList) {
|
||||||
|
SMStreamDropOrphanMsg msg = {.pList = pList};
|
||||||
|
|
||||||
|
int32_t num = taosArrayGetSize(pList);
|
||||||
|
int32_t contLen = tSerializeDropOrphanTaskMsg(NULL, 0, &msg);
|
||||||
|
if (contLen <= 0) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pReq = rpcMallocCont(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)tSerializeDropOrphanTaskMsg(pReq, contLen, &msg);
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_DROP_ORPHANTASKS, .pCont = pReq, .contLen = contLen};
|
||||||
|
int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
|
if (code) {
|
||||||
|
mError("failed to put drop-orphan task msg into write queue, code:%s", tstrerror(code));
|
||||||
|
} else {
|
||||||
|
mDebug("send drop %d orphan tasks msg succ", num);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndProcessResetStatusReq(SRpcMsg *pReq) {
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
code = mndGetStreamObj(pMnode, streamId, &pStream);
|
|
||||||
|
SStreamTaskResetMsg* pMsg = pReq->pCont;
|
||||||
|
mndKillTransImpl(pMnode, pMsg->transId, "");
|
||||||
|
|
||||||
|
code = mndGetStreamObj(pMnode, pMsg->streamId, &pStream);
|
||||||
if (pStream == NULL || code != 0) {
|
if (pStream == NULL || code != 0) {
|
||||||
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
||||||
mError("failed to acquire the streamObj:0x%" PRIx64 " to reset checkpoint, may have been dropped", pStream->uid);
|
mError("failed to acquire the streamObj:0x%" PRIx64 " to reset checkpoint, may have been dropped", pStream->uid);
|
||||||
|
@ -123,7 +222,7 @@ int32_t mndResetStatusFromCheckpoint(SMnode *pMnode, int64_t streamId, int32_t t
|
||||||
pStream->sourceDb, pStream->targetSTbName);
|
pStream->sourceDb, pStream->targetSTbName);
|
||||||
} else {
|
} else {
|
||||||
mDebug("stream:%s (0x%" PRIx64 ") reset checkpoint procedure, transId:%d, create reset trans", pStream->name,
|
mDebug("stream:%s (0x%" PRIx64 ") reset checkpoint procedure, transId:%d, create reset trans", pStream->name,
|
||||||
pStream->uid, transId);
|
pStream->uid, pMsg->transId);
|
||||||
code = mndCreateStreamResetStatusTrans(pMnode, pStream);
|
code = mndCreateStreamResetStatusTrans(pMnode, pStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +237,10 @@ int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList) {
|
||||||
|
|
||||||
for (int k = 0; k < num; ++k) {
|
for (int k = 0; k < num; ++k) {
|
||||||
int32_t *pVgId = taosArrayGet(pNodeList, k);
|
int32_t *pVgId = taosArrayGet(pNodeList, k);
|
||||||
|
if (pVgId == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
mInfo("set node expired for nodeId:%d, total:%d", *pVgId, num);
|
mInfo("set node expired for nodeId:%d, total:%d", *pVgId, num);
|
||||||
|
|
||||||
bool setFlag = false;
|
bool setFlag = false;
|
||||||
|
@ -145,8 +248,7 @@ int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList) {
|
||||||
|
|
||||||
for (int i = 0; i < numOfNodes; ++i) {
|
for (int i = 0; i < numOfNodes; ++i) {
|
||||||
SNodeEntry *pNodeEntry = taosArrayGet(execInfo.pNodeList, i);
|
SNodeEntry *pNodeEntry = taosArrayGet(execInfo.pNodeList, i);
|
||||||
|
if ((pNodeEntry) && (pNodeEntry->nodeId == *pVgId)) {
|
||||||
if (pNodeEntry->nodeId == *pVgId) {
|
|
||||||
mInfo("vgId:%d expired for some stream tasks, needs update nodeEp", *pVgId);
|
mInfo("vgId:%d expired for some stream tasks, needs update nodeEp", *pVgId);
|
||||||
pNodeEntry->stageUpdated = true;
|
pNodeEntry->stageUpdated = true;
|
||||||
setFlag = true;
|
setFlag = true;
|
||||||
|
@ -162,51 +264,6 @@ int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndDropOrphanTasks(SMnode *pMnode, SArray *pList) {
|
|
||||||
SOrphanTask *pTask = taosArrayGet(pList, 0);
|
|
||||||
|
|
||||||
// check if it is conflict with other trans in both sourceDb and targetDb.
|
|
||||||
bool conflict = mndStreamTransConflictCheck(pMnode, pTask->streamId, MND_STREAM_DROP_NAME, false);
|
|
||||||
if (conflict) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SStreamObj dummyObj = {.uid = pTask->streamId, .sourceDb = "", .targetSTbName = ""};
|
|
||||||
STrans *pTrans = NULL;
|
|
||||||
int32_t code =
|
|
||||||
doCreateTrans(pMnode, &dummyObj, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream", &pTrans);
|
|
||||||
if (pTrans == NULL || code != 0) {
|
|
||||||
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pTask->streamId);
|
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
// drop all tasks
|
|
||||||
if ((code = mndStreamSetDropActionFromList(pMnode, pTrans, pList)) < 0) {
|
|
||||||
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
// drop stream
|
|
||||||
if ((code = mndPersistTransLog(&dummyObj, pTrans, SDB_STATUS_DROPPED)) < 0) {
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
|
||||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
mndTransDrop(pTrans);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo *info) {
|
int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo *info) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
@ -272,8 +329,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
if (tDecodeStreamHbMsg(&decoder, &req) < 0) {
|
if (tDecodeStreamHbMsg(&decoder, &req) < 0) {
|
||||||
tCleanupStreamHbMsg(&req);
|
tCleanupStreamHbMsg(&req);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
code = terrno = TSDB_CODE_INVALID_MSG;
|
TAOS_RETURN(TSDB_CODE_INVALID_MSG);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
|
@ -281,6 +337,11 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
pFailedChkpt = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
pFailedChkpt = taosArrayInit(4, sizeof(SFailedCheckpointInfo));
|
||||||
pOrphanTasks = taosArrayInit(4, sizeof(SOrphanTask));
|
pOrphanTasks = taosArrayInit(4, sizeof(SOrphanTask));
|
||||||
|
if (pFailedChkpt == NULL || pOrphanTasks == NULL) {
|
||||||
|
taosArrayDestroy(pFailedChkpt);
|
||||||
|
taosArrayDestroy(pOrphanTasks);
|
||||||
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
streamMutexLock(&execInfo.lock);
|
streamMutexLock(&execInfo.lock);
|
||||||
|
|
||||||
|
@ -288,12 +349,11 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
if (!validateHbMsg(execInfo.pNodeList, req.vgId)) {
|
if (!validateHbMsg(execInfo.pNodeList, req.vgId)) {
|
||||||
mError("vgId:%d not exists in nodeList buf, discarded", req.vgId);
|
mError("vgId:%d not exists in nodeList buf, discarded", req.vgId);
|
||||||
|
|
||||||
code = terrno = TSDB_CODE_INVALID_MSG;
|
|
||||||
doSendHbMsgRsp(terrno, &pReq->info, req.vgId, req.msgId);
|
doSendHbMsgRsp(terrno, &pReq->info, req.vgId, req.msgId);
|
||||||
|
|
||||||
streamMutexUnlock(&execInfo.lock);
|
streamMutexUnlock(&execInfo.lock);
|
||||||
cleanupAfterProcessHbMsg(&req, pFailedChkpt, pOrphanTasks);
|
cleanupAfterProcessHbMsg(&req, pFailedChkpt, pOrphanTasks);
|
||||||
return code;
|
TAOS_RETURN(TSDB_CODE_INVALID_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
||||||
|
@ -305,15 +365,18 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
bool snodeChanged = false;
|
bool snodeChanged = false;
|
||||||
for (int32_t i = 0; i < req.numOfTasks; ++i) {
|
for (int32_t i = 0; i < req.numOfTasks; ++i) {
|
||||||
STaskStatusEntry *p = taosArrayGet(req.pTaskStatus, i);
|
STaskStatusEntry *p = taosArrayGet(req.pTaskStatus, i);
|
||||||
|
if (p == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
STaskStatusEntry *pTaskEntry = taosHashGet(execInfo.pTaskMap, &p->id, sizeof(p->id));
|
STaskStatusEntry *pTaskEntry = taosHashGet(execInfo.pTaskMap, &p->id, sizeof(p->id));
|
||||||
if (pTaskEntry == NULL) {
|
if (pTaskEntry == NULL) {
|
||||||
mError("s-task:0x%" PRIx64 " not found in mnode task list", p->id.taskId);
|
mError("s-task:0x%" PRIx64 " not found in mnode task list, added into orphan task list", p->id.taskId);
|
||||||
|
|
||||||
SOrphanTask oTask = {.streamId = p->id.streamId, .taskId = p->id.taskId, .nodeId = p->nodeId};
|
SOrphanTask oTask = {.streamId = p->id.streamId, .taskId = p->id.taskId, .nodeId = p->nodeId};
|
||||||
void* px = taosArrayPush(pOrphanTasks, &oTask);
|
void* px = taosArrayPush(pOrphanTasks, &oTask);
|
||||||
if (px == NULL) {
|
if (px == NULL) {
|
||||||
mError("Failed to put task into list, taskId:0x%" PRIx64, p->id.taskId);
|
mError("failed to put task into list, taskId:0x%" PRIx64, p->id.taskId);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -330,13 +393,12 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
code = mndGetStreamObj(pMnode, p->id.streamId, &pStream);
|
code = mndGetStreamObj(pMnode, p->id.streamId, &pStream);
|
||||||
if (code) {
|
if (code) {
|
||||||
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTasks = mndGetNumOfStreamTasks(pStream);
|
int32_t numOfTasks = mndGetNumOfStreamTasks(pStream);
|
||||||
SCheckpointConsensusInfo *pInfo = NULL;
|
|
||||||
|
|
||||||
|
SCheckpointConsensusInfo *pInfo = NULL;
|
||||||
code = mndGetConsensusInfo(execInfo.pStreamConsensus, p->id.streamId, numOfTasks, &pInfo);
|
code = mndGetConsensusInfo(execInfo.pStreamConsensus, p->id.streamId, numOfTasks, &pInfo);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
mndAddConsensusTasks(pInfo, &cp);
|
mndAddConsensusTasks(pInfo, &cp);
|
||||||
|
@ -356,7 +418,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
streamTaskStatusCopy(pTaskEntry, p);
|
streamTaskStatusCopy(pTaskEntry, p);
|
||||||
|
|
||||||
if ((pChkInfo->activeId != 0) && pChkInfo->failed) {
|
if ((pChkInfo->activeId != 0) && pChkInfo->failed) {
|
||||||
mError("stream task:0x%" PRIx64 " checkpointId:%" PRIx64 " transId:%d failed, kill it", p->id.taskId,
|
mError("stream task:0x%" PRIx64 " checkpointId:%" PRId64 " transId:%d failed, kill it", p->id.taskId,
|
||||||
pChkInfo->activeId, pChkInfo->activeTransId);
|
pChkInfo->activeId, pChkInfo->activeTransId);
|
||||||
|
|
||||||
SFailedCheckpointInfo info = {
|
SFailedCheckpointInfo info = {
|
||||||
|
@ -371,13 +433,6 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->status == pTaskEntry->status) {
|
|
||||||
pTaskEntry->statusLastDuration++;
|
|
||||||
} else {
|
|
||||||
pTaskEntry->status = p->status;
|
|
||||||
pTaskEntry->statusLastDuration = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p->status != TASK_STATUS__READY) {
|
if (p->status != TASK_STATUS__READY) {
|
||||||
mDebug("received s-task:0x%" PRIx64 " not in ready status:%s", p->id.taskId, streamTaskGetStatusStr(p->status));
|
mDebug("received s-task:0x%" PRIx64 " not in ready status:%s", p->id.taskId, streamTaskGetStatusStr(p->status));
|
||||||
}
|
}
|
||||||
|
@ -390,7 +445,6 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
if (pMnode != NULL) {
|
if (pMnode != NULL) {
|
||||||
SArray *p = NULL;
|
SArray *p = NULL;
|
||||||
|
|
||||||
code = mndTakeVgroupSnapshot(pMnode, &allReady, &p);
|
code = mndTakeVgroupSnapshot(pMnode, &allReady, &p);
|
||||||
taosArrayDestroy(p);
|
taosArrayDestroy(p);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
@ -404,10 +458,14 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
// if the execInfo.activeCheckpoint == 0, the checkpoint is restoring from wal
|
// if the execInfo.activeCheckpoint == 0, the checkpoint is restoring from wal
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pFailedChkpt); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pFailedChkpt); ++i) {
|
||||||
SFailedCheckpointInfo *pInfo = taosArrayGet(pFailedChkpt, i);
|
SFailedCheckpointInfo *pInfo = taosArrayGet(pFailedChkpt, i);
|
||||||
|
if (pInfo == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
mInfo("checkpointId:%" PRId64 " transId:%d failed, issue task-reset trans to reset all tasks status",
|
mInfo("checkpointId:%" PRId64 " transId:%d failed, issue task-reset trans to reset all tasks status",
|
||||||
pInfo->checkpointId, pInfo->transId);
|
pInfo->checkpointId, pInfo->transId);
|
||||||
|
|
||||||
code = mndResetStatusFromCheckpoint(pMnode, pInfo->streamUid, pInfo->transId);
|
code = mndSendResetFromCheckpointMsg(pMnode, pInfo->streamUid, pInfo->transId);
|
||||||
if (code) {
|
if (code) {
|
||||||
mError("failed to create reset task trans, code:%s", tstrerror(code));
|
mError("failed to create reset task trans, code:%s", tstrerror(code));
|
||||||
}
|
}
|
||||||
|
@ -419,11 +477,14 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
// handle the orphan tasks that are invalid but not removed in some vnodes or snode due to some unknown errors.
|
// handle the orphan tasks that are invalid but not removed in some vnodes or snode due to some unknown errors.
|
||||||
if (taosArrayGetSize(pOrphanTasks) > 0) {
|
if (taosArrayGetSize(pOrphanTasks) > 0) {
|
||||||
code = mndDropOrphanTasks(pMnode, pOrphanTasks);
|
code = mndSendDropOrphanTasksMsg(pMnode, pOrphanTasks);
|
||||||
|
if (code) {
|
||||||
|
mError("failed to send drop orphan tasks msg, code:%s, try next time", tstrerror(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMnode != NULL) { // make sure that the unit test case can work
|
if (pMnode != NULL) { // make sure that the unit test case can work
|
||||||
mndStreamStartUpdateCheckpointInfo(pMnode);
|
mndStreamSendUpdateChkptInfoMsg(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMutexUnlock(&execInfo.lock);
|
streamMutexUnlock(&execInfo.lock);
|
||||||
|
@ -434,22 +495,10 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndStreamStartUpdateCheckpointInfo(SMnode *pMnode) { // here reuse the doCheckpointmsg
|
|
||||||
SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg));
|
|
||||||
if (pMsg != NULL) {
|
|
||||||
int32_t size = sizeof(SMStreamDoCheckpointMsg);
|
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_UPDATE_CHKPT_EVT, .pCont = pMsg, .contLen = size};
|
|
||||||
int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
|
||||||
if (code) {
|
|
||||||
mError("failed to put into write Queue, code:%s", tstrerror(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validateHbMsg(const SArray *pNodeList, int32_t vgId) {
|
bool validateHbMsg(const SArray *pNodeList, int32_t vgId) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pNodeList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pNodeList); ++i) {
|
||||||
SNodeEntry *pEntry = taosArrayGet(pNodeList, i);
|
SNodeEntry *pEntry = taosArrayGet(pNodeList, i);
|
||||||
if (pEntry->nodeId == vgId) {
|
if ((pEntry) && (pEntry->nodeId == vgId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
#include "mndStb.h"
|
||||||
|
#include "mndDb.h"
|
||||||
|
|
||||||
struct SStreamTaskIter {
|
struct SStreamTaskIter {
|
||||||
SStreamObj *pStream;
|
SStreamObj *pStream;
|
||||||
|
@ -31,7 +33,6 @@ int32_t doRemoveTasks(SStreamExecInfo *pExecNode, STaskId *pRemovedId);
|
||||||
int32_t createStreamTaskIter(SStreamObj* pStream, SStreamTaskIter** pIter) {
|
int32_t createStreamTaskIter(SStreamObj* pStream, SStreamTaskIter** pIter) {
|
||||||
*pIter = taosMemoryCalloc(1, sizeof(SStreamTaskIter));
|
*pIter = taosMemoryCalloc(1, sizeof(SStreamTaskIter));
|
||||||
if (*pIter == NULL) {
|
if (*pIter == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +129,6 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*allReady = true;
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||||
if (pIter == NULL) {
|
if (pIter == NULL) {
|
||||||
|
@ -548,6 +547,10 @@ static int32_t doSetDropActionFromId(SMnode *pMnode, STrans *pTrans, SOrphanTask
|
||||||
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray* pList) {
|
int32_t mndStreamSetDropActionFromList(SMnode *pMnode, STrans *pTrans, SArray* pList) {
|
||||||
for(int32_t i = 0; i < taosArrayGetSize(pList); ++i) {
|
for(int32_t i = 0; i < taosArrayGetSize(pList); ++i) {
|
||||||
SOrphanTask* pTask = taosArrayGet(pList, i);
|
SOrphanTask* pTask = taosArrayGet(pList, i);
|
||||||
|
if (pTask == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = doSetDropActionFromId(pMnode, pTrans, pTask);
|
int32_t code = doSetDropActionFromId(pMnode, pTrans, pTask);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -567,8 +570,8 @@ static void initNodeUpdateMsg(SStreamTaskNodeUpdateMsg *pMsg, const SVgroupChang
|
||||||
pMsg->transId = transId;
|
pMsg->transId = transId;
|
||||||
pMsg->pNodeList = taosArrayInit(taosArrayGetSize(pInfo->pUpdateNodeList), sizeof(SNodeUpdateInfo));
|
pMsg->pNodeList = taosArrayInit(taosArrayGetSize(pInfo->pUpdateNodeList), sizeof(SNodeUpdateInfo));
|
||||||
if (pMsg->pNodeList == NULL) {
|
if (pMsg->pNodeList == NULL) {
|
||||||
mError("failed to prepare node list, code:out of memory");
|
mError("failed to prepare node list, code:%s", tstrerror(terrno));
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -598,7 +601,6 @@ static int32_t doBuildStreamTaskUpdateMsg(void **pBuf, int32_t *pLen, SVgroupCha
|
||||||
|
|
||||||
void *buf = taosMemoryMalloc(tlen);
|
void *buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
taosArrayDestroy(req.pNodeList);
|
taosArrayDestroy(req.pNodeList);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -692,9 +694,8 @@ int32_t mndStreamSetUpdateEpsetAction(SMnode *pMnode, SStreamObj *pStream, SVgro
|
||||||
static int32_t doSetResetAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask) {
|
static int32_t doSetResetAction(SMnode *pMnode, STrans *pTrans, SStreamTask *pTask) {
|
||||||
SVResetStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVResetStreamTaskReq));
|
SVResetStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVResetStreamTaskReq));
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
mError("failed to malloc in reset stream, size:%" PRIzu ", code:%s", sizeof(SVResetStreamTaskReq),
|
mError("failed to malloc in reset stream, size:%" PRIzu ", code:%s", sizeof(SVResetStreamTaskReq),
|
||||||
tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
tstrerror(terrno));
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,6 +772,14 @@ int32_t mndInitExecInfo() {
|
||||||
execInfo.pChkptStreams = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
execInfo.pChkptStreams = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
execInfo.pStreamConsensus = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
execInfo.pStreamConsensus = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
execInfo.pNodeList = taosArrayInit(4, sizeof(SNodeEntry));
|
execInfo.pNodeList = taosArrayInit(4, sizeof(SNodeEntry));
|
||||||
|
execInfo.pKilledChkptTrans = taosArrayInit(4, sizeof(SStreamTaskResetMsg));
|
||||||
|
|
||||||
|
if (execInfo.pTaskList == NULL || execInfo.pTaskMap == NULL || execInfo.transMgmt.pDBTrans == NULL ||
|
||||||
|
execInfo.pTransferStateStreams == NULL || execInfo.pChkptStreams == NULL || execInfo.pStreamConsensus == NULL ||
|
||||||
|
execInfo.pNodeList == NULL || execInfo.pKilledChkptTrans == NULL) {
|
||||||
|
mError("failed to initialize the stream runtime env, code:%s", tstrerror(terrno));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
taosHashSetFreeFp(execInfo.pTransferStateStreams, freeTaskList);
|
||||||
taosHashSetFreeFp(execInfo.pChkptStreams, freeTaskList);
|
taosHashSetFreeFp(execInfo.pChkptStreams, freeTaskList);
|
||||||
|
@ -780,14 +789,25 @@ int32_t mndInitExecInfo() {
|
||||||
|
|
||||||
void removeExpiredNodeInfo(const SArray *pNodeSnapshot) {
|
void removeExpiredNodeInfo(const SArray *pNodeSnapshot) {
|
||||||
SArray *pValidList = taosArrayInit(4, sizeof(SNodeEntry));
|
SArray *pValidList = taosArrayInit(4, sizeof(SNodeEntry));
|
||||||
|
if (pValidList == NULL) { // not continue
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t size = taosArrayGetSize(pNodeSnapshot);
|
int32_t size = taosArrayGetSize(pNodeSnapshot);
|
||||||
int32_t oldSize = taosArrayGetSize(execInfo.pNodeList);
|
int32_t oldSize = taosArrayGetSize(execInfo.pNodeList);
|
||||||
|
|
||||||
for (int32_t i = 0; i < oldSize; ++i) {
|
for (int32_t i = 0; i < oldSize; ++i) {
|
||||||
SNodeEntry *p = taosArrayGet(execInfo.pNodeList, i);
|
SNodeEntry *p = taosArrayGet(execInfo.pNodeList, i);
|
||||||
|
if (p == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < size; ++j) {
|
for (int32_t j = 0; j < size; ++j) {
|
||||||
SNodeEntry *pEntry = taosArrayGet(pNodeSnapshot, j);
|
SNodeEntry *pEntry = taosArrayGet(pNodeSnapshot, j);
|
||||||
|
if (pEntry == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pEntry->nodeId == p->nodeId) {
|
if (pEntry->nodeId == p->nodeId) {
|
||||||
void* px = taosArrayPush(pValidList, p);
|
void* px = taosArrayPush(pValidList, p);
|
||||||
if (px == NULL) {
|
if (px == NULL) {
|
||||||
|
@ -818,6 +838,10 @@ int32_t doRemoveTasks(SStreamExecInfo *pExecNode, STaskId *pRemovedId) {
|
||||||
|
|
||||||
for (int32_t k = 0; k < taosArrayGetSize(pExecNode->pTaskList); ++k) {
|
for (int32_t k = 0; k < taosArrayGetSize(pExecNode->pTaskList); ++k) {
|
||||||
STaskId *pId = taosArrayGet(pExecNode->pTaskList, k);
|
STaskId *pId = taosArrayGet(pExecNode->pTaskList, k);
|
||||||
|
if (pId == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pId->taskId == pRemovedId->taskId && pId->streamId == pRemovedId->streamId) {
|
if (pId->taskId == pRemovedId->taskId && pId->streamId == pRemovedId->streamId) {
|
||||||
taosArrayRemove(pExecNode->pTaskList, k);
|
taosArrayRemove(pExecNode->pTaskList, k);
|
||||||
|
|
||||||
|
@ -833,6 +857,10 @@ int32_t doRemoveTasks(SStreamExecInfo *pExecNode, STaskId *pRemovedId) {
|
||||||
void removeTasksInBuf(SArray *pTaskIds, SStreamExecInfo* pExecInfo) {
|
void removeTasksInBuf(SArray *pTaskIds, SStreamExecInfo* pExecInfo) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTaskIds); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pTaskIds); ++i) {
|
||||||
STaskId *pId = taosArrayGet(pTaskIds, i);
|
STaskId *pId = taosArrayGet(pTaskIds, i);
|
||||||
|
if (pId == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = doRemoveTasks(pExecInfo, pId);
|
int32_t code = doRemoveTasks(pExecInfo, pId);
|
||||||
if (code) {
|
if (code) {
|
||||||
mError("failed to remove task in buffer list, 0x%"PRIx64, pId->taskId);
|
mError("failed to remove task in buffer list, 0x%"PRIx64, pId->taskId);
|
||||||
|
@ -880,6 +908,10 @@ static bool taskNodeExists(SArray *pList, int32_t nodeId) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SNodeEntry *pEntry = taosArrayGet(pList, i);
|
SNodeEntry *pEntry = taosArrayGet(pList, i);
|
||||||
|
if (pEntry == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pEntry->nodeId == nodeId) {
|
if (pEntry->nodeId == nodeId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -890,12 +922,22 @@ static bool taskNodeExists(SArray *pList, int32_t nodeId) {
|
||||||
|
|
||||||
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot) {
|
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot) {
|
||||||
SArray *pRemovedTasks = taosArrayInit(4, sizeof(STaskId));
|
SArray *pRemovedTasks = taosArrayInit(4, sizeof(STaskId));
|
||||||
|
if (pRemovedTasks == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t numOfTask = taosArrayGetSize(execInfo.pTaskList);
|
int32_t numOfTask = taosArrayGetSize(execInfo.pTaskList);
|
||||||
for (int32_t i = 0; i < numOfTask; ++i) {
|
for (int32_t i = 0; i < numOfTask; ++i) {
|
||||||
STaskId *pId = taosArrayGet(execInfo.pTaskList, i);
|
STaskId *pId = taosArrayGet(execInfo.pTaskList, i);
|
||||||
|
if (pId == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, pId, sizeof(*pId));
|
STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, pId, sizeof(*pId));
|
||||||
|
if (pEntry == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pEntry->nodeId == SNODE_HANDLE) {
|
if (pEntry->nodeId == SNODE_HANDLE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -939,6 +981,10 @@ static int32_t doSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamTas
|
||||||
int32_t size = taosArrayGetSize(*pReqTaskList);
|
int32_t size = taosArrayGetSize(*pReqTaskList);
|
||||||
for(int32_t i = 0; i < size; ++i) {
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
STaskChkptInfo* pInfo = taosArrayGet(*pReqTaskList, i);
|
STaskChkptInfo* pInfo = taosArrayGet(*pReqTaskList, i);
|
||||||
|
if (pInfo == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pInfo->taskId == pTask->id.taskId) {
|
if (pInfo->taskId == pTask->id.taskId) {
|
||||||
pReq->checkpointId = pInfo->checkpointId;
|
pReq->checkpointId = pInfo->checkpointId;
|
||||||
pReq->checkpointVer = pInfo->version;
|
pReq->checkpointVer = pInfo->version;
|
||||||
|
@ -1002,8 +1048,11 @@ int32_t mndStreamSetUpdateChkptAction(SMnode *pMnode, STrans *pTrans, SStreamObj
|
||||||
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SArray *pDropped = taosArrayInit(4, sizeof(int64_t));
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SArray *pDropped = taosArrayInit(4, sizeof(int64_t));
|
||||||
|
if (pDropped == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("start to scan checkpoint report info");
|
mDebug("start to scan checkpoint report info");
|
||||||
|
|
||||||
|
@ -1011,6 +1060,10 @@ int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
||||||
SArray *pList = *(SArray **)pIter;
|
SArray *pList = *(SArray **)pIter;
|
||||||
|
|
||||||
STaskChkptInfo *pInfo = taosArrayGet(pList, 0);
|
STaskChkptInfo *pInfo = taosArrayGet(pList, 0);
|
||||||
|
if (pInfo == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
code = mndGetStreamObj(pMnode, pInfo->streamId, &pStream);
|
code = mndGetStreamObj(pMnode, pInfo->streamId, &pStream);
|
||||||
if (pStream == NULL || code != 0) {
|
if (pStream == NULL || code != 0) {
|
||||||
|
@ -1059,10 +1112,14 @@ int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
||||||
int32_t size = taosArrayGetSize(pDropped);
|
int32_t size = taosArrayGetSize(pDropped);
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
int64_t streamId = *(int64_t *)taosArrayGet(pDropped, i);
|
int64_t* pStreamId = (int64_t *)taosArrayGet(pDropped, i);
|
||||||
code = taosHashRemove(execInfo.pChkptStreams, &streamId, sizeof(streamId));
|
if (pStreamId == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taosHashRemove(execInfo.pChkptStreams, pStreamId, sizeof(*pStreamId));
|
||||||
if (code) {
|
if (code) {
|
||||||
mError("failed to remove stream in buf:0x%"PRIx64, streamId);
|
mError("failed to remove stream in buf:0x%"PRIx64, *pStreamId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1088,14 +1145,14 @@ static int32_t mndStreamSetChkptIdAction(SMnode *pMnode, STrans *pTrans, SStream
|
||||||
int32_t blen;
|
int32_t blen;
|
||||||
tEncodeSize(tEncodeRestoreCheckpointInfo, &req, blen, code);
|
tEncodeSize(tEncodeRestoreCheckpointInfo, &req, blen, code);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return terrno = TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tlen = sizeof(SMsgHead) + blen;
|
int32_t tlen = sizeof(SMsgHead) + blen;
|
||||||
|
|
||||||
void *pBuf = taosMemoryMalloc(tlen);
|
void *pBuf = taosMemoryMalloc(tlen);
|
||||||
if (pBuf == NULL) {
|
if (pBuf == NULL) {
|
||||||
return terrno = TSDB_CODE_OUT_OF_MEMORY;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *abuf = POINTER_SHIFT(pBuf, sizeof(SMsgHead));
|
void *abuf = POINTER_SHIFT(pBuf, sizeof(SMsgHead));
|
||||||
|
@ -1169,7 +1226,7 @@ int32_t mndCreateSetConsensusChkptIdTrans(SMnode *pMnode, SStreamObj *pStream, i
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndTransPrepare(pMnode, pTrans);
|
code = mndTransPrepare(pMnode, pTrans);
|
||||||
if (code) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("trans:%d, failed to prepare set consensus-chkptId trans since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare set consensus-chkptId trans since %s", pTrans->id, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
@ -1197,6 +1254,10 @@ int32_t mndGetConsensusInfo(SHashObj* pHash, int64_t streamId, int32_t numOfTask
|
||||||
.streamId = streamId,
|
.streamId = streamId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (p.pTaskList == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = taosHashPut(pHash, &streamId, sizeof(streamId), &p, sizeof(p));
|
int32_t code = taosHashPut(pHash, &streamId, sizeof(streamId), &p, sizeof(p));
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
void *pChkptInfo = (SCheckpointConsensusInfo *)taosHashGet(pHash, &streamId, sizeof(streamId));
|
void *pChkptInfo = (SCheckpointConsensusInfo *)taosHashGet(pHash, &streamId, sizeof(streamId));
|
||||||
|
@ -1204,6 +1265,7 @@ int32_t mndGetConsensusInfo(SHashObj* pHash, int64_t streamId, int32_t numOfTask
|
||||||
} else {
|
} else {
|
||||||
*pInfo = NULL;
|
*pInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1215,6 +1277,10 @@ void mndAddConsensusTasks(SCheckpointConsensusInfo *pInfo, const SRestoreCheckpo
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pTaskList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pTaskList); ++i) {
|
||||||
SCheckpointConsensusEntry *p = taosArrayGet(pInfo->pTaskList, i);
|
SCheckpointConsensusEntry *p = taosArrayGet(pInfo->pTaskList, i);
|
||||||
|
if (p == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (p->req.taskId == info.req.taskId) {
|
if (p->req.taskId == info.req.taskId) {
|
||||||
mDebug("s-task:0x%x already in consensus-checkpointId list for stream:0x%" PRIx64 ", update ts %" PRId64
|
mDebug("s-task:0x%x already in consensus-checkpointId list for stream:0x%" PRIx64 ", update ts %" PRId64
|
||||||
"->%" PRId64 " total existed:%d",
|
"->%" PRId64 " total existed:%d",
|
||||||
|
@ -1257,3 +1323,489 @@ int64_t mndClearConsensusCheckpointId(SHashObj* pHash, int64_t streamId) {
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mndShowStreamStatus(char *dst, SStreamObj *pStream) {
|
||||||
|
int8_t status = atomic_load_8(&pStream->status);
|
||||||
|
if (status == STREAM_STATUS__NORMAL) {
|
||||||
|
strcpy(dst, "ready");
|
||||||
|
} else if (status == STREAM_STATUS__STOP) {
|
||||||
|
strcpy(dst, "stop");
|
||||||
|
} else if (status == STREAM_STATUS__FAILED) {
|
||||||
|
strcpy(dst, "failed");
|
||||||
|
} else if (status == STREAM_STATUS__RECOVER) {
|
||||||
|
strcpy(dst, "recover");
|
||||||
|
} else if (status == STREAM_STATUS__PAUSE) {
|
||||||
|
strcpy(dst, "paused");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mndShowStreamTrigger(char *dst, SStreamObj *pStream) {
|
||||||
|
int8_t trigger = pStream->conf.trigger;
|
||||||
|
if (trigger == STREAM_TRIGGER_AT_ONCE) {
|
||||||
|
strcpy(dst, "at once");
|
||||||
|
} else if (trigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||||
|
strcpy(dst, "window close");
|
||||||
|
} else if (trigger == STREAM_TRIGGER_MAX_DELAY) {
|
||||||
|
strcpy(dst, "max delay");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void int64ToHexStr(int64_t id, char *pBuf, int32_t bufLen) {
|
||||||
|
memset(pBuf, 0, bufLen);
|
||||||
|
pBuf[2] = '0';
|
||||||
|
pBuf[3] = 'x';
|
||||||
|
|
||||||
|
int32_t len = tintToHex(id, &pBuf[4]);
|
||||||
|
varDataSetLen(pBuf, len + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_t numOfRows) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t cols = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
char streamName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(streamName, mndGetDbStr(pStream->name), sizeof(streamName));
|
||||||
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)streamName, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// create time
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pStream->createTime, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// stream id
|
||||||
|
char buf[128] = {0};
|
||||||
|
int64ToHexStr(pStream->uid, buf, tListLen(buf));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// related fill-history stream id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
if (pStream->hTaskUid != 0) {
|
||||||
|
int64ToHexStr(pStream->hTaskUid, buf, tListLen(buf));
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
} else {
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, buf, true);
|
||||||
|
}
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// related fill-history stream id
|
||||||
|
char sql[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(sql, pStream->sql, sizeof(sql));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)sql, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
char status2[20] = {0};
|
||||||
|
mndShowStreamStatus(status2, pStream);
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(status, status2, sizeof(status));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&status, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
char sourceDB[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(sourceDB, mndGetDbStr(pStream->sourceDb), sizeof(sourceDB));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&sourceDB, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
char targetDB[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(targetDB, mndGetDbStr(pStream->targetDb), sizeof(targetDB));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&targetDB, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
if (pStream->targetSTbName[0] == 0) {
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, NULL, true);
|
||||||
|
} else {
|
||||||
|
char targetSTB[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(targetSTB, mndGetStbStr(pStream->targetSTbName), sizeof(targetSTB));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&targetSTB, false);
|
||||||
|
}
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pStream->conf.watermark, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
char trigger[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
char trigger2[20] = {0};
|
||||||
|
mndShowStreamTrigger(trigger2, pStream);
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(trigger, trigger2, sizeof(trigger));
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&trigger, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// sink_quota
|
||||||
|
char sinkQuota[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
sinkQuota[0] = '0';
|
||||||
|
char dstStr[20] = {0};
|
||||||
|
STR_TO_VARSTR(dstStr, sinkQuota)
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)dstStr, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint interval
|
||||||
|
char tmp[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
sprintf(varDataVal(tmp), "%d sec", tsStreamCheckpointInterval);
|
||||||
|
varDataSetLen(tmp, strlen(varDataVal(tmp)));
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)tmp, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint backup type
|
||||||
|
char backup[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_TO_VARSTR(backup, "none")
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)backup, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// history scan idle
|
||||||
|
char scanHistoryIdle[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
strcpy(scanHistoryIdle, "100a");
|
||||||
|
|
||||||
|
memset(dstStr, 0, tListLen(dstStr));
|
||||||
|
STR_TO_VARSTR(dstStr, scanHistoryIdle)
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)dstStr, false);
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code) {
|
||||||
|
mError("error happens when build stream attr result block, lino:%d, code:%s", lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SSDataBlock *pBlock, int32_t numOfRows) {
|
||||||
|
SColumnInfoData *pColInfo = NULL;
|
||||||
|
int32_t cols = 0;
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId};
|
||||||
|
|
||||||
|
STaskStatusEntry *pe = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
||||||
|
if (pe == NULL) {
|
||||||
|
mError("task:0x%" PRIx64 " not exists in any vnodes, streamName:%s, streamId:0x%" PRIx64 " createTs:%" PRId64
|
||||||
|
" no valid status/stage info",
|
||||||
|
id.taskId, pStream->name, pStream->uid, pStream->createTime);
|
||||||
|
return TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stream name
|
||||||
|
char streamName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(streamName, mndGetDbStr(pStream->name), sizeof(streamName));
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)streamName, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// task id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
char idstr[128] = {0};
|
||||||
|
int64ToHexStr(pTask->id.taskId, idstr, tListLen(idstr));
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// node type
|
||||||
|
char nodeType[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
varDataSetLen(nodeType, 5);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
if (pTask->info.nodeId > 0) {
|
||||||
|
memcpy(varDataVal(nodeType), "vnode", 5);
|
||||||
|
} else {
|
||||||
|
memcpy(varDataVal(nodeType), "snode", 5);
|
||||||
|
}
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, nodeType, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// node id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
int64_t nodeId = TMAX(pTask->info.nodeId, 0);
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&nodeId, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// level
|
||||||
|
char level[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
|
memcpy(varDataVal(level), "source", 6);
|
||||||
|
varDataSetLen(level, 6);
|
||||||
|
} else if (pTask->info.taskLevel == TASK_LEVEL__AGG) {
|
||||||
|
memcpy(varDataVal(level), "agg", 3);
|
||||||
|
varDataSetLen(level, 3);
|
||||||
|
} else if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
||||||
|
memcpy(varDataVal(level), "sink", 4);
|
||||||
|
varDataSetLen(level, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)level, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// status
|
||||||
|
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
||||||
|
const char *pStatus = streamTaskGetStatusStr(pe->status);
|
||||||
|
STR_TO_VARSTR(status, pStatus);
|
||||||
|
|
||||||
|
// status
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)status, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// stage
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->stage, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// input queue
|
||||||
|
char vbuf[40] = {0};
|
||||||
|
char buf[38] = {0};
|
||||||
|
const char *queueInfoStr = "%4.2f MiB (%6.2f%)";
|
||||||
|
snprintf(buf, tListLen(buf), queueInfoStr, pe->inputQUsed, pe->inputRate);
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// input total
|
||||||
|
const char *formatTotalMb = "%7.2f MiB";
|
||||||
|
const char *formatTotalGb = "%7.2f GiB";
|
||||||
|
if (pe->procsTotal < 1024) {
|
||||||
|
snprintf(buf, tListLen(buf), formatTotalMb, pe->procsTotal);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, tListLen(buf), formatTotalGb, pe->procsTotal / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(vbuf, 0, tListLen(vbuf));
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// process throughput
|
||||||
|
const char *formatKb = "%7.2f KiB/s";
|
||||||
|
const char *formatMb = "%7.2f MiB/s";
|
||||||
|
if (pe->procsThroughput < 1024) {
|
||||||
|
snprintf(buf, tListLen(buf), formatKb, pe->procsThroughput);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, tListLen(buf), formatMb, pe->procsThroughput / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(vbuf, 0, tListLen(vbuf));
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// output total
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
||||||
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
|
} else {
|
||||||
|
sprintf(buf, formatTotalMb, pe->outputTotal);
|
||||||
|
memset(vbuf, 0, tListLen(vbuf));
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// output throughput
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
||||||
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
|
} else {
|
||||||
|
if (pe->outputThroughput < 1024) {
|
||||||
|
snprintf(buf, tListLen(buf), formatKb, pe->outputThroughput);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, tListLen(buf), formatMb, pe->outputThroughput / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(vbuf, 0, tListLen(vbuf));
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// output queue
|
||||||
|
// sprintf(buf, queueInfoStr, pe->outputQUsed, pe->outputRate);
|
||||||
|
// STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
// colDataSetVal(pColInfo, numOfRows, (const char*)vbuf, false);
|
||||||
|
|
||||||
|
// info
|
||||||
|
if (pTask->info.taskLevel == TASK_LEVEL__SINK) {
|
||||||
|
const char *sinkStr = "%.2f MiB";
|
||||||
|
snprintf(buf, tListLen(buf), sinkStr, pe->sinkDataSize);
|
||||||
|
} else if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||||
|
// offset info
|
||||||
|
const char *offsetStr = "%" PRId64 " [%" PRId64 ", %" PRId64 "]";
|
||||||
|
snprintf(buf, tListLen(buf), offsetStr, pe->processedVer, pe->verRange.minVer, pe->verRange.maxVer);
|
||||||
|
} else {
|
||||||
|
memset(buf, 0, tListLen(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
STR_TO_VARSTR(vbuf, buf);
|
||||||
|
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)vbuf, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// start_time
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startTime, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// start id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startCheckpointId, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// start ver
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->startCheckpointVer, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint time
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
if (pe->checkpointInfo.latestTime != 0) {
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestTime, false);
|
||||||
|
} else {
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
}
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint_id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestId, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint version
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pe->checkpointInfo.latestVer, false);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// checkpoint size
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
colDataSetNULL(pColInfo, numOfRows);
|
||||||
|
|
||||||
|
// checkpoint backup status
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// ds_err_info
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// history_task_id
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
if (pe->hTaskId != 0) {
|
||||||
|
int64ToHexStr(pe->hTaskId, idstr, tListLen(idstr));
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||||
|
} else {
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
}
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
// history_task_status
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||||
|
|
||||||
|
code = colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code) {
|
||||||
|
mError("error happens during build task attr result blocks, lino:%d, code:%s", lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
|
@ -50,10 +50,10 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa
|
||||||
}
|
}
|
||||||
|
|
||||||
STablePair pair1 = {.tbl = pTq->pStreamMeta->pTaskDb, .type = SNAP_DATA_STREAM_TASK};
|
STablePair pair1 = {.tbl = pTq->pStreamMeta->pTaskDb, .type = SNAP_DATA_STREAM_TASK};
|
||||||
taosArrayPush(pReader->tdbTbList, &pair1);
|
(void)taosArrayPush(pReader->tdbTbList, &pair1);
|
||||||
|
|
||||||
STablePair pair2 = {.tbl = pTq->pStreamMeta->pCheckpointDb, .type = SNAP_DATA_STREAM_TASK_CHECKPOINT};
|
STablePair pair2 = {.tbl = pTq->pStreamMeta->pCheckpointDb, .type = SNAP_DATA_STREAM_TASK_CHECKPOINT};
|
||||||
taosArrayPush(pReader->tdbTbList, &pair2);
|
(void)taosArrayPush(pReader->tdbTbList, &pair2);
|
||||||
|
|
||||||
pReader->pos = 0;
|
pReader->pos = 0;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tqError("vgId:%d, vnode stream-task snapshot reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
tqError("vgId:%d, vnode stream-task snapshot reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||||
streamTaskSnapReaderClose(pReader);
|
(void)streamTaskSnapReaderClose(pReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", TD_VID(pReader->pTq->pVnode));
|
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", TD_VID(pReader->pTq->pVnode));
|
||||||
taosArrayDestroy(pReader->tdbTbList);
|
taosArrayDestroy(pReader->tdbTbList);
|
||||||
tdbTbcClose(pReader->pCur);
|
(void)tdbTbcClose(pReader->pCur);
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -126,17 +126,17 @@ NextTbl:
|
||||||
memcpy(pVal, tVal, tLen);
|
memcpy(pVal, tVal, tLen);
|
||||||
vLen = tLen;
|
vLen = tLen;
|
||||||
}
|
}
|
||||||
tdbTbcMoveToNext(pReader->pCur);
|
(void)tdbTbcMoveToNext(pReader->pCur);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (except == 1) {
|
if (except == 1) {
|
||||||
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
||||||
tdbTbcClose(pReader->pCur);
|
(void)tdbTbcClose(pReader->pCur);
|
||||||
|
|
||||||
pReader->pos += 1;
|
pReader->pos += 1;
|
||||||
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
||||||
code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL);
|
code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL);
|
||||||
tdbTbcMoveToFirst(pReader->pCur);
|
(void)tdbTbcMoveToFirst(pReader->pCur);
|
||||||
|
|
||||||
goto NextTbl;
|
goto NextTbl;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) {
|
||||||
streamMetaWLock(pTq->pStreamMeta);
|
streamMetaWLock(pTq->pStreamMeta);
|
||||||
tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode));
|
tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode));
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
(void)tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
|
@ -256,8 +256,10 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
|
if (pFile) {
|
||||||
vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code));
|
vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
taosMemoryFree(pData);
|
taosMemoryFree(pData);
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -45,11 +45,11 @@ static FORCE_INLINE void auditDeleteRecord(SAuditRecord * record) {
|
||||||
|
|
||||||
void auditCleanup() {
|
void auditCleanup() {
|
||||||
tsLogFp = NULL;
|
tsLogFp = NULL;
|
||||||
taosThreadMutexLock(&tsAudit.lock);
|
(void)taosThreadMutexLock(&tsAudit.lock);
|
||||||
taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord);
|
taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord);
|
||||||
taosThreadMutexUnlock(&tsAudit.lock);
|
(void)taosThreadMutexUnlock(&tsAudit.lock);
|
||||||
tsAudit.records = NULL;
|
tsAudit.records = NULL;
|
||||||
taosThreadMutexDestroy(&tsAudit.lock);
|
(void)taosThreadMutexDestroy(&tsAudit.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
extern void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||||
|
|
|
@ -1437,7 +1437,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
(void) tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset);
|
tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2369,11 +2369,12 @@ static FORCE_INLINE int optSysBinarySearch(SArray* arr, int s, int e, uint64_t k
|
||||||
int32_t optSysIntersection(SArray* in, SArray* out) {
|
int32_t optSysIntersection(SArray* in, SArray* out) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
MergeIndex* mi = NULL;
|
||||||
int32_t sz = (int32_t)taosArrayGetSize(in);
|
int32_t sz = (int32_t)taosArrayGetSize(in);
|
||||||
if (sz <= 0) {
|
if (sz <= 0) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
MergeIndex* mi = taosMemoryCalloc(sz, sizeof(MergeIndex));
|
mi = taosMemoryCalloc(sz, sizeof(MergeIndex));
|
||||||
QUERY_CHECK_NULL(mi, code, lino, _end, terrno);
|
QUERY_CHECK_NULL(mi, code, lino, _end, terrno);
|
||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
SArray* t = taosArrayGetP(in, i);
|
SArray* t = taosArrayGetP(in, i);
|
||||||
|
|
|
@ -101,7 +101,10 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pBucket->pPageIdList, &newPageId);
|
void* px = taosArrayPush(pBucket->pPageIdList, &newPageId);
|
||||||
|
if (px == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
doCopyObject(pNewPage->data, key, keyLen, data, size);
|
doCopyObject(pNewPage->data, key, keyLen, data, size);
|
||||||
pNewPage->num = sizeof(SFilePage) + nodeSize;
|
pNewPage->num = sizeof(SFilePage) + nodeSize;
|
||||||
|
@ -127,7 +130,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
|
||||||
char* p = (char*)pNode + len;
|
char* p = (char*)pNode + len;
|
||||||
|
|
||||||
char* pEnd = (char*)pPage + pPage->num;
|
char* pEnd = (char*)pPage + pPage->num;
|
||||||
memmove(pNode, p, (pEnd - p));
|
(void) memmove(pNode, p, (pEnd - p));
|
||||||
|
|
||||||
pPage->num -= len;
|
pPage->num -= len;
|
||||||
if (pPage->num == 0) {
|
if (pPage->num == 0) {
|
||||||
|
@ -189,7 +192,7 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
|
||||||
nodeSize = GET_LHASH_NODE_LEN(pStart);
|
nodeSize = GET_LHASH_NODE_LEN(pStart);
|
||||||
} else { // move to the front of pLast page
|
} else { // move to the front of pLast page
|
||||||
if (pStart != pLast->data) {
|
if (pStart != pLast->data) {
|
||||||
memmove(pLast->data, pStart, (((char*)pLast) + pLast->num - pStart));
|
(void) memmove(pLast->data, pStart, (((char*)pLast) + pLast->num - pStart));
|
||||||
setBufPageDirty(pLast, true);
|
setBufPageDirty(pLast, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +238,10 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
|
||||||
setBufPageDirty(p, true);
|
setBufPageDirty(p, true);
|
||||||
|
|
||||||
releaseBufPage(pHashObj->pBuf, p);
|
releaseBufPage(pHashObj->pBuf, p);
|
||||||
taosArrayPush(pBucket->pPageIdList, &pageId);
|
void* px = taosArrayPush(pBucket->pPageIdList, &pageId);
|
||||||
|
if (px == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
pHashObj->numOfBuckets += 1;
|
pHashObj->numOfBuckets += 1;
|
||||||
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
|
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
|
||||||
|
@ -251,7 +257,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
|
||||||
|
|
||||||
if (!osTempSpaceAvailable()) {
|
if (!osTempSpaceAvailable()) {
|
||||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||||
printf("tHash Init failed since %s, tempDir:%s", terrstr(), tsTempDir);
|
(void) printf("tHash Init failed since %s, tempDir:%s", terrstr(), tsTempDir);
|
||||||
taosMemoryFree(pHashObj);
|
taosMemoryFree(pHashObj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -301,9 +307,10 @@ void* tHashCleanup(SLHashObj* pHashObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size) {
|
int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size) {
|
||||||
|
int32_t code = 0;
|
||||||
if (pHashObj->bits == 0) {
|
if (pHashObj->bits == 0) {
|
||||||
SLHashBucket* pBucket = pHashObj->pBucket[0];
|
SLHashBucket* pBucket = pHashObj->pBucket[0];
|
||||||
doAddToBucket(pHashObj, pBucket, 0, key, keyLen, data, size);
|
code = doAddToBucket(pHashObj, pBucket, 0, key, keyLen, data, size);
|
||||||
} else {
|
} else {
|
||||||
int32_t hashVal = pHashObj->hashFn(key, keyLen);
|
int32_t hashVal = pHashObj->hashFn(key, keyLen);
|
||||||
int32_t v = doGetBucketIdFromHashVal(hashVal, pHashObj->bits);
|
int32_t v = doGetBucketIdFromHashVal(hashVal, pHashObj->bits);
|
||||||
|
@ -315,10 +322,11 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
|
||||||
}
|
}
|
||||||
|
|
||||||
SLHashBucket* pBucket = pHashObj->pBucket[v];
|
SLHashBucket* pBucket = pHashObj->pBucket[v];
|
||||||
int32_t code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size);
|
code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pHashObj->size += 1;
|
pHashObj->size += 1;
|
||||||
|
@ -327,7 +335,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
|
||||||
if ((pHashObj->numOfBuckets * LHASH_CAP_RATIO * pHashObj->tuplesPerPage) < pHashObj->size) {
|
if ((pHashObj->numOfBuckets * LHASH_CAP_RATIO * pHashObj->tuplesPerPage) < pHashObj->size) {
|
||||||
int32_t newBucketId = pHashObj->numOfBuckets;
|
int32_t newBucketId = pHashObj->numOfBuckets;
|
||||||
|
|
||||||
int32_t code = doAddNewBucket(pHashObj);
|
code = doAddNewBucket(pHashObj);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +370,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
|
||||||
ASSERT(v1 == newBucketId);
|
ASSERT(v1 == newBucketId);
|
||||||
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
|
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
|
||||||
SLHashBucket* pNewBucket = pHashObj->pBucket[newBucketId];
|
SLHashBucket* pNewBucket = pHashObj->pBucket[newBucketId];
|
||||||
doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen,
|
code = doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen,
|
||||||
GET_LHASH_NODE_KEY(pNode), pNode->dataLen);
|
GET_LHASH_NODE_KEY(pNode), pNode->dataLen);
|
||||||
doRemoveFromBucket(p, pNode, pBucket);
|
doRemoveFromBucket(p, pNode, pBucket);
|
||||||
} else {
|
} else {
|
||||||
|
@ -377,7 +385,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
|
||||||
doTrimBucketPages(pHashObj, pBucket);
|
doTrimBucketPages(pHashObj, pBucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen) {
|
char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen) {
|
||||||
|
@ -420,8 +428,8 @@ int32_t tHashRemove(SLHashObj* pHashObj, const void* key, size_t keyLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
|
void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
|
||||||
printf("==================== linear hash ====================\n");
|
(void) printf("==================== linear hash ====================\n");
|
||||||
printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
|
(void) printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
|
||||||
|
|
||||||
dBufSetPrintInfo(pHashObj->pBuf);
|
dBufSetPrintInfo(pHashObj->pBuf);
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ int32_t indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* re
|
||||||
(void)idxTermSearch(index, qterm, &trslt);
|
(void)idxTermSearch(index, qterm, &trslt);
|
||||||
(void)taosArrayPush(iRslts, (void*)&trslt);
|
(void)taosArrayPush(iRslts, (void*)&trslt);
|
||||||
}
|
}
|
||||||
idxMergeFinalResults(iRslts, opera, result);
|
(void)idxMergeFinalResults(iRslts, opera, result);
|
||||||
idxInterRsltDestroy(iRslts);
|
idxInterRsltDestroy(iRslts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,10 +390,10 @@ void idxCacheDebug(IndexCache* cache) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
taosThreadMutexLock(&cache->mtx);
|
(void)taosThreadMutexLock(&cache->mtx);
|
||||||
tbl = cache->imm;
|
tbl = cache->imm;
|
||||||
idxMemRef(tbl);
|
idxMemRef(tbl);
|
||||||
taosThreadMutexUnlock(&cache->mtx);
|
(void)taosThreadMutexUnlock(&cache->mtx);
|
||||||
if (tbl != NULL) {
|
if (tbl != NULL) {
|
||||||
SSkipList* slt = tbl->mem;
|
SSkipList* slt = tbl->mem;
|
||||||
SSkipListIterator* iter = tSkipListCreateIter(slt);
|
SSkipListIterator* iter = tSkipListCreateIter(slt);
|
||||||
|
@ -438,7 +438,7 @@ void idxCacheDestroyImm(IndexCache* cache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MemTable* tbl = NULL;
|
MemTable* tbl = NULL;
|
||||||
taosThreadMutexLock(&cache->mtx);
|
(void)taosThreadMutexLock(&cache->mtx);
|
||||||
|
|
||||||
tbl = cache->imm;
|
tbl = cache->imm;
|
||||||
cache->imm = NULL; // or throw int bg thread
|
cache->imm = NULL; // or throw int bg thread
|
||||||
|
@ -533,7 +533,7 @@ static void idxCacheMakeRoomForWrite(IndexCache* cache) {
|
||||||
}
|
}
|
||||||
// 1. sched to merge
|
// 1. sched to merge
|
||||||
// 2. unref cache in bgwork
|
// 2. unref cache in bgwork
|
||||||
idxCacheSchedToMerge(cache, quit);
|
(void)idxCacheSchedToMerge(cache, quit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode
|
||||||
}
|
}
|
||||||
for (int32_t i = sz - 1; i >= 0; i--) {
|
for (int32_t i = sz - 1; i >= 0; i--) {
|
||||||
FstTransition* t = taosArrayGet(node->trans, i);
|
FstTransition* t = taosArrayGet(node->trans, i);
|
||||||
idxFileWrite(w, (char*)&t->inp, 1);
|
(void)idxFileWrite(w, (char*)&t->inp, 1);
|
||||||
}
|
}
|
||||||
if (sz > TRANS_INDEX_THRESHOLD) {
|
if (sz > TRANS_INDEX_THRESHOLD) {
|
||||||
// A value of 255 indicates that no transition exists for the byte at that idx
|
// A value of 255 indicates that no transition exists for the byte at that idx
|
||||||
|
@ -1015,7 +1015,7 @@ void fstDestroy(Fst* fst) {
|
||||||
taosMemoryFree(fst->meta);
|
taosMemoryFree(fst->meta);
|
||||||
fstSliceDestroy(fst->data);
|
fstSliceDestroy(fst->data);
|
||||||
taosMemoryFree(fst->data);
|
taosMemoryFree(fst->data);
|
||||||
taosThreadMutexDestroy(&fst->mtx);
|
(void)taosThreadMutexDestroy(&fst->mtx);
|
||||||
}
|
}
|
||||||
taosMemoryFree(fst);
|
taosMemoryFree(fst);
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ IdxFstFile* idxFileCreate(void* wrt) {
|
||||||
return cw;
|
return cw;
|
||||||
}
|
}
|
||||||
void idxFileDestroy(IdxFstFile* cw) {
|
void idxFileDestroy(IdxFstFile* cw) {
|
||||||
idxFileFlush(cw);
|
(void)idxFileFlush(cw);
|
||||||
taosMemoryFree(cw);
|
taosMemoryFree(cw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ uint32_t idxFileMaskedCheckSum(IdxFstFile* write) {
|
||||||
|
|
||||||
int idxFileFlush(IdxFstFile* write) {
|
int idxFileFlush(IdxFstFile* write) {
|
||||||
IFileCtx* ctx = write->wrt;
|
IFileCtx* ctx = write->wrt;
|
||||||
ctx->flush(ctx);
|
(void)(ctx->flush(ctx));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) {
|
||||||
buf[i] = (uint8_t)n;
|
buf[i] = (uint8_t)n;
|
||||||
n = n >> 8;
|
n = n >> 8;
|
||||||
}
|
}
|
||||||
idxFileWrite(writer, buf, nBytes);
|
(void)idxFileWrite(writer, buf, nBytes);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,7 +671,7 @@ IndexTFile* idxTFileCreate(SIndex* idx, const char* path) {
|
||||||
tfileCacheDestroy(cache);
|
tfileCacheDestroy(cache);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosThreadMutexInit(&tfile->mtx, NULL);
|
(void)taosThreadMutexInit(&tfile->mtx, NULL);
|
||||||
tfile->cache = cache;
|
tfile->cache = cache;
|
||||||
return tfile;
|
return tfile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ extern char* tsMonFwUri;
|
||||||
#define VNODE_ROLE "taosd_vnodes_info:role"
|
#define VNODE_ROLE "taosd_vnodes_info:role"
|
||||||
|
|
||||||
void monInitMonitorFW(){
|
void monInitMonitorFW(){
|
||||||
taos_collector_registry_default_init();
|
(void)taos_collector_registry_default_init();
|
||||||
|
|
||||||
tsMonitor.metrics = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
tsMonitor.metrics = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||||
taos_gauge_t *gauge = NULL;
|
taos_gauge_t *gauge = NULL;
|
||||||
|
@ -115,9 +115,9 @@ void monInitMonitorFW(){
|
||||||
for(int32_t i = 0; i < 25; i++){
|
for(int32_t i = 0; i < 25; i++){
|
||||||
gauge= taos_gauge_new(dnodes_gauges[i], "", dnodes_label_count, dnodes_sample_labels);
|
gauge= taos_gauge_new(dnodes_gauges[i], "", dnodes_label_count, dnodes_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, dnodes_gauges[i], strlen(dnodes_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, dnodes_gauges[i], strlen(dnodes_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodes_data_label_count = 5;
|
int32_t dnodes_data_label_count = 5;
|
||||||
|
@ -126,9 +126,10 @@ void monInitMonitorFW(){
|
||||||
for(int32_t i = 0; i < 3; i++){
|
for(int32_t i = 0; i < 3; i++){
|
||||||
gauge= taos_gauge_new(dnodes_data_gauges[i], "", dnodes_data_label_count, dnodes_data_sample_labels);
|
gauge= taos_gauge_new(dnodes_data_gauges[i], "", dnodes_data_label_count, dnodes_data_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, dnodes_data_gauges[i], strlen(dnodes_data_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, dnodes_data_gauges[i], strlen(dnodes_data_gauges[i]), &gauge,
|
||||||
|
sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodes_log_label_count = 4;
|
int32_t dnodes_log_label_count = 4;
|
||||||
|
@ -137,15 +138,16 @@ void monInitMonitorFW(){
|
||||||
for(int32_t i = 0; i < 3; i++){
|
for(int32_t i = 0; i < 3; i++){
|
||||||
gauge= taos_gauge_new(dnodes_log_gauges[i], "", dnodes_log_label_count, dnodes_log_sample_labels);
|
gauge= taos_gauge_new(dnodes_log_gauges[i], "", dnodes_log_label_count, dnodes_log_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, dnodes_log_gauges[i], strlen(dnodes_log_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, dnodes_log_gauges[i], strlen(dnodes_log_gauges[i]), &gauge,
|
||||||
|
sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void monCleanupMonitorFW(){
|
void monCleanupMonitorFW(){
|
||||||
taosHashCleanup(tsMonitor.metrics);
|
taosHashCleanup(tsMonitor.metrics);
|
||||||
taos_collector_registry_destroy(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
(void)taos_collector_registry_destroy(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
||||||
TAOS_COLLECTOR_REGISTRY_DEFAULT = NULL;
|
TAOS_COLLECTOR_REGISTRY_DEFAULT = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
uError("failed to delete metric %s", metric_names[i]);
|
uError("failed to delete metric %s", metric_names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]));
|
(void)taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pBasicInfo->cluster_id == 0) {
|
if(pBasicInfo->cluster_id == 0) {
|
||||||
|
@ -182,9 +184,9 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
for(int32_t i = 0; i < 18; i++){
|
for(int32_t i = 0; i < 18; i++){
|
||||||
gauge= taos_gauge_new(metric_names[i], "", label_count, sample_labels1);
|
gauge= taos_gauge_new(metric_names[i], "", label_count, sample_labels1);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]), &gauge, sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
|
@ -194,37 +196,37 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
taos_gauge_t **metric = NULL;
|
taos_gauge_t **metric = NULL;
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MASTER_UPTIME, strlen(MASTER_UPTIME));
|
metric = taosHashGet(tsMonitor.metrics, MASTER_UPTIME, strlen(MASTER_UPTIME));
|
||||||
taos_gauge_set(*metric, pInfo->master_uptime, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->master_uptime, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DBS_TOTAL, strlen(DBS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DBS_TOTAL, strlen(DBS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->dbs_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->dbs_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, TBS_TOTAL, strlen(TBS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, TBS_TOTAL, strlen(TBS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->tbs_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->tbs_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, STBS_TOTAL, strlen(STBS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, STBS_TOTAL, strlen(STBS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->stbs_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->stbs_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VGROUPS_TOTAL, strlen(VGROUPS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, VGROUPS_TOTAL, strlen(VGROUPS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->vgroups_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vgroups_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VGROUPS_ALIVE, strlen(VGROUPS_ALIVE));
|
metric = taosHashGet(tsMonitor.metrics, VGROUPS_ALIVE, strlen(VGROUPS_ALIVE));
|
||||||
taos_gauge_set(*metric, pInfo->vgroups_alive, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vgroups_alive, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VNODES_TOTAL, strlen(VNODES_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, VNODES_TOTAL, strlen(VNODES_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->vnodes_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vnodes_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VNODES_ALIVE, strlen(VNODES_ALIVE));
|
metric = taosHashGet(tsMonitor.metrics, VNODES_ALIVE, strlen(VNODES_ALIVE));
|
||||||
taos_gauge_set(*metric, pInfo->vnodes_alive, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vnodes_alive, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, CONNECTIONS_TOTAL, strlen(CONNECTIONS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, CONNECTIONS_TOTAL, strlen(CONNECTIONS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->connections_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->connections_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, TOPICS_TOTAL, strlen(TOPICS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, TOPICS_TOTAL, strlen(TOPICS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->topics_toal, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->topics_toal, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, STREAMS_TOTAL, strlen(STREAMS_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, STREAMS_TOTAL, strlen(STREAMS_TOTAL));
|
||||||
taos_gauge_set(*metric, pInfo->streams_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->streams_total, sample_label_values);
|
||||||
|
|
||||||
//dnodes number
|
//dnodes number
|
||||||
int32_t dnode_total = taosArrayGetSize(pInfo->dnodes);
|
int32_t dnode_total = taosArrayGetSize(pInfo->dnodes);
|
||||||
|
@ -239,10 +241,10 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
}
|
}
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODES_TOTAL, strlen(DNODES_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DNODES_TOTAL, strlen(DNODES_TOTAL));
|
||||||
taos_gauge_set(*metric, dnode_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, dnode_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODES_ALIVE, strlen(DNODES_ALIVE));
|
metric = taosHashGet(tsMonitor.metrics, DNODES_ALIVE, strlen(DNODES_ALIVE));
|
||||||
taos_gauge_set(*metric, dnode_alive, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, dnode_alive, sample_label_values);
|
||||||
|
|
||||||
//mnodes number
|
//mnodes number
|
||||||
int32_t mnode_total = taosArrayGetSize(pInfo->mnodes);
|
int32_t mnode_total = taosArrayGetSize(pInfo->mnodes);
|
||||||
|
@ -271,20 +273,20 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){
|
||||||
}
|
}
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MNODES_TOTAL, strlen(MNODES_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, MNODES_TOTAL, strlen(MNODES_TOTAL));
|
||||||
taos_gauge_set(*metric, mnode_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, mnode_total, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MNODES_ALIVE, strlen(MNODES_ALIVE));
|
metric = taosHashGet(tsMonitor.metrics, MNODES_ALIVE, strlen(MNODES_ALIVE));
|
||||||
taos_gauge_set(*metric, mnode_alive, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, mnode_alive, sample_label_values);
|
||||||
|
|
||||||
//grant info
|
//grant info
|
||||||
metric = taosHashGet(tsMonitor.metrics, EXPIRE_TIME, strlen(EXPIRE_TIME));
|
metric = taosHashGet(tsMonitor.metrics, EXPIRE_TIME, strlen(EXPIRE_TIME));
|
||||||
taos_gauge_set(*metric, pGrantInfo->expire_time, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->expire_time, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, TIMESERIES_USED, strlen(TIMESERIES_USED));
|
metric = taosHashGet(tsMonitor.metrics, TIMESERIES_USED, strlen(TIMESERIES_USED));
|
||||||
taos_gauge_set(*metric, pGrantInfo->timeseries_used, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->timeseries_used, sample_label_values);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, TIMESERIES_TOTAL, strlen(TIMESERIES_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, TIMESERIES_TOTAL, strlen(TIMESERIES_TOTAL));
|
||||||
taos_gauge_set(*metric, pGrantInfo->timeseries_total, sample_label_values);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->timeseries_total, sample_label_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
void monGenVgroupInfoTable(SMonInfo *pMonitor){
|
void monGenVgroupInfoTable(SMonInfo *pMonitor){
|
||||||
|
@ -306,11 +308,11 @@ void monGenVgroupInfoTable(SMonInfo *pMonitor){
|
||||||
const char *vgroup_sample_labels[] = {"cluster_id", "vgroup_id", "database_name"};
|
const char *vgroup_sample_labels[] = {"cluster_id", "vgroup_id", "database_name"};
|
||||||
taos_gauge_t *tableNumGauge = taos_gauge_new(TABLES_NUM, "", vgroup_label_count, vgroup_sample_labels);
|
taos_gauge_t *tableNumGauge = taos_gauge_new(TABLES_NUM, "", vgroup_label_count, vgroup_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(tableNumGauge) == 1){
|
if(taos_collector_registry_register_metric(tableNumGauge) == 1){
|
||||||
taos_counter_destroy(tableNumGauge);
|
(void)taos_counter_destroy(tableNumGauge);
|
||||||
}
|
}
|
||||||
taos_gauge_t *statusGauge = taos_gauge_new(STATUS, "", vgroup_label_count, vgroup_sample_labels);
|
taos_gauge_t *statusGauge = taos_gauge_new(STATUS, "", vgroup_label_count, vgroup_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(statusGauge) == 1){
|
if(taos_collector_registry_register_metric(statusGauge) == 1){
|
||||||
taos_counter_destroy(statusGauge);
|
(void)taos_counter_destroy(statusGauge);
|
||||||
}
|
}
|
||||||
|
|
||||||
char cluster_id[TSDB_CLUSTER_ID_LEN] = {0};
|
char cluster_id[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
|
@ -326,13 +328,13 @@ void monGenVgroupInfoTable(SMonInfo *pMonitor){
|
||||||
|
|
||||||
taos_gauge_t **metric = NULL;
|
taos_gauge_t **metric = NULL;
|
||||||
|
|
||||||
taos_gauge_set(tableNumGauge, pVgroupDesc->tables_num, sample_labels);
|
if (tableNumGauge != NULL) (void)taos_gauge_set(tableNumGauge, pVgroupDesc->tables_num, sample_labels);
|
||||||
|
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
if(strcmp(pVgroupDesc->status, "ready") == 0){
|
if(strcmp(pVgroupDesc->status, "ready") == 0){
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
taos_gauge_set(statusGauge, status, sample_labels);
|
if (statusGauge != NULL) (void)taos_gauge_set(statusGauge, status, sample_labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,70 +403,70 @@ void monGenDnodeInfoTable(SMonInfo *pMonitor) {
|
||||||
double io_write_disk_rate = io_write_disk / interval;
|
double io_write_disk_rate = io_write_disk / interval;
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, UPTIME, strlen(UPTIME));
|
metric = taosHashGet(tsMonitor.metrics, UPTIME, strlen(UPTIME));
|
||||||
taos_gauge_set(*metric, pInfo->uptime, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->uptime, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, CPU_ENGINE, strlen(CPU_ENGINE));
|
metric = taosHashGet(tsMonitor.metrics, CPU_ENGINE, strlen(CPU_ENGINE));
|
||||||
taos_gauge_set(*metric, cpu_engine, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, cpu_engine, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, CPU_SYSTEM, strlen(CPU_SYSTEM));
|
metric = taosHashGet(tsMonitor.metrics, CPU_SYSTEM, strlen(CPU_SYSTEM));
|
||||||
taos_gauge_set(*metric, pSys->cpu_system, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->cpu_system, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, CPU_CORE, strlen(CPU_CORE));
|
metric = taosHashGet(tsMonitor.metrics, CPU_CORE, strlen(CPU_CORE));
|
||||||
taos_gauge_set(*metric, pSys->cpu_cores, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->cpu_cores, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MEM_ENGINE, strlen(MEM_ENGINE));
|
metric = taosHashGet(tsMonitor.metrics, MEM_ENGINE, strlen(MEM_ENGINE));
|
||||||
taos_gauge_set(*metric, mem_engine, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, mem_engine, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MEM_SYSTEM, strlen(MEM_SYSTEM));
|
metric = taosHashGet(tsMonitor.metrics, MEM_SYSTEM, strlen(MEM_SYSTEM));
|
||||||
taos_gauge_set(*metric, pSys->mem_system, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->mem_system, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MEM_TOTAL, strlen(MEM_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, MEM_TOTAL, strlen(MEM_TOTAL));
|
||||||
taos_gauge_set(*metric, pSys->mem_total, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->mem_total, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DISK_ENGINE, strlen(DISK_ENGINE));
|
metric = taosHashGet(tsMonitor.metrics, DISK_ENGINE, strlen(DISK_ENGINE));
|
||||||
taos_gauge_set(*metric, pSys->disk_engine, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_engine, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DISK_USED, strlen(DISK_USED));
|
metric = taosHashGet(tsMonitor.metrics, DISK_USED, strlen(DISK_USED));
|
||||||
taos_gauge_set(*metric, pSys->disk_used, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_used, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DISK_TOTAL, strlen(DISK_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DISK_TOTAL, strlen(DISK_TOTAL));
|
||||||
taos_gauge_set(*metric, pSys->disk_total, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_total, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, NET_IN, strlen(NET_IN));
|
metric = taosHashGet(tsMonitor.metrics, NET_IN, strlen(NET_IN));
|
||||||
taos_gauge_set(*metric, net_in_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, net_in_rate, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, NET_OUT, strlen(NET_OUT));
|
metric = taosHashGet(tsMonitor.metrics, NET_OUT, strlen(NET_OUT));
|
||||||
taos_gauge_set(*metric, net_out_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, net_out_rate, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, IO_READ, strlen(IO_READ));
|
metric = taosHashGet(tsMonitor.metrics, IO_READ, strlen(IO_READ));
|
||||||
taos_gauge_set(*metric, io_read_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, io_read_rate, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, IO_WRITE, strlen(IO_WRITE));
|
metric = taosHashGet(tsMonitor.metrics, IO_WRITE, strlen(IO_WRITE));
|
||||||
taos_gauge_set(*metric, io_write_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, io_write_rate, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, IO_READ_DISK, strlen(IO_READ_DISK));
|
metric = taosHashGet(tsMonitor.metrics, IO_READ_DISK, strlen(IO_READ_DISK));
|
||||||
taos_gauge_set(*metric, io_read_disk_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, io_read_disk_rate, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, IO_WRITE_DISK, strlen(IO_WRITE_DISK));
|
metric = taosHashGet(tsMonitor.metrics, IO_WRITE_DISK, strlen(IO_WRITE_DISK));
|
||||||
taos_gauge_set(*metric, io_write_disk_rate, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, io_write_disk_rate, sample_labels);
|
||||||
|
|
||||||
// metric = taosHashGet(tsMonitor.metrics, ERRORS, strlen(ERRORS));
|
// metric = taosHashGet(tsMonitor.metrics, ERRORS, strlen(ERRORS));
|
||||||
//taos_gauge_set(*metric, pStat->errors, sample_labels);
|
// if(metric != NULL) (void)taos_gauge_set(*metric, pStat->errors, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VNODES_NUM, strlen(VNODES_NUM));
|
metric = taosHashGet(tsMonitor.metrics, VNODES_NUM, strlen(VNODES_NUM));
|
||||||
taos_gauge_set(*metric, pStat->totalVnodes, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pStat->totalVnodes, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, MASTERS, strlen(MASTERS));
|
metric = taosHashGet(tsMonitor.metrics, MASTERS, strlen(MASTERS));
|
||||||
taos_gauge_set(*metric, pStat->masterNum, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pStat->masterNum, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, HAS_MNODE, strlen(HAS_MNODE));
|
metric = taosHashGet(tsMonitor.metrics, HAS_MNODE, strlen(HAS_MNODE));
|
||||||
taos_gauge_set(*metric, pInfo->has_mnode, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_mnode, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, HAS_QNODE, strlen(HAS_QNODE));
|
metric = taosHashGet(tsMonitor.metrics, HAS_QNODE, strlen(HAS_QNODE));
|
||||||
taos_gauge_set(*metric, pInfo->has_qnode, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_qnode, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, HAS_SNODE, strlen(HAS_SNODE));
|
metric = taosHashGet(tsMonitor.metrics, HAS_SNODE, strlen(HAS_SNODE));
|
||||||
taos_gauge_set(*metric, pInfo->has_snode, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_snode, sample_labels);
|
||||||
|
|
||||||
//log number
|
//log number
|
||||||
SMonLogs *logs[6];
|
SMonLogs *logs[6];
|
||||||
|
@ -489,16 +491,16 @@ void monGenDnodeInfoTable(SMonInfo *pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_ERROR, strlen(DNODE_LOG_ERROR));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_ERROR, strlen(DNODE_LOG_ERROR));
|
||||||
taos_gauge_set(*metric, numOfErrorLogs, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, numOfErrorLogs, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_INFO, strlen(DNODE_LOG_INFO));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_INFO, strlen(DNODE_LOG_INFO));
|
||||||
taos_gauge_set(*metric, numOfInfoLogs, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, numOfInfoLogs, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_DEBUG, strlen(DNODE_LOG_DEBUG));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_DEBUG, strlen(DNODE_LOG_DEBUG));
|
||||||
taos_gauge_set(*metric, numOfDebugLogs, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, numOfDebugLogs, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TRACE, strlen(DNODE_LOG_TRACE));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TRACE, strlen(DNODE_LOG_TRACE));
|
||||||
taos_gauge_set(*metric, numOfTraceLogs, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, numOfTraceLogs, sample_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){
|
void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){
|
||||||
|
@ -519,7 +521,7 @@ void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){
|
||||||
|
|
||||||
gauge= taos_gauge_new(DNODE_STATUS, "", dnodes_label_count, dnodes_sample_labels);
|
gauge= taos_gauge_new(DNODE_STATUS, "", dnodes_label_count, dnodes_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
|
|
||||||
char cluster_id[TSDB_CLUSTER_ID_LEN];
|
char cluster_id[TSDB_CLUSTER_ID_LEN];
|
||||||
|
@ -541,7 +543,7 @@ void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){
|
||||||
if(strcmp(pDnodeDesc->status, "ready") == 0){
|
if(strcmp(pDnodeDesc->status, "ready") == 0){
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
taos_gauge_set(gauge, status, sample_labels);
|
if (gauge != NULL) (void)taos_gauge_set(gauge, status, sample_labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,13 +569,13 @@ void monGenDataDiskTable(SMonInfo *pMonitor){
|
||||||
const char *sample_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pDatadirDesc->name, level};
|
const char *sample_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pDatadirDesc->name, level};
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_AVAIL, strlen(DNODE_DATA_AVAIL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_AVAIL, strlen(DNODE_DATA_AVAIL));
|
||||||
taos_gauge_set(*metric, pDatadirDesc->size.avail, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.avail, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_USED, strlen(DNODE_DATA_USED));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_USED, strlen(DNODE_DATA_USED));
|
||||||
taos_gauge_set(*metric, pDatadirDesc->size.used, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.used, sample_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_TOTAL, strlen(DNODE_DATA_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_TOTAL, strlen(DNODE_DATA_TOTAL));
|
||||||
taos_gauge_set(*metric, pDatadirDesc->size.total, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.total, sample_labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,24 +596,24 @@ void monGenLogDiskTable(SMonInfo *pMonitor){
|
||||||
const char *sample_log_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pLogDesc->name};
|
const char *sample_log_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pLogDesc->name};
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL));
|
||||||
taos_gauge_set(*metric, pLogDesc->size.avail, sample_log_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.avail, sample_log_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED));
|
||||||
taos_gauge_set(*metric, pLogDesc->size.used, sample_log_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.used, sample_log_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL));
|
||||||
taos_gauge_set(*metric, pLogDesc->size.total, sample_log_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.total, sample_log_labels);
|
||||||
|
|
||||||
const char *sample_temp_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pTempDesc->name};
|
const char *sample_temp_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pTempDesc->name};
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL));
|
||||||
taos_gauge_set(*metric, pTempDesc->size.avail, sample_temp_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.avail, sample_temp_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED));
|
||||||
taos_gauge_set(*metric, pTempDesc->size.used, sample_temp_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.used, sample_temp_labels);
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL));
|
metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL));
|
||||||
taos_gauge_set(*metric, pTempDesc->size.total, sample_temp_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.total, sample_temp_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
||||||
|
@ -622,7 +624,7 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
||||||
uError("failed to delete metric %s", mnodes_role_gauges[i]);
|
uError("failed to delete metric %s", mnodes_role_gauges[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]));
|
(void)taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster;
|
SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster;
|
||||||
|
@ -636,9 +638,10 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
||||||
for(int32_t i = 0; i < 1; i++){
|
for(int32_t i = 0; i < 1; i++){
|
||||||
gauge= taos_gauge_new(mnodes_role_gauges[i], "", mnodes_role_label_count, mnodes_role_sample_labels);
|
gauge= taos_gauge_new(mnodes_role_gauges[i], "", mnodes_role_label_count, mnodes_role_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]), &gauge,
|
||||||
|
sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
|
@ -669,13 +672,13 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){
|
||||||
metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE));
|
metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE));
|
||||||
|
|
||||||
if(dnodeIsOnline){
|
if(dnodeIsOnline){
|
||||||
taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
taos_gauge_set(*metric, 0, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, 0, sample_labels);
|
||||||
}
|
}
|
||||||
// metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE));
|
// metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE));
|
||||||
//taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels);
|
// if(metric != NULL) (void)taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +691,7 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){
|
||||||
uError("failed to delete metric %s", vnodes_role_gauges[i]);
|
uError("failed to delete metric %s", vnodes_role_gauges[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]));
|
(void)taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonVgroupInfo *pInfo = &pMonitor->mmInfo.vgroup;
|
SMonVgroupInfo *pInfo = &pMonitor->mmInfo.vgroup;
|
||||||
|
@ -702,9 +705,10 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){
|
||||||
for(int32_t i = 0; i < 1; i++){
|
for(int32_t i = 0; i < 1; i++){
|
||||||
gauge= taos_gauge_new(vnodes_role_gauges[i], "", vnodes_role_label_count, vnodes_role_sample_labels);
|
gauge= taos_gauge_new(vnodes_role_gauges[i], "", vnodes_role_label_count, vnodes_role_sample_labels);
|
||||||
if(taos_collector_registry_register_metric(gauge) == 1){
|
if(taos_collector_registry_register_metric(gauge) == 1){
|
||||||
taos_counter_destroy(gauge);
|
(void)taos_counter_destroy(gauge);
|
||||||
}
|
}
|
||||||
taosHashPut(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]), &gauge, sizeof(taos_gauge_t *));
|
(void)taosHashPut(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]), &gauge,
|
||||||
|
sizeof(taos_gauge_t *));
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
char buf[TSDB_CLUSTER_ID_LEN] = {0};
|
||||||
|
@ -728,7 +732,7 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){
|
||||||
const char *sample_labels[] = {buf, vgroup_id, pVgroupDesc->database_name, dnode_id};
|
const char *sample_labels[] = {buf, vgroup_id, pVgroupDesc->database_name, dnode_id};
|
||||||
|
|
||||||
metric = taosHashGet(tsMonitor.metrics, VNODE_ROLE, strlen(VNODE_ROLE));
|
metric = taosHashGet(tsMonitor.metrics, VNODE_ROLE, strlen(VNODE_ROLE));
|
||||||
taos_gauge_set(*metric, pVnodeDesc->syncState, sample_labels);
|
if (metric != NULL) (void)taos_gauge_set(*metric, pVnodeDesc->syncState, sample_labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -753,7 +757,7 @@ void monSendPromReport() {
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg");
|
uError("failed to send monitor msg");
|
||||||
}else{
|
}else{
|
||||||
taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
(void)taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pCont);
|
taosMemoryFreeClear(pCont);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ int32_t monInit(const SMonCfg *pCfg) {
|
||||||
tsMonitor.cfg = *pCfg;
|
tsMonitor.cfg = *pCfg;
|
||||||
tsLogFp = monRecordLog;
|
tsLogFp = monRecordLog;
|
||||||
tsMonitor.lastTime = taosGetTimestampMs();
|
tsMonitor.lastTime = taosGetTimestampMs();
|
||||||
taosThreadMutexInit(&tsMonitor.lock, NULL);
|
(void)taosThreadMutexInit(&tsMonitor.lock, NULL);
|
||||||
|
|
||||||
monInitMonitorFW();
|
monInitMonitorFW();
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void monCleanup() {
|
||||||
tFreeSMonSmInfo(&tsMonitor.smInfo);
|
tFreeSMonSmInfo(&tsMonitor.smInfo);
|
||||||
tFreeSMonQmInfo(&tsMonitor.qmInfo);
|
tFreeSMonQmInfo(&tsMonitor.qmInfo);
|
||||||
tFreeSMonBmInfo(&tsMonitor.bmInfo);
|
tFreeSMonBmInfo(&tsMonitor.bmInfo);
|
||||||
taosThreadMutexDestroy(&tsMonitor.lock);
|
(void)taosThreadMutexDestroy(&tsMonitor.lock);
|
||||||
|
|
||||||
monCleanupMonitorFW();
|
monCleanupMonitorFW();
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,9 @@ static SMonInfo *monCreateMonitorInfo() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
monGetLogs(&pMonitor->log);
|
if ((terrno = monGetLogs(&pMonitor->log)) != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
(void)taosThreadMutexLock(&tsMonitor.lock);
|
(void)taosThreadMutexLock(&tsMonitor.lock);
|
||||||
memcpy(&pMonitor->dmInfo, &tsMonitor.dmInfo, sizeof(SMonDmInfo));
|
memcpy(&pMonitor->dmInfo, &tsMonitor.dmInfo, sizeof(SMonDmInfo));
|
||||||
|
@ -185,14 +187,14 @@ static void monGenBasicJson(SMonInfo *pMonitor) {
|
||||||
|
|
||||||
SJson *pJson = pMonitor->pJson;
|
SJson *pJson = pMonitor->pJson;
|
||||||
char buf[40] = {0};
|
char buf[40] = {0};
|
||||||
taosFormatUtcTime(buf, sizeof(buf), pMonitor->curTime, TSDB_TIME_PRECISION_MILLI);
|
(void)taosFormatUtcTime(buf, sizeof(buf), pMonitor->curTime, TSDB_TIME_PRECISION_MILLI);
|
||||||
|
|
||||||
tjsonAddStringToObject(pJson, "ts", buf);
|
(void)tjsonAddStringToObject(pJson, "ts", buf);
|
||||||
tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
|
(void)tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
|
||||||
tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
|
(void)tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
|
||||||
snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id);
|
snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id);
|
||||||
tjsonAddStringToObject(pJson, "cluster_id", buf);
|
(void)tjsonAddStringToObject(pJson, "cluster_id", buf);
|
||||||
tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol);
|
(void)tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenBasicJsonBasic(SMonInfo *pMonitor) {
|
static void monGenBasicJsonBasic(SMonInfo *pMonitor) {
|
||||||
|
@ -203,12 +205,12 @@ static void monGenBasicJsonBasic(SMonInfo *pMonitor) {
|
||||||
char buf[40] = {0};
|
char buf[40] = {0};
|
||||||
|
|
||||||
sprintf(buf, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
sprintf(buf, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||||
tjsonAddStringToObject(pJson, "ts", buf);
|
(void)tjsonAddStringToObject(pJson, "ts", buf);
|
||||||
tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
|
(void)tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id);
|
||||||
tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
|
(void)tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep);
|
||||||
snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id);
|
snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id);
|
||||||
tjsonAddStringToObject(pJson, "cluster_id", buf);
|
(void)tjsonAddStringToObject(pJson, "cluster_id", buf);
|
||||||
tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol);
|
(void)tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenClusterJson(SMonInfo *pMonitor) {
|
static void monGenClusterJson(SMonInfo *pMonitor) {
|
||||||
|
@ -222,21 +224,21 @@ static void monGenClusterJson(SMonInfo *pMonitor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tjsonAddStringToObject(pJson, "first_ep", pInfo->first_ep);
|
(void)tjsonAddStringToObject(pJson, "first_ep", pInfo->first_ep);
|
||||||
tjsonAddDoubleToObject(pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id);
|
(void)tjsonAddDoubleToObject(pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id);
|
||||||
tjsonAddStringToObject(pJson, "version", pInfo->version);
|
(void)tjsonAddStringToObject(pJson, "version", pInfo->version);
|
||||||
tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime);
|
(void)tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime);
|
||||||
tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval);
|
(void)tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval);
|
||||||
tjsonAddDoubleToObject(pJson, "dbs_total", pInfo->dbs_total);
|
(void)tjsonAddDoubleToObject(pJson, "dbs_total", pInfo->dbs_total);
|
||||||
tjsonAddDoubleToObject(pJson, "tbs_total", pInfo->tbs_total);
|
(void)tjsonAddDoubleToObject(pJson, "tbs_total", pInfo->tbs_total);
|
||||||
tjsonAddDoubleToObject(pJson, "stbs_total", pInfo->stbs_total);
|
(void)tjsonAddDoubleToObject(pJson, "stbs_total", pInfo->stbs_total);
|
||||||
tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total);
|
(void)tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total);
|
||||||
tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive);
|
(void)tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive);
|
||||||
tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total);
|
(void)tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total);
|
||||||
tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive);
|
(void)tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive);
|
||||||
tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total);
|
(void)tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total);
|
||||||
tjsonAddDoubleToObject(pJson, "topics_total", pInfo->topics_toal);
|
(void)tjsonAddDoubleToObject(pJson, "topics_total", pInfo->topics_toal);
|
||||||
tjsonAddDoubleToObject(pJson, "streams_total", pInfo->streams_total);
|
(void)tjsonAddDoubleToObject(pJson, "streams_total", pInfo->streams_total);
|
||||||
|
|
||||||
SJson *pDnodesJson = tjsonAddArrayToObject(pJson, "dnodes");
|
SJson *pDnodesJson = tjsonAddArrayToObject(pJson, "dnodes");
|
||||||
if (pDnodesJson == NULL) return;
|
if (pDnodesJson == NULL) return;
|
||||||
|
@ -246,9 +248,9 @@ static void monGenClusterJson(SMonInfo *pMonitor) {
|
||||||
if (pDnodeJson == NULL) continue;
|
if (pDnodeJson == NULL) continue;
|
||||||
|
|
||||||
SMonDnodeDesc *pDnodeDesc = taosArrayGet(pInfo->dnodes, i);
|
SMonDnodeDesc *pDnodeDesc = taosArrayGet(pInfo->dnodes, i);
|
||||||
tjsonAddDoubleToObject(pDnodeJson, "dnode_id", pDnodeDesc->dnode_id);
|
(void)tjsonAddDoubleToObject(pDnodeJson, "dnode_id", pDnodeDesc->dnode_id);
|
||||||
tjsonAddStringToObject(pDnodeJson, "dnode_ep", pDnodeDesc->dnode_ep);
|
(void)tjsonAddStringToObject(pDnodeJson, "dnode_ep", pDnodeDesc->dnode_ep);
|
||||||
tjsonAddStringToObject(pDnodeJson, "status", pDnodeDesc->status);
|
(void)tjsonAddStringToObject(pDnodeJson, "status", pDnodeDesc->status);
|
||||||
|
|
||||||
if (tjsonAddItemToArray(pDnodesJson, pDnodeJson) != 0) tjsonDelete(pDnodeJson);
|
if (tjsonAddItemToArray(pDnodesJson, pDnodeJson) != 0) tjsonDelete(pDnodeJson);
|
||||||
}
|
}
|
||||||
|
@ -261,9 +263,9 @@ static void monGenClusterJson(SMonInfo *pMonitor) {
|
||||||
if (pMnodeJson == NULL) continue;
|
if (pMnodeJson == NULL) continue;
|
||||||
|
|
||||||
SMonMnodeDesc *pMnodeDesc = taosArrayGet(pInfo->mnodes, i);
|
SMonMnodeDesc *pMnodeDesc = taosArrayGet(pInfo->mnodes, i);
|
||||||
tjsonAddDoubleToObject(pMnodeJson, "mnode_id", pMnodeDesc->mnode_id);
|
(void)tjsonAddDoubleToObject(pMnodeJson, "mnode_id", pMnodeDesc->mnode_id);
|
||||||
tjsonAddStringToObject(pMnodeJson, "mnode_ep", pMnodeDesc->mnode_ep);
|
(void)tjsonAddStringToObject(pMnodeJson, "mnode_ep", pMnodeDesc->mnode_ep);
|
||||||
tjsonAddStringToObject(pMnodeJson, "role", pMnodeDesc->role);
|
(void)tjsonAddStringToObject(pMnodeJson, "role", pMnodeDesc->role);
|
||||||
|
|
||||||
if (tjsonAddItemToArray(pMnodesJson, pMnodeJson) != 0) tjsonDelete(pMnodeJson);
|
if (tjsonAddItemToArray(pMnodesJson, pMnodeJson) != 0) tjsonDelete(pMnodeJson);
|
||||||
}
|
}
|
||||||
|
@ -273,11 +275,11 @@ static void monGenClusterJsonBasic(SMonInfo *pMonitor) {
|
||||||
SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster;
|
SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster;
|
||||||
if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return;
|
if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return;
|
||||||
|
|
||||||
// tjsonAddStringToObject(pMonitor->pJson, "first_ep", pInfo->first_ep);
|
// (void)tjsonAddStringToObject(pMonitor->pJson, "first_ep", pInfo->first_ep);
|
||||||
tjsonAddStringToObject(pMonitor->pJson, "first_ep", tsFirst);
|
(void)tjsonAddStringToObject(pMonitor->pJson, "first_ep", tsFirst);
|
||||||
tjsonAddDoubleToObject(pMonitor->pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id);
|
(void)tjsonAddDoubleToObject(pMonitor->pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id);
|
||||||
tjsonAddStringToObject(pMonitor->pJson, "cluster_version", pInfo->version);
|
(void)tjsonAddStringToObject(pMonitor->pJson, "cluster_version", pInfo->version);
|
||||||
// tjsonAddDoubleToObject(pMonitor->pJson, "monitor_interval", pInfo->monitor_interval);
|
// (void)tjsonAddDoubleToObject(pMonitor->pJson, "monitor_interval", pInfo->monitor_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenVgroupJson(SMonInfo *pMonitor) {
|
static void monGenVgroupJson(SMonInfo *pMonitor) {
|
||||||
|
@ -296,10 +298,10 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonVgroupDesc *pVgroupDesc = taosArrayGet(pInfo->vgroups, i);
|
SMonVgroupDesc *pVgroupDesc = taosArrayGet(pInfo->vgroups, i);
|
||||||
tjsonAddDoubleToObject(pVgroupJson, "vgroup_id", pVgroupDesc->vgroup_id);
|
(void)tjsonAddDoubleToObject(pVgroupJson, "vgroup_id", pVgroupDesc->vgroup_id);
|
||||||
tjsonAddStringToObject(pVgroupJson, "database_name", pVgroupDesc->database_name);
|
(void)tjsonAddStringToObject(pVgroupJson, "database_name", pVgroupDesc->database_name);
|
||||||
tjsonAddDoubleToObject(pVgroupJson, "tables_num", pVgroupDesc->tables_num);
|
(void)tjsonAddDoubleToObject(pVgroupJson, "tables_num", pVgroupDesc->tables_num);
|
||||||
tjsonAddStringToObject(pVgroupJson, "status", pVgroupDesc->status);
|
(void)tjsonAddStringToObject(pVgroupJson, "status", pVgroupDesc->status);
|
||||||
|
|
||||||
SJson *pVnodesJson = tjsonAddArrayToObject(pVgroupJson, "vnodes");
|
SJson *pVnodesJson = tjsonAddArrayToObject(pVgroupJson, "vnodes");
|
||||||
if (pVnodesJson == NULL) continue;
|
if (pVnodesJson == NULL) continue;
|
||||||
|
@ -311,8 +313,8 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
|
||||||
SJson *pVnodeJson = tjsonCreateObject();
|
SJson *pVnodeJson = tjsonCreateObject();
|
||||||
if (pVnodeJson == NULL) continue;
|
if (pVnodeJson == NULL) continue;
|
||||||
|
|
||||||
tjsonAddDoubleToObject(pVnodeJson, "dnode_id", pVnodeDesc->dnode_id);
|
(void)tjsonAddDoubleToObject(pVnodeJson, "dnode_id", pVnodeDesc->dnode_id);
|
||||||
tjsonAddStringToObject(pVnodeJson, "vnode_role", pVnodeDesc->vnode_role);
|
(void)tjsonAddStringToObject(pVnodeJson, "vnode_role", pVnodeDesc->vnode_role);
|
||||||
|
|
||||||
if (tjsonAddItemToArray(pVnodesJson, pVnodeJson) != 0) tjsonDelete(pVnodeJson);
|
if (tjsonAddItemToArray(pVnodesJson, pVnodeJson) != 0) tjsonDelete(pVnodeJson);
|
||||||
}
|
}
|
||||||
|
@ -335,8 +337,8 @@ static void monGenStbJson(SMonInfo *pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonStbDesc *pStbDesc = taosArrayGet(pInfo->stbs, i);
|
SMonStbDesc *pStbDesc = taosArrayGet(pInfo->stbs, i);
|
||||||
tjsonAddStringToObject(pStbJson, "stb_name", pStbDesc->stb_name);
|
(void)tjsonAddStringToObject(pStbJson, "stb_name", pStbDesc->stb_name);
|
||||||
tjsonAddStringToObject(pStbJson, "database_name", pStbDesc->database_name);
|
(void)tjsonAddStringToObject(pStbJson, "database_name", pStbDesc->database_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,9 +353,9 @@ static void monGenGrantJson(SMonInfo *pMonitor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tjsonAddDoubleToObject(pJson, "expire_time", pInfo->expire_time);
|
(void)tjsonAddDoubleToObject(pJson, "expire_time", pInfo->expire_time);
|
||||||
tjsonAddDoubleToObject(pJson, "timeseries_used", pInfo->timeseries_used);
|
(void)tjsonAddDoubleToObject(pJson, "timeseries_used", pInfo->timeseries_used);
|
||||||
tjsonAddDoubleToObject(pJson, "timeseries_total", pInfo->timeseries_total);
|
(void)tjsonAddDoubleToObject(pJson, "timeseries_total", pInfo->timeseries_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenDnodeJson(SMonInfo *pMonitor) {
|
static void monGenDnodeJson(SMonInfo *pMonitor) {
|
||||||
|
@ -410,36 +412,36 @@ static void monGenDnodeJson(SMonInfo *pMonitor) {
|
||||||
double io_read_disk_rate = io_read_disk / interval;
|
double io_read_disk_rate = io_read_disk / interval;
|
||||||
double io_write_disk_rate = io_write_disk / interval;
|
double io_write_disk_rate = io_write_disk / interval;
|
||||||
|
|
||||||
tjsonAddDoubleToObject(pJson, "uptime", pInfo->uptime);
|
(void)tjsonAddDoubleToObject(pJson, "uptime", pInfo->uptime);
|
||||||
tjsonAddDoubleToObject(pJson, "cpu_engine", cpu_engine);
|
(void)tjsonAddDoubleToObject(pJson, "cpu_engine", cpu_engine);
|
||||||
tjsonAddDoubleToObject(pJson, "cpu_system", pSys->cpu_system);
|
(void)tjsonAddDoubleToObject(pJson, "cpu_system", pSys->cpu_system);
|
||||||
tjsonAddDoubleToObject(pJson, "cpu_cores", pSys->cpu_cores);
|
(void)tjsonAddDoubleToObject(pJson, "cpu_cores", pSys->cpu_cores);
|
||||||
tjsonAddDoubleToObject(pJson, "mem_engine", mem_engine);
|
(void)tjsonAddDoubleToObject(pJson, "mem_engine", mem_engine);
|
||||||
tjsonAddDoubleToObject(pJson, "mem_system", pSys->mem_system);
|
(void)tjsonAddDoubleToObject(pJson, "mem_system", pSys->mem_system);
|
||||||
tjsonAddDoubleToObject(pJson, "mem_total", pSys->mem_total);
|
(void)tjsonAddDoubleToObject(pJson, "mem_total", pSys->mem_total);
|
||||||
tjsonAddDoubleToObject(pJson, "disk_engine", pSys->disk_engine);
|
(void)tjsonAddDoubleToObject(pJson, "disk_engine", pSys->disk_engine);
|
||||||
tjsonAddDoubleToObject(pJson, "disk_used", pSys->disk_used);
|
(void)tjsonAddDoubleToObject(pJson, "disk_used", pSys->disk_used);
|
||||||
tjsonAddDoubleToObject(pJson, "disk_total", pSys->disk_total);
|
(void)tjsonAddDoubleToObject(pJson, "disk_total", pSys->disk_total);
|
||||||
tjsonAddDoubleToObject(pJson, "net_in", net_in_rate);
|
(void)tjsonAddDoubleToObject(pJson, "net_in", net_in_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "net_out", net_out_rate);
|
(void)tjsonAddDoubleToObject(pJson, "net_out", net_out_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "io_read", io_read_rate);
|
(void)tjsonAddDoubleToObject(pJson, "io_read", io_read_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "io_write", io_write_rate);
|
(void)tjsonAddDoubleToObject(pJson, "io_write", io_write_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "io_read_disk", io_read_disk_rate);
|
(void)tjsonAddDoubleToObject(pJson, "io_read_disk", io_read_disk_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "io_write_disk", io_write_disk_rate);
|
(void)tjsonAddDoubleToObject(pJson, "io_write_disk", io_write_disk_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "req_select", pStat->numOfSelectReqs);
|
(void)tjsonAddDoubleToObject(pJson, "req_select", pStat->numOfSelectReqs);
|
||||||
tjsonAddDoubleToObject(pJson, "req_select_rate", req_select_rate);
|
(void)tjsonAddDoubleToObject(pJson, "req_select_rate", req_select_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert", pStat->numOfInsertReqs);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert", pStat->numOfInsertReqs);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert_success", pStat->numOfInsertSuccessReqs);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert_success", pStat->numOfInsertSuccessReqs);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert_rate", req_insert_rate);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert_rate", req_insert_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert_batch", pStat->numOfBatchInsertReqs);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert_batch", pStat->numOfBatchInsertReqs);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert_batch_success", pStat->numOfBatchInsertSuccessReqs);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert_batch_success", pStat->numOfBatchInsertSuccessReqs);
|
||||||
tjsonAddDoubleToObject(pJson, "req_insert_batch_rate", req_insert_batch_rate);
|
(void)tjsonAddDoubleToObject(pJson, "req_insert_batch_rate", req_insert_batch_rate);
|
||||||
tjsonAddDoubleToObject(pJson, "errors", pStat->errors);
|
(void)tjsonAddDoubleToObject(pJson, "errors", pStat->errors);
|
||||||
tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes);
|
(void)tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes);
|
||||||
tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum);
|
(void)tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum);
|
||||||
tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode);
|
(void)tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode);
|
||||||
tjsonAddDoubleToObject(pJson, "has_qnode", pInfo->has_qnode);
|
(void)tjsonAddDoubleToObject(pJson, "has_qnode", pInfo->has_qnode);
|
||||||
tjsonAddDoubleToObject(pJson, "has_snode", pInfo->has_snode);
|
(void)tjsonAddDoubleToObject(pJson, "has_snode", pInfo->has_snode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenDiskJson(SMonInfo *pMonitor) {
|
static void monGenDiskJson(SMonInfo *pMonitor) {
|
||||||
|
@ -474,18 +476,18 @@ static void monGenDiskJson(SMonInfo *pMonitor) {
|
||||||
SJson *pLogdirJson = tjsonCreateObject();
|
SJson *pLogdirJson = tjsonCreateObject();
|
||||||
if (pLogdirJson == NULL) return;
|
if (pLogdirJson == NULL) return;
|
||||||
if (tjsonAddItemToObject(pJson, "logdir", pLogdirJson) != 0) return;
|
if (tjsonAddItemToObject(pJson, "logdir", pLogdirJson) != 0) return;
|
||||||
tjsonAddStringToObject(pLogdirJson, "name", pLogDesc->name);
|
(void)tjsonAddStringToObject(pLogdirJson, "name", pLogDesc->name);
|
||||||
tjsonAddDoubleToObject(pLogdirJson, "avail", pLogDesc->size.avail);
|
(void)tjsonAddDoubleToObject(pLogdirJson, "avail", pLogDesc->size.avail);
|
||||||
tjsonAddDoubleToObject(pLogdirJson, "used", pLogDesc->size.used);
|
(void)tjsonAddDoubleToObject(pLogdirJson, "used", pLogDesc->size.used);
|
||||||
tjsonAddDoubleToObject(pLogdirJson, "total", pLogDesc->size.total);
|
(void)tjsonAddDoubleToObject(pLogdirJson, "total", pLogDesc->size.total);
|
||||||
|
|
||||||
SJson *pTempdirJson = tjsonCreateObject();
|
SJson *pTempdirJson = tjsonCreateObject();
|
||||||
if (pTempdirJson == NULL) return;
|
if (pTempdirJson == NULL) return;
|
||||||
if (tjsonAddItemToObject(pJson, "tempdir", pTempdirJson) != 0) return;
|
if (tjsonAddItemToObject(pJson, "tempdir", pTempdirJson) != 0) return;
|
||||||
tjsonAddStringToObject(pTempdirJson, "name", pTempDesc->name);
|
(void)tjsonAddStringToObject(pTempdirJson, "name", pTempDesc->name);
|
||||||
tjsonAddDoubleToObject(pTempdirJson, "avail", pTempDesc->size.avail);
|
(void)tjsonAddDoubleToObject(pTempdirJson, "avail", pTempDesc->size.avail);
|
||||||
tjsonAddDoubleToObject(pTempdirJson, "used", pTempDesc->size.used);
|
(void)tjsonAddDoubleToObject(pTempdirJson, "used", pTempDesc->size.used);
|
||||||
tjsonAddDoubleToObject(pTempdirJson, "total", pTempDesc->size.total);
|
(void)tjsonAddDoubleToObject(pTempdirJson, "total", pTempDesc->size.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *monLogLevelStr(ELogLevel level) {
|
static const char *monLogLevelStr(ELogLevel level) {
|
||||||
|
@ -530,26 +532,26 @@ static void monGenLogJson(SMonInfo *pMonitor) {
|
||||||
|
|
||||||
SJson *pLogError = tjsonCreateObject();
|
SJson *pLogError = tjsonCreateObject();
|
||||||
if (pLogError == NULL) return;
|
if (pLogError == NULL) return;
|
||||||
tjsonAddStringToObject(pLogError, "level", "error");
|
(void)tjsonAddStringToObject(pLogError, "level", "error");
|
||||||
tjsonAddDoubleToObject(pLogError, "total", numOfErrorLogs);
|
(void)tjsonAddDoubleToObject(pLogError, "total", numOfErrorLogs);
|
||||||
if (tjsonAddItemToArray(pSummaryJson, pLogError) != 0) tjsonDelete(pLogError);
|
if (tjsonAddItemToArray(pSummaryJson, pLogError) != 0) tjsonDelete(pLogError);
|
||||||
|
|
||||||
SJson *pLogInfo = tjsonCreateObject();
|
SJson *pLogInfo = tjsonCreateObject();
|
||||||
if (pLogInfo == NULL) return;
|
if (pLogInfo == NULL) return;
|
||||||
tjsonAddStringToObject(pLogInfo, "level", "info");
|
(void)tjsonAddStringToObject(pLogInfo, "level", "info");
|
||||||
tjsonAddDoubleToObject(pLogInfo, "total", numOfInfoLogs);
|
(void)tjsonAddDoubleToObject(pLogInfo, "total", numOfInfoLogs);
|
||||||
if (tjsonAddItemToArray(pSummaryJson, pLogInfo) != 0) tjsonDelete(pLogInfo);
|
if (tjsonAddItemToArray(pSummaryJson, pLogInfo) != 0) tjsonDelete(pLogInfo);
|
||||||
|
|
||||||
SJson *pLogDebug = tjsonCreateObject();
|
SJson *pLogDebug = tjsonCreateObject();
|
||||||
if (pLogDebug == NULL) return;
|
if (pLogDebug == NULL) return;
|
||||||
tjsonAddStringToObject(pLogDebug, "level", "debug");
|
(void)tjsonAddStringToObject(pLogDebug, "level", "debug");
|
||||||
tjsonAddDoubleToObject(pLogDebug, "total", numOfDebugLogs);
|
(void)tjsonAddDoubleToObject(pLogDebug, "total", numOfDebugLogs);
|
||||||
if (tjsonAddItemToArray(pSummaryJson, pLogDebug) != 0) tjsonDelete(pLogDebug);
|
if (tjsonAddItemToArray(pSummaryJson, pLogDebug) != 0) tjsonDelete(pLogDebug);
|
||||||
|
|
||||||
SJson *pLogTrace = tjsonCreateObject();
|
SJson *pLogTrace = tjsonCreateObject();
|
||||||
if (pLogTrace == NULL) return;
|
if (pLogTrace == NULL) return;
|
||||||
tjsonAddStringToObject(pLogTrace, "level", "trace");
|
(void)tjsonAddStringToObject(pLogTrace, "level", "trace");
|
||||||
tjsonAddDoubleToObject(pLogTrace, "total", numOfTraceLogs);
|
(void)tjsonAddDoubleToObject(pLogTrace, "total", numOfTraceLogs);
|
||||||
if (tjsonAddItemToArray(pSummaryJson, pLogTrace) != 0) tjsonDelete(pLogTrace);
|
if (tjsonAddItemToArray(pSummaryJson, pLogTrace) != 0) tjsonDelete(pLogTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,9 @@ static void checkParamIsFunc(SFunctionNode* pFunc) {
|
||||||
if (nodeType(pPara) == QUERY_NODE_COLUMN) {
|
if (nodeType(pPara) == QUERY_NODE_COLUMN) {
|
||||||
((SColumnNode*)pPara)->node.asParam = true;
|
((SColumnNode*)pPara)->node.asParam = true;
|
||||||
}
|
}
|
||||||
|
if (nodeType(pPara) == QUERY_NODE_VALUE) {
|
||||||
|
((SValueNode*)pPara)->node.asParam = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1450,6 +1450,8 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getFuncInfo(STranslateContext* pCxt, SFunctionNode* pFunc);
|
||||||
|
|
||||||
static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** pCol, bool* pFound) {
|
static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** pCol, bool* pFound) {
|
||||||
SNodeList* pProjectionList = getProjectListFromCurrStmt(pCxt->pCurrStmt);
|
SNodeList* pProjectionList = getProjectListFromCurrStmt(pCxt->pCurrStmt);
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
|
@ -1470,6 +1472,25 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*pFound) {
|
if (*pFound) {
|
||||||
|
if (QUERY_NODE_FUNCTION == nodeType(pFoundNode) && (SQL_CLAUSE_GROUP_BY == pCxt->currClause || SQL_CLAUSE_PARTITION_BY == pCxt->currClause)) {
|
||||||
|
pCxt->errCode = getFuncInfo(pCxt, (SFunctionNode*)pFoundNode);
|
||||||
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
|
if (fmIsVectorFunc(((SFunctionNode*)pFoundNode)->funcId)) {
|
||||||
|
pCxt->errCode = TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
} else if (fmIsPseudoColumnFunc(((SFunctionNode*)pFoundNode)->funcId)) {
|
||||||
|
if ('\0' != (*pCol)->tableAlias[0]) {
|
||||||
|
return translateColumnWithPrefix(pCxt, pCol);
|
||||||
|
} else {
|
||||||
|
return translateColumnWithoutPrefix(pCxt, pCol);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Do nothing and replace old node with found node. */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
SNode* pNew = NULL;
|
SNode* pNew = NULL;
|
||||||
int32_t code = nodesCloneNode(pFoundNode, &pNew);
|
int32_t code = nodesCloneNode(pFoundNode, &pNew);
|
||||||
if (NULL == pNew) {
|
if (NULL == pNew) {
|
||||||
|
@ -1478,6 +1499,13 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*(SNode**)pCol);
|
nodesDestroyNode(*(SNode**)pCol);
|
||||||
*(SNode**)pCol = (SNode*)pNew;
|
*(SNode**)pCol = (SNode*)pNew;
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pFoundNode)) {
|
||||||
|
if ('\0' != (*pCol)->tableAlias[0]) {
|
||||||
|
return translateColumnWithPrefix(pCxt, pCol);
|
||||||
|
} else {
|
||||||
|
return translateColumnWithoutPrefix(pCxt, pCol);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1716,6 +1744,12 @@ int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool clauseSupportAlias(ESqlClause clause) {
|
||||||
|
return SQL_CLAUSE_GROUP_BY == clause ||
|
||||||
|
SQL_CLAUSE_PARTITION_BY == clause ||
|
||||||
|
SQL_CLAUSE_ORDER_BY == clause;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||||
if (NULL == pCxt->pCurrStmt ||
|
if (NULL == pCxt->pCurrStmt ||
|
||||||
(isSelectStmt(pCxt->pCurrStmt) && NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
(isSelectStmt(pCxt->pCurrStmt) && NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
||||||
|
@ -1742,7 +1776,8 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||||
res = translateColumnWithPrefix(pCxt, pCol);
|
res = translateColumnWithPrefix(pCxt, pCol);
|
||||||
} else {
|
} else {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause && !(*pCol)->node.asParam) {
|
if ((clauseSupportAlias(pCxt->currClause)) &&
|
||||||
|
!(*pCol)->node.asParam) {
|
||||||
res = translateColumnUseAlias(pCxt, pCol, &found);
|
res = translateColumnUseAlias(pCxt, pCol, &found);
|
||||||
}
|
}
|
||||||
if (DEAL_RES_ERROR != res && !found) {
|
if (DEAL_RES_ERROR != res && !found) {
|
||||||
|
@ -1752,7 +1787,9 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
|
||||||
res = translateColumnWithoutPrefix(pCxt, pCol);
|
res = translateColumnWithoutPrefix(pCxt, pCol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause && !(*pCol)->node.asParam && res != DEAL_RES_CONTINUE &&
|
if (clauseSupportAlias(pCxt->currClause) &&
|
||||||
|
!(*pCol)->node.asParam &&
|
||||||
|
res != DEAL_RES_CONTINUE &&
|
||||||
res != DEAL_RES_END) {
|
res != DEAL_RES_END) {
|
||||||
res = translateColumnUseAlias(pCxt, pCol, &found);
|
res = translateColumnUseAlias(pCxt, pCol, &found);
|
||||||
}
|
}
|
||||||
|
@ -2954,6 +2991,13 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
pCxt->errCode = getFuncInfo(pCxt, *pFunc);
|
pCxt->errCode = getFuncInfo(pCxt, *pFunc);
|
||||||
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
|
if ((SQL_CLAUSE_GROUP_BY == pCxt->currClause ||
|
||||||
|
SQL_CLAUSE_PARTITION_BY == pCxt->currClause) &&
|
||||||
|
fmIsVectorFunc((*pFunc)->funcId)) {
|
||||||
|
pCxt->errCode = TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
pCxt->errCode = translateFunctionImpl(pCxt, pFunc);
|
pCxt->errCode = translateFunctionImpl(pCxt, pFunc);
|
||||||
}
|
}
|
||||||
|
@ -3439,7 +3483,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList);
|
||||||
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
FOREACH(pPartKey, pSelect->pPartitionByList) {
|
||||||
if (nodesEqualNode(pPartKey, *pNode)) {
|
if (nodesEqualNode(pPartKey, *pNode)) {
|
||||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
return pCxt->currClause == SQL_CLAUSE_HAVING ? DEAL_RES_IGNORE_CHILD : rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||||
}
|
}
|
||||||
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) &&
|
||||||
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) {
|
||||||
|
@ -3658,6 +3702,7 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
if (NULL != pSelect->pHaving) {
|
if (NULL != pSelect->pHaving) {
|
||||||
|
pCxt->currClause = SQL_CLAUSE_HAVING;
|
||||||
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -4939,7 +4984,7 @@ static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
case TSDB_DATA_TYPE_GEOMETRY:
|
case TSDB_DATA_TYPE_GEOMETRY:
|
||||||
return -1;
|
return -1;
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
return (pVal->datum.b ? 1 : 0);
|
return -1;
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
@ -4947,7 +4992,7 @@ static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
return pVal->datum.i;
|
return pVal->datum.i;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
return pVal->datum.d;
|
return -1;
|
||||||
case TSDB_DATA_TYPE_UTINYINT:
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
|
@ -4959,25 +5004,36 @@ static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
static int32_t translateClausePosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pClauseList,
|
||||||
bool* pOther) {
|
bool* pOther) {
|
||||||
*pOther = false;
|
*pOther = false;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
WHERE_EACH(pNode, pOrderByList) {
|
WHERE_EACH(pNode, pClauseList) {
|
||||||
SNode* pExpr = ((SOrderByExprNode*)pNode)->pExpr;
|
SNode* pExpr = NULL;
|
||||||
|
switch (pNode->type) {
|
||||||
|
case QUERY_NODE_GROUPING_SET:
|
||||||
|
pExpr = getGroupByNode(pNode);
|
||||||
|
break;
|
||||||
|
case QUERY_NODE_ORDER_BY_EXPR:
|
||||||
|
pExpr = ((SOrderByExprNode*)pNode)->pExpr;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pExpr = pNode;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (QUERY_NODE_VALUE == nodeType(pExpr)) {
|
if (QUERY_NODE_VALUE == nodeType(pExpr)) {
|
||||||
SValueNode* pVal = (SValueNode*)pExpr;
|
SValueNode* pVal = (SValueNode*)pExpr;
|
||||||
|
pVal->node.asPosition = false;
|
||||||
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
int32_t pos = getPositionValue(pVal);
|
int32_t pos = getPositionValue(pVal);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
ERASE_NODE(pOrderByList);
|
pVal->node.asPosition = false;
|
||||||
continue;
|
|
||||||
} else if (0 == pos || pos > LIST_LENGTH(pProjectionList)) {
|
} else if (0 == pos || pos > LIST_LENGTH(pProjectionList)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT);
|
||||||
} else {
|
} else {
|
||||||
// No longer using SColumnRefNode, processing in replaceOrderByAliasImpl function
|
pVal->node.asPosition = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*pOther = true;
|
*pOther = true;
|
||||||
|
@ -4989,7 +5045,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro
|
||||||
|
|
||||||
static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
bool other;
|
bool other;
|
||||||
int32_t code = translateOrderByPosition(pCxt, pSelect->pProjectionList, pSelect->pOrderByList, &other);
|
int32_t code = translateClausePosition(pCxt, pSelect->pProjectionList, pSelect->pOrderByList, &other);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (0 == LIST_LENGTH(pSelect->pOrderByList)) {
|
if (0 == LIST_LENGTH(pSelect->pOrderByList)) {
|
||||||
NODES_DESTORY_LIST(pSelect->pOrderByList);
|
NODES_DESTORY_LIST(pSelect->pOrderByList);
|
||||||
|
@ -5120,6 +5176,68 @@ static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SReplaceGroupByAliasCxt {
|
||||||
|
STranslateContext* pTranslateCxt;
|
||||||
|
SNodeList* pProjectionList;
|
||||||
|
} SReplaceGroupByAliasCxt;
|
||||||
|
|
||||||
|
static EDealRes replaceGroupByAliasImpl(SNode** pNode, void* pContext) {
|
||||||
|
SReplaceGroupByAliasCxt* pCxt = pContext;
|
||||||
|
SNodeList* pProjectionList = pCxt->pProjectionList;
|
||||||
|
SNode* pProject = NULL;
|
||||||
|
if (QUERY_NODE_VALUE == nodeType(*pNode)) {
|
||||||
|
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
|
||||||
|
SValueNode* pVal = (SValueNode*) *pNode;
|
||||||
|
if (DEAL_RES_ERROR == translateValue(pTransCxt, pVal)) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
if (!pVal->node.asPosition) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
int32_t pos = getPositionValue(pVal);
|
||||||
|
if (0 < pos && pos <= LIST_LENGTH(pProjectionList)) {
|
||||||
|
SNode* pNew = NULL;
|
||||||
|
int32_t code = nodesCloneNode(nodesListGetNode(pProjectionList, pos - 1), (SNode**)&pNew);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
pCxt->pTranslateCxt->errCode = code;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
nodesDestroyNode(*pNode);
|
||||||
|
*pNode = pNew;
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
} else {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
} else if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
|
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
|
||||||
|
return translateColumn(pTransCxt, (SColumnNode**)pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t replaceGroupByAlias(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
if (NULL == pSelect->pGroupByList) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
SReplaceGroupByAliasCxt cxt = {
|
||||||
|
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
||||||
|
nodesRewriteExprsPostOrder(pSelect->pGroupByList, replaceGroupByAliasImpl, &cxt);
|
||||||
|
|
||||||
|
return pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t replacePartitionByAlias(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
if (NULL == pSelect->pPartitionByList) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
SReplaceGroupByAliasCxt cxt = {
|
||||||
|
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
|
||||||
|
nodesRewriteExprsPostOrder(pSelect->pPartitionByList, replaceGroupByAliasImpl, &cxt);
|
||||||
|
|
||||||
|
return pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
pCxt->currClause = SQL_CLAUSE_SELECT;
|
pCxt->currClause = SQL_CLAUSE_SELECT;
|
||||||
int32_t code = translateExprList(pCxt, pSelect->pProjectionList);
|
int32_t code = translateExprList(pCxt, pSelect->pProjectionList);
|
||||||
|
@ -5171,9 +5289,21 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL != pSelect->pWindow) {
|
if (NULL != pSelect->pWindow) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST);
|
||||||
}
|
}
|
||||||
|
bool other;
|
||||||
|
int32_t code = translateClausePosition(pCxt, pSelect->pProjectionList, pSelect->pGroupByList, &other);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (0 == LIST_LENGTH(pSelect->pGroupByList)) {
|
||||||
|
NODES_DESTORY_LIST(pSelect->pGroupByList);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
code = replaceGroupByAlias(pCxt, pSelect);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pCxt->currClause = SQL_CLAUSE_GROUP_BY;
|
pCxt->currClause = SQL_CLAUSE_GROUP_BY;
|
||||||
pSelect->timeLineResMode = TIME_LINE_NONE;
|
pSelect->timeLineResMode = TIME_LINE_NONE;
|
||||||
return translateExprList(pCxt, pSelect->pGroupByList);
|
code = translateExprList(pCxt, pSelect->pGroupByList);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bool* pIsStrict) {
|
static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bool* pIsStrict) {
|
||||||
|
@ -5780,7 +5910,8 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (pSelect->pPartitionByList) {
|
if (pSelect->pPartitionByList) {
|
||||||
code = removeConstantValueFromList(&pSelect->pPartitionByList);
|
bool other;
|
||||||
|
code = translateClausePosition(pCxt, pSelect->pProjectionList, pSelect->pPartitionByList, &other);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && pSelect->pPartitionByList) {
|
if (TSDB_CODE_SUCCESS == code && pSelect->pPartitionByList) {
|
||||||
|
@ -5790,9 +5921,11 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec
|
||||||
(QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
(QUERY_NODE_FUNCTION == nodeType(pPar) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPar)->funcType))) {
|
||||||
pSelect->timeLineResMode = TIME_LINE_MULTI;
|
pSelect->timeLineResMode = TIME_LINE_MULTI;
|
||||||
}
|
}
|
||||||
|
code = replacePartitionByAlias(pCxt, pSelect);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateExprList(pCxt, pSelect->pPartitionByList);
|
code = translateExprList(pCxt, pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateExprList(pCxt, pSelect->pTags);
|
code = translateExprList(pCxt, pSelect->pTags);
|
||||||
}
|
}
|
||||||
|
@ -6518,7 +6651,11 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
code = removeConstantValueFromList(&pSelect->pPartitionByList);
|
code = removeConstantValueFromList(&pSelect->pPartitionByList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
if (pSelect->pGroupByList) {
|
||||||
|
code = removeConstantValueFromList(&pSelect->pGroupByList);
|
||||||
|
}
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6605,7 +6742,7 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
bool other;
|
bool other;
|
||||||
int32_t code = translateOrderByPosition(pCxt, pSetOperator->pProjectionList, pSetOperator->pOrderByList, &other);
|
int32_t code = translateClausePosition(pCxt, pSetOperator->pProjectionList, pSetOperator->pOrderByList, &other);
|
||||||
/*
|
/*
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (other) {
|
if (other) {
|
||||||
|
@ -12977,7 +13114,11 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
||||||
}
|
}
|
||||||
SNode* pCol;
|
SNode* pCol;
|
||||||
col_id_t index = 0;
|
col_id_t index = 0;
|
||||||
tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols);
|
int32_t code = tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
tdDestroySVCreateTbReq(&req);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
FOREACH(pCol, pStmt->pCols) {
|
FOREACH(pCol, pStmt->pCols) {
|
||||||
SColumnDefNode* pColDef = (SColumnDefNode*)pCol;
|
SColumnDefNode* pColDef = (SColumnDefNode*)pCol;
|
||||||
SSchema* pScheam = req.ntb.schemaRow.pSchema + index;
|
SSchema* pScheam = req.ntb.schemaRow.pSchema + index;
|
||||||
|
|
|
@ -44,7 +44,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION:
|
case TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION:
|
||||||
return "There mustn't be aggregation";
|
return "There mustn't be aggregation";
|
||||||
case TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT:
|
case TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT:
|
||||||
return "ORDER BY item must be the number of a SELECT-list expression";
|
return "ORDER BY / GROUP BY item must be the number of a SELECT-list expression";
|
||||||
case TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION:
|
case TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION:
|
||||||
return "Not a GROUP BY expression";
|
return "Not a GROUP BY expression";
|
||||||
case TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION:
|
case TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION:
|
||||||
|
|
|
@ -1176,27 +1176,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
|
|
||||||
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
|
|
||||||
SNode *tnode = NULL;
|
|
||||||
WHERE_EACH(tnode, listNode->pNodeList) {
|
|
||||||
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
|
|
||||||
if (node->opType == OP_TYPE_IN) {
|
|
||||||
ERASE_NODE(listNode->pNodeList);
|
|
||||||
continue;
|
|
||||||
} else { // OP_TYPE_NOT_IN
|
|
||||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WHERE_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listNode->pNodeList->length <= 0) {
|
|
||||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1334,6 +1313,27 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
|
||||||
|
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
|
||||||
|
SNode *tnode = NULL;
|
||||||
|
WHERE_EACH(tnode, listNode->pNodeList) {
|
||||||
|
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
|
||||||
|
if (node->opType == OP_TYPE_IN) {
|
||||||
|
ERASE_NODE(listNode->pNodeList);
|
||||||
|
continue;
|
||||||
|
} else { // OP_TYPE_NOT_IN
|
||||||
|
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHERE_NEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listNode->pNodeList->length <= 0) {
|
||||||
|
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
||||||
return sclRewriteNonConstOperator(pNode, ctx);
|
return sclRewriteNonConstOperator(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,7 +793,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut,
|
||||||
return vectorConvertFromVarData(&cCtx, overflow);
|
return vectorConvertFromVarData(&cCtx, overflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow) {
|
if (overflow && TSDB_DATA_TYPE_NULL != cCtx.inType) {
|
||||||
if (1 != pIn->numOfRows) {
|
if (1 != pIn->numOfRows) {
|
||||||
sclError("invalid numOfRows %d", pIn->numOfRows);
|
sclError("invalid numOfRows %d", pIn->numOfRows);
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
|
|
@ -424,7 +424,7 @@ void cleanDir(const char* pPath, const char* id) {
|
||||||
|
|
||||||
if (taosIsDir(pPath)) {
|
if (taosIsDir(pPath)) {
|
||||||
taosRemoveDir(pPath);
|
taosRemoveDir(pPath);
|
||||||
taosMkDir(pPath);
|
(void)taosMkDir(pPath);
|
||||||
stInfo("%s clear dir:%s, succ", id, pPath);
|
stInfo("%s clear dir:%s, succ", id, pPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId
|
||||||
_EXIT:
|
_EXIT:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
if (rename) {
|
if (rename) {
|
||||||
taosRenameFile(defaultTmp, defaultPath);
|
(void)taosRenameFile(defaultTmp, defaultPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,13 +652,13 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) {
|
||||||
|
|
||||||
taosMemoryFreeClear(srcName);
|
taosMemoryFreeClear(srcName);
|
||||||
taosMemoryFreeClear(dstName);
|
taosMemoryFreeClear(dstName);
|
||||||
taosCloseDir(&pDir);
|
(void)taosCloseDir(&pDir);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_ERROR:
|
_ERROR:
|
||||||
taosMemoryFreeClear(srcName);
|
taosMemoryFreeClear(srcName);
|
||||||
taosMemoryFreeClear(dstName);
|
taosMemoryFreeClear(dstName);
|
||||||
taosCloseDir(&pDir);
|
(void)taosCloseDir(&pDir);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,8 +820,8 @@ void* streamBackendInit(const char* streamPath, int64_t chkpId, int32_t vgId) {
|
||||||
uint32_t dbMemLimit = nextPow2(tsMaxStreamBackendCache) << 20;
|
uint32_t dbMemLimit = nextPow2(tsMaxStreamBackendCache) << 20;
|
||||||
SBackendWrapper* pHandle = taosMemoryCalloc(1, sizeof(SBackendWrapper));
|
SBackendWrapper* pHandle = taosMemoryCalloc(1, sizeof(SBackendWrapper));
|
||||||
pHandle->list = tdListNew(sizeof(SCfComparator));
|
pHandle->list = tdListNew(sizeof(SCfComparator));
|
||||||
taosThreadMutexInit(&pHandle->mutex, NULL);
|
(void)taosThreadMutexInit(&pHandle->mutex, NULL);
|
||||||
taosThreadMutexInit(&pHandle->cfMutex, NULL);
|
(void)taosThreadMutexInit(&pHandle->cfMutex, NULL);
|
||||||
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
rocksdb_env_t* env = rocksdb_create_default_env(); // rocksdb_envoptions_create();
|
rocksdb_env_t* env = rocksdb_create_default_env(); // rocksdb_envoptions_create();
|
||||||
|
@ -890,7 +890,7 @@ _EXIT:
|
||||||
streamMutexDestroy(&pHandle->mutex);
|
streamMutexDestroy(&pHandle->mutex);
|
||||||
streamMutexDestroy(&pHandle->cfMutex);
|
streamMutexDestroy(&pHandle->cfMutex);
|
||||||
taosHashCleanup(pHandle->cfInst);
|
taosHashCleanup(pHandle->cfInst);
|
||||||
tdListFree(pHandle->list);
|
(void)tdListFree(pHandle->list);
|
||||||
taosMemoryFree(pHandle);
|
taosMemoryFree(pHandle);
|
||||||
stDebug("failed to init stream backend at %s", backendPath);
|
stDebug("failed to init stream backend at %s", backendPath);
|
||||||
taosMemoryFree(backendPath);
|
taosMemoryFree(backendPath);
|
||||||
|
@ -922,7 +922,7 @@ void streamBackendCleanup(void* arg) {
|
||||||
head = tdListPopHead(pHandle->list);
|
head = tdListPopHead(pHandle->list);
|
||||||
}
|
}
|
||||||
|
|
||||||
tdListFree(pHandle->list);
|
(void)tdListFree(pHandle->list);
|
||||||
streamMutexDestroy(&pHandle->mutex);
|
streamMutexDestroy(&pHandle->mutex);
|
||||||
|
|
||||||
streamMutexDestroy(&pHandle->cfMutex);
|
streamMutexDestroy(&pHandle->cfMutex);
|
||||||
|
@ -933,11 +933,11 @@ void streamBackendCleanup(void* arg) {
|
||||||
void streamBackendHandleCleanup(void* arg) {
|
void streamBackendHandleCleanup(void* arg) {
|
||||||
SBackendCfWrapper* wrapper = arg;
|
SBackendCfWrapper* wrapper = arg;
|
||||||
bool remove = wrapper->remove;
|
bool remove = wrapper->remove;
|
||||||
taosThreadRwlockWrlock(&wrapper->rwLock);
|
(void)taosThreadRwlockWrlock(&wrapper->rwLock);
|
||||||
|
|
||||||
stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr);
|
stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr);
|
||||||
if (wrapper->rocksdb == NULL) {
|
if (wrapper->rocksdb == NULL) {
|
||||||
taosThreadRwlockUnlock(&wrapper->rwLock);
|
(void)taosThreadRwlockUnlock(&wrapper->rwLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,9 +988,9 @@ void streamBackendHandleCleanup(void* arg) {
|
||||||
wrapper->readOpts = NULL;
|
wrapper->readOpts = NULL;
|
||||||
taosMemoryFreeClear(wrapper->cfOpts);
|
taosMemoryFreeClear(wrapper->cfOpts);
|
||||||
taosMemoryFreeClear(wrapper->param);
|
taosMemoryFreeClear(wrapper->param);
|
||||||
taosThreadRwlockUnlock(&wrapper->rwLock);
|
(void)taosThreadRwlockUnlock(&wrapper->rwLock);
|
||||||
|
|
||||||
taosThreadRwlockDestroy(&wrapper->rwLock);
|
(void)taosThreadRwlockDestroy(&wrapper->rwLock);
|
||||||
wrapper->rocksdb = NULL;
|
wrapper->rocksdb = NULL;
|
||||||
// taosReleaseRef(streamBackendId, wrapper->backendId);
|
// taosReleaseRef(streamBackendId, wrapper->backendId);
|
||||||
|
|
||||||
|
@ -1083,12 +1083,20 @@ int32_t delObsoleteCheckpoint(void* arg, const char* path) {
|
||||||
int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
||||||
STaskDbWrapper* pBackend = arg;
|
STaskDbWrapper* pBackend = arg;
|
||||||
|
|
||||||
taosThreadRwlockWrlock(&pBackend->chkpDirLock);
|
(void)taosThreadRwlockWrlock(&pBackend->chkpDirLock);
|
||||||
|
|
||||||
taosArrayPush(pBackend->chkpSaved, &chkpId);
|
(void)taosArrayPush(pBackend->chkpSaved, &chkpId);
|
||||||
|
|
||||||
SArray* chkpDel = taosArrayInit(8, sizeof(int64_t));
|
SArray* chkpDel = taosArrayInit(8, sizeof(int64_t));
|
||||||
|
if (chkpDel == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
SArray* chkpDup = taosArrayInit(8, sizeof(int64_t));
|
SArray* chkpDup = taosArrayInit(8, sizeof(int64_t));
|
||||||
|
if (chkpDup == NULL) {
|
||||||
|
taosArrayDestroy(chkpDel);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t firsId = 0;
|
int64_t firsId = 0;
|
||||||
if (taosArrayGetSize(pBackend->chkpInUse) >= 1) {
|
if (taosArrayGetSize(pBackend->chkpInUse) >= 1) {
|
||||||
|
@ -1097,9 +1105,9 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
||||||
for (int i = 0; i < taosArrayGetSize(pBackend->chkpSaved); i++) {
|
for (int i = 0; i < taosArrayGetSize(pBackend->chkpSaved); i++) {
|
||||||
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
||||||
if (id >= firsId) {
|
if (id >= firsId) {
|
||||||
taosArrayPush(chkpDup, &id);
|
(void)taosArrayPush(chkpDup, &id);
|
||||||
} else {
|
} else {
|
||||||
taosArrayPush(chkpDel, &id);
|
(void)taosArrayPush(chkpDel, &id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1108,17 +1116,17 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
||||||
|
|
||||||
for (int i = 0; i < dsz; i++) {
|
for (int i = 0; i < dsz; i++) {
|
||||||
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
||||||
taosArrayPush(chkpDel, &id);
|
(void)taosArrayPush(chkpDel, &id);
|
||||||
}
|
}
|
||||||
for (int i = dsz < 0 ? 0 : dsz; i < sz; i++) {
|
for (int i = dsz < 0 ? 0 : dsz; i < sz; i++) {
|
||||||
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i);
|
||||||
taosArrayPush(chkpDup, &id);
|
(void)taosArrayPush(chkpDup, &id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pBackend->chkpSaved);
|
taosArrayDestroy(pBackend->chkpSaved);
|
||||||
pBackend->chkpSaved = chkpDup;
|
pBackend->chkpSaved = chkpDup;
|
||||||
|
|
||||||
taosThreadRwlockUnlock(&pBackend->chkpDirLock);
|
(void)taosThreadRwlockUnlock(&pBackend->chkpDirLock);
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(chkpDel); i++) {
|
for (int i = 0; i < taosArrayGetSize(chkpDel); i++) {
|
||||||
int64_t id = *(int64_t*)taosArrayGet(chkpDel, i);
|
int64_t id = *(int64_t*)taosArrayGet(chkpDel, i);
|
||||||
|
@ -1263,7 +1271,7 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) {
|
||||||
|
|
||||||
int ret = sscanf(taosGetDirEntryName(de), "checkpoint%" PRId64 "", &checkpointId);
|
int ret = sscanf(taosGetDirEntryName(de), "checkpoint%" PRId64 "", &checkpointId);
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
taosArrayPush(pBackend->chkpSaved, &checkpointId);
|
(void)taosArrayPush(pBackend->chkpSaved, &checkpointId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1272,7 +1280,7 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) {
|
||||||
taosArraySort(pBackend->chkpSaved, chkpIdComp);
|
taosArraySort(pBackend->chkpSaved, chkpIdComp);
|
||||||
|
|
||||||
taosMemoryFree(pChkpDir);
|
taosMemoryFree(pChkpDir);
|
||||||
taosCloseDir(&pDir);
|
(void)taosCloseDir(&pDir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1281,7 +1289,7 @@ int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_ha
|
||||||
for (int i = 0; i < sizeof(ginitDict) / sizeof(ginitDict[0]); i++) {
|
for (int i = 0; i < sizeof(ginitDict) / sizeof(ginitDict[0]); i++) {
|
||||||
if (pBackend->pCf[i]) {
|
if (pBackend->pCf[i]) {
|
||||||
rocksdb_column_family_handle_t* p = pBackend->pCf[i];
|
rocksdb_column_family_handle_t* p = pBackend->pCf[i];
|
||||||
taosArrayPush(pHandle, &p);
|
(void)taosArrayPush(pHandle, &p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t nCf = taosArrayGetSize(pHandle);
|
int32_t nCf = taosArrayGetSize(pHandle);
|
||||||
|
@ -1430,7 +1438,7 @@ int32_t taskDbBuildSnap(void* arg, SArray* pSnap) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosArrayPush(pSnap, &snap);
|
(void)taosArrayPush(pSnap, &snap);
|
||||||
|
|
||||||
pIter = taosHashIterate(pMeta->pTaskDbUnique, pIter);
|
pIter = taosHashIterate(pMeta->pTaskDbUnique, pIter);
|
||||||
}
|
}
|
||||||
|
@ -1497,7 +1505,7 @@ void* taskAcquireDb(int64_t refId) {
|
||||||
}
|
}
|
||||||
void taskReleaseDb(int64_t refId) {
|
void taskReleaseDb(int64_t refId) {
|
||||||
// release
|
// release
|
||||||
taosReleaseRef(taskDbWrapperId, refId);
|
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taskGetDBRef(void* arg) {
|
int64_t taskGetDBRef(void* arg) {
|
||||||
|
@ -1558,7 +1566,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
|
||||||
code = 0;
|
code = 0;
|
||||||
_EXIT:
|
_EXIT:
|
||||||
taosMemoryFree(pDst);
|
taosMemoryFree(pDst);
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
||||||
|
@ -1613,7 +1621,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_EXIT:
|
_EXIT:
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
taosMemoryFree(pDst);
|
taosMemoryFree(pDst);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1671,7 +1679,7 @@ int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId) {
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_store_64(&pTaskDb->dataWritten, 0);
|
(void)atomic_store_64(&pTaskDb->dataWritten, 0);
|
||||||
pTaskDb->chkpId = chkpId;
|
pTaskDb->chkpId = chkpId;
|
||||||
|
|
||||||
_EXIT:
|
_EXIT:
|
||||||
|
@ -1679,13 +1687,13 @@ _EXIT:
|
||||||
// clear checkpoint dir if failed
|
// clear checkpoint dir if failed
|
||||||
if (code != 0 && pChkpDir != NULL) {
|
if (code != 0 && pChkpDir != NULL) {
|
||||||
if (taosDirExist(pChkpIdDir)) {
|
if (taosDirExist(pChkpIdDir)) {
|
||||||
taosRemoveDir(pChkpIdDir);
|
(void)taosRemoveDir(pChkpIdDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(pChkpIdDir);
|
taosMemoryFree(pChkpIdDir);
|
||||||
taosMemoryFree(pChkpDir);
|
taosMemoryFree(pChkpDir);
|
||||||
|
|
||||||
taosReleaseRef(taskDbWrapperId, refId);
|
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||||
taosMemoryFree(ppCf);
|
taosMemoryFree(ppCf);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1758,7 +1766,7 @@ int defaultKeyComp(void* state, const char* aBuf, size_t aLen, const char* bBuf,
|
||||||
}
|
}
|
||||||
int streamStateValueIsStale(char* v) {
|
int streamStateValueIsStale(char* v) {
|
||||||
int64_t ts = 0;
|
int64_t ts = 0;
|
||||||
taosDecodeFixedI64(v, &ts);
|
(void)taosDecodeFixedI64(v, &ts);
|
||||||
return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0;
|
return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0;
|
||||||
}
|
}
|
||||||
int iterValueIsStale(rocksdb_iterator_t* iter) {
|
int iterValueIsStale(rocksdb_iterator_t* iter) {
|
||||||
|
@ -1801,8 +1809,8 @@ int stateKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf,
|
||||||
p1 = taosDecodeFixedI64(p1, &key1.key.ts);
|
p1 = taosDecodeFixedI64(p1, &key1.key.ts);
|
||||||
p2 = taosDecodeFixedI64(p2, &key2.key.ts);
|
p2 = taosDecodeFixedI64(p2, &key2.key.ts);
|
||||||
|
|
||||||
taosDecodeFixedI64(p1, &key1.opNum);
|
(void)taosDecodeFixedI64(p1, &key1.opNum);
|
||||||
taosDecodeFixedI64(p2, &key2.opNum);
|
(void)taosDecodeFixedI64(p2, &key2.opNum);
|
||||||
|
|
||||||
return stateKeyCmpr(&key1, sizeof(key1), &key2, sizeof(key2));
|
return stateKeyCmpr(&key1, sizeof(key1), &key2, sizeof(key2));
|
||||||
}
|
}
|
||||||
|
@ -1998,8 +2006,8 @@ int parKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf, s
|
||||||
char* p1 = (char*)aBuf;
|
char* p1 = (char*)aBuf;
|
||||||
char* p2 = (char*)bBuf;
|
char* p2 = (char*)bBuf;
|
||||||
|
|
||||||
taosDecodeFixedI64(p1, &w1);
|
(void)taosDecodeFixedI64(p1, &w1);
|
||||||
taosDecodeFixedI64(p2, &w2);
|
(void)taosDecodeFixedI64(p2, &w2);
|
||||||
if (w1 == w2) {
|
if (w1 == w2) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2320,7 +2328,7 @@ void taskDbRemoveRef(void* pTaskDb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskDbWrapper* pBackend = pTaskDb;
|
STaskDbWrapper* pBackend = pTaskDb;
|
||||||
taosReleaseRef(taskDbWrapperId, pBackend->refId);
|
(void)taosReleaseRef(taskDbWrapperId, pBackend->refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskDbInitOpt(STaskDbWrapper* pTaskDb) {
|
void taskDbInitOpt(STaskDbWrapper* pTaskDb) {
|
||||||
|
@ -2386,22 +2394,22 @@ void taskDbInitChkpOpt(STaskDbWrapper* pTaskDb) {
|
||||||
pTaskDb->chkpId = -1;
|
pTaskDb->chkpId = -1;
|
||||||
pTaskDb->chkpCap = 4;
|
pTaskDb->chkpCap = 4;
|
||||||
pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t));
|
pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t));
|
||||||
taskDbLoadChkpInfo(pTaskDb);
|
(void)taskDbLoadChkpInfo(pTaskDb);
|
||||||
|
|
||||||
pTaskDb->chkpInUse = taosArrayInit(4, sizeof(int64_t));
|
pTaskDb->chkpInUse = taosArrayInit(4, sizeof(int64_t));
|
||||||
|
|
||||||
taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL);
|
(void)taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskDbRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
void taskDbRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
||||||
taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
(void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
||||||
taosArrayPush(pTaskDb->chkpInUse, &chkp);
|
(void)taosArrayPush(pTaskDb->chkpInUse, &chkp);
|
||||||
taosArraySort(pTaskDb->chkpInUse, chkpIdComp);
|
taosArraySort(pTaskDb->chkpInUse, chkpIdComp);
|
||||||
taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
||||||
taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
(void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
||||||
int32_t size = taosArrayGetSize(pTaskDb->chkpInUse);
|
int32_t size = taosArrayGetSize(pTaskDb->chkpInUse);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i);
|
int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i);
|
||||||
|
@ -2410,13 +2418,13 @@ void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) {
|
void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) {
|
||||||
taosArrayDestroy(pTaskDb->chkpSaved);
|
taosArrayDestroy(pTaskDb->chkpSaved);
|
||||||
taosArrayDestroy(pTaskDb->chkpInUse);
|
taosArrayDestroy(pTaskDb->chkpInUse);
|
||||||
taosThreadRwlockDestroy(&pTaskDb->chkpDirLock);
|
(void)taosThreadRwlockDestroy(&pTaskDb->chkpDirLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** stateFullPath) {
|
int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** stateFullPath) {
|
||||||
|
@ -2462,9 +2470,9 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta
|
||||||
|
|
||||||
void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId) {
|
void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId) {
|
||||||
STaskDbWrapper* p = pTaskDb;
|
STaskDbWrapper* p = pTaskDb;
|
||||||
streamMutexLock(&p->mutex);
|
(void)streamMutexLock(&p->mutex);
|
||||||
p->chkpId = chkpId;
|
p->chkpId = chkpId;
|
||||||
streamMutexUnlock(&p->mutex);
|
(void)streamMutexUnlock(&p->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) {
|
STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) {
|
||||||
|
@ -2476,7 +2484,7 @@ STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) {
|
||||||
pTaskDb->idstr = key ? taosStrdup(key) : NULL;
|
pTaskDb->idstr = key ? taosStrdup(key) : NULL;
|
||||||
pTaskDb->path = statePath ? taosStrdup(statePath) : NULL;
|
pTaskDb->path = statePath ? taosStrdup(statePath) : NULL;
|
||||||
|
|
||||||
taosThreadMutexInit(&pTaskDb->mutex, NULL);
|
(void)taosThreadMutexInit(&pTaskDb->mutex, NULL);
|
||||||
taskDbInitChkpOpt(pTaskDb);
|
taskDbInitChkpOpt(pTaskDb);
|
||||||
taskDbInitOpt(pTaskDb);
|
taskDbInitOpt(pTaskDb);
|
||||||
|
|
||||||
|
@ -2650,7 +2658,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
||||||
|
|
||||||
char* buf = taosMemoryCalloc(1, cap);
|
char* buf = taosMemoryCalloc(1, cap);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
taosReleaseRef(taskDbWrapperId, refId);
|
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2658,7 +2666,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
||||||
snprintf(buf, cap, "%s%s%s%s%s%" PRId64 "", pDb->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, "checkpoint", chkpId);
|
snprintf(buf, cap, "%s%s%s%s%s%" PRId64 "", pDb->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, "checkpoint", chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosReleaseRef(taskDbWrapperId, refId);
|
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2669,7 +2677,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosReleaseRef(taskDbWrapperId, refId);
|
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2906,7 +2914,7 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
|
||||||
|
|
||||||
inst->dbOpt = handle->dbOpt;
|
inst->dbOpt = handle->dbOpt;
|
||||||
rocksdb_writeoptions_disable_WAL(inst->wOpt, 1);
|
rocksdb_writeoptions_disable_WAL(inst->wOpt, 1);
|
||||||
taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*));
|
(void)taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*));
|
||||||
} else {
|
} else {
|
||||||
inst = *pInst;
|
inst = *pInst;
|
||||||
}
|
}
|
||||||
|
@ -3146,9 +3154,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1); \
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \
|
||||||
char toString[128] = {0}; \
|
char toString[128] = {0}; \
|
||||||
if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
|
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \
|
||||||
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
||||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||||
rocksdb_writeoptions_t* opts = wrapper->writeOpt; \
|
rocksdb_writeoptions_t* opts = wrapper->writeOpt; \
|
||||||
|
@ -3180,7 +3188,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
|
||||||
} \
|
} \
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
||||||
char toString[128] = {0}; \
|
char toString[128] = {0}; \
|
||||||
if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
|
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \
|
||||||
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
||||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||||
rocksdb_t* db = wrapper->db; \
|
rocksdb_t* db = wrapper->db; \
|
||||||
|
@ -3223,9 +3231,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1); \
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \
|
||||||
char toString[128] = {0}; \
|
char toString[128] = {0}; \
|
||||||
if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
|
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \
|
||||||
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
|
||||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||||
rocksdb_t* db = wrapper->db; \
|
rocksdb_t* db = wrapper->db; \
|
||||||
|
@ -3264,7 +3272,7 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
||||||
stDebug("streamStateClear_rocksdb");
|
stDebug("streamStateClear_rocksdb");
|
||||||
|
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
||||||
|
|
||||||
char sKeyStr[128] = {0};
|
char sKeyStr[128] = {0};
|
||||||
char eKeyStr[128] = {0};
|
char eKeyStr[128] = {0};
|
||||||
|
@ -3280,8 +3288,8 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
char toStringStart[128] = {0};
|
char toStringStart[128] = {0};
|
||||||
char toStringEnd[128] = {0};
|
char toStringEnd[128] = {0};
|
||||||
stateKeyToString(&sKey, toStringStart);
|
(void)stateKeyToString(&sKey, toStringStart);
|
||||||
stateKeyToString(&eKey, toStringEnd);
|
(void)stateKeyToString(&eKey, toStringEnd);
|
||||||
|
|
||||||
stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
|
stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
|
||||||
taosMemoryFree(err);
|
taosMemoryFree(err);
|
||||||
|
@ -3298,16 +3306,22 @@ void streamStateCurNext_rocksdb(SStreamStateCur* pCur) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t streamStateGetFirst_rocksdb(SStreamState* pState, SWinKey* key) {
|
int32_t streamStateGetFirst_rocksdb(SStreamState* pState, SWinKey* key) {
|
||||||
|
int code = 0;
|
||||||
stDebug("streamStateGetFirst_rocksdb");
|
stDebug("streamStateGetFirst_rocksdb");
|
||||||
SWinKey tmp = {.ts = 0, .groupId = 0};
|
SWinKey tmp = {.ts = 0, .groupId = 0};
|
||||||
streamStatePut_rocksdb(pState, &tmp, NULL, 0);
|
code = streamStatePut_rocksdb(pState, &tmp, NULL, 0);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SStreamStateCur* pCur = streamStateSeekKeyNext_rocksdb(pState, &tmp);
|
SStreamStateCur* pCur = streamStateSeekKeyNext_rocksdb(pState, &tmp);
|
||||||
int32_t code = streamStateGetKVByCur_rocksdb(pCur, key, NULL, 0);
|
code = streamStateGetKVByCur_rocksdb(pCur, key, NULL, 0);
|
||||||
streamStateFreeCur(pCur);
|
if (code != 0) {
|
||||||
streamStateDel_rocksdb(pState, &tmp);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
streamStateFreeCur(pCur);
|
||||||
|
return streamStateDel_rocksdb(pState, &tmp);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t streamStateGetGroupKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) {
|
int32_t streamStateGetGroupKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) {
|
||||||
stDebug("streamStateGetGroupKVByCur_rocksdb");
|
stDebug("streamStateGetGroupKVByCur_rocksdb");
|
||||||
|
@ -3335,6 +3349,9 @@ int32_t streamStateAddIfNotExist_rocksdb(SStreamState* pState, const SWinKey* ke
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*pVal = taosMemoryMalloc(size);
|
*pVal = taosMemoryMalloc(size);
|
||||||
|
if (*pVal == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
memset(*pVal, 0, size);
|
memset(*pVal, 0, size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3351,7 +3368,7 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons
|
||||||
if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) {
|
if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) {
|
||||||
size_t tlen;
|
size_t tlen;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen);
|
||||||
stateKeyDecode((void*)pKtmp, keyStr);
|
(void)stateKeyDecode((void*)pKtmp, keyStr);
|
||||||
if (pKtmp->opNum != pCur->number) {
|
if (pKtmp->opNum != pCur->number) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -3404,7 +3421,7 @@ SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWin
|
||||||
SStateKey curKey;
|
SStateKey curKey;
|
||||||
size_t kLen;
|
size_t kLen;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
||||||
stateKeyDecode((void*)&curKey, keyStr);
|
(void)stateKeyDecode((void*)&curKey, keyStr);
|
||||||
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) {
|
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) {
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
|
@ -3426,7 +3443,7 @@ SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) {
|
||||||
|
|
||||||
{
|
{
|
||||||
char tbuf[256] = {0};
|
char tbuf[256] = {0};
|
||||||
stateKeyToString((void*)&maxStateKey, tbuf);
|
(void)stateKeyToString((void*)&maxStateKey, tbuf);
|
||||||
stDebug("seek to last:%s", tbuf);
|
stDebug("seek to last:%s", tbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3476,7 +3493,7 @@ SStreamStateCur* streamStateGetCur_rocksdb(SStreamState* pState, const SWinKey*
|
||||||
SStateKey curKey;
|
SStateKey curKey;
|
||||||
size_t kLen = 0;
|
size_t kLen = 0;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
||||||
stateKeyDecode((void*)&curKey, keyStr);
|
(void)stateKeyDecode((void*)&curKey, keyStr);
|
||||||
|
|
||||||
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) == 0) {
|
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) == 0) {
|
||||||
pCur->number = pState->number;
|
pCur->number = pState->number;
|
||||||
|
@ -3624,7 +3641,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pSta
|
||||||
size_t klen;
|
size_t klen;
|
||||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||||
SStateSessionKey curKey = {0};
|
SStateSessionKey curKey = {0};
|
||||||
stateSessionKeyDecode(&curKey, (char*)iKey);
|
(void)stateSessionKeyDecode(&curKey, (char*)iKey);
|
||||||
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) >= 0) return pCur;
|
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) >= 0) return pCur;
|
||||||
|
|
||||||
rocksdb_iter_prev(pCur->iter);
|
rocksdb_iter_prev(pCur->iter);
|
||||||
|
@ -3661,7 +3678,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pSta
|
||||||
size_t klen;
|
size_t klen;
|
||||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||||
SStateSessionKey curKey = {0};
|
SStateSessionKey curKey = {0};
|
||||||
stateSessionKeyDecode(&curKey, (char*)iKey);
|
(void)stateSessionKeyDecode(&curKey, (char*)iKey);
|
||||||
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) <= 0) return pCur;
|
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) <= 0) return pCur;
|
||||||
|
|
||||||
rocksdb_iter_next(pCur->iter);
|
rocksdb_iter_next(pCur->iter);
|
||||||
|
@ -3701,7 +3718,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con
|
||||||
size_t klen;
|
size_t klen;
|
||||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||||
SStateSessionKey curKey = {0};
|
SStateSessionKey curKey = {0};
|
||||||
stateSessionKeyDecode(&curKey, (char*)iKey);
|
(void)stateSessionKeyDecode(&curKey, (char*)iKey);
|
||||||
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) < 0) return pCur;
|
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) < 0) return pCur;
|
||||||
|
|
||||||
rocksdb_iter_next(pCur->iter);
|
rocksdb_iter_next(pCur->iter);
|
||||||
|
@ -3741,7 +3758,7 @@ SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, con
|
||||||
size_t klen;
|
size_t klen;
|
||||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||||
SStateSessionKey curKey = {0};
|
SStateSessionKey curKey = {0};
|
||||||
stateSessionKeyDecode(&curKey, (char*)iKey);
|
(void)stateSessionKeyDecode(&curKey, (char*)iKey);
|
||||||
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur;
|
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur;
|
||||||
|
|
||||||
rocksdb_iter_prev(pCur->iter);
|
rocksdb_iter_prev(pCur->iter);
|
||||||
|
@ -3764,7 +3781,7 @@ int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey*
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const char* curKey = rocksdb_iter_key(pCur->iter, (size_t*)&kLen);
|
const char* curKey = rocksdb_iter_key(pCur->iter, (size_t*)&kLen);
|
||||||
stateSessionKeyDecode((void*)&ktmp, (char*)curKey);
|
(void)stateSessionKeyDecode((void*)&ktmp, (char*)curKey);
|
||||||
|
|
||||||
if (pVal != NULL) *pVal = NULL;
|
if (pVal != NULL) *pVal = NULL;
|
||||||
if (pVLen != NULL) *pVLen = 0;
|
if (pVLen != NULL) *pVLen = 0;
|
||||||
|
@ -3843,7 +3860,7 @@ SStreamStateCur* streamStateFillGetCur_rocksdb(SStreamState* pState, const SWinK
|
||||||
size_t kLen;
|
size_t kLen;
|
||||||
SWinKey curKey;
|
SWinKey curKey;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
||||||
winKeyDecode((void*)&curKey, keyStr);
|
(void)winKeyDecode((void*)&curKey, keyStr);
|
||||||
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) == 0) {
|
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) == 0) {
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
|
@ -3863,7 +3880,7 @@ int32_t streamStateFillGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey,
|
||||||
}
|
}
|
||||||
size_t klen, vlen;
|
size_t klen, vlen;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &klen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &klen);
|
||||||
winKeyDecode(&winKey, keyStr);
|
(void)winKeyDecode(&winKey, keyStr);
|
||||||
|
|
||||||
const char* valStr = rocksdb_iter_value(pCur->iter, &vlen);
|
const char* valStr = rocksdb_iter_value(pCur->iter, &vlen);
|
||||||
int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal);
|
int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal);
|
||||||
|
@ -3904,7 +3921,7 @@ SStreamStateCur* streamStateFillSeekKeyNext_rocksdb(SStreamState* pState, const
|
||||||
SWinKey curKey;
|
SWinKey curKey;
|
||||||
size_t kLen = 0;
|
size_t kLen = 0;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
||||||
winKeyDecode((void*)&curKey, keyStr);
|
(void)winKeyDecode((void*)&curKey, keyStr);
|
||||||
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) < 0) {
|
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) < 0) {
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
|
@ -3941,7 +3958,7 @@ SStreamStateCur* streamStateFillSeekKeyPrev_rocksdb(SStreamState* pState, const
|
||||||
SWinKey curKey;
|
SWinKey curKey;
|
||||||
size_t kLen = 0;
|
size_t kLen = 0;
|
||||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
|
||||||
winKeyDecode((void*)&curKey, keyStr);
|
(void)winKeyDecode((void*)&curKey, keyStr);
|
||||||
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) > 0) {
|
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) > 0) {
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
|
@ -4024,10 +4041,11 @@ int32_t streamStateSessionAddIfNotExist_rocksdb(SStreamState* pState, SSessionKe
|
||||||
int32_t valSize = *pVLen;
|
int32_t valSize = *pVLen;
|
||||||
|
|
||||||
void* tmp = taosMemoryMalloc(valSize);
|
void* tmp = taosMemoryMalloc(valSize);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key);
|
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key);
|
||||||
if (pCur == NULL) {
|
|
||||||
}
|
|
||||||
int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, key, pVal, pVLen);
|
int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, key, pVal, pVLen);
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -4076,7 +4094,7 @@ void streamStateSessionClear_rocksdb(SStreamState* pState) {
|
||||||
if (code == 0 && size > 0) {
|
if (code == 0 && size > 0) {
|
||||||
memset(buf, 0, size);
|
memset(buf, 0, size);
|
||||||
// refactor later
|
// refactor later
|
||||||
streamStateSessionPut_rocksdb(pState, &delKey, buf, size);
|
(void)streamStateSessionPut_rocksdb(pState, &delKey, buf, size);
|
||||||
} else {
|
} else {
|
||||||
taosMemoryFreeClear(buf);
|
taosMemoryFreeClear(buf);
|
||||||
break;
|
break;
|
||||||
|
@ -4214,7 +4232,7 @@ int32_t streamDefaultIterGet_rocksdb(SStreamState* pState, const void* start, co
|
||||||
if (strncmp(key, start, strlen(start)) == 0 && strlen(key) >= strlen(start) + 1) {
|
if (strncmp(key, start, strlen(start)) == 0 && strlen(key) >= strlen(start) + 1) {
|
||||||
int64_t checkPoint = 0;
|
int64_t checkPoint = 0;
|
||||||
if (sscanf(key + strlen(key), ":%" PRId64 "", &checkPoint) == 1) {
|
if (sscanf(key + strlen(key), ":%" PRId64 "", &checkPoint) == 1) {
|
||||||
taosArrayPush(result, &checkPoint);
|
(void)taosArrayPush(result, &checkPoint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -4286,7 +4304,7 @@ void streamStateDestroyBatch(void* pBatch) { rocksdb_writebatch_destroy((rock
|
||||||
int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb_writebatch_t* pBatch, void* key,
|
int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb_writebatch_t* pBatch, void* key,
|
||||||
void* val, int32_t vlen, int64_t ttl) {
|
void* val, int32_t vlen, int64_t ttl) {
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
||||||
|
|
||||||
int i = streamStateGetCfIdx(pState, cfKeyName);
|
int i = streamStateGetCfIdx(pState, cfKeyName);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
|
@ -4306,7 +4324,7 @@ int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb
|
||||||
|
|
||||||
{
|
{
|
||||||
char tbuf[256] = {0};
|
char tbuf[256] = {0};
|
||||||
ginitDict[i].toStrFunc((void*)key, tbuf);
|
(void)(ginitDict[i].toStrFunc((void*)key, tbuf));
|
||||||
stTrace("streamState str: %s succ to write to %s_%s, len: %d", tbuf, wrapper->idstr, ginitDict[i].key, vlen);
|
stTrace("streamState str: %s succ to write to %s_%s, len: %d", tbuf, wrapper->idstr, ginitDict[i].key, vlen);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4321,7 +4339,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
|
||||||
|
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||||
|
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
||||||
|
|
||||||
rocksdb_column_family_handle_t* pCf = wrapper->pCf[ginitDict[cfIdx].idx];
|
rocksdb_column_family_handle_t* pCf = wrapper->pCf[ginitDict[cfIdx].idx];
|
||||||
rocksdb_writebatch_put_cf((rocksdb_writebatch_t*)pBatch, pCf, buf, (size_t)klen, ttlV, (size_t)ttlVLen);
|
rocksdb_writebatch_put_cf((rocksdb_writebatch_t*)pBatch, pCf, buf, (size_t)klen, ttlV, (size_t)ttlVLen);
|
||||||
|
@ -4332,7 +4350,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
|
||||||
|
|
||||||
{
|
{
|
||||||
char tbuf[256] = {0};
|
char tbuf[256] = {0};
|
||||||
ginitDict[cfIdx].toStrFunc((void*)key, tbuf);
|
(void)(ginitDict[cfIdx].toStrFunc((void*)key, tbuf));
|
||||||
stTrace("streamState str: %s succ to write to %s_%s", tbuf, wrapper->idstr, ginitDict[cfIdx].key);
|
stTrace("streamState str: %s succ to write to %s_%s", tbuf, wrapper->idstr, ginitDict[cfIdx].key);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4340,7 +4358,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
|
||||||
int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) {
|
int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) {
|
||||||
char* err = NULL;
|
char* err = NULL;
|
||||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||||
atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1);
|
||||||
rocksdb_write(wrapper->db, wrapper->writeOpt, (rocksdb_writebatch_t*)pBatch, &err);
|
rocksdb_write(wrapper->db, wrapper->writeOpt, (rocksdb_writebatch_t*)pBatch, &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
stError("streamState failed to write batch, err:%s", err);
|
stError("streamState failed to write batch, err:%s", err);
|
||||||
|
@ -4429,8 +4447,8 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) {
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strncpy(fname, name, len);
|
(void)strncpy(fname, name, len);
|
||||||
taosArrayPush(diff, &fname);
|
(void)taosArrayPush(diff, &fname);
|
||||||
}
|
}
|
||||||
pIter = taosHashIterate(p2, pIter);
|
pIter = taosHashIterate(p2, pIter);
|
||||||
}
|
}
|
||||||
|
@ -4506,7 +4524,7 @@ void dbChkpDebugInfo(SDbChkp* pDb) {
|
||||||
int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t nBytes;
|
int32_t nBytes;
|
||||||
taosThreadRwlockWrlock(&p->rwLock);
|
(void)taosThreadRwlockWrlock(&p->rwLock);
|
||||||
|
|
||||||
p->preCkptId = p->curChkpId;
|
p->preCkptId = p->curChkpId;
|
||||||
p->curChkpId = chkpId;
|
p->curChkpId = chkpId;
|
||||||
|
@ -4524,7 +4542,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
nBytes =
|
nBytes =
|
||||||
snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
||||||
if (nBytes <= 0 || nBytes >= p->len) {
|
if (nBytes <= 0 || nBytes >= p->len) {
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return TSDB_CODE_OUT_OF_RANGE;
|
return TSDB_CODE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4534,7 +4552,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
|
|
||||||
TdDirPtr pDir = taosOpenDir(p->buf);
|
TdDirPtr pDir = taosOpenDir(p->buf);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4570,9 +4588,9 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosCloseDir(&pDir);
|
(void)taosCloseDir(&pDir);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4584,12 +4602,12 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
if (name != NULL && !isBkdDataMeta(name, len)) {
|
if (name != NULL && !isBkdDataMeta(name, len)) {
|
||||||
char* fname = taosMemoryCalloc(1, len + 1);
|
char* fname = taosMemoryCalloc(1, len + 1);
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(fname, name, len);
|
(void)strncpy(fname, name, len);
|
||||||
taosArrayPush(p->pAdd, &fname);
|
(void)taosArrayPush(p->pAdd, &fname);
|
||||||
}
|
}
|
||||||
pIter = taosHashIterate(p->pSstTbl[1 - p->idx], pIter);
|
pIter = taosHashIterate(p->pSstTbl[1 - p->idx], pIter);
|
||||||
}
|
}
|
||||||
|
@ -4621,7 +4639,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
|
|
||||||
p->idx = 1 - p->idx;
|
p->idx = 1 - p->idx;
|
||||||
|
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -4679,7 +4697,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
p->update = 0;
|
p->update = 0;
|
||||||
taosThreadRwlockInit(&p->rwLock, NULL);
|
(void)taosThreadRwlockInit(&p->rwLock, NULL);
|
||||||
|
|
||||||
SArray* list = NULL;
|
SArray* list = NULL;
|
||||||
code = dbChkpGetDelta(p, initChkpId, list);
|
code = dbChkpGetDelta(p, initChkpId, list);
|
||||||
|
@ -4720,7 +4738,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
static char* chkpMeta = "META";
|
static char* chkpMeta = "META";
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
taosThreadRwlockRdlock(&p->rwLock);
|
(void)taosThreadRwlockRdlock(&p->rwLock);
|
||||||
|
|
||||||
int32_t cap = p->len + 128;
|
int32_t cap = p->len + 128;
|
||||||
|
|
||||||
|
@ -4793,7 +4811,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
taosArrayPush(list, &p);
|
(void)taosArrayPush(list, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy current file to dst dir
|
// copy current file to dst dir
|
||||||
|
@ -4859,7 +4877,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
if (nBytes <= 0 || nBytes >= sizeof(content)) {
|
if (nBytes <= 0 || nBytes >= sizeof(content)) {
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir);
|
stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir);
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4867,10 +4885,10 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
if (nBytes != strlen(content)) {
|
if (nBytes != strlen(content)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
|
|
||||||
// clear delta data buf
|
// clear delta data buf
|
||||||
taosArrayClearP(p->pAdd, taosMemoryFree);
|
taosArrayClearP(p->pAdd, taosMemoryFree);
|
||||||
|
@ -4879,7 +4897,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
|
|
||||||
_ERROR:
|
_ERROR:
|
||||||
taosMemoryFree(buffer);
|
taosMemoryFree(buffer);
|
||||||
taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4925,7 +4943,7 @@ void bkdMgtDestroy(SBkdMgt* bm) {
|
||||||
pIter = taosHashIterate(bm->pDbChkpTbl, pIter);
|
pIter = taosHashIterate(bm->pDbChkpTbl, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockDestroy(&bm->rwLock);
|
(void)taosThreadRwlockDestroy(&bm->rwLock);
|
||||||
taosMemoryFree(bm->path);
|
taosMemoryFree(bm->path);
|
||||||
taosHashCleanup(bm->pDbChkpTbl);
|
taosHashCleanup(bm->pDbChkpTbl);
|
||||||
|
|
||||||
|
@ -4933,7 +4951,7 @@ void bkdMgtDestroy(SBkdMgt* bm) {
|
||||||
}
|
}
|
||||||
int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* dname) {
|
int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* dname) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
taosThreadRwlockWrlock(&bm->rwLock);
|
(void)taosThreadRwlockWrlock(&bm->rwLock);
|
||||||
SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId));
|
SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId));
|
||||||
SDbChkp* pChkp = ppChkp != NULL ? *ppChkp : NULL;
|
SDbChkp* pChkp = ppChkp != NULL ? *ppChkp : NULL;
|
||||||
|
|
||||||
|
@ -4941,14 +4959,14 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
||||||
int32_t cap = strlen(bm->path) + 64;
|
int32_t cap = strlen(bm->path) + 64;
|
||||||
char* path = taosMemoryCalloc(1, cap);
|
char* path = taosMemoryCalloc(1, cap);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
||||||
if (nBytes <= 0 || nBytes >= cap) {
|
if (nBytes <= 0 || nBytes >= cap) {
|
||||||
taosMemoryFree(path);
|
taosMemoryFree(path);
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
code = TSDB_CODE_OUT_OF_RANGE;
|
code = TSDB_CODE_OUT_OF_RANGE;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -4957,20 +4975,20 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
||||||
code = dbChkpCreate(path, chkpId, &p);
|
code = dbChkpCreate(path, chkpId, &p);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFree(path);
|
taosMemoryFree(path);
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) {
|
if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) {
|
||||||
dbChkpDestroy(p);
|
dbChkpDestroy(p);
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pChkp = p;
|
pChkp = p;
|
||||||
code = dbChkpDumpTo(pChkp, dname, list);
|
code = dbChkpDumpTo(pChkp, dname, list);
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
return code;
|
return code;
|
||||||
} else {
|
} else {
|
||||||
code = dbChkpGetDelta(pChkp, chkpId, NULL);
|
code = dbChkpGetDelta(pChkp, chkpId, NULL);
|
||||||
|
@ -4979,7 +4997,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadRwlockUnlock(&bm->rwLock);
|
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,8 @@ void streamTaskStartMonitorCheckRsp(SStreamTask* pTask) {
|
||||||
// drop procedure already started, not start check downstream now
|
// drop procedure already started, not start check downstream now
|
||||||
ETaskStatus s = streamTaskGetStatus(pTask).state;
|
ETaskStatus s = streamTaskGetStatus(pTask).state;
|
||||||
if (s == TASK_STATUS__DROPPING) {
|
if (s == TASK_STATUS__DROPPING) {
|
||||||
|
stDebug("s-task:%s task not in uninit status, status:%s not start monitor check-rsp", pTask->id.idStr,
|
||||||
|
streamTaskGetStatusStr(s));
|
||||||
streamMutexUnlock(&pInfo->checkInfoLock);
|
streamMutexUnlock(&pInfo->checkInfoLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,13 +219,17 @@ int32_t streamQueueMergeQueueItem(SStreamQueueItem* dst, SStreamQueueItem* pElem
|
||||||
if (dst->type == STREAM_INPUT__DATA_BLOCK && pElem->type == STREAM_INPUT__DATA_BLOCK) {
|
if (dst->type == STREAM_INPUT__DATA_BLOCK && pElem->type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
SStreamDataBlock* pBlock = (SStreamDataBlock*)dst;
|
SStreamDataBlock* pBlock = (SStreamDataBlock*)dst;
|
||||||
SStreamDataBlock* pBlockSrc = (SStreamDataBlock*)pElem;
|
SStreamDataBlock* pBlockSrc = (SStreamDataBlock*)pElem;
|
||||||
(void) taosArrayAddAll(pBlock->blocks, pBlockSrc->blocks);
|
void* px = taosArrayAddAll(pBlock->blocks, pBlockSrc->blocks);
|
||||||
|
if (px == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pBlockSrc->blocks);
|
taosArrayDestroy(pBlockSrc->blocks);
|
||||||
streamQueueItemIncSize(dst, streamQueueItemGetSize(pElem));
|
streamQueueItemIncSize(dst, streamQueueItemGetSize(pElem));
|
||||||
|
|
||||||
taosFreeQitem(pElem);
|
taosFreeQitem(pElem);
|
||||||
*pRes = dst;
|
*pRes = dst;
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
} else if (dst->type == STREAM_INPUT__MERGED_SUBMIT && pElem->type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (dst->type == STREAM_INPUT__MERGED_SUBMIT && pElem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)dst;
|
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)dst;
|
||||||
SStreamDataSubmit* pBlockSrc = (SStreamDataSubmit*)pElem;
|
SStreamDataSubmit* pBlockSrc = (SStreamDataSubmit*)pElem;
|
||||||
|
|
|
@ -231,13 +231,14 @@ EExtractDataCode streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueIte
|
||||||
if (*pInput == NULL) {
|
if (*pInput == NULL) {
|
||||||
ASSERT((*numOfBlocks) == 0);
|
ASSERT((*numOfBlocks) == 0);
|
||||||
*pInput = qItem;
|
*pInput = qItem;
|
||||||
} else {
|
} else { // merge current block failed, let's handle the already merged blocks.
|
||||||
// merge current block failed, let's handle the already merged blocks.
|
|
||||||
void* newRet = NULL;
|
void* newRet = NULL;
|
||||||
int32_t code = streamQueueMergeQueueItem(*pInput, qItem, (SStreamQueueItem**)&newRet);
|
int32_t code = streamQueueMergeQueueItem(*pInput, qItem, (SStreamQueueItem**)&newRet);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (newRet == NULL) {
|
||||||
|
if (code) {
|
||||||
stError("s-task:%s failed to merge blocks from inputQ, numOfBlocks:%d, code:%s", id, *numOfBlocks,
|
stError("s-task:%s failed to merge blocks from inputQ, numOfBlocks:%d, code:%s", id, *numOfBlocks,
|
||||||
tstrerror(terrno));
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
*blockSize = streamQueueItemGetSize(*pInput);
|
*blockSize = streamQueueItemGetSize(*pInput);
|
||||||
if (taskLevel == TASK_LEVEL__SINK) {
|
if (taskLevel == TASK_LEVEL__SINK) {
|
||||||
|
|
|
@ -872,6 +872,7 @@ void streamTaskStatusCopy(STaskStatusEntry* pDst, const STaskStatusEntry* pSrc)
|
||||||
pDst->checkpointInfo = pSrc->checkpointInfo;
|
pDst->checkpointInfo = pSrc->checkpointInfo;
|
||||||
pDst->startCheckpointId = pSrc->startCheckpointId;
|
pDst->startCheckpointId = pSrc->startCheckpointId;
|
||||||
pDst->startCheckpointVer = pSrc->startCheckpointVer;
|
pDst->startCheckpointVer = pSrc->startCheckpointVer;
|
||||||
|
pDst->status = pSrc->status;
|
||||||
|
|
||||||
pDst->startTime = pSrc->startTime;
|
pDst->startTime = pSrc->startTime;
|
||||||
pDst->hTaskId = pSrc->hTaskId;
|
pDst->hTaskId = pSrc->hTaskId;
|
||||||
|
|
|
@ -181,7 +181,7 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) {
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg);
|
TAOS_CHECK_RETURN(syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg));
|
||||||
syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex);
|
syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex);
|
||||||
|
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) {
|
||||||
|
|
|
@ -646,7 +646,7 @@ static SCliConn* getConnFromPool(SCliThrd* pThrd, char* key, bool* exceed) {
|
||||||
SConnList* plist = taosHashGet((SHashObj*)pool, key, klen);
|
SConnList* plist = taosHashGet((SHashObj*)pool, key, klen);
|
||||||
if (plist == NULL) {
|
if (plist == NULL) {
|
||||||
SConnList list = {0};
|
SConnList list = {0};
|
||||||
taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list));
|
(void)taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list));
|
||||||
plist = taosHashGet(pool, key, klen);
|
plist = taosHashGet(pool, key, klen);
|
||||||
|
|
||||||
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
||||||
|
@ -903,7 +903,7 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
|
||||||
conn->refId = exh->refId;
|
conn->refId = exh->refId;
|
||||||
taosWUnLockLatch(&exh->latch);
|
taosWUnLockLatch(&exh->latch);
|
||||||
|
|
||||||
transReleaseExHandle(transGetRefMgt(), handle);
|
(void)transReleaseExHandle(transGetRefMgt(), handle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ _failed:
|
||||||
if (conn) {
|
if (conn) {
|
||||||
taosMemoryFree(conn->stream);
|
taosMemoryFree(conn->stream);
|
||||||
transReqQueueClear(&conn->wreqQueue);
|
transReqQueueClear(&conn->wreqQueue);
|
||||||
transDestroyBuffer(&conn->readBuf);
|
(void)transDestroyBuffer(&conn->readBuf);
|
||||||
transQueueDestroy(&conn->cliMsgs);
|
transQueueDestroy(&conn->cliMsgs);
|
||||||
}
|
}
|
||||||
taosMemoryFree(conn);
|
taosMemoryFree(conn);
|
||||||
|
@ -1390,7 +1390,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
|
||||||
cliHandleFastFail(conn, -1);
|
cliHandleFastFail(conn, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0);
|
(void)uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,9 +1481,9 @@ void cliConnCb(uv_connect_t* req, int status) {
|
||||||
if (pConn->timer == NULL) {
|
if (pConn->timer == NULL) {
|
||||||
timeout = true;
|
timeout = true;
|
||||||
} else {
|
} else {
|
||||||
uv_timer_stop(pConn->timer);
|
(void)uv_timer_stop(pConn->timer);
|
||||||
pConn->timer->data = NULL;
|
pConn->timer->data = NULL;
|
||||||
taosArrayPush(pThrd->timerList, &pConn->timer);
|
(void)taosArrayPush(pThrd->timerList, &pConn->timer);
|
||||||
pConn->timer = NULL;
|
pConn->timer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1609,7 +1609,7 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr)
|
||||||
conn = getConnFromPool2(pThrd, addr, pMsg);
|
conn = getConnFromPool2(pThrd, addr, pMsg);
|
||||||
if (conn != NULL) specifyConnRef(conn, true, refId);
|
if (conn != NULL) specifyConnRef(conn, true, refId);
|
||||||
}
|
}
|
||||||
transReleaseExHandle(transGetRefMgt(), refId);
|
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||||
}
|
}
|
||||||
return conn;
|
return conn;
|
||||||
};
|
};
|
||||||
|
@ -1759,14 +1759,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
|
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
|
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
|
||||||
transQueuePush(&conn->cliMsgs, pMsg);
|
(void)transQueuePush(&conn->cliMsgs, pMsg);
|
||||||
cliSend(conn);
|
cliSend(conn);
|
||||||
} else {
|
} else {
|
||||||
code = cliCreateConn(pThrd, &conn);
|
code = cliCreateConn(pThrd, &conn);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code));
|
tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code));
|
||||||
STransMsg resp = {.code = code};
|
STransMsg resp = {.code = code};
|
||||||
cliBuildExceptResp(pMsg, &resp);
|
(void)cliBuildExceptResp(pMsg, &resp);
|
||||||
|
|
||||||
resp.info.cliVer = pTransInst->compatibilityVer;
|
resp.info.cliVer = pTransInst->compatibilityVer;
|
||||||
if (pMsg->type != Release) {
|
if (pMsg->type != Release) {
|
||||||
|
@ -1827,7 +1827,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
|
|
||||||
ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
|
ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
uv_timer_stop(conn->timer);
|
(void)uv_timer_stop(conn->timer);
|
||||||
conn->timer->data = NULL;
|
conn->timer->data = NULL;
|
||||||
(void)taosArrayPush(pThrd->timerList, &conn->timer);
|
(void)taosArrayPush(pThrd->timerList, &conn->timer);
|
||||||
conn->timer = NULL;
|
conn->timer = NULL;
|
||||||
|
@ -1923,7 +1923,7 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
||||||
|
|
||||||
QUEUE_PUSH(&pBatchList->wq, &pBatch->listq);
|
QUEUE_PUSH(&pBatchList->wq, &pBatch->listq);
|
||||||
|
|
||||||
taosHashPut(pThrd->batchCache, key, klen, &pBatchList, sizeof(void*));
|
(void)taosHashPut(pThrd->batchCache, key, klen, &pBatchList, sizeof(void*));
|
||||||
} else {
|
} else {
|
||||||
if (QUEUE_IS_EMPTY(&(*ppBatchList)->wq)) {
|
if (QUEUE_IS_EMPTY(&(*ppBatchList)->wq)) {
|
||||||
SCliBatch* pBatch = taosMemoryCalloc(1, sizeof(SCliBatch));
|
SCliBatch* pBatch = taosMemoryCalloc(1, sizeof(SCliBatch));
|
||||||
|
@ -2099,10 +2099,10 @@ static void* cliWorkThread(void* arg) {
|
||||||
SCliThrd* pThrd = (SCliThrd*)arg;
|
SCliThrd* pThrd = (SCliThrd*)arg;
|
||||||
pThrd->pid = taosGetSelfPthreadId();
|
pThrd->pid = taosGetSelfPthreadId();
|
||||||
|
|
||||||
strtolower(threadName, pThrd->pTransInst->label);
|
(void)strtolower(threadName, pThrd->pTransInst->label);
|
||||||
setThreadName(threadName);
|
setThreadName(threadName);
|
||||||
|
|
||||||
uv_run(pThrd->loop, UV_RUN_DEFAULT);
|
(void)uv_run(pThrd->loop, UV_RUN_DEFAULT);
|
||||||
|
|
||||||
tDebug("thread quit-thread:%08" PRId64, pThrd->pid);
|
tDebug("thread quit-thread:%08" PRId64, pThrd->pid);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2198,7 +2198,7 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QUEUE_INIT(&pThrd->msg);
|
QUEUE_INIT(&pThrd->msg);
|
||||||
taosThreadMutexInit(&pThrd->msgMtx, NULL);
|
(void)taosThreadMutexInit(&pThrd->msgMtx, NULL);
|
||||||
|
|
||||||
pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
|
pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
|
||||||
if (pThrd->loop == NULL) {
|
if (pThrd->loop == NULL) {
|
||||||
|
@ -2291,7 +2291,7 @@ _end:
|
||||||
(void)uv_loop_close(pThrd->loop);
|
(void)uv_loop_close(pThrd->loop);
|
||||||
taosMemoryFree(pThrd->loop);
|
taosMemoryFree(pThrd->loop);
|
||||||
taosMemoryFree(pThrd->prepare);
|
taosMemoryFree(pThrd->prepare);
|
||||||
taosThreadMutexDestroy(&pThrd->msgMtx);
|
(void)taosThreadMutexDestroy(&pThrd->msgMtx);
|
||||||
transAsyncPoolDestroy(pThrd->asyncPool);
|
transAsyncPoolDestroy(pThrd->asyncPool);
|
||||||
for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) {
|
for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) {
|
||||||
uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i);
|
uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i);
|
||||||
|
@ -2916,7 +2916,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
|
|
||||||
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
||||||
if (pCtx == NULL) {
|
if (pCtx == NULL) {
|
||||||
tsem_destroy(sem);
|
(void)tsem_destroy(sem);
|
||||||
taosMemoryFree(sem);
|
taosMemoryFree(sem);
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1);
|
||||||
}
|
}
|
||||||
|
@ -2930,7 +2930,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
|
|
||||||
SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg));
|
SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg));
|
||||||
if (cliMsg == NULL) {
|
if (cliMsg == NULL) {
|
||||||
tsem_destroy(sem);
|
(void)tsem_destroy(sem);
|
||||||
taosMemoryFree(sem);
|
taosMemoryFree(sem);
|
||||||
taosMemoryFree(pCtx);
|
taosMemoryFree(pCtx);
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1);
|
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1);
|
||||||
|
@ -2951,7 +2951,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
destroyCmsg(cliMsg);
|
destroyCmsg(cliMsg);
|
||||||
TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN);
|
TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN);
|
||||||
}
|
}
|
||||||
tsem_wait(sem);
|
(void)tsem_wait(sem);
|
||||||
|
|
||||||
memcpy(pRsp, pTransRsp, sizeof(STransMsg));
|
memcpy(pRsp, pTransRsp, sizeof(STransMsg));
|
||||||
|
|
||||||
|
@ -3085,7 +3085,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr
|
||||||
_RETURN:
|
_RETURN:
|
||||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||||
(void)taosReleaseRef(transGetSyncMsgMgt(), ref);
|
(void)taosReleaseRef(transGetSyncMsgMgt(), ref);
|
||||||
taosRemoveRef(transGetSyncMsgMgt(), ref);
|
(void)taosRemoveRef(transGetSyncMsgMgt(), ref);
|
||||||
return code;
|
return code;
|
||||||
_RETURN2:
|
_RETURN2:
|
||||||
transFreeMsg(pReq->pCont);
|
transFreeMsg(pReq->pCont);
|
||||||
|
|
|
@ -377,7 +377,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
|
||||||
// if (dVal) {
|
// if (dVal) {
|
||||||
// dst->freeFunc(dVal->val);
|
// dst->freeFunc(dVal->val);
|
||||||
// }
|
// }
|
||||||
taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal));
|
(void)taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal));
|
||||||
iter = taosHashIterate(src->args, iter);
|
iter = taosHashIterate(src->args, iter);
|
||||||
}
|
}
|
||||||
taosHashCleanup(src->args);
|
taosHashCleanup(src->args);
|
||||||
|
|
|
@ -1673,7 +1673,7 @@ void transCloseServer(void* arg) {
|
||||||
destroyWorkThrd(srv->pThreadObj[i]);
|
destroyWorkThrd(srv->pThreadObj[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uv_loop_close(srv->loop);
|
(void)uv_loop_close(srv->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(srv->pThreadObj);
|
taosMemoryFree(srv->pThreadObj);
|
||||||
|
|
|
@ -823,9 +823,9 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement
|
||||||
return nelements * longBytes;
|
return nelements * longBytes;
|
||||||
} else if (input[0] == 1) { // Decompress
|
} else if (input[0] == 1) { // Decompress
|
||||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
||||||
tsDecompressTimestampAvx512(input, nelements, output, false);
|
(void)tsDecompressTimestampAvx512(input, nelements, output, false);
|
||||||
} else if (tsSIMDEnable && tsAVX2Supported) {
|
} else if (tsSIMDEnable && tsAVX2Supported) {
|
||||||
tsDecompressTimestampAvx2(input, nelements, output, false);
|
(void)tsDecompressTimestampAvx2(input, nelements, output, false);
|
||||||
} else {
|
} else {
|
||||||
int64_t *ostream = (int64_t *)output;
|
int64_t *ostream = (int64_t *)output;
|
||||||
|
|
||||||
|
@ -1199,9 +1199,9 @@ int32_t tsDecompressFloatImp(const char *const input, const int32_t nelements, c
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsSIMDEnable && tsAVX2Supported) {
|
if (tsSIMDEnable && tsAVX2Supported) {
|
||||||
tsDecompressFloatImplAvx2(input, nelements, output);
|
(void)tsDecompressFloatImplAvx2(input, nelements, output);
|
||||||
} else if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
} else if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
||||||
tsDecompressFloatImplAvx512(input, nelements, output);
|
(void)tsDecompressFloatImplAvx512(input, nelements, output);
|
||||||
} else { // alternative implementation without SIMD instructions.
|
} else { // alternative implementation without SIMD instructions.
|
||||||
tsDecompressFloatHelper(input, nelements, (float *)output);
|
tsDecompressFloatHelper(input, nelements, (float *)output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -595,7 +595,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TABLE_NOT_EXIST, "Table does not exist
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_AMBIGUOUS_COLUMN, "Column ambiguously defined")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_AMBIGUOUS_COLUMN, "Column ambiguously defined")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Invalid value type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Invalid value type")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, "There mustn't be aggregation")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, "There mustn't be aggregation")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT, "ORDER BY item must be the number of a SELECT-list expression")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT, "ORDER BY / GROUP BY item must be the number of a SELECT-list expression")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION, "Not a GROUP BY expression")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION, "Not a GROUP BY expression")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION, "Not SELECTed expression")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION, "Not SELECTed expression")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SINGLE_GROUP, "Not a single-group group function")
|
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SINGLE_GROUP, "Not a single-group group function")
|
||||||
|
|
|
@ -932,7 +932,7 @@ void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, vo
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosUnLockFile(pFile);
|
(void)taosUnLockFile(pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
|
@ -8,7 +8,7 @@ int32_t doRegComp(pcre2_code** ppRegex, pcre2_match_data** ppMatchData, const ch
|
||||||
*ppRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
*ppRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||||
if (*ppRegex == NULL) {
|
if (*ppRegex == NULL) {
|
||||||
PCRE2_UCHAR buffer[256];
|
PCRE2_UCHAR buffer[256];
|
||||||
pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
|
(void)pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ int32_t doRegExec(const char* pString, pcre2_code* pRegex, pcre2_match_data* pMa
|
||||||
ret = pcre2_match(pRegex, (PCRE2_SPTR)pString, PCRE2_ZERO_TERMINATED, 0, 0, pMatchData, NULL);
|
ret = pcre2_match(pRegex, (PCRE2_SPTR)pString, PCRE2_ZERO_TERMINATED, 0, 0, pMatchData, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PCRE2_UCHAR buffer[256];
|
PCRE2_UCHAR buffer[256];
|
||||||
pcre2_get_error_message(ret, buffer, sizeof(buffer));
|
(void)pcre2_get_error_message(ret, buffer, sizeof(buffer));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ char *strbetween(char *string, char *begin, char *end) {
|
||||||
int32_t size = (int32_t)(_end - _begin);
|
int32_t size = (int32_t)(_end - _begin);
|
||||||
if (_end != NULL && size > 0) {
|
if (_end != NULL && size > 0) {
|
||||||
result = (char *)taosMemoryCalloc(1, size);
|
result = (char *)taosMemoryCalloc(1, size);
|
||||||
if (result) {
|
if (!result) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(result, _begin + strlen(begin), size - +strlen(begin));
|
memcpy(result, _begin + strlen(begin), size - +strlen(begin));
|
||||||
|
|
|
@ -560,6 +560,8 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -R
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -R
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -R
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -R
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -R
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -R
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -R
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Now.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Now.py
|
||||||
|
@ -739,6 +741,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 2
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
|
||||||
|
@ -837,6 +840,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 3
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
|
||||||
|
@ -934,6 +938,7 @@
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 4
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4
|
||||||
|
|
|
@ -144,8 +144,8 @@ class TDTestCase:
|
||||||
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 order by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 order by ts)")
|
||||||
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.t1 where c1 > 2 order by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.t1 where c1 > 2 order by ts)")
|
||||||
tdSql.error(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 group by c1)")
|
tdSql.error(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 group by c1)")
|
||||||
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 group by c1)")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 group by stb1.c1)")
|
||||||
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 group by c1)")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 group by t1.c1)")
|
||||||
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 )")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 )")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 )")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 )")
|
||||||
|
@ -245,7 +245,7 @@ class TDTestCase:
|
||||||
tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.error(f"select distinct t1, t0 from (select t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.error(f"select distinct t1, t0 from (select t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1 group by t1)")
|
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1 group by stb1.t1)")
|
||||||
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1)")
|
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1)")
|
||||||
tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
|
@ -77,7 +77,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
query_condition.extend(
|
query_condition.extend(
|
||||||
(
|
(
|
||||||
1010,
|
1010.1,
|
||||||
''' "test1234!@#$%^&*():'><?/.,][}{" ''',
|
''' "test1234!@#$%^&*():'><?/.,][}{" ''',
|
||||||
"null"
|
"null"
|
||||||
)
|
)
|
||||||
|
|
|
@ -81,6 +81,12 @@ class TDTestCase:
|
||||||
num = self.row_nums
|
num = self.row_nums
|
||||||
tdSql.checkRows(num)
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
tdSql.query(f"select c1, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by c1 having c1 >= 0")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = self.row_nums
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
tdSql.query(f"select ts, count(*) from {self.dbname}.{self.stable} {keyword} by ts ")
|
tdSql.query(f"select ts, count(*) from {self.dbname}.{self.stable} {keyword} by ts ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
@ -91,6 +97,157 @@ class TDTestCase:
|
||||||
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3, c1 ")
|
||||||
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
def test_groupby_position(self, keyword, check_num, nonempty_tb_num):
|
||||||
|
####### by tbname
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname from {self.dbname}.{self.stable} {keyword} by 1 order by count(*)")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
# last
|
||||||
|
tdSql.query(f"select tbname from {self.dbname}.{self.stable} {keyword} by 1 having count(*)>=0")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
# having filter out empty
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} {keyword} by 1 having count(*) <= 0")
|
||||||
|
tdSql.checkRows(check_num - nonempty_tb_num)
|
||||||
|
|
||||||
|
####### by tag
|
||||||
|
tdSql.query(f"select t2, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, count(*) from {self.dbname}.{self.stable} {keyword} by 1 having count(*) <= 0")
|
||||||
|
tdSql.checkRows(check_num - nonempty_tb_num)
|
||||||
|
|
||||||
|
# where
|
||||||
|
tdSql.query(f"select t2, count(*) from {self.dbname}.{self.stable} where ts < now {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, count(*) from {self.dbname}.{self.stable} where ts > 1737146000000 {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, count(*) from {self.dbname}.{self.stable} where c1 = 1 {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
####### by col
|
||||||
|
tdSql.query(f"select c1, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by 1 ")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = self.row_nums
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
tdSql.query(f"select ts, count(*) from {self.dbname}.{self.stable} {keyword} by 1 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
# col + tag
|
||||||
|
tdSql.query(f"select t2, c1, count(*) from {self.dbname}.{self.stable} {keyword} by 1, 2 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2, c1, count(*) from {self.dbname}.{self.stable} {keyword} by 1, c1 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, 2 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by 1, 2, 3 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by t2, 2, 3 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2, t3, c1, count(*) from {self.dbname}.{self.stable} {keyword} by 1, t3, 3 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
tdSql.query(f"select sum(t0.sumc2) from (select c1, sum(c2) as sumc2 from {self.dbname}.{self.stable} {keyword} by 1) t0")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = 1
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
tdSql.query(f"select abs(c1), count(*) from {self.dbname}.{self.stable} {keyword} by 1")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = self.row_nums
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
####### error case
|
||||||
|
tdSql.error(f"select c1, count(*) from {self.dbname}.{self.stable} {keyword} by 10")
|
||||||
|
tdSql.error(f"select c1, count(*) from {self.dbname}.{self.stable} {keyword} by 0")
|
||||||
|
tdSql.error(f"select c1, c2, count(*) from {self.dbname}.{self.stable} {keyword} by 0, 1")
|
||||||
|
tdSql.error(f"select c1, count(*) from {self.dbname}.{self.stable} {keyword} by 1.2")
|
||||||
|
tdSql.error(f"select c1, c2, c3, count(*) from {self.dbname}.{self.stable} {keyword} by 1, 2.2, 3")
|
||||||
|
tdSql.error(f"select c1, c2, count(*) from {self.dbname}.{self.stable} {keyword} by 1")
|
||||||
|
tdSql.error(f"select c1, avg(c2), count(*) from {self.dbname}.{self.stable} {keyword} by 1, 2")
|
||||||
|
|
||||||
|
def test_groupby_alias(self, keyword, check_num, nonempty_tb_num):
|
||||||
|
tdSql.query(f"select t1 as t1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t1_alias ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t1 as t1_alias from {self.dbname}.{self.stable} {keyword} by t1_alias order by count(*)")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
# last
|
||||||
|
tdSql.query(f"select t1 as t1_alias from {self.dbname}.{self.stable} {keyword} by t1_alias having count(*)>=0")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
# having filter out empty
|
||||||
|
tdSql.query(f"select t1 as t1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t1_alias having count(*) <= 0")
|
||||||
|
tdSql.checkRows(check_num - nonempty_tb_num)
|
||||||
|
|
||||||
|
####### by tag
|
||||||
|
tdSql.query(f"select t2 as t2_alias, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by t2_alias ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 as t2_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t2_alias having count(*) <= 0")
|
||||||
|
tdSql.checkRows(check_num - nonempty_tb_num)
|
||||||
|
|
||||||
|
# where
|
||||||
|
tdSql.query(f"select t2 as t2_alias, count(*) from {self.dbname}.{self.stable} where ts < now {keyword} by t2_alias ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 as t2_alias, count(*) from {self.dbname}.{self.stable} where ts > 1737146000000 {keyword} by t2_alias ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 as t2_alias, count(*) from {self.dbname}.{self.stable} where c1 = 1 {keyword} by t2_alias ")
|
||||||
|
tdSql.checkRows(check_num)
|
||||||
|
|
||||||
|
####### by col
|
||||||
|
tdSql.query(f"select c1 as c1_alias, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by c1_alias ")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = self.row_nums
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
tdSql.query(f"select ts as ts_alias, count(*) from {self.dbname}.{self.stable} {keyword} by ts_alias ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
# col + tag
|
||||||
|
tdSql.query(f"select t2 as t2_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by 1, 2 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2 as t2_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by 1, c1 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2 as t2_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t2, 2 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
tdSql.query(f"select t2 as t2_alias, t3 as t3_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t2_alias, t3_alias, 3 ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2 as t2_alias, t3 as t3_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t2, t3_alias, c1_alias ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
tdSql.query(f"select t2 as t2_alias, t3 as t3_alias, c1 as c1_alias, count(*) from {self.dbname}.{self.stable} {keyword} by t2_alias, t3, c1_alias ")
|
||||||
|
tdSql.checkRows(nonempty_tb_num * self.row_nums)
|
||||||
|
|
||||||
|
tdSql.query(f"select sum(t0.sumc2) from (select c1 as c1_alias, sum(c2) as sumc2 from {self.dbname}.{self.stable} {keyword} by c1_alias) t0")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = 1
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
tdSql.query(f"select abs(c1) as abs_alias, count(*) from {self.dbname}.{self.stable} {keyword} by abs_alias")
|
||||||
|
num = 0
|
||||||
|
if nonempty_tb_num > 0:
|
||||||
|
num = self.row_nums
|
||||||
|
tdSql.checkRows(num)
|
||||||
|
|
||||||
|
####### error case
|
||||||
|
tdSql.error(f"select c1, avg(c2) as avg_alias, count(*) from {self.dbname}.{self.stable} {keyword} by 1, avg_alias")
|
||||||
|
|
||||||
def test_groupby_sub_table(self):
|
def test_groupby_sub_table(self):
|
||||||
for i in range(self.tb_nums):
|
for i in range(self.tb_nums):
|
||||||
tbname = f"{self.dbname}.sub_{self.stable}_{i}"
|
tbname = f"{self.dbname}.sub_{self.stable}_{i}"
|
||||||
|
@ -270,6 +427,10 @@ class TDTestCase:
|
||||||
# empty table only
|
# empty table only
|
||||||
self.test_groupby('group', self.tb_nums, 0)
|
self.test_groupby('group', self.tb_nums, 0)
|
||||||
self.test_groupby('partition', self.tb_nums, 0)
|
self.test_groupby('partition', self.tb_nums, 0)
|
||||||
|
self.test_groupby_position('group', self.tb_nums, 0)
|
||||||
|
self.test_groupby_position('partition', self.tb_nums, 0)
|
||||||
|
self.test_groupby_alias('group', self.tb_nums, 0)
|
||||||
|
self.test_groupby_alias('partition', self.tb_nums, 0)
|
||||||
self.test_innerSelect(self.tb_nums)
|
self.test_innerSelect(self.tb_nums)
|
||||||
self.test_multi_group_key(self.tb_nums, 0)
|
self.test_multi_group_key(self.tb_nums, 0)
|
||||||
self.test_multi_agg(self.tb_nums, 0)
|
self.test_multi_agg(self.tb_nums, 0)
|
||||||
|
@ -281,6 +442,10 @@ class TDTestCase:
|
||||||
|
|
||||||
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('group', self.tb_nums, nonempty_tb_num)
|
||||||
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
self.test_groupby('partition', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_position('group', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_position('partition', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_alias('group', self.tb_nums, nonempty_tb_num)
|
||||||
|
self.test_groupby_alias('partition', self.tb_nums, nonempty_tb_num)
|
||||||
self.test_groupby_sub_table()
|
self.test_groupby_sub_table()
|
||||||
self.test_innerSelect(self.tb_nums)
|
self.test_innerSelect(self.tb_nums)
|
||||||
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
||||||
|
|
|
@ -77,7 +77,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
query_condition.extend(
|
query_condition.extend(
|
||||||
(
|
(
|
||||||
1010,
|
1010.1,
|
||||||
''' "test1234!@#$%^&*():'><?/.,][}{" ''',
|
''' "test1234!@#$%^&*():'><?/.,][}{" ''',
|
||||||
"null"
|
"null"
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
from wsgiref.headers import tspecials
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
self.dbname = "db"
|
||||||
|
self.rowNum = 10
|
||||||
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
def inAndNotinTest(self):
|
||||||
|
dbname = self.dbname
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 in (1, 2)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, True)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 in (2, 3)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 not in (2, 3)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, True)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 not in (1)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 in (1, null)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, True)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 in (2, null)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL?
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 not in (1, null)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False)
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 not in (2, null)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL?
|
||||||
|
|
||||||
|
tdSql.query(f"select 1 not in (null)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, False) # 1 not in (null) is NULL?
|
||||||
|
|
||||||
|
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 int, col2 nchar(20)) tags(loc nchar(20))''')
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
|
||||||
|
tdSql.execute(f"create table {dbname}.stb_2 using {dbname}.stb tags('shanghai')")
|
||||||
|
|
||||||
|
for i in range(self.rowNum):
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" )
|
||||||
|
for i in range(self.rowNum):
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" )
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 2) order by ts")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 1, 2)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3) order by ts")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 1, 3)
|
||||||
|
tdSql.checkData(2, 1, 9)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, 'xy') order by ts")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 1, 3)
|
||||||
|
tdSql.checkData(2, 1, 9)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, '9', 3) order by ts")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 1, 3)
|
||||||
|
tdSql.checkData(2, 1, 9)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, null) order by ts")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 1, 3)
|
||||||
|
tdSql.checkData(2, 1, 9)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" )
|
||||||
|
tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" )
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', null)")
|
||||||
|
tdSql.checkRows(11)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', null)")
|
||||||
|
tdSql.checkRows(11)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', 'shanghai', null)")
|
||||||
|
tdSql.checkRows(11)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', 'shanghai', null)")
|
||||||
|
tdSql.checkRows(22)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc not in ('beijing', null)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select * from {dbname}.stb where loc not in ('shanghai', 'shanghai', null)")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
dbname = "db"
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
self.inAndNotinTest()
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -75,7 +75,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
query_condition.extend(
|
query_condition.extend(
|
||||||
(
|
(
|
||||||
1010,
|
1010.1,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,7 @@ class TDTestCase:
|
||||||
sum_condition.extend( f"{num_col} + {num_col_2}" for num_col_2 in NUM_COL )
|
sum_condition.extend( f"{num_col} + {num_col_2}" for num_col_2 in NUM_COL )
|
||||||
sum_condition.extend( f"{num_col} + {un_num_col} " for un_num_col in UN_NUM_COL )
|
sum_condition.extend( f"{num_col} + {un_num_col} " for un_num_col in UN_NUM_COL )
|
||||||
|
|
||||||
sum_condition.append(1)
|
sum_condition.append(1.1)
|
||||||
|
|
||||||
return sum_condition
|
return sum_condition
|
||||||
|
|
||||||
def __where_condition(self, col):
|
def __where_condition(self, col):
|
||||||
|
|
|
@ -20,32 +20,32 @@ class TDTestCase:
|
||||||
tdSql.execute("insert into td_28068.ct4 using td_28068.st (branch, scenario) tags ('3.1', 'scenario2') values (1717122950000, 'query1', 9,10);")
|
tdSql.execute("insert into td_28068.ct4 using td_28068.st (branch, scenario) tags ('3.1', 'scenario2') values (1717122950000, 'query1', 9,10);")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by branch, scenario order by last(branch);')
|
tdSql.query('select last(ts) as ts, last(branch) as branch, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by last(branch);')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by branch, scenario order by last(branch), last(scenario); ')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by last(branch), last(scenario); ')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by branch, scenario order by last(branch); ')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by last(branch); ')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) from td_28068.st group by branch, scenario order by last(branch), last(test_case);')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario, last(test_case) from td_28068.st group by st.branch, st.scenario order by last(branch), last(test_case);')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by branch, scenario order by last(branch), last(scenario);')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by last(branch), last(scenario);')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by branch, scenario order by branch1, scenario1;')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by branch1, scenario1;')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by tbname; ')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by tbname; ')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by branch, scenario order by test_case;')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case from td_28068.st group by st.branch, st.scenario order by test_case;')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case1 from td_28068.st group by branch, scenario order by last(test_case);')
|
tdSql.query('select last(ts) as ts, last(branch) as branch1, last(scenario) as scenario1, last(test_case) as test_case1 from td_28068.st group by st.branch, st.scenario order by last(test_case);')
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
tdSql.query('select time_cost, num, time_cost + num as final_cost from td_28068.st partition by branch; ')
|
tdSql.query('select time_cost, num, time_cost + num as final_cost from td_28068.st partition by st.branch; ')
|
||||||
tdSql.checkRows(8)
|
tdSql.checkRows(8)
|
||||||
|
|
||||||
tdSql.query('select count(*) from td_28068.st partition by branch order by branch; ')
|
tdSql.query('select count(*) from td_28068.st partition by branch order by branch; ')
|
||||||
|
|
|
@ -615,6 +615,8 @@ class TDTestCase:
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor(), False)
|
tdSql.init(conn.cursor(), False)
|
||||||
|
tdSql.execute('alter local "debugFlag" "143"')
|
||||||
|
tdSql.execute('alter dnode 1 "debugFlag" "143"')
|
||||||
self.tsma_tester: TSMATester = TSMATester(tdSql)
|
self.tsma_tester: TSMATester = TSMATester(tdSql)
|
||||||
self.tsma_sql_generator: TSMATestSQLGenerator = TSMATestSQLGenerator()
|
self.tsma_sql_generator: TSMATestSQLGenerator = TSMATestSQLGenerator()
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ class TDTestCase:
|
||||||
for i in range(rowCnt):
|
for i in range(rowCnt):
|
||||||
results.append(tdSql.getData(i,1))
|
results.append(tdSql.getData(i,1))
|
||||||
|
|
||||||
tdSql.query("select * from st1 order by groupid,_wstart")
|
sql = "select * from st1 order by groupid,_wstart"
|
||||||
|
tdSql.check_rows_loop(rowCnt, sql, loopCount=100, waitTime=0.5)
|
||||||
|
|
||||||
tdSql.checkRows(rowCnt)
|
tdSql.checkRows(rowCnt)
|
||||||
for i in range(rowCnt):
|
for i in range(rowCnt):
|
||||||
data1 = tdSql.getData(i,1)
|
data1 = tdSql.getData(i,1)
|
||||||
|
|
|
@ -243,6 +243,8 @@ python3 ./test.py -f 2-query/max.py -P
|
||||||
python3 ./test.py -f 2-query/max.py -P -R
|
python3 ./test.py -f 2-query/max.py -P -R
|
||||||
python3 ./test.py -f 2-query/min.py -P
|
python3 ./test.py -f 2-query/min.py -P
|
||||||
python3 ./test.py -f 2-query/min.py -P -R
|
python3 ./test.py -f 2-query/min.py -P -R
|
||||||
|
python3 ./test.py -f 2-query/normal.py -P
|
||||||
|
python3 ./test.py -f 2-query/normal.py -P -R
|
||||||
python3 ./test.py -f 2-query/mode.py -P
|
python3 ./test.py -f 2-query/mode.py -P
|
||||||
python3 ./test.py -f 2-query/mode.py -P -R
|
python3 ./test.py -f 2-query/mode.py -P -R
|
||||||
python3 ./test.py -f 2-query/Now.py -P
|
python3 ./test.py -f 2-query/Now.py -P
|
||||||
|
@ -424,6 +426,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/Today.py -P -Q 2
|
python3 ./test.py -f 2-query/Today.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 2
|
python3 ./test.py -f 2-query/max.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 2
|
python3 ./test.py -f 2-query/min.py -P -Q 2
|
||||||
|
python3 ./test.py -f 2-query/normal.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 2
|
python3 ./test.py -f 2-query/mode.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 2
|
python3 ./test.py -f 2-query/count.py -P -Q 2
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2
|
||||||
|
@ -522,6 +525,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/Today.py -P -Q 3
|
python3 ./test.py -f 2-query/Today.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 3
|
python3 ./test.py -f 2-query/max.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 3
|
python3 ./test.py -f 2-query/min.py -P -Q 3
|
||||||
|
python3 ./test.py -f 2-query/normal.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 3
|
python3 ./test.py -f 2-query/mode.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 3
|
python3 ./test.py -f 2-query/count.py -P -Q 3
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3
|
||||||
|
@ -619,6 +623,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/Today.py -P -Q 4
|
python3 ./test.py -f 2-query/Today.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/max.py -P -Q 4
|
python3 ./test.py -f 2-query/max.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/min.py -P -Q 4
|
python3 ./test.py -f 2-query/min.py -P -Q 4
|
||||||
|
python3 ./test.py -f 2-query/normal.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/mode.py -P -Q 4
|
python3 ./test.py -f 2-query/mode.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/count.py -P -Q 4
|
python3 ./test.py -f 2-query/count.py -P -Q 4
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4
|
||||||
|
|
|
@ -46,6 +46,7 @@ python3 .\test.py -f 2-query\between.py
|
||||||
@REM python3 .\test.py -f 2-query\Today.py
|
@REM python3 .\test.py -f 2-query\Today.py
|
||||||
@REM python3 .\test.py -f 2-query\max.py
|
@REM python3 .\test.py -f 2-query\max.py
|
||||||
@REM python3 .\test.py -f 2-query\min.py
|
@REM python3 .\test.py -f 2-query\min.py
|
||||||
|
@REM python3 .\test.py -f 2-query\normal.py
|
||||||
@REM python3 .\test.py -f 2-query\count.py
|
@REM python3 .\test.py -f 2-query\count.py
|
||||||
@REM python3 .\test.py -f 2-query\last.py
|
@REM python3 .\test.py -f 2-query\last.py
|
||||||
@REM python3 .\test.py -f 2-query\first.py
|
@REM python3 .\test.py -f 2-query\first.py
|
||||||
|
|
|
@ -382,6 +382,8 @@ python3 ./test.py -f 2-query/max.py
|
||||||
python3 ./test.py -f 2-query/max.py -R
|
python3 ./test.py -f 2-query/max.py -R
|
||||||
python3 ./test.py -f 2-query/min.py
|
python3 ./test.py -f 2-query/min.py
|
||||||
python3 ./test.py -f 2-query/min.py -R
|
python3 ./test.py -f 2-query/min.py -R
|
||||||
|
python3 ./test.py -f 2-query/normal.py
|
||||||
|
python3 ./test.py -f 2-query/normal.py -R
|
||||||
python3 ./test.py -f 2-query/mode.py
|
python3 ./test.py -f 2-query/mode.py
|
||||||
python3 ./test.py -f 2-query/mode.py -R
|
python3 ./test.py -f 2-query/mode.py -R
|
||||||
python3 ./test.py -f 2-query/Now.py
|
python3 ./test.py -f 2-query/Now.py
|
||||||
|
@ -550,6 +552,7 @@ python3 ./test.py -f 2-query/Now.py -Q 2
|
||||||
python3 ./test.py -f 2-query/Today.py -Q 2
|
python3 ./test.py -f 2-query/Today.py -Q 2
|
||||||
python3 ./test.py -f 2-query/max.py -Q 2
|
python3 ./test.py -f 2-query/max.py -Q 2
|
||||||
python3 ./test.py -f 2-query/min.py -Q 2
|
python3 ./test.py -f 2-query/min.py -Q 2
|
||||||
|
python3 ./test.py -f 2-query/normal.py -Q 2
|
||||||
python3 ./test.py -f 2-query/mode.py -Q 2
|
python3 ./test.py -f 2-query/mode.py -Q 2
|
||||||
python3 ./test.py -f 2-query/count.py -Q 2
|
python3 ./test.py -f 2-query/count.py -Q 2
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
|
||||||
|
@ -646,6 +649,7 @@ python3 ./test.py -f 2-query/Now.py -Q 3
|
||||||
python3 ./test.py -f 2-query/Today.py -Q 3
|
python3 ./test.py -f 2-query/Today.py -Q 3
|
||||||
python3 ./test.py -f 2-query/max.py -Q 3
|
python3 ./test.py -f 2-query/max.py -Q 3
|
||||||
python3 ./test.py -f 2-query/min.py -Q 3
|
python3 ./test.py -f 2-query/min.py -Q 3
|
||||||
|
python3 ./test.py -f 2-query/normal.py -Q 3
|
||||||
python3 ./test.py -f 2-query/mode.py -Q 3
|
python3 ./test.py -f 2-query/mode.py -Q 3
|
||||||
python3 ./test.py -f 2-query/count.py -Q 3
|
python3 ./test.py -f 2-query/count.py -Q 3
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
|
||||||
|
@ -742,6 +746,7 @@ python3 ./test.py -f 2-query/Now.py -Q 4
|
||||||
python3 ./test.py -f 2-query/Today.py -Q 4
|
python3 ./test.py -f 2-query/Today.py -Q 4
|
||||||
python3 ./test.py -f 2-query/max.py -Q 4
|
python3 ./test.py -f 2-query/max.py -Q 4
|
||||||
python3 ./test.py -f 2-query/min.py -Q 4
|
python3 ./test.py -f 2-query/min.py -Q 4
|
||||||
|
python3 ./test.py -f 2-query/normal.py -Q 4
|
||||||
python3 ./test.py -f 2-query/mode.py -Q 4
|
python3 ./test.py -f 2-query/mode.py -Q 4
|
||||||
python3 ./test.py -f 2-query/count.py -Q 4
|
python3 ./test.py -f 2-query/count.py -Q 4
|
||||||
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4
|
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4
|
||||||
|
|
Loading…
Reference in New Issue