Merge branch '3.0' into refact/submit_req
This commit is contained in:
commit
723efba79b
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.2.0")
|
||||
SET(TD_VER_NUMBER "3.0.2.1")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef enum {
|
|||
AUTH_TYPE_READ = 1,
|
||||
AUTH_TYPE_WRITE,
|
||||
AUTH_TYPE_OTHER,
|
||||
AUTH_TYPE_READ_OR_WRITE,
|
||||
} AUTH_TYPE;
|
||||
|
||||
typedef struct SUserAuthInfo {
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef struct SExprNode {
|
|||
char userAlias[TSDB_COL_NAME_LEN];
|
||||
SArray* pAssociation;
|
||||
bool orderAlias;
|
||||
bool asAlias;
|
||||
} SExprNode;
|
||||
|
||||
typedef enum EColumnType {
|
||||
|
@ -127,8 +128,7 @@ typedef struct SLogicConditionNode {
|
|||
} SLogicConditionNode;
|
||||
|
||||
typedef struct SNodeListNode {
|
||||
ENodeType type; // QUERY_NODE_NODE_LIST
|
||||
SDataType dataType;
|
||||
SExprNode node; // QUERY_NODE_NODE_LIST
|
||||
SNodeList* pNodeList;
|
||||
} SNodeListNode;
|
||||
|
||||
|
|
|
@ -153,10 +153,10 @@ typedef struct SSyncFSM {
|
|||
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
||||
|
||||
int32_t (*FpGetSnapshot)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
void (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||
|
||||
int32_t (*FpSnapshotStartRead)(const struct SSyncFSM* pFsm, void* pReaderParam, void** ppReader);
|
||||
int32_t (*FpSnapshotStopRead)(const struct SSyncFSM* pFsm, void* pReader);
|
||||
void (*FpSnapshotStopRead)(const struct SSyncFSM* pFsm, void* pReader);
|
||||
int32_t (*FpSnapshotDoRead)(const struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||
|
||||
int32_t (*FpSnapshotStartWrite)(const struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||
|
|
|
@ -204,9 +204,15 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_CANT_DROP_LEADER TAOS_DEF_ERROR_CODE(0, 0x0333)
|
||||
#define TSDB_CODE_MND_NO_ENOUGH_DNODES TAOS_DEF_ERROR_CODE(0, 0x0334)
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_CFG TAOS_DEF_ERROR_CODE(0, 0x0335)
|
||||
// #define TSDB_CODE_MND_INVALID_DNODE_CFG_... TAOS_DEF_ERROR_CODE(0, 0x0336) // 2.x
|
||||
// #define TSDB_CODE_MND_BALANCE_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0337) // 2.x
|
||||
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0338)
|
||||
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0339)
|
||||
// #define TSDB_CODE_MND_DNODE_NOT_FREE TAOS_DEF_ERROR_CODE(0, 0x033A) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_CLUSTER_ID TAOS_DEF_ERROR_CODE(0, 0x033B)
|
||||
// #define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x033C) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_ID_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033D) // 2.x
|
||||
// #define TSDB_CODE_MND_DNODE_EP_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033E) // 2.x
|
||||
|
||||
// mnode-acct
|
||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||
|
@ -298,6 +304,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x03B5)
|
||||
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x03B6)
|
||||
#define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x03B7)
|
||||
#define TSDB_CODE_MND_DNODE_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x03B8)
|
||||
#define TSDB_CODE_MND_DNODE_IN_DROPPING TAOS_DEF_ERROR_CODE(0, 0x03B9)
|
||||
|
||||
// mnode-stable-part2
|
||||
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
|
@ -318,6 +326,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
||||
#define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D5)
|
||||
#define TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x03D6) //internal
|
||||
#define TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x03D7)
|
||||
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
||||
|
||||
// mnode-mq
|
||||
|
|
|
@ -122,6 +122,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
|
||||
char* key = getClusterKey(user, secretEncrypt, ip, port);
|
||||
|
||||
tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
|
||||
user, db, key);
|
||||
for (int32_t i = 0; i < epSet.epSet.numOfEps; ++i) {
|
||||
tscInfo("ep:%d, %s:%u", i, epSet.epSet.eps[i].fqdn, epSet.epSet.eps[i].port);
|
||||
}
|
||||
|
||||
SAppInstInfo** pInst = NULL;
|
||||
taosThreadMutexLock(&appInfo.mutex);
|
||||
|
||||
|
@ -142,7 +148,7 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
|
|||
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||
p->instKey = key;
|
||||
key = NULL;
|
||||
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, ip, port);
|
||||
tscDebug("new app inst mgr %p, user:%s, ip:%s, port:%d", p, user, epSet.epSet.eps[0].fqdn, epSet.epSet.eps[0].port);
|
||||
|
||||
pInst = &p;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) {
|
|||
}
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
end:
|
||||
end:
|
||||
cJSON_Delete(json);
|
||||
tFreeSMAltertbReq(&req);
|
||||
return string;
|
||||
|
@ -200,7 +200,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE);
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen);
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
cJSON_AddItemToArray(tags, tag);
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
cJSON_AddItemToObject(json, "tags", tags);
|
||||
taosArrayDestroy(pTagVals);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFreeClear(pCreateReq->comment);
|
||||
|
@ -393,7 +393,7 @@ static char* processAutoCreateTable(STaosxRsp* rsp) {
|
|||
}
|
||||
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
for (int i = 0; i < rsp->createTableNum; i++) {
|
||||
tDecoderClear(&decoder[i]);
|
||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||
|
@ -515,7 +515,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
|||
}
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
|
@ -548,11 +548,50 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) {
|
|||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
}
|
||||
static char* processDeleteTable(SMqMetaRsp* metaRsp){
|
||||
SDeleteRes req = {0};
|
||||
SDecoder coder = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
cJSON* json = NULL;
|
||||
char* string = NULL;
|
||||
|
||||
// decode and process req
|
||||
void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead));
|
||||
int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead);
|
||||
|
||||
tDecoderInit(&coder, data, len);
|
||||
if (tDecodeDeleteRes(&coder, &req) < 0) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// getTbName(req.tableFName);
|
||||
char sql[256] = {0};
|
||||
snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName,
|
||||
req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||
uDebug("delete sql:%s\n", sql);
|
||||
|
||||
json = cJSON_CreateObject();
|
||||
if (json == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
cJSON* type = cJSON_CreateString("delete");
|
||||
cJSON_AddItemToObject(json, "type", type);
|
||||
cJSON* sqlJson = cJSON_CreateString(sql);
|
||||
cJSON_AddItemToObject(json, "sql", sqlJson);
|
||||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&coder);
|
||||
return string;
|
||||
}
|
||||
|
||||
static char* processDropTable(SMqMetaRsp* metaRsp) {
|
||||
SDecoder decoder = {0};
|
||||
|
@ -590,7 +629,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) {
|
|||
|
||||
string = cJSON_PrintUnformatted(json);
|
||||
|
||||
_exit:
|
||||
_exit:
|
||||
cJSON_Delete(json);
|
||||
tDecoderClear(&decoder);
|
||||
return string;
|
||||
|
@ -678,7 +717,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
end:
|
||||
destroyRequest(pRequest);
|
||||
tFreeSMCreateStbReq(&pReq);
|
||||
tDecoderClear(&coder);
|
||||
|
@ -748,7 +787,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = pRequest->code;
|
||||
taosMemoryFree(pCmdMsg.pMsg);
|
||||
|
||||
end:
|
||||
end:
|
||||
destroyRequest(pRequest);
|
||||
tDecoderClear(&coder);
|
||||
return code;
|
||||
|
@ -809,9 +848,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
|
||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||
// loop to create table
|
||||
|
@ -891,7 +930,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFreeClear(pCreateReq->comment);
|
||||
|
@ -961,9 +1000,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||
// loop to create table
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
|
@ -1015,7 +1054,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
taosHashCleanup(pVgroupHashmap);
|
||||
destroyRequest(pRequest);
|
||||
tDecoderClear(&coder);
|
||||
|
@ -1083,7 +1122,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
taos_free_result(res);
|
||||
|
||||
end:
|
||||
end:
|
||||
tDecoderClear(&coder);
|
||||
return code;
|
||||
}
|
||||
|
@ -1130,9 +1169,9 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
.requestId = pRequest->requestId,
|
||||
.requestObjRefId = pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||
|
||||
SVgroupInfo pInfo = {0};
|
||||
SName pName = {0};
|
||||
|
@ -1191,7 +1230,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
code = handleAlterTbExecRes(pRes->res, pCatalog);
|
||||
}
|
||||
}
|
||||
end:
|
||||
end:
|
||||
taosArrayDestroy(pArray);
|
||||
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
||||
taosMemoryFreeClear(pVgData);
|
||||
|
@ -1354,7 +1393,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
qDestroyQuery(pQuery);
|
||||
destroyRequest(pRequest);
|
||||
|
@ -1414,7 +1453,6 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
goto end;
|
||||
}
|
||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
|
||||
uDebug("raw data block num:%d\n", rspObj.rsp.blockNum);
|
||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||
|
@ -1474,7 +1512,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
code = pRequest->code;
|
||||
|
||||
end:
|
||||
end:
|
||||
tDeleteSMqDataRsp(&rspObj.rsp);
|
||||
tDecoderClear(&decoder);
|
||||
qDestroyQuery(pQuery);
|
||||
|
@ -1647,7 +1685,12 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
|||
return processAlterTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
||||
return processDropTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
||||
return processDropTable(&pMetaRspObj->metaRsp);
|
||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) {
|
||||
return processDeleteTable(&pMetaRspObj->metaRsp);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1902,10 +1902,6 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) {
|
|||
if (TD_RES_TMQ(res)) {
|
||||
return TMQ_RES_DATA;
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||
if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) {
|
||||
return TMQ_RES_DATA;
|
||||
}
|
||||
return TMQ_RES_TABLE_META;
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
return TMQ_RES_METADATA;
|
||||
|
|
|
@ -41,6 +41,8 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
|||
pMgmt->statusSeq);
|
||||
pMgmt->pData->dropped = 1;
|
||||
dmWriteEps(pMgmt->pData);
|
||||
dInfo("dnode will exit since it is in the dropped state");
|
||||
raise(SIGINT);
|
||||
}
|
||||
} else {
|
||||
SStatusRsp statusRsp = {0};
|
||||
|
|
|
@ -53,6 +53,15 @@ static bool dmFailFastFp(tmsg_t msgType) {
|
|||
return msgType == TDMT_SYNC_HEARTBEAT || msgType == TDMT_SYNC_APPEND_ENTRIES;
|
||||
}
|
||||
|
||||
static void dmConvertErrCode(tmsg_t msgType) {
|
||||
if (terrno != TSDB_CODE_APP_IS_STOPPING) {
|
||||
return;
|
||||
}
|
||||
if ((msgType > TDMT_VND_MSG && msgType < TDMT_VND_MAX_MSG) ||
|
||||
(msgType > TDMT_SCH_MSG && msgType < TDMT_SCH_MAX_MSG)) {
|
||||
terrno = TSDB_CODE_VND_STOPPED;
|
||||
}
|
||||
}
|
||||
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
int32_t code = -1;
|
||||
|
@ -102,7 +111,12 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _OVER;
|
||||
}
|
||||
} /* else if ((pRpc->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || pRpc->code == TSDB_CODE_RPC_BROKEN_LINK) &&
|
||||
(!IsReq(pRpc)) && (pRpc->pCont == NULL)) {
|
||||
dGError("msg:%p, type:%s pCont is NULL, err: %s", pRpc, TMSG_INFO(pRpc->msgType), tstrerror(pRpc->code));
|
||||
terrno = pRpc->code;
|
||||
goto _OVER;
|
||||
}*/
|
||||
|
||||
if (pHandle->defaultNtype == NODE_END) {
|
||||
dGError("msg:%p, type:%s not processed since no handle", pRpc, TMSG_INFO(pRpc->msgType));
|
||||
|
@ -152,6 +166,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
|
||||
_OVER:
|
||||
if (code != 0) {
|
||||
dmConvertErrCode(pRpc->msgType);
|
||||
if (terrno != 0) code = terrno;
|
||||
if (pMsg) {
|
||||
dGTrace("msg:%p, failed to process %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
||||
|
|
|
@ -557,6 +557,8 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
|||
mInfo("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||
|
||||
mndTransSetDbName(pTrans, dbObj.name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetOper(pTrans, MND_OPER_CREATE_DB);
|
||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
if (mndSetCreateDbUndoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||
|
@ -776,7 +778,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
|
|||
|
||||
int32_t code = -1;
|
||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetAlterDbRedoLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||
if (mndSetAlterDbCommitLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||
|
@ -1038,7 +1040,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
|
|||
|
||||
mInfo("trans:%d, used to drop db:%s", pTrans->id, pDb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
if (mndCheckTopicExist(pMnode, pDb) < 0) goto _OVER;
|
||||
|
||||
if (mndSetDropDbRedoLogs(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||
|
|
|
@ -217,8 +217,18 @@ SDnodeObj *mndAcquireDnode(SMnode *pMnode, int32_t dnodeId) {
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
SDnodeObj *pDnode = sdbAcquire(pSdb, SDB_DNODE, &dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
if (terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
} else if (terrno == TSDB_CODE_SDB_OBJ_CREATING) {
|
||||
terrno = TSDB_CODE_MND_DNODE_IN_CREATING;
|
||||
} else if (terrno == TSDB_CODE_SDB_OBJ_DROPPING) {
|
||||
terrno = TSDB_CODE_MND_DNODE_IN_DROPPING;
|
||||
} else {
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
mFatal("dnode:%d, failed to acquire db since %s", dnodeId, terrstr());
|
||||
}
|
||||
}
|
||||
|
||||
return pDnode;
|
||||
}
|
||||
|
||||
|
@ -254,6 +264,27 @@ static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static SDnodeObj *mndAcquireDnodeAllStatusByEp(SMnode *pMnode, char *pEpStr) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
ESdbStatus objStatus = 0;
|
||||
pIter = sdbFetchAll(pSdb, SDB_DNODE, pIter, (void **)&pDnode, &objStatus, true);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
return pDnode;
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t mndGetDnodeSize(SMnode *pMnode) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
return sdbGetSize(pSdb, SDB_DNODE);
|
||||
|
@ -340,12 +371,22 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
} else {
|
||||
pDnode = mndAcquireDnode(pMnode, statusReq.dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
int32_t err = terrno;
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp);
|
||||
if (pDnode != NULL) {
|
||||
pDnode->offlineReason = DND_REASON_DNODE_ID_NOT_MATCH;
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mError("dnode:%d, %s not exist, code:0x%x", statusReq.dnodeId, statusReq.dnodeEp, err);
|
||||
if (err == TSDB_CODE_MND_DNODE_NOT_EXIST) {
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
} else {
|
||||
pDnode = mndAcquireDnodeAllStatusByEp(pMnode, statusReq.dnodeEp);
|
||||
if (pDnode == NULL) goto _OVER;
|
||||
}
|
||||
mError("dnode:%d, %s not exist", statusReq.dnodeId, statusReq.dnodeEp);
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,6 +558,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
|
|||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mInfo("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
pRaw = mndDnodeActionEncode(&dnodeObj);
|
||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
|
@ -698,6 +740,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop dnode:%d, force:%d", pTrans->id, pDnode->id, force);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
pRaw = mndDnodeActionEncode(pDnode);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
@ -762,11 +805,12 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
char ep[TSDB_EP_LEN + 1] = {0};
|
||||
int32_t err = terrno;
|
||||
char ep[TSDB_EP_LEN + 1] = {0};
|
||||
snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||
if (pDnode == NULL) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
terrno = err;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
@ -967,11 +1011,12 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
ESdbStatus objStatus = 0;
|
||||
SDnodeObj *pDnode = NULL;
|
||||
int64_t curMs = taosGetTimestampMs();
|
||||
|
||||
while (numOfRows < rows) {
|
||||
pShow->pIter = sdbFetch(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode);
|
||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode, &objStatus, true);
|
||||
if (pShow->pIter == NULL) break;
|
||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||
|
||||
|
@ -993,8 +1038,20 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pDnode->numOfSupportVnodes, false);
|
||||
|
||||
const char *status = "ready";
|
||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||
if (!online) {
|
||||
if (objStatus == SDB_STATUS_CREATING)
|
||||
status = "creating*";
|
||||
else if (objStatus == SDB_STATUS_DROPPING)
|
||||
status = "dropping*";
|
||||
else
|
||||
status = "offline";
|
||||
}
|
||||
|
||||
char b1[9] = {0};
|
||||
STR_TO_VARSTR(b1, online ? "ready" : "offline");
|
||||
STR_TO_VARSTR(b1, status);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, b1, false);
|
||||
|
||||
|
|
|
@ -390,6 +390,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||
|
@ -526,6 +527,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
|||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
@ -633,6 +635,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
const char *status = "ready";
|
||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||
if (!mndIsDnodeOnline(pObj->pDnode, curMs)) status = "offline";
|
||||
char b3[9 + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -595,6 +595,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
|||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-sma");
|
||||
if (pTrans == NULL) goto _OVER;
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetSerial(pTrans);
|
||||
mInfo("trans:%d, used to create sma:%s stream:%s", pTrans->id, pCreate->name, streamObj.name);
|
||||
|
||||
|
@ -809,6 +811,8 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
|
||||
mInfo("trans:%d, used to drop sma:%s", pTrans->id, pSma->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
mndTransSetSerial(pTrans);
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
|
|
|
@ -823,6 +823,7 @@ _OVER:
|
|||
|
||||
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||
|
@ -1856,6 +1857,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb
|
|||
|
||||
mInfo("trans:%d, used to alter stb:%s", pTrans->id, pStb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (needRsp) {
|
||||
void *pCont = NULL;
|
||||
|
@ -2055,6 +2057,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
|
|||
|
||||
mInfo("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||
if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||
|
|
|
@ -631,9 +631,11 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
||||
mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
||||
|
||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||
|
||||
// create stb for stream
|
||||
if (mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createStreamReq.name, terrstr());
|
||||
|
@ -781,6 +783,12 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) {
|
|||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "stream-checkpoint");
|
||||
if (pTrans == NULL) return -1;
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosRLockLatch(&pStream->lock);
|
||||
// 1. redo action: broadcast checkpoint source msg for all source vg
|
||||
int32_t totLevel = taosArrayGetSize(pStream->tasks);
|
||||
|
@ -871,11 +879,11 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stream");
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (pTrans == NULL) {
|
||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
@ -883,6 +891,13 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
mInfo("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
||||
|
||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// drop all tasks
|
||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
||||
|
|
|
@ -442,7 +442,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
|||
static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) {
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "tmq-reb");
|
||||
if (pTrans == NULL) return -1;
|
||||
|
||||
mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// make txn:
|
||||
// 1. redo action: action to all vg
|
||||
|
|
|
@ -142,10 +142,9 @@ int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pRe
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
static void mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndRestoreFinish(const SSyncFSM *pFsm) {
|
||||
|
@ -170,10 +169,10 @@ int32_t mndSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void **ppReader
|
|||
return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
static void mndSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
mInfo("stop to read snapshot from sdb");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
return sdbStopRead(pMnode->pSdb, pReader);
|
||||
sdbStopRead(pMnode->pSdb, pReader);
|
||||
}
|
||||
|
||||
int32_t mndSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
|
|
|
@ -701,13 +701,19 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
||||
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mInfo("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||
|
||||
// TODO check if rebalancing
|
||||
|
|
|
@ -960,6 +960,10 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||
}
|
||||
if (code == TSDB_CODE_SYN_TIMEOUT) {
|
||||
code = TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT;
|
||||
}
|
||||
|
||||
if (i != 0 && code == 0) {
|
||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ void *sdbGetRowObj(SSdbRow *pRow);
|
|||
void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc);
|
||||
|
||||
int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *term, int64_t *config);
|
||||
int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter);
|
||||
void sdbStopRead(SSdb *pSdb, SSdbIter *pIter);
|
||||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len);
|
||||
|
||||
int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter);
|
||||
|
|
|
@ -585,10 +585,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter) {
|
||||
sdbCloseIter(pIter);
|
||||
return 0;
|
||||
}
|
||||
void sdbStopRead(SSdb *pSdb, SSdbIter *pIter) { sdbCloseIter(pIter); }
|
||||
|
||||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
|
||||
int32_t maxlen = 4096;
|
||||
|
|
|
@ -185,7 +185,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta);
|
|||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
uint64_t suid, void **pReader);
|
||||
uint64_t suid, void **pReader, const char* idstr);
|
||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||
void *tsdbCacherowsReaderClose(void *pReader);
|
||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||
|
@ -275,7 +275,7 @@ int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *
|
|||
|
||||
// SVSnapReader
|
||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader);
|
||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader);
|
||||
void vnodeSnapReaderClose(SVSnapReader *pReader);
|
||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
||||
// SVSnapWriter
|
||||
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
||||
|
|
|
@ -121,6 +121,7 @@ typedef struct {
|
|||
struct STQ {
|
||||
SVnode* pVnode;
|
||||
char* path;
|
||||
int64_t walLogLastVer;
|
||||
|
||||
SRWLatch pushLock;
|
||||
|
||||
|
|
|
@ -726,21 +726,21 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
|
|||
|
||||
// tsdbCache ==============================================================================================
|
||||
typedef struct SCacheRowsReader {
|
||||
SVnode *pVnode;
|
||||
STSchema *pSchema;
|
||||
uint64_t uid;
|
||||
uint64_t suid;
|
||||
char **transferBuf; // todo remove it soon
|
||||
int32_t numOfCols;
|
||||
int32_t type;
|
||||
int32_t tableIndex; // currently returned result tables
|
||||
|
||||
SVnode *pVnode;
|
||||
STSchema *pSchema;
|
||||
uint64_t uid;
|
||||
uint64_t suid;
|
||||
char **transferBuf; // todo remove it soon
|
||||
int32_t numOfCols;
|
||||
int32_t type;
|
||||
int32_t tableIndex; // currently returned result tables
|
||||
STableKeyInfo *pTableList; // table id list
|
||||
int32_t numOfTables;
|
||||
SSttBlockLoadInfo *pLoadInfo;
|
||||
STsdbReadSnap *pReadSnap;
|
||||
SDataFReader *pDataFReader;
|
||||
SDataFReader *pDataFReaderLast;
|
||||
const char *idstr;
|
||||
} SCacheRowsReader;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -90,7 +90,9 @@ typedef struct SCommitInfo SCommitInfo;
|
|||
#define VND_INFO_FNAME "vnode.json"
|
||||
|
||||
// vnd.h
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int32_t size);
|
||||
|
||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||
void* vnodeBufPoolMallocAligned(SVBufPool* pPool, int size);
|
||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||
|
@ -199,6 +201,7 @@ int32_t tqProcessTaskRecover1Req(STQ* pTq, SRpcMsg* pMsg);
|
|||
int32_t tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqCheckLogInWal(STQ* pTq, int64_t version);
|
||||
|
||||
int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
||||
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
||||
|
|
|
@ -54,6 +54,7 @@ struct SMetaCache {
|
|||
|
||||
// query cache
|
||||
struct STagFilterResCache {
|
||||
TdThreadMutex lock;
|
||||
SHashObj* pTableEntry;
|
||||
SLRUCache* pUidResCache;
|
||||
uint64_t keyBuf[3];
|
||||
|
@ -140,6 +141,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
|||
}
|
||||
|
||||
taosHashSetFreeFp(pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
||||
taosThreadMutexInit(&pCache->sTagFilterResCache.lock, NULL);
|
||||
|
||||
pMeta->pCache = pCache;
|
||||
return code;
|
||||
|
||||
|
@ -159,6 +162,8 @@ void metaCacheClose(SMeta* pMeta) {
|
|||
|
||||
taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry);
|
||||
taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache);
|
||||
taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock);
|
||||
|
||||
taosMemoryFree(pMeta->pCache);
|
||||
pMeta->pCache = NULL;
|
||||
}
|
||||
|
@ -422,63 +427,78 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
|
|||
|
||||
int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1,
|
||||
bool* acquireRes) {
|
||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
||||
|
||||
// generate the composed key for LRU cache
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
||||
SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
uint32_t times = 0;
|
||||
|
||||
*acquireRes = 0;
|
||||
pBuf[0] = suid;
|
||||
memcpy(&pBuf[1], pKey, keyLen);
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
int32_t len = keyLen + sizeof(uint64_t);
|
||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
if (pHandle == NULL) {
|
||||
*acquireRes = 0;
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else { // do some book mark work after acquiring the filter result from cache
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
ASSERT(pEntry != NULL);
|
||||
*acquireRes = 1;
|
||||
}
|
||||
|
||||
const char* p = taosLRUCacheValue(pMeta->pCache->sTagFilterResCache.pUidResCache, pHandle);
|
||||
int32_t size = *(int32_t*)p;
|
||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||
// do some book mark work after acquiring the filter result from cache
|
||||
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||
ASSERT(pEntry != NULL);
|
||||
*acquireRes = 1;
|
||||
|
||||
(*pEntry)->qTimes += 1;
|
||||
taosLRUCacheRelease(pCache, pHandle, false);
|
||||
const char* p = taosLRUCacheValue(pCache, pHandle);
|
||||
int32_t size = *(int32_t*)p;
|
||||
|
||||
// check if scanning all items are necessary or not
|
||||
if ((*pEntry)->qTimes >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
||||
SArray* pList = taosArrayInit(64, POINTER_BYTES);
|
||||
// set the result into the buffer
|
||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
times = atomic_add_fetch_32(&(*pEntry)->qTimes, 1);
|
||||
taosLRUCacheRelease(pCache, pHandle, false);
|
||||
|
||||
SListNode* pNode = NULL;
|
||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||
memcpy(&pBuf[1], pNode->data, keyLen);
|
||||
// unlock meta
|
||||
taosThreadMutexUnlock(pLock);
|
||||
|
||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
if (pRes == NULL) { // remove the item in the linked list
|
||||
taosArrayPush(pList, &pNode);
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, pRes, false);
|
||||
}
|
||||
// check if scanning all items are necessary or not
|
||||
if (times >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
SArray* pInvalidRes = taosArrayInit(64, POINTER_BYTES);
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
|
||||
SListNode* pNode = NULL;
|
||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
||||
memcpy(&pBuf[1], pNode->data, keyLen);
|
||||
|
||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
||||
if (pRes == NULL) { // remove the item in the linked list
|
||||
taosArrayPush(pInvalidRes, &pNode);
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, pRes, false);
|
||||
}
|
||||
|
||||
// remove the keys, of which query uid lists have been replaced already.
|
||||
size_t s = taosArrayGetSize(pList);
|
||||
for (int32_t i = 0; i < s; ++i) {
|
||||
SListNode** p1 = taosArrayGet(pList, i);
|
||||
tdListPopNode(&(*pEntry)->list, *p1);
|
||||
taosMemoryFree(*p1);
|
||||
}
|
||||
|
||||
(*pEntry)->qTimes = 0; // reset the query times
|
||||
|
||||
taosArrayDestroy(pList);
|
||||
}
|
||||
|
||||
// remove the keys, of which query uid lists have been replaced already.
|
||||
size_t s = taosArrayGetSize(pInvalidRes);
|
||||
for (int32_t i = 0; i < s; ++i) {
|
||||
SListNode** p1 = taosArrayGet(pInvalidRes, i);
|
||||
tdListPopNode(&(*pEntry)->list, *p1);
|
||||
taosMemoryFree(*p1);
|
||||
}
|
||||
|
||||
atomic_store_32(&(*pEntry)->qTimes, 0); // reset the query times
|
||||
taosArrayDestroy(pInvalidRes);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -510,8 +530,11 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
|
||||
STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL) {
|
||||
|
@ -533,6 +556,9 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
// add to cache.
|
||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
|
||||
metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid,
|
||||
(int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry));
|
||||
|
||||
|
@ -541,15 +567,19 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
|
||||
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
|
||||
int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t keyLen = sizeof(uint64_t) * 3;
|
||||
uint64_t p[3] = {0};
|
||||
p[0] = suid;
|
||||
|
||||
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||
|
||||
taosThreadMutexLock(pLock);
|
||||
STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t));
|
||||
if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) {
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SListIter iter = {0};
|
||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||
|
||||
|
@ -562,5 +592,6 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
|||
(*pEntry)->qTimes = 0;
|
||||
tdListEmpty(&(*pEntry)->list);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
|
||||
#include "meta.h"
|
||||
|
||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBufPoolMalloc((SVBufPool *)pPool, size); }
|
||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
||||
return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
|
||||
}
|
||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta, int8_t heap) {
|
||||
|
|
|
@ -710,8 +710,8 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
metaDebug("vgId:%d, start to save ctime:%" PRId64 " uid:%" PRId64 " ct:%" PRId64, TD_VID(pMeta->pVnode), pME->version,
|
||||
pME->uid, ctimeKey.ctime);
|
||||
metaTrace("vgId:%d, start to save version:%" PRId64 " uid:%" PRId64 " ctime:%" PRId64, TD_VID(pMeta->pVnode),
|
||||
pME->version, pME->uid, ctimeKey.ctime);
|
||||
|
||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
|
|||
}
|
||||
pTq->path = strdup(path);
|
||||
pTq->pVnode = pVnode;
|
||||
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;
|
||||
|
||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
||||
|
@ -1542,3 +1543,5 @@ FAIL:
|
|||
taosFreeQitem(pMsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t tqCheckLogInWal(STQ* pTq, int64_t version) { return version <= pTq->walLogLastVer; }
|
||||
|
|
|
@ -1473,29 +1473,6 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
|||
|
||||
return code;
|
||||
}
|
||||
// int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) {
|
||||
// int32_t code = 0;
|
||||
// int16_t nCol = taosArrayGetSize(pLastArray);
|
||||
// SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal));
|
||||
|
||||
// for (int16_t iCol = 0; iCol < nCol; ++iCol) {
|
||||
// SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLastArray, iCol);
|
||||
// SColVal *tColVal = &tTsVal->colVal;
|
||||
// taosArrayPush(pColArray, tColVal);
|
||||
// }
|
||||
|
||||
// code = tdSTSRowNew(pColArray, pTSchema, ppRow);
|
||||
// if (code) goto _err;
|
||||
|
||||
// taosArrayDestroy(pColArray);
|
||||
|
||||
// return code;
|
||||
|
||||
// _err:
|
||||
// taosArrayDestroy(pColArray);
|
||||
|
||||
// return code;
|
||||
// }
|
||||
|
||||
int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **handle) {
|
||||
int32_t code = 0;
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
|
||||
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
||||
|
||||
static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||
void** pRes) {
|
||||
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
||||
static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||
void** pRes, const char* idStr) {
|
||||
int32_t numOfRows = pBlock->info.rows;
|
||||
|
||||
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||
|
@ -65,9 +64,7 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
|||
}
|
||||
|
||||
pBlock->info.rows += allNullRow ? 0 : 1;
|
||||
} else {
|
||||
ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW));
|
||||
|
||||
} else if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
||||
|
@ -94,11 +91,16 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
|||
}
|
||||
|
||||
pBlock->info.rows += 1;
|
||||
} else {
|
||||
tsdbError("invalid retrieve type:%d, %s", pReader->type, idStr);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
uint64_t suid, void** pReader) {
|
||||
uint64_t suid, void** pReader, const char* idstr) {
|
||||
*pReader = NULL;
|
||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||
if (p == NULL) {
|
||||
|
@ -142,6 +144,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
p->idstr = taosMemoryStrDup(idstr);
|
||||
|
||||
*pReader = p;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -160,6 +164,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
|
|||
|
||||
destroyLastBlockLoadInfo(p->pLoadInfo);
|
||||
|
||||
taosMemoryFree((void*) p->idstr);
|
||||
taosMemoryFree(pReader);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -312,7 +317,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
}
|
||||
|
||||
if (hasRes) {
|
||||
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes);
|
||||
saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||
}
|
||||
|
||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||
|
@ -331,7 +336,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
continue;
|
||||
}
|
||||
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||
// TODO reset the pRes
|
||||
|
||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||
|
|
|
@ -32,13 +32,13 @@ struct SLDataIter {
|
|||
};
|
||||
|
||||
SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) {
|
||||
SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo));
|
||||
SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_MAX_STT_TRIGGER, sizeof(SSttBlockLoadInfo));
|
||||
if (pLoadInfo == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
|
@ -63,7 +63,7 @@ SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList,
|
|||
}
|
||||
|
||||
void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
|
@ -77,14 +77,14 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
|||
}
|
||||
|
||||
void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
*el += pLoadInfo[i].elapsedTime;
|
||||
*blocks += pLoadInfo[i].loadBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||
for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
|
||||
for (int32_t i = 0; i < TSDB_MAX_STT_TRIGGER; ++i) {
|
||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||
pLoadInfo[i].blockIndex[0] = -1;
|
||||
pLoadInfo[i].blockIndex[1] = -1;
|
||||
|
@ -158,9 +158,9 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
pBlock, el, idStr);
|
||||
|
||||
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
|
||||
tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr);
|
||||
|
||||
pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1;
|
||||
|
||||
tsdbDebug("last block index list:%d, %d, rowIndex:%d %s", pInfo->blockIndex[0], pInfo->blockIndex[1], pIter->iRow, idStr);
|
||||
return &pInfo->blockData[pInfo->currentLoadBlockIndex];
|
||||
|
||||
_exit:
|
||||
|
@ -419,6 +419,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
|
|||
pBlockData->aUid != NULL) {
|
||||
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
|
||||
if (i == -1) {
|
||||
tsdbDebug("failed to find the data in pBlockData, uid:%"PRIu64" , %s", pIter->uid, idStr);
|
||||
pIter->iRow = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -500,7 +501,12 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
|||
|
||||
if (iBlockL != pIter->iSttBlk) {
|
||||
pBlockData = loadLastBlock(pIter, idStr);
|
||||
pIter->iRow += step;
|
||||
if (pBlockData == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// set start row index
|
||||
pIter->iRow = pIter->backward? pBlockData->nRow-1:0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -398,7 +398,6 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
|||
}
|
||||
|
||||
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
||||
ASSERT(pWindow != NULL);
|
||||
return pWindow->skey > pWindow->ekey;
|
||||
}
|
||||
|
||||
|
@ -1449,7 +1448,6 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock
|
|||
index += step;
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2423,6 +2421,46 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pBlockScanInfo,
|
||||
STsdbReader* pReader, bool* loadNeighbor) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
int32_t nextIndex = -1;
|
||||
SBlockIndex nxtBIndex = {0};
|
||||
|
||||
*loadNeighbor = false;
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &nxtBIndex);
|
||||
if (!hasNeighbor) { // do nothing
|
||||
return code;
|
||||
}
|
||||
|
||||
if (overlapWithNeighborBlock(pBlock, &nxtBIndex, pReader->order)) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
*loadNeighbor = true;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -2481,39 +2519,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||
SBlockIndex bIndex = {0};
|
||||
int32_t nextIndex = -1;
|
||||
bool hasNeighbor = false;
|
||||
if (pBlockInfo != NULL) {
|
||||
hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||
}
|
||||
pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); // NOTE: get the new block info
|
||||
|
||||
if (!hasNeighbor) { // do nothing
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
||||
if (overlapWithNeighborBlock(pBlock, &bIndex, pReader->order)) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pBlockInfo->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pBlockInfo->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
} else {
|
||||
// continue check for the next file block if the last ts in the current block
|
||||
// is overlapped with the next neighbor block
|
||||
bool loadNeighbor = false;
|
||||
code = loadNeighborIfOverlap(pBlockInfo, pBlockScanInfo, pReader, &loadNeighbor);
|
||||
if ((!loadNeighbor) || (code != 0)) {
|
||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||
break;
|
||||
}
|
||||
|
@ -2779,7 +2791,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
|
|||
|
||||
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
||||
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
||||
ASSERT(pStatus->pTableIter != NULL);
|
||||
if (pStatus->pTableIter == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3124,10 +3139,10 @@ SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_
|
|||
}
|
||||
|
||||
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
||||
ASSERT(pKey != NULL);
|
||||
if (pDelList == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t num = taosArrayGetSize(pDelList);
|
||||
bool asc = ASCENDING_TRAVERSE(order);
|
||||
int32_t step = asc ? 1 : -1;
|
||||
|
@ -3330,35 +3345,10 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
*state = CHECK_FILEBLOCK_QUIT;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
|
||||
int32_t nextIndex = -1;
|
||||
SBlockIndex bIndex = {0};
|
||||
|
||||
bool hasNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order, &bIndex);
|
||||
if (!hasNeighbor) { // do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool overlap = overlapWithNeighborBlock(pBlock, &bIndex, pReader->order);
|
||||
if (overlap) { // load next block
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
|
||||
// 1. find the next neighbor block in the scan block list
|
||||
SFileDataBlockInfo fb = {.uid = pFBlock->uid, .tbBlockIdx = nextIndex};
|
||||
int32_t neighborIndex = findFileBlockInfoIndex(pBlockIter, &fb);
|
||||
|
||||
// 2. remove it from the scan block list
|
||||
setFileBlockActiveInBlockIter(pBlockIter, neighborIndex, step);
|
||||
|
||||
// 3. load the neighbor block, and set it to be the currently accessed file data block
|
||||
int32_t code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pFBlock->uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 4. check the data values
|
||||
initBlockDumpInfo(pReader, pBlockIter);
|
||||
bool loadNeighbor = true;
|
||||
int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor);
|
||||
|
||||
if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) {
|
||||
pDumpInfo->rowIndex =
|
||||
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
||||
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
||||
|
@ -3366,7 +3356,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
||||
|
@ -3551,7 +3541,8 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
|
|||
}
|
||||
}
|
||||
|
||||
int32_t code = tsdbRowMergerGetRow(&merge, pTSRow);
|
||||
int32_t code = tRowMergerGetRow(&merge, pTSRow);
|
||||
tRowMergerClear(&merge);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3744,13 +3735,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
|||
}
|
||||
} while (1);
|
||||
|
||||
ASSERT(pBlock->info.rows <= capacity);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO refactor: with createDataBlockScanInfo
|
||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||
ASSERT(pReader != NULL);
|
||||
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||
|
||||
STableBlockScanInfo** p = NULL;
|
||||
|
@ -4114,7 +4103,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||
ASSERT(pReader != NULL);
|
||||
*rows = pReader->pResBlock->info.rows;
|
||||
*uid = pReader->pResBlock->info.id.uid;
|
||||
*pWindow = pReader->pResBlock->info.window;
|
||||
|
@ -4393,6 +4381,8 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
|||
pTableBlockInfo->numOfSmallBlocks += 1;
|
||||
}
|
||||
|
||||
pTableBlockInfo->totalSize += pBlock->aSubBlock[0].szBlock;
|
||||
|
||||
int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows);
|
||||
pTableBlockInfo->blockRowsHisto[bucketIndex]++;
|
||||
|
||||
|
|
|
@ -123,7 +123,48 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
|
|||
pPool->ptr = pPool->node.data;
|
||||
}
|
||||
|
||||
void *vnodeBufPoolMalloc(SVBufPool *pPool, int32_t size) {
|
||||
|
||||
void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) {
|
||||
SVBufPoolNode *pNode;
|
||||
void *p = NULL;
|
||||
uint8_t *ptr = NULL;
|
||||
int paddingLen = 0;
|
||||
ASSERT(pPool != NULL);
|
||||
|
||||
if (pPool->lock) taosThreadSpinLock(pPool->lock);
|
||||
|
||||
ptr = pPool->ptr;
|
||||
paddingLen = (((long)ptr + 7) & ~7) - (long)ptr;
|
||||
|
||||
if (pPool->node.size >= pPool->ptr - pPool->node.data + size + paddingLen) {
|
||||
// allocate from the anchor node
|
||||
p = pPool->ptr + paddingLen;
|
||||
size += paddingLen;
|
||||
pPool->ptr = pPool->ptr + size;
|
||||
pPool->size += size;
|
||||
} else {
|
||||
// allocate a new node
|
||||
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
||||
if (pNode == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = pNode->data;
|
||||
pNode->size = size;
|
||||
pNode->prev = pPool->pTail;
|
||||
pNode->pnext = &pPool->pTail;
|
||||
pPool->pTail->pnext = &pNode->prev;
|
||||
pPool->pTail = pNode;
|
||||
|
||||
pPool->size = pPool->size + sizeof(*pNode) + size;
|
||||
}
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||
SVBufPoolNode *pNode;
|
||||
void *p = NULL;
|
||||
ASSERT(pPool != NULL);
|
||||
|
|
|
@ -67,9 +67,8 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||
int32_t code = 0;
|
||||
|
||||
void vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||
vInfo("vgId:%d, close vnode snapshot reader", TD_VID(pReader->pVnode));
|
||||
if (pReader->pRsmaReader) {
|
||||
rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||
}
|
||||
|
@ -82,9 +81,7 @@ int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
|||
metaSnapReaderClose(&pReader->pMetaReader);
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, vnode snapshot reader closed", TD_VID(pReader->pVnode));
|
||||
taosMemoryFree(pReader);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
||||
|
|
|
@ -217,6 +217,10 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
|
||||
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||
|
||||
if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE) {
|
||||
if (tqCheckLogInWal(pVnode->pTq, version)) return 0;
|
||||
}
|
||||
|
||||
// skip header
|
||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
len = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
@ -1352,7 +1356,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
|
|||
SSingleDeleteReq *pOneReq = taosArrayGet(deleteReq.deleteReqs, i);
|
||||
char *name = pOneReq->tbname;
|
||||
if (metaGetTableEntryByName(&mr, name) < 0) {
|
||||
vDebug("stream delete msg, skip vgId:%d since no table: %s", pVnode->config.vgId, name);
|
||||
vDebug("vgId:%d, stream delete msg, skip since no table: %s", pVnode->config.vgId, name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,9 +380,8 @@ static int32_t vnodeSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
static void vnodeSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||
vnodeGetSnapshot(pFsm->data, pSnapshot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
|
@ -424,10 +423,9 @@ static int32_t vnodeSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void *
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
static void vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
int32_t code = vnodeSnapReaderClose(pReader);
|
||||
return code;
|
||||
vnodeSnapReaderClose(pReader);
|
||||
}
|
||||
|
||||
static int32_t vnodeSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||
|
@ -539,7 +537,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
|||
pFsm->FpCommitCb = vnodeSyncCommitMsg;
|
||||
pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg;
|
||||
pFsm->FpRollBackCb = vnodeSyncRollBackMsg;
|
||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshot;
|
||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshotInfo;
|
||||
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
||||
pFsm->FpLeaderTransferCb = NULL;
|
||||
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
||||
|
|
|
@ -485,6 +485,9 @@ typedef struct SCtgOperation {
|
|||
ctgOpFunc func;
|
||||
} SCtgOperation;
|
||||
|
||||
#define CTG_AUTH_READ(_t) ((_t) == AUTH_TYPE_READ || (_t) == AUTH_TYPE_READ_OR_WRITE)
|
||||
#define CTG_AUTH_WRITE(_t) ((_t) == AUTH_TYPE_WRITE || (_t) == AUTH_TYPE_READ_OR_WRITE)
|
||||
|
||||
#define CTG_QUEUE_INC() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
|
||||
#define CTG_QUEUE_DEC() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
|
||||
|
||||
|
|
|
@ -352,9 +352,9 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, co
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if (type == AUTH_TYPE_READ && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) {
|
||||
if (CTG_AUTH_READ(type) && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) {
|
||||
*pass = true;
|
||||
} else if (type == AUTH_TYPE_WRITE && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) {
|
||||
} else if (CTG_AUTH_WRITE(type) && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1549,10 +1549,10 @@ int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if (ctx->user.type == AUTH_TYPE_READ && pOut->readDbs &&
|
||||
if (CTG_AUTH_READ(ctx->user.type) && pOut->readDbs &&
|
||||
taosHashGet(pOut->readDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||
pass = true;
|
||||
} else if (ctx->user.type == AUTH_TYPE_WRITE && pOut->writeDbs &&
|
||||
} else if (CTG_AUTH_WRITE(ctx->user.type) && pOut->writeDbs &&
|
||||
taosHashGet(pOut->writeDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||
pass = true;
|
||||
}
|
||||
|
|
|
@ -718,11 +718,11 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, char *user, char *dbFName, AUTH_TYPE
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pUser->readDbs && taosHashGet(pUser->readDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_READ) {
|
||||
if (pUser->readDbs && taosHashGet(pUser->readDbs, dbFName, strlen(dbFName)) && CTG_AUTH_READ(type)) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
if (pUser->writeDbs && taosHashGet(pUser->writeDbs, dbFName, strlen(dbFName)) && type == AUTH_TYPE_WRITE) {
|
||||
if (pUser->writeDbs && taosHashGet(pUser->writeDbs, dbFName, strlen(dbFName)) && CTG_AUTH_WRITE(type)) {
|
||||
*pass = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -659,7 +659,6 @@ typedef struct SStreamFillOperatorInfo {
|
|||
SSDataBlock* pRes;
|
||||
SSDataBlock* pSrcBlock;
|
||||
int32_t srcRowIndex;
|
||||
SSDataBlock* pPrevSrcBlock;
|
||||
SSDataBlock* pSrcDelBlock;
|
||||
int32_t srcDelRowIndex;
|
||||
SSDataBlock* pDelRes;
|
||||
|
|
|
@ -90,7 +90,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
|||
|
||||
uint64_t suid = tableListGetSuid(pTableList);
|
||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader);
|
||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||
taosArrayClear(pInfo->pUidList);
|
||||
|
||||
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
||||
|
|
|
@ -896,35 +896,35 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
|
|||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL ||
|
||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) {
|
||||
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||
|
||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||
qInfo("restore stream param for interval: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION ||
|
||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION ||
|
||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
||||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||
|
||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||
qInfo("restore stream param for session: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) {
|
||||
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||
|
||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
||||
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||
qInfo("restore stream param for state: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||
}
|
||||
|
||||
|
@ -932,7 +932,7 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
|
|||
if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) {
|
||||
if (pOperator->numOfDownstream > 1) {
|
||||
qError("unexpected stream, multiple downstream");
|
||||
ASSERT(0);
|
||||
/*ASSERT(0);*/
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -99,6 +99,8 @@ static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SC
|
|||
int32_t status);
|
||||
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||
bool createDummyCol);
|
||||
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo);
|
||||
|
||||
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
|
@ -139,9 +141,6 @@ SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn,
|
|||
return fpSet;
|
||||
}
|
||||
|
||||
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
SGroupResInfo* pGroupResInfo);
|
||||
|
||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
|
||||
SFilePage* pData = NULL;
|
||||
|
||||
|
@ -200,7 +199,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
|
||||
// in case of repeat scan/reverse scan, no new time window added.
|
||||
if (isIntervalQuery) {
|
||||
if (masterscan && p1 != NULL) { // the *p1 may be NULL in case of sliding+offset exists.
|
||||
if (p1 != NULL) { // the *p1 may be NULL in case of sliding+offset exists.
|
||||
pResult = getResultRowByPos(pResultBuf, p1, true);
|
||||
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset);
|
||||
}
|
||||
|
@ -245,7 +244,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
}
|
||||
|
||||
// a new buffer page for each table. Needs to opt this design
|
||||
static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, int32_t tid, uint32_t size) {
|
||||
static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) {
|
||||
if (pWindowRes->pageId != -1) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -916,8 +915,7 @@ void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uin
|
|||
* all group belong to one result set, and each group result has different group id so set the id to be one
|
||||
*/
|
||||
if (pResultRow->pageId == -1) {
|
||||
int32_t ret =
|
||||
addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, groupId, pAggInfo->binfo.pRes->info.rowSize);
|
||||
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
|||
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||
} else {
|
||||
pBlock->info.dataLoad = 1;
|
||||
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
@ -170,6 +171,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
|||
// Fill the previous group data block, before handle the data block of new group.
|
||||
// Close the fill operation for previous group data block
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||
pInfo->pFillInfo->prev.key = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +472,6 @@ static void destroyStreamFillOperatorInfo(void* param) {
|
|||
pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup);
|
||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||
pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock);
|
||||
pInfo->pPrevSrcBlock = blockDataDestroy(pInfo->pPrevSrcBlock);
|
||||
pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes);
|
||||
pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList);
|
||||
taosMemoryFree(pInfo);
|
||||
|
@ -992,12 +993,6 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) {
|
|||
|
||||
if (pInfo->srcRowIndex == 0) {
|
||||
keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize);
|
||||
SSDataBlock* preBlock = pInfo->pPrevSrcBlock;
|
||||
if (preBlock->info.rows > 0) {
|
||||
int preRowId = preBlock->info.rows - 1;
|
||||
SColumnInfoData* pPreTsCol = taosArrayGet(preBlock->pDataBlock, pInfo->primaryTsCol);
|
||||
doFillResults(pOperator, pFillSup, pFillInfo, preBlock, (TSKEY*)pPreTsCol->pData, preRowId, pRes);
|
||||
}
|
||||
pInfo->srcRowIndex++;
|
||||
}
|
||||
|
||||
|
@ -1011,9 +1006,8 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) {
|
|||
}
|
||||
pInfo->srcRowIndex++;
|
||||
}
|
||||
doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes);
|
||||
blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol);
|
||||
blockDataCleanup(pInfo->pPrevSrcBlock);
|
||||
copyDataBlock(pInfo->pPrevSrcBlock, pInfo->pSrcBlock);
|
||||
blockDataCleanup(pInfo->pSrcBlock);
|
||||
}
|
||||
|
||||
|
@ -1173,7 +1167,6 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) {
|
||||
blockDataCleanup(pInfo->pPrevSrcBlock);
|
||||
tSimpleHashClear(pInfo->pFillSup->pResMap);
|
||||
pInfo->pFillSup->hasDelete = false;
|
||||
taosArrayClear(pInfo->pFillInfo->delRanges);
|
||||
|
@ -1231,13 +1224,6 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
|||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||
if (pBlock == NULL) {
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
SSDataBlock* preBlock = pInfo->pPrevSrcBlock;
|
||||
if (preBlock->info.rows > 0) {
|
||||
int preRowId = preBlock->info.rows - 1;
|
||||
SColumnInfoData* pPreTsCol = taosArrayGet(preBlock->pDataBlock, pInfo->primaryTsCol);
|
||||
doFillResults(pOperator, pInfo->pFillSup, pInfo->pFillInfo, preBlock, (TSKEY*)pPreTsCol->pData, preRowId,
|
||||
pInfo->pRes);
|
||||
}
|
||||
pInfo->pFillInfo->preRowKey = INT64_MIN;
|
||||
if (pInfo->pRes->info.rows > 0) {
|
||||
printDataBlock(pInfo->pRes, "stream fill");
|
||||
|
@ -1411,10 +1397,8 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
|||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||
pInfo->pSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||
pInfo->pPrevSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity);
|
||||
blockDataEnsureCapacity(pInfo->pPrevSrcBlock, pOperator->resultInfo.capacity);
|
||||
|
||||
pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes);
|
||||
if (!pInfo->pFillInfo) {
|
||||
|
|
|
@ -317,7 +317,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
|
||||
if (pProjectInfo->mergeDataBlocks) {
|
||||
if (pRes->info.rows > 0) {
|
||||
pFinalRes->info.id.groupId = pRes->info.id.groupId;
|
||||
pFinalRes->info.id.groupId = 0; //clear groupId
|
||||
pFinalRes->info.version = pRes->info.version;
|
||||
|
||||
// continue merge data, ignore the group id
|
||||
|
@ -351,6 +351,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
|
||||
SSDataBlock* p = pProjectInfo->mergeDataBlocks ? pFinalRes : pRes;
|
||||
pOperator->resultInfo.totalRows += p->info.rows;
|
||||
p->info.dataLoad = 1;
|
||||
|
||||
if (pOperator->cost.openCost == 0) {
|
||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||
|
@ -700,13 +701,30 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
|||
if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||
if (pResult->info.rows > 0 && !createNewColModel) {
|
||||
colDataMergeCol(pColInfoData, pResult->info.rows, (int32_t*)&pResult->info.capacity, pInputData->pData[0],
|
||||
pInputData->numOfRows);
|
||||
} else {
|
||||
colDataAssign(pColInfoData, pInputData->pData[0], pInputData->numOfRows, &pResult->info);
|
||||
}
|
||||
if (pInputData->pData[0] == NULL) {
|
||||
int32_t slotId = pfCtx->param[0].pCol->slotId;
|
||||
|
||||
numOfRows = pInputData->numOfRows;
|
||||
SColumnInfoData* pInput = taosArrayGet(pSrcBlock->pDataBlock, slotId);
|
||||
|
||||
colDataMergeCol(pColInfoData, pResult->info.rows, (int32_t*)&pResult->info.capacity, pInput,
|
||||
pSrcBlock->info.rows);
|
||||
} else {
|
||||
colDataMergeCol(pColInfoData, pResult->info.rows, (int32_t*)&pResult->info.capacity, pInputData->pData[0],
|
||||
pInputData->numOfRows);
|
||||
}
|
||||
} else {
|
||||
if (pInputData->pData[0] == NULL) {
|
||||
int32_t slotId = pfCtx->param[0].pCol->slotId;
|
||||
|
||||
SColumnInfoData* pInput = taosArrayGet(pSrcBlock->pDataBlock, slotId);
|
||||
colDataAssign(pColInfoData, pInput, pSrcBlock->info.rows, &pResult->info);
|
||||
|
||||
numOfRows = pSrcBlock->info.rows;
|
||||
} else {
|
||||
colDataAssign(pColInfoData, pInputData->pData[0], pInputData->numOfRows, &pResult->info);
|
||||
numOfRows = pInputData->numOfRows;
|
||||
}
|
||||
}
|
||||
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||
|
||||
|
|
|
@ -37,6 +37,22 @@
|
|||
|
||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||
|
||||
static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, int32_t rowIndex, int32_t colIdx) {
|
||||
SRowVal* p = NULL;
|
||||
if (FILL_IS_ASC_FILL(pFillInfo)) {
|
||||
if (pFillInfo->prev.key != 0) {
|
||||
p = &pFillInfo->prev; // prev has been set value
|
||||
} else { // otherwise, use the value in the next row
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
} else {
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey = taosArrayGet(p->pRowVal, colIdx);
|
||||
doSetVal(pDstColInfo, rowIndex, pKey);
|
||||
}
|
||||
|
||||
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
|
@ -45,19 +61,7 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd
|
|||
if (pCol->notFillCol) {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
||||
if (!filled) {
|
||||
SRowVal* p = NULL;
|
||||
if (FILL_IS_ASC_FILL(pFillInfo)) {
|
||||
if (pFillInfo->prev.key != 0) {
|
||||
p = &pFillInfo->prev; // prev has been set value
|
||||
} else { // otherwise, use the value in the next row
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
} else {
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey = taosArrayGet(p->pRowVal, i);
|
||||
doSetVal(pDstColInfo, rowIndex, pKey);
|
||||
setNotFillColumn(pFillInfo, pDstColInfo, rowIndex, i);
|
||||
}
|
||||
} else {
|
||||
colDataAppendNULL(pDstColInfo, rowIndex);
|
||||
|
@ -124,28 +128,23 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
|
||||
// set the other values
|
||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
|
||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
|
||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||
if (!filled) {
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstColInfoData, index, pKey);
|
||||
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||
}
|
||||
}
|
||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next.pRowVal : pFillInfo->prev.pRowVal;
|
||||
// todo refactor: start from 0 not 1
|
||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||
if (!filled) {
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstColInfoData, index, pKey);
|
||||
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||
}
|
||||
}
|
||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||
|
@ -163,9 +162,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
if (pCol->notFillCol) {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDstCol, index, pKey);
|
||||
setNotFillColumn(pFillInfo, pDstCol, index, i);
|
||||
}
|
||||
} else {
|
||||
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev.pRowVal, i);
|
||||
|
@ -205,9 +202,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
|||
if (pCol->notFillCol) {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
doSetVal(pDst, index, pKey);
|
||||
setNotFillColumn(pFillInfo, pDst, index, i);
|
||||
}
|
||||
} else {
|
||||
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
||||
|
|
|
@ -147,9 +147,23 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
|
|||
|
||||
}
|
||||
|
||||
|
||||
static FORCE_INLINE int32_t timeSliceEnsureBlockCapacity(STimeSliceOperatorInfo* pSliceInfo, SSDataBlock* pBlock) {
|
||||
if (pBlock->info.rows < pBlock->info.capacity) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t winNum = (pSliceInfo->win.ekey - pSliceInfo->win.skey) / pSliceInfo->interval.interval;
|
||||
uint32_t newRowsNum = pBlock->info.rows + TMIN(winNum / 4 + 1, 1048576);
|
||||
blockDataEnsureCapacity(pBlock, newRowsNum);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock, bool beforeTs) {
|
||||
int32_t rows = pResBlock->info.rows;
|
||||
blockDataEnsureCapacity(pResBlock, rows + 1);
|
||||
timeSliceEnsureBlockCapacity(pSliceInfo, pResBlock);
|
||||
// todo set the correct primary timestamp column
|
||||
|
||||
// output the result
|
||||
|
@ -269,7 +283,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
|
||||
static void addCurrentRowToResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock,
|
||||
SSDataBlock* pSrcBlock, int32_t index) {
|
||||
blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1);
|
||||
timeSliceEnsureBlockCapacity(pSliceInfo, pResBlock);
|
||||
for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) {
|
||||
SExprInfo* pExprInfo = &pExprSup->pExprInfo[j];
|
||||
|
||||
|
|
|
@ -1037,7 +1037,7 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
|
|||
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
||||
TSKEY* tsCols = NULL;
|
||||
|
||||
if (pBlock->pDataBlock != NULL && pBlock->info.dataLoad == 1) {
|
||||
if (pBlock->pDataBlock != NULL && pBlock->info.dataLoad) {
|
||||
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||
tsCols = (int64_t*)pColDataInfo->pData;
|
||||
ASSERT(tsCols[0] != 0);
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct SSumRes {
|
|||
int16_t type;
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
bool overflow; // if overflow is true, dsum to be used for any type;
|
||||
} SSumRes;
|
||||
|
||||
typedef struct SMinmaxResInfo {
|
||||
|
|
|
@ -1995,6 +1995,22 @@ static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowInde
|
|||
return *(TSKEY*)colDataGetData(pTsColInfo, rowIndex);
|
||||
}
|
||||
|
||||
static void prepareBuf(SqlFunctionCtx* pCtx) {
|
||||
if (pCtx->subsidiaries.rowLen == 0) {
|
||||
int32_t rowLen = 0;
|
||||
for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) {
|
||||
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
|
||||
rowLen += pc->pExpr->base.resSchema.bytes;
|
||||
}
|
||||
|
||||
pCtx->subsidiaries.rowLen = rowLen + pCtx->subsidiaries.num * sizeof(bool);
|
||||
pCtx->subsidiaries.buf = taosMemoryMalloc(pCtx->subsidiaries.rowLen);
|
||||
}
|
||||
|
||||
ASSERT(pCtx->subsidiaries.buf != NULL);
|
||||
ASSERT(pCtx->subsidiaries.rowLen > 0);
|
||||
}
|
||||
|
||||
static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx,
|
||||
SFirstLastRes* pInfo) {
|
||||
if (pCtx->subsidiaries.num <= 0) {
|
||||
|
@ -2003,8 +2019,6 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde
|
|||
|
||||
if (!pInfo->hasResult) {
|
||||
pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL);
|
||||
ASSERT(pCtx->subsidiaries.buf != NULL);
|
||||
ASSERT(pCtx->subsidiaries.rowLen > 0);
|
||||
} else {
|
||||
updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
||||
}
|
||||
|
@ -2960,16 +2974,7 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
|
|||
}
|
||||
|
||||
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) {
|
||||
if (pCtx->subsidiaries.rowLen == 0) {
|
||||
int32_t rowLen = 0;
|
||||
for (int32_t j = 0; j < pCtx->subsidiaries.num; ++j) {
|
||||
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
|
||||
rowLen += pc->pExpr->base.resSchema.bytes;
|
||||
}
|
||||
|
||||
pCtx->subsidiaries.rowLen = rowLen + pCtx->subsidiaries.num * sizeof(bool);
|
||||
pCtx->subsidiaries.buf = taosMemoryMalloc(pCtx->subsidiaries.rowLen);
|
||||
}
|
||||
prepareBuf(pCtx);
|
||||
|
||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pKey);
|
||||
|
@ -2989,6 +2994,8 @@ static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf
|
|||
}
|
||||
|
||||
int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) {
|
||||
prepareBuf(pCtx);
|
||||
|
||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||
doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -5292,7 +5299,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
|
||||
int32_t len = sprintf(st + VARSTR_HEADER_SIZE,
|
||||
"Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]",
|
||||
pData->numOfBlocks, pData->totalSize / 1024.0, averageSize, compRatio, '%');
|
||||
pData->numOfBlocks, pData->totalSize / 1024.0, averageSize/1024.0, compRatio, '%');
|
||||
|
||||
varDataSetLen(st, len);
|
||||
colDataAppend(pColInfo, row++, st, false);
|
||||
|
|
|
@ -41,6 +41,57 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
// define signed number sum with check overflow
|
||||
#define CHECK_OVERFLOW_SUM_SIGNED(out, val) \
|
||||
if (out->sum.overflow) { \
|
||||
out->sum.dsum += val; \
|
||||
} else if (out->sum.isum > 0 && val > 0 && INT64_MAX - out->sum.isum <= val || \
|
||||
out->sum.isum < 0 && val < 0 && INT64_MIN - out->sum.isum >= val) { \
|
||||
double dsum = (double)out->sum.isum; \
|
||||
out->sum.overflow = true; \
|
||||
out->sum.dsum = dsum + val; \
|
||||
} else { \
|
||||
out->sum.isum += val; \
|
||||
}
|
||||
|
||||
// val is big than INT64_MAX, val come from merge
|
||||
#define CHECK_OVERFLOW_SUM_SIGNED_BIG(out, val, big) \
|
||||
if (out->sum.overflow) { \
|
||||
out->sum.dsum += val; \
|
||||
} else if (out->sum.isum > 0 && val > 0 && INT64_MAX - out->sum.isum <= val || \
|
||||
out->sum.isum < 0 && val < 0 && INT64_MIN - out->sum.isum >= val || \
|
||||
big) { \
|
||||
double dsum = (double)out->sum.isum; \
|
||||
out->sum.overflow = true; \
|
||||
out->sum.dsum = dsum + val; \
|
||||
} else { \
|
||||
out->sum.isum += val; \
|
||||
}
|
||||
|
||||
// define unsigned number sum with check overflow
|
||||
#define CHECK_OVERFLOW_SUM_UNSIGNED(out, val) \
|
||||
if (out->sum.overflow) { \
|
||||
out->sum.dsum += val; \
|
||||
} else if (UINT64_MAX - out->sum.usum <= val) { \
|
||||
double dsum = (double)out->sum.usum; \
|
||||
out->sum.overflow = true; \
|
||||
out->sum.dsum = dsum + val; \
|
||||
} else { \
|
||||
out->sum.usum += val; \
|
||||
}
|
||||
|
||||
// val is big than UINT64_MAX, val come from merge
|
||||
#define CHECK_OVERFLOW_SUM_UNSIGNED_BIG(out, val, big) \
|
||||
if (out->sum.overflow) { \
|
||||
out->sum.dsum += val; \
|
||||
} else if (UINT64_MAX - out->sum.usum <= val || big) { \
|
||||
double dsum = (double)out->sum.usum; \
|
||||
out->sum.overflow = true; \
|
||||
out->sum.dsum = dsum + val; \
|
||||
} else { \
|
||||
out->sum.usum += val; \
|
||||
}
|
||||
|
||||
typedef struct SAvgRes {
|
||||
double result;
|
||||
SSumRes sum;
|
||||
|
@ -319,9 +370,9 @@ static int32_t calculateAvgBySMAInfo(SAvgRes* pRes, int32_t numOfRows, int32_t t
|
|||
|
||||
pRes->count += numOfElem;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
pRes->sum.isum += pAgg->sum;
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pRes, pAgg->sum);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||
pRes->sum.usum += pAgg->sum;
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, pAgg->sum);
|
||||
} else if (IS_FLOAT_TYPE(type)) {
|
||||
pRes->sum.dsum += GET_DOUBLE_VAL((const char*)&(pAgg->sum));
|
||||
}
|
||||
|
@ -344,7 +395,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -359,7 +410,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -373,7 +424,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -388,7 +439,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -402,7 +453,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.usum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -417,7 +468,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.usum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -431,7 +482,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.usum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -446,7 +497,8 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
|||
|
||||
numOfElems += 1;
|
||||
pRes->count += 1;
|
||||
pRes->sum.usum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -527,9 +579,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (type == TSDB_DATA_TYPE_TINYINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint8_t)plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint8_t)plist[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,9 +598,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint16_t)plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint16_t)plist[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,9 +617,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (type == TSDB_DATA_TYPE_INT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint32_t)plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint32_t)plist[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,9 +636,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||
} else {
|
||||
pAvgRes->sum.usum += (uint64_t)plist[i];
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pAvgRes, (uint64_t)plist[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -639,9 +691,11 @@ static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) {
|
|||
|
||||
pOutput->type = pInput->type;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pOutput->type)) {
|
||||
pOutput->sum.isum += pInput->sum.isum;
|
||||
bool overflow = pInput->sum.overflow;
|
||||
CHECK_OVERFLOW_SUM_SIGNED_BIG(pOutput, (overflow ? pInput->sum.dsum : pInput->sum.isum), overflow);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pOutput->type)) {
|
||||
pOutput->sum.usum += pInput->sum.usum;
|
||||
bool overflow = pInput->sum.overflow;
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED_BIG(pOutput, (overflow ? pInput->sum.dsum : pInput->sum.usum), overflow);
|
||||
} else {
|
||||
pOutput->sum.dsum += pInput->sum.dsum;
|
||||
}
|
||||
|
@ -741,9 +795,9 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
|||
int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type;
|
||||
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
pDBuf->sum.isum += pSBuf->sum.isum;
|
||||
CHECK_OVERFLOW_SUM_SIGNED(pDBuf, pSBuf->sum.isum)
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||
pDBuf->sum.usum += pSBuf->sum.usum;
|
||||
CHECK_OVERFLOW_SUM_UNSIGNED(pDBuf, pSBuf->sum.usum)
|
||||
} else {
|
||||
pDBuf->sum.dsum += pSBuf->sum.dsum;
|
||||
}
|
||||
|
@ -759,7 +813,10 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
int32_t type = pRes->type;
|
||||
|
||||
if (pRes->count > 0) {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
if(pRes->sum.overflow) {
|
||||
// overflow flag set , use dsum
|
||||
pRes->result = pRes->sum.dsum / ((double)pRes->count);
|
||||
}else if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
pRes->result = pRes->sum.isum / ((double)pRes->count);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||
pRes->result = pRes->sum.usum / ((double)pRes->count);
|
||||
|
|
|
@ -44,6 +44,11 @@ typedef struct IFileCtx {
|
|||
bool readOnly;
|
||||
char buf[256];
|
||||
int64_t size;
|
||||
|
||||
char* wBuf;
|
||||
int32_t wBufOffset;
|
||||
int32_t wBufCap;
|
||||
|
||||
#ifdef USE_MMAP
|
||||
char* ptr;
|
||||
#endif
|
||||
|
|
|
@ -255,7 +255,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
|||
indexError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
SIF_ERR_RET(scalarGenerateSetFromList((void **)¶m->pFilter, node, nl->dataType.type));
|
||||
SIF_ERR_RET(scalarGenerateSetFromList((void **)¶m->pFilter, node, nl->node.resType.type));
|
||||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||
taosHashCleanup(param->pFilter);
|
||||
indexError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||
|
|
|
@ -38,14 +38,41 @@ static FORCE_INLINE void idxGenLRUKey(char* buf, const char* path, int32_t block
|
|||
return;
|
||||
}
|
||||
static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||
int tlen = len;
|
||||
if (ctx->type == TFILE) {
|
||||
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
|
||||
assert(nwr == len);
|
||||
int32_t cap = ctx->file.wBufCap;
|
||||
if (len + ctx->file.wBufOffset >= cap) {
|
||||
int32_t nw = cap - ctx->file.wBufOffset;
|
||||
memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, nw);
|
||||
taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap);
|
||||
|
||||
memset(ctx->file.wBuf, 0, cap);
|
||||
ctx->file.wBufOffset = 0;
|
||||
|
||||
len -= nw;
|
||||
buf += nw;
|
||||
|
||||
nw = (len / cap) * cap;
|
||||
if (nw != 0) {
|
||||
taosWriteFile(ctx->file.pFile, buf, nw);
|
||||
}
|
||||
|
||||
len -= nw;
|
||||
buf += nw;
|
||||
if (len != 0) {
|
||||
memcpy(ctx->file.wBuf, buf, len);
|
||||
}
|
||||
ctx->file.wBufOffset += len;
|
||||
} else {
|
||||
memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, len);
|
||||
ctx->file.wBufOffset += len;
|
||||
}
|
||||
|
||||
} else {
|
||||
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
||||
}
|
||||
ctx->offset += len;
|
||||
return len;
|
||||
ctx->offset += tlen;
|
||||
return tlen;
|
||||
}
|
||||
static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||
int nRead = 0;
|
||||
|
@ -127,14 +154,22 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
|||
}
|
||||
static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
|
||||
if (ctx->type == TFILE) {
|
||||
int64_t file_size = 0;
|
||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
||||
return (int)file_size;
|
||||
if (ctx->file.readOnly == false) {
|
||||
return ctx->offset;
|
||||
} else {
|
||||
int64_t file_size = 0;
|
||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
||||
return (int)file_size;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
|
||||
if (ctx->type == TFILE) {
|
||||
if (ctx->file.wBufOffset > 0) {
|
||||
int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset);
|
||||
ctx->file.wBufOffset = 0;
|
||||
}
|
||||
taosFsyncFile(ctx->file.pFile);
|
||||
} else {
|
||||
// do nothing
|
||||
|
@ -157,10 +192,15 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
|
|||
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||
taosFtruncateFile(ctx->file.pFile, 0);
|
||||
taosStatFile(path, &ctx->file.size, NULL);
|
||||
|
||||
ctx->file.wBufOffset = 0;
|
||||
ctx->file.wBufCap = kBlockSize * 4;
|
||||
ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap);
|
||||
} else {
|
||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
||||
|
||||
taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
|
||||
ctx->file.wBufOffset = 0;
|
||||
|
||||
#ifdef USE_MMAP
|
||||
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
|
||||
#endif
|
||||
|
@ -195,17 +235,18 @@ void idxFileCtxDestroy(IFileCtx* ctx, bool remove) {
|
|||
if (ctx->type == TMEMORY) {
|
||||
taosMemoryFree(ctx->mem.buf);
|
||||
} else {
|
||||
if (ctx->file.wBufOffset > 0) {
|
||||
int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset);
|
||||
ctx->file.wBufOffset = 0;
|
||||
}
|
||||
ctx->flush(ctx);
|
||||
taosMemoryFreeClear(ctx->file.wBuf);
|
||||
taosCloseFile(&ctx->file.pFile);
|
||||
if (ctx->file.readOnly) {
|
||||
#ifdef USE_MMAP
|
||||
munmap(ctx->file.ptr, ctx->file.size);
|
||||
#endif
|
||||
}
|
||||
if (ctx->file.readOnly == false) {
|
||||
int64_t file_size = 0;
|
||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
||||
}
|
||||
if (remove) {
|
||||
unlink(ctx->file.buf);
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void sifMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *
|
|||
void sifMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->dataType.type = resType;
|
||||
lnode->node.resType.type = resType;
|
||||
lnode->pNodeList = list;
|
||||
|
||||
*pNode = (SNode *)lnode;
|
||||
|
|
|
@ -318,7 +318,7 @@ static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SInterval
|
|||
}
|
||||
|
||||
static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
||||
COPY_OBJECT_FIELD(dataType, sizeof(SDataType));
|
||||
COPY_OBJECT_FIELD(node.resType, sizeof(SDataType));
|
||||
CLONE_NODE_LIST_FIELD(pNodeList);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -3903,7 +3903,7 @@ static const char* jkNodeListNodeList = "NodeList";
|
|||
static int32_t nodeListNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SNodeListNode* pNode = (const SNodeListNode*)pObj;
|
||||
|
||||
int32_t code = tjsonAddObject(pJson, jkNodeListDataType, dataTypeToJson, &pNode->dataType);
|
||||
int32_t code = tjsonAddObject(pJson, jkNodeListDataType, dataTypeToJson, &pNode->node.resType);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkNodeListNodeList, pNode->pNodeList);
|
||||
}
|
||||
|
@ -3914,7 +3914,7 @@ static int32_t nodeListNodeToJson(const void* pObj, SJson* pJson) {
|
|||
static int32_t jsonToNodeListNode(const SJson* pJson, void* pObj) {
|
||||
SNodeListNode* pNode = (SNodeListNode*)pObj;
|
||||
|
||||
int32_t code = tjsonToObject(pJson, jkNodeListDataType, jsonToDataType, &pNode->dataType);
|
||||
int32_t code = tjsonToObject(pJson, jkNodeListDataType, jsonToDataType, &pNode->node.resType);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkNodeListNodeList, &pNode->pNodeList);
|
||||
}
|
||||
|
|
|
@ -1298,7 +1298,7 @@ enum { NODE_LIST_CODE_DATA_TYPE = 1, NODE_LIST_CODE_NODE_LIST };
|
|||
static int32_t nodeListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
const SNodeListNode* pNode = (const SNodeListNode*)pObj;
|
||||
|
||||
int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_DATA_TYPE, dataTypeInlineToMsg, &pNode->dataType);
|
||||
int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_DATA_TYPE, dataTypeInlineToMsg, &pNode->node.resType);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_NODE_LIST, nodeListToMsg, pNode->pNodeList);
|
||||
}
|
||||
|
@ -1314,7 +1314,7 @@ static int32_t msgToNodeListNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
tlvForEach(pDecoder, pTlv, code) {
|
||||
switch (pTlv->type) {
|
||||
case NODE_LIST_CODE_DATA_TYPE:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->dataType);
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->node.resType);
|
||||
break;
|
||||
case NODE_LIST_CODE_NODE_LIST:
|
||||
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList);
|
||||
|
|
|
@ -694,6 +694,7 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias)
|
|||
pExpr->aliasName[len] = '\0';
|
||||
strncpy(pExpr->userAlias, pAlias->z, len);
|
||||
pExpr->userAlias[len] = '\0';
|
||||
pExpr->asAlias = true;
|
||||
return pNode;
|
||||
}
|
||||
|
||||
|
|
|
@ -434,7 +434,7 @@ static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt
|
|||
pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser,
|
||||
((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ, pCxt->pMetaCache);
|
||||
((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ_OR_WRITE, pCxt->pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser,
|
||||
((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ, pCxt->pMetaCache);
|
||||
((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ_OR_WRITE, pCxt->pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ static int32_t authInsert(SAuthCxt* pCxt, SInsertStmt* pInsert) {
|
|||
}
|
||||
|
||||
static int32_t authShowTables(SAuthCxt* pCxt, SShowStmt* pStmt) {
|
||||
return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ);
|
||||
return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ_OR_WRITE);
|
||||
}
|
||||
|
||||
static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) {
|
||||
|
|
|
@ -1579,7 +1579,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
|||
"%s(*) is only supported in SELECTed list", pFunc->functionName);
|
||||
}
|
||||
}
|
||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias) {
|
||||
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -138,7 +138,10 @@ static int32_t adjustScanDataRequirement(SScanLogicNode* pScan, EDataOrderLevel
|
|||
} else if (TSDB_SUPER_TABLE == pScan->tableType) {
|
||||
pScan->scanType = SCAN_TYPE_TABLE_MERGE;
|
||||
}
|
||||
pScan->node.resultDataOrder = requirement;
|
||||
|
||||
if (TSDB_NORMAL_TABLE != pScan->tableType && TSDB_CHILD_TABLE != pScan->tableType) {
|
||||
pScan->node.resultDataOrder = requirement;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,11 @@ typedef struct SScalarCtx {
|
|||
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
||||
#define SCL_DEFAULT_OP_NUM 10
|
||||
|
||||
#define SCL_IS_NOTNULL_CONST_NODE(_node) ((QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||
#define SCL_IS_CONST_NODE(_node) \
|
||||
((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||
((NULL == (_node)) || SCL_IS_NOTNULL_CONST_NODE(_node))
|
||||
#define SCL_IS_VAR_VALUE_NODE(_node) ((QUERY_NODE_VALUE == (_node)->type) && IS_STR_DATA_TYPE(((SValueNode*)(_node))->node.resType.type))
|
||||
|
||||
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
||||
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode
|
||||
//*)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
||||
|
|
|
@ -3762,6 +3762,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -3785,7 +3786,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
|||
stat->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
*/
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -3931,7 +3932,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
|||
stat->scalarMode = true;
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
int32_t type = vectorGetConvertType(refNode->node.resType.type, listNode->dataType.type);
|
||||
int32_t type = vectorGetConvertType(refNode->node.resType.type, listNode->node.resType.type);
|
||||
if (0 != type && type != refNode->node.resType.type) {
|
||||
stat->scalarMode = true;
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
@ -3955,12 +3956,14 @@ int32_t fltReviseNodes(SFilterInfo *pInfo, SNode **pNode, SFltTreeStat *pStat) {
|
|||
|
||||
FLT_ERR_JRET(pStat->code);
|
||||
|
||||
/*
|
||||
int32_t nodeNum = taosArrayGetSize(pStat->nodeList);
|
||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||
SValueNode *valueNode = *(SValueNode **)taosArrayGet(pStat->nodeList, i);
|
||||
|
||||
FLT_ERR_JRET(sclConvertToTsValueNode(pStat->precision, valueNode));
|
||||
}
|
||||
*/
|
||||
|
||||
_return:
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
|
||||
int32_t type = vectorGetConvertType(ctx->type.selfType, ctx->type.peerType);
|
||||
if (type == 0) {
|
||||
type = nodeList->dataType.type;
|
||||
type = nodeList->node.resType.type;
|
||||
}
|
||||
|
||||
SCL_ERR_RET(scalarGenerateSetFromList((void **)¶m->pHashFilter, node, type));
|
||||
|
@ -507,7 +507,7 @@ int32_t sclGetNodeType(SNode *pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
case QUERY_NODE_NODE_LIST: {
|
||||
SNodeListNode *nodeList = (SNodeListNode *)pNode;
|
||||
return nodeList->dataType.type;
|
||||
return nodeList->node.resType.type;
|
||||
}
|
||||
case QUERY_NODE_COLUMN: {
|
||||
SColumnNode *colNode = (SColumnNode *)pNode;
|
||||
|
@ -1029,6 +1029,72 @@ bool sclContainsAggFuncNode(SNode *pNode) {
|
|||
return aggFunc;
|
||||
}
|
||||
|
||||
|
||||
int32_t sclConvertOpValueNodeTs(SOperatorNode *node, SScalarCtx *ctx) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) {
|
||||
if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pRight)->resType.precision, (SValueNode*)node->pLeft));
|
||||
}
|
||||
} else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) {
|
||||
if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(node->pRight)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pLeft)->resType.precision, (SValueNode*)node->pRight));
|
||||
} else if (QUERY_NODE_NODE_LIST == node->pRight->type) {
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, ((SNodeListNode*)node->pRight)->pNodeList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(pNode)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pLeft)->resType.precision, (SValueNode*)pNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node, SScalarCtx *ctx) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (NULL == node->pCase) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (SCL_IS_VAR_VALUE_NODE(node->pCase)) {
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, node->pWhenThenList) {
|
||||
SExprNode *pExpr = (SExprNode *)((SWhenThenNode *)pNode)->pWhen;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP == pExpr->resType.type) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(pExpr->resType.precision, (SValueNode*)node->pCase));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pCase)->resType.type) {
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, node->pWhenThenList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(((SWhenThenNode *)pNode)->pWhen)) {
|
||||
SCL_ERR_JRET(sclConvertToTsValueNode(((SExprNode *)node->pCase)->resType.precision, (SValueNode*)((SWhenThenNode *)pNode)->pWhen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
int32_t code = 0;
|
||||
|
@ -1040,15 +1106,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
|||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight) &&
|
||||
((SExprNode *)node->pRight)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode *)node->pRight)->resType.precision, valueNode);
|
||||
if (code) {
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) {
|
||||
sclDowngradeValueType(valueNode);
|
||||
}
|
||||
|
@ -1061,15 +1118,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
|||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
|
||||
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft) &&
|
||||
((SExprNode *)node->pLeft)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
code = sclConvertToTsValueNode(((SExprNode *)node->pLeft)->resType.precision, valueNode);
|
||||
if (code) {
|
||||
ctx->code = code;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) {
|
||||
sclDowngradeValueType(valueNode);
|
||||
}
|
||||
|
@ -1197,9 +1245,12 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
|
||||
SCL_ERR_RET(sclConvertOpValueNodeTs(node, ctx));
|
||||
|
||||
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
||||
return sclRewriteNonConstOperator(pNode, ctx);
|
||||
}
|
||||
|
@ -1245,6 +1296,8 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
|||
EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
||||
SCaseWhenNode *node = (SCaseWhenNode *)*pNode;
|
||||
|
||||
SCL_ERR_RET(sclConvertCaseWhenValueNodeTs(node, ctx));
|
||||
|
||||
if ((!SCL_IS_CONST_NODE(node->pCase)) || (!SCL_IS_CONST_NODE(node->pElse))) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ void flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeL
|
|||
void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->dataType.type = resType;
|
||||
lnode->node.resType.type = resType;
|
||||
lnode->pNodeList = list;
|
||||
|
||||
*pNode = (SNode *)lnode;
|
||||
|
|
|
@ -233,7 +233,7 @@ void scltMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode
|
|||
void scltMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->dataType.type = resType;
|
||||
lnode->node.resType.type = resType;
|
||||
lnode->pNodeList = list;
|
||||
|
||||
*pNode = (SNode *)lnode;
|
||||
|
|
|
@ -227,7 +227,7 @@ int32_t syncNodeOnRequestVoteReply(SSyncNode* pNode, const SRpcMsg* pMsg);
|
|||
int32_t syncNodeOnAppendEntries(SSyncNode* pNode, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnSnapshot(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnSnapshotRsp(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||
|
|
|
@ -86,7 +86,7 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceive
|
|||
|
||||
// on message
|
||||
int32_t syncNodeOnSnapshot(SSyncNode *ths, const SRpcMsg *pMsg);
|
||||
int32_t syncNodeOnSnapshotReply(SSyncNode *ths, const SRpcMsg *pMsg);
|
||||
int32_t syncNodeOnSnapshotRsp(SSyncNode *ths, const SRpcMsg *pMsg);
|
||||
|
||||
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode *pSyncNode, SyncIndex snapshotLastApplyIndex);
|
||||
|
||||
|
|
|
@ -100,12 +100,6 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64
|
|||
void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
||||
void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff, const char* s);
|
||||
|
||||
void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s);
|
||||
void syncLogRecvSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s);
|
||||
|
||||
void syncLogSendSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s);
|
||||
void syncLogRecvSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s);
|
||||
|
||||
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s);
|
||||
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s);
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) {
|
|||
code = syncNodeOnSnapshot(pSyncNode, pMsg);
|
||||
break;
|
||||
case TDMT_SYNC_SNAPSHOT_RSP:
|
||||
code = syncNodeOnSnapshotReply(pSyncNode, pMsg);
|
||||
code = syncNodeOnSnapshotRsp(pSyncNode, pMsg);
|
||||
break;
|
||||
case TDMT_SYNC_LOCAL_CMD:
|
||||
code = syncNodeOnLocalCmd(pSyncNode, pMsg);
|
||||
|
@ -705,7 +705,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq) {
|
|||
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t* seq) {
|
||||
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||
sNError(pSyncNode, "sync propose not leader, %s, type:%s", syncStr(pSyncNode->state), TMSG_INFO(pMsg->msgType));
|
||||
sNError(pSyncNode, "sync propose not leader, type:%s", TMSG_INFO(pMsg->msgType));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -815,11 +815,9 @@ int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) {
|
|||
ASSERTS(pNode->pLogStore != NULL, "log store not created");
|
||||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||
SSnapshot snapshot;
|
||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) {
|
||||
sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr());
|
||||
return -1;
|
||||
}
|
||||
SSnapshot snapshot = {0};
|
||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||
|
||||
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
||||
SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore);
|
||||
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||
|
@ -892,10 +890,10 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
|||
// init by SSyncInfo
|
||||
pSyncNode->vgId = pSyncInfo->vgId;
|
||||
SSyncCfg* pCfg = &pSyncInfo->syncCfg;
|
||||
sDebug("vgId:%d, replica:%d selfIndex:%d", pSyncNode->vgId, pCfg->replicaNum, pCfg->myIndex);
|
||||
sInfo("vgId:%d, start to open sync node, replica:%d selfIndex:%d", pSyncNode->vgId, pCfg->replicaNum, pCfg->myIndex);
|
||||
for (int32_t i = 0; i < pCfg->replicaNum; ++i) {
|
||||
SNodeInfo* pNode = &pCfg->nodeInfo[i];
|
||||
sDebug("vgId:%d, index:%d ep:%s:%u", pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort);
|
||||
sInfo("vgId:%d, index:%d ep:%s:%u", pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort);
|
||||
}
|
||||
|
||||
memcpy(pSyncNode->path, pSyncInfo->path, sizeof(pSyncNode->path));
|
||||
|
@ -1029,11 +1027,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
|||
SyncIndex commitIndex = SYNC_INDEX_INVALID;
|
||||
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||
SSnapshot snapshot = {0};
|
||||
int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
if (code != 0) {
|
||||
sError("vgId:%d, failed to get snapshot info, code:%d", pSyncNode->vgId, code);
|
||||
goto _error;
|
||||
}
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
if (snapshot.lastApplyIndex > commitIndex) {
|
||||
commitIndex = snapshot.lastApplyIndex;
|
||||
sNTrace(pSyncNode, "reset commit index by snapshot");
|
||||
|
@ -1092,7 +1086,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
|||
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i);
|
||||
// ASSERT(pSender != NULL);
|
||||
(pSyncNode->senders)[i] = pSender;
|
||||
sSTrace(pSender, "snapshot sender create new while open, data:%p", pSender);
|
||||
sSDebug(pSender, "snapshot sender create new while open, data:%p", pSender);
|
||||
}
|
||||
|
||||
// snapshot receivers
|
||||
|
@ -1155,9 +1149,8 @@ _error:
|
|||
|
||||
void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
||||
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||
SSnapshot snapshot;
|
||||
int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
ASSERT(code == 0);
|
||||
SSnapshot snapshot = {0};
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||
if (snapshot.lastApplyIndex > pSyncNode->commitIndex) {
|
||||
pSyncNode->commitIndex = snapshot.lastApplyIndex;
|
||||
}
|
||||
|
@ -1301,10 +1294,6 @@ void syncNodeClose(SSyncNode* pSyncNode) {
|
|||
syncNodeStopElectTimer(pSyncNode);
|
||||
syncNodeStopHeartbeatTimer(pSyncNode);
|
||||
|
||||
if (pSyncNode->pFsm != NULL) {
|
||||
taosMemoryFree(pSyncNode->pFsm);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||
if ((pSyncNode->senders)[i] != NULL) {
|
||||
sSTrace((pSyncNode->senders)[i], "snapshot sender destroy while close, data:%p", (pSyncNode->senders)[i]);
|
||||
|
@ -1327,6 +1316,10 @@ void syncNodeClose(SSyncNode* pSyncNode) {
|
|||
pSyncNode->pNewNodeReceiver = NULL;
|
||||
}
|
||||
|
||||
if (pSyncNode->pFsm != NULL) {
|
||||
taosMemoryFree(pSyncNode->pFsm);
|
||||
}
|
||||
|
||||
taosMemoryFree(pSyncNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,9 @@ SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, S
|
|||
return prevLogTerm;
|
||||
}
|
||||
|
||||
SSnapshot snapshot;
|
||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) == 0 && prevIndex == snapshot.lastApplyIndex) {
|
||||
SSnapshot snapshot = {0};
|
||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||
if (prevIndex == snapshot.lastApplyIndex) {
|
||||
return snapshot.lastApplyTerm;
|
||||
}
|
||||
|
||||
|
@ -145,11 +146,9 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
|||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||
|
||||
SSnapshot snapshot;
|
||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) {
|
||||
sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
SSnapshot snapshot = {0};
|
||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||
|
||||
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
||||
SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0);
|
||||
if (syncLogValidateAlignmentOfCommit(pNode, commitIndex)) {
|
||||
|
|
|
@ -36,21 +36,21 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) {
|
|||
taosThreadMutexInit(&(pObj->mutex), NULL);
|
||||
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, create resp manager", pNode->vgId);
|
||||
sDebug("vgId:%d, resp manager create", pNode->vgId);
|
||||
return pObj;
|
||||
}
|
||||
|
||||
void syncRespMgrDestroy(SSyncRespMgr *pObj) {
|
||||
if (pObj != NULL) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, destroy resp manager", pNode->vgId);
|
||||
if (pObj == NULL) return;
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
taosHashCleanup(pObj->pRespHash);
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
taosThreadMutexDestroy(&(pObj->mutex));
|
||||
taosMemoryFree(pObj);
|
||||
}
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sDebug("vgId:%d, resp manager destroy", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
taosHashCleanup(pObj->pRespHash);
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
taosThreadMutexDestroy(&(pObj->mutex));
|
||||
taosMemoryFree(pObj);
|
||||
}
|
||||
|
||||
uint64_t syncRespMgrAdd(SSyncRespMgr *pObj, const SRespStub *pStub) {
|
||||
|
@ -107,7 +107,7 @@ int32_t syncRespMgrGetAndDel(SSyncRespMgr *pObj, uint64_t seq, SRpcHandleInfo *p
|
|||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
return 1; // get one object
|
||||
} else {
|
||||
sNError(pObj->data, "get-and-del message handle, no object of seq:%" PRIu64, seq);
|
||||
sNTrace(pObj->data, "get-and-del message handle, no object of seq:%" PRIu64, seq);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
@ -174,7 +174,7 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
|
|||
|
||||
void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, clean all rsp", pNode->vgId);
|
||||
sTrace("vgId:%d, clean all resp", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
syncRespCleanByTTL(pObj, -1, true);
|
||||
|
@ -183,7 +183,7 @@ void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
|||
|
||||
void syncRespClean(SSyncRespMgr *pObj) {
|
||||
SSyncNode *pNode = pObj->data;
|
||||
sTrace("vgId:%d, clean rsp by ttl", pNode->vgId);
|
||||
sTrace("vgId:%d, clean resp by ttl", pNode->vgId);
|
||||
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
syncRespCleanByTTL(pObj, pObj->ttl, false);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -277,14 +277,12 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
|
|||
|
||||
if (pNode != NULL && pNode->pRaftCfg != NULL) {
|
||||
taosPrintLog(flags, level, dflag,
|
||||
"vgId:%d, sync %s "
|
||||
"%s"
|
||||
", term:%" PRIu64 ", commit-index:%" PRId64 ", first-ver:%" PRId64 ", last-ver:%" PRId64
|
||||
", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64
|
||||
"vgId:%d, %s, sync:%s, term:%" PRIu64 ", commit-index:%" PRId64 ", first-ver:%" PRId64
|
||||
", last-ver:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64
|
||||
", elect-times:%d, as-leader-times:%d, cfg-ch-times:%d, hit:%d, mis:%d, hb-slow:%d, hbr-slow:%d, "
|
||||
"aq-items:%d, snaping:%" PRId64 ", replicas:%d, last-cfg:%" PRId64
|
||||
", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%" PRId64 ", hb:%" PRId64 ", %s, %s, %s, %s",
|
||||
pNode->vgId, syncStr(pNode->state), eventLog, currentTerm, pNode->commitIndex, logBeginIndex,
|
||||
pNode->vgId, eventLog, syncStr(pNode->state), currentTerm, pNode->commitIndex, logBeginIndex,
|
||||
logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum,
|
||||
pNode->becomeLeaderNum, pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum,
|
||||
pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum,
|
||||
|
@ -330,13 +328,13 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
|
|||
va_end(argpointer);
|
||||
|
||||
taosPrintLog(flags, level, dflag,
|
||||
"vgId:%d, sync %s "
|
||||
"%s {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
||||
"vgId:%d, %s, sync:%s, {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64
|
||||
" lcindex:%" PRId64
|
||||
" seq:%d ack:%d finish:%d replica-index:%d %s:%d}"
|
||||
", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64
|
||||
", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64
|
||||
", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
||||
pNode->vgId, syncStr(pNode->state), eventLog, pSender, pSender->snapshotParam.start,
|
||||
pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->snapshotParam.start,
|
||||
pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm,
|
||||
pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex,
|
||||
host, port, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex,
|
||||
|
@ -382,14 +380,14 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df
|
|||
va_end(argpointer);
|
||||
|
||||
taosPrintLog(flags, level, dflag,
|
||||
"vgId:%d, sync %s "
|
||||
"%s {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from:%s:%d s-param:%" PRId64
|
||||
"vgId:%d, %s, sync:%s,"
|
||||
" {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from:%s:%d s-param:%" PRId64
|
||||
" e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
||||
"}"
|
||||
", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64
|
||||
", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64
|
||||
", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
|
||||
pNode->vgId, syncStr(pNode->state), eventLog, pReceiver, pReceiver->start, pReceiver->ack,
|
||||
pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack,
|
||||
pReceiver->term, pReceiver->startTime, host, port, pReceiver->snapshotParam.start,
|
||||
pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm,
|
||||
pReceiver->snapshot.lastConfigIndex, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex,
|
||||
|
@ -520,95 +518,56 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p
|
|||
port, pMsg->term, pMsg->timeStamp, s, timeDiff);
|
||||
}
|
||||
|
||||
void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||
sNTrace(pSyncNode, "send sync-pre-snapshot to %s:%d {term:%" PRId64 "}, %s", host, port, pMsg->term, s);
|
||||
}
|
||||
|
||||
void syncLogRecvSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||
sNTrace(pSyncNode, "recv sync-pre-snapshot from %s:%d {term:%" PRId64 "}, %s", host, port, pMsg->term, s);
|
||||
}
|
||||
|
||||
void syncLogSendSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||
sNTrace(pSyncNode, "send sync-pre-snapshot-reply to %s:%d {term:%" PRId64 ", snap-start:%" PRId64 "}, %s", host, port,
|
||||
pMsg->term, pMsg->snapStart, s);
|
||||
}
|
||||
|
||||
void syncLogRecvSyncPreSnapshotReply(SSyncNode* pSyncNode, const SyncPreSnapshotReply* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||
sNTrace(pSyncNode, "recv sync-pre-snapshot-reply from %s:%d {term:%" PRId64 ", snap-start:%" PRId64 "}, %s", host,
|
||||
port, pMsg->term, pMsg->snapStart, s);
|
||||
}
|
||||
|
||||
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||
|
||||
sNTrace(pSyncNode,
|
||||
"send sync-snapshot-send to %s:%d {term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64 ", lterm:%" PRId64
|
||||
", stime:%" PRId64 ", seq:%d}, %s",
|
||||
host, port, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->seq, s);
|
||||
sNDebug(pSyncNode,
|
||||
"send sync-snapshot-send to %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64
|
||||
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||
host, port, s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime);
|
||||
}
|
||||
|
||||
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||
|
||||
sNTrace(pSyncNode,
|
||||
"recv sync-snapshot-send from %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
||||
", stime:%" PRId64 ", seq:%d, len:%u}, %s",
|
||||
host, port, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->seq,
|
||||
pMsg->dataLen, s);
|
||||
sNDebug(pSyncNode,
|
||||
"recv sync-snapshot-send from %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||
", lterm:%" PRId64 ", stime:%" PRId64 ", len:%u",
|
||||
host, port, s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime,
|
||||
pMsg->dataLen);
|
||||
}
|
||||
|
||||
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
|
||||
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||
|
||||
sNTrace(pSyncNode,
|
||||
"send sync-snapshot-rsp to %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
||||
", stime:%" PRId64 ", ack:%d}, %s",
|
||||
host, port, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->ack, s);
|
||||
sNDebug(pSyncNode,
|
||||
"send sync-snapshot-rsp to %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||
host, port, s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime);
|
||||
}
|
||||
|
||||
void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
|
||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
||||
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||
|
||||
char host[64];
|
||||
uint16_t port;
|
||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||
|
||||
sNTrace(pSyncNode,
|
||||
"recv sync-snapshot-rsp from %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
||||
", stime:%" PRId64 ", ack:%d}, %s",
|
||||
host, port, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->ack, s);
|
||||
sNDebug(pSyncNode,
|
||||
"recv sync-snapshot-rsp from %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||
host, port, s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime);
|
||||
}
|
||||
|
||||
void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
|
||||
|
|
|
@ -47,7 +47,7 @@ void init() {
|
|||
pSyncNode->pWal = pWal;
|
||||
|
||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||
// pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
|
|
|
@ -47,7 +47,7 @@ void init() {
|
|||
pSyncNode->pWal = pWal;
|
||||
|
||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||
// pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
|
|
|
@ -132,7 +132,7 @@ char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) {
|
|||
}
|
||||
|
||||
int32_t syncNodeOnPreSnapshot(SSyncNode *ths, SyncPreSnapshot *pMsg) {
|
||||
syncLogRecvSyncPreSnapshot(ths, pMsg, "");
|
||||
// syncLogRecvSyncPreSnapshot(ths, pMsg, "");
|
||||
|
||||
SyncPreSnapshotReply *pMsgReply = syncPreSnapshotReplyBuild(ths->vgId);
|
||||
pMsgReply->srcId = ths->myRaftId;
|
||||
|
@ -181,7 +181,7 @@ _IGNORE:
|
|||
}
|
||||
|
||||
int32_t syncNodeOnPreSnapshotReply(SSyncNode *ths, SyncPreSnapshotReply *pMsg) {
|
||||
syncLogRecvSyncPreSnapshotReply(ths, pMsg, "");
|
||||
// syncLogRecvSyncPreSnapshotReply(ths, pMsg, "");
|
||||
|
||||
// start snapshot
|
||||
|
||||
|
|
|
@ -205,15 +205,34 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) {
|
|||
pCache->pFree = pPage;
|
||||
pPage->isFree = 0;
|
||||
++pCache->nFree;
|
||||
tdbTrace("pcache/free page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||
tdbTrace("pcache/free page %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||
} else {
|
||||
tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||
tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||
|
||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void tdbPCacheInvalidatePage(SPCache *pCache, SPager *pPager, SPgno pgno) {
|
||||
SPgid pgid;
|
||||
const SPgid *pPgid = &pgid;
|
||||
SPage *pPage = NULL;
|
||||
|
||||
memcpy(&pgid, pPager->fid, TDB_FILE_ID_LEN);
|
||||
pgid.pgno = pgno;
|
||||
|
||||
pPage = pCache->pgHash[tdbPCachePageHash(pPgid) % pCache->nHash];
|
||||
while (pPage) {
|
||||
if (pPage->pgid.pgno == pPgid->pgno && memcmp(pPage->pgid.fileid, pPgid->fileid, TDB_FILE_ID_LEN) == 0) break;
|
||||
pPage = pPage->pHashNext;
|
||||
}
|
||||
|
||||
if (pPage) {
|
||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||
}
|
||||
}
|
||||
|
||||
void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) {
|
||||
i32 nRef;
|
||||
|
||||
|
@ -359,7 +378,7 @@ static void tdbPCachePinPage(SPCache *pCache, SPage *pPage) {
|
|||
|
||||
pCache->nRecyclable--;
|
||||
|
||||
tdbTrace("pcache/pin page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||
tdbTrace("pcache/pin page %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +391,8 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) {
|
|||
|
||||
ASSERT(pPage->pLruNext == NULL);
|
||||
|
||||
tdbTrace("pCache:%p unpin page %p/%d/%d, nPages:%d", pCache, pPage, TDB_PAGE_PGNO(pPage), pPage->id, pCache->nPages);
|
||||
tdbTrace("pCache:%p unpin page %p/%d, nPages:%d, pgno:%d, ", pCache, pPage, pPage->id, pCache->nPages,
|
||||
TDB_PAGE_PGNO(pPage));
|
||||
if (pPage->id < pCache->nPages) {
|
||||
pPage->pLruPrev = &(pCache->lru);
|
||||
pPage->pLruNext = pCache->lru.pLruNext;
|
||||
|
@ -404,7 +424,7 @@ static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage) {
|
|||
// printf("rmv page %d to hash, pgno %d, pPage %p\n", pPage->id, TDB_PAGE_PGNO(pPage), pPage);
|
||||
}
|
||||
|
||||
tdbTrace("pcache/remove page %p/%d/%d from hash %" PRIu32, pPage, TDB_PAGE_PGNO(pPage), pPage->id, h);
|
||||
tdbTrace("pcache/remove page %p/%d from hash %" PRIu32 " pgno:%d, ", pPage, pPage->id, h, TDB_PAGE_PGNO(pPage));
|
||||
}
|
||||
|
||||
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
||||
|
@ -415,7 +435,7 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
|||
|
||||
pCache->nPage++;
|
||||
|
||||
tdbTrace("pcache/add page %p/%d/%d to hash %" PRIu32, pPage, TDB_PAGE_PGNO(pPage), pPage->id, h);
|
||||
tdbTrace("pcache/add page %p/%d to hash %" PRIu32 " pgno:%d, ", pPage, pPage->id, h, TDB_PAGE_PGNO(pPage));
|
||||
}
|
||||
|
||||
static int tdbPCacheOpenImpl(SPCache *pCache) {
|
||||
|
|
|
@ -299,6 +299,9 @@ int tdbPagerBegin(SPager *pPager, TXN *pTxn) {
|
|||
pTxn->jPageSet = hashset_create();
|
||||
|
||||
pPager->pActiveTxn = pTxn;
|
||||
|
||||
tdbDebug("pager/begin: %p, %d/%d, txnId:%" PRId64, pPager, pPager->dbOrigSize, pPager->dbFileSize, pTxn->txnId);
|
||||
|
||||
// TODO: write the size of the file
|
||||
/*
|
||||
pPager->inTran = 1;
|
||||
|
@ -332,7 +335,8 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
|
|||
}
|
||||
}
|
||||
|
||||
tdbTrace("tdbttl commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize);
|
||||
tdbDebug("pager/commit: %p, %d/%d, txnId:%" PRId64, pPager, pPager->dbOrigSize, pPager->dbFileSize, pTxn->txnId);
|
||||
|
||||
pPager->dbOrigSize = pPager->dbFileSize;
|
||||
|
||||
// release the page
|
||||
|
@ -381,6 +385,8 @@ int tdbPagerPostCommit(SPager *pPager, TXN *pTxn) {
|
|||
|
||||
// pPager->inTran = 0;
|
||||
|
||||
tdbDebug("pager/post-commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -477,7 +483,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
tdbDebug("tdb/abort: pager:%p,", pPager);
|
||||
tdbDebug("pager/abort: %p, %d/%d, txnId:%" PRId64, pPager, pPager->dbOrigSize, pPager->dbFileSize, pTxn->txnId);
|
||||
|
||||
for (int pgIndex = 0; pgIndex < journalSize; ++pgIndex) {
|
||||
// read pgno & the page from journal
|
||||
|
@ -489,7 +495,9 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
tdbTrace("tdb/abort: pgno:%d,", pgno);
|
||||
tdbTrace("pager/abort: restore pgno:%d,", pgno);
|
||||
|
||||
tdbPCacheInvalidatePage(pPager->pCache, pPager, pgno);
|
||||
|
||||
ret = tdbOsRead(jfd, pageBuf, pPager->pageSize);
|
||||
if (ret < 0) {
|
||||
|
@ -529,6 +537,9 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
|||
SRBTreeNode *pNode = NULL;
|
||||
while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
|
||||
pPage = (SPage *)pNode;
|
||||
SPgno pgno = TDB_PAGE_PGNO(pPage);
|
||||
|
||||
tdbTrace("pager/abort: drop dirty pgno:%d,", pgno);
|
||||
|
||||
pPage->isDirty = 0;
|
||||
|
||||
|
@ -538,7 +549,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
|||
tdbPCacheRelease(pPager->pCache, pPage, pTxn);
|
||||
}
|
||||
|
||||
tdbTrace("reset dirty tree: %p", &pPager->rbt);
|
||||
tdbTrace("pager/abort: reset dirty tree: %p", &pPager->rbt);
|
||||
tRBTreeCreate(&pPager->rbt, pageCmpFn);
|
||||
|
||||
// 4, remove the journal file
|
||||
|
@ -599,6 +610,9 @@ int tdbPagerFlushPage(SPager *pPager, TXN *pTxn) {
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
tdbDebug("pager/flush: %p, %d/%d, txnId:%" PRId64, pPager, pPager->dbOrigSize, pPager->dbFileSize, pTxn->txnId);
|
||||
|
||||
/*
|
||||
tdbTrace("tdb/flush:%p, %d/%d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize, maxPgno);
|
||||
pPager->dbOrigSize = maxPgno;
|
||||
|
|
|
@ -224,6 +224,7 @@ int tdbPCacheAlter(SPCache *pCache, int32_t nPage);
|
|||
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, TXN *pTxn);
|
||||
void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn);
|
||||
void tdbPCacheMarkFree(SPCache *pCache, SPage *pPage);
|
||||
void tdbPCacheInvalidatePage(SPCache *pCache, SPager *pPager, SPgno pgno);
|
||||
int tdbPCacheGetPageSize(SPCache *pCache);
|
||||
|
||||
// tdbPage.c ====================================
|
||||
|
|
|
@ -37,11 +37,11 @@ float tsNumOfCores = 0;
|
|||
int64_t tsTotalMemoryKB = 0;
|
||||
char *tsProcPath = NULL;
|
||||
|
||||
char tsSIMDBuiltins = 0;
|
||||
char tsSSE42Enable = 0;
|
||||
char tsAVXEnable = 0;
|
||||
char tsAVX2Enable = 0;
|
||||
char tsFMAEnable = 0;
|
||||
char tsSIMDBuiltins = 0;
|
||||
char tsSSE42Enable = 0;
|
||||
char tsAVXEnable = 0;
|
||||
char tsAVX2Enable = 0;
|
||||
char tsFMAEnable = 0;
|
||||
|
||||
void osDefaultInit() {
|
||||
taosSeedRand(taosSafeRand());
|
||||
|
|
|
@ -116,39 +116,36 @@ TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4)
|
|||
return memcpy(target_ucs4, source_ucs4, len_ucs4 * sizeof(TdUcs4));
|
||||
}
|
||||
|
||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
||||
return -1;
|
||||
#else
|
||||
iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
|
||||
size_t ucs4_input_len = ucs4_max_len;
|
||||
size_t outLen = ucs4_max_len;
|
||||
if (iconv(cd, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) {
|
||||
iconv_close(cd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
return (int32_t)(ucs4_max_len - outLen);
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
iconv_t conv;
|
||||
int8_t inUse;
|
||||
} SConv;
|
||||
|
||||
SConv *gConv = NULL;
|
||||
int32_t convUsed = 0;
|
||||
int32_t gConvMaxNum = 0;
|
||||
typedef enum { M2C = 0, C2M } ConvType;
|
||||
|
||||
// 0: Mbs --> Ucs4
|
||||
// 1: Ucs4--> Mbs
|
||||
SConv *gConv[2] = {NULL, NULL};
|
||||
int32_t convUsed[2] = {0, 0};
|
||||
int32_t gConvMaxNum[2] = {0, 0};
|
||||
|
||||
int32_t taosConvInit(void) {
|
||||
gConvMaxNum = 512;
|
||||
gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv));
|
||||
for (int32_t i = 0; i < gConvMaxNum; ++i) {
|
||||
gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
if ((iconv_t)-1 == gConv[i].conv || (iconv_t)0 == gConv[i].conv) {
|
||||
int8_t M2C = 0;
|
||||
gConvMaxNum[M2C] = 512;
|
||||
gConvMaxNum[1 - M2C] = 512;
|
||||
|
||||
gConv[M2C] = taosMemoryCalloc(gConvMaxNum[M2C], sizeof(SConv));
|
||||
gConv[1 - M2C] = taosMemoryCalloc(gConvMaxNum[1 - M2C], sizeof(SConv));
|
||||
|
||||
for (int32_t i = 0; i < gConvMaxNum[M2C]; ++i) {
|
||||
gConv[M2C][i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
if ((iconv_t)-1 == gConv[M2C][i].conv || (iconv_t)0 == gConv[M2C][i].conv) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < gConvMaxNum[1 - M2C]; ++i) {
|
||||
gConv[1 - M2C][i].conv = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
|
||||
if ((iconv_t)-1 == gConv[1 - M2C][i].conv || (iconv_t)0 == gConv[1 - M2C][i].conv) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -157,23 +154,33 @@ int32_t taosConvInit(void) {
|
|||
}
|
||||
|
||||
void taosConvDestroy() {
|
||||
for (int32_t i = 0; i < gConvMaxNum; ++i) {
|
||||
iconv_close(gConv[i].conv);
|
||||
int8_t M2C = 0;
|
||||
for (int32_t i = 0; i < gConvMaxNum[M2C]; ++i) {
|
||||
iconv_close(gConv[M2C][i].conv);
|
||||
}
|
||||
taosMemoryFreeClear(gConv);
|
||||
gConvMaxNum = -1;
|
||||
for (int32_t i = 0; i < gConvMaxNum[1 - M2C]; ++i) {
|
||||
iconv_close(gConv[1 - M2C][i].conv);
|
||||
}
|
||||
taosMemoryFreeClear(gConv[M2C]);
|
||||
taosMemoryFreeClear(gConv[1 - M2C]);
|
||||
gConvMaxNum[M2C] = -1;
|
||||
gConvMaxNum[1 - M2C] = -1;
|
||||
}
|
||||
|
||||
iconv_t taosAcquireConv(int32_t *idx) {
|
||||
if (gConvMaxNum <= 0) {
|
||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type) {
|
||||
if (gConvMaxNum[type] <= 0) {
|
||||
*idx = -1;
|
||||
return iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
if (type == M2C) {
|
||||
return iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
} else {
|
||||
return iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
int32_t used = atomic_add_fetch_32(&convUsed, 1);
|
||||
if (used > gConvMaxNum) {
|
||||
used = atomic_sub_fetch_32(&convUsed, 1);
|
||||
int32_t used = atomic_add_fetch_32(&convUsed[type], 1);
|
||||
if (used > gConvMaxNum[type]) {
|
||||
used = atomic_sub_fetch_32(&convUsed[type], 1);
|
||||
sched_yield();
|
||||
continue;
|
||||
}
|
||||
|
@ -181,31 +188,31 @@ iconv_t taosAcquireConv(int32_t *idx) {
|
|||
break;
|
||||
}
|
||||
|
||||
int32_t startId = taosGetSelfPthreadId() % gConvMaxNum;
|
||||
int32_t startId = taosGetSelfPthreadId() % gConvMaxNum[type];
|
||||
while (true) {
|
||||
if (gConv[startId].inUse) {
|
||||
startId = (startId + 1) % gConvMaxNum;
|
||||
if (gConv[type][startId].inUse) {
|
||||
startId = (startId + 1) % gConvMaxNum[type];
|
||||
continue;
|
||||
}
|
||||
|
||||
int8_t old = atomic_val_compare_exchange_8(&gConv[startId].inUse, 0, 1);
|
||||
int8_t old = atomic_val_compare_exchange_8(&gConv[type][startId].inUse, 0, 1);
|
||||
if (0 == old) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*idx = startId;
|
||||
return gConv[startId].conv;
|
||||
return gConv[type][startId].conv;
|
||||
}
|
||||
|
||||
void taosReleaseConv(int32_t idx, iconv_t conv) {
|
||||
void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type) {
|
||||
if (idx < 0) {
|
||||
iconv_close(conv);
|
||||
return;
|
||||
}
|
||||
|
||||
atomic_store_8(&gConv[idx].inUse, 0);
|
||||
atomic_sub_fetch_32(&convUsed, 1);
|
||||
atomic_store_8(&gConv[type][idx].inUse, 0);
|
||||
atomic_sub_fetch_32(&convUsed[type], 1);
|
||||
}
|
||||
|
||||
bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) {
|
||||
|
@ -216,15 +223,15 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
|||
memset(ucs4, 0, ucs4_max_len);
|
||||
|
||||
int32_t idx = -1;
|
||||
iconv_t conv = taosAcquireConv(&idx);
|
||||
iconv_t conv = taosAcquireConv(&idx, M2C);
|
||||
size_t ucs4_input_len = mbsLength;
|
||||
size_t outLeft = ucs4_max_len;
|
||||
if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) {
|
||||
taosReleaseConv(idx, conv);
|
||||
taosReleaseConv(idx, conv, M2C);
|
||||
return false;
|
||||
}
|
||||
|
||||
taosReleaseConv(idx, conv);
|
||||
taosReleaseConv(idx, conv, M2C);
|
||||
if (len != NULL) {
|
||||
*len = (int32_t)(ucs4_max_len - outLeft);
|
||||
if (*len < 0) {
|
||||
|
@ -236,6 +243,24 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
|||
#endif
|
||||
}
|
||||
|
||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
||||
return -1;
|
||||
#else
|
||||
|
||||
int32_t idx = -1;
|
||||
iconv_t conv = taosAcquireConv(&idx, C2M);
|
||||
size_t ucs4_input_len = ucs4_max_len;
|
||||
size_t outLen = ucs4_max_len;
|
||||
if (iconv(conv, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) {
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return -1;
|
||||
}
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return (int32_t)(ucs4_max_len - outLen);
|
||||
#endif
|
||||
}
|
||||
bool taosValidateEncodec(const char *encodec) {
|
||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
||||
|
|
|
@ -249,16 +249,19 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SINGLE_STB_MODE_DB, "Database is single st
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SCHEMA_VER, "Invalid schema version while alter stb")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_STABLE_UID_NOT_MATCH, "Invalid stable uid while alter stb")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA, "Field used by tsma")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_IN_CREATING, "Dnode in creating status")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_IN_DROPPING, "Dnode in dropping status")
|
||||
|
||||
// mnode-trans
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_ALREADY_EXIST, "Transaction already exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NOT_EXIST, "Transaction not exists")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_INVALID_STAGE, "Invalid stage to kill")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CONFLICT, "Conflict transaction not completed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_UNKNOW_ERROR, "Unknown transaction error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CLOG_IS_NULL, "Transaction commitlog is null")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL, "Unable to establish connection While execute transaction and will continue in the background")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED, "Last Transaction not finished")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL, "Unable to establish connection While execute transaction")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT, "Sync timeout While execute transaction and will continue in the background")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_UNKNOW_ERROR, "Unknown transaction error")
|
||||
|
||||
// mnode-mq
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_ALREADY_EXIST, "Topic already exists")
|
||||
|
|
|
@ -621,11 +621,13 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) {
|
|||
|
||||
const SDiskbasedBufStatis* ps = &pBuf->statis;
|
||||
|
||||
#if 0
|
||||
printf(
|
||||
"Paged buffer closed, total:%.2f Kb (%d Pages), inmem size:%.2f Kb (%d Pages), file size:%.2f Kb, page size:%.2f "
|
||||
"Kb, %s\n",
|
||||
pBuf->totalBufSize / 1024.0, pBuf->numOfPages, listNEles(pBuf->lruList) * pBuf->pageSize / 1024.0,
|
||||
listNEles(pBuf->lruList), pBuf->fileSize / 1024.0, pBuf->pageSize / 1024.0f, pBuf->id);
|
||||
#endif
|
||||
|
||||
if (ps->loadPages > 0) {
|
||||
printf(
|
||||
|
@ -634,7 +636,7 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) {
|
|||
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
|
||||
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
|
||||
} else {
|
||||
printf("no page loaded\n");
|
||||
//printf("no page loaded\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
,,y,script,./test.sh -f tsim/query/session.sim
|
||||
,,y,script,./test.sh -f tsim/query/udf.sim
|
||||
,,y,script,./test.sh -f tsim/query/udf_with_const.sim
|
||||
,,y,script,./test.sh -f tsim/query/groupby.sim
|
||||
,,y,script,./test.sh -f tsim/qnode/basic1.sim
|
||||
,,y,script,./test.sh -f tsim/snode/basic1.sim
|
||||
,,y,script,./test.sh -f tsim/mnode/basic1.sim
|
||||
|
@ -313,6 +314,7 @@
|
|||
,,y,script,./test.sh -f tsim/scalar/scalar.sim
|
||||
,,y,script,./test.sh -f tsim/scalar/filter.sim
|
||||
,,y,script,./test.sh -f tsim/scalar/caseWhen.sim
|
||||
,,y,script,./test.sh -f tsim/scalar/tsConvert.sim
|
||||
,,y,script,./test.sh -f tsim/alter/cached_schema_after_alter.sim
|
||||
,,y,script,./test.sh -f tsim/alter/dnode.sim
|
||||
,,y,script,./test.sh -f tsim/alter/table.sim
|
||||
|
@ -416,6 +418,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/cachemodel.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/sysinfo.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_manage.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
||||
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py
|
||||
|
@ -626,6 +629,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat2.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/json_tag.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py
|
||||
|
@ -795,6 +799,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interp.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2
|
||||
|
@ -888,6 +893,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3
|
||||
|
@ -981,6 +987,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4
|
||||
|
|
|
@ -235,7 +235,7 @@ class TAdapter:
|
|||
return
|
||||
|
||||
toBeKilled = "taosadapter"
|
||||
|
||||
|
||||
if self.running != 0:
|
||||
psCmd = f"ps -ef|grep -w {toBeKilled}| grep -v grep | awk '{{print $2}}'"
|
||||
# psCmd = f"pgrep {toBeKilled}"
|
||||
|
|
|
@ -66,32 +66,40 @@ function buildTDengine() {
|
|||
|
||||
function runCasesOneByOne () {
|
||||
while read -r line; do
|
||||
cmd=`echo $line | cut -d',' -f 5`
|
||||
if [[ "$2" == "sim" ]] && [[ $cmd == *"test.sh"* ]]; then
|
||||
case=`echo $cmd | cut -d' ' -f 3`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT \
|
||||
|| echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
elif [[ "$2" == "system-test" ]] && [[ $line == *"system-test"* ]]; then
|
||||
case=`echo $cmd | cut -d' ' -f 4`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
elif [[ "$2" == "develop-test" ]] && [[ $line == *"develop-test"* ]]; then
|
||||
case=`echo $cmd | cut -d' ' -f 4`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
fi
|
||||
if [[ "$line" != "#"* ]]; then
|
||||
cmd=`echo $line | cut -d',' -f 5`
|
||||
if [[ "$2" == "sim" ]] && [[ $line == *"script"* ]]; then
|
||||
case=`echo $cmd | cut -d' ' -f 3`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT \
|
||||
|| echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
elif [[ "$2" == "system-test" ]] && [[ $line == *"system-test"* ]]; then
|
||||
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
||||
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
||||
fi
|
||||
case=`echo $cmd | cut -d' ' -f 4-20`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
elif [[ "$2" == "develop-test" ]] && [[ $line == *"develop-test"* ]]; then
|
||||
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
||||
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
||||
fi
|
||||
case=`echo $cmd | cut -d' ' -f 4-20`
|
||||
start_time=`date +%s`
|
||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
end_time=`date +%s`
|
||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||
fi
|
||||
fi
|
||||
done < $1
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,17 @@ if $data00 != 5.000000000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart, percentile(tbcol, 10) as c from $tb interval(1d)
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @20-10-01 00:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != @1.900000000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql select * from information_schema.ins_databases
|
||||
|
|
|
@ -1075,16 +1075,11 @@ if $loop_count == 20 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 20026 then
|
||||
if $data00 != 40052 then
|
||||
print =====data00=$data00
|
||||
goto loop0
|
||||
endi
|
||||
|
||||
if $data10 != 20026 then
|
||||
print =====data10=$data10
|
||||
goto loop0
|
||||
endi
|
||||
|
||||
sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(prev);
|
||||
|
||||
if $rows != 40052 then
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
|
||||
sql drop database if exists db1;
|
||||
sql create database db1;
|
||||
sql use db1;
|
||||
sql create table test(pos_time TIMESTAMP,target_id INT ,data DOUBLE) tags(scene_id BIGINT,data_stage VARCHAR(64),data_source VARCHAR(64));
|
||||
|
||||
sql insert into _413254290_108_1001_ using test tags(108,'1001','') values(1667232060000,413254290,1);
|
||||
sql insert into _413254290_108_1001_ using test tags(108,'1001','') values(1667232061000,413254290,2);
|
||||
sql insert into _413254290_108_1001_ using test tags(108,'1001','') values(1667232062000,413254290,3);
|
||||
sql insert into _413254000_108_1001_ using test tags(109,'1001','') values(1667232060000,413254290,3);
|
||||
sql insert into _413254000_108_1001_ using test tags(109,'1001','') values(1667232062000,413254290,3);
|
||||
|
||||
sql select target_name,max(time_diff) AS time_diff,(count(1)) AS track_count from (select tbname as target_name,diff(pos_time) time_diff from test where tbname in ('_413254290_108_1001_','_413254000_108_1001_') partition by tbname) a group by target_name;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,127 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
sql drop database if exists db1;
|
||||
sql create database db1;
|
||||
sql use db1;
|
||||
sql create stable st1 (ts timestamp, f1 int, f2 binary(30)) tags(t1 int, t2 binary(30));
|
||||
sql create table tb1 using st1 tags(1, '1');
|
||||
sql insert into tb1 values ('2022-07-10 16:31:00', 1, '1');
|
||||
sql insert into tb1 values ('2022-07-10 16:32:00', 2, '2');
|
||||
sql insert into tb1 values ('2022-07-10 16:33:00', 3, '3');
|
||||
sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4');
|
||||
sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <=' 2022-11-3 23:59:59' ) t where td >12;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @22-07-10 16:31:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @22-07-10 16:32:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @22-07-10 16:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @22-07-10 16:34:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from tb1 where ts > '2022-07-10 16:32:00';
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @22-07-10 16:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @22-07-10 16:34:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from tb1 where ts + 1 > '2022-07-10 16:32:00';
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @22-07-10 16:32:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @22-07-10 16:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @22-07-10 16:34:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from tb1 where '2022-07-10 16:32:00' > timestamp '2022-07-10 16:31:59';
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @22-07-10 16:31:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @22-07-10 16:32:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @22-07-10 16:33:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @22-07-10 16:34:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select case f1 when '1' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select case ts when '2022-07-10 16:31:00' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select case '2022-07-10 16:31:00' when ts then 1 when 2022 then '2' else 3 end from tb1;
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -127,7 +127,114 @@ if $rows != 13 then
|
|||
goto loop3
|
||||
endi
|
||||
|
||||
sql insert into t2 values(1648791217000,11,11,11,11.0,'eee') (1648791219000,11,11,11,11.0,'eee') t1 values(1648791217000,11,11,11,11.0,'eee') (1648791219000,11,11,11,11.0,'eee');
|
||||
|
||||
$loop_count = 0
|
||||
|
||||
loop4:
|
||||
sleep 200
|
||||
|
||||
$loop_count = $loop_count + 1
|
||||
if $loop_count == 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select * from streamt1 order by group_id, ts;
|
||||
|
||||
if $rows != 20 then
|
||||
print ====streamt1=rows1=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
if $data04 == 0 then
|
||||
print ====streamt1=data04=$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select group_id,count(*) from streamt1 group by group_id;
|
||||
|
||||
if $rows != 2 then
|
||||
print ====streamt1=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
sql select * from streamt2 order by group_id, ts;
|
||||
|
||||
if $rows != 20 then
|
||||
print ====streamt2=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
if $data04 == 0 then
|
||||
print ====streamt2=data04=$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select group_id,count(*) from streamt2 group by group_id;
|
||||
|
||||
if $rows != 2 then
|
||||
print ====streamt2=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
sql select * from streamt3 order by group_id, ts;
|
||||
|
||||
if $rows != 20 then
|
||||
print ====streamt3=rows3=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
if $data04 == 0 then
|
||||
print ====streamt3=data04=$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select group_id,count(*) from streamt3 group by group_id;
|
||||
|
||||
if $rows != 2 then
|
||||
print ====streamt3=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
|
||||
sql select * from streamt4 order by group_id, ts;
|
||||
|
||||
if $rows != 20 then
|
||||
print ====streamt4=rows4=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
if $data04 == 0 then
|
||||
print ====streamt4=data04=$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select group_id,count(*) from streamt4 group by group_id;
|
||||
|
||||
if $rows != 2 then
|
||||
print ====streamt4=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
sql select * from streamt5 order by group_id, ts;
|
||||
|
||||
if $rows != 20 then
|
||||
print ====streamt5=rows5=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
if $data04 == 0 then
|
||||
print ====streamt5=data04=$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select group_id,count(*) from streamt5 group by group_id;
|
||||
|
||||
if $rows != 2 then
|
||||
print ====streamt5=rows2=$rows
|
||||
goto loop4
|
||||
endi
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ class TDTestCase:
|
|||
use.error(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())")
|
||||
elif check_priv == PRIVILEGES_WRITE:
|
||||
use.query(f"use {DBNAME}")
|
||||
use.error(f"show {DBNAME}.tables")
|
||||
use.query(f"show {DBNAME}.tables")
|
||||
use.error(f"select * from {DBNAME}.{CTBNAME}")
|
||||
use.query(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())")
|
||||
elif check_priv is None:
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.common import *
|
||||
from util.sqlset import *
|
||||
from taos.tmq import *
|
||||
|
||||
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.setsql = TDSetSql()
|
||||
self.stbname = 'stb'
|
||||
self.binary_length = 20 # the length of binary for column_dict
|
||||
self.nchar_length = 20 # the length of nchar for column_dict
|
||||
self.column_dict = {
|
||||
'ts' : 'timestamp',
|
||||
'col1': 'tinyint',
|
||||
'col2': 'smallint',
|
||||
'col3': 'int',
|
||||
'col4': 'bigint',
|
||||
'col5': 'tinyint unsigned',
|
||||
'col6': 'smallint unsigned',
|
||||
'col7': 'int unsigned',
|
||||
'col8': 'bigint unsigned',
|
||||
'col9': 'float',
|
||||
'col10': 'double',
|
||||
'col11': 'bool',
|
||||
'col12': f'binary({self.binary_length})',
|
||||
'col13': f'nchar({self.nchar_length})'
|
||||
}
|
||||
self.tag_dict = {
|
||||
'ts_tag' : 'timestamp',
|
||||
't1': 'tinyint',
|
||||
't2': 'smallint',
|
||||
't3': 'int',
|
||||
't4': 'bigint',
|
||||
't5': 'tinyint unsigned',
|
||||
't6': 'smallint unsigned',
|
||||
't7': 'int unsigned',
|
||||
't8': 'bigint unsigned',
|
||||
't9': 'float',
|
||||
't10': 'double',
|
||||
't11': 'bool',
|
||||
't12': f'binary({self.binary_length})',
|
||||
't13': f'nchar({self.nchar_length})'
|
||||
}
|
||||
self.tag_list = [
|
||||
f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"'
|
||||
]
|
||||
self.values_list = [
|
||||
f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"'
|
||||
]
|
||||
self.tbnum = 1
|
||||
def prepare_data(self):
|
||||
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict))
|
||||
for i in range(self.tbnum):
|
||||
tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_list[i]})')
|
||||
for j in self.values_list:
|
||||
tdSql.execute(f'insert into {self.stbname}_{i} values({j})')
|
||||
def create_user(self):
|
||||
for user_name in ['jiacy1_all','jiacy1_read','jiacy1_write','jiacy1_none','jiacy0_all','jiacy0_read','jiacy0_write','jiacy0_none']:
|
||||
if 'jiacy1' in user_name.lower():
|
||||
tdSql.execute(f'create user {user_name} pass "123" sysinfo 1')
|
||||
elif 'jiacy0' in user_name.lower():
|
||||
tdSql.execute(f'create user {user_name} pass "123" sysinfo 0')
|
||||
for user_name in ['jiacy1_all','jiacy1_read','jiacy0_all','jiacy0_read']:
|
||||
tdSql.execute(f'grant read on db to {user_name}')
|
||||
for user_name in ['jiacy1_all','jiacy1_write','jiacy0_all','jiacy0_write']:
|
||||
tdSql.execute(f'grant write on db to {user_name}')
|
||||
|
||||
def user_privilege_check(self):
|
||||
jiacy1_read_conn = taos.connect(user='jiacy1_read',password='123')
|
||||
sql = "create table ntb (ts timestamp,c0 int)"
|
||||
expectErrNotOccured = True
|
||||
try:
|
||||
jiacy1_read_conn.execute(sql)
|
||||
except BaseException:
|
||||
expectErrNotOccured = False
|
||||
if expectErrNotOccured:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, expect error not occured" )
|
||||
else:
|
||||
self.queryRows = 0
|
||||
self.queryCols = 0
|
||||
self.queryResult = None
|
||||
tdLog.info(f"sql:{sql}, expect error occured")
|
||||
pass
|
||||
def drop_topic(self):
|
||||
jiacy1_all_conn = taos.connect(user='jiacy1_all',password='123')
|
||||
jiacy1_read_conn = taos.connect(user='jiacy1_read',password='123')
|
||||
jiacy1_write_conn = taos.connect(user='jiacy1_write',password='123')
|
||||
jiacy1_none_conn = taos.connect(user='jiacy1_none',password='123')
|
||||
jiacy0_all_conn = taos.connect(user='jiacy0_all',password='123')
|
||||
jiacy0_read_conn = taos.connect(user='jiacy0_read',password='123')
|
||||
jiacy0_write_conn = taos.connect(user='jiacy0_write',password='123')
|
||||
jiacy0_none_conn = taos.connect(user='jiacy0_none',password='123')
|
||||
tdSql.execute('create topic root_db as select * from db.stb')
|
||||
for user in [jiacy1_all_conn,jiacy1_read_conn,jiacy0_all_conn,jiacy0_read_conn]:
|
||||
user.execute(f'create topic db_jiacy as select * from db.stb')
|
||||
user.execute('drop topic db_jiacy')
|
||||
for user in [jiacy1_write_conn,jiacy1_none_conn,jiacy0_write_conn,jiacy0_none_conn,jiacy1_all_conn,jiacy1_read_conn,jiacy0_all_conn,jiacy0_read_conn]:
|
||||
sql_list = []
|
||||
if user in [jiacy1_all_conn,jiacy1_read_conn,jiacy0_all_conn,jiacy0_read_conn]:
|
||||
sql_list = ['drop topic root_db']
|
||||
elif user in [jiacy1_write_conn,jiacy1_none_conn,jiacy0_write_conn,jiacy0_none_conn]:
|
||||
sql_list = ['drop topic root_db','create topic db_jiacy as select * from db.stb']
|
||||
for sql in sql_list:
|
||||
expectErrNotOccured = True
|
||||
try:
|
||||
user.execute(sql)
|
||||
except BaseException:
|
||||
expectErrNotOccured = False
|
||||
if expectErrNotOccured:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, expect error not occured" )
|
||||
else:
|
||||
self.queryRows = 0
|
||||
self.queryCols = 0
|
||||
self.queryResult = None
|
||||
tdLog.info(f"sql:{sql}, expect error occured")
|
||||
def tmq_commit_cb_print(tmq, resp, param=None):
|
||||
print(f"commit: {resp}, tmq: {tmq}, param: {param}")
|
||||
def subscribe_topic(self):
|
||||
print("create topic")
|
||||
tdSql.execute('create topic db_topic as select * from db.stb')
|
||||
tdSql.execute('grant subscribe on db_topic to jiacy1_all')
|
||||
print("build consumer")
|
||||
conf = TaosTmqConf()
|
||||
conf.set("group.id", "tg2")
|
||||
conf.set("td.connect.user", "jiacy1_all")
|
||||
conf.set("td.connect.pass", "123")
|
||||
conf.set("enable.auto.commit", "true")
|
||||
conf.set_auto_commit_cb(self.tmq_commit_cb_print, None)
|
||||
tmq = conf.new_consumer()
|
||||
print("build topic list")
|
||||
topic_list = TaosTmqList()
|
||||
topic_list.append("db_topic")
|
||||
print("basic consume loop")
|
||||
tmq.subscribe(topic_list)
|
||||
sub_list = tmq.subscription()
|
||||
print("subscribed topics: ", sub_list)
|
||||
c = 0
|
||||
l = 0
|
||||
for i in range(10):
|
||||
if c > 10:
|
||||
break
|
||||
res = tmq.poll(10)
|
||||
print(f"loop {l}")
|
||||
l += 1
|
||||
if res:
|
||||
c += 1
|
||||
topic = res.get_topic_name()
|
||||
vg = res.get_vgroup_id()
|
||||
db = res.get_db_name()
|
||||
print(f"topic: {topic}\nvgroup id: {vg}\ndb: {db}")
|
||||
for row in res:
|
||||
print(row)
|
||||
print("* committed")
|
||||
tmq.commit(res)
|
||||
else:
|
||||
print(f"received empty message at loop {l} (committed {c})")
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
self.create_user()
|
||||
self.prepare_data()
|
||||
self.drop_topic()
|
||||
self.user_privilege_check()
|
||||
self.subscribe_topic()
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -409,7 +409,7 @@ class TDTestCase:
|
|||
tdSql.query(f"select avg(c1) ,avg(c2) , avg(c3) , avg(c4), avg(c5), avg(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,920350133.571428537)
|
||||
tdSql.checkData(0,1,1.3176245766935393e+18)
|
||||
tdSql.checkData(0,1,3.952873730080618e+18)
|
||||
tdSql.checkData(0,2,14042.142857143)
|
||||
tdSql.checkData(0,3,53.571428571)
|
||||
tdSql.checkData(0,4,5.828571332045761e+37)
|
||||
|
@ -419,13 +419,56 @@ class TDTestCase:
|
|||
# check + - * / in functions
|
||||
tdSql.query(f" select avg(c1+1) ,avg(c2) , avg(c3*1) , avg(c4/2), avg(c5)/2, avg(c6) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0,0,920350134.5714285)
|
||||
tdSql.checkData(0,1,1.3176245766935393e+18)
|
||||
tdSql.checkData(0,1,3.952873730080618e+18)
|
||||
tdSql.checkData(0,2,14042.142857143)
|
||||
tdSql.checkData(0,3,26.785714286)
|
||||
tdSql.checkData(0,4,2.9142856660228804e+37)
|
||||
tdSql.checkData(0,5,None)
|
||||
|
||||
#
|
||||
# test bigint to check overflow
|
||||
#
|
||||
def avg_check_overflow(self):
|
||||
# create db
|
||||
tdSql.execute(f"drop database if exists db")
|
||||
tdSql.execute(f"create database if not exists db")
|
||||
time.sleep(3)
|
||||
tdSql.execute(f"use db")
|
||||
tdSql.execute(f"create table db.st(ts timestamp, ibv bigint, ubv bigint unsigned) tags(area int)")
|
||||
# insert t1 data
|
||||
tdSql.execute(f"insert into db.t1 using db.st tags(1) values(now,9223372036854775801,18446744073709551611)")
|
||||
tdSql.execute(f"insert into db.t1 using db.st tags(1) values(now,8223372036854775801,17446744073709551611)")
|
||||
tdSql.execute(f"insert into db.t1 using db.st tags(1) values(now,7223372036854775801,16446744073709551611)")
|
||||
# insert t2 data
|
||||
tdSql.execute(f"insert into db.t2 using db.st tags(2) values(now,9223372036854775801,18446744073709551611)")
|
||||
tdSql.execute(f"insert into db.t2 using db.st tags(2) values(now,8223372036854775801,17446744073709551611)")
|
||||
tdSql.execute(f"insert into db.t2 using db.st tags(2) values(now,7223372036854775801,16446744073709551611)")
|
||||
|
||||
# check single table answer
|
||||
tdSql.query(f"select avg(ibv), avg(ubv) from db.t1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0,8.223372036854776e+18)
|
||||
tdSql.checkData(0, 1,1.744674407370955e+19)
|
||||
|
||||
# check super table
|
||||
tdSql.query(f"select avg(ibv), avg(ubv) from db.st")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0,8.223372036854776e+18)
|
||||
tdSql.checkData(0, 1,1.744674407370955e+19)
|
||||
|
||||
# check child query
|
||||
tdSql.query(f"select avg(ibv), avg(ubv) from (select * from db.st)")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0,8.223372036854776e+18)
|
||||
tdSql.checkData(0, 1,1.744674407370955e+19)
|
||||
|
||||
# check group by
|
||||
tdSql.query(f"select avg(ibv), avg(ubv) from db.st group by tbname")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 0,8.223372036854776e+18)
|
||||
tdSql.checkData(0, 1,1.744674407370955e+19)
|
||||
tdSql.checkData(1, 0,8.223372036854776e+18)
|
||||
tdSql.checkData(1, 1,1.744674407370955e+19)
|
||||
|
||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||
tdSql.prepare()
|
||||
|
@ -455,6 +498,8 @@ class TDTestCase:
|
|||
self.avg_func_filter()
|
||||
self.avg_check_unsigned()
|
||||
|
||||
# check avg overflow
|
||||
self.avg_check_overflow()
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue