Merge branch 'main' into merge/mainto3.0_1226
This commit is contained in:
commit
664dcb6b4e
|
@ -2,7 +2,7 @@
|
||||||
IF (DEFINED VERNUMBER)
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_NUMBER "3.0.2.0")
|
SET(TD_VER_NUMBER "3.0.2.1")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERCOMPATIBLE)
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef enum {
|
||||||
AUTH_TYPE_READ = 1,
|
AUTH_TYPE_READ = 1,
|
||||||
AUTH_TYPE_WRITE,
|
AUTH_TYPE_WRITE,
|
||||||
AUTH_TYPE_OTHER,
|
AUTH_TYPE_OTHER,
|
||||||
|
AUTH_TYPE_READ_OR_WRITE,
|
||||||
} AUTH_TYPE;
|
} AUTH_TYPE;
|
||||||
|
|
||||||
typedef struct SUserAuthInfo {
|
typedef struct SUserAuthInfo {
|
||||||
|
|
|
@ -51,6 +51,7 @@ typedef struct SExprNode {
|
||||||
char userAlias[TSDB_COL_NAME_LEN];
|
char userAlias[TSDB_COL_NAME_LEN];
|
||||||
SArray* pAssociation;
|
SArray* pAssociation;
|
||||||
bool orderAlias;
|
bool orderAlias;
|
||||||
|
bool asAlias;
|
||||||
} SExprNode;
|
} SExprNode;
|
||||||
|
|
||||||
typedef enum EColumnType {
|
typedef enum EColumnType {
|
||||||
|
@ -127,8 +128,7 @@ typedef struct SLogicConditionNode {
|
||||||
} SLogicConditionNode;
|
} SLogicConditionNode;
|
||||||
|
|
||||||
typedef struct SNodeListNode {
|
typedef struct SNodeListNode {
|
||||||
ENodeType type; // QUERY_NODE_NODE_LIST
|
SExprNode node; // QUERY_NODE_NODE_LIST
|
||||||
SDataType dataType;
|
|
||||||
SNodeList* pNodeList;
|
SNodeList* pNodeList;
|
||||||
} SNodeListNode;
|
} SNodeListNode;
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,10 @@ typedef struct SSyncFSM {
|
||||||
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm);
|
||||||
|
|
||||||
int32_t (*FpGetSnapshot)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader);
|
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 (*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 (*FpSnapshotDoRead)(const struct SSyncFSM* pFsm, void* pReader, void** ppBuf, int32_t* len);
|
||||||
|
|
||||||
int32_t (*FpSnapshotStartWrite)(const struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
int32_t (*FpSnapshotStartWrite)(const struct SSyncFSM* pFsm, void* pWriterParam, void** ppWriter);
|
||||||
|
|
|
@ -203,9 +203,15 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_CANT_DROP_LEADER TAOS_DEF_ERROR_CODE(0, 0x0333)
|
#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_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_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_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_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_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
|
// mnode-acct
|
||||||
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340)
|
||||||
|
@ -297,6 +303,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x03B5)
|
#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_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_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
|
// mnode-stable-part2
|
||||||
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||||
|
@ -317,6 +325,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
#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_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_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)
|
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF)
|
||||||
|
|
||||||
// mnode-mq
|
// 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);
|
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;
|
SAppInstInfo** pInst = NULL;
|
||||||
taosThreadMutexLock(&appInfo.mutex);
|
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);
|
taosHashPut(appInfo.pInstMap, key, strlen(key), &p, POINTER_BYTES);
|
||||||
p->instKey = key;
|
p->instKey = key;
|
||||||
key = NULL;
|
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;
|
pInst = &p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) {
|
||||||
}
|
}
|
||||||
string = cJSON_PrintUnformatted(json);
|
string = cJSON_PrintUnformatted(json);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
tFreeSMAltertbReq(&req);
|
tFreeSMAltertbReq(&req);
|
||||||
return string;
|
return string;
|
||||||
|
@ -200,7 +200,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) {
|
||||||
}
|
}
|
||||||
string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE);
|
string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE);
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) {
|
||||||
}
|
}
|
||||||
string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen);
|
string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen);
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
cJSON_AddItemToArray(tags, tag);
|
cJSON_AddItemToArray(tags, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
cJSON_AddItemToObject(json, "tags", tags);
|
cJSON_AddItemToObject(json, "tags", tags);
|
||||||
taosArrayDestroy(pTagVals);
|
taosArrayDestroy(pTagVals);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pCreateReq = req.pReqs + iReq;
|
pCreateReq = req.pReqs + iReq;
|
||||||
taosMemoryFreeClear(pCreateReq->comment);
|
taosMemoryFreeClear(pCreateReq->comment);
|
||||||
|
@ -393,7 +393,7 @@ static char* processAutoCreateTable(STaosxRsp* rsp) {
|
||||||
}
|
}
|
||||||
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
for (int i = 0; i < rsp->createTableNum; i++) {
|
for (int i = 0; i < rsp->createTableNum; i++) {
|
||||||
tDecoderClear(&decoder[i]);
|
tDecoderClear(&decoder[i]);
|
||||||
taosMemoryFreeClear(pCreateReq[i].comment);
|
taosMemoryFreeClear(pCreateReq[i].comment);
|
||||||
|
@ -515,7 +515,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
||||||
}
|
}
|
||||||
string = cJSON_PrintUnformatted(json);
|
string = cJSON_PrintUnformatted(json);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return string;
|
return string;
|
||||||
|
@ -548,11 +548,50 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) {
|
||||||
|
|
||||||
string = cJSON_PrintUnformatted(json);
|
string = cJSON_PrintUnformatted(json);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return string;
|
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) {
|
static char* processDropTable(SMqMetaRsp* metaRsp) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
@ -590,7 +629,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) {
|
||||||
|
|
||||||
string = cJSON_PrintUnformatted(json);
|
string = cJSON_PrintUnformatted(json);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return string;
|
return string;
|
||||||
|
@ -678,7 +717,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
taosMemoryFree(pCmdMsg.pMsg);
|
taosMemoryFree(pCmdMsg.pMsg);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
tFreeSMCreateStbReq(&pReq);
|
tFreeSMCreateStbReq(&pReq);
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
|
@ -748,7 +787,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
taosMemoryFree(pCmdMsg.pMsg);
|
taosMemoryFree(pCmdMsg.pMsg);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return code;
|
return code;
|
||||||
|
@ -809,9 +848,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch);
|
taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch);
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||||
|
|
||||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||||
// loop to create table
|
// loop to create table
|
||||||
|
@ -891,7 +930,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
|
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pCreateReq = req.pReqs + iReq;
|
pCreateReq = req.pReqs + iReq;
|
||||||
taosMemoryFreeClear(pCreateReq->comment);
|
taosMemoryFreeClear(pCreateReq->comment);
|
||||||
|
@ -961,9 +1000,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch);
|
taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch);
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||||
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName));
|
||||||
// loop to create table
|
// loop to create table
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
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;
|
code = pRequest->code;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
taosHashCleanup(pVgroupHashmap);
|
taosHashCleanup(pVgroupHashmap);
|
||||||
destroyRequest(pRequest);
|
destroyRequest(pRequest);
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
|
@ -1073,7 +1112,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
char sql[256] = {0};
|
char sql[256] = {0};
|
||||||
snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName,
|
snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName,
|
||||||
req.tsColName, req.skey, req.tsColName, req.ekey);
|
req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||||
printf("delete sql:%s\n", sql);
|
uDebug("delete sql:%s\n", sql);
|
||||||
|
|
||||||
TAOS_RES* res = taos_query(taos, sql);
|
TAOS_RES* res = taos_query(taos, sql);
|
||||||
SRequestObj* pRequest = (SRequestObj*)res;
|
SRequestObj* pRequest = (SRequestObj*)res;
|
||||||
|
@ -1083,7 +1122,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
}
|
}
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tDecoderClear(&coder);
|
tDecoderClear(&coder);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1130,9 +1169,9 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||||
|
|
||||||
SVgroupInfo pInfo = {0};
|
SVgroupInfo pInfo = {0};
|
||||||
SName pName = {0};
|
SName pName = {0};
|
||||||
|
@ -1191,7 +1230,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
code = handleAlterTbExecRes(pRes->res, pCatalog);
|
code = handleAlterTbExecRes(pRes->res, pCatalog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
if (pVgData) taosMemoryFreeClear(pVgData->pData);
|
||||||
taosMemoryFreeClear(pVgData);
|
taosMemoryFreeClear(pVgData);
|
||||||
|
@ -1600,7 +1639,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
||||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
taosMemoryFreeClear(pTableMeta);
|
taosMemoryFreeClear(pTableMeta);
|
||||||
qDestroyQuery(pQuery);
|
qDestroyQuery(pQuery);
|
||||||
taosMemoryFree(subReq);
|
taosMemoryFree(subReq);
|
||||||
|
@ -1655,7 +1694,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
conn.requestObjRefId = pRequest->self;
|
conn.requestObjRefId = pRequest->self;
|
||||||
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
||||||
printf("raw data block num:%d\n", rspObj.rsp.blockNum);
|
uDebug("raw data block num:%d\n", rspObj.rsp.blockNum);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.withSchema) {
|
||||||
|
@ -1678,7 +1717,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("raw data tbname:%s\n", tbName);
|
uDebug("raw data tbname:%s\n", tbName);
|
||||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||||
strcpy(pName.dbname, pRequest->pDb);
|
strcpy(pName.dbname, pRequest->pDb);
|
||||||
strcpy(pName.tname, tbName);
|
strcpy(pName.tname, tbName);
|
||||||
|
@ -1864,7 +1903,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
launchQueryImpl(pRequest, pQuery, true, NULL);
|
launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||||
code = pRequest->code;
|
code = pRequest->code;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tDeleteSMqDataRsp(&rspObj.rsp);
|
tDeleteSMqDataRsp(&rspObj.rsp);
|
||||||
rspObj.resInfo.pRspMsg = NULL;
|
rspObj.resInfo.pRspMsg = NULL;
|
||||||
doFreeReqResultInfo(&rspObj.resInfo);
|
doFreeReqResultInfo(&rspObj.resInfo);
|
||||||
|
@ -1924,7 +1963,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
conn.requestObjRefId = pRequest->self;
|
conn.requestObjRefId = pRequest->self;
|
||||||
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
||||||
printf("raw data block num:%d\n", rspObj.rsp.blockNum);
|
uDebug("raw data block num:%d\n", rspObj.rsp.blockNum);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.withSchema) {
|
||||||
|
@ -1947,7 +1986,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("raw data tbname:%s\n", tbName);
|
uDebug("raw data tbname:%s\n", tbName);
|
||||||
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}};
|
||||||
strcpy(pName.dbname, pRequest->pDb);
|
strcpy(pName.dbname, pRequest->pDb);
|
||||||
strcpy(pName.tname, tbName);
|
strcpy(pName.tname, tbName);
|
||||||
|
@ -2204,7 +2243,12 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
||||||
return processAlterTable(&pMetaRspObj->metaRsp);
|
return processAlterTable(&pMetaRspObj->metaRsp);
|
||||||
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
} else if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DROP_TABLE) {
|
||||||
return processDropTable(&pMetaRspObj->metaRsp);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1902,10 +1902,6 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) {
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
return TMQ_RES_DATA;
|
return TMQ_RES_DATA;
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} 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;
|
return TMQ_RES_TABLE_META;
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
return TMQ_RES_METADATA;
|
return TMQ_RES_METADATA;
|
||||||
|
|
|
@ -41,6 +41,8 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
pMgmt->statusSeq);
|
pMgmt->statusSeq);
|
||||||
pMgmt->pData->dropped = 1;
|
pMgmt->pData->dropped = 1;
|
||||||
dmWriteEps(pMgmt->pData);
|
dmWriteEps(pMgmt->pData);
|
||||||
|
dInfo("dnode will exit since it is in the dropped state");
|
||||||
|
raise(SIGINT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SStatusRsp statusRsp = {0};
|
SStatusRsp statusRsp = {0};
|
||||||
|
|
|
@ -53,6 +53,15 @@ static bool dmFailFastFp(tmsg_t msgType) {
|
||||||
return msgType == TDMT_SYNC_HEARTBEAT || msgType == TDMT_SYNC_APPEND_ENTRIES;
|
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) {
|
static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
int32_t code = -1;
|
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));
|
dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType));
|
||||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||||
goto _OVER;
|
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) {
|
if (pHandle->defaultNtype == NODE_END) {
|
||||||
dGError("msg:%p, type:%s not processed since no handle", pRpc, TMSG_INFO(pRpc->msgType));
|
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:
|
_OVER:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
dmConvertErrCode(pRpc->msgType);
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
if (pMsg) {
|
if (pMsg) {
|
||||||
dGTrace("msg:%p, failed to process %s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
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);
|
mInfo("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, dbObj.name, NULL);
|
mndTransSetDbName(pTrans, dbObj.name, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
mndTransSetOper(pTrans, MND_OPER_CREATE_DB);
|
mndTransSetOper(pTrans, MND_OPER_CREATE_DB);
|
||||||
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
if (mndSetCreateDbRedoLogs(pMnode, pTrans, &dbObj, pVgroups) != 0) goto _OVER;
|
||||||
if (mndSetCreateDbUndoLogs(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;
|
int32_t code = -1;
|
||||||
mndTransSetDbName(pTrans, pOld->name, NULL);
|
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 (mndSetAlterDbRedoLogs(pMnode, pTrans, pOld, pNew) != 0) goto _OVER;
|
||||||
if (mndSetAlterDbCommitLogs(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);
|
mInfo("trans:%d, used to drop db:%s", pTrans->id, pDb->name);
|
||||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
if (mndCheckTopicExist(pMnode, pDb) < 0) goto _OVER;
|
if (mndCheckTopicExist(pMnode, pDb) < 0) goto _OVER;
|
||||||
|
|
||||||
if (mndSetDropDbRedoLogs(pMnode, pTrans, 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;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SDnodeObj *pDnode = sdbAcquire(pSdb, SDB_DNODE, &dnodeId);
|
SDnodeObj *pDnode = sdbAcquire(pSdb, SDB_DNODE, &dnodeId);
|
||||||
if (pDnode == NULL) {
|
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;
|
return pDnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +264,27 @@ static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) {
|
||||||
return NULL;
|
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) {
|
int32_t mndGetDnodeSize(SMnode *pMnode) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
return sdbGetSize(pSdb, SDB_DNODE);
|
return sdbGetSize(pSdb, SDB_DNODE);
|
||||||
|
@ -340,12 +371,22 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
} else {
|
} else {
|
||||||
pDnode = mndAcquireDnode(pMnode, statusReq.dnodeId);
|
pDnode = mndAcquireDnode(pMnode, statusReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
|
int32_t err = terrno;
|
||||||
pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp);
|
pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
pDnode->offlineReason = DND_REASON_DNODE_ID_NOT_MATCH;
|
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");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mInfo("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
mInfo("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
pRaw = mndDnodeActionEncode(&dnodeObj);
|
pRaw = mndDnodeActionEncode(&dnodeObj);
|
||||||
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
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;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
mInfo("trans:%d, used to drop dnode:%d, force:%d", pTrans->id, pDnode->id, force);
|
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);
|
pRaw = mndDnodeActionEncode(pDnode);
|
||||||
if (pRaw == NULL) goto _OVER;
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
@ -762,11 +805,12 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
pDnode = mndAcquireDnode(pMnode, dropReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
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);
|
snprintf(ep, sizeof(ep), dropReq.fqdn, dropReq.port);
|
||||||
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
pDnode = mndAcquireDnodeByEp(pMnode, ep);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = err;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -967,11 +1011,12 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
ESdbStatus objStatus = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
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;
|
if (pShow->pIter == NULL) break;
|
||||||
bool online = mndIsDnodeOnline(pDnode, curMs);
|
bool online = mndIsDnodeOnline(pDnode, curMs);
|
||||||
|
|
||||||
|
@ -993,8 +1038,20 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pDnode->numOfSupportVnodes, false);
|
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};
|
char b1[9] = {0};
|
||||||
STR_TO_VARSTR(b1, online ? "ready" : "offline");
|
STR_TO_VARSTR(b1, status);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, b1, false);
|
colDataAppend(pColInfo, numOfRows, b1, false);
|
||||||
|
|
||||||
|
|
|
@ -390,6 +390,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId);
|
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 (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &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;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id);
|
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 (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pObj, false) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 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";
|
const char *status = "ready";
|
||||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||||
|
if (!mndIsDnodeOnline(pObj->pDnode, curMs)) status = "offline";
|
||||||
char b3[9 + VARSTR_HEADER_SIZE] = {0};
|
char b3[9 + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
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");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-sma");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
mInfo("trans:%d, used to create sma:%s stream:%s", pTrans->id, pCreate->name, streamObj.name);
|
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);
|
mInfo("trans:%d, used to drop sma:%s", pTrans->id, pSma->name);
|
||||||
mndTransSetDbName(pTrans, pDb->name, NULL);
|
mndTransSetDbName(pTrans, pDb->name, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
|
|
@ -823,6 +823,7 @@ _OVER:
|
||||||
|
|
||||||
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) return -1;
|
||||||
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) return -1;
|
||||||
if (mndSetCreateStbUndoLogs(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;
|
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);
|
mInfo("trans:%d, used to alter stb:%s", pTrans->id, pStb->name);
|
||||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
if (needRsp) {
|
if (needRsp) {
|
||||||
void *pCont = NULL;
|
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);
|
mInfo("trans:%d, used to drop stb:%s", pTrans->id, pStb->name);
|
||||||
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
mndTransSetDbName(pTrans, pDb->name, pStb->name);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
if (mndSetDropStbCommitLogs(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());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb);
|
|
||||||
mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name);
|
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
|
// create stb for stream
|
||||||
if (mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) {
|
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());
|
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");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "stream-checkpoint");
|
||||||
if (pTrans == NULL) return -1;
|
if (pTrans == NULL) return -1;
|
||||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||||
|
mndReleaseStream(pMnode, pStream);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
taosRLockLatch(&pStream->lock);
|
taosRLockLatch(&pStream->lock);
|
||||||
// 1. redo action: broadcast checkpoint source msg for all source vg
|
// 1. redo action: broadcast checkpoint source msg for all source vg
|
||||||
int32_t totLevel = taosArrayGetSize(pStream->tasks);
|
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) {
|
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) {
|
||||||
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stream");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stream");
|
||||||
mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb);
|
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
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);
|
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
|
// drop all tasks
|
||||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
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) {
|
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");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "tmq-reb");
|
||||||
if (pTrans == NULL) return -1;
|
if (pTrans == NULL) return -1;
|
||||||
|
|
||||||
mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL);
|
mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL);
|
||||||
|
if (mndTrancCheckConflict(pMnode, pTrans) != 0) {
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// make txn:
|
// make txn:
|
||||||
// 1. redo action: action to all vg
|
// 1. redo action: action to all vg
|
||||||
|
|
|
@ -142,10 +142,9 @@ int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pRe
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
static void mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||||
SMnode *pMnode = pFsm->data;
|
SMnode *pMnode = pFsm->data;
|
||||||
sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex);
|
sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndRestoreFinish(const SSyncFSM *pFsm) {
|
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);
|
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");
|
mInfo("stop to read snapshot from sdb");
|
||||||
SMnode *pMnode = pFsm->data;
|
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) {
|
int32_t mndSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||||
|
|
|
@ -706,13 +706,19 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic");
|
||||||
mndTransSetDbName(pTrans, pTopic->db, NULL);
|
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
mError("topic:%s, failed to drop since %s", pTopic->name, terrstr());
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
return -1;
|
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);
|
mInfo("trans:%d, used to drop topic:%s", pTrans->id, pTopic->name);
|
||||||
|
|
||||||
// TODO check if rebalancing
|
// TODO check if rebalancing
|
||||||
|
|
|
@ -960,6 +960,10 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
|
||||||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
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) {
|
if (i != 0 && code == 0) {
|
||||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ void *sdbGetRowObj(SSdbRow *pRow);
|
||||||
void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc);
|
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 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 sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len);
|
||||||
|
|
||||||
int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbStopRead(SSdb *pSdb, SSdbIter *pIter) {
|
void sdbStopRead(SSdb *pSdb, SSdbIter *pIter) { sdbCloseIter(pIter); }
|
||||||
sdbCloseIter(pIter);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
|
int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
|
||||||
int32_t maxlen = 4096;
|
int32_t maxlen = 4096;
|
||||||
|
|
|
@ -185,7 +185,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
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);
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||||
void *tsdbCacherowsReaderClose(void *pReader);
|
void *tsdbCacherowsReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
@ -264,7 +264,7 @@ int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *
|
||||||
|
|
||||||
// SVSnapReader
|
// SVSnapReader
|
||||||
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader);
|
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);
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
||||||
// SVSnapWriter
|
// SVSnapWriter
|
||||||
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
||||||
|
|
|
@ -121,6 +121,7 @@ typedef struct {
|
||||||
struct STQ {
|
struct STQ {
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
char* path;
|
char* path;
|
||||||
|
int64_t walLogLastVer;
|
||||||
|
|
||||||
SRWLatch pushLock;
|
SRWLatch pushLock;
|
||||||
|
|
||||||
|
|
|
@ -715,21 +715,21 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
|
||||||
|
|
||||||
// tsdbCache ==============================================================================================
|
// tsdbCache ==============================================================================================
|
||||||
typedef struct SCacheRowsReader {
|
typedef struct SCacheRowsReader {
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
STSchema *pSchema;
|
STSchema *pSchema;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
char **transferBuf; // todo remove it soon
|
char **transferBuf; // todo remove it soon
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
int32_t tableIndex; // currently returned result tables
|
int32_t tableIndex; // currently returned result tables
|
||||||
|
|
||||||
STableKeyInfo *pTableList; // table id list
|
STableKeyInfo *pTableList; // table id list
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
SSttBlockLoadInfo *pLoadInfo;
|
SSttBlockLoadInfo *pLoadInfo;
|
||||||
STsdbReadSnap *pReadSnap;
|
STsdbReadSnap *pReadSnap;
|
||||||
SDataFReader *pDataFReader;
|
SDataFReader *pDataFReader;
|
||||||
SDataFReader *pDataFReaderLast;
|
SDataFReader *pDataFReaderLast;
|
||||||
|
const char *idstr;
|
||||||
} SCacheRowsReader;
|
} SCacheRowsReader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -752,8 +752,6 @@ int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
|
||||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||||
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
||||||
|
|
||||||
int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pSchema);
|
|
||||||
|
|
||||||
// ========== inline functions ==========
|
// ========== inline functions ==========
|
||||||
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
||||||
|
|
|
@ -91,6 +91,7 @@ typedef struct SCommitInfo SCommitInfo;
|
||||||
|
|
||||||
// vnd.h
|
// vnd.h
|
||||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||||
|
void* vnodeBufPoolMallocAligned(SVBufPool* pPool, int size);
|
||||||
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
void vnodeBufPoolFree(SVBufPool* pPool, void* p);
|
||||||
void vnodeBufPoolRef(SVBufPool* pPool);
|
void vnodeBufPoolRef(SVBufPool* pPool);
|
||||||
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
void vnodeBufPoolUnRef(SVBufPool* pPool);
|
||||||
|
@ -200,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 tqProcessTaskRecover2Req(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRecoverFinishReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
int32_t tqCheckLogInWal(STQ* pTq, int64_t version);
|
||||||
|
|
||||||
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
|
||||||
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
|
||||||
|
|
|
@ -54,6 +54,7 @@ struct SMetaCache {
|
||||||
|
|
||||||
// query cache
|
// query cache
|
||||||
struct STagFilterResCache {
|
struct STagFilterResCache {
|
||||||
|
TdThreadMutex lock;
|
||||||
SHashObj* pTableEntry;
|
SHashObj* pTableEntry;
|
||||||
SLRUCache* pUidResCache;
|
SLRUCache* pUidResCache;
|
||||||
uint64_t keyBuf[3];
|
uint64_t keyBuf[3];
|
||||||
|
@ -140,6 +141,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashSetFreeFp(pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
taosHashSetFreeFp(pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp);
|
||||||
|
taosThreadMutexInit(&pCache->sTagFilterResCache.lock, NULL);
|
||||||
|
|
||||||
pMeta->pCache = pCache;
|
pMeta->pCache = pCache;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
@ -159,6 +162,8 @@ void metaCacheClose(SMeta* pMeta) {
|
||||||
|
|
||||||
taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry);
|
taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry);
|
||||||
taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache);
|
taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache);
|
||||||
|
taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock);
|
||||||
|
|
||||||
taosMemoryFree(pMeta->pCache);
|
taosMemoryFree(pMeta->pCache);
|
||||||
pMeta->pCache = NULL;
|
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,
|
int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1,
|
||||||
bool* acquireRes) {
|
bool* acquireRes) {
|
||||||
uint64_t* pBuf = pMeta->pCache->sTagFilterResCache.keyBuf;
|
|
||||||
|
|
||||||
// generate the composed key for LRU cache
|
// 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;
|
pBuf[0] = suid;
|
||||||
memcpy(&pBuf[1], pKey, keyLen);
|
memcpy(&pBuf[1], pKey, keyLen);
|
||||||
|
|
||||||
|
taosThreadMutexLock(pLock);
|
||||||
|
|
||||||
int32_t len = keyLen + sizeof(uint64_t);
|
int32_t len = keyLen + sizeof(uint64_t);
|
||||||
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
LRUHandle* pHandle = taosLRUCacheLookup(pCache, pBuf, len);
|
||||||
if (pHandle == NULL) {
|
if (pHandle == NULL) {
|
||||||
*acquireRes = 0;
|
taosThreadMutexUnlock(pLock);
|
||||||
return TSDB_CODE_SUCCESS;
|
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);
|
// do some book mark work after acquiring the filter result from cache
|
||||||
int32_t size = *(int32_t*)p;
|
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||||
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
ASSERT(pEntry != NULL);
|
||||||
|
*acquireRes = 1;
|
||||||
|
|
||||||
(*pEntry)->qTimes += 1;
|
const char* p = taosLRUCacheValue(pCache, pHandle);
|
||||||
taosLRUCacheRelease(pCache, pHandle, false);
|
int32_t size = *(int32_t*)p;
|
||||||
|
|
||||||
// check if scanning all items are necessary or not
|
// set the result into the buffer
|
||||||
if ((*pEntry)->qTimes >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
taosArrayAddBatch(pList1, p + sizeof(int32_t), size);
|
||||||
SArray* pList = taosArrayInit(64, POINTER_BYTES);
|
|
||||||
|
|
||||||
SListIter iter = {0};
|
times = atomic_add_fetch_32(&(*pEntry)->qTimes, 1);
|
||||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
taosLRUCacheRelease(pCache, pHandle, false);
|
||||||
|
|
||||||
SListNode* pNode = NULL;
|
// unlock meta
|
||||||
while ((pNode = tdListNext(&iter)) != NULL) {
|
taosThreadMutexUnlock(pLock);
|
||||||
memcpy(&pBuf[1], pNode->data, keyLen);
|
|
||||||
|
|
||||||
// check whether it is existed in LRU cache, and remove it from linked list if not.
|
// check if scanning all items are necessary or not
|
||||||
LRUHandle* pRes = taosLRUCacheLookup(pCache, pBuf, len);
|
if (times >= 5000 && TD_DLIST_NELES(&(*pEntry)->list) > 10) {
|
||||||
if (pRes == NULL) { // remove the item in the linked list
|
taosThreadMutexLock(pLock);
|
||||||
taosArrayPush(pList, &pNode);
|
|
||||||
} else {
|
SArray* pInvalidRes = taosArrayInit(64, POINTER_BYTES);
|
||||||
taosLRUCacheRelease(pCache, pRes, false);
|
|
||||||
}
|
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;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -510,8 +530,11 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache;
|
||||||
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry;
|
||||||
|
TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock;
|
||||||
|
|
||||||
|
taosThreadMutexLock(pLock);
|
||||||
|
|
||||||
STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t));
|
STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t));
|
||||||
if (pEntry == NULL) {
|
if (pEntry == NULL) {
|
||||||
|
@ -533,6 +556,9 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
||||||
// add to cache.
|
// add to cache.
|
||||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||||
TAOS_LRU_PRIORITY_LOW);
|
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,
|
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));
|
(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
|
// 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) {
|
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;
|
int32_t keyLen = sizeof(uint64_t) * 3;
|
||||||
uint64_t p[3] = {0};
|
uint64_t p[3] = {0};
|
||||||
p[0] = suid;
|
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};
|
SListIter iter = {0};
|
||||||
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
|
||||||
|
|
||||||
|
@ -562,5 +592,6 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
|
||||||
(*pEntry)->qTimes = 0;
|
(*pEntry)->qTimes = 0;
|
||||||
tdListEmpty(&(*pEntry)->list);
|
tdListEmpty(&(*pEntry)->list);
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(pLock);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) { return vnodeBufPoolMalloc((SVBufPool *)pPool, size); }
|
static FORCE_INLINE void *metaMalloc(void *pPool, size_t size) {
|
||||||
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
return vnodeBufPoolMallocAligned((SVBufPool *)pPool, size);
|
||||||
|
}
|
||||||
|
static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVBufPool *)pPool, p); }
|
||||||
|
|
||||||
// begin a meta txn
|
// begin a meta txn
|
||||||
int metaBegin(SMeta *pMeta, int8_t heap) {
|
int metaBegin(SMeta *pMeta, int8_t heap) {
|
||||||
|
|
|
@ -710,8 +710,8 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
metaDebug("vgId:%d, start to save ctime:%" PRId64 " uid:%" PRId64 " ct:%" PRId64, TD_VID(pMeta->pVnode), pME->version,
|
metaTrace("vgId:%d, start to save version:%" PRId64 " uid:%" PRId64 " ctime:%" PRId64, TD_VID(pMeta->pVnode),
|
||||||
pME->uid, ctimeKey.ctime);
|
pME->version, pME->uid, ctimeKey.ctime);
|
||||||
|
|
||||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
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->path = strdup(path);
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
|
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;
|
||||||
|
|
||||||
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
|
||||||
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
|
||||||
|
@ -1538,3 +1539,5 @@ FAIL:
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqCheckLogInWal(STQ* pTq, int64_t version) { return version <= pTq->walLogLastVer; }
|
||||||
|
|
|
@ -1406,30 +1406,6 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *
|
||||||
return code;
|
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 tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **handle) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char key[32] = {0};
|
char key[32] = {0};
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
#define HASTYPE(_type, _t) (((_type) & (_t)) == (_t))
|
||||||
|
|
||||||
static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pReader, const int32_t* slotIds,
|
||||||
void** pRes) {
|
void** pRes, const char* idStr) {
|
||||||
ASSERT(pReader->numOfCols <= taosArrayGetSize(pBlock->pDataBlock));
|
|
||||||
int32_t numOfRows = pBlock->info.rows;
|
int32_t numOfRows = pBlock->info.rows;
|
||||||
|
|
||||||
if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) {
|
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;
|
pBlock->info.rows += allNullRow ? 0 : 1;
|
||||||
} else {
|
} else if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||||
ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW));
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
for (int32_t i = 0; i < pReader->numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
||||||
|
@ -94,11 +91,16 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.rows += 1;
|
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,
|
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;
|
*pReader = NULL;
|
||||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
@ -142,6 +144,8 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->idstr = taosMemoryStrDup(idstr);
|
||||||
|
|
||||||
*pReader = p;
|
*pReader = p;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +164,7 @@ void* tsdbCacherowsReaderClose(void* pReader) {
|
||||||
|
|
||||||
destroyLastBlockLoadInfo(p->pLoadInfo);
|
destroyLastBlockLoadInfo(p->pLoadInfo);
|
||||||
|
|
||||||
|
taosMemoryFree((void*) p->idstr);
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +313,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasRes) {
|
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)) {
|
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||||
|
@ -323,7 +328,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds, pRes);
|
saveOneRow(pRow, pResBlock, pr, slotIds, pRes, pr->idstr);
|
||||||
// TODO reset the pRes
|
// TODO reset the pRes
|
||||||
|
|
||||||
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
taosArrayPush(pTableUidList, &pKeyInfo->uid);
|
||||||
|
|
|
@ -32,13 +32,13 @@ struct SLDataIter {
|
||||||
};
|
};
|
||||||
|
|
||||||
SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) {
|
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) {
|
if (pLoadInfo == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
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[0] = -1;
|
||||||
pLoadInfo[i].blockIndex[1] = -1;
|
pLoadInfo[i].blockIndex[1] = -1;
|
||||||
pLoadInfo[i].currentLoadBlockIndex = 1;
|
pLoadInfo[i].currentLoadBlockIndex = 1;
|
||||||
|
@ -63,7 +63,7 @@ SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList,
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
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].currentLoadBlockIndex = 1;
|
||||||
pLoadInfo[i].blockIndex[0] = -1;
|
pLoadInfo[i].blockIndex[0] = -1;
|
||||||
pLoadInfo[i].blockIndex[1] = -1;
|
pLoadInfo[i].blockIndex[1] = -1;
|
||||||
|
@ -77,14 +77,14 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el) {
|
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;
|
*el += pLoadInfo[i].elapsedTime;
|
||||||
*blocks += pLoadInfo[i].loadBlocks;
|
*blocks += pLoadInfo[i].loadBlocks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
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].currentLoadBlockIndex = 1;
|
||||||
pLoadInfo[i].blockIndex[0] = -1;
|
pLoadInfo[i].blockIndex[0] = -1;
|
||||||
pLoadInfo[i].blockIndex[1] = -1;
|
pLoadInfo[i].blockIndex[1] = -1;
|
||||||
|
@ -154,13 +154,13 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
||||||
|
|
||||||
tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64
|
tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64
|
||||||
", last file index:%d, last block index:%d, entry:%d, rows:%d, %p, elapsed time:%.2f ms, %s",
|
", last file index:%d, last block index:%d, entry:%d, rows:%d, %p, elapsed time:%.2f ms, %s",
|
||||||
pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock->nRow, pBlock, el,
|
pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock->nRow,
|
||||||
idStr);
|
pBlock, el, idStr);
|
||||||
|
|
||||||
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
|
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;
|
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];
|
return &pInfo->blockData[pInfo->currentLoadBlockIndex];
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -419,6 +419,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
|
||||||
pBlockData->aUid != NULL) {
|
pBlockData->aUid != NULL) {
|
||||||
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
|
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
|
tsdbDebug("failed to find the data in pBlockData, uid:%"PRIu64" , %s", pIter->uid, idStr);
|
||||||
pIter->iRow = -1;
|
pIter->iRow = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +501,12 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
||||||
|
|
||||||
if (iBlockL != pIter->iSttBlk) {
|
if (iBlockL != pIter->iSttBlk) {
|
||||||
pBlockData = loadLastBlock(pIter, idStr);
|
pBlockData = loadLastBlock(pIter, idStr);
|
||||||
pIter->iRow += step;
|
if (pBlockData == NULL) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set start row index
|
||||||
|
pIter->iRow = pIter->backward? pBlockData->nRow-1:0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,9 +558,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
||||||
}
|
}
|
||||||
|
|
||||||
pMTree->idStr = idStr;
|
pMTree->idStr = idStr;
|
||||||
if (!pMTree->backward) { // asc
|
if (!pMTree->backward) { // asc
|
||||||
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
|
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
|
||||||
} else { // desc
|
} else { // desc
|
||||||
tRBTreeCreate(&pMTree->rbt, tLDataIterDescCmprFn);
|
tRBTreeCreate(&pMTree->rbt, tLDataIterDescCmprFn);
|
||||||
}
|
}
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -190,7 +190,7 @@ static int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STabl
|
||||||
static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger,
|
static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger,
|
||||||
STsdbReader* pReader);
|
STsdbReader* pReader);
|
||||||
static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow,
|
static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow,
|
||||||
STableBlockScanInfo* pInfo);
|
STableBlockScanInfo* pScanInfo);
|
||||||
static int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData,
|
static int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData,
|
||||||
int32_t rowIndex);
|
int32_t rowIndex);
|
||||||
static void setComposedBlockFlag(STsdbReader* pReader, bool composed);
|
static void setComposedBlockFlag(STsdbReader* pReader, bool composed);
|
||||||
|
@ -396,7 +396,6 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
|
||||||
ASSERT(pWindow != NULL);
|
|
||||||
return pWindow->skey > pWindow->ekey;
|
return pWindow->skey > pWindow->ekey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1447,7 +1446,6 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock
|
||||||
index += step;
|
index += step;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(0);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2421,6 +2419,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) {
|
static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -2479,36 +2517,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||||
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
|
||||||
|
pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); // NOTE: get the new block info
|
||||||
|
|
||||||
int32_t nextIndex = -1;
|
// continue check for the next file block if the last ts in the current block
|
||||||
SBlockIndex bIndex = {0};
|
// is overlapped with the next neighbor block
|
||||||
bool hasNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pBlockScanInfo, &nextIndex, pReader->order, &bIndex);
|
bool loadNeighbor = false;
|
||||||
if (!hasNeighbor) { // do nothing
|
code = loadNeighborIfOverlap(pBlockInfo, pBlockScanInfo, pReader, &loadNeighbor);
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
if ((!loadNeighbor) || (code != 0)) {
|
||||||
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 {
|
|
||||||
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2775,7 +2790,10 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
|
||||||
|
|
||||||
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
|
||||||
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
|
||||||
ASSERT(pStatus->pTableIter != NULL);
|
if (pStatus->pTableIter == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3115,10 +3133,10 @@ SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order, SVersionRange* pVerRange) {
|
||||||
ASSERT(pKey != NULL);
|
|
||||||
if (pDelList == NULL) {
|
if (pDelList == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(pDelList);
|
size_t num = taosArrayGetSize(pDelList);
|
||||||
bool asc = ASCENDING_TRAVERSE(order);
|
bool asc = ASCENDING_TRAVERSE(order);
|
||||||
int32_t step = asc ? 1 : -1;
|
int32_t step = asc ? 1 : -1;
|
||||||
|
@ -3316,35 +3334,10 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
*state = CHECK_FILEBLOCK_QUIT;
|
*state = CHECK_FILEBLOCK_QUIT;
|
||||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||||
|
|
||||||
int32_t nextIndex = -1;
|
bool loadNeighbor = true;
|
||||||
SBlockIndex bIndex = {0};
|
int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) {
|
||||||
pDumpInfo->rowIndex =
|
pDumpInfo->rowIndex =
|
||||||
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step);
|
||||||
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) {
|
||||||
|
@ -3352,7 +3345,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
|
||||||
|
@ -3520,6 +3513,8 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = tRowMergerGetRow(&merge, pTSRow);
|
int32_t code = tRowMergerGetRow(&merge, pTSRow);
|
||||||
|
tRowMergerClear(&merge);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3705,13 +3700,11 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
ASSERT(pBlock->info.rows <= capacity);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO refactor: with createDataBlockScanInfo
|
// TODO refactor: with createDataBlockScanInfo
|
||||||
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||||
ASSERT(pReader != NULL);
|
|
||||||
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
int32_t size = taosHashGetSize(pReader->status.pTableMap);
|
||||||
|
|
||||||
STableBlockScanInfo** p = NULL;
|
STableBlockScanInfo** p = NULL;
|
||||||
|
@ -4075,7 +4068,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||||
ASSERT(pReader != NULL);
|
|
||||||
*rows = pReader->pResBlock->info.rows;
|
*rows = pReader->pResBlock->info.rows;
|
||||||
*uid = pReader->pResBlock->info.id.uid;
|
*uid = pReader->pResBlock->info.id.uid;
|
||||||
*pWindow = pReader->pResBlock->info.window;
|
*pWindow = pReader->pResBlock->info.window;
|
||||||
|
@ -4349,6 +4341,8 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
|
||||||
pTableBlockInfo->numOfSmallBlocks += 1;
|
pTableBlockInfo->numOfSmallBlocks += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pTableBlockInfo->totalSize += pBlock->aSubBlock[0].szBlock;
|
||||||
|
|
||||||
int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows);
|
int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows);
|
||||||
pTableBlockInfo->blockRowsHisto[bucketIndex]++;
|
pTableBlockInfo->blockRowsHisto[bucketIndex]++;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (taosThreadSpinInit(pPool->lock, 0) != 0) {
|
if (taosThreadSpinInit(pPool->lock, 0) != 0) {
|
||||||
taosMemoryFree((void*)pPool->lock);
|
taosMemoryFree((void *)pPool->lock);
|
||||||
taosMemoryFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -62,7 +62,7 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||||
vnodeBufPoolReset(pPool);
|
vnodeBufPoolReset(pPool);
|
||||||
if (pPool->lock) {
|
if (pPool->lock) {
|
||||||
taosThreadSpinDestroy(pPool->lock);
|
taosThreadSpinDestroy(pPool->lock);
|
||||||
taosMemoryFree((void*)pPool->lock);
|
taosMemoryFree((void *)pPool->lock);
|
||||||
}
|
}
|
||||||
taosMemoryFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -123,6 +123,46 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
|
||||||
pPool->ptr = pPool->node.data;
|
pPool->ptr = pPool->node.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||||
SVBufPoolNode *pNode;
|
SVBufPoolNode *pNode;
|
||||||
void *p = NULL;
|
void *p = NULL;
|
||||||
|
|
|
@ -67,9 +67,8 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
void vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||||
int32_t code = 0;
|
vInfo("vgId:%d, close vnode snapshot reader", TD_VID(pReader->pVnode));
|
||||||
|
|
||||||
if (pReader->pRsmaReader) {
|
if (pReader->pRsmaReader) {
|
||||||
rsmaSnapReaderClose(&pReader->pRsmaReader);
|
rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||||
}
|
}
|
||||||
|
@ -82,9 +81,7 @@ int32_t vnodeSnapReaderClose(SVSnapReader *pReader) {
|
||||||
metaSnapReaderClose(&pReader->pMetaReader);
|
metaSnapReaderClose(&pReader->pMetaReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId:%d, vnode snapshot reader closed", TD_VID(pReader->pVnode));
|
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) {
|
||||||
|
|
|
@ -197,6 +197,10 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
|
|
||||||
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
if (!syncUtilUserCommit(pMsg->msgType)) goto _exit;
|
||||||
|
|
||||||
|
if (pMsg->msgType == TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE) {
|
||||||
|
if (tqCheckLogInWal(pVnode->pTq, version)) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// skip header
|
// skip header
|
||||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
@ -1192,7 +1196,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
|
||||||
SSingleDeleteReq *pOneReq = taosArrayGet(deleteReq.deleteReqs, i);
|
SSingleDeleteReq *pOneReq = taosArrayGet(deleteReq.deleteReqs, i);
|
||||||
char *name = pOneReq->tbname;
|
char *name = pOneReq->tbname;
|
||||||
if (metaGetTableEntryByName(&mr, name) < 0) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,9 +380,8 @@ static int32_t vnodeSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
static void vnodeSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) {
|
||||||
vnodeGetSnapshot(pFsm->data, pSnapshot);
|
vnodeGetSnapshot(pFsm->data, pSnapshot);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
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;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
static void vnodeSnapshotStopRead(const SSyncFSM *pFsm, void *pReader) {
|
||||||
SVnode *pVnode = pFsm->data;
|
SVnode *pVnode = pFsm->data;
|
||||||
int32_t code = vnodeSnapReaderClose(pReader);
|
vnodeSnapReaderClose(pReader);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vnodeSnapshotDoRead(const SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
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->FpCommitCb = vnodeSyncCommitMsg;
|
||||||
pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg;
|
pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg;
|
||||||
pFsm->FpRollBackCb = vnodeSyncRollBackMsg;
|
pFsm->FpRollBackCb = vnodeSyncRollBackMsg;
|
||||||
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshot;
|
pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshotInfo;
|
||||||
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
pFsm->FpRestoreFinishCb = vnodeRestoreFinish;
|
||||||
pFsm->FpLeaderTransferCb = NULL;
|
pFsm->FpLeaderTransferCb = NULL;
|
||||||
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty;
|
||||||
|
|
|
@ -485,6 +485,9 @@ typedef struct SCtgOperation {
|
||||||
ctgOpFunc func;
|
ctgOpFunc func;
|
||||||
} SCtgOperation;
|
} 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_INC() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
|
||||||
#define CTG_QUEUE_DEC() atomic_sub_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;
|
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;
|
*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;
|
*pass = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1549,10 +1549,10 @@ int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
|
||||||
goto _return;
|
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))) {
|
taosHashGet(pOut->readDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||||
pass = true;
|
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))) {
|
taosHashGet(pOut->writeDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) {
|
||||||
pass = true;
|
pass = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,11 +718,11 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, char *user, char *dbFName, AUTH_TYPE
|
||||||
return TSDB_CODE_SUCCESS;
|
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;
|
*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;
|
*pass = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,6 @@ typedef struct STableMergeScanInfo {
|
||||||
SLimitInfo limitInfo;
|
SLimitInfo limitInfo;
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
SScanInfo scanInfo;
|
SScanInfo scanInfo;
|
||||||
int32_t scanTimes;
|
|
||||||
SSDataBlock* pResBlock;
|
SSDataBlock* pResBlock;
|
||||||
SSampleExecInfo sample; // sample execution info
|
SSampleExecInfo sample; // sample execution info
|
||||||
SSortExecInfo sortExecInfo;
|
SSortExecInfo sortExecInfo;
|
||||||
|
@ -657,7 +656,6 @@ typedef struct SStreamFillOperatorInfo {
|
||||||
SSDataBlock* pRes;
|
SSDataBlock* pRes;
|
||||||
SSDataBlock* pSrcBlock;
|
SSDataBlock* pSrcBlock;
|
||||||
int32_t srcRowIndex;
|
int32_t srcRowIndex;
|
||||||
SSDataBlock* pPrevSrcBlock;
|
|
||||||
SSDataBlock* pSrcDelBlock;
|
SSDataBlock* pSrcDelBlock;
|
||||||
int32_t srcDelRowIndex;
|
int32_t srcDelRowIndex;
|
||||||
SSDataBlock* pDelRes;
|
SSDataBlock* pDelRes;
|
||||||
|
|
|
@ -90,7 +90,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
|
|
||||||
uint64_t suid = tableListGetSuid(pTableList);
|
uint64_t suid = tableListGetSuid(pTableList);
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
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);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
||||||
|
|
|
@ -539,7 +539,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
||||||
taosArrayPush(pTaskInfo->pResultBlockList, &p1);
|
taosArrayPush(pTaskInfo->pResultBlockList, &p1);
|
||||||
p = p1;
|
p = p1;
|
||||||
} else {
|
} else {
|
||||||
p = *(SSDataBlock**) taosArrayGet(pTaskInfo->pResultBlockList, blockIndex);
|
p = *(SSDataBlock**)taosArrayGet(pTaskInfo->pResultBlockList, blockIndex);
|
||||||
copyDataBlock(p, pRes);
|
copyDataBlock(p, pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,9 +574,9 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
||||||
|
|
||||||
void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo) {
|
void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
SArray* pList = pTaskInfo->pResultBlockList;
|
SArray* pList = pTaskInfo->pResultBlockList;
|
||||||
size_t num = taosArrayGetSize(pList);
|
size_t num = taosArrayGetSize(pList);
|
||||||
for(int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SSDataBlock** p = taosArrayGet(pTaskInfo->pResultBlockList, i);
|
SSDataBlock** p = taosArrayGet(pTaskInfo->pResultBlockList, i);
|
||||||
blockDataDestroy(*p);
|
blockDataDestroy(*p);
|
||||||
}
|
}
|
||||||
|
@ -747,11 +747,11 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nOptrWithVal = 0;
|
int32_t nOptrWithVal = 0;
|
||||||
// int32_t code = encodeOperator(pTaskInfo->pRoot, pOutput, len, &nOptrWithVal);
|
// int32_t code = encodeOperator(pTaskInfo->pRoot, pOutput, len, &nOptrWithVal);
|
||||||
// if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal == 0)) {
|
// if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal == 0)) {
|
||||||
// taosMemoryFreeClear(*pOutput);
|
// taosMemoryFreeClear(*pOutput);
|
||||||
// *len = 0;
|
// *len = 0;
|
||||||
// }
|
// }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,7 +763,7 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
// return decodeOperator(pTaskInfo->pRoot, pInput, len);
|
// return decodeOperator(pTaskInfo->pRoot, pInput, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
|
||||||
|
@ -890,35 +890,35 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
|
||||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL ||
|
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL ||
|
||||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) {
|
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) {
|
||||||
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||||
|
|
||||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||||
qInfo("restore stream param for interval: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
qInfo("restore stream param for interval: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||||
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION ||
|
} 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_SEMI_SESSION ||
|
||||||
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
||||||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||||
|
|
||||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||||
qInfo("restore stream param for session: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
qInfo("restore stream param for session: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||||
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) {
|
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) {
|
||||||
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/
|
||||||
ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);
|
/*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/
|
||||||
|
|
||||||
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved;
|
||||||
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved;
|
||||||
ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||
|
/*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);
|
/*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/
|
||||||
qInfo("restore stream param for state: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
qInfo("restore stream param for state: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
|
||||||
if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) {
|
if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) {
|
||||||
if (pOperator->numOfDownstream > 1) {
|
if (pOperator->numOfDownstream > 1) {
|
||||||
qError("unexpected stream, multiple downstream");
|
qError("unexpected stream, multiple downstream");
|
||||||
ASSERT(0);
|
/*ASSERT(0);*/
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -99,6 +99,8 @@ static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SC
|
||||||
int32_t status);
|
int32_t status);
|
||||||
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||||
bool createDummyCol);
|
bool createDummyCol);
|
||||||
|
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||||
|
SGroupResInfo* pGroupResInfo);
|
||||||
|
|
||||||
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
void setOperatorCompleted(SOperatorInfo* pOperator) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
|
@ -139,9 +141,6 @@ SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn,
|
||||||
return fpSet;
|
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) {
|
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
|
||||||
SFilePage* pData = NULL;
|
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.
|
// in case of repeat scan/reverse scan, no new time window added.
|
||||||
if (isIntervalQuery) {
|
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);
|
pResult = getResultRowByPos(pResultBuf, p1, true);
|
||||||
ASSERT(pResult->pageId == p1->pageId && pResult->offset == p1->offset);
|
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
|
// 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) {
|
if (pWindowRes->pageId != -1) {
|
||||||
return 0;
|
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
|
* 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) {
|
if (pResultRow->pageId == -1) {
|
||||||
int32_t ret =
|
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize);
|
||||||
addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, groupId, pAggInfo->binfo.pRes->info.rowSize);
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
||||||
} else {
|
} else {
|
||||||
|
pBlock->info.dataLoad = 1;
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
blockDataUpdateTsWindow(pBlock, pInfo->primarySrcSlotId);
|
||||||
|
|
||||||
blockDataCleanup(pInfo->pRes);
|
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.
|
// Fill the previous group data block, before handle the data block of new group.
|
||||||
// Close the fill operation for previous group data block
|
// Close the fill operation for previous group data block
|
||||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey);
|
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->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup);
|
||||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||||
pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock);
|
pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock);
|
||||||
pInfo->pPrevSrcBlock = blockDataDestroy(pInfo->pPrevSrcBlock);
|
|
||||||
pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes);
|
pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes);
|
||||||
pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList);
|
pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList);
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
|
@ -992,12 +993,6 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pInfo->srcRowIndex == 0) {
|
if (pInfo->srcRowIndex == 0) {
|
||||||
keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize);
|
keepBlockRowInDiscBuf(pOperator, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex, groupId, pFillSup->rowSize);
|
||||||
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++;
|
pInfo->srcRowIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,9 +1006,8 @@ static void doStreamFillImpl(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
pInfo->srcRowIndex++;
|
pInfo->srcRowIndex++;
|
||||||
}
|
}
|
||||||
|
doFillResults(pOperator, pFillSup, pFillInfo, pBlock, tsCol, pInfo->srcRowIndex - 1, pRes);
|
||||||
blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol);
|
blockDataUpdateTsWindow(pRes, pInfo->primaryTsCol);
|
||||||
blockDataCleanup(pInfo->pPrevSrcBlock);
|
|
||||||
copyDataBlock(pInfo->pPrevSrcBlock, pInfo->pSrcBlock);
|
|
||||||
blockDataCleanup(pInfo->pSrcBlock);
|
blockDataCleanup(pInfo->pSrcBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,7 +1167,6 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) {
|
static void resetStreamFillInfo(SStreamFillOperatorInfo* pInfo) {
|
||||||
blockDataCleanup(pInfo->pPrevSrcBlock);
|
|
||||||
tSimpleHashClear(pInfo->pFillSup->pResMap);
|
tSimpleHashClear(pInfo->pFillSup->pResMap);
|
||||||
pInfo->pFillSup->hasDelete = false;
|
pInfo->pFillSup->hasDelete = false;
|
||||||
taosArrayClear(pInfo->pFillInfo->delRanges);
|
taosArrayClear(pInfo->pFillInfo->delRanges);
|
||||||
|
@ -1231,13 +1224,6 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
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;
|
pInfo->pFillInfo->preRowKey = INT64_MIN;
|
||||||
if (pInfo->pRes->info.rows > 0) {
|
if (pInfo->pRes->info.rows > 0) {
|
||||||
printDataBlock(pInfo->pRes, "stream fill");
|
printDataBlock(pInfo->pRes, "stream fill");
|
||||||
|
@ -1411,10 +1397,8 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
||||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||||
pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
pInfo->pRes = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||||
pInfo->pSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
pInfo->pSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
||||||
pInfo->pPrevSrcBlock = createDataBlockFromDescNode(pPhyFillNode->node.pOutputDataBlockDesc);
|
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pSrcBlock, pOperator->resultInfo.capacity);
|
||||||
blockDataEnsureCapacity(pInfo->pPrevSrcBlock, pOperator->resultInfo.capacity);
|
|
||||||
|
|
||||||
pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes);
|
pInfo->pFillInfo = initStreamFillInfo(pInfo->pFillSup, pInfo->pRes);
|
||||||
if (!pInfo->pFillInfo) {
|
if (!pInfo->pFillInfo) {
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "filter.h"
|
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
#include "filter.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
||||||
typedef struct SProjectOperatorInfo {
|
typedef struct SProjectOperatorInfo {
|
||||||
|
@ -90,7 +90,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
|
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pFinalRes = createOneDataBlock(pResBlock, false);
|
pInfo->pFinalRes = createOneDataBlock(pResBlock, false);
|
||||||
pInfo->mergeDataBlocks = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM)? false:pProjPhyNode->mergeDataBlock;
|
pInfo->mergeDataBlocks = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) ? false : pProjPhyNode->mergeDataBlock;
|
||||||
|
|
||||||
int32_t numOfRows = 4096;
|
int32_t numOfRows = 4096;
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
|
@ -117,9 +117,10 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
||||||
|
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL,
|
pTaskInfo);
|
||||||
destroyProjectOperatorInfo, optrDefaultBufFn, NULL);
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL, destroyProjectOperatorInfo,
|
||||||
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -316,7 +317,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
if (pProjectInfo->mergeDataBlocks) {
|
if (pProjectInfo->mergeDataBlocks) {
|
||||||
if (pRes->info.rows > 0) {
|
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;
|
pFinalRes->info.version = pRes->info.version;
|
||||||
|
|
||||||
// continue merge data, ignore the group id
|
// continue merge data, ignore the group id
|
||||||
|
@ -350,6 +351,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SSDataBlock* p = pProjectInfo->mergeDataBlocks ? pFinalRes : pRes;
|
SSDataBlock* p = pProjectInfo->mergeDataBlocks ? pFinalRes : pRes;
|
||||||
pOperator->resultInfo.totalRows += p->info.rows;
|
pOperator->resultInfo.totalRows += p->info.rows;
|
||||||
|
p->info.dataLoad = 1;
|
||||||
|
|
||||||
if (pOperator->cost.openCost == 0) {
|
if (pOperator->cost.openCost == 0) {
|
||||||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
@ -414,8 +416,10 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
||||||
pInfo->binfo.pRes = pResBlock;
|
pInfo->binfo.pRes = pResBlock;
|
||||||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo,
|
||||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, optrDefaultBufFn, NULL);
|
pTaskInfo);
|
||||||
|
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo,
|
||||||
|
optrDefaultBufFn, NULL);
|
||||||
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -697,13 +701,30 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query
|
if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
if (pResult->info.rows > 0 && !createNewColModel) {
|
if (pResult->info.rows > 0 && !createNewColModel) {
|
||||||
colDataMergeCol(pColInfoData, pResult->info.rows, (int32_t*)&pResult->info.capacity, pInputData->pData[0],
|
if (pInputData->pData[0] == NULL) {
|
||||||
pInputData->numOfRows);
|
int32_t slotId = pfCtx->param[0].pCol->slotId;
|
||||||
} else {
|
|
||||||
colDataAssign(pColInfoData, pInputData->pData[0], pInputData->numOfRows, &pResult->info);
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,22 @@
|
||||||
|
|
||||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
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) {
|
static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowIndex) {
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
|
@ -45,19 +61,7 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SRowVal* p = NULL;
|
setNotFillColumn(pFillInfo, pDstColInfo, rowIndex, i);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataAppendNULL(pDstColInfo, rowIndex);
|
colDataAppendNULL(pDstColInfo, rowIndex);
|
||||||
|
@ -124,28 +128,23 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
|
|
||||||
// set the other values
|
// set the other values
|
||||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
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) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
|
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
} 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
|
// todo refactor: start from 0 not 1
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfoData, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
setNotFillColumn(pFillInfo, pDstColInfoData, index, i);
|
||||||
doSetVal(pDstColInfoData, index, pKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
|
@ -163,9 +162,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstCol, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
setNotFillColumn(pFillInfo, pDstCol, index, i);
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
doSetVal(pDstCol, index, pKey);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev.pRowVal, i);
|
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev.pRowVal, i);
|
||||||
|
@ -205,9 +202,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
|
||||||
if (pCol->notFillCol) {
|
if (pCol->notFillCol) {
|
||||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDst, index);
|
||||||
if (!filled) {
|
if (!filled) {
|
||||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
setNotFillColumn(pFillInfo, pDst, index, i);
|
||||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
|
||||||
doSetVal(pDst, index, pKey);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
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) {
|
static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock, bool beforeTs) {
|
||||||
int32_t rows = pResBlock->info.rows;
|
int32_t rows = pResBlock->info.rows;
|
||||||
blockDataEnsureCapacity(pResBlock, rows + 1);
|
timeSliceEnsureBlockCapacity(pSliceInfo, pResBlock);
|
||||||
// todo set the correct primary timestamp column
|
// todo set the correct primary timestamp column
|
||||||
|
|
||||||
// output the result
|
// output the result
|
||||||
|
@ -269,7 +283,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
||||||
|
|
||||||
static void addCurrentRowToResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock,
|
static void addCurrentRowToResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock,
|
||||||
SSDataBlock* pSrcBlock, int32_t index) {
|
SSDataBlock* pSrcBlock, int32_t index) {
|
||||||
blockDataEnsureCapacity(pResBlock, pResBlock->info.rows + 1);
|
timeSliceEnsureBlockCapacity(pSliceInfo, pResBlock);
|
||||||
for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) {
|
for (int32_t j = 0; j < pExprSup->numOfExprs; ++j) {
|
||||||
SExprInfo* pExprInfo = &pExprSup->pExprInfo[j];
|
SExprInfo* pExprInfo = &pExprSup->pExprInfo[j];
|
||||||
|
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
|
||||||
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo) {
|
||||||
TSKEY* tsCols = NULL;
|
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);
|
SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
|
||||||
tsCols = (int64_t*)pColDataInfo->pData;
|
tsCols = (int64_t*)pColDataInfo->pData;
|
||||||
ASSERT(tsCols[0] != 0);
|
ASSERT(tsCols[0] != 0);
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef struct SSumRes {
|
||||||
int16_t type;
|
int16_t type;
|
||||||
int64_t prevTs;
|
int64_t prevTs;
|
||||||
bool isPrevTsSet;
|
bool isPrevTsSet;
|
||||||
|
bool overflow; // if overflow is true, dsum to be used for any type;
|
||||||
} SSumRes;
|
} SSumRes;
|
||||||
|
|
||||||
typedef struct SMinmaxResInfo {
|
typedef struct SMinmaxResInfo {
|
||||||
|
|
|
@ -1995,6 +1995,22 @@ static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowInde
|
||||||
return *(TSKEY*)colDataGetData(pTsColInfo, rowIndex);
|
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,
|
static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx,
|
||||||
SFirstLastRes* pInfo) {
|
SFirstLastRes* pInfo) {
|
||||||
if (pCtx->subsidiaries.num <= 0) {
|
if (pCtx->subsidiaries.num <= 0) {
|
||||||
|
@ -2003,8 +2019,6 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde
|
||||||
|
|
||||||
if (!pInfo->hasResult) {
|
if (!pInfo->hasResult) {
|
||||||
pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL);
|
pInfo->pos = saveTupleData(pCtx, rowIndex, pSrcBlock, NULL);
|
||||||
ASSERT(pCtx->subsidiaries.buf != NULL);
|
|
||||||
ASSERT(pCtx->subsidiaries.rowLen > 0);
|
|
||||||
} else {
|
} else {
|
||||||
updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
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) {
|
STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, const STupleKey* pKey) {
|
||||||
if (pCtx->subsidiaries.rowLen == 0) {
|
prepareBuf(pCtx);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||||
return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pKey);
|
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) {
|
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);
|
char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf);
|
||||||
doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos);
|
doUpdateTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, pPos);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -5292,7 +5299,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
int32_t len = sprintf(st + VARSTR_HEADER_SIZE,
|
int32_t len = sprintf(st + VARSTR_HEADER_SIZE,
|
||||||
"Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]",
|
"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);
|
varDataSetLen(st, len);
|
||||||
colDataAppend(pColInfo, row++, st, false);
|
colDataAppend(pColInfo, row++, st, false);
|
||||||
|
|
|
@ -41,6 +41,57 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} 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 {
|
typedef struct SAvgRes {
|
||||||
double result;
|
double result;
|
||||||
SSumRes sum;
|
SSumRes sum;
|
||||||
|
@ -319,9 +370,9 @@ static int32_t calculateAvgBySMAInfo(SAvgRes* pRes, int32_t numOfRows, int32_t t
|
||||||
|
|
||||||
pRes->count += numOfElem;
|
pRes->count += numOfElem;
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
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)) {
|
} 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)) {
|
} else if (IS_FLOAT_TYPE(type)) {
|
||||||
pRes->sum.dsum += GET_DOUBLE_VAL((const char*)&(pAgg->sum));
|
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;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -359,7 +410,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +424,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -388,7 +439,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +453,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -417,7 +468,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +482,7 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -446,7 +497,8 @@ static int32_t doAddNumericVector(SColumnInfoData* pCol, int32_t type, SInputCol
|
||||||
|
|
||||||
numOfElems += 1;
|
numOfElems += 1;
|
||||||
pRes->count += 1;
|
pRes->count += 1;
|
||||||
pRes->sum.usum += plist[i];
|
CHECK_OVERFLOW_SUM_UNSIGNED(pRes, plist[i])
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -527,9 +579,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_TINYINT) {
|
if (type == TSDB_DATA_TYPE_TINYINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_INT) {
|
if (type == TSDB_DATA_TYPE_INT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||||
pAvgRes->sum.isum += plist[i];
|
CHECK_OVERFLOW_SUM_SIGNED(pAvgRes, plist[i])
|
||||||
} else {
|
} 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;
|
pOutput->type = pInput->type;
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(pOutput->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)) {
|
} 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 {
|
} else {
|
||||||
pOutput->sum.dsum += pInput->sum.dsum;
|
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;
|
int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type;
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(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)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
pDBuf->sum.usum += pSBuf->sum.usum;
|
CHECK_OVERFLOW_SUM_UNSIGNED(pDBuf, pSBuf->sum.usum)
|
||||||
} else {
|
} else {
|
||||||
pDBuf->sum.dsum += pSBuf->sum.dsum;
|
pDBuf->sum.dsum += pSBuf->sum.dsum;
|
||||||
}
|
}
|
||||||
|
@ -759,7 +813,10 @@ int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t type = pRes->type;
|
int32_t type = pRes->type;
|
||||||
|
|
||||||
if (pRes->count > 0) {
|
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);
|
pRes->result = pRes->sum.isum / ((double)pRes->count);
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
pRes->result = pRes->sum.usum / ((double)pRes->count);
|
pRes->result = pRes->sum.usum / ((double)pRes->count);
|
||||||
|
|
|
@ -44,6 +44,11 @@ typedef struct IFileCtx {
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
|
||||||
|
char* wBuf;
|
||||||
|
int32_t wBufOffset;
|
||||||
|
int32_t wBufCap;
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
char* ptr;
|
char* ptr;
|
||||||
#endif
|
#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));
|
indexError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
||||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
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))) {
|
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||||
taosHashCleanup(param->pFilter);
|
taosHashCleanup(param->pFilter);
|
||||||
indexError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||||
|
int tlen = len;
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
|
int32_t cap = ctx->file.wBufCap;
|
||||||
assert(nwr == len);
|
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 {
|
} else {
|
||||||
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
||||||
}
|
}
|
||||||
ctx->offset += len;
|
ctx->offset += tlen;
|
||||||
return len;
|
return tlen;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
|
static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||||
int nRead = 0;
|
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) {
|
static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
|
||||||
if (ctx->type == TFILE) {
|
if (ctx->type == TFILE) {
|
||||||
int64_t file_size = 0;
|
if (ctx->file.readOnly == false) {
|
||||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
return ctx->offset;
|
||||||
return (int)file_size;
|
} else {
|
||||||
|
int64_t file_size = 0;
|
||||||
|
taosStatFile(ctx->file.buf, &file_size, NULL);
|
||||||
|
return (int)file_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
|
static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
|
||||||
if (ctx->type == TFILE) {
|
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);
|
taosFsyncFile(ctx->file.pFile);
|
||||||
} else {
|
} else {
|
||||||
// do nothing
|
// 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);
|
ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
taosFtruncateFile(ctx->file.pFile, 0);
|
taosFtruncateFile(ctx->file.pFile, 0);
|
||||||
taosStatFile(path, &ctx->file.size, NULL);
|
taosStatFile(path, &ctx->file.size, NULL);
|
||||||
|
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
ctx->file.wBufCap = kBlockSize * 4;
|
||||||
|
ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap);
|
||||||
} else {
|
} else {
|
||||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
||||||
|
|
||||||
taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
|
taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
|
||||||
|
ctx->file.wBufOffset = 0;
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
|
ctx->file.ptr = (char*)tfMmapReadOnly(ctx->file.pFile, ctx->file.size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -195,17 +235,18 @@ void idxFileCtxDestroy(IFileCtx* ctx, bool remove) {
|
||||||
if (ctx->type == TMEMORY) {
|
if (ctx->type == TMEMORY) {
|
||||||
taosMemoryFree(ctx->mem.buf);
|
taosMemoryFree(ctx->mem.buf);
|
||||||
} else {
|
} 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);
|
ctx->flush(ctx);
|
||||||
|
taosMemoryFreeClear(ctx->file.wBuf);
|
||||||
taosCloseFile(&ctx->file.pFile);
|
taosCloseFile(&ctx->file.pFile);
|
||||||
if (ctx->file.readOnly) {
|
if (ctx->file.readOnly) {
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
munmap(ctx->file.ptr, ctx->file.size);
|
munmap(ctx->file.ptr, ctx->file.size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ctx->file.readOnly == false) {
|
|
||||||
int64_t file_size = 0;
|
|
||||||
taosStatFile(ctx->file.buf, &file_size, NULL);
|
|
||||||
}
|
|
||||||
if (remove) {
|
if (remove) {
|
||||||
unlink(ctx->file.buf);
|
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) {
|
void sifMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||||
lnode->dataType.type = resType;
|
lnode->node.resType.type = resType;
|
||||||
lnode->pNodeList = list;
|
lnode->pNodeList = list;
|
||||||
|
|
||||||
*pNode = (SNode *)lnode;
|
*pNode = (SNode *)lnode;
|
||||||
|
|
|
@ -318,7 +318,7 @@ static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) {
|
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);
|
CLONE_NODE_LIST_FIELD(pNodeList);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3903,7 +3903,7 @@ static const char* jkNodeListNodeList = "NodeList";
|
||||||
static int32_t nodeListNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t nodeListNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SNodeListNode* pNode = (const SNodeListNode*)pObj;
|
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) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkNodeListNodeList, pNode->pNodeList);
|
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) {
|
static int32_t jsonToNodeListNode(const SJson* pJson, void* pObj) {
|
||||||
SNodeListNode* pNode = (SNodeListNode*)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) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkNodeListNodeList, &pNode->pNodeList);
|
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) {
|
static int32_t nodeListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||||
const SNodeListNode* pNode = (const SNodeListNode*)pObj;
|
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) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_NODE_LIST, nodeListToMsg, pNode->pNodeList);
|
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) {
|
tlvForEach(pDecoder, pTlv, code) {
|
||||||
switch (pTlv->type) {
|
switch (pTlv->type) {
|
||||||
case NODE_LIST_CODE_DATA_TYPE:
|
case NODE_LIST_CODE_DATA_TYPE:
|
||||||
code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->dataType);
|
code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->node.resType);
|
||||||
break;
|
break;
|
||||||
case NODE_LIST_CODE_NODE_LIST:
|
case NODE_LIST_CODE_NODE_LIST:
|
||||||
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList);
|
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList);
|
||||||
|
|
|
@ -694,6 +694,7 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias)
|
||||||
pExpr->aliasName[len] = '\0';
|
pExpr->aliasName[len] = '\0';
|
||||||
strncpy(pExpr->userAlias, pAlias->z, len);
|
strncpy(pExpr->userAlias, pAlias->z, len);
|
||||||
pExpr->userAlias[len] = '\0';
|
pExpr->userAlias[len] = '\0';
|
||||||
|
pExpr->asAlias = true;
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser,
|
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;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser,
|
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;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ static int32_t authInsert(SAuthCxt* pCxt, SInsertStmt* pInsert) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t authShowTables(SAuthCxt* pCxt, SShowStmt* pStmt) {
|
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) {
|
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);
|
"%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);
|
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -138,7 +138,10 @@ static int32_t adjustScanDataRequirement(SScanLogicNode* pScan, EDataOrderLevel
|
||||||
} else if (TSDB_SUPER_TABLE == pScan->tableType) {
|
} else if (TSDB_SUPER_TABLE == pScan->tableType) {
|
||||||
pScan->scanType = SCAN_TYPE_TABLE_MERGE;
|
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;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,11 @@ typedef struct SScalarCtx {
|
||||||
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
||||||
#define SCL_DEFAULT_OP_NUM 10
|
#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) \
|
#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_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
||||||
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode
|
//#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))
|
//*)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
||||||
|
|
|
@ -3762,6 +3762,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)) {
|
if (!FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -3785,7 +3786,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
||||||
stat->code = code;
|
stat->code = code;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3931,7 +3932,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
||||||
stat->scalarMode = true;
|
stat->scalarMode = true;
|
||||||
return DEAL_RES_CONTINUE;
|
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) {
|
if (0 != type && type != refNode->node.resType.type) {
|
||||||
stat->scalarMode = true;
|
stat->scalarMode = true;
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -3955,12 +3956,14 @@ int32_t fltReviseNodes(SFilterInfo *pInfo, SNode **pNode, SFltTreeStat *pStat) {
|
||||||
|
|
||||||
FLT_ERR_JRET(pStat->code);
|
FLT_ERR_JRET(pStat->code);
|
||||||
|
|
||||||
|
/*
|
||||||
int32_t nodeNum = taosArrayGetSize(pStat->nodeList);
|
int32_t nodeNum = taosArrayGetSize(pStat->nodeList);
|
||||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||||
SValueNode *valueNode = *(SValueNode **)taosArrayGet(pStat->nodeList, i);
|
SValueNode *valueNode = *(SValueNode **)taosArrayGet(pStat->nodeList, i);
|
||||||
|
|
||||||
FLT_ERR_JRET(sclConvertToTsValueNode(pStat->precision, valueNode));
|
FLT_ERR_JRET(sclConvertToTsValueNode(pStat->precision, valueNode));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
_return:
|
_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);
|
int32_t type = vectorGetConvertType(ctx->type.selfType, ctx->type.peerType);
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
type = nodeList->dataType.type;
|
type = nodeList->node.resType.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCL_ERR_RET(scalarGenerateSetFromList((void **)¶m->pHashFilter, node, 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: {
|
case QUERY_NODE_NODE_LIST: {
|
||||||
SNodeListNode *nodeList = (SNodeListNode *)pNode;
|
SNodeListNode *nodeList = (SNodeListNode *)pNode;
|
||||||
return nodeList->dataType.type;
|
return nodeList->node.resType.type;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_COLUMN: {
|
case QUERY_NODE_COLUMN: {
|
||||||
SColumnNode *colNode = (SColumnNode *)pNode;
|
SColumnNode *colNode = (SColumnNode *)pNode;
|
||||||
|
@ -1029,6 +1029,72 @@ bool sclContainsAggFuncNode(SNode *pNode) {
|
||||||
return aggFunc;
|
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) {
|
EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1040,15 +1106,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
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)) {
|
if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) {
|
||||||
sclDowngradeValueType(valueNode);
|
sclDowngradeValueType(valueNode);
|
||||||
}
|
}
|
||||||
|
@ -1061,15 +1118,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return sclRewriteNullInOptr(pNode, ctx, node->opType);
|
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)) {
|
if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) {
|
||||||
sclDowngradeValueType(valueNode);
|
sclDowngradeValueType(valueNode);
|
||||||
}
|
}
|
||||||
|
@ -1197,9 +1245,12 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||||
|
|
||||||
|
SCL_ERR_RET(sclConvertOpValueNodeTs(node, ctx));
|
||||||
|
|
||||||
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
||||||
return sclRewriteNonConstOperator(pNode, ctx);
|
return sclRewriteNonConstOperator(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
@ -1245,6 +1296,8 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
||||||
SCaseWhenNode *node = (SCaseWhenNode *)*pNode;
|
SCaseWhenNode *node = (SCaseWhenNode *)*pNode;
|
||||||
|
|
||||||
|
SCL_ERR_RET(sclConvertCaseWhenValueNodeTs(node, ctx));
|
||||||
|
|
||||||
if ((!SCL_IS_CONST_NODE(node->pCase)) || (!SCL_IS_CONST_NODE(node->pElse))) {
|
if ((!SCL_IS_CONST_NODE(node->pCase)) || (!SCL_IS_CONST_NODE(node->pElse))) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ void flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeL
|
||||||
void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||||
lnode->dataType.type = resType;
|
lnode->node.resType.type = resType;
|
||||||
lnode->pNodeList = list;
|
lnode->pNodeList = list;
|
||||||
|
|
||||||
*pNode = (SNode *)lnode;
|
*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) {
|
void scltMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||||
lnode->dataType.type = resType;
|
lnode->node.resType.type = resType;
|
||||||
lnode->pNodeList = list;
|
lnode->pNodeList = list;
|
||||||
|
|
||||||
*pNode = (SNode *)lnode;
|
*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 syncNodeOnAppendEntries(SSyncNode* pNode, const SRpcMsg* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||||
int32_t syncNodeOnSnapshot(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 syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||||
int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pMsg);
|
int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pMsg);
|
||||||
|
|
|
@ -86,7 +86,7 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceive
|
||||||
|
|
||||||
// on message
|
// on message
|
||||||
int32_t syncNodeOnSnapshot(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);
|
||||||
|
|
||||||
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode *pSyncNode, SyncIndex snapshotLastApplyIndex);
|
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 syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s);
|
||||||
void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff, 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 syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s);
|
||||||
void syncLogRecvSyncSnapshotSend(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);
|
code = syncNodeOnSnapshot(pSyncNode, pMsg);
|
||||||
break;
|
break;
|
||||||
case TDMT_SYNC_SNAPSHOT_RSP:
|
case TDMT_SYNC_SNAPSHOT_RSP:
|
||||||
code = syncNodeOnSnapshotReply(pSyncNode, pMsg);
|
code = syncNodeOnSnapshotRsp(pSyncNode, pMsg);
|
||||||
break;
|
break;
|
||||||
case TDMT_SYNC_LOCAL_CMD:
|
case TDMT_SYNC_LOCAL_CMD:
|
||||||
code = syncNodeOnLocalCmd(pSyncNode, pMsg);
|
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) {
|
int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t* seq) {
|
||||||
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
|
||||||
terrno = TSDB_CODE_SYN_NOT_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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,11 +815,9 @@ int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) {
|
||||||
ASSERTS(pNode->pLogStore != NULL, "log store not created");
|
ASSERTS(pNode->pLogStore != NULL, "log store not created");
|
||||||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot = {0};
|
||||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) {
|
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
||||||
SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore);
|
SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore);
|
||||||
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
|
||||||
|
@ -892,10 +890,10 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
||||||
// init by SSyncInfo
|
// init by SSyncInfo
|
||||||
pSyncNode->vgId = pSyncInfo->vgId;
|
pSyncNode->vgId = pSyncInfo->vgId;
|
||||||
SSyncCfg* pCfg = &pSyncInfo->syncCfg;
|
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) {
|
for (int32_t i = 0; i < pCfg->replicaNum; ++i) {
|
||||||
SNodeInfo* pNode = &pCfg->nodeInfo[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));
|
memcpy(pSyncNode->path, pSyncInfo->path, sizeof(pSyncNode->path));
|
||||||
|
@ -1029,11 +1027,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
||||||
SyncIndex commitIndex = SYNC_INDEX_INVALID;
|
SyncIndex commitIndex = SYNC_INDEX_INVALID;
|
||||||
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
SSnapshot snapshot = {0};
|
SSnapshot snapshot = {0};
|
||||||
int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||||
if (code != 0) {
|
|
||||||
sError("vgId:%d, failed to get snapshot info, code:%d", pSyncNode->vgId, code);
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
if (snapshot.lastApplyIndex > commitIndex) {
|
if (snapshot.lastApplyIndex > commitIndex) {
|
||||||
commitIndex = snapshot.lastApplyIndex;
|
commitIndex = snapshot.lastApplyIndex;
|
||||||
sNTrace(pSyncNode, "reset commit index by snapshot");
|
sNTrace(pSyncNode, "reset commit index by snapshot");
|
||||||
|
@ -1092,7 +1086,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
||||||
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i);
|
SSyncSnapshotSender* pSender = snapshotSenderCreate(pSyncNode, i);
|
||||||
// ASSERT(pSender != NULL);
|
// ASSERT(pSender != NULL);
|
||||||
(pSyncNode->senders)[i] = pSender;
|
(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
|
// snapshot receivers
|
||||||
|
@ -1155,9 +1149,8 @@ _error:
|
||||||
|
|
||||||
void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) {
|
||||||
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot = {0};
|
||||||
int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
|
||||||
ASSERT(code == 0);
|
|
||||||
if (snapshot.lastApplyIndex > pSyncNode->commitIndex) {
|
if (snapshot.lastApplyIndex > pSyncNode->commitIndex) {
|
||||||
pSyncNode->commitIndex = snapshot.lastApplyIndex;
|
pSyncNode->commitIndex = snapshot.lastApplyIndex;
|
||||||
}
|
}
|
||||||
|
@ -1301,10 +1294,6 @@ void syncNodeClose(SSyncNode* pSyncNode) {
|
||||||
syncNodeStopElectTimer(pSyncNode);
|
syncNodeStopElectTimer(pSyncNode);
|
||||||
syncNodeStopHeartbeatTimer(pSyncNode);
|
syncNodeStopHeartbeatTimer(pSyncNode);
|
||||||
|
|
||||||
if (pSyncNode->pFsm != NULL) {
|
|
||||||
taosMemoryFree(pSyncNode->pFsm);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||||
if ((pSyncNode->senders)[i] != NULL) {
|
if ((pSyncNode->senders)[i] != NULL) {
|
||||||
sSTrace((pSyncNode->senders)[i], "snapshot sender destroy while close, data:%p", (pSyncNode->senders)[i]);
|
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;
|
pSyncNode->pNewNodeReceiver = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSyncNode->pFsm != NULL) {
|
||||||
|
taosMemoryFree(pSyncNode->pFsm);
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFree(pSyncNode);
|
taosMemoryFree(pSyncNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,9 @@ SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, S
|
||||||
return prevLogTerm;
|
return prevLogTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot = {0};
|
||||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) == 0 && prevIndex == snapshot.lastApplyIndex) {
|
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
|
if (prevIndex == snapshot.lastApplyIndex) {
|
||||||
return snapshot.lastApplyTerm;
|
return snapshot.lastApplyTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,11 +146,9 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
||||||
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
ASSERTS(pNode->pFsm != NULL, "pFsm not registered");
|
||||||
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered");
|
||||||
|
|
||||||
SSnapshot snapshot;
|
SSnapshot snapshot = {0};
|
||||||
if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) {
|
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr());
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
||||||
SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0);
|
SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0);
|
||||||
if (syncLogValidateAlignmentOfCommit(pNode, commitIndex)) {
|
if (syncLogValidateAlignmentOfCommit(pNode, commitIndex)) {
|
||||||
|
|
|
@ -36,21 +36,21 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) {
|
||||||
taosThreadMutexInit(&(pObj->mutex), NULL);
|
taosThreadMutexInit(&(pObj->mutex), NULL);
|
||||||
|
|
||||||
SSyncNode *pNode = pObj->data;
|
SSyncNode *pNode = pObj->data;
|
||||||
sTrace("vgId:%d, create resp manager", pNode->vgId);
|
sDebug("vgId:%d, resp manager create", pNode->vgId);
|
||||||
return pObj;
|
return pObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncRespMgrDestroy(SSyncRespMgr *pObj) {
|
void syncRespMgrDestroy(SSyncRespMgr *pObj) {
|
||||||
if (pObj != NULL) {
|
if (pObj == NULL) return;
|
||||||
SSyncNode *pNode = pObj->data;
|
|
||||||
sTrace("vgId:%d, destroy resp manager", pNode->vgId);
|
|
||||||
|
|
||||||
taosThreadMutexLock(&pObj->mutex);
|
SSyncNode *pNode = pObj->data;
|
||||||
taosHashCleanup(pObj->pRespHash);
|
sDebug("vgId:%d, resp manager destroy", pNode->vgId);
|
||||||
taosThreadMutexUnlock(&pObj->mutex);
|
|
||||||
taosThreadMutexDestroy(&(pObj->mutex));
|
taosThreadMutexLock(&pObj->mutex);
|
||||||
taosMemoryFree(pObj);
|
taosHashCleanup(pObj->pRespHash);
|
||||||
}
|
taosThreadMutexUnlock(&pObj->mutex);
|
||||||
|
taosThreadMutexDestroy(&(pObj->mutex));
|
||||||
|
taosMemoryFree(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t syncRespMgrAdd(SSyncRespMgr *pObj, const SRespStub *pStub) {
|
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);
|
taosThreadMutexUnlock(&pObj->mutex);
|
||||||
return 1; // get one object
|
return 1; // get one object
|
||||||
} else {
|
} 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);
|
taosThreadMutexUnlock(&pObj->mutex);
|
||||||
|
@ -174,7 +174,7 @@ static void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
|
||||||
|
|
||||||
void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
||||||
SSyncNode *pNode = pObj->data;
|
SSyncNode *pNode = pObj->data;
|
||||||
sTrace("vgId:%d, clean all rsp", pNode->vgId);
|
sTrace("vgId:%d, clean all resp", pNode->vgId);
|
||||||
|
|
||||||
taosThreadMutexLock(&pObj->mutex);
|
taosThreadMutexLock(&pObj->mutex);
|
||||||
syncRespCleanByTTL(pObj, -1, true);
|
syncRespCleanByTTL(pObj, -1, true);
|
||||||
|
@ -183,7 +183,7 @@ void syncRespCleanRsp(SSyncRespMgr *pObj) {
|
||||||
|
|
||||||
void syncRespClean(SSyncRespMgr *pObj) {
|
void syncRespClean(SSyncRespMgr *pObj) {
|
||||||
SSyncNode *pNode = pObj->data;
|
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);
|
taosThreadMutexLock(&pObj->mutex);
|
||||||
syncRespCleanByTTL(pObj, pObj->ttl, false);
|
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) {
|
if (pNode != NULL && pNode->pRaftCfg != NULL) {
|
||||||
taosPrintLog(flags, level, dflag,
|
taosPrintLog(flags, level, dflag,
|
||||||
"vgId:%d, sync %s "
|
"vgId:%d, %s, sync:%s, term:%" PRIu64 ", commit-index:%" PRId64 ", first-ver:%" PRId64
|
||||||
"%s"
|
", last-ver:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64
|
||||||
", 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, "
|
", 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
|
"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",
|
", 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,
|
logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum,
|
||||||
pNode->becomeLeaderNum, pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum,
|
pNode->becomeLeaderNum, pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum,
|
||||||
pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum,
|
pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum,
|
||||||
|
@ -330,13 +328,13 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
|
||||||
va_end(argpointer);
|
va_end(argpointer);
|
||||||
|
|
||||||
taosPrintLog(flags, level, dflag,
|
taosPrintLog(flags, level, dflag,
|
||||||
"vgId:%d, sync %s "
|
"vgId:%d, %s, sync:%s, {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64
|
||||||
"%s {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
" lcindex:%" PRId64
|
||||||
" seq:%d ack:%d finish:%d replica-index:%d %s:%d}"
|
" seq:%d ack:%d finish:%d replica-index:%d %s:%d}"
|
||||||
", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" 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
|
", 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",
|
", 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->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm,
|
||||||
pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex,
|
pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex,
|
||||||
host, port, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex,
|
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);
|
va_end(argpointer);
|
||||||
|
|
||||||
taosPrintLog(flags, level, dflag,
|
taosPrintLog(flags, level, dflag,
|
||||||
"vgId:%d, sync %s "
|
"vgId:%d, %s, sync:%s,"
|
||||||
"%s {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from:%s:%d s-param:%" PRId64
|
" {%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
|
" e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
|
||||||
"}"
|
"}"
|
||||||
", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" 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
|
", 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",
|
", 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->term, pReceiver->startTime, host, port, pReceiver->snapshotParam.start,
|
||||||
pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm,
|
pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm,
|
||||||
pReceiver->snapshot.lastConfigIndex, pNode->pRaftStore->currentTerm, pNode->commitIndex, logBeginIndex,
|
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);
|
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) {
|
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
|
||||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||||
|
|
||||||
char host[64];
|
char host[64];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
sNTrace(pSyncNode,
|
sNDebug(pSyncNode,
|
||||||
"send sync-snapshot-send to %s:%d {term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64 ", lterm:%" PRId64
|
"send sync-snapshot-send to %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64
|
||||||
", stime:%" PRId64 ", seq:%d}, %s",
|
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||||
host, port, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->seq, s);
|
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) {
|
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
|
||||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||||
|
|
||||||
char host[64];
|
char host[64];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
sNTrace(pSyncNode,
|
sNDebug(pSyncNode,
|
||||||
"recv sync-snapshot-send from %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
"recv sync-snapshot-send from %s:%u, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||||
", stime:%" PRId64 ", seq:%d, len:%u}, %s",
|
", lterm:%" PRId64 ", stime:%" PRId64 ", len:%u",
|
||||||
host, port, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->seq,
|
host, port, s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime,
|
||||||
pMsg->dataLen, s);
|
pMsg->dataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
|
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
|
||||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||||
|
|
||||||
char host[64];
|
char host[64];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
syncUtilU642Addr(pMsg->destId.addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
sNTrace(pSyncNode,
|
sNDebug(pSyncNode,
|
||||||
"send sync-snapshot-rsp to %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
"send sync-snapshot-rsp to %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||||
", stime:%" PRId64 ", ack:%d}, %s",
|
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||||
host, port, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->ack, s);
|
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) {
|
void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
|
||||||
if (!(sDebugFlag & DEBUG_TRACE)) return;
|
if (!(sDebugFlag & DEBUG_DEBUG)) return;
|
||||||
|
|
||||||
char host[64];
|
char host[64];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port);
|
||||||
|
|
||||||
sNTrace(pSyncNode,
|
sNDebug(pSyncNode,
|
||||||
"recv sync-snapshot-rsp from %s:%d {term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 ", lterm:%" PRId64
|
"recv sync-snapshot-rsp from %s:%u, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
|
||||||
", stime:%" PRId64 ", ack:%d}, %s",
|
", lterm:%" PRId64 ", stime:%" PRId64,
|
||||||
host, port, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->ack, s);
|
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) {
|
void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ void init() {
|
||||||
pSyncNode->pWal = pWal;
|
pSyncNode->pWal = pWal;
|
||||||
|
|
||||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
// pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
|
|
|
@ -47,7 +47,7 @@ void init() {
|
||||||
pSyncNode->pWal = pWal;
|
pSyncNode->pWal = pWal;
|
||||||
|
|
||||||
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(SSyncFSM));
|
||||||
pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
// pSyncNode->pFsm->FpGetSnapshotInfo = GetSnapshotCb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
|
|
|
@ -132,7 +132,7 @@ char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeOnPreSnapshot(SSyncNode *ths, SyncPreSnapshot *pMsg) {
|
int32_t syncNodeOnPreSnapshot(SSyncNode *ths, SyncPreSnapshot *pMsg) {
|
||||||
syncLogRecvSyncPreSnapshot(ths, pMsg, "");
|
// syncLogRecvSyncPreSnapshot(ths, pMsg, "");
|
||||||
|
|
||||||
SyncPreSnapshotReply *pMsgReply = syncPreSnapshotReplyBuild(ths->vgId);
|
SyncPreSnapshotReply *pMsgReply = syncPreSnapshotReplyBuild(ths->vgId);
|
||||||
pMsgReply->srcId = ths->myRaftId;
|
pMsgReply->srcId = ths->myRaftId;
|
||||||
|
@ -181,7 +181,7 @@ _IGNORE:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeOnPreSnapshotReply(SSyncNode *ths, SyncPreSnapshotReply *pMsg) {
|
int32_t syncNodeOnPreSnapshotReply(SSyncNode *ths, SyncPreSnapshotReply *pMsg) {
|
||||||
syncLogRecvSyncPreSnapshotReply(ths, pMsg, "");
|
// syncLogRecvSyncPreSnapshotReply(ths, pMsg, "");
|
||||||
|
|
||||||
// start snapshot
|
// start snapshot
|
||||||
|
|
||||||
|
|
|
@ -205,15 +205,34 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) {
|
||||||
pCache->pFree = pPage;
|
pCache->pFree = pPage;
|
||||||
pPage->isFree = 0;
|
pPage->isFree = 0;
|
||||||
++pCache->nFree;
|
++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 {
|
} 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);
|
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
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) {
|
void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) {
|
||||||
i32 nRef;
|
i32 nRef;
|
||||||
|
|
||||||
|
@ -359,7 +378,7 @@ static void tdbPCachePinPage(SPCache *pCache, SPage *pPage) {
|
||||||
|
|
||||||
pCache->nRecyclable--;
|
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);
|
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) {
|
if (pPage->id < pCache->nPages) {
|
||||||
pPage->pLruPrev = &(pCache->lru);
|
pPage->pLruPrev = &(pCache->lru);
|
||||||
pPage->pLruNext = pCache->lru.pLruNext;
|
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);
|
// 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) {
|
static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
||||||
|
@ -415,7 +435,7 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage) {
|
||||||
|
|
||||||
pCache->nPage++;
|
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) {
|
static int tdbPCacheOpenImpl(SPCache *pCache) {
|
||||||
|
|
|
@ -299,6 +299,9 @@ int tdbPagerBegin(SPager *pPager, TXN *pTxn) {
|
||||||
pTxn->jPageSet = hashset_create();
|
pTxn->jPageSet = hashset_create();
|
||||||
|
|
||||||
pPager->pActiveTxn = pTxn;
|
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
|
// TODO: write the size of the file
|
||||||
/*
|
/*
|
||||||
pPager->inTran = 1;
|
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;
|
pPager->dbOrigSize = pPager->dbFileSize;
|
||||||
|
|
||||||
// release the page
|
// release the page
|
||||||
|
@ -381,6 +385,8 @@ int tdbPagerPostCommit(SPager *pPager, TXN *pTxn) {
|
||||||
|
|
||||||
// pPager->inTran = 0;
|
// pPager->inTran = 0;
|
||||||
|
|
||||||
|
tdbDebug("pager/post-commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +483,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
||||||
return -1;
|
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) {
|
for (int pgIndex = 0; pgIndex < journalSize; ++pgIndex) {
|
||||||
// read pgno & the page from journal
|
// read pgno & the page from journal
|
||||||
|
@ -489,7 +495,9 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
||||||
return -1;
|
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);
|
ret = tdbOsRead(jfd, pageBuf, pPager->pageSize);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -529,6 +537,9 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
||||||
SRBTreeNode *pNode = NULL;
|
SRBTreeNode *pNode = NULL;
|
||||||
while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
|
while ((pNode = tRBTreeIterNext(&iter)) != NULL) {
|
||||||
pPage = (SPage *)pNode;
|
pPage = (SPage *)pNode;
|
||||||
|
SPgno pgno = TDB_PAGE_PGNO(pPage);
|
||||||
|
|
||||||
|
tdbTrace("pager/abort: drop dirty pgno:%d,", pgno);
|
||||||
|
|
||||||
pPage->isDirty = 0;
|
pPage->isDirty = 0;
|
||||||
|
|
||||||
|
@ -538,7 +549,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
|
||||||
tdbPCacheRelease(pPager->pCache, pPage, 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);
|
tRBTreeCreate(&pPager->rbt, pageCmpFn);
|
||||||
|
|
||||||
// 4, remove the journal file
|
// 4, remove the journal file
|
||||||
|
@ -599,6 +610,9 @@ int tdbPagerFlushPage(SPager *pPager, TXN *pTxn) {
|
||||||
|
|
||||||
break;
|
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);
|
tdbTrace("tdb/flush:%p, %d/%d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize, maxPgno);
|
||||||
pPager->dbOrigSize = maxPgno;
|
pPager->dbOrigSize = maxPgno;
|
||||||
|
|
|
@ -224,6 +224,7 @@ int tdbPCacheAlter(SPCache *pCache, int32_t nPage);
|
||||||
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, TXN *pTxn);
|
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, TXN *pTxn);
|
||||||
void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn);
|
void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn);
|
||||||
void tdbPCacheMarkFree(SPCache *pCache, SPage *pPage);
|
void tdbPCacheMarkFree(SPCache *pCache, SPage *pPage);
|
||||||
|
void tdbPCacheInvalidatePage(SPCache *pCache, SPager *pPager, SPgno pgno);
|
||||||
int tdbPCacheGetPageSize(SPCache *pCache);
|
int tdbPCacheGetPageSize(SPCache *pCache);
|
||||||
|
|
||||||
// tdbPage.c ====================================
|
// tdbPage.c ====================================
|
||||||
|
|
|
@ -37,11 +37,11 @@ float tsNumOfCores = 0;
|
||||||
int64_t tsTotalMemoryKB = 0;
|
int64_t tsTotalMemoryKB = 0;
|
||||||
char *tsProcPath = NULL;
|
char *tsProcPath = NULL;
|
||||||
|
|
||||||
char tsSIMDBuiltins = 0;
|
char tsSIMDBuiltins = 0;
|
||||||
char tsSSE42Enable = 0;
|
char tsSSE42Enable = 0;
|
||||||
char tsAVXEnable = 0;
|
char tsAVXEnable = 0;
|
||||||
char tsAVX2Enable = 0;
|
char tsAVX2Enable = 0;
|
||||||
char tsFMAEnable = 0;
|
char tsFMAEnable = 0;
|
||||||
|
|
||||||
void osDefaultInit() {
|
void osDefaultInit() {
|
||||||
taosSeedRand(taosSafeRand());
|
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));
|
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 {
|
typedef struct {
|
||||||
iconv_t conv;
|
iconv_t conv;
|
||||||
int8_t inUse;
|
int8_t inUse;
|
||||||
} SConv;
|
} SConv;
|
||||||
|
|
||||||
SConv *gConv = NULL;
|
typedef enum { M2C = 0, C2M } ConvType;
|
||||||
int32_t convUsed = 0;
|
|
||||||
int32_t gConvMaxNum = 0;
|
// 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) {
|
int32_t taosConvInit(void) {
|
||||||
gConvMaxNum = 512;
|
int8_t M2C = 0;
|
||||||
gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv));
|
gConvMaxNum[M2C] = 512;
|
||||||
for (int32_t i = 0; i < gConvMaxNum; ++i) {
|
gConvMaxNum[1 - M2C] = 512;
|
||||||
gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
|
||||||
if ((iconv_t)-1 == gConv[i].conv || (iconv_t)0 == gConv[i].conv) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,23 +154,33 @@ int32_t taosConvInit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosConvDestroy() {
|
void taosConvDestroy() {
|
||||||
for (int32_t i = 0; i < gConvMaxNum; ++i) {
|
int8_t M2C = 0;
|
||||||
iconv_close(gConv[i].conv);
|
for (int32_t i = 0; i < gConvMaxNum[M2C]; ++i) {
|
||||||
|
iconv_close(gConv[M2C][i].conv);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(gConv);
|
for (int32_t i = 0; i < gConvMaxNum[1 - M2C]; ++i) {
|
||||||
gConvMaxNum = -1;
|
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) {
|
iconv_t taosAcquireConv(int32_t *idx, ConvType type) {
|
||||||
if (gConvMaxNum <= 0) {
|
if (gConvMaxNum[type] <= 0) {
|
||||||
*idx = -1;
|
*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) {
|
while (true) {
|
||||||
int32_t used = atomic_add_fetch_32(&convUsed, 1);
|
int32_t used = atomic_add_fetch_32(&convUsed[type], 1);
|
||||||
if (used > gConvMaxNum) {
|
if (used > gConvMaxNum[type]) {
|
||||||
used = atomic_sub_fetch_32(&convUsed, 1);
|
used = atomic_sub_fetch_32(&convUsed[type], 1);
|
||||||
sched_yield();
|
sched_yield();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -181,31 +188,31 @@ iconv_t taosAcquireConv(int32_t *idx) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t startId = taosGetSelfPthreadId() % gConvMaxNum;
|
int32_t startId = taosGetSelfPthreadId() % gConvMaxNum[type];
|
||||||
while (true) {
|
while (true) {
|
||||||
if (gConv[startId].inUse) {
|
if (gConv[type][startId].inUse) {
|
||||||
startId = (startId + 1) % gConvMaxNum;
|
startId = (startId + 1) % gConvMaxNum[type];
|
||||||
continue;
|
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) {
|
if (0 == old) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*idx = startId;
|
*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) {
|
if (idx < 0) {
|
||||||
iconv_close(conv);
|
iconv_close(conv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_store_8(&gConv[idx].inUse, 0);
|
atomic_store_8(&gConv[type][idx].inUse, 0);
|
||||||
atomic_sub_fetch_32(&convUsed, 1);
|
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) {
|
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);
|
memset(ucs4, 0, ucs4_max_len);
|
||||||
|
|
||||||
int32_t idx = -1;
|
int32_t idx = -1;
|
||||||
iconv_t conv = taosAcquireConv(&idx);
|
iconv_t conv = taosAcquireConv(&idx, M2C);
|
||||||
size_t ucs4_input_len = mbsLength;
|
size_t ucs4_input_len = mbsLength;
|
||||||
size_t outLeft = ucs4_max_len;
|
size_t outLeft = ucs4_max_len;
|
||||||
if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) {
|
if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) {
|
||||||
taosReleaseConv(idx, conv);
|
taosReleaseConv(idx, conv, M2C);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosReleaseConv(idx, conv);
|
taosReleaseConv(idx, conv, M2C);
|
||||||
if (len != NULL) {
|
if (len != NULL) {
|
||||||
*len = (int32_t)(ucs4_max_len - outLeft);
|
*len = (int32_t)(ucs4_max_len - outLeft);
|
||||||
if (*len < 0) {
|
if (*len < 0) {
|
||||||
|
@ -236,6 +243,24 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
||||||
#endif
|
#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) {
|
bool taosValidateEncodec(const char *encodec) {
|
||||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
||||||
|
|
|
@ -248,16 +248,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_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_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_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
|
// mnode-trans
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_ALREADY_EXIST, "Transaction already exists")
|
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_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_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_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_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_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
|
// mnode-mq
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOPIC_ALREADY_EXIST, "Topic already exists")
|
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;
|
const SDiskbasedBufStatis* ps = &pBuf->statis;
|
||||||
|
|
||||||
|
#if 0
|
||||||
printf(
|
printf(
|
||||||
"Paged buffer closed, total:%.2f Kb (%d Pages), inmem size:%.2f Kb (%d Pages), file size:%.2f Kb, page size:%.2f "
|
"Paged buffer closed, total:%.2f Kb (%d Pages), inmem size:%.2f Kb (%d Pages), file size:%.2f Kb, page size:%.2f "
|
||||||
"Kb, %s\n",
|
"Kb, %s\n",
|
||||||
pBuf->totalBufSize / 1024.0, pBuf->numOfPages, listNEles(pBuf->lruList) * pBuf->pageSize / 1024.0,
|
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);
|
listNEles(pBuf->lruList), pBuf->fileSize / 1024.0, pBuf->pageSize / 1024.0f, pBuf->id);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ps->loadPages > 0) {
|
if (ps->loadPages > 0) {
|
||||||
printf(
|
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->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
|
||||||
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
|
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
|
||||||
} else {
|
} 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/session.sim
|
||||||
,,y,script,./test.sh -f tsim/query/udf.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/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/qnode/basic1.sim
|
||||||
,,y,script,./test.sh -f tsim/snode/basic1.sim
|
,,y,script,./test.sh -f tsim/snode/basic1.sim
|
||||||
,,y,script,./test.sh -f tsim/mnode/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/scalar.sim
|
||||||
,,y,script,./test.sh -f tsim/scalar/filter.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/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/cached_schema_after_alter.sim
|
||||||
,,y,script,./test.sh -f tsim/alter/dnode.sim
|
,,y,script,./test.sh -f tsim/alter/dnode.sim
|
||||||
,,y,script,./test.sh -f tsim/alter/table.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/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/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_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
|
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
|
||||||
,,n,system-test,python3 ./test.py -f 0-others/compatibility.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
|
,,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/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/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/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_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_math.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.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/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/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/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_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_math.py -Q 2
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.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/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/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/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_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_math.py -Q 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.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/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/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/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_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_math.py -Q 4
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.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
|
return
|
||||||
|
|
||||||
toBeKilled = "taosadapter"
|
toBeKilled = "taosadapter"
|
||||||
|
|
||||||
if self.running != 0:
|
if self.running != 0:
|
||||||
psCmd = f"ps -ef|grep -w {toBeKilled}| grep -v grep | awk '{{print $2}}'"
|
psCmd = f"ps -ef|grep -w {toBeKilled}| grep -v grep | awk '{{print $2}}'"
|
||||||
# psCmd = f"pgrep {toBeKilled}"
|
# psCmd = f"pgrep {toBeKilled}"
|
||||||
|
|
|
@ -66,32 +66,40 @@ function buildTDengine() {
|
||||||
|
|
||||||
function runCasesOneByOne () {
|
function runCasesOneByOne () {
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
cmd=`echo $line | cut -d',' -f 5`
|
if [[ "$line" != "#"* ]]; then
|
||||||
if [[ "$2" == "sim" ]] && [[ $cmd == *"test.sh"* ]]; then
|
cmd=`echo $line | cut -d',' -f 5`
|
||||||
case=`echo $cmd | cut -d' ' -f 3`
|
if [[ "$2" == "sim" ]] && [[ $line == *"script"* ]]; then
|
||||||
start_time=`date +%s`
|
case=`echo $cmd | cut -d' ' -f 3`
|
||||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
start_time=`date +%s`
|
||||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT \
|
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||||
|| echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT \
|
||||||
end_time=`date +%s`
|
|| echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
end_time=`date +%s`
|
||||||
elif [[ "$2" == "system-test" ]] && [[ $line == *"system-test"* ]]; then
|
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||||
case=`echo $cmd | cut -d' ' -f 4`
|
elif [[ "$2" == "system-test" ]] && [[ $line == *"system-test"* ]]; then
|
||||||
start_time=`date +%s`
|
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
||||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
||||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
fi
|
||||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
case=`echo $cmd | cut -d' ' -f 4-20`
|
||||||
end_time=`date +%s`
|
start_time=`date +%s`
|
||||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
||||||
elif [[ "$2" == "develop-test" ]] && [[ $line == *"develop-test"* ]]; then
|
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
||||||
case=`echo $cmd | cut -d' ' -f 4`
|
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
||||||
start_time=`date +%s`
|
end_time=`date +%s`
|
||||||
date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && $cmd > /dev/null 2>&1 && \
|
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
||||||
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
|
elif [[ "$2" == "develop-test" ]] && [[ $line == *"develop-test"* ]]; then
|
||||||
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
|
if [[ "$cmd" == *"pytest.sh"* ]]; then
|
||||||
end_time=`date +%s`
|
cmd=`echo $cmd | cut -d' ' -f 2-20`
|
||||||
echo execution time of $case was `expr $end_time - $start_time`s. | tee -a $TDENGINE_COVERAGE_REPORT
|
fi
|
||||||
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
|
done < $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,17 @@ if $data00 != 5.000000000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
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
|
print =============== clear
|
||||||
sql drop database $db
|
sql drop database $db
|
||||||
sql select * from information_schema.ins_databases
|
sql select * from information_schema.ins_databases
|
||||||
|
|
|
@ -1075,16 +1075,11 @@ if $loop_count == 20 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data00 != 20026 then
|
if $data00 != 40052 then
|
||||||
print =====data00=$data00
|
print =====data00=$data00
|
||||||
goto loop0
|
goto loop0
|
||||||
endi
|
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);
|
sql select _wstart, count(a) from st where ts >= 1648712201000 and ts <= 1648732226000 partition by tbname interval(1s) fill(prev);
|
||||||
|
|
||||||
if $rows != 40052 then
|
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
|
goto loop3
|
||||||
endi
|
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())")
|
use.error(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())")
|
||||||
elif check_priv == PRIVILEGES_WRITE:
|
elif check_priv == PRIVILEGES_WRITE:
|
||||||
use.query(f"use {DBNAME}")
|
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.error(f"select * from {DBNAME}.{CTBNAME}")
|
||||||
use.query(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())")
|
use.query(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())")
|
||||||
elif check_priv is None:
|
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.query(f"select avg(c1) ,avg(c2) , avg(c3) , avg(c4), avg(c5), avg(c6) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,920350133.571428537)
|
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,2,14042.142857143)
|
||||||
tdSql.checkData(0,3,53.571428571)
|
tdSql.checkData(0,3,53.571428571)
|
||||||
tdSql.checkData(0,4,5.828571332045761e+37)
|
tdSql.checkData(0,4,5.828571332045761e+37)
|
||||||
|
@ -419,13 +419,56 @@ class TDTestCase:
|
||||||
# check + - * / in functions
|
# 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.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,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,2,14042.142857143)
|
||||||
tdSql.checkData(0,3,26.785714286)
|
tdSql.checkData(0,3,26.785714286)
|
||||||
tdSql.checkData(0,4,2.9142856660228804e+37)
|
tdSql.checkData(0,4,2.9142856660228804e+37)
|
||||||
tdSql.checkData(0,5,None)
|
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
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
@ -455,6 +498,8 @@ class TDTestCase:
|
||||||
self.avg_func_filter()
|
self.avg_func_filter()
|
||||||
self.avg_check_unsigned()
|
self.avg_check_unsigned()
|
||||||
|
|
||||||
|
# check avg overflow
|
||||||
|
self.avg_check_overflow()
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
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