Merge branch '3.0' of github.com:taosdata/TDengine into test/udf_test
This commit is contained in:
commit
b55d49b862
|
@ -343,7 +343,7 @@ typedef struct SSdb {
|
||||||
int64_t maxId[SDB_MAX];
|
int64_t maxId[SDB_MAX];
|
||||||
EKeyType keyTypes[SDB_MAX];
|
EKeyType keyTypes[SDB_MAX];
|
||||||
SHashObj *hashObjs[SDB_MAX];
|
SHashObj *hashObjs[SDB_MAX];
|
||||||
SRWLatch locks[SDB_MAX];
|
TdThreadRwlock locks[SDB_MAX];
|
||||||
SdbInsertFp insertFps[SDB_MAX];
|
SdbInsertFp insertFps[SDB_MAX];
|
||||||
SdbUpdateFp updateFps[SDB_MAX];
|
SdbUpdateFp updateFps[SDB_MAX];
|
||||||
SdbDeleteFp deleteFps[SDB_MAX];
|
SdbDeleteFp deleteFps[SDB_MAX];
|
||||||
|
|
|
@ -95,6 +95,15 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan,
|
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan,
|
||||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model);
|
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tinfo
|
||||||
|
* @param sversion
|
||||||
|
* @param tversion
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t* tversion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main task execution function, including query on both table and multiple tables,
|
* The main task execution function, including query on both table and multiple tables,
|
||||||
* which are decided according to the tag or table name query conditions
|
* which are decided according to the tag or table name query conditions
|
||||||
|
|
|
@ -142,6 +142,8 @@ void fmFuncMgtDestroy();
|
||||||
|
|
||||||
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc);
|
int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc);
|
||||||
|
|
||||||
|
bool fmIsBuiltinFunc(const char* pFunc);
|
||||||
|
|
||||||
bool fmIsAggFunc(int32_t funcId);
|
bool fmIsAggFunc(int32_t funcId);
|
||||||
bool fmIsScalarFunc(int32_t funcId);
|
bool fmIsScalarFunc(int32_t funcId);
|
||||||
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
||||||
|
|
|
@ -78,7 +78,7 @@ typedef struct SAlterDatabaseStmt {
|
||||||
|
|
||||||
typedef struct STableOptions {
|
typedef struct STableOptions {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char comment[TSDB_STB_COMMENT_LEN];
|
char comment[TSDB_TB_COMMENT_LEN];
|
||||||
int32_t delay;
|
int32_t delay;
|
||||||
float filesFactor;
|
float filesFactor;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
|
@ -90,7 +90,7 @@ typedef struct SColumnDefNode {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char colName[TSDB_COL_NAME_LEN];
|
char colName[TSDB_COL_NAME_LEN];
|
||||||
SDataType dataType;
|
SDataType dataType;
|
||||||
char comments[TSDB_STB_COMMENT_LEN];
|
char comments[TSDB_TB_COMMENT_LEN];
|
||||||
bool sma;
|
bool sma;
|
||||||
} SColumnDefNode;
|
} SColumnDefNode;
|
||||||
|
|
||||||
|
|
|
@ -647,6 +647,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x264A)
|
#define TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x264A)
|
||||||
#define TSDB_CODE_PAR_INVALID_MODIFY_COL TAOS_DEF_ERROR_CODE(0, 0x264B)
|
#define TSDB_CODE_PAR_INVALID_MODIFY_COL TAOS_DEF_ERROR_CODE(0, 0x264B)
|
||||||
#define TSDB_CODE_PAR_INVALID_TBNAME TAOS_DEF_ERROR_CODE(0, 0x264C)
|
#define TSDB_CODE_PAR_INVALID_TBNAME TAOS_DEF_ERROR_CODE(0, 0x264C)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_FUNCTION_NAME TAOS_DEF_ERROR_CODE(0, 0x264D)
|
||||||
|
#define TSDB_CODE_PAR_COMMENT_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x264E)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -219,7 +219,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb
|
#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb
|
||||||
|
|
||||||
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
||||||
#define TSDB_STB_COMMENT_LEN 1024
|
#define TSDB_TB_COMMENT_LEN 1025
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||||
|
|
|
@ -1435,7 +1435,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t wait_time) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tmqHandleAllDelayedTask(tmq);
|
tmqHandleAllDelayedTask(tmq);
|
||||||
tmqPollImpl(tmq, wait_time);
|
if (tmqPollImpl(tmq, wait_time) < 0) return NULL;
|
||||||
|
|
||||||
rspObj = tmqHandleAllRsp(tmq, wait_time, false);
|
rspObj = tmqHandleAllRsp(tmq, wait_time, false);
|
||||||
if (rspObj) {
|
if (rspObj) {
|
||||||
|
|
|
@ -36,9 +36,9 @@ typedef struct SBnodeMgmt {
|
||||||
|
|
||||||
// bmHandle.c
|
// bmHandle.c
|
||||||
SArray *bmGetMsgHandles();
|
SArray *bmGetMsgHandles();
|
||||||
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pReq);
|
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pReq);
|
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// bmWorker.c
|
// bmWorker.c
|
||||||
int32_t bmStartWorker(SBnodeMgmt *pMgmt);
|
int32_t bmStartWorker(SBnodeMgmt *pMgmt);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
||||||
|
|
||||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonBmInfo bmInfo = {0};
|
SMonBmInfo bmInfo = {0};
|
||||||
bmGetMonitorInfo(pMgmt, &bmInfo);
|
bmGetMonitorInfo(pMgmt, &bmInfo);
|
||||||
dmGetMonitorSystemInfo(&bmInfo.sys);
|
dmGetMonitorSystemInfo(&bmInfo.sys);
|
||||||
|
@ -37,17 +37,15 @@ int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonBmInfo(pRsp, rspLen, &bmInfo);
|
tSerializeSMonBmInfo(pRsp, rspLen, &bmInfo);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonBmInfo(&bmInfo);
|
tFreeSMonBmInfo(&bmInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDCreateBnodeReq createReq = {0};
|
SDCreateBnodeReq createReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +66,8 @@ int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDDropBnodeReq dropReq = {0};
|
SDDropBnodeReq dropReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
||||||
if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) {
|
if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) {
|
||||||
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
||||||
taosWLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockWrlock(&pMgmt->pData->lock);
|
||||||
pMgmt->pData->dnodeId = pCfg->dnodeId;
|
pMgmt->pData->dnodeId = pCfg->dnodeId;
|
||||||
pMgmt->pData->clusterId = pCfg->clusterId;
|
pMgmt->pData->clusterId = pCfg->clusterId;
|
||||||
dmWriteEps(pMgmt->pData);
|
dmWriteEps(pMgmt->pData);
|
||||||
taosWUnLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
|
||||||
void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
SStatusReq req = {0};
|
SStatusReq req = {0};
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||||
req.sver = tsVersion;
|
req.sver = tsVersion;
|
||||||
req.dnodeVer = pMgmt->pData->dnodeVer;
|
req.dnodeVer = pMgmt->pData->dnodeVer;
|
||||||
req.dnodeId = pMgmt->pData->dnodeId;
|
req.dnodeId = pMgmt->pData->dnodeId;
|
||||||
|
@ -69,7 +69,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
||||||
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
||||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||||
taosRUnLockLatch(&pMgmt->pData->latch);
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
|
|
||||||
SMonVloadInfo vinfo = {0};
|
SMonVloadInfo vinfo = {0};
|
||||||
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
(*pMgmt->getVnodeLoadsFp)(&vinfo);
|
||||||
|
|
|
@ -41,18 +41,18 @@ typedef struct SMnodeMgmt {
|
||||||
|
|
||||||
// mmFile.c
|
// mmFile.c
|
||||||
int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed);
|
int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed);
|
||||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq, bool deployed);
|
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed);
|
||||||
|
|
||||||
// mmInt.c
|
// mmInt.c
|
||||||
int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq);
|
int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pMsg);
|
||||||
|
|
||||||
// mmHandle.c
|
// mmHandle.c
|
||||||
SArray *mmGetMsgHandles();
|
SArray *mmGetMsgHandles();
|
||||||
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// mmWorker.c
|
// mmWorker.c
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
||||||
|
@ -62,10 +62,10 @@ int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutRpcMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc);
|
int32_t mmPutRpcMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutRpcMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc);
|
int32_t mmPutRpcMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutRpcMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc);
|
int32_t mmPutRpcMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutRpcMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pRpc);
|
int32_t mmPutRpcMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq, bool deployed) {
|
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
|
||||||
|
@ -124,11 +124,11 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq, bool deployed) {
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"mnodes\": [{\n");
|
len += snprintf(content + len, maxLen - len, " \"mnodes\": [{\n");
|
||||||
|
|
||||||
int8_t replica = (pReq != NULL ? pReq->replica : pMgmt->replica);
|
int8_t replica = (pMsg != NULL ? pMsg->replica : pMgmt->replica);
|
||||||
for (int32_t i = 0; i < replica; ++i) {
|
for (int32_t i = 0; i < replica; ++i) {
|
||||||
SReplica *pReplica = &pMgmt->replicas[i];
|
SReplica *pReplica = &pMgmt->replicas[i];
|
||||||
if (pReq != NULL) {
|
if (pMsg != NULL) {
|
||||||
pReplica = &pReq->replicas[i];
|
pReplica = &pMsg->replicas[i];
|
||||||
}
|
}
|
||||||
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
||||||
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
||||||
|
|
|
@ -25,7 +25,7 @@ void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
||||||
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonMmInfo mmInfo = {0};
|
SMonMmInfo mmInfo = {0};
|
||||||
mmGetMonitorInfo(pMgmt, &mmInfo);
|
mmGetMonitorInfo(pMgmt, &mmInfo);
|
||||||
dmGetMonitorSystemInfo(&mmInfo.sys);
|
dmGetMonitorSystemInfo(&mmInfo.sys);
|
||||||
|
@ -44,13 +44,13 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonMmInfo(pRsp, rspLen, &mmInfo);
|
tSerializeSMonMmInfo(pRsp, rspLen, &mmInfo);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonMmInfo(&mmInfo);
|
tFreeSMonMmInfo(&mmInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonMloadInfo mloads = {0};
|
SMonMloadInfo mloads = {0};
|
||||||
mmGetMnodeLoads(pMgmt, &mloads);
|
mmGetMnodeLoads(pMgmt, &mloads);
|
||||||
|
|
||||||
|
@ -67,16 +67,14 @@ int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonMloadInfo(pRsp, rspLen, &mloads);
|
tSerializeSMonMloadInfo(pRsp, rspLen, &mloads);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDCreateMnodeReq createReq = {0};
|
SDCreateMnodeReq createReq = {0};
|
||||||
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSDCreateMnodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -101,10 +99,8 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDDropMnodeReq dropReq = {0};
|
SDDropMnodeReq dropReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -129,10 +125,8 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDAlterMnodeReq alterReq = {0};
|
SDAlterMnodeReq alterReq = {0};
|
||||||
if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
if (tDeserializeSDCreateMnodeReq(pMsg->pCont, pMsg->contLen, &alterReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCre
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq) {
|
int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pMsg) {
|
||||||
SMnodeOpt option = {0};
|
SMnodeOpt option = {0};
|
||||||
if (mmBuildOptionFromReq(pMgmt, &option, pReq) != 0) {
|
if (mmBuildOptionFromReq(pMgmt, &option, pMsg) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deployed = true;
|
bool deployed = true;
|
||||||
if (mmWriteFile(pMgmt, pReq, deployed) != 0) {
|
if (mmWriteFile(pMgmt, pMsg, deployed) != 0) {
|
||||||
dError("failed to write mnode file since %s", terrstr());
|
dError("failed to write mnode file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)mmPutRpcMsgToQueryQueue;
|
pMgmt->msgCb.queueFps[QUERY_QUEUE] = (PutToQueueFp)mmPutRpcMsgToQueryQueue;
|
||||||
pMgmt->msgCb.queueFps[READ_QUEUE] = (PutToQueueFp)mmPutRpcMsgToReadQueue;
|
pMgmt->msgCb.queueFps[READ_QUEUE] = (PutToQueueFp)mmPutRpcMsgToReadQueue;
|
||||||
pMgmt->msgCb.queueFps[WRITE_QUEUE] = (PutToQueueFp)mmPutRpcMsgToWriteQueue;
|
pMgmt->msgCb.queueFps[WRITE_QUEUE] = (PutToQueueFp)mmPutRpcMsgToWriteQueue;
|
||||||
pMgmt->msgCb.queueFps[SYNC_QUEUE] = (PutToQueueFp)mmPutRpcMsgToWriteQueue;
|
pMgmt->msgCb.queueFps[SYNC_QUEUE] = (PutToQueueFp)mmPutRpcMsgToSyncQueue;
|
||||||
pMgmt->msgCb.mgmt = pMgmt;
|
pMgmt->msgCb.mgmt = pMgmt;
|
||||||
|
|
||||||
bool deployed = false;
|
bool deployed = false;
|
||||||
|
|
|
@ -126,7 +126,7 @@ int32_t mmPutRpcMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return mmPutRpcMsgToWorker(&pMgmt->readWorker, pMsg);
|
return mmPutRpcMsgToWorker(&pMgmt->readWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pMsg); }
|
int32_t mmPutRpcMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutRpcMsgToWorker(&pMgmt->syncWorker, pMsg); }
|
||||||
|
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
SSingleWorkerCfg qCfg = {
|
SSingleWorkerCfg qCfg = {
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct SQnodeMgmt {
|
||||||
SArray *qmGetMsgHandles();
|
SArray *qmGetMsgHandles();
|
||||||
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// qmWorker.c
|
// qmWorker.c
|
||||||
int32_t qmPutRpcMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t qmPutRpcMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {}
|
||||||
|
|
||||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonQmInfo qmInfo = {0};
|
SMonQmInfo qmInfo = {0};
|
||||||
qmGetMonitorInfo(pMgmt, &qmInfo);
|
qmGetMonitorInfo(pMgmt, &qmInfo);
|
||||||
dmGetMonitorSystemInfo(&qmInfo.sys);
|
dmGetMonitorSystemInfo(&qmInfo.sys);
|
||||||
|
@ -37,17 +37,15 @@ int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonQmInfo(pRsp, rspLen, &qmInfo);
|
tSerializeSMonQmInfo(pRsp, rspLen, &qmInfo);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonQmInfo(&qmInfo);
|
tFreeSMonQmInfo(&qmInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDCreateQnodeReq createReq = {0};
|
SDCreateQnodeReq createReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +66,8 @@ int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDDropQnodeReq dropReq = {0};
|
SDDropQnodeReq dropReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ typedef struct SSnodeMgmt {
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *name;
|
const char *name;
|
||||||
SRWLatch latch;
|
|
||||||
int8_t uniqueWorkerInUse;
|
int8_t uniqueWorkerInUse;
|
||||||
SArray *uniqueWorkers; // SArray<SMultiWorker*>
|
SArray *uniqueWorkers; // SArray<SMultiWorker*>
|
||||||
SSingleWorker sharedWorker;
|
SSingleWorker sharedWorker;
|
||||||
|
@ -41,7 +40,7 @@ typedef struct SSnodeMgmt {
|
||||||
SArray *smGetMsgHandles();
|
SArray *smGetMsgHandles();
|
||||||
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// smWorker.c
|
// smWorker.c
|
||||||
int32_t smStartWorker(SSnodeMgmt *pMgmt);
|
int32_t smStartWorker(SSnodeMgmt *pMgmt);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
||||||
|
|
||||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonSmInfo smInfo = {0};
|
SMonSmInfo smInfo = {0};
|
||||||
smGetMonitorInfo(pMgmt, &smInfo);
|
smGetMonitorInfo(pMgmt, &smInfo);
|
||||||
dmGetMonitorSystemInfo(&smInfo.sys);
|
dmGetMonitorSystemInfo(&smInfo.sys);
|
||||||
|
@ -37,17 +37,15 @@ int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonSmInfo(pRsp, rspLen, &smInfo);
|
tSerializeSMonSmInfo(pRsp, rspLen, &smInfo);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonSmInfo(&smInfo);
|
tFreeSMonSmInfo(&smInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDCreateSnodeReq createReq = {0};
|
SDCreateSnodeReq createReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +66,8 @@ int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
|
|
||||||
SDDropSnodeReq dropReq = {0};
|
SDDropSnodeReq dropReq = {0};
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct SVnodeMgmt {
|
||||||
SSingleWorker mgmtWorker;
|
SSingleWorker mgmtWorker;
|
||||||
SSingleWorker monitorWorker;
|
SSingleWorker monitorWorker;
|
||||||
SHashObj *hash;
|
SHashObj *hash;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
SVnodesStat state;
|
SVnodesStat state;
|
||||||
STfs *pTfs;
|
STfs *pTfs;
|
||||||
} SVnodeMgmt;
|
} SVnodeMgmt;
|
||||||
|
@ -84,10 +84,10 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
|
||||||
|
|
||||||
// vmHandle.c
|
// vmHandle.c
|
||||||
SArray *vmGetMsgHandles();
|
SArray *vmGetMsgHandles();
|
||||||
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq);
|
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// vmFile.c
|
// vmFile.c
|
||||||
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "vmInt.h"
|
#include "vmInt.h"
|
||||||
|
|
||||||
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
int32_t size = taosHashGetSize(pMgmt->hash);
|
int32_t size = taosHashGetSize(pMgmt->hash);
|
||||||
|
@ -38,7 +38,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
*numOfVnodes = num;
|
*numOfVnodes = num;
|
||||||
|
|
||||||
return pVnodes;
|
return pVnodes;
|
||||||
|
|
|
@ -20,7 +20,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||||
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad));
|
pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad));
|
||||||
if (pInfo->pVloads == NULL) return;
|
if (pInfo->pVloads == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
|
@ -34,7 +34,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
|
||||||
pIter = taosHashIterate(pMgmt->hash, pIter);
|
pIter = taosHashIterate(pMgmt->hash, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||||
|
@ -82,7 +82,7 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
||||||
taosArrayDestroy(pVloads);
|
taosArrayDestroy(pVloads);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonVmInfo vmInfo = {0};
|
SMonVmInfo vmInfo = {0};
|
||||||
vmGetMonitorInfo(pMgmt, &vmInfo);
|
vmGetMonitorInfo(pMgmt, &vmInfo);
|
||||||
dmGetMonitorSystemInfo(&vmInfo.sys);
|
dmGetMonitorSystemInfo(&vmInfo.sys);
|
||||||
|
@ -101,13 +101,13 @@ int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonVmInfo(pRsp, rspLen, &vmInfo);
|
tSerializeSMonVmInfo(pRsp, rspLen, &vmInfo);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonVmInfo(&vmInfo);
|
tFreeSMonVmInfo(&vmInfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonVloadInfo vloads = {0};
|
SMonVloadInfo vloads = {0};
|
||||||
vmGetVnodeLoads(pMgmt, &vloads);
|
vmGetVnodeLoads(pMgmt, &vloads);
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSMonVloadInfo(pRsp, rspLen, &vloads);
|
tSerializeSMonVloadInfo(pRsp, rspLen, &vloads);
|
||||||
pReq->info.rsp = pRsp;
|
pMsg->info.rsp = pRsp;
|
||||||
pReq->info.rspLen = rspLen;
|
pMsg->info.rspLen = rspLen;
|
||||||
tFreeSMonVloadInfo(&vloads);
|
tFreeSMonVloadInfo(&vloads);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -174,12 +174,11 @@ static void vmGenerateWrapperCfg(SVnodeMgmt *pMgmt, SCreateVnodeReq *pCreate, SW
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
SCreateVnodeReq createReq = {0};
|
SCreateVnodeReq createReq = {0};
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateVnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateVnodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -242,9 +241,8 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SRpcMsg *pReq = pMsg;
|
|
||||||
SDropVnodeReq dropReq = {0};
|
SDropVnodeReq dropReq = {0};
|
||||||
if (tDeserializeSDropVnodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropVnodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,14 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||||
SVnodeObj *pVnode = NULL;
|
SVnodeObj *pVnode = NULL;
|
||||||
int32_t refCount = 0;
|
int32_t refCount = 0;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode);
|
taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
|
||||||
} else {
|
} else {
|
||||||
refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
refCount = atomic_add_fetch_32(&pVnode->refCount, 1);
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
if (pVnode != NULL) {
|
if (pVnode != NULL) {
|
||||||
dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
|
dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
|
||||||
|
@ -39,9 +39,9 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
|
||||||
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
if (pVnode == NULL) return;
|
if (pVnode == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pMgmt->latch);
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
dTrace("vgId:%d, release vnode, refCount:%d", pVnode->vgId, refCount);
|
dTrace("vgId:%d, release vnode, refCount:%d", pVnode->vgId, refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
char path[TSDB_FILENAME_LEN] = {0};
|
char path[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosThreadRwlockWrlock(&pMgmt->lock);
|
||||||
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
vmReleaseVnode(pMgmt, pVnode);
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
while (pVnode->refCount > 0) taosMsleep(10);
|
while (pVnode->refCount > 0) taosMsleep(10);
|
||||||
|
@ -239,6 +239,7 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
|
||||||
vmStopWorker(pMgmt);
|
vmStopWorker(pMgmt);
|
||||||
vnodeCleanup();
|
vnodeCleanup();
|
||||||
tfsClose(pMgmt->pTfs);
|
tfsClose(pMgmt->pTfs);
|
||||||
|
taosThreadRwlockDestroy(&pMgmt->lock);
|
||||||
taosMemoryFree(pMgmt);
|
taosMemoryFree(pMgmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +261,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->msgCb.queueFps[MERGE_QUEUE] = (PutToQueueFp)vmPutRpcMsgToMergeQueue;
|
pMgmt->msgCb.queueFps[MERGE_QUEUE] = (PutToQueueFp)vmPutRpcMsgToMergeQueue;
|
||||||
pMgmt->msgCb.qsizeFp = (GetQueueSizeFp)vmGetQueueSize;
|
pMgmt->msgCb.qsizeFp = (GetQueueSizeFp)vmGetQueueSize;
|
||||||
pMgmt->msgCb.mgmt = pMgmt;
|
pMgmt->msgCb.mgmt = pMgmt;
|
||||||
taosInitRWLatch(&pMgmt->latch);
|
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
||||||
|
|
||||||
SDiskCfg dCfg = {0};
|
SDiskCfg dCfg = {0};
|
||||||
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
||||||
|
@ -334,19 +335,23 @@ static int32_t vmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmStart(SVnodeMgmt *pMgmt) {
|
static int32_t vmStart(SVnodeMgmt *pMgmt) {
|
||||||
taosRLockLatch(&pMgmt->latch);
|
int32_t numOfVnodes = 0;
|
||||||
|
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(pMgmt->hash, NULL);
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
while (pIter) {
|
SVnodeObj *pVnode = pVnodes[i];
|
||||||
SVnodeObj **ppVnode = pIter;
|
|
||||||
if (ppVnode == NULL || *ppVnode == NULL) continue;
|
|
||||||
|
|
||||||
SVnodeObj *pVnode = *ppVnode;
|
|
||||||
vnodeStart(pVnode->pImpl);
|
vnodeStart(pVnode->pImpl);
|
||||||
pIter = taosHashIterate(pMgmt->hash, pIter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pMgmt->latch);
|
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||||
|
SVnodeObj *pVnode = pVnodes[i];
|
||||||
|
vmReleaseVnode(pMgmt, pVnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pVnodes != NULL) {
|
||||||
|
taosMemoryFree(pVnodes);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ typedef struct SMgmtWrapper {
|
||||||
const char *name;
|
const char *name;
|
||||||
char *path;
|
char *path;
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
EDndNodeType ntype;
|
EDndNodeType ntype;
|
||||||
bool deployed;
|
bool deployed;
|
||||||
bool required;
|
bool required;
|
||||||
|
|
|
@ -91,7 +91,7 @@ static int32_t dmInitVars(SDnode *pDnode, EDndNodeType rtype) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosInitRWLatch(&pData->latch);
|
taosThreadRwlockInit(&pData->lock, NULL);
|
||||||
taosThreadMutexInit(&pDnode->mutex, NULL);
|
taosThreadMutexInit(&pDnode->mutex, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
taosMemoryFreeClear(pWrapper->path);
|
taosMemoryFreeClear(pWrapper->path);
|
||||||
|
taosThreadRwlockDestroy(&pWrapper->lock);
|
||||||
}
|
}
|
||||||
if (pDnode->lockfile != NULL) {
|
if (pDnode->lockfile != NULL) {
|
||||||
taosUnLockFile(pDnode->lockfile);
|
taosUnLockFile(pDnode->lockfile);
|
||||||
|
@ -108,7 +109,7 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
SDnodeData *pData = &pDnode->data;
|
||||||
taosWLockLatch(&pData->latch);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
if (pData->dnodeEps != NULL) {
|
if (pData->dnodeEps != NULL) {
|
||||||
taosArrayDestroy(pData->dnodeEps);
|
taosArrayDestroy(pData->dnodeEps);
|
||||||
pData->dnodeEps = NULL;
|
pData->dnodeEps = NULL;
|
||||||
|
@ -117,8 +118,9 @@ static void dmClearVars(SDnode *pDnode) {
|
||||||
taosHashCleanup(pData->dnodeHash);
|
taosHashCleanup(pData->dnodeHash);
|
||||||
pData->dnodeHash = NULL;
|
pData->dnodeHash = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
|
|
||||||
|
taosThreadRwlockDestroy(&pData->lock);
|
||||||
taosThreadMutexDestroy(&pDnode->mutex);
|
taosThreadMutexDestroy(&pDnode->mutex);
|
||||||
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
|
||||||
if (ntype == DNODE) {
|
if (ntype == DNODE) {
|
||||||
pWrapper->proc.ptype = DND_PROC_SINGLE;
|
pWrapper->proc.ptype = DND_PROC_SINGLE;
|
||||||
}
|
}
|
||||||
taosInitRWLatch(&pWrapper->latch);
|
taosThreadRwlockInit(&pWrapper->lock, NULL);
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
|
||||||
pWrapper->path = strdup(path);
|
pWrapper->path = strdup(path);
|
||||||
|
@ -223,7 +225,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
SMgmtWrapper *pRetWrapper = pWrapper;
|
SMgmtWrapper *pRetWrapper = pWrapper;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
if (pWrapper->deployed) {
|
if (pWrapper->deployed) {
|
||||||
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
||||||
dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount);
|
||||||
|
@ -231,7 +233,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
pRetWrapper = NULL;
|
pRetWrapper = NULL;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
return pRetWrapper;
|
return pRetWrapper;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +241,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
|
||||||
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
if (pWrapper->deployed || (InParentProc(pWrapper) && pWrapper->required)) {
|
if (pWrapper->deployed || (InParentProc(pWrapper) && pWrapper->required)) {
|
||||||
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
|
||||||
dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
|
||||||
|
@ -247,7 +249,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -255,9 +257,9 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
|
||||||
void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
|
void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
|
||||||
if (pWrapper == NULL) return;
|
if (pWrapper == NULL) return;
|
||||||
|
|
||||||
taosRLockLatch(&pWrapper->latch);
|
taosThreadRwlockRdlock(&pWrapper->lock);
|
||||||
int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1);
|
int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1);
|
||||||
taosRUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount);
|
dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,12 +186,12 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWLockLatch(&pWrapper->latch);
|
taosThreadRwlockWrlock(&pWrapper->lock);
|
||||||
if (pWrapper->pMgmt != NULL) {
|
if (pWrapper->pMgmt != NULL) {
|
||||||
(*pWrapper->func.closeFp)(pWrapper->pMgmt);
|
(*pWrapper->func.closeFp)(pWrapper->pMgmt);
|
||||||
pWrapper->pMgmt = NULL;
|
pWrapper->pMgmt = NULL;
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(&pWrapper->latch);
|
taosThreadRwlockUnlock(&pWrapper->lock);
|
||||||
|
|
||||||
if (!OnlyInSingleProc(pWrapper)) {
|
if (!OnlyInSingleProc(pWrapper)) {
|
||||||
dmCleanupProc(pWrapper);
|
dmCleanupProc(pWrapper);
|
||||||
|
|
|
@ -200,12 +200,12 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmSendRpcRedirectRsp(const SRpcMsg *pReq) {
|
static void dmSendRpcRedirectRsp(const SRpcMsg *pMsg) {
|
||||||
SDnode *pDnode = dmInstance();
|
SDnode *pDnode = dmInstance();
|
||||||
SEpSet epSet = {0};
|
SEpSet epSet = {0};
|
||||||
dmGetMnodeEpSet(&pDnode->data, &epSet);
|
dmGetMnodeEpSet(&pDnode->data, &epSet);
|
||||||
|
|
||||||
dDebug("RPC %p, req is redirected, num:%d use:%d", pReq->info.handle, epSet.numOfEps, epSet.inUse);
|
dDebug("RPC %p, req is redirected, num:%d use:%d", pMsg->info.handle, epSet.numOfEps, epSet.inUse);
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
dDebug("mnode index:%d %s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
dDebug("mnode index:%d %s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||||
if (strcmp(epSet.eps[i].fqdn, tsLocalFqdn) == 0 && epSet.eps[i].port == tsServerPort) {
|
if (strcmp(epSet.eps[i].fqdn, tsLocalFqdn) == 0 && epSet.eps[i].port == tsServerPort) {
|
||||||
|
@ -220,12 +220,14 @@ static void dmSendRpcRedirectRsp(const SRpcMsg *pReq) {
|
||||||
|
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = TSDB_CODE_RPC_REDIRECT,
|
.code = TSDB_CODE_RPC_REDIRECT,
|
||||||
.info = pReq->info,
|
.info = pMsg->info,
|
||||||
.contLen = len,
|
.contLen = len,
|
||||||
};
|
};
|
||||||
rsp.pCont = rpcMallocCont(len);
|
rsp.pCont = rpcMallocCont(len);
|
||||||
tSerializeSMEpSet(rsp.pCont, len, &msg);
|
tSerializeSMEpSet(rsp.pCont, len, &msg);
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dmSendRecv(SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
static inline void dmSendRecv(SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
||||||
|
@ -239,16 +241,16 @@ static inline void dmSendRecv(SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pReq) {
|
static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
SDnode *pDnode = dmInstance();
|
SDnode *pDnode = dmInstance();
|
||||||
if (pDnode->status != DND_STAT_RUNNING) {
|
if (pDnode->status != DND_STAT_RUNNING) {
|
||||||
rpcFreeCont(pReq->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
pReq->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
terrno = TSDB_CODE_NODE_OFFLINE;
|
terrno = TSDB_CODE_NODE_OFFLINE;
|
||||||
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pReq->info.handle);
|
dError("failed to send rpc msg since %s, handle:%p", terrstr(), pMsg->info.handle);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
rpcSendRequest(pDnode->trans.clientRpc, pEpSet, pReq, NULL);
|
rpcSendRequest(pDnode->trans.clientRpc, pEpSet, pMsg, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ typedef struct {
|
||||||
SEpSet mnodeEps;
|
SEpSet mnodeEps;
|
||||||
SArray *dnodeEps;
|
SArray *dnodeEps;
|
||||||
SHashObj *dnodeHash;
|
SHashObj *dnodeHash;
|
||||||
SRWLatch latch;
|
TdThreadRwlock lock;
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
} SDnodeData;
|
} SDnodeData;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep);
|
||||||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps);
|
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps);
|
||||||
|
|
||||||
static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) {
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
|
@ -36,7 +36,7 @@ static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmReadEps(SDnodeData *pData) {
|
int32_t dmReadEps(SDnodeData *pData) {
|
||||||
|
@ -232,7 +232,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
||||||
int32_t numOfEps = taosArrayGetSize(eps);
|
int32_t numOfEps = taosArrayGetSize(eps);
|
||||||
if (numOfEps <= 0) return;
|
if (numOfEps <= 0) return;
|
||||||
|
|
||||||
taosWLockLatch(&pData->latch);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
|
|
||||||
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pData->dnodeEps);
|
int32_t numOfEpsOld = (int32_t)taosArrayGetSize(pData->dnodeEps);
|
||||||
if (numOfEps != numOfEpsOld) {
|
if (numOfEps != numOfEpsOld) {
|
||||||
|
@ -246,7 +246,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
||||||
|
@ -292,7 +292,7 @@ static void dmPrintEps(SDnodeData *pData) {
|
||||||
static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (dnodeId == 0) return changed;
|
if (dnodeId == 0) return changed;
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
|
|
||||||
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t));
|
||||||
if (pDnodeEp != NULL) {
|
if (pDnodeEp != NULL) {
|
||||||
|
@ -304,24 +304,23 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
taosRLockLatch(&pData->latch);
|
taosThreadRwlockRdlock(&pData->lock);
|
||||||
*pEpSet = pData->mnodeEps;
|
*pEpSet = pData->mnodeEps;
|
||||||
taosRUnLockLatch(&pData->latch);
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
||||||
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
taosThreadRwlockWrlock(&pData->lock);
|
||||||
|
|
||||||
taosWLockLatch(&pData->latch);
|
|
||||||
pData->mnodeEps = *pEpSet;
|
pData->mnodeEps = *pEpSet;
|
||||||
|
taosThreadRwlockUnlock(&pData->lock);
|
||||||
|
|
||||||
|
dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse);
|
||||||
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
for (int32_t i = 0; i < pEpSet->numOfEps; ++i) {
|
||||||
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
dInfo("mnode index:%d %s:%u", i, pEpSet->eps[i].fqdn, pEpSet->eps[i].port);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pData->latch);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -848,7 +848,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)cgroup, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)cgroup, false);
|
||||||
|
|
||||||
// app id
|
// client id
|
||||||
char clientId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
char clientId[TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
tstrncpy(varDataVal(clientId), pConsumer->clientId, TSDB_CGROUP_LEN);
|
tstrncpy(varDataVal(clientId), pConsumer->clientId, TSDB_CGROUP_LEN);
|
||||||
varDataSetLen(clientId, strlen(varDataVal(clientId)));
|
varDataSetLen(clientId, strlen(varDataVal(clientId)));
|
||||||
|
|
|
@ -624,14 +624,12 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen, .info = pReq->info};
|
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen, .info = pReq->info};
|
||||||
|
|
||||||
mInfo("dnode:%d, app:%p config:%s req send to dnode", cfgReq.dnodeId, rpcMsg.info.ahandle, cfgReq.config);
|
mDebug("dnode:%d, send config req to dnode, app:%p", cfgReq.dnodeId, rpcMsg.info.ahandle);
|
||||||
tmsgSendReq(&epSet, &rpcMsg);
|
return tmsgSendReq(&epSet, &rpcMsg);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
||||||
mInfo("app:%p config rsp from dnode", pRsp->info.ahandle);
|
mDebug("config rsp from dnode, app:%p", pRsp->info.ahandle);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
||||||
taosInitRWLatch(&pSdb->locks[i]);
|
taosThreadRwlockInit(&pSdb->locks[i], NULL);
|
||||||
pSdb->maxId[i] = 0;
|
pSdb->maxId[i] = 0;
|
||||||
pSdb->tableVer[i] = 0;
|
pSdb->tableVer[i] = 0;
|
||||||
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
||||||
|
@ -98,7 +98,10 @@ void sdbCleanup(SSdb *pSdb) {
|
||||||
|
|
||||||
taosHashClear(hash);
|
taosHashClear(hash);
|
||||||
taosHashCleanup(hash);
|
taosHashCleanup(hash);
|
||||||
|
taosThreadRwlockDestroy(&pSdb->locks[i]);
|
||||||
pSdb->hashObjs[i] = NULL;
|
pSdb->hashObjs[i] = NULL;
|
||||||
|
memset(&pSdb->locks[i], 0, sizeof(pSdb->locks[i]));
|
||||||
|
|
||||||
mDebug("sdb table:%s is cleaned up", sdbTableName(i));
|
mDebug("sdb table:%s is cleaned up", sdbTableName(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +137,6 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
|
||||||
|
|
||||||
pSdb->maxId[sdbType] = 0;
|
pSdb->maxId[sdbType] = 0;
|
||||||
pSdb->hashObjs[sdbType] = hash;
|
pSdb->hashObjs[sdbType] = hash;
|
||||||
taosInitRWLatch(&pSdb->locks[sdbType]);
|
|
||||||
mDebug("sdb table:%s is initialized", sdbTableName(sdbType));
|
mDebug("sdb table:%s is initialized", sdbTableName(sdbType));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -257,8 +257,8 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
mTrace("write %s to file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
mTrace("write %s to file, total %d rows", sdbTableName(i), sdbGetSize(pSdb, i));
|
||||||
|
|
||||||
SHashObj *hash = pSdb->hashObjs[i];
|
SHashObj *hash = pSdb->hashObjs[i];
|
||||||
SRWLatch *pLock = &pSdb->locks[i];
|
TdThreadRwlock *pLock = &pSdb->locks[i];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -303,7 +303,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
|
|
@ -129,12 +129,12 @@ static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (pOldRow != NULL) {
|
if (pOldRow != NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -145,13 +145,13 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
sdbPrintOper(pSdb, pRow, "insert");
|
sdbPrintOper(pSdb, pRow, "insert");
|
||||||
|
|
||||||
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
SdbInsertFp insertFp = pSdb->insertFps[pRow->type];
|
||||||
|
@ -159,9 +159,9 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
code = (*insertFp)(pSdb, pRow->pObj);
|
code = (*insertFp)(pSdb, pRow->pObj);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
taosHashRemove(hash, pRow->pObj, keySize);
|
taosHashRemove(hash, pRow->pObj, keySize);
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -180,19 +180,19 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pNewRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pNewRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *pOldRow = *ppOldRow;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
||||||
|
@ -207,12 +207,12 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -223,7 +223,7 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
sdbPrintOper(pSdb, pOldRow, "delete");
|
sdbPrintOper(pSdb, pOldRow, "delete");
|
||||||
|
|
||||||
taosHashRemove(hash, pOldRow->pObj, keySize);
|
taosHashRemove(hash, pOldRow->pObj, keySize);
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
|
@ -278,12 +278,12 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
void *pRet = NULL;
|
void *pRet = NULL;
|
||||||
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
int32_t keySize = sdbGetkeySize(pSdb, type, pKey);
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
SSdbRow **ppRow = taosHashGet(hash, pKey, keySize);
|
||||||
if (ppRow == NULL || *ppRow == NULL) {
|
if (ppRow == NULL || *ppRow == NULL) {
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
terrno = TSDB_CODE_SDB_OBJ_NOT_THERE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -306,13 +306,13 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_load_32(&pRow->refCount);
|
int32_t ref = atomic_load_32(&pRow->refCount);
|
||||||
sdbPrintOper(pSdb, pRow, "check");
|
sdbPrintOper(pSdb, pRow, "check");
|
||||||
|
@ -320,7 +320,7 @@ static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbRelease(SSdb *pSdb, void *pObj) {
|
void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
|
@ -329,8 +329,8 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
SSdbRow *pRow = (SSdbRow *)((char *)pObj - sizeof(SSdbRow));
|
||||||
if (pRow->type >= SDB_MAX) return;
|
if (pRow->type >= SDB_MAX) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosWLockLatch(pLock);
|
taosThreadRwlockWrlock(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||||
sdbPrintOper(pSdb, pRow, "release");
|
sdbPrintOper(pSdb, pRow, "release");
|
||||||
|
@ -338,7 +338,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
|
@ -347,8 +347,8 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return NULL;
|
if (hash == NULL) return NULL;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -363,7 +363,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
*ppObj = pRow->pObj;
|
*ppObj = pRow->pObj;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
return ppRow;
|
return ppRow;
|
||||||
}
|
}
|
||||||
|
@ -374,18 +374,18 @@ void sdbCancelFetch(SSdb *pSdb, void *pIter) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
TdThreadRwlock *pLock = &pSdb->locks[pRow->type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
taosHashCancelIterate(hash, pIter);
|
taosHashCancelIterate(hash, pIter);
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2, void *p3) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return;
|
if (hash == NULL) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -401,17 +401,17 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
int32_t sdbGetSize(SSdb *pSdb, ESdbType type) {
|
||||||
SHashObj *hash = sdbGetHash(pSdb, type);
|
SHashObj *hash = sdbGetHash(pSdb, type);
|
||||||
if (hash == NULL) return 0;
|
if (hash == NULL) return 0;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
int32_t size = taosHashGetSize(hash);
|
int32_t size = taosHashGetSize(hash);
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -424,8 +424,8 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
|
|
||||||
int32_t maxId = 0;
|
int32_t maxId = 0;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
TdThreadRwlock *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosThreadRwlockRdlock(pLock);
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
|
@ -435,7 +435,7 @@ int32_t sdbGetMaxId(SSdb *pSdb, ESdbType type) {
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosThreadRwlockUnlock(pLock);
|
||||||
|
|
||||||
maxId = TMAX(maxId, pSdb->maxId[type]);
|
maxId = TMAX(maxId, pSdb->maxId[type]);
|
||||||
return maxId + 1;
|
return maxId + 1;
|
||||||
|
|
|
@ -128,6 +128,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
|
||||||
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList);
|
||||||
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver);
|
||||||
bool tqNextDataBlock(STqReadHandle *pHandle);
|
bool tqNextDataBlock(STqReadHandle *pHandle);
|
||||||
|
bool tqNextDataBlockFilterOut(STqReadHandle *pHandle, SHashObj *filterOutUids);
|
||||||
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, uint64_t *pUid,
|
int32_t tqRetrieveDataBlock(SArray **ppCols, STqReadHandle *pHandle, uint64_t *pGroupId, uint64_t *pUid,
|
||||||
int32_t *pNumOfRows, int16_t *pNumOfCols);
|
int32_t *pNumOfRows, int16_t *pNumOfCols);
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ typedef struct {
|
||||||
int8_t withSchema;
|
int8_t withSchema;
|
||||||
int8_t withTag;
|
int8_t withTag;
|
||||||
char* qmsg;
|
char* qmsg;
|
||||||
|
SHashObj* pDropTbUid;
|
||||||
STqPushHandle pushHandle;
|
STqPushHandle pushHandle;
|
||||||
// SRWLatch lock;
|
// SRWLatch lock;
|
||||||
SWalReadHandle* pWalReader;
|
SWalReadHandle* pWalReader;
|
||||||
|
|
|
@ -82,7 +82,7 @@ int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq*
|
||||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||||
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
||||||
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq);
|
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids);
|
||||||
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq);
|
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq);
|
||||||
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
||||||
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
||||||
|
@ -104,7 +104,7 @@ int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeep
|
||||||
int tsdbClose(STsdb** pTsdb);
|
int tsdbClose(STsdb** pTsdb);
|
||||||
int tsdbBegin(STsdb* pTsdb);
|
int tsdbBegin(STsdb* pTsdb);
|
||||||
int tsdbCommit(STsdb* pTsdb);
|
int tsdbCommit(STsdb* pTsdb);
|
||||||
int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, const SSubmitReq *pMsg);
|
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, const SSubmitReq* pMsg);
|
||||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||||
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
||||||
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
|
@ -118,7 +118,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal);
|
||||||
void tqClose(STQ*);
|
void tqClose(STQ*);
|
||||||
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver);
|
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver);
|
||||||
int tqCommit(STQ*);
|
int tqCommit(STQ*);
|
||||||
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList);
|
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd);
|
||||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen, int32_t workerId);
|
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen, int32_t workerId);
|
||||||
|
|
|
@ -44,6 +44,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
pMeta->path = (char *)&pMeta[1];
|
pMeta->path = (char *)&pMeta[1];
|
||||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
VNODE_META_DIR);
|
VNODE_META_DIR);
|
||||||
|
taosRealPath(pMeta->path, NULL, slen);
|
||||||
pMeta->pVnode = pVnode;
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
// create path if not created yet
|
// create path if not created yet
|
||||||
|
|
|
@ -255,7 +255,7 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids) {
|
||||||
TBC *pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
TBC *pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
TBC *pNameIdxc = NULL;
|
TBC *pNameIdxc = NULL;
|
||||||
|
@ -336,6 +336,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq) {
|
||||||
if (type == TSDB_CHILD_TABLE) {
|
if (type == TSDB_CHILD_TABLE) {
|
||||||
ctime = me.ctbEntry.ctime;
|
ctime = me.ctbEntry.ctime;
|
||||||
suid = me.ctbEntry.suid;
|
suid = me.ctbEntry.suid;
|
||||||
|
taosArrayPush(tbUids, &me.uid);
|
||||||
} else if (type == TSDB_NORMAL_TABLE) {
|
} else if (type == TSDB_NORMAL_TABLE) {
|
||||||
ctime = me.ntbEntry.ctime;
|
ctime = me.ntbEntry.ctime;
|
||||||
suid = 0;
|
suid = 0;
|
||||||
|
|
|
@ -104,16 +104,26 @@ static void tdSRowDemo() {
|
||||||
taosMemoryFree(pTSChema);
|
taosMemoryFree(pTSChema);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList) {
|
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
STqExec* pExec = NULL;
|
STqExec* pExec = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = taosHashIterate(pTq->execs, pIter);
|
pIter = taosHashIterate(pTq->execs, pIter);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
pExec = (STqExec*)pIter;
|
pExec = (STqExec*)pIter;
|
||||||
if (pExec->subType == TOPIC_SUB_TYPE__DB) continue;
|
if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
|
if (isAdd) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
int32_t sz = taosArrayGetSize(tbUidList);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
||||||
|
taosHashPut(pExec->pDropTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < 5; i++) {
|
for (int32_t i = 0; i < 5; i++) {
|
||||||
int32_t code = qUpdateQualifiedTableId(pExec->task[i], tbUidList, true);
|
int32_t code = qUpdateQualifiedTableId(pExec->task[i], tbUidList, isAdd);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,7 +592,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
rsp.withSchema = 1;
|
rsp.withSchema = 1;
|
||||||
STqReadHandle* pReader = pExec->pExecReader[workerId];
|
STqReadHandle* pReader = pExec->pExecReader[workerId];
|
||||||
tqReadHandleSetMsg(pReader, pCont, 0);
|
tqReadHandleSetMsg(pReader, pCont, 0);
|
||||||
while (tqNextDataBlock(pReader)) {
|
while (tqNextDataBlockFilterOut(pReader, pExec->pDropTbUid)) {
|
||||||
SSDataBlock block = {0};
|
SSDataBlock block = {0};
|
||||||
if (tqRetrieveDataBlock(&block.pDataBlock, pReader, &block.info.groupId, &block.info.uid, &block.info.rows,
|
if (tqRetrieveDataBlock(&block.pDataBlock, pReader, &block.info.groupId, &block.info.uid, &block.info.rows,
|
||||||
&block.info.numOfCols) < 0) {
|
&block.info.numOfCols) < 0) {
|
||||||
|
@ -915,9 +925,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
req.qmsg = NULL;
|
req.qmsg = NULL;
|
||||||
|
|
||||||
pExec->pWalReader = walOpenReadHandle(pTq->pVnode->pWal);
|
pExec->pWalReader = walOpenReadHandle(pTq->pVnode->pWal);
|
||||||
|
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||||
for (int32_t i = 0; i < 5; i++) {
|
for (int32_t i = 0; i < 5; i++) {
|
||||||
pExec->pExecReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
pExec->pExecReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||||
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
|
||||||
SReadHandle handle = {
|
SReadHandle handle = {
|
||||||
.reader = pExec->pExecReader[i],
|
.reader = pExec->pExecReader[i],
|
||||||
.meta = pTq->pVnode->pMeta,
|
.meta = pTq->pVnode->pMeta,
|
||||||
|
@ -925,9 +936,12 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
};
|
};
|
||||||
pExec->task[i] = qCreateStreamExecTaskInfo(pExec->qmsg, &handle);
|
pExec->task[i] = qCreateStreamExecTaskInfo(pExec->qmsg, &handle);
|
||||||
ASSERT(pExec->task[i]);
|
ASSERT(pExec->task[i]);
|
||||||
} else {
|
|
||||||
pExec->task[i] = NULL;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = 0; i < 5; i++) {
|
||||||
|
pExec->pExecReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta);
|
||||||
|
}
|
||||||
|
pExec->pDropTbUid = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
}
|
}
|
||||||
taosHashPut(pTq->execs, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
taosHashPut(pTq->execs, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -64,22 +64,28 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
}
|
}
|
||||||
if (pHandle->pBlock == NULL) return false;
|
if (pHandle->pBlock == NULL) return false;
|
||||||
|
|
||||||
/*pHandle->pBlock->uid = htobe64(pHandle->pBlock->uid);*/
|
|
||||||
/*if (pHandle->tbUid == pHandle->pBlock->uid) {*/
|
|
||||||
if (pHandle->tbIdHash == NULL) {
|
if (pHandle->tbIdHash == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->msgIter.uid, sizeof(int64_t));
|
void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->msgIter.uid, sizeof(int64_t));
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
/*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/
|
|
||||||
/*pHandle->pBlock->tid = htonl(pHandle->pBlock->tid);*/
|
|
||||||
/*pHandle->pBlock->sversion = htonl(pHandle->pBlock->sversion);*/
|
|
||||||
/*pHandle->pBlock->dataLen = htonl(pHandle->pBlock->dataLen);*/
|
|
||||||
/*pHandle->pBlock->schemaLen = htonl(pHandle->pBlock->schemaLen);*/
|
|
||||||
/*pHandle->pBlock->numOfRows = htons(pHandle->pBlock->numOfRows);*/
|
|
||||||
return true;
|
return true;
|
||||||
/*} else {*/
|
}
|
||||||
/*printf("skip one tb %ld\n", pHandle->pBlock->uid);*/
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) {
|
||||||
|
while (1) {
|
||||||
|
if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (pHandle->pBlock == NULL) return false;
|
||||||
|
|
||||||
|
ASSERT(pHandle->tbIdHash == NULL);
|
||||||
|
void* ret = taosHashGet(filterOutUids, &pHandle->msgIter.uid, sizeof(int64_t));
|
||||||
|
if (ret == NULL) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,6 +55,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
memcpy(pTsdb->dir, dir, strlen(dir));
|
memcpy(pTsdb->dir, dir, strlen(dir));
|
||||||
pTsdb->path = (char *)&pTsdb[1];
|
pTsdb->path = (char *)&pTsdb[1];
|
||||||
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, dir);
|
||||||
|
taosRealPath(pTsdb->path, NULL, slen);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
pTsdb->repoLocked = false;
|
pTsdb->repoLocked = false;
|
||||||
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||||
|
|
|
@ -420,6 +420,11 @@ static STsdbReadHandle* tsdbQueryTablesImpl(SVnode* pVnode, SQueryTableDataCond*
|
||||||
setQueryTimewindow(pReadHandle, pCond);
|
setQueryTimewindow(pReadHandle, pCond);
|
||||||
|
|
||||||
if (pCond->numOfCols > 0) {
|
if (pCond->numOfCols > 0) {
|
||||||
|
int32_t rowLen = 0;
|
||||||
|
for(int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||||
|
rowLen += pCond->colList[i].bytes;
|
||||||
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
pReadHandle->suppInfo.pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
pReadHandle->suppInfo.pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
||||||
if (pReadHandle->suppInfo.pstatis == NULL) {
|
if (pReadHandle->suppInfo.pstatis == NULL) {
|
||||||
|
|
|
@ -109,6 +109,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open wal
|
// open wal
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||||
if (pVnode->pWal == NULL) {
|
if (pVnode->pWal == NULL) {
|
||||||
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
@ -117,6 +118,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open tq
|
// open tq
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
|
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||||
if (pVnode->pTq == NULL) {
|
if (pVnode->pTq == NULL) {
|
||||||
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
|
|
@ -62,11 +62,6 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
|
||||||
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
|
|
||||||
vError("vgId:%d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
/* META */
|
/* META */
|
||||||
case TDMT_VND_CREATE_STB:
|
case TDMT_VND_CREATE_STB:
|
||||||
|
@ -123,8 +118,18 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
|
||||||
|
vError("vgId:%d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
vDebug("vgId:%d process %s request success, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
|
vDebug("vgId:%d process %s request success, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
|
||||||
|
|
||||||
|
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
|
||||||
|
vError("vgId:%d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// commit if need
|
// commit if need
|
||||||
if (vnodeShouldCommit(pVnode)) {
|
if (vnodeShouldCommit(pVnode)) {
|
||||||
vInfo("vgId:%d commit at version %" PRId64, TD_VID(pVnode), version);
|
vInfo("vgId:%d commit at version %" PRId64, TD_VID(pVnode), version);
|
||||||
|
@ -386,7 +391,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
tqUpdateTbUidList(pVnode->pTq, tbUids);
|
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
||||||
tdUpdateTbUidList(pVnode->pSma, pStore);
|
tdUpdateTbUidList(pVnode->pSma, pStore);
|
||||||
tdUidStoreFree(pStore);
|
tdUidStoreFree(pStore);
|
||||||
|
|
||||||
|
@ -517,6 +522,7 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int ret;
|
int ret;
|
||||||
|
SArray *tbUids = NULL;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
||||||
pRsp->pCont = NULL;
|
pRsp->pCont = NULL;
|
||||||
|
@ -533,13 +539,16 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
}
|
}
|
||||||
|
|
||||||
// process req
|
// process req
|
||||||
|
tbUids = taosArrayInit(req.nReqs, sizeof(int64_t));
|
||||||
rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp));
|
rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp));
|
||||||
|
if (tbUids == NULL || rsp.pArray == NULL) goto _exit;
|
||||||
|
|
||||||
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
||||||
SVDropTbRsp dropTbRsp = {0};
|
SVDropTbRsp dropTbRsp = {0};
|
||||||
|
|
||||||
/* code */
|
/* code */
|
||||||
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq);
|
ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (pDropTbReq->igNotExists && terrno == TSDB_CODE_VND_TABLE_NOT_EXIST) {
|
if (pDropTbReq->igNotExists && terrno == TSDB_CODE_VND_TABLE_NOT_EXIST) {
|
||||||
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -553,7 +562,10 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
taosArrayPush(rsp.pArray, &dropTbRsp);
|
taosArrayPush(rsp.pArray, &dropTbRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tqUpdateTbUidList(pVnode->pTq, tbUids, false);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
taosArrayDestroy(tbUids);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
|
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
|
||||||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||||
|
|
|
@ -217,6 +217,13 @@ typedef struct SExecTaskInfo {
|
||||||
int64_t owner; // if it is in execution
|
int64_t owner; // if it is in execution
|
||||||
int32_t code;
|
int32_t code;
|
||||||
uint64_t totalRows; // total number of rows
|
uint64_t totalRows; // total number of rows
|
||||||
|
struct {
|
||||||
|
char *tablename;
|
||||||
|
char *dbname;
|
||||||
|
int32_t sversion;
|
||||||
|
int32_t tversion;
|
||||||
|
} schemaVer;
|
||||||
|
|
||||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||||
char* sql; // query sql string
|
char* sql; // query sql string
|
||||||
jmp_buf env; // jump to this position when error happens.
|
jmp_buf env; // jump to this position when error happens.
|
||||||
|
@ -689,7 +696,8 @@ SSDataBlock* loadNextDataBlock(void* param);
|
||||||
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset);
|
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset);
|
||||||
|
|
||||||
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
||||||
int32_t type);
|
SExecTaskInfo* pTaskInfo, int32_t type);
|
||||||
|
|
||||||
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs);
|
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs);
|
||||||
SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode);
|
SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode);
|
||||||
int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode);
|
int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
#include <vnode.h>
|
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
@ -171,3 +170,15 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t* tversion) {
|
||||||
|
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
|
||||||
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo;
|
||||||
|
|
||||||
|
*sversion = pTaskInfo->schemaVer.sversion;
|
||||||
|
*tversion = pTaskInfo->schemaVer.tversion;
|
||||||
|
strcpy(dbName, pTaskInfo->schemaVer.dbname);
|
||||||
|
strcpy(tableName, pTaskInfo->schemaVer.tablename);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
* 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 <executorimpl.h>
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
@ -585,8 +586,7 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow
|
||||||
int32_t numOfRows = pCtx[k].input.numOfRows;
|
int32_t numOfRows = pCtx[k].input.numOfRows;
|
||||||
int32_t startOffset = pCtx[k].input.startRowIndex;
|
int32_t startOffset = pCtx[k].input.startRowIndex;
|
||||||
|
|
||||||
int32_t pos = (order == TSDB_ORDER_ASC) ? offset : offset - (forwardStep - 1);
|
pCtx[k].input.startRowIndex = offset;
|
||||||
pCtx[k].input.startRowIndex = pos;
|
|
||||||
pCtx[k].input.numOfRows = forwardStep;
|
pCtx[k].input.numOfRows = forwardStep;
|
||||||
|
|
||||||
if (tsCol != NULL) {
|
if (tsCol != NULL) {
|
||||||
|
@ -757,45 +757,6 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns);
|
|
||||||
// uint32_t flag = pOperator->pExpr[i].base.pParam[0].pCol->flag;
|
|
||||||
// if (TSDB_COL_IS_NORMAL_COL(flag) /*|| (pCtx[i].functionId == FUNCTION_BLKINFO) ||
|
|
||||||
// (TSDB_COL_IS_TAG(flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)*/) {
|
|
||||||
|
|
||||||
// SColumn* pCol = pOperator->pExpr[i].base.pParam[0].pCol;
|
|
||||||
// if (pCtx[i].columnIndex == -1) {
|
|
||||||
// for(int32_t j = 0; j < pBlock->info.numOfCols; ++j) {
|
|
||||||
// SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, j);
|
|
||||||
// if (pColData->info.colId == pCol->colId) {
|
|
||||||
// pCtx[i].columnIndex = j;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// uint32_t status = aAggs[pCtx[i].functionId].status;
|
|
||||||
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
|
|
||||||
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
|
||||||
// In case of the top/bottom query again the nest query result, which has no timestamp column
|
|
||||||
// don't set the ptsList attribute.
|
|
||||||
// if (tsInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
|
||||||
// pCtx[i].ptsList = (int64_t*) tsInfo->pData;
|
|
||||||
// } else {
|
|
||||||
// pCtx[i].ptsList = NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else if (TSDB_COL_IS_UD_COL(pCol->flag) && (pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)) {
|
|
||||||
// SColIndex* pColIndex = &pOperator->pExpr[i].base.colInfo;
|
|
||||||
// SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, pColIndex->colIndex);
|
|
||||||
//
|
|
||||||
// pCtx[i].pInput = p->pData;
|
|
||||||
// assert(p->info.colId == pColIndex->info.colId && pCtx[i].inputType == p->info.type);
|
|
||||||
// for(int32_t j = 0; j < pBlock->info.rows; ++j) {
|
|
||||||
// char* dst = p->pData + j * p->info.bytes;
|
|
||||||
// taosVariantDump(&pOperator->pExpr[i].base.param[1], dst, p->info.type, true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1831,12 +1792,6 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
|
||||||
|
|
||||||
pCtx[i].resultInfo = pEntry;
|
pCtx[i].resultInfo = pEntry;
|
||||||
pCtx[i].scanFlag = stage;
|
pCtx[i].scanFlag = stage;
|
||||||
|
|
||||||
// set the timestamp output buffer for top/bottom/diff query
|
|
||||||
// int32_t fid = pCtx[i].functionId;
|
|
||||||
// if (fid == FUNCTION_TOP || fid == FUNCTION_BOTTOM || fid == FUNCTION_DIFF || fid == FUNCTION_DERIVATIVE) {
|
|
||||||
// if (i > 0) pCtx[i].pTsOutput = pCtx[i-1].pOutput;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols);
|
initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols);
|
||||||
|
@ -2847,9 +2802,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData idata = {0};
|
SColumnInfoData idata = {0};
|
||||||
|
|
||||||
idata.info.type = pSchema[i].type;
|
idata.info.type = pSchema[i].type;
|
||||||
idata.info.bytes = pSchema[i].bytes;
|
idata.info.bytes = pSchema[i].bytes;
|
||||||
idata.info.colId = pSchema[i].colId;
|
idata.info.colId = pSchema[i].colId;
|
||||||
|
idata.hasNull = true;
|
||||||
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &idata);
|
taosArrayPush(pBlock->pDataBlock, &idata);
|
||||||
if (IS_VAR_DATA_TYPE(idata.info.type)) {
|
if (IS_VAR_DATA_TYPE(idata.info.type)) {
|
||||||
|
@ -4635,6 +4592,28 @@ static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
static SArray* createSortInfo(SNodeList* pNodeList);
|
static SArray* createSortInfo(SNodeList* pNodeList);
|
||||||
static SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
static SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
||||||
|
|
||||||
|
void extractTableSchemaVersion(SReadHandle *pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) {
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pHandle->meta, 0);
|
||||||
|
metaGetTableEntryByUid(&mr, uid);
|
||||||
|
|
||||||
|
pTaskInfo->schemaVer.tablename = strdup(mr.me.name);
|
||||||
|
|
||||||
|
if (mr.me.type == TSDB_SUPER_TABLE) {
|
||||||
|
pTaskInfo->schemaVer.sversion = mr.me.stbEntry.schema.sver;
|
||||||
|
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.sver;
|
||||||
|
} else if (mr.me.type == TSDB_CHILD_TABLE) {
|
||||||
|
tb_uid_t suid = mr.me.ctbEntry.suid;
|
||||||
|
metaGetTableEntryByUid(&mr, suid);
|
||||||
|
pTaskInfo->schemaVer.sversion = mr.me.stbEntry.schema.sver;
|
||||||
|
pTaskInfo->schemaVer.tversion = mr.me.stbEntry.schemaTag.sver;
|
||||||
|
} else {
|
||||||
|
pTaskInfo->schemaVer.sversion = mr.me.ntbEntry.schema.sver;
|
||||||
|
}
|
||||||
|
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
||||||
uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
||||||
int32_t type = nodeType(pPhyNode);
|
int32_t type = nodeType(pPhyNode);
|
||||||
|
@ -4648,6 +4627,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
SOperatorInfo* pOperator = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
|
@ -4685,7 +4665,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pDataReader, pHandle, pScanPhyNode->uid, pResBlock, pCols, tableIdList, pTaskInfo,
|
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pDataReader, pHandle, pScanPhyNode->uid, pResBlock, pCols, tableIdList, pTaskInfo,
|
||||||
pScanPhyNode->node.pConditions, pOperatorDumy);
|
pScanPhyNode->node.pConditions, pOperatorDumy);
|
||||||
|
@ -4700,7 +4680,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfOutputCols, COL_MATCH_FROM_COL_ID);
|
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfOutputCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
||||||
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
||||||
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
||||||
|
@ -4723,7 +4703,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* colList =
|
SArray* colList =
|
||||||
extractColMatchInfo(pScanPhyNode->pScanPseudoCols, pDescNode, &numOfOutputCols, COL_MATCH_FROM_COL_ID);
|
extractColMatchInfo(pScanPhyNode->pScanPseudoCols, pDescNode, &numOfOutputCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator =
|
||||||
createTagScanOperatorInfo(pHandle, pExprInfo, num, pResBlock, colList, pTableGroupInfo, pTaskInfo);
|
createTagScanOperatorInfo(pHandle, pExprInfo, num, pResBlock, colList, pTableGroupInfo, pTaskInfo);
|
||||||
|
@ -4805,7 +4785,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols);
|
SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols);
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
int32_t numOfOutputCols = 0;
|
||||||
SArray* pColList = extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
|
SArray* pColList = extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, pTaskInfo, COL_MATCH_FROM_SLOT_ID);
|
||||||
|
|
||||||
pOptr = createSortOperatorInfo(ops[0], pResBlock, info, pExprInfo, numOfCols, pColList, pTaskInfo);
|
pOptr = createSortOperatorInfo(ops[0], pResBlock, info, pExprInfo, numOfCols, pColList, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) {
|
||||||
|
@ -4996,7 +4976,7 @@ SArray* createSortInfo(SNodeList* pNodeList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
|
||||||
int32_t type) {
|
SExecTaskInfo* pTaskInfo, int32_t type) {
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
size_t numOfCols = LIST_LENGTH(pNodeList);
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo));
|
SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo));
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
|
@ -5004,10 +4984,16 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* tname = pTaskInfo->schemaVer.tablename;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
STargetNode* pNode = (STargetNode*)nodesListGetNode(pNodeList, i);
|
STargetNode* pNode = (STargetNode*)nodesListGetNode(pNodeList, i);
|
||||||
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
||||||
|
|
||||||
|
if (tname != NULL && (pTaskInfo->schemaVer.dbname == NULL) &&
|
||||||
|
strncmp(pColNode->tableName, tname, tListLen(pColNode->tableName)) == 0) {
|
||||||
|
pTaskInfo->schemaVer.dbname = strdup(pColNode->dbName);
|
||||||
|
}
|
||||||
|
|
||||||
SColMatchInfo c = {0};
|
SColMatchInfo c = {0};
|
||||||
c.output = true;
|
c.output = true;
|
||||||
c.colId = pColNode->colId;
|
c.colId = pColNode->colId;
|
||||||
|
@ -5201,6 +5187,8 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
||||||
// taosArrayDestroy(pTaskInfo->summary.queryProfEvents);
|
// taosArrayDestroy(pTaskInfo->summary.queryProfEvents);
|
||||||
// taosHashCleanup(pTaskInfo->summary.operatorProfResults);
|
// taosHashCleanup(pTaskInfo->summary.operatorProfResults);
|
||||||
|
|
||||||
|
taosMemoryFree(pTaskInfo->schemaVer.dbname);
|
||||||
|
taosMemoryFree(pTaskInfo->schemaVer.tablename);
|
||||||
taosMemoryFreeClear(pTaskInfo->sql);
|
taosMemoryFreeClear(pTaskInfo->sql);
|
||||||
taosMemoryFreeClear(pTaskInfo->id.str);
|
taosMemoryFreeClear(pTaskInfo->id.str);
|
||||||
taosMemoryFreeClear(pTaskInfo);
|
taosMemoryFreeClear(pTaskInfo);
|
||||||
|
|
|
@ -460,7 +460,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
SArray* pColList = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
SArray* pColList = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -898,11 +898,11 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* upRes = getUpdateDataBlock(pInfo, true); //TODO(liuyao) get invertible from plan
|
SSDataBlock* upRes = getUpdateDataBlock(pInfo, true); //TODO(liuyao) get invertible from plan
|
||||||
if (upRes) {
|
if (upRes) {
|
||||||
pInfo->pUpdateRes = upRes;
|
pInfo->pUpdateRes = upRes;
|
||||||
if (upRes->info.type = STREAM_REPROCESS) {
|
if (upRes->info.type == STREAM_REPROCESS) {
|
||||||
pInfo->updateResIndex = 0;
|
pInfo->updateResIndex = 0;
|
||||||
prepareDataScan(pInfo);
|
prepareDataScan(pInfo);
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_UPDATERES;
|
pInfo->scanMode = STREAM_SCAN_FROM_UPDATERES;
|
||||||
} else if (upRes->info.type = STREAM_INVERT) {
|
} else if (upRes->info.type == STREAM_INVERT) {
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_RES;
|
pInfo->scanMode = STREAM_SCAN_FROM_RES;
|
||||||
return upRes;
|
return upRes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1072,7 +1072,9 @@ static void doClearWindows(SAggSupporter* pSup, SOptrBasicInfo* pBinfo,
|
||||||
|
|
||||||
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
SIntervalAggOperatorInfo* pInfo = pOperator->info;
|
SIntervalAggOperatorInfo* pInfo = pOperator->info;
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
pInfo->order = TSDB_ORDER_ASC;
|
||||||
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1086,11 +1088,9 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// STimeWindow win = {0};
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
|
|
||||||
SArray* pUpdated = NULL;
|
SArray* pUpdated = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
|
@ -1103,16 +1103,18 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
// The timewindows that overlaps the timestamps of the input pBlock need to be recalculated and return to the
|
// The timewindows that overlaps the timestamps of the input pBlock need to be recalculated and return to the
|
||||||
// caller. Note that all the time window are not close till now.
|
// caller. Note that all the time window are not close till now.
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
|
||||||
if (pInfo->invertible) {
|
if (pInfo->invertible) {
|
||||||
setInverFunction(pInfo->binfo.pCtx, pOperator->numOfExprs, pBlock->info.type);
|
setInverFunction(pInfo->binfo.pCtx, pOperator->numOfExprs, pBlock->info.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval,
|
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval,
|
||||||
pInfo->primaryTsIndex, pOperator->numOfExprs, pBlock);
|
pInfo->primaryTsIndex, pOperator->numOfExprs, pBlock);
|
||||||
|
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pInfo->order = TSDB_ORDER_ASC;
|
|
||||||
pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,10 @@ int32_t fmGetFuncInfo(SFmGetFuncInfoParam* pParam, SFunctionNode* pFunc) {
|
||||||
return getUdfInfo(pParam, pFunc);
|
return getUdfInfo(pParam, pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fmIsBuiltinFunc(const char* pFunc) {
|
||||||
|
return NULL != taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc));
|
||||||
|
}
|
||||||
|
|
||||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||||
if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
@ -203,6 +207,9 @@ bool fmIsInvertible(int32_t funcId) {
|
||||||
case FUNCTION_TYPE_SUM:
|
case FUNCTION_TYPE_SUM:
|
||||||
case FUNCTION_TYPE_STDDEV:
|
case FUNCTION_TYPE_STDDEV:
|
||||||
case FUNCTION_TYPE_AVG:
|
case FUNCTION_TYPE_AVG:
|
||||||
|
case FUNCTION_TYPE_WSTARTTS:
|
||||||
|
case FUNCTION_TYPE_WENDTS:
|
||||||
|
case FUNCTION_TYPE_WDURATION:
|
||||||
res = true;
|
res = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -64,7 +64,11 @@ int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInte
|
||||||
*(double*)(newInterBuf->buf) = sumSquares;
|
*(double*)(newInterBuf->buf) = sumSquares;
|
||||||
newInterBuf->bufLen = sizeof(double);
|
newInterBuf->bufLen = sizeof(double);
|
||||||
}
|
}
|
||||||
newInterBuf->numOfResult = numOutput;
|
if (interBuf->numOfResult == 0 && numOutput == 0) {
|
||||||
|
newInterBuf->numOfResult = 0;
|
||||||
|
} else {
|
||||||
|
newInterBuf->numOfResult = 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -946,6 +946,23 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkLogicPlanSubplans = "Subplans";
|
||||||
|
|
||||||
|
static int32_t logicPlanToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SQueryLogicPlan* pNode = (const SQueryLogicPlan*)pObj;
|
||||||
|
return tjsonAddObject(pJson, jkLogicPlanSubplans, nodeToJson, nodesListGetNode(pNode->pTopSubplans, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToLogicPlan(const SJson* pJson, void* pObj) {
|
||||||
|
SQueryLogicPlan* pNode = (SQueryLogicPlan*)pObj;
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
int32_t code = jsonToNodeObject(pJson, jkLogicPlanSubplans, &pChild);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeStrictAppend(&pNode->pTopSubplans, pChild);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkJoinLogicPlanJoinType = "JoinType";
|
static const char* jkJoinLogicPlanJoinType = "JoinType";
|
||||||
static const char* jkJoinLogicPlanOnConditions = "OnConditions";
|
static const char* jkJoinLogicPlanOnConditions = "OnConditions";
|
||||||
|
|
||||||
|
@ -3029,7 +3046,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return logicSubplanToJson(pObj, pJson);
|
return logicSubplanToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN:
|
case QUERY_NODE_LOGIC_PLAN:
|
||||||
break;
|
return logicPlanToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
return physiTagScanNodeToJson(pObj, pJson);
|
return physiTagScanNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
|
@ -3126,6 +3143,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToLogicPartitionNode(pJson, pObj);
|
return jsonToLogicPartitionNode(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||||
return jsonToLogicSubplan(pJson, pObj);
|
return jsonToLogicSubplan(pJson, pObj);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN:
|
||||||
|
return jsonToLogicPlan(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
return jsonToPhysiTagScanNode(pJson, pObj);
|
return jsonToPhysiTagScanNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
|
|
|
@ -196,6 +196,15 @@ static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, bool demand) {
|
||||||
|
if (NULL == pCommentToken) {
|
||||||
|
pCxt->errCode = demand ? TSDB_CODE_PAR_SYNTAX_ERROR : TSDB_CODE_SUCCESS;
|
||||||
|
} else if (pCommentToken->n >= (TSDB_TB_COMMENT_LEN + 2)) {
|
||||||
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_COMMENT_TOO_LONG);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
||||||
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
||||||
CHECK_OUT_OF_MEM(target);
|
CHECK_OUT_OF_MEM(target);
|
||||||
|
@ -823,8 +832,10 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
|
||||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal) {
|
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TABLE_OPTION_COMMENT:
|
case TABLE_OPTION_COMMENT:
|
||||||
|
if (checkComment(pCxt, (SToken*)pVal, true)) {
|
||||||
copyStringFormStringToken((SToken*)pVal, ((STableOptions*)pOptions)->comment,
|
copyStringFormStringToken((SToken*)pVal, ((STableOptions*)pOptions)->comment,
|
||||||
sizeof(((STableOptions*)pOptions)->comment));
|
sizeof(((STableOptions*)pOptions)->comment));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TABLE_OPTION_DELAY:
|
case TABLE_OPTION_DELAY:
|
||||||
((STableOptions*)pOptions)->delay = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
((STableOptions*)pOptions)->delay = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
|
@ -848,7 +859,7 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) {
|
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) {
|
||||||
if (!checkColumnName(pCxt, pColName)) {
|
if (!checkColumnName(pCxt, pColName) || !checkComment(pCxt, pComment, false)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF);
|
||||||
|
|
|
@ -272,6 +272,10 @@ static bool isTimelineFunc(const SNode* pNode) {
|
||||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId));
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isScanPseudoColumnFunc(const SNode* pNode) {
|
||||||
|
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsScanPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
||||||
|
}
|
||||||
|
|
||||||
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
||||||
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct);
|
return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct);
|
||||||
}
|
}
|
||||||
|
@ -892,7 +896,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
if (pCxt->selectFuncNum > 1) {
|
if (pCxt->selectFuncNum > 1) {
|
||||||
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
||||||
} else {
|
} else {
|
||||||
|
@ -930,7 +934,7 @@ static EDealRes rewriteColsToSelectValFuncImpl(SNode** pNode, void* pContext) {
|
||||||
if (isAggFunc(*pNode)) {
|
if (isAggFunc(*pNode)) {
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode);
|
return rewriteColToSelectValFunc((STranslateContext*)pContext, NULL, pNode);
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -958,7 +962,7 @@ static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) {
|
||||||
pCxt->existAggFunc = true;
|
pCxt->existAggFunc = true;
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (isScanPseudoColumnFunc(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
pCxt->existCol = true;
|
pCxt->existCol = true;
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -3261,6 +3265,9 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionStmt* pStmt) {
|
static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionStmt* pStmt) {
|
||||||
|
if (fmIsBuiltinFunc(pStmt->funcName)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME);
|
||||||
|
}
|
||||||
SCreateFuncReq req = {0};
|
SCreateFuncReq req = {0};
|
||||||
strcpy(req.name, pStmt->funcName);
|
strcpy(req.name, pStmt->funcName);
|
||||||
req.igExists = pStmt->ignoreExists;
|
req.igExists = pStmt->ignoreExists;
|
||||||
|
|
|
@ -160,6 +160,10 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "Only binary/nchar column length could be modified";
|
return "Only binary/nchar column length could be modified";
|
||||||
case TSDB_CODE_PAR_INVALID_TBNAME:
|
case TSDB_CODE_PAR_INVALID_TBNAME:
|
||||||
return "Invalid tbname pseudo column";
|
return "Invalid tbname pseudo column";
|
||||||
|
case TSDB_CODE_PAR_INVALID_FUNCTION_NAME:
|
||||||
|
return "Invalid function name";
|
||||||
|
case TSDB_CODE_PAR_COMMENT_TOO_LONG:
|
||||||
|
return "Comment too long";
|
||||||
case TSDB_CODE_OUT_OF_MEMORY:
|
case TSDB_CODE_OUT_OF_MEMORY:
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
typedef struct SSplitContext {
|
typedef struct SSplitContext {
|
||||||
|
int32_t queryId;
|
||||||
int32_t groupId;
|
int32_t groupId;
|
||||||
bool split;
|
bool split;
|
||||||
} SSplitContext;
|
} SSplitContext;
|
||||||
|
@ -62,6 +63,7 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pSubplan->id.queryId = pCxt->queryId;
|
||||||
pSubplan->id.groupId = pCxt->groupId;
|
pSubplan->id.groupId = pCxt->groupId;
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan);
|
pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan);
|
||||||
|
@ -242,6 +244,7 @@ static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode)
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pSubplan->id.queryId = pCxt->queryId;
|
||||||
pSubplan->id.groupId = pCxt->groupId;
|
pSubplan->id.groupId = pCxt->groupId;
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
pSubplan->pNode = pNode;
|
pSubplan->pNode = pNode;
|
||||||
|
@ -406,7 +409,7 @@ static const SSplitRule splitRuleSet[] = {{.pName = "SuperTableScan", .splitFunc
|
||||||
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
||||||
|
|
||||||
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
||||||
SSplitContext cxt = {.groupId = pSubplan->id.groupId + 1, .split = false};
|
SSplitContext cxt = {.queryId = pSubplan->id.queryId, .groupId = pSubplan->id.groupId + 1, .split = false};
|
||||||
do {
|
do {
|
||||||
cxt.split = false;
|
cxt.split = false;
|
||||||
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
||||||
|
|
|
@ -32,6 +32,15 @@ TEST_F(PlanSetOpTest, unionAllSubquery) {
|
||||||
run("SELECT * FROM (SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1)");
|
run("SELECT * FROM (SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanSetOpTest, unionAllWithSubquery) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
// child table
|
||||||
|
run("SELECT ts FROM (SELECT ts FROM st1s1) UNION ALL SELECT ts FROM (SELECT ts FROM st1s2)");
|
||||||
|
// super table
|
||||||
|
run("SELECT ts FROM (SELECT ts FROM st1) UNION ALL SELECT ts FROM (SELECT ts FROM st1)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlanSetOpTest, union) {
|
TEST_F(PlanSetOpTest, union) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,7 @@ class PlannerTestBaseImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) {
|
void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) {
|
||||||
|
pCxt->queryId = 1;
|
||||||
if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) {
|
if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) {
|
||||||
pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery;
|
pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery;
|
||||||
pCxt->topicQuery = true;
|
pCxt->topicQuery = true;
|
||||||
|
|
|
@ -214,6 +214,8 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pPager->dbOrigSize = pPager->dbFileSize;
|
||||||
|
|
||||||
// release the page
|
// release the page
|
||||||
for (pPage = pPager->pDirty; pPage; pPage = pPager->pDirty) {
|
for (pPage = pPager->pDirty; pPage; pPage = pPager->pDirty) {
|
||||||
pPager->pDirty = pPage->pDirtyNext;
|
pPager->pDirty = pPage->pDirtyNext;
|
||||||
|
@ -230,7 +232,6 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
|
||||||
// remote the journal file
|
// remote the journal file
|
||||||
tdbOsClose(pPager->jfd);
|
tdbOsClose(pPager->jfd);
|
||||||
tdbOsRemove(pPager->jFileName);
|
tdbOsRemove(pPager->jFileName);
|
||||||
pPager->dbOrigSize = pPager->dbFileSize;
|
|
||||||
pPager->inTran = 0;
|
pPager->inTran = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#define ALLOW_FORBID_FUNC
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tdb.h"
|
#include "tdb.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef struct SPoolMem {
|
typedef struct SPoolMem {
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
@ -481,3 +484,117 @@ TEST(tdb_test, simple_upsert1) {
|
||||||
tdbTbClose(pDb);
|
tdbTbClose(pDb);
|
||||||
tdbClose(pEnv);
|
tdbClose(pEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(tdb_test, multi_thread_query) {
|
||||||
|
int ret;
|
||||||
|
TDB *pEnv;
|
||||||
|
TTB *pDb;
|
||||||
|
tdb_cmpr_fn_t compFunc;
|
||||||
|
int nData = 20000;
|
||||||
|
TXN txn;
|
||||||
|
|
||||||
|
taosRemoveDir("tdb");
|
||||||
|
|
||||||
|
// Open Env
|
||||||
|
ret = tdbOpen("tdb", 512, 1, &pEnv);
|
||||||
|
GTEST_ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
|
// Create a database
|
||||||
|
compFunc = tKeyCmpr;
|
||||||
|
ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb);
|
||||||
|
GTEST_ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
|
char key[64];
|
||||||
|
char val[64];
|
||||||
|
int64_t poolLimit = 4096; // 1M pool limit
|
||||||
|
int64_t txnid = 0;
|
||||||
|
SPoolMem *pPool;
|
||||||
|
|
||||||
|
// open the pool
|
||||||
|
pPool = openPool();
|
||||||
|
|
||||||
|
// start a transaction
|
||||||
|
txnid++;
|
||||||
|
txn.flags = TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED;
|
||||||
|
txn.txnId = -1;
|
||||||
|
txn.xMalloc = poolMalloc;
|
||||||
|
txn.xFree = poolFree;
|
||||||
|
txn.xArg = pPool;
|
||||||
|
// tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, );
|
||||||
|
tdbBegin(pEnv, &txn);
|
||||||
|
|
||||||
|
for (int iData = 1; iData <= nData; iData++) {
|
||||||
|
sprintf(key, "key%d", iData);
|
||||||
|
sprintf(val, "value%d", iData);
|
||||||
|
ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn);
|
||||||
|
GTEST_ASSERT_EQ(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto f = [](TTB *pDb, int nData) {
|
||||||
|
TBC *pDBC;
|
||||||
|
void *pKey = NULL;
|
||||||
|
void *pVal = NULL;
|
||||||
|
int vLen, kLen;
|
||||||
|
int count = 0;
|
||||||
|
int ret;
|
||||||
|
TXN txn;
|
||||||
|
|
||||||
|
SPoolMem *pPool = openPool();
|
||||||
|
txn.flags = 0;
|
||||||
|
txn.txnId = 0;
|
||||||
|
txn.xMalloc = poolMalloc;
|
||||||
|
txn.xFree = poolFree;
|
||||||
|
txn.xArg = pPool;
|
||||||
|
|
||||||
|
ret = tdbTbcOpen(pDb, &pDBC, &txn);
|
||||||
|
GTEST_ASSERT_EQ(ret, 0);
|
||||||
|
|
||||||
|
tdbTbcMoveToFirst(pDBC);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
ret = tdbTbcNext(pDBC, &pKey, &kLen, &pVal, &vLen);
|
||||||
|
if (ret < 0) break;
|
||||||
|
|
||||||
|
// std::cout.write((char *)pKey, kLen) /* << " " << kLen */ << " ";
|
||||||
|
// std::cout.write((char *)pVal, vLen) /* << " " << vLen */;
|
||||||
|
// std::cout << std::endl;
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ASSERT_EQ(count, nData);
|
||||||
|
|
||||||
|
tdbTbcClose(pDBC);
|
||||||
|
|
||||||
|
tdbFree(pKey);
|
||||||
|
tdbFree(pVal);
|
||||||
|
};
|
||||||
|
|
||||||
|
// tdbCommit(pEnv, &txn);
|
||||||
|
|
||||||
|
// multi-thread query
|
||||||
|
int nThreads = 20;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
for (int i = 0; i < nThreads; i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
threads.push_back(std::thread(tdbCommit, pEnv, &txn));
|
||||||
|
} else {
|
||||||
|
threads.push_back(std::thread(f, pDb, nData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &th : threads) {
|
||||||
|
th.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit the transaction
|
||||||
|
tdbCommit(pEnv, &txn);
|
||||||
|
tdbTxnClose(&txn);
|
||||||
|
|
||||||
|
// Close a database
|
||||||
|
tdbTbClose(pDb);
|
||||||
|
|
||||||
|
// Close Env
|
||||||
|
ret = tdbClose(pEnv);
|
||||||
|
GTEST_ASSERT_EQ(ret, 0);
|
||||||
|
}
|
|
@ -160,7 +160,14 @@ bool tfsIsSameFile(const STfsFile *pFile1, const STfsFile *pFile2) {
|
||||||
if (pFile1 == NULL || pFile2 == NULL || pFile1->pTfs != pFile2->pTfs) return false;
|
if (pFile1 == NULL || pFile2 == NULL || pFile1->pTfs != pFile2->pTfs) return false;
|
||||||
if (pFile1->did.level != pFile2->did.level) return false;
|
if (pFile1->did.level != pFile2->did.level) return false;
|
||||||
if (pFile1->did.id != pFile2->did.id) return false;
|
if (pFile1->did.id != pFile2->did.id) return false;
|
||||||
if (strncmp(pFile1->rname, pFile2->rname, TSDB_FILENAME_LEN) != 0) return false;
|
char nameBuf1[TMPNAME_LEN], nameBuf2[TMPNAME_LEN];
|
||||||
|
strncpy(nameBuf1, pFile1->rname, TMPNAME_LEN);
|
||||||
|
strncpy(nameBuf2, pFile2->rname, TMPNAME_LEN);
|
||||||
|
nameBuf1[TMPNAME_LEN - 1] = 0;
|
||||||
|
nameBuf2[TMPNAME_LEN - 1] = 0;
|
||||||
|
taosRealPath(nameBuf1, NULL, TMPNAME_LEN);
|
||||||
|
taosRealPath(nameBuf2, NULL, TMPNAME_LEN);
|
||||||
|
if (strncmp(nameBuf1, nameBuf2, TMPNAME_LEN) != 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ if $data[0][4] != ready then
|
||||||
goto check_dnode_ready
|
goto check_dnode_ready
|
||||||
endi
|
endi
|
||||||
|
|
||||||
#sql connect
|
sql connect
|
||||||
sql create dnode $hostname port 7200
|
sql create dnode $hostname port 7200
|
||||||
sql create dnode $hostname port 7300
|
sql create dnode $hostname port 7300
|
||||||
sql create dnode $hostname port 7400
|
sql create dnode $hostname port 7400
|
||||||
|
@ -83,7 +83,7 @@ print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $dat
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data(db)[19] != ready then
|
if $data(db)[19] != nostrict then
|
||||||
goto check_db_ready
|
goto check_db_ready
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -93,49 +93,48 @@ $loop_cnt = 0
|
||||||
check_vg_ready:
|
check_vg_ready:
|
||||||
$loop_cnt = $loop_cnt + 1
|
$loop_cnt = $loop_cnt + 1
|
||||||
sleep 200
|
sleep 200
|
||||||
if $loop_cnt == 10 then
|
if $loop_cnt == 40 then
|
||||||
print ====> vgroups not ready!
|
print ====> vgroups not ready!
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
sql show vgroups
|
sql show vgroups
|
||||||
print ===> rows: $rows
|
print ===> rows: $rows
|
||||||
print $data(2)[0] $data(2)[1] $data(2)[2] $data(2)[3] $data(2)[4] $data(2)[5] $data(2)[6] $data(2)[7] $data(2)[8] $data(2)[9] $data(2)[10] $data(2)[11] $data(2)[12] $data(2)[13]
|
|
||||||
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[10][6] $data[0][11] $data[0][12] $data[0][13]
|
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[10][6] $data[0][11] $data[0][12] $data[0][13]
|
||||||
if $rows != $vgroups then
|
if $rows != $vgroups then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] == LEADER then
|
if $data[0][4] == LEADER then
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader locate on dnode $data[0][3]
|
print ---- vgroup $data[0][0] leader locate on dnode $data[0][3]
|
||||||
goto vg_ready
|
goto vg_ready
|
||||||
endi
|
elif $data[0][6] == LEADER then
|
||||||
if $data[0][6] == LEADER then
|
if $data[0][4] != FOLLOWER then
|
||||||
if $data[0][4] != FLLOWER then
|
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader locate on dnode $data[0][5]
|
print ---- vgroup $data[0][0] leader locate on dnode $data[0][5]
|
||||||
goto vg_ready
|
goto vg_ready
|
||||||
endi
|
elif $data[0][8] == LEADER then
|
||||||
if $data[0][8] == LEADER then
|
if $data[0][4] != FOLLOWER then
|
||||||
if $data[0][4] != FLLOWER then
|
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader locate on dnode $data[0][7]
|
print ---- vgroup $data[0][0] leader locate on dnode $data[0][7]
|
||||||
goto vg_ready
|
goto vg_ready
|
||||||
|
else
|
||||||
|
goto check_vg_ready
|
||||||
endi
|
endi
|
||||||
vg_ready:
|
|
||||||
|
|
||||||
|
vg_ready:
|
||||||
print ====> create stable/child table
|
print ====> create stable/child table
|
||||||
sql create table stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
sql create table stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ print ====> create a normal table for interaction between main and back threads
|
||||||
sql create table interaction (ts timestamp, flag binary(10), childrows int, stbrows int)
|
sql create table interaction (ts timestamp, flag binary(10), childrows int, stbrows int)
|
||||||
|
|
||||||
print ====> start to run_back to insert data
|
print ====> start to run_back to insert data
|
||||||
run_back tsim/tmq/insertDataByRunBack.sim
|
run_back tsim/sync/insertDataByRunBack.sim
|
||||||
|
|
||||||
|
|
||||||
print ====> waiting insert thread starting insert data
|
print ====> waiting insert thread starting insert data
|
||||||
|
@ -239,34 +238,34 @@ if $rows != $vgroups then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] == LEADER then
|
if $data[0][4] == LEADER then
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader switch to dnode $data[0][3]
|
print ---- vgroup $data[0][0] leader switch to dnode $data[0][3]
|
||||||
goto vg_ready_2
|
goto vg_ready_2
|
||||||
endi
|
elif $data[0][6] == LEADER then
|
||||||
if $data[0][6] == LEADER then
|
if $data[0][4] != FOLLOWER then
|
||||||
if $data[0][4] != FLLOWER then
|
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader switch to dnode $data[0][5]
|
print ---- vgroup $data[0][0] leader switch to dnode $data[0][5]
|
||||||
goto vg_ready_2
|
goto vg_ready_2
|
||||||
endi
|
elif $data[0][8] == LEADER then
|
||||||
if $data[0][8] == LEADER then
|
if $data[0][4] != FOLLOWER then
|
||||||
if $data[0][4] != FLLOWER then
|
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready_2
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
print ---- vgroup $data[0][0] leader switch to dnode $data[0][7]
|
print ---- vgroup $data[0][0] leader switch to dnode $data[0][7]
|
||||||
goto vg_ready_2
|
goto vg_ready_2
|
||||||
|
else
|
||||||
|
goto check_vg_ready_2
|
||||||
endi
|
endi
|
||||||
vg_ready_2:
|
vg_ready_2:
|
||||||
|
|
||||||
|
@ -344,28 +343,28 @@ if $rows != $vgroups then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] == LEADER then
|
if $data[0][4] == LEADER then
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
goto vg_ready_1
|
goto vg_ready_1
|
||||||
endi
|
endi
|
||||||
if $data[0][6] == LEADER then
|
if $data[0][6] == LEADER then
|
||||||
if $data[0][4] != FLLOWER then
|
if $data[0][4] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
if $data[0][8] != FLLOWER then
|
if $data[0][8] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
goto vg_ready_1
|
goto vg_ready_1
|
||||||
endi
|
endi
|
||||||
if $data[0][8] == LEADER then
|
if $data[0][8] == LEADER then
|
||||||
if $data[0][4] != FLLOWER then
|
if $data[0][4] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
if $data[0][6] != FLLOWER then
|
if $data[0][6] != FOLLOWER then
|
||||||
goto check_vg_ready_1
|
goto check_vg_ready_1
|
||||||
endi
|
endi
|
||||||
goto vg_ready_1
|
goto vg_ready_1
|
||||||
|
|
|
@ -137,7 +137,11 @@ endi
|
||||||
|
|
||||||
sql insert into t1 values(1648791223001,12,14,13,11.1);
|
sql insert into t1 values(1648791223001,12,14,13,11.1);
|
||||||
sleep 500
|
sleep 500
|
||||||
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt;
|
sql select * from streamt;
|
||||||
|
|
||||||
|
print count(*) , count(d) , sum(a) , max(b) , min(c)
|
||||||
|
print 0: $data00 , $data01 , $data02 , $data03 , $data04 , $data05
|
||||||
|
print 1: $data10 , $data11 , $data12 , $data13 , $data14 , $data15
|
||||||
|
|
||||||
if $rows != 4 then
|
if $rows != 4 then
|
||||||
print ======$rows
|
print ======$rows
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading as thd
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
from numpy.lib.function_base import insert
|
from numpy.lib.function_base import insert
|
||||||
import taos
|
import taos
|
||||||
|
@ -30,7 +30,10 @@ class TDTestCase:
|
||||||
#
|
#
|
||||||
# --------------- main frame -------------------
|
# --------------- main frame -------------------
|
||||||
#
|
#
|
||||||
|
clientCfgDict = {'queryproxy': '1'}
|
||||||
|
clientCfgDict["queryproxy"] = '2'
|
||||||
|
updatecfgDict = {'clientCfg': {}}
|
||||||
|
updatecfgDict["clientCfg"] = clientCfgDict
|
||||||
def caseDescription(self):
|
def caseDescription(self):
|
||||||
'''
|
'''
|
||||||
limit and offset keyword function test cases;
|
limit and offset keyword function test cases;
|
||||||
|
@ -63,53 +66,13 @@ class TDTestCase:
|
||||||
# self.create_tables();
|
# self.create_tables();
|
||||||
self.ts = 1500000000000
|
self.ts = 1500000000000
|
||||||
|
|
||||||
|
|
||||||
# run case
|
|
||||||
def run(self):
|
|
||||||
|
|
||||||
# # test base case
|
|
||||||
# self.test_case1()
|
|
||||||
# tdLog.debug(" LIMIT test_case1 ............ [OK]")
|
|
||||||
|
|
||||||
# test case
|
|
||||||
# self.test_case2()
|
|
||||||
# tdLog.debug(" LIMIT test_case2 ............ [OK]")
|
|
||||||
|
|
||||||
# test case
|
|
||||||
self.test_case3()
|
|
||||||
tdLog.debug(" LIMIT test_case3 ............ [OK]")
|
|
||||||
|
|
||||||
|
|
||||||
# stop
|
# stop
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success("%s successfully executed" % __file__)
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
# --------------- case -------------------
|
|
||||||
|
|
||||||
# create tables
|
# --------------- case -------------------
|
||||||
def create_tables(self,dbname,stbname,count):
|
|
||||||
tdSql.execute("use %s" %dbname)
|
|
||||||
tdSql.execute("create stable %s(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%stbname)
|
|
||||||
pre_create = "create table"
|
|
||||||
sql = pre_create
|
|
||||||
tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
|
||||||
# print(time.time())
|
|
||||||
exeStartTime=time.time()
|
|
||||||
for i in range(count):
|
|
||||||
sql += " %s_%d using %s tags(%d)"%(stbname,i,stbname,i+1)
|
|
||||||
if i >0 and i%3000 == 0:
|
|
||||||
tdSql.execute(sql)
|
|
||||||
sql = pre_create
|
|
||||||
# print(time.time())
|
|
||||||
# end sql
|
|
||||||
if sql != pre_create:
|
|
||||||
tdSql.execute(sql)
|
|
||||||
exeEndTime=time.time()
|
|
||||||
spendTime=exeEndTime-exeStartTime
|
|
||||||
speedCreate=count/spendTime
|
|
||||||
tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
|
|
||||||
return
|
|
||||||
|
|
||||||
def newcur(self,host,cfg):
|
def newcur(self,host,cfg):
|
||||||
user = "root"
|
user = "root"
|
||||||
|
@ -120,28 +83,23 @@ class TDTestCase:
|
||||||
print(cur)
|
print(cur)
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
def new_create_tables(self,dbname,vgroups,stbname,tcountStart,tcountStop):
|
# create tables
|
||||||
host = "localhost"
|
def create_tables(self,host,dbname,stbname,count):
|
||||||
buildPath = self.getBuildPath()
|
buildPath = self.getBuildPath()
|
||||||
config = buildPath+ "../sim/dnode1/cfg/"
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
|
|
||||||
tsql=self.newcur(host,config)
|
tsql=self.newcur(host,config)
|
||||||
tsql.execute("drop database if exists %s"%dbname)
|
|
||||||
tsql.execute("create database %s vgroups %d"%(dbname,vgroups))
|
|
||||||
tsql.execute("use %s" %dbname)
|
tsql.execute("use %s" %dbname)
|
||||||
tsql.execute("create stable %s(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%stbname)
|
|
||||||
|
|
||||||
pre_create = "create table"
|
pre_create = "create table"
|
||||||
sql = pre_create
|
sql = pre_create
|
||||||
tcountStop=int(tcountStop)
|
count=int(count)
|
||||||
tcountStart=int(tcountStart)
|
|
||||||
count=tcountStop-tcountStart
|
|
||||||
|
|
||||||
tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
||||||
# print(time.time())
|
# print(time.time())
|
||||||
exeStartTime=time.time()
|
exeStartTime=time.time()
|
||||||
# print(type(tcountStop),type(tcountStart))
|
# print(type(tcountStop),type(tcountStart))
|
||||||
for i in range(tcountStart,tcountStop):
|
for i in range(0,count):
|
||||||
sql += " %s_%d using %s tags(%d)"%(stbname,i,stbname,i+1)
|
sql += " %s_%d using %s tags(%d)"%(stbname,i,stbname,i+1)
|
||||||
if i >0 and i%20000 == 0:
|
if i >0 and i%20000 == 0:
|
||||||
# print(sql)
|
# print(sql)
|
||||||
|
@ -158,11 +116,78 @@ class TDTestCase:
|
||||||
# tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
|
# tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,count):
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
|
|
||||||
|
tsql=self.newcur(host,config)
|
||||||
|
tdLog.debug("create database %s"%dbname)
|
||||||
|
tsql.execute("drop database if exists %s"%dbname)
|
||||||
|
tsql.execute("create database %s vgroups %d"%(dbname,vgroups))
|
||||||
|
tsql.execute("use %s" %dbname)
|
||||||
|
count=int(count)
|
||||||
|
threads = []
|
||||||
|
for i in range(threadNumbers):
|
||||||
|
tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
|
||||||
|
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
|
||||||
|
start_time = time.time()
|
||||||
|
for tr in threads:
|
||||||
|
tr.start()
|
||||||
|
for tr in threads:
|
||||||
|
tr.join()
|
||||||
|
end_time = time.time()
|
||||||
|
spendTime=end_time-start_time
|
||||||
|
speedCreate=count/spendTime
|
||||||
|
tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate))
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
# def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop):
|
||||||
|
|
||||||
|
|
||||||
# insert data
|
# insert data
|
||||||
def insert_data(self, dbname, stbname, ts_start, tcountStart,tcountStop,rowCount):
|
def insert_data(self, host, dbname, stbname, ts_start,rowCount):
|
||||||
tdSql.execute("use %s" %dbname)
|
buildPath = self.getBuildPath()
|
||||||
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
|
|
||||||
|
tsql=self.newcur(host,config)
|
||||||
|
tdLog.debug("ready to inser data")
|
||||||
|
|
||||||
|
tsql.execute("use %s" %dbname)
|
||||||
|
pre_insert = "insert into "
|
||||||
|
sql = pre_insert
|
||||||
|
tcount=int(tcount)
|
||||||
|
allRows=tcount*rowCount
|
||||||
|
tdLog.debug("doing insert data into stable-index:%s rows:%d ..."%(stbname, allRows))
|
||||||
|
exeStartTime=time.time()
|
||||||
|
for i in range(0,tcount):
|
||||||
|
sql += " %s_%d values "%(stbname,i)
|
||||||
|
for j in range(rowCount):
|
||||||
|
sql += "(%d, %d, 'taos_%d') "%(ts_start + j*1000, j, j)
|
||||||
|
if j >0 and j%5000 == 0:
|
||||||
|
# print(sql)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
sql = "insert into %s_%d values " %(stbname,i)
|
||||||
|
# end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
# print(sql)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
exeEndTime=time.time()
|
||||||
|
spendTime=exeEndTime-exeStartTime
|
||||||
|
speedInsert=allRows/spendTime
|
||||||
|
# tdLog.debug("spent %.2fs to INSERT %d rows , insert rate is %.2f rows/s... [OK]"% (spendTime,allRows,speedInsert))
|
||||||
|
|
||||||
|
tdLog.debug("INSERT TABLE DATA ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, ts_start, tcountStart,tcountStop,rowCount):
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
|
|
||||||
|
tsql=self.newcur(host,config)
|
||||||
|
tdLog.debug("ready to inser data")
|
||||||
|
|
||||||
|
tsql.execute("use %s" %dbname)
|
||||||
pre_insert = "insert into "
|
pre_insert = "insert into "
|
||||||
sql = pre_insert
|
sql = pre_insert
|
||||||
tcount=tcountStop-tcountStart
|
tcount=tcountStop-tcountStart
|
||||||
|
@ -187,8 +212,30 @@ class TDTestCase:
|
||||||
# tdLog.debug("spent %.2fs to INSERT %d rows , insert rate is %.2f rows/s... [OK]"% (spendTime,allRows,speedInsert))
|
# tdLog.debug("spent %.2fs to INSERT %d rows , insert rate is %.2f rows/s... [OK]"% (spendTime,allRows,speedInsert))
|
||||||
|
|
||||||
tdLog.debug("INSERT TABLE DATA ............ [OK]")
|
tdLog.debug("INSERT TABLE DATA ............ [OK]")
|
||||||
|
|
||||||
|
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
|
|
||||||
|
tsql=self.newcur(host,config)
|
||||||
|
tsql.execute("use %s" %dbname)
|
||||||
|
count=int(count)
|
||||||
|
threads = []
|
||||||
|
for i in range(threadNumbers):
|
||||||
|
tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
|
||||||
|
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
|
||||||
|
start_time = time.time()
|
||||||
|
for tr in threads:
|
||||||
|
tr.start()
|
||||||
|
for tr in threads:
|
||||||
|
tr.join()
|
||||||
|
end_time = time.time()
|
||||||
|
spendTime=end_time-start_time
|
||||||
|
speedCreate=count/spendTime
|
||||||
|
tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def taosBench(self,jsonFile):
|
def taosBench(self,jsonFile):
|
||||||
buildPath = self.getBuildPath()
|
buildPath = self.getBuildPath()
|
||||||
if (buildPath == ""):
|
if (buildPath == ""):
|
||||||
|
@ -199,16 +246,10 @@ class TDTestCase:
|
||||||
os.system("%s -f %s -y " %(taosBenchbin,jsonFile))
|
os.system("%s -f %s -y " %(taosBenchbin,jsonFile))
|
||||||
|
|
||||||
return
|
return
|
||||||
def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,threadNumbers,count):
|
def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count):
|
||||||
|
|
||||||
# count=50000
|
# count=50000
|
||||||
buildPath = self.getBuildPath()
|
buildPath = self.getBuildPath()
|
||||||
if (buildPath == ""):
|
|
||||||
tdLog.exit("taosd not found!")
|
|
||||||
else:
|
|
||||||
tdLog.info("taosd found in %s" % buildPath)
|
|
||||||
taosBenchbin = buildPath+ "/build/bin/taosBenchmark"
|
|
||||||
buildPath = self.getBuildPath()
|
|
||||||
config = buildPath+ "../sim/dnode1/cfg/"
|
config = buildPath+ "../sim/dnode1/cfg/"
|
||||||
tsql=self.newcur(host,config)
|
tsql=self.newcur(host,config)
|
||||||
|
|
||||||
|
@ -222,8 +263,7 @@ class TDTestCase:
|
||||||
tsql.execute("use %s" %dbname)
|
tsql.execute("use %s" %dbname)
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
# threadNumbers=2
|
for i in range(processNumbers):
|
||||||
for i in range(threadNumbers):
|
|
||||||
jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i)
|
jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i)
|
||||||
os.system("cp -f 1-insert/manyVgroups.json %s"%(jsonfile))
|
os.system("cp -f 1-insert/manyVgroups.json %s"%(jsonfile))
|
||||||
os.system("sed -i 's/\"name\": \"db\",/\"name\": \"%s\",/g' %s"%(dbname,jsonfile))
|
os.system("sed -i 's/\"name\": \"db\",/\"name\": \"%s\",/g' %s"%(dbname,jsonfile))
|
||||||
|
@ -246,68 +286,15 @@ class TDTestCase:
|
||||||
return
|
return
|
||||||
# test case1 base
|
# test case1 base
|
||||||
def test_case1(self):
|
def test_case1(self):
|
||||||
tdLog.debug("-----create database and tables test------- ")
|
tdLog.debug("-----create database and muti-thread create tables test------- ")
|
||||||
tdSql.execute("drop database if exists db1")
|
#host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop
|
||||||
tdSql.execute("drop database if exists db4")
|
self.mutiThread_create_tables(host="localhost",dbname="db2",stbname="stb2", vgroups=1, threadNumbers=5, count=10000)
|
||||||
tdSql.execute("drop database if exists db6")
|
|
||||||
tdSql.execute("drop database if exists db8")
|
|
||||||
tdSql.execute("drop database if exists db12")
|
|
||||||
tdSql.execute("drop database if exists db16")
|
|
||||||
|
|
||||||
#create database and tables;
|
|
||||||
|
|
||||||
# tdSql.execute("create database db11 vgroups 1")
|
|
||||||
# # self.create_tables("db1", "stb1", 30*10000)
|
|
||||||
# tdSql.execute("use db1")
|
|
||||||
# tdSql.execute("create stable stb1(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)")
|
|
||||||
|
|
||||||
# tdSql.execute("create database db12 vgroups 1")
|
|
||||||
# # self.create_tables("db1", "stb1", 30*10000)
|
|
||||||
# tdSql.execute("use db1")
|
|
||||||
|
|
||||||
# t1 = threading.Thread(target=self.new_create_tables("db1", "stb1", 15*10000), args=(1,))
|
|
||||||
# t2 = threading.Thread(target=self.new_create_tables("db1", "stb1", 15*10000), args=(2,))
|
|
||||||
# t1 = mp.Process(target=self.new_create_tables, args=("db1", "stb1", 0,count/2,))
|
|
||||||
# t2 = mp.Process(target=self.new_create_tables, args=("db1", "stb1", count/2,count,))
|
|
||||||
|
|
||||||
count=50000
|
|
||||||
vgroups=1
|
|
||||||
threads = []
|
|
||||||
threadNumbers=2
|
|
||||||
for i in range(threadNumbers):
|
|
||||||
threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,)))
|
|
||||||
start_time = time.time()
|
|
||||||
for tr in threads:
|
|
||||||
tr.start()
|
|
||||||
for tr in threads:
|
|
||||||
tr.join()
|
|
||||||
end_time = time.time()
|
|
||||||
spendTime=end_time-start_time
|
|
||||||
speedCreate=count/spendTime
|
|
||||||
tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
|
|
||||||
# self.new_create_tables("db1", "stb1", 15*10000)
|
|
||||||
# self.new_create_tables("db1", "stb1", 15*10000)
|
|
||||||
|
|
||||||
# tdSql.execute("create database db4 vgroups 4")
|
|
||||||
# self.create_tables("db4", "stb4", 30*10000)
|
|
||||||
|
|
||||||
# tdSql.execute("create database db6 vgroups 6")
|
|
||||||
# self.create_tables("db6", "stb6", 30*10000)
|
|
||||||
|
|
||||||
# tdSql.execute("create database db8 vgroups 8")
|
|
||||||
# self.create_tables("db8", "stb8", 30*10000)
|
|
||||||
|
|
||||||
# tdSql.execute("create database db12 vgroups 12")
|
|
||||||
# self.create_tables("db12", "stb12", 30*10000)
|
|
||||||
|
|
||||||
# tdSql.execute("create database db16 vgroups 16")
|
|
||||||
# self.create_tables("db16", "stb16", 30*10000)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# test case2 base:insert data
|
# test case2 base:insert data
|
||||||
def test_case2(self):
|
def test_case2(self):
|
||||||
|
|
||||||
tdLog.debug("-----insert data test------- ")
|
tdLog.debug("-----muti-thread insert data test------- ")
|
||||||
# drop database
|
# drop database
|
||||||
tdSql.execute("drop database if exists db1")
|
tdSql.execute("drop database if exists db1")
|
||||||
tdSql.execute("drop database if exists db4")
|
tdSql.execute("drop database if exists db4")
|
||||||
|
@ -321,28 +308,6 @@ class TDTestCase:
|
||||||
tdSql.execute("create database db1 vgroups 1")
|
tdSql.execute("create database db1 vgroups 1")
|
||||||
self.create_tables("db1", "stb1", 1*100)
|
self.create_tables("db1", "stb1", 1*100)
|
||||||
self.insert_data("db1", "stb1", self.ts, 1*50,1*10000)
|
self.insert_data("db1", "stb1", self.ts, 1*50,1*10000)
|
||||||
|
|
||||||
|
|
||||||
tdSql.execute("create database db4 vgroups 4")
|
|
||||||
self.create_tables("db4", "stb4", 1*100)
|
|
||||||
self.insert_data("db4", "stb4", self.ts, 1*100,1*10000)
|
|
||||||
|
|
||||||
tdSql.execute("create database db6 vgroups 6")
|
|
||||||
self.create_tables("db6", "stb6", 1*100)
|
|
||||||
self.insert_data("db6", "stb6", self.ts, 1*100,1*10000)
|
|
||||||
|
|
||||||
tdSql.execute("create database db8 vgroups 8")
|
|
||||||
self.create_tables("db8", "stb8", 1*100)
|
|
||||||
self.insert_data("db8", "stb8", self.ts, 1*100,1*10000)
|
|
||||||
|
|
||||||
tdSql.execute("create database db12 vgroups 12")
|
|
||||||
self.create_tables("db12", "stb12", 1*100)
|
|
||||||
self.insert_data("db12", "stb12", self.ts, 1*100,1*10000)
|
|
||||||
|
|
||||||
tdSql.execute("create database db16 vgroups 16")
|
|
||||||
self.create_tables("db16", "stb16", 1*100)
|
|
||||||
self.insert_data("db16", "stb16", self.ts, 1*100,1*10000)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def test_case3(self):
|
def test_case3(self):
|
||||||
|
@ -356,6 +321,70 @@ class TDTestCase:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def test_case4(self):
|
||||||
|
self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10)
|
||||||
|
tdSql.execute("use db1;")
|
||||||
|
tdSql.query("show dnodes;")
|
||||||
|
dnodeId=tdSql.getData(0,0)
|
||||||
|
print(dnodeId)
|
||||||
|
tdSql.execute("create qnode on dnode %s"%dnodeId)
|
||||||
|
tdSql.query("select max(c1) from stb10;")
|
||||||
|
maxQnode=tdSql.getData(0,0)
|
||||||
|
tdSql.query("select min(c1) from stb11;")
|
||||||
|
minQnode=tdSql.getData(0,0)
|
||||||
|
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
|
||||||
|
unionQnode=tdSql.queryResult
|
||||||
|
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
|
||||||
|
unionallQnode=tdSql.queryResult
|
||||||
|
|
||||||
|
# tdSql.query("show qnodes;")
|
||||||
|
# qnodeId=tdSql.getData(0,0)
|
||||||
|
tdSql.execute("drop qnode on dnode %s"%dnodeId)
|
||||||
|
tdSql.execute("reset query cache")
|
||||||
|
tdSql.query("select max(c1) from stb10;")
|
||||||
|
tdSql.checkData(0, 0, "%s"%maxQnode)
|
||||||
|
tdSql.query("select min(c1) from stb11;")
|
||||||
|
tdSql.checkData(0, 0, "%s"%minQnode)
|
||||||
|
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;")
|
||||||
|
unionVnode=tdSql.queryResult
|
||||||
|
assert unionQnode == unionVnode
|
||||||
|
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
|
||||||
|
unionallVnode=tdSql.queryResult
|
||||||
|
assert unionallQnode == unionallVnode
|
||||||
|
|
||||||
|
|
||||||
|
# tdSql.execute("create qnode on dnode %s"%dnodeId)
|
||||||
|
|
||||||
|
|
||||||
|
# self.taosBenchCreate("test209","no","db2", "stb2", 1, 8, 1*10000)
|
||||||
|
|
||||||
|
# self.taosBenchCreate("chenhaoran02","no","db1", "stb1", 1, 8, 1*10000)
|
||||||
|
|
||||||
|
# self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000)
|
||||||
|
# self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000)
|
||||||
|
|
||||||
|
# run case
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
# # test base case
|
||||||
|
# self.test_case1()
|
||||||
|
# tdLog.debug(" LIMIT test_case1 ............ [OK]")
|
||||||
|
|
||||||
|
# test case
|
||||||
|
# self.test_case2()
|
||||||
|
# tdLog.debug(" LIMIT test_case2 ............ [OK]")
|
||||||
|
|
||||||
|
# test case
|
||||||
|
self.test_case3()
|
||||||
|
tdLog.debug(" LIMIT test_case3 ............ [OK]")
|
||||||
|
|
||||||
|
|
||||||
|
# # test qnode
|
||||||
|
# self.test_case4()
|
||||||
|
# tdLog.debug(" LIMIT test_case3 ............ [OK]")
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
#
|
#
|
||||||
# add case with filename
|
# add case with filename
|
||||||
#
|
#
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"confirm_parameter_prompt": "no",
|
"confirm_parameter_prompt": "no",
|
||||||
"insert_interval": 0,
|
"insert_interval": 0,
|
||||||
"interlace_rows": 100000,
|
"interlace_rows": 100000,
|
||||||
"num_of_records_per_req": 100000,
|
"num_of_records_per_req": 100,
|
||||||
"databases": [
|
"databases": [
|
||||||
{
|
{
|
||||||
"dbinfo": {
|
"dbinfo": {
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TDTestCase:
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143}
|
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143}
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
def prepare_datas(self):
|
def prepare_datas(self):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -354,7 +354,7 @@ class TDTestCase:
|
||||||
event.wait()
|
event.wait()
|
||||||
|
|
||||||
tdLog.info("start consume processor")
|
tdLog.info("start consume processor")
|
||||||
pollDelay = 5
|
pollDelay = 15
|
||||||
showMsg = 1
|
showMsg = 1
|
||||||
showRow = 1
|
showRow = 1
|
||||||
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow)
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow)
|
||||||
|
|
|
@ -183,6 +183,7 @@ SScript *simParseScript(char *fileName) {
|
||||||
strcpy(name, fileName);
|
strcpy(name, fileName);
|
||||||
} else {
|
} else {
|
||||||
sprintf(name, "%s" TD_DIRSEP "%s", simScriptDir, fileName);
|
sprintf(name, "%s" TD_DIRSEP "%s", simScriptDir, fileName);
|
||||||
|
taosRealPath(name, NULL, sizeof(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ((fd = fopen(name, "r")) == NULL) {
|
// if ((fd = fopen(name, "r")) == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue