Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/tsdb_refact
This commit is contained in:
commit
76a71b11ed
|
@ -82,7 +82,8 @@ int32_t create_stream() {
|
||||||
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||||
pRes = taos_query(
|
pRes = taos_query(
|
||||||
pConn, "create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 interval(10m)");
|
pConn,
|
||||||
|
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 interval(10m)");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -135,6 +135,8 @@ typedef enum _mgmt_table {
|
||||||
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
|
||||||
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
|
||||||
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
|
||||||
|
#define TSDB_ALTER_USER_ENABLE 0x9
|
||||||
|
#define TSDB_ALTER_USER_SYSINFO 0xA
|
||||||
|
|
||||||
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
#define TSDB_ALTER_USER_PRIVILEGES 0x2
|
||||||
|
|
||||||
|
@ -534,6 +536,8 @@ int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t createType;
|
int8_t createType;
|
||||||
int8_t superUser; // denote if it is a super user or not
|
int8_t superUser; // denote if it is a super user or not
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_USET_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
} SCreateUserReq;
|
} SCreateUserReq;
|
||||||
|
@ -544,6 +548,8 @@ int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pR
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_USET_PASSWORD_LEN];
|
char pass[TSDB_USET_PASSWORD_LEN];
|
||||||
char dbname[TSDB_DB_FNAME_LEN];
|
char dbname[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -563,6 +569,9 @@ typedef struct {
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
int32_t version;
|
int32_t version;
|
||||||
int8_t superAuth;
|
int8_t superAuth;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
|
int8_t reserve;
|
||||||
SHashObj* createdDbs;
|
SHashObj* createdDbs;
|
||||||
SHashObj* readDbs;
|
SHashObj* readDbs;
|
||||||
SHashObj* writeDbs;
|
SHashObj* writeDbs;
|
||||||
|
|
|
@ -38,8 +38,10 @@ typedef struct SReadHandle {
|
||||||
SMsgCb* pMsgCb;
|
SMsgCb* pMsgCb;
|
||||||
} SReadHandle;
|
} SReadHandle;
|
||||||
|
|
||||||
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
enum {
|
||||||
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
|
STREAM_DATA_TYPE_SUBMIT_BLOCK = 1,
|
||||||
|
STREAM_DATA_TYPE_SSDATA_BLOCK = 2,
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OPTR_EXEC_MODEL_BATCH = 0x1,
|
OPTR_EXEC_MODEL_BATCH = 0x1,
|
||||||
|
@ -102,7 +104,8 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
* @param tversion
|
* @param tversion
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t* tversion);
|
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,
|
||||||
|
|
|
@ -177,7 +177,8 @@ typedef enum ESubplanType {
|
||||||
SUBPLAN_TYPE_MERGE = 1,
|
SUBPLAN_TYPE_MERGE = 1,
|
||||||
SUBPLAN_TYPE_PARTIAL,
|
SUBPLAN_TYPE_PARTIAL,
|
||||||
SUBPLAN_TYPE_SCAN,
|
SUBPLAN_TYPE_SCAN,
|
||||||
SUBPLAN_TYPE_MODIFY
|
SUBPLAN_TYPE_MODIFY,
|
||||||
|
SUBPLAN_TYPE_COMPUTE
|
||||||
} ESubplanType;
|
} ESubplanType;
|
||||||
|
|
||||||
typedef struct SSubplanId {
|
typedef struct SSubplanId {
|
||||||
|
@ -196,6 +197,7 @@ typedef struct SLogicSubplan {
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t splitFlag;
|
int32_t splitFlag;
|
||||||
|
int32_t numOfComputeNodes;
|
||||||
} SLogicSubplan;
|
} SLogicSubplan;
|
||||||
|
|
||||||
typedef struct SQueryLogicPlan {
|
typedef struct SQueryLogicPlan {
|
||||||
|
|
|
@ -58,6 +58,7 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
STREAM_INPUT__DATA_SUBMIT = 1,
|
STREAM_INPUT__DATA_SUBMIT = 1,
|
||||||
STREAM_INPUT__DATA_BLOCK,
|
STREAM_INPUT__DATA_BLOCK,
|
||||||
|
STREAM_INPUT__TRIGGER,
|
||||||
STREAM_INPUT__CHECKPOINT,
|
STREAM_INPUT__CHECKPOINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,6 +86,11 @@ typedef struct {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
} SStreamCheckpoint;
|
} SStreamCheckpoint;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
SSDataBlock* pBlock;
|
||||||
|
} SStreamTrigger;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STREAM_QUEUE__SUCESS = 1,
|
STREAM_QUEUE__SUCESS = 1,
|
||||||
STREAM_QUEUE__FAILED,
|
STREAM_QUEUE__FAILED,
|
||||||
|
@ -98,6 +104,9 @@ typedef struct {
|
||||||
int8_t status;
|
int8_t status;
|
||||||
} SStreamQueue;
|
} SStreamQueue;
|
||||||
|
|
||||||
|
int32_t streamInit();
|
||||||
|
void streamCleanUp();
|
||||||
|
|
||||||
SStreamQueue* streamQueueOpen();
|
SStreamQueue* streamQueueOpen();
|
||||||
void streamQueueClose(SStreamQueue* queue);
|
void streamQueueClose(SStreamQueue* queue);
|
||||||
|
|
||||||
|
@ -220,6 +229,11 @@ enum {
|
||||||
TASK_INPUT_TYPE__DATA_BLOCK,
|
TASK_INPUT_TYPE__DATA_BLOCK,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TASK_TRIGGER_STATUS__IN_ACTIVE = 1,
|
||||||
|
TASK_TRIGGER_STATUS__ACTIVE,
|
||||||
|
};
|
||||||
|
|
||||||
struct SStreamTask {
|
struct SStreamTask {
|
||||||
int64_t streamId;
|
int64_t streamId;
|
||||||
int32_t taskId;
|
int32_t taskId;
|
||||||
|
@ -262,8 +276,16 @@ struct SStreamTask {
|
||||||
SStreamQueue* inputQueue;
|
SStreamQueue* inputQueue;
|
||||||
SStreamQueue* outputQueue;
|
SStreamQueue* outputQueue;
|
||||||
|
|
||||||
|
// trigger
|
||||||
|
int8_t triggerStatus;
|
||||||
|
int64_t triggerParam;
|
||||||
|
void* timer;
|
||||||
|
|
||||||
// application storage
|
// application storage
|
||||||
// void* ahandle;
|
// void* ahandle;
|
||||||
|
|
||||||
|
// msg handle
|
||||||
|
SMsgCb* pMsgCb;
|
||||||
};
|
};
|
||||||
|
|
||||||
SStreamTask* tNewSStreamTask(int64_t streamId);
|
SStreamTask* tNewSStreamTask(int64_t streamId);
|
||||||
|
@ -292,6 +314,13 @@ static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem
|
||||||
taosWriteQitem(pTask->inputQueue->queue, pItem);
|
taosWriteQitem(pTask->inputQueue->queue, pItem);
|
||||||
} else if (pItem->type == STREAM_INPUT__CHECKPOINT) {
|
} else if (pItem->type == STREAM_INPUT__CHECKPOINT) {
|
||||||
taosWriteQitem(pTask->inputQueue->queue, pItem);
|
taosWriteQitem(pTask->inputQueue->queue, pItem);
|
||||||
|
} else if (pItem->type == STREAM_INPUT__TRIGGER) {
|
||||||
|
taosWriteQitem(pTask->inputQueue->queue, pItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pItem->type != STREAM_INPUT__TRIGGER && pItem->type != STREAM_INPUT__CHECKPOINT && pTask->triggerParam != 0 &&
|
||||||
|
pTask->triggerStatus == TASK_TRIGGER_STATUS__IN_ACTIVE) {
|
||||||
|
atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: back pressure
|
// TODO: back pressure
|
||||||
|
@ -370,7 +399,8 @@ typedef struct {
|
||||||
|
|
||||||
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq);
|
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq);
|
||||||
|
|
||||||
int32_t streamTriggerByWrite(SStreamTask* pTask, int32_t vgId, SMsgCb* pMsgCb);
|
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId, SMsgCb* pMsgCb);
|
||||||
|
int32_t streamSetupTrigger(SStreamTask* pTask);
|
||||||
|
|
||||||
int32_t streamTaskRun(SStreamTask* pTask);
|
int32_t streamTaskRun(SStreamTask* pTask);
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,6 @@ typedef enum {
|
||||||
TAOS_SYNC_STATE_ERROR = 103,
|
TAOS_SYNC_STATE_ERROR = 103,
|
||||||
} ESyncState;
|
} ESyncState;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TAOS_SYNC_PROPOSE_SUCCESS = 0,
|
|
||||||
TAOS_SYNC_PROPOSE_NOT_LEADER = 1,
|
|
||||||
TAOS_SYNC_ONLY_ONE_REPLICA = 2,
|
|
||||||
TAOS_SYNC_NOT_IN_NEW_CONFIG = 3,
|
|
||||||
TAOS_SYNC_OTHER_ERROR = 100,
|
|
||||||
} ESyncProposeCode;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TAOS_SYNC_FSM_CB_SUCCESS = 0,
|
TAOS_SYNC_FSM_CB_SUCCESS = 0,
|
||||||
TAOS_SYNC_FSM_CB_OTHER_ERROR = 1,
|
TAOS_SYNC_FSM_CB_OTHER_ERROR = 1,
|
||||||
|
|
|
@ -133,7 +133,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
||||||
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
|
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
|
||||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
|
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
|
||||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0303)
|
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||||
|
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0304)
|
||||||
|
|
||||||
// mnode-show
|
// mnode-show
|
||||||
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
|
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
|
||||||
|
@ -412,6 +413,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
||||||
|
|
||||||
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x0910)
|
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x0910)
|
||||||
|
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0911)
|
||||||
|
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0912)
|
||||||
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
|
|
|
@ -992,6 +992,90 @@ CREATE_MSG_FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
|
||||||
|
bool set = false;
|
||||||
|
|
||||||
|
int32_t topicNumGet = taosArrayGetSize(pRsp->topics);
|
||||||
|
char vgKey[TSDB_TOPIC_FNAME_LEN + 22];
|
||||||
|
tscDebug("consumer %ld update ep epoch %d to epoch %d, topic num: %d", tmq->consumerId, tmq->epoch, epoch,
|
||||||
|
topicNumGet);
|
||||||
|
|
||||||
|
SArray* newTopics = taosArrayInit(topicNumGet, sizeof(SMqClientTopic));
|
||||||
|
if (newTopics == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHashObj* pHash = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
||||||
|
if (pHash == NULL) {
|
||||||
|
taosArrayDestroy(newTopics);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics);
|
||||||
|
for (int32_t i = 0; i < topicNumCur; i++) {
|
||||||
|
// find old topic
|
||||||
|
SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, i);
|
||||||
|
if (pTopicCur->vgs) {
|
||||||
|
int32_t vgNumCur = taosArrayGetSize(pTopicCur->vgs);
|
||||||
|
tscDebug("consumer %ld new vg num: %d", tmq->consumerId, vgNumCur);
|
||||||
|
if (vgNumCur == 0) break;
|
||||||
|
for (int32_t j = 0; j < vgNumCur; j++) {
|
||||||
|
SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j);
|
||||||
|
sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId);
|
||||||
|
tscDebug("consumer %ld epoch %d vg %d build %s", tmq->consumerId, epoch, pVgCur->vgId, vgKey);
|
||||||
|
taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(int64_t));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < topicNumGet; i++) {
|
||||||
|
SMqClientTopic topic = {0};
|
||||||
|
SMqSubTopicEp* pTopicEp = taosArrayGet(pRsp->topics, i);
|
||||||
|
topic.schema = pTopicEp->schema;
|
||||||
|
taosHashClear(pHash);
|
||||||
|
topic.topicName = strdup(pTopicEp->topic);
|
||||||
|
tstrncpy(topic.db, pTopicEp->db, TSDB_DB_FNAME_LEN);
|
||||||
|
|
||||||
|
tscDebug("consumer %ld update topic: %s", tmq->consumerId, topic.topicName);
|
||||||
|
|
||||||
|
int32_t vgNumGet = taosArrayGetSize(pTopicEp->vgs);
|
||||||
|
topic.vgs = taosArrayInit(vgNumGet, sizeof(SMqClientVg));
|
||||||
|
for (int32_t j = 0; j < vgNumGet; j++) {
|
||||||
|
SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j);
|
||||||
|
sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId);
|
||||||
|
int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey));
|
||||||
|
int64_t offset = tmq->resetOffsetCfg;
|
||||||
|
if (pOffset != NULL) {
|
||||||
|
offset = *pOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset);
|
||||||
|
SMqClientVg clientVg = {
|
||||||
|
.pollCnt = 0,
|
||||||
|
.currentOffset = offset,
|
||||||
|
.vgId = pVgEp->vgId,
|
||||||
|
.epSet = pVgEp->epSet,
|
||||||
|
.vgStatus = TMQ_VG_STATUS__IDLE,
|
||||||
|
.vgSkipCnt = 0,
|
||||||
|
};
|
||||||
|
taosArrayPush(topic.vgs, &clientVg);
|
||||||
|
set = true;
|
||||||
|
}
|
||||||
|
taosArrayPush(newTopics, &topic);
|
||||||
|
}
|
||||||
|
if (tmq->clientTopics) taosArrayDestroy(tmq->clientTopics);
|
||||||
|
taosHashCleanup(pHash);
|
||||||
|
tmq->clientTopics = newTopics;
|
||||||
|
|
||||||
|
if (taosArrayGetSize(tmq->clientTopics) == 0)
|
||||||
|
atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__NO_TOPIC);
|
||||||
|
else
|
||||||
|
atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__READY);
|
||||||
|
|
||||||
|
atomic_store_32(&tmq->epoch, epoch);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
|
bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
|
||||||
/*printf("call update ep %d\n", epoch);*/
|
/*printf("call update ep %d\n", epoch);*/
|
||||||
bool set = false;
|
bool set = false;
|
||||||
|
|
|
@ -170,7 +170,9 @@ static const SSysDbTableSchema userTblDistSchema[] = {
|
||||||
|
|
||||||
static const SSysDbTableSchema userUsersSchema[] = {
|
static const SSysDbTableSchema userUsersSchema[] = {
|
||||||
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "super", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
|
{.name = "enable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
|
{.name = "sysinfo", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1160,6 +1160,8 @@ int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->createType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->createType) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->enable) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
@ -1176,6 +1178,8 @@ int32_t tDeserializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pR
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->createType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->createType) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
@ -1191,6 +1195,8 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->superUser) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->enable) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->user) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1;
|
||||||
|
@ -1208,6 +1214,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->superUser) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1;
|
||||||
|
@ -1245,6 +1253,9 @@ int32_t tDeserializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *
|
||||||
int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) {
|
int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) {
|
||||||
if (tEncodeCStr(pEncoder, pRsp->user) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pRsp->user) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pRsp->superAuth) < 0) return -1;
|
if (tEncodeI8(pEncoder, pRsp->superAuth) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->sysInfo) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->enable) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pRsp->reserve) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pRsp->version) < 0) return -1;
|
if (tEncodeI32(pEncoder, pRsp->version) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCreatedDbs = taosHashGetSize(pRsp->createdDbs);
|
int32_t numOfCreatedDbs = taosHashGetSize(pRsp->createdDbs);
|
||||||
|
@ -1300,6 +1311,9 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
|
||||||
|
|
||||||
if (tDecodeCStrTo(pDecoder, pRsp->user) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pRsp->user) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pRsp->superAuth) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pRsp->superAuth) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->sysInfo) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->enable) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pRsp->reserve) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pRsp->version) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->version) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCreatedDbs = 0;
|
int32_t numOfCreatedDbs = 0;
|
||||||
|
|
|
@ -22,23 +22,42 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MND_OPER_CREATE_USER = 1,
|
||||||
|
MND_OPER_DROP_USER,
|
||||||
|
MND_OPER_ALTER_USER,
|
||||||
|
MND_OPER_CREATE_BNODE,
|
||||||
|
MND_OPER_DROP_BNODE,
|
||||||
|
MND_OPER_CREATE_DNODE,
|
||||||
|
MND_OPER_DROP_DNODE,
|
||||||
|
MND_OPER_CREATE_MNODE,
|
||||||
|
MND_OPER_DROP_MNODE,
|
||||||
|
MND_OPER_CREATE_QNODE,
|
||||||
|
MND_OPER_DROP_QNODE,
|
||||||
|
MND_OPER_CREATE_SNODE,
|
||||||
|
MND_OPER_DROP_SNODE,
|
||||||
|
MND_OPER_REDISTRIBUTE_VGROUP,
|
||||||
|
MND_OPER_SPLIT_VGROUP,
|
||||||
|
MND_OPER_BALANCE_VGROUP,
|
||||||
|
MND_OPER_CREATE_FUNC,
|
||||||
|
MND_OPER_DROP_FUNC,
|
||||||
|
MND_OPER_KILL_TRANS,
|
||||||
|
MND_OPER_CREATE_DB,
|
||||||
|
MND_OPER_ALTER_DB,
|
||||||
|
MND_OPER_DROP_DB,
|
||||||
|
MND_OPER_COMPACT_DB,
|
||||||
|
MND_OPER_USE_DB,
|
||||||
|
MND_OPER_WRITE_DB,
|
||||||
|
MND_OPER_READ_DB,
|
||||||
|
} EOperType;
|
||||||
|
|
||||||
int32_t mndInitAuth(SMnode *pMnode);
|
int32_t mndInitAuth(SMnode *pMnode);
|
||||||
void mndCleanupAuth(SMnode *pMnode);
|
void mndCleanupAuth(SMnode *pMnode);
|
||||||
|
|
||||||
int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
|
int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType);
|
||||||
|
int32_t mndCheckDbAuth(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb);
|
||||||
|
int32_t mndCheckShowAuth(SMnode *pMnode, const char *user, int32_t showType);
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
|
||||||
|
|
||||||
int32_t mndCheckNodeAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckFuncAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckTransAuth(SUserObj *pOperUser);
|
|
||||||
|
|
||||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser);
|
|
||||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
int32_t mndCheckUseDbAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
|
|
||||||
int32_t mndCheckWriteAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,9 @@ typedef struct {
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int8_t superUser;
|
int8_t superUser;
|
||||||
|
int8_t sysInfo;
|
||||||
|
int8_t enable;
|
||||||
|
int8_t reserve;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
int32_t authVersion;
|
int32_t authVersion;
|
||||||
SHashObj* readDbs;
|
SHashObj* readDbs;
|
||||||
|
@ -554,8 +557,8 @@ typedef struct {
|
||||||
SVgObj fixedSinkVg;
|
SVgObj fixedSinkVg;
|
||||||
int64_t smaId; // 0 for unused
|
int64_t smaId; // 0 for unused
|
||||||
int8_t trigger;
|
int8_t trigger;
|
||||||
int32_t triggerParam;
|
int64_t triggerParam;
|
||||||
int64_t waterMark;
|
int64_t watermark;
|
||||||
char* sql;
|
char* sql;
|
||||||
char* physicalPlan;
|
char* physicalPlan;
|
||||||
SArray* tasks; // SArray<SArray<SStreamTask>>
|
SArray* tasks; // SArray<SArray<SStreamTask>>
|
||||||
|
|
|
@ -31,7 +31,7 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
|
||||||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream);
|
||||||
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, int8_t triggerType, int64_t watermark, STrans *pTrans);
|
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,29 +73,44 @@ static int32_t mndProcessAuthReq(SRpcMsg *pReq) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckCreateUserAuth(SUserObj *pOperUser) {
|
int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
|
||||||
if (pOperUser->superUser) return 0;
|
int32_t code = 0;
|
||||||
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
|
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pUser->superUser) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
||||||
|
if (pOperUser->superUser) return 0;
|
||||||
|
if (!pOperUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) {
|
if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) {
|
||||||
if (pOperUser->superUser || strcmp(pUser->user, pOperUser->user) == 0) {
|
if (strcmp(pUser->user, pOperUser->user) == 0) {
|
||||||
return 0;
|
if (pOperUser->sysInfo) return 0;
|
||||||
}
|
|
||||||
} else if (pAlter->alterType == TSDB_ALTER_USER_SUPERUSER) {
|
|
||||||
if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pOperUser->superUser) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pOperUser->superUser) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,65 +118,92 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserRe
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
|
int32_t mndCheckShowAuth(SMnode *pMnode, const char *user, int32_t showType) {
|
||||||
if (pOperUser->superUser) return 0;
|
int32_t code = 0;
|
||||||
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
|
|
||||||
|
if (pUser == NULL) {
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pUser->superUser) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pUser->sysInfo) {
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
}
|
goto _OVER;
|
||||||
|
|
||||||
int32_t mndCheckNodeAuth(SUserObj *pOperUser) {
|
|
||||||
if (pOperUser->superUser) return 0;
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckFuncAuth(SUserObj *pOperUser) {
|
|
||||||
if (pOperUser->superUser) return 0;
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckTransAuth(SUserObj *pOperUser) {
|
|
||||||
if (pOperUser->superUser) return 0;
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mndCheckCreateDbAuth(SUserObj *pOperUser) { return 0; }
|
|
||||||
|
|
||||||
int32_t mndCheckAlterDropCompactDbAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndCheckUseDbAuth(SUserObj *pOperUser, SDbObj *pDb) { return 0; }
|
int32_t mndCheckDbAuth(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||||
|
|
||||||
int32_t mndCheckWriteAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
if (pUser == NULL) {
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
code = -1;
|
||||||
return 0;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashGet(pOperUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) {
|
if (pUser->superUser) goto _OVER;
|
||||||
return 0;
|
|
||||||
|
if (!pUser->enable) {
|
||||||
|
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||||
|
code = -1;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_CREATE_DB) {
|
||||||
|
if (pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_ALTER_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_DROP_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_COMPACT_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_USE_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_WRITE_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operType == MND_OPER_READ_DB) {
|
||||||
|
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||||
|
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
code = -1;
|
||||||
}
|
|
||||||
|
_OVER:
|
||||||
int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
mndReleaseUser(pMnode, pUser);
|
||||||
if (pOperUser->superUser || strcmp(pOperUser->user, pDb->createUser) == 0) {
|
return code;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosHashGet(pOperUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SBnodeObj *pObj = NULL;
|
SBnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateBnodeReq createReq = {0};
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -293,13 +292,7 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_BNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +306,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseBnode(pMnode, pObj);
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +374,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SBnodeObj *pObj = NULL;
|
SBnodeObj *pObj = NULL;
|
||||||
SMDropBnodeReq dropReq = {0};
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -403,13 +394,7 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_BNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,8 +407,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseBnode(pMnode, pObj);
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckCreateDbAuth(pUser) != 0) {
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_DB, NULL) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +684,6 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SAlterDbReq alterReq = {0};
|
SAlterDbReq alterReq = {0};
|
||||||
SDbObj dbObj = {0};
|
SDbObj dbObj = {0};
|
||||||
|
|
||||||
|
@ -701,12 +700,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_ALTER_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +727,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(dbObj.cfg.pRetensions);
|
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -967,7 +960,6 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDropDbReq dropReq = {0};
|
SDropDbReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSDropDbReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropDbReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
@ -988,12 +980,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_DROP_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,8 +993,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,7 +1088,6 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SUseDbReq usedbReq = {0};
|
SUseDbReq usedbReq = {0};
|
||||||
SUseDbRsp usedbRsp = {0};
|
SUseDbRsp usedbRsp = {0};
|
||||||
|
|
||||||
|
@ -1143,12 +1127,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr());
|
||||||
} else {
|
} else {
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_USE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckUseDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,7 +1158,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSUsedbRsp(&usedbRsp);
|
tFreeSUsedbRsp(&usedbRsp);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1260,7 +1238,6 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCompactDbReq compactReq = {0};
|
SCompactDbReq compactReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCompactDbReq(pReq->pCont, pReq->contLen, &compactReq) != 0) {
|
if (tDeserializeSCompactDbReq(pReq->pCont, pReq->contLen, &compactReq) != 0) {
|
||||||
|
@ -1275,12 +1252,7 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_COMPACT_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckAlterDropCompactDbAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,8 +1264,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||||
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pObj->triggerParam) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->triggerParam) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->waterMark) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->watermark) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
||||||
|
@ -85,8 +85,8 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
|
||||||
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pObj->triggerParam) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->triggerParam) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->waterMark) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->watermark) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
||||||
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
||||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||||
|
|
|
@ -499,7 +499,6 @@ _OVER:
|
||||||
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SCreateDnodeReq createReq = {0};
|
SCreateDnodeReq createReq = {0};
|
||||||
|
|
||||||
|
@ -522,13 +521,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_DNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +534,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +578,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SMnodeObj *pMObj = NULL;
|
SMnodeObj *pMObj = NULL;
|
||||||
SMDropMnodeReq dropReq = {0};
|
SMDropMnodeReq dropReq = {0};
|
||||||
|
@ -631,13 +622,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +635,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseMnode(pMnode, pMObj);
|
mndReleaseMnode(pMnode, pMObj);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,6 @@ _OVER:
|
||||||
static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SFuncObj *pFunc = NULL;
|
SFuncObj *pFunc = NULL;
|
||||||
SCreateFuncReq createReq = {0};
|
SCreateFuncReq createReq = {0};
|
||||||
|
|
||||||
|
@ -319,13 +318,7 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_FUNC) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckFuncAuth(pUser)) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,16 +331,13 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseFunc(pMnode, pFunc);
|
mndReleaseFunc(pMnode, pFunc);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSCreateFuncReq(&createReq);
|
tFreeSCreateFuncReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SFuncObj *pFunc = NULL;
|
SFuncObj *pFunc = NULL;
|
||||||
SDropFuncReq dropReq = {0};
|
SDropFuncReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -375,13 +365,7 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_FUNC) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckFuncAuth(pUser)) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,8 +378,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseFunc(pMnode, pFunc);
|
mndReleaseFunc(pMnode, pFunc);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,17 +380,19 @@ void mndStop(SMnode *pMnode) {
|
||||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
int32_t code = TAOS_SYNC_OTHER_ERROR;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (!syncEnvIsStart()) {
|
if (!syncEnvIsStart()) {
|
||||||
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char logBuf[512] = {0};
|
char logBuf[512] = {0};
|
||||||
|
@ -451,7 +453,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = TAOS_SYNC_OTHER_ERROR;
|
code = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||||
|
@ -492,10 +494,13 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = TAOS_SYNC_OTHER_ERROR;
|
code = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateMnodeReq createReq = {0};
|
SMCreateMnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -415,13 +414,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +428,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseMnode(pMnode, pObj);
|
mndReleaseMnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +586,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
SMDropMnodeReq dropReq = {0};
|
SMDropMnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -630,13 +621,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_MNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,8 +634,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseMnode(pMnode, pObj);
|
mndReleaseMnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SQnodeObj *pObj = NULL;
|
SQnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateQnodeReq createReq = {0};
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -295,13 +294,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_QNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +308,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseQnode(pMnode, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +376,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SQnodeObj *pObj = NULL;
|
SQnodeObj *pObj = NULL;
|
||||||
SMDropQnodeReq dropReq = {0};
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -405,13 +396,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_QNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,8 +409,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseQnode(pMnode, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,6 +387,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
// input
|
// input
|
||||||
pFinalTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK;
|
pFinalTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK;
|
||||||
|
|
||||||
|
// trigger
|
||||||
|
pFinalTask->triggerParam = pStream->triggerParam;
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
if (mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pFinalTask) < 0) {
|
if (mndAddDispatcherToInnerTask(pMnode, pTrans, pStream, pFinalTask) < 0) {
|
||||||
qDestroyQueryPlan(pPlan);
|
qDestroyQueryPlan(pPlan);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
|
|
||||||
#define SHOW_STEP_SIZE 100
|
#define SHOW_STEP_SIZE 100
|
||||||
|
|
||||||
|
@ -228,6 +229,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
|
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
|
||||||
|
|
||||||
|
// if (mndCheckShowAuth(pMnode, pReq->conn.user, pShow->type) != 0) return -1;
|
||||||
|
|
||||||
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
||||||
SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
|
|
@ -561,6 +561,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
streamObj.sql = pCreate->sql;
|
streamObj.sql = pCreate->sql;
|
||||||
streamObj.createdBy = STREAM_CREATED_BY__SMA;
|
streamObj.createdBy = STREAM_CREATED_BY__SMA;
|
||||||
streamObj.smaId = smaObj.uid;
|
streamObj.smaId = smaObj.uid;
|
||||||
|
streamObj.watermark = 0;
|
||||||
|
streamObj.trigger = STREAM_TRIGGER_AT_ONCE;
|
||||||
|
|
||||||
if (mndAllocSmaVgroup(pMnode, pDb, &streamObj.fixedSinkVg) != 0) {
|
if (mndAllocSmaVgroup(pMnode, pDb, &streamObj.fixedSinkVg) != 0) {
|
||||||
mError("sma:%s, failed to create since %s", smaObj.name, terrstr());
|
mError("sma:%s, failed to create since %s", smaObj.name, terrstr());
|
||||||
|
@ -583,7 +585,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER;
|
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pTrans) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -629,7 +631,6 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateSmaReq createReq = {0};
|
SMCreateSmaReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMCreateSmaReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSMCreateSmaReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -673,12 +674,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +690,6 @@ _OVER:
|
||||||
mndReleaseSma(pMnode, pSma);
|
mndReleaseSma(pMnode, pSma);
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSMCreateSmaReq(&createReq);
|
tFreeSMCreateSmaReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -911,7 +906,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SMDropSmaReq dropReq = {0};
|
SMDropSmaReq dropReq = {0};
|
||||||
|
@ -941,12 +935,7 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,9 +948,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseSma(pMnode, pSma);
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SSnodeObj *pObj = NULL;
|
SSnodeObj *pObj = NULL;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateSnodeReq createReq = {0};
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -301,13 +300,7 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_SNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +315,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseSnode(pMnode, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +384,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SSnodeObj *pObj = NULL;
|
SSnodeObj *pObj = NULL;
|
||||||
SMDropSnodeReq dropReq = {0};
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
|
||||||
|
@ -413,13 +404,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_SNODE) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,8 +417,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseSnode(pMnode, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -773,7 +773,6 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||||
|
@ -807,12 +806,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +830,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
tFreeSMCreateStbReq(&createReq);
|
tFreeSMCreateStbReq(&createReq);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1431,7 +1424,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SMAlterStbReq alterReq = {0};
|
SMAlterStbReq alterReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSMAlterStbReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
if (tDeserializeSMAlterStbReq(pReq->pCont, pReq->contLen, &alterReq) != 0) {
|
||||||
|
@ -1462,12 +1454,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1468,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(alterReq.pFields);
|
taosArrayDestroy(alterReq.pFields);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1569,7 +1555,6 @@ _OVER:
|
||||||
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SMDropStbReq dropReq = {0};
|
SMDropStbReq dropReq = {0};
|
||||||
|
@ -1599,12 +1584,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,8 +1598,6 @@ _OVER:
|
||||||
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,23 +228,22 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
|
||||||
.pAstRoot = pAst,
|
.pAstRoot = pAst,
|
||||||
.topicQuery = false,
|
.topicQuery = false,
|
||||||
.streamQuery = true,
|
.streamQuery = true,
|
||||||
.triggerType = triggerType,
|
.triggerType = triggerType == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : triggerType,
|
||||||
.watermark = watermark,
|
.watermark = watermark,
|
||||||
};
|
};
|
||||||
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
|
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesNodeToString((SNode*)pPlan, false, pStr, NULL);
|
code = nodesNodeToString((SNode *)pPlan, false, pStr, NULL);
|
||||||
}
|
}
|
||||||
nodesDestroyNode(pAst);
|
nodesDestroyNode(pAst);
|
||||||
nodesDestroyNode((SNode*)pPlan);
|
nodesDestroyNode((SNode *)pPlan);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, int8_t triggerType, int64_t watermark,
|
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) {
|
||||||
STrans *pTrans) {
|
|
||||||
SNode *pAst = NULL;
|
SNode *pAst = NULL;
|
||||||
|
|
||||||
if (nodesStringToNode(ast, &pAst) < 0) {
|
if (nodesStringToNode(ast, &pAst) < 0) {
|
||||||
|
@ -258,7 +257,6 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
|
||||||
// free
|
// free
|
||||||
nodesDestroyNode(pAst);
|
nodesDestroyNode(pAst);
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("|");
|
printf("|");
|
||||||
for (int i = 0; i < pStream->outputSchema.nCols; i++) {
|
for (int i = 0; i < pStream->outputSchema.nCols; i++) {
|
||||||
|
@ -268,7 +266,7 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != mndStreamGetPlanString(ast, triggerType, watermark, &pStream->physicalPlan)) {
|
if (TSDB_CODE_SUCCESS != mndStreamGetPlanString(ast, pStream->trigger, pStream->watermark, &pStream->physicalPlan)) {
|
||||||
mError("topic:%s, failed to get plan since %s", pStream->name, terrstr());
|
mError("topic:%s, failed to get plan since %s", pStream->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +291,6 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
|
||||||
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -335,12 +332,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +361,6 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +383,8 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
|
||||||
streamObj.smaId = 0;
|
streamObj.smaId = 0;
|
||||||
/*streamObj.physicalPlan = "";*/
|
/*streamObj.physicalPlan = "";*/
|
||||||
streamObj.trigger = pCreate->triggerType;
|
streamObj.trigger = pCreate->triggerType;
|
||||||
streamObj.waterMark = pCreate->watermark;
|
streamObj.watermark = pCreate->watermark;
|
||||||
|
streamObj.triggerParam = pCreate->maxDelay;
|
||||||
|
|
||||||
if (streamObj.targetSTbName[0]) {
|
if (streamObj.targetSTbName[0]) {
|
||||||
pDb = mndAcquireDbByStb(pMnode, streamObj.targetSTbName);
|
pDb = mndAcquireDbByStb(pMnode, streamObj.targetSTbName);
|
||||||
|
@ -409,7 +402,7 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
|
||||||
}
|
}
|
||||||
mDebug("trans:%d, used to create stream:%s", pTrans->id, pCreate->name);
|
mDebug("trans:%d, used to create stream:%s", pTrans->id, pCreate->name);
|
||||||
|
|
||||||
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pCreate->triggerType, pCreate->watermark, pTrans) != 0) {
|
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, pTrans) != 0) {
|
||||||
mError("trans:%d, failed to add stream since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to add stream since %s", pTrans->id, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -436,19 +429,18 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCMCreateStreamReq createStreamReq = {0};
|
SCMCreateStreamReq createStreamReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createStreamReq) != 0) {
|
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createStreamReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("stream:%s, start to create, sql:%s", createStreamReq.name, createStreamReq.sql);
|
mDebug("stream:%s, start to create, sql:%s", createStreamReq.name, createStreamReq.sql);
|
||||||
|
|
||||||
if (mndCheckCreateStreamReq(&createStreamReq) != 0) {
|
if (mndCheckCreateStreamReq(&createStreamReq) != 0) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, createStreamReq.name);
|
pStream = mndAcquireStream(pMnode, createStreamReq.name);
|
||||||
|
@ -456,41 +448,35 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
if (createStreamReq.igExists) {
|
if (createStreamReq.igExists) {
|
||||||
mDebug("stream:%s, already exist, ignore exist is set", createStreamReq.name);
|
mDebug("stream:%s, already exist, ignore exist is set", createStreamReq.name);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
} else if (terrno != TSDB_CODE_MND_STREAM_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_STREAM_NOT_EXIST) {
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
goto CREATE_STREAM_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
goto _OVER;
|
||||||
goto CREATE_STREAM_OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto CREATE_STREAM_OVER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);
|
code = mndCreateStream(pMnode, pReq, &createStreamReq, pDb);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
CREATE_STREAM_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseStream(pMnode, pStream);
|
mndReleaseStream(pMnode, pStream);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
tFreeSCMCreateStreamReq(&createStreamReq);
|
tFreeSCMCreateStreamReq(&createStreamReq);
|
||||||
return code;
|
return code;
|
||||||
|
@ -566,7 +552,7 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->targetSTbName, true);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->targetSTbName, true);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->waterMark, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->watermark, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->trigger, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->trigger, false);
|
||||||
|
|
|
@ -234,9 +234,9 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
int32_t code = syncPropose(pMgmt->sync, &rsp, isWeak);
|
int32_t code = syncPropose(pMgmt->sync, &rsp, isWeak);
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
tsem_wait(&pMgmt->syncSem);
|
tsem_wait(&pMgmt->syncSem);
|
||||||
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
} else if (code == TAOS_SYNC_OTHER_ERROR) {
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_INTERNAL_ERROR) {
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
|
@ -257,13 +257,13 @@ void mndSyncStart(SMnode *pMnode) {
|
||||||
syncStart(pMgmt->sync);
|
syncStart(pMgmt->sync);
|
||||||
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (pMgmt->standby) {
|
if (pMgmt->standby) {
|
||||||
syncStartStandBy(pMgmt->sync);
|
syncStartStandBy(pMgmt->sync);
|
||||||
} else {
|
} else {
|
||||||
syncStart(pMgmt->sync);
|
syncStart(pMgmt->sync);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSyncStop(SMnode *pMnode) {}
|
void mndSyncStop(SMnode *pMnode) {}
|
||||||
|
|
|
@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodesNodeToString((SNode*)pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
if (nodesNodeToString((SNode *)pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
@ -440,19 +440,18 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMqTopicObj *pTopic = NULL;
|
SMqTopicObj *pTopic = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SCMCreateTopicReq createTopicReq = {0};
|
SCMCreateTopicReq createTopicReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) {
|
if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("topic:%s, start to create, sql:%s", createTopicReq.name, createTopicReq.sql);
|
mDebug("topic:%s, start to create, sql:%s", createTopicReq.name, createTopicReq.sql);
|
||||||
|
|
||||||
if (mndCheckCreateTopicReq(&createTopicReq) != 0) {
|
if (mndCheckCreateTopicReq(&createTopicReq) != 0) {
|
||||||
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTopic = mndAcquireTopic(pMnode, createTopicReq.name);
|
pTopic = mndAcquireTopic(pMnode, createTopicReq.name);
|
||||||
|
@ -460,41 +459,35 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
||||||
if (createTopicReq.igExists) {
|
if (createTopicReq.igExists) {
|
||||||
mDebug("topic:%s, already exist, ignore exist is set", createTopicReq.name);
|
mDebug("topic:%s, already exist, ignore exist is set", createTopicReq.name);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MND_TOPIC_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_TOPIC_ALREADY_EXIST;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
} else if (terrno != TSDB_CODE_MND_TOPIC_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_TOPIC_NOT_EXIST) {
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDb = mndAcquireDb(pMnode, createTopicReq.subDbName);
|
pDb = mndAcquireDb(pMnode, createTopicReq.subDbName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
goto CREATE_TOPIC_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckDbAuth(pMnode, pReq->conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
if (pUser == NULL) {
|
goto _OVER;
|
||||||
goto CREATE_TOPIC_OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckWriteAuth(pUser, pDb) != 0) {
|
|
||||||
goto CREATE_TOPIC_OVER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb);
|
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
CREATE_TOPIC_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
mError("topic:%s, failed to create since %s", createTopicReq.name, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
|
|
||||||
tFreeSCMCreateTopicReq(&createTopicReq);
|
tFreeSCMCreateTopicReq(&createTopicReq);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -1362,7 +1362,6 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SKillTransReq killReq = {0};
|
SKillTransReq killReq = {0};
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
if (tDeserializeSKillTransReq(pReq->pCont, pReq->contLen, &killReq) != 0) {
|
if (tDeserializeSKillTransReq(pReq->pCont, pReq->contLen, &killReq) != 0) {
|
||||||
|
@ -1372,12 +1371,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
mInfo("trans:%d, start to kill", killReq.transId);
|
mInfo("trans:%d, start to kill", killReq.transId);
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_KILL_TRANS) != 0) {
|
||||||
if (pUser == NULL) {
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckTransAuth(pUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,7 +1387,6 @@ _OVER:
|
||||||
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
|
||||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
userObj.createdTime = taosGetTimestampMs();
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
|
userObj.sysInfo = 1;
|
||||||
|
userObj.enable = 1;
|
||||||
|
|
||||||
if (strcmp(user, TSDB_DEFAULT_USER) == 0) {
|
if (strcmp(user, TSDB_DEFAULT_USER) == 0) {
|
||||||
userObj.superUser = 1;
|
userObj.superUser = 1;
|
||||||
|
@ -128,6 +130,9 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->createdTime, _OVER)
|
||||||
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pUser->updateTime, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pUser->superUser, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->sysInfo, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->enable, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pUser->reserve, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER)
|
||||||
|
@ -184,6 +189,9 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->createdTime, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pUser->updateTime, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pUser->superUser, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->sysInfo, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->enable, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pUser->reserve, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pUser->authVersion, _OVER)
|
||||||
|
|
||||||
int32_t numOfReadDbs = 0;
|
int32_t numOfReadDbs = 0;
|
||||||
|
@ -256,6 +264,8 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
|
||||||
taosWLockLatch(&pOld->lock);
|
taosWLockLatch(&pOld->lock);
|
||||||
pOld->updateTime = pNew->updateTime;
|
pOld->updateTime = pNew->updateTime;
|
||||||
pOld->authVersion = pNew->authVersion;
|
pOld->authVersion = pNew->authVersion;
|
||||||
|
pOld->sysInfo = pNew->sysInfo;
|
||||||
|
pOld->enable = pNew->enable;
|
||||||
memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
||||||
TSWAP(pOld->readDbs, pNew->readDbs);
|
TSWAP(pOld->readDbs, pNew->readDbs);
|
||||||
TSWAP(pOld->writeDbs, pNew->writeDbs);
|
TSWAP(pOld->writeDbs, pNew->writeDbs);
|
||||||
|
@ -286,6 +296,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
userObj.createdTime = taosGetTimestampMs();
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
userObj.updateTime = userObj.createdTime;
|
userObj.updateTime = userObj.createdTime;
|
||||||
userObj.superUser = pCreate->superUser;
|
userObj.superUser = pCreate->superUser;
|
||||||
|
userObj.sysInfo = pCreate->sysInfo;
|
||||||
|
userObj.enable = pCreate->enable;
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
|
@ -348,7 +360,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCheckCreateUserAuth(pOperUser) != 0) {
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_CREATE_USER) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +493,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
||||||
newUser.superUser = alterReq.superUser;
|
newUser.superUser = alterReq.superUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alterReq.alterType == TSDB_ALTER_USER_ENABLE) {
|
||||||
|
newUser.enable = alterReq.enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alterReq.alterType == TSDB_ALTER_USER_SYSINFO) {
|
||||||
|
newUser.sysInfo = alterReq.sysInfo;
|
||||||
|
}
|
||||||
|
|
||||||
if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) {
|
||||||
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||||
int32_t len = strlen(alterReq.dbname) + 1;
|
int32_t len = strlen(alterReq.dbname) + 1;
|
||||||
|
@ -603,7 +623,6 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
SUserObj *pOperUser = NULL;
|
|
||||||
SDropUserReq dropReq = {0};
|
SDropUserReq dropReq = {0};
|
||||||
|
|
||||||
if (tDeserializeSDropUserReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
if (tDeserializeSDropUserReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
|
||||||
|
@ -624,13 +643,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_DROP_USER) != 0) {
|
||||||
if (pOperUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckDropUserAuth(pOperUser) != 0) {
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,9 +655,7 @@ _OVER:
|
||||||
mError("user:%s, failed to drop since %s", dropReq.user, terrstr());
|
mError("user:%s, failed to drop since %s", dropReq.user, terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pOperUser);
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,19 +751,21 @@ static int32_t mndRetrieveUsers(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
|
|
||||||
cols = 0;
|
cols = 0;
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
|
||||||
char name[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
char name[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)name, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)name, false);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->superUser, false);
|
||||||
|
|
||||||
const char *src = pUser->superUser ? "super" : "normal";
|
cols++;
|
||||||
char b[10 + VARSTR_HEADER_SIZE] = {0};
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
STR_WITH_SIZE_TO_VARSTR(b, src, strlen(src));
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->enable, false);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)b, false);
|
|
||||||
|
cols++;
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
colDataAppend(pColInfo, numOfRows, (const char *)&pUser->sysInfo, false);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
|
|
|
@ -1177,7 +1177,6 @@ _OVER:
|
||||||
|
|
||||||
static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SDnodeObj *pNew1 = NULL;
|
SDnodeObj *pNew1 = NULL;
|
||||||
SDnodeObj *pNew2 = NULL;
|
SDnodeObj *pNew2 = NULL;
|
||||||
SDnodeObj *pNew3 = NULL;
|
SDnodeObj *pNew3 = NULL;
|
||||||
|
@ -1200,13 +1199,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
mInfo("vgId:%d, start to redistribute to dnode %d:%d:%d", req.vgId, req.dnodeId1, req.dnodeId2, req.dnodeId3);
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_REDISTRIBUTE_VGROUP) != 0) goto _OVER;
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
pVgroup = mndAcquireVgroup(pMnode, req.vgId);
|
||||||
if (pVgroup == NULL) goto _OVER;
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
@ -1368,7 +1362,6 @@ _OVER:
|
||||||
mndReleaseDnode(pMnode, pOld1);
|
mndReleaseDnode(pMnode, pOld1);
|
||||||
mndReleaseDnode(pMnode, pOld2);
|
mndReleaseDnode(pMnode, pOld2);
|
||||||
mndReleaseDnode(pMnode, pOld3);
|
mndReleaseDnode(pMnode, pOld3);
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
|
||||||
|
@ -1496,7 +1489,6 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
int32_t vgId = 2;
|
int32_t vgId = 2;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
|
||||||
|
@ -1508,19 +1500,12 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
|
||||||
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
|
||||||
if (pDb == NULL) goto _OVER;
|
if (pDb == NULL) goto _OVER;
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_SPLIT_VGROUP) != 0) goto _OVER;
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
|
||||||
|
|
||||||
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
code = mndSplitVgroup(pMnode, pReq, pDb, pVgroup);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
return code;
|
return code;
|
||||||
|
@ -1633,19 +1618,13 @@ _OVER:
|
||||||
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
|
static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
|
||||||
SArray *pArray = NULL;
|
SArray *pArray = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
mDebug("start to balance vgroup");
|
mDebug("start to balance vgroup");
|
||||||
pUser = mndAcquireUser(pMnode, pReq->conn.user);
|
|
||||||
if (pUser == NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndCheckNodeAuth(pUser) != 0) goto _OVER;
|
if (mndCheckOperAuth(pMnode, pReq->conn.user, MND_OPER_BALANCE_VGROUP) != 0) goto _OVER;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
|
@ -1676,7 +1655,6 @@ _OVER:
|
||||||
mError("failed to balance vgroup since %s", terrstr());
|
mError("failed to balance vgroup since %s", terrstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseUser(pMnode, pUser);
|
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -375,6 +375,8 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
|
|
||||||
if (pTask->inputQueue == NULL || pTask->outputQueue == NULL) goto FAIL;
|
if (pTask->inputQueue == NULL || pTask->outputQueue == NULL) goto FAIL;
|
||||||
|
|
||||||
|
pTask->pMsgCb = &pTq->pVnode->msgCb;
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
if (pTask->execType != TASK_EXEC__NONE) {
|
if (pTask->execType != TASK_EXEC__NONE) {
|
||||||
// expand runners
|
// expand runners
|
||||||
|
@ -406,9 +408,12 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
tdGetSTSChemaFromSSChema(&pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols);
|
tdGetSTSChemaFromSSChema(&pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols);
|
||||||
ASSERT(pTask->tbSink.pTSchema);
|
ASSERT(pTask->tbSink.pTSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
streamSetupTrigger(pTask);
|
||||||
|
|
||||||
tqInfo("deploy stream task id %d child id %d on vg %d", pTask->taskId, pTask->childId, pTq->pVnode->config.vgId);
|
tqInfo("deploy stream task id %d child id %d on vg %d", pTask->taskId, pTask->childId, pTq->pVnode->config.vgId);
|
||||||
|
|
||||||
taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), pTask, sizeof(SStreamTask));
|
taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
FAIL:
|
FAIL:
|
||||||
|
@ -431,7 +436,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = taosHashIterate(pTq->pStreamTasks, pIter);
|
pIter = taosHashIterate(pTq->pStreamTasks, pIter);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
SStreamTask* pTask = (SStreamTask*)pIter;
|
SStreamTask* pTask = *(SStreamTask**)pIter;
|
||||||
if (pTask->inputType != STREAM_INPUT__DATA_SUBMIT) continue;
|
if (pTask->inputType != STREAM_INPUT__DATA_SUBMIT) continue;
|
||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
|
@ -439,7 +444,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamTriggerByWrite(pTask, pTq->pVnode->config.vgId, &pTq->pVnode->msgCb) < 0) {
|
if (streamLaunchByWrite(pTask, pTq->pVnode->config.vgId, &pTq->pVnode->msgCb) < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +464,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
//
|
//
|
||||||
SStreamTaskRunReq* pReq = pMsg->pCont;
|
SStreamTaskRunReq* pReq = pMsg->pCont;
|
||||||
int32_t taskId = pReq->taskId;
|
int32_t taskId = pReq->taskId;
|
||||||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
streamTaskProcessRunReq(pTask, &pTq->pVnode->msgCb);
|
streamTaskProcessRunReq(pTask, &pTq->pVnode->msgCb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -473,7 +478,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
tDecoderInit(&decoder, msgBody, msgLen);
|
tDecoderInit(&decoder, msgBody, msgLen);
|
||||||
tDecodeStreamDispatchReq(&decoder, &req);
|
tDecodeStreamDispatchReq(&decoder, &req);
|
||||||
int32_t taskId = req.taskId;
|
int32_t taskId = req.taskId;
|
||||||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.info = pMsg->info,
|
.info = pMsg->info,
|
||||||
.code = 0,
|
.code = 0,
|
||||||
|
@ -485,7 +490,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
SStreamTaskRecoverReq* pReq = pMsg->pCont;
|
||||||
int32_t taskId = pReq->taskId;
|
int32_t taskId = pReq->taskId;
|
||||||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
streamProcessRecoverReq(pTask, &pTq->pVnode->msgCb, pReq, pMsg);
|
streamProcessRecoverReq(pTask, &pTq->pVnode->msgCb, pReq, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +498,7 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
int32_t taskId = pRsp->taskId;
|
int32_t taskId = pRsp->taskId;
|
||||||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
streamProcessDispatchRsp(pTask, &pTq->pVnode->msgCb, pRsp);
|
streamProcessDispatchRsp(pTask, &pTq->pVnode->msgCb, pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +506,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
SStreamTaskRecoverRsp* pRsp = pMsg->pCont;
|
||||||
int32_t taskId = pRsp->taskId;
|
int32_t taskId = pRsp->taskId;
|
||||||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||||
streamProcessRecoverRsp(pTask, pRsp);
|
streamProcessRecoverRsp(pTask, pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
int32_t ret = TAOS_SYNC_OTHER_ERROR;
|
int32_t ret = 0;
|
||||||
|
|
||||||
if (syncEnvIsStart()) {
|
if (syncEnvIsStart()) {
|
||||||
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
||||||
|
@ -381,15 +381,18 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
||||||
ret = TAOS_SYNC_OTHER_ERROR;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
} else {
|
} else {
|
||||||
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
||||||
ret = TAOS_SYNC_OTHER_ERROR;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
vnodeAccumBlockMsg(pVnode, pMsg->msgType);
|
||||||
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
|
||||||
|
} else if (code == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
SEpSet newEpSet = {0};
|
SEpSet newEpSet = {0};
|
||||||
syncGetEpSet(pVnode->sync, &newEpSet);
|
syncGetEpSet(pVnode->sync, &newEpSet);
|
||||||
SEp *pEp = &newEpSet.eps[newEpSet.inUse];
|
SEp *pEp = &newEpSet.eps[newEpSet.inUse];
|
||||||
|
@ -247,29 +248,17 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) {
|
int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
|
int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) {
|
int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
|
int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
||||||
|
|
|
@ -1899,7 +1899,7 @@ _return:
|
||||||
|
|
||||||
|
|
||||||
void ctgUpdateThreadUnexpectedStopped(void) {
|
void ctgUpdateThreadUnexpectedStopped(void) {
|
||||||
if (CTG_IS_LOCKED(&gCtgMgmt.lock) > 0) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock);
|
if (!atomic_load_8((int8_t*)&gCtgMgmt.exit) && CTG_IS_LOCKED(&gCtgMgmt.lock) > 0) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgCleanupCacheQueue(void) {
|
void ctgCleanupCacheQueue(void) {
|
||||||
|
|
|
@ -365,7 +365,9 @@ typedef struct SCatchSupporter {
|
||||||
} SCatchSupporter;
|
} SCatchSupporter;
|
||||||
|
|
||||||
typedef struct SStreamAggSupporter {
|
typedef struct SStreamAggSupporter {
|
||||||
SArray* pResultRows;
|
SHashObj* pResultRows;
|
||||||
|
SArray* pCurWins;
|
||||||
|
int32_t valueSize;
|
||||||
int32_t keySize;
|
int32_t keySize;
|
||||||
char* pKeyBuf; // window key buffer
|
char* pKeyBuf; // window key buffer
|
||||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||||
|
@ -899,9 +901,9 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
|
||||||
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
|
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
|
||||||
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey,
|
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey,
|
||||||
SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t size);
|
SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t size);
|
||||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize);
|
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize);
|
||||||
SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap, int32_t* pIndex);
|
SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, int64_t gap, int32_t* pIndex);
|
||||||
int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows,
|
int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows,
|
||||||
int32_t start, int64_t gap, SHashObj* pStDeleted);
|
int32_t start, int64_t gap, SHashObj* pStDeleted);
|
||||||
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, bool assignUid, char* id) {
|
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, bool assignUid,
|
||||||
|
char* id) {
|
||||||
ASSERT(pOperator != NULL);
|
ASSERT(pOperator != NULL);
|
||||||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
if (pOperator->numOfDownstream == 0) {
|
if (pOperator->numOfDownstream == 0) {
|
||||||
|
@ -43,6 +44,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
if (pInfo->blockType == 0) {
|
if (pInfo->blockType == 0) {
|
||||||
pInfo->blockType = type;
|
pInfo->blockType = type;
|
||||||
} else if (pInfo->blockType != type) {
|
} else if (pInfo->blockType != type) {
|
||||||
|
ASSERT(0);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
qError("submit msg messed up when initing stream block, %s" PRIx64, id);
|
qError("submit msg messed up when initing stream block, %s" PRIx64, id);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (type == STREAM_DATA_TYPE_SSDATA_BLOCK) {
|
||||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||||
|
|
||||||
|
@ -62,6 +64,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock);
|
||||||
taosArrayPush(pInfo->pBlockLists, &p);
|
taosArrayPush(pInfo->pBlockLists, &p);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -83,7 +87,8 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
||||||
|
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, assignUid, GET_TASKID(pTaskInfo));
|
int32_t code =
|
||||||
|
doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, assignUid, GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
||||||
} else {
|
} else {
|
||||||
|
@ -178,9 +183,10 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t* tversion) {
|
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
|
||||||
|
int32_t* tversion) {
|
||||||
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
|
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*) tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
*sversion = pTaskInfo->schemaVer.sversion;
|
*sversion = pTaskInfo->schemaVer.sversion;
|
||||||
*tversion = pTaskInfo->schemaVer.tversion;
|
*tversion = pTaskInfo->schemaVer.tversion;
|
||||||
|
|
|
@ -4814,6 +4814,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
.calTrigger = pIntervalPhyNode->window.triggerType,
|
.calTrigger = pIntervalPhyNode->window.triggerType,
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
|
ASSERT(as.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
||||||
|
|
||||||
int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
bool isStream = (QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type);
|
bool isStream = (QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type);
|
||||||
|
@ -5498,14 +5499,16 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput,
|
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput,
|
||||||
size_t size) {
|
int32_t size) {
|
||||||
pSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
pSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
||||||
pSup->keySize = sizeof(int64_t) + sizeof(TSKEY);
|
pSup->keySize = sizeof(int64_t) + sizeof(TSKEY);
|
||||||
pSup->pKeyBuf = taosMemoryCalloc(1, pSup->keySize);
|
pSup->pKeyBuf = taosMemoryCalloc(1, pSup->keySize);
|
||||||
pSup->pResultRows = taosArrayInit(1024, size);
|
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||||
|
pSup->pResultRows = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
|
||||||
if (pSup->pKeyBuf == NULL || pSup->pResultRows == NULL) {
|
if (pSup->pKeyBuf == NULL || pSup->pResultRows == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
pSup->valueSize = size;
|
||||||
|
|
||||||
pSup->pScanWindow = taosArrayInit(4, sizeof(STimeWindow));
|
pSup->pScanWindow = taosArrayInit(4, sizeof(STimeWindow));
|
||||||
|
|
||||||
|
|
|
@ -716,7 +716,7 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
|
||||||
int64_t gap = pInfo->sessionSup.gap;
|
int64_t gap = pInfo->sessionSup.gap;
|
||||||
int32_t winIndex = 0;
|
int32_t winIndex = 0;
|
||||||
SResultWindowInfo* pCurWin =
|
SResultWindowInfo* pCurWin =
|
||||||
getSessionTimeWindow(pAggSup->pResultRows, tsCols[pInfo->updateResIndex], gap, &winIndex);
|
getSessionTimeWindow(pAggSup, tsCols[pInfo->updateResIndex], pSDB->info.groupId, gap, &winIndex);
|
||||||
win = pCurWin->win;
|
win = pCurWin->win;
|
||||||
pInfo->updateResIndex +=
|
pInfo->updateResIndex +=
|
||||||
updateSessionWindowInfo(pCurWin, tsCols, pSDB->info.rows, pInfo->updateResIndex, gap, NULL);
|
updateSessionWindowInfo(pCurWin, tsCols, pSDB->info.rows, pInfo->updateResIndex, gap, NULL);
|
||||||
|
|
|
@ -1320,6 +1320,15 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
|
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval, 0, pOperator->numOfExprs, pBlock, NULL);
|
||||||
|
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
|
||||||
|
continue;
|
||||||
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
|
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
|
// The timewindow 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
|
||||||
|
@ -1328,16 +1337,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
setInverFunction(pInfo->binfo.pCtx, pOperator->numOfExprs, pBlock->info.type);
|
setInverFunction(pInfo->binfo.pCtx, pOperator->numOfExprs, pBlock->info.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
|
||||||
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval, 0, pOperator->numOfExprs, pBlock, NULL);
|
|
||||||
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
|
|
||||||
continue;
|
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL &&
|
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) {
|
|
||||||
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated);
|
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated);
|
||||||
}
|
}
|
||||||
|
@ -2038,7 +2037,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
SArray* pUpWins = taosArrayInit(8, sizeof(STimeWindow));
|
SArray* pUpWins = taosArrayInit(8, sizeof(STimeWindow));
|
||||||
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval, pInfo->primaryTsIndex, pOperator->numOfExprs,
|
doClearWindows(&pInfo->aggSup, &pInfo->binfo, &pInfo->interval, pInfo->primaryTsIndex, pOperator->numOfExprs,
|
||||||
|
@ -2058,12 +2056,12 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
copyUpdateDataBlock(pInfo->pUpdateRes, pBlock, pInfo->primaryTsIndex);
|
copyUpdateDataBlock(pInfo->pUpdateRes, pBlock, pInfo->primaryTsIndex);
|
||||||
taosArrayDestroy(pUpWins);
|
taosArrayDestroy(pUpWins);
|
||||||
break;
|
break;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL && isFinalInterval(pInfo) &&
|
} else if (pBlock->info.type == STREAM_GET_ALL && isFinalInterval(pInfo)) {
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) {
|
|
||||||
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated);
|
getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdated);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
|
||||||
if (isFinalInterval(pInfo)) {
|
if (isFinalInterval(pInfo)) {
|
||||||
int32_t chIndex = getChildIndex(pBlock);
|
int32_t chIndex = getChildIndex(pBlock);
|
||||||
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
int32_t size = taosArrayGetSize(pInfo->pChildren);
|
||||||
|
@ -2125,6 +2123,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
||||||
.calTrigger = pIntervalPhyNode->window.triggerType,
|
.calTrigger = pIntervalPhyNode->window.triggerType,
|
||||||
.maxTs = INT64_MIN,
|
.maxTs = INT64_MIN,
|
||||||
};
|
};
|
||||||
|
ASSERT(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY);
|
||||||
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
initResultSizeInfo(pOperator, 4096);
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
@ -2190,8 +2189,13 @@ _error:
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyStreamAggSupporter(SStreamAggSupporter* pSup) {
|
void destroyStreamAggSupporter(SStreamAggSupporter* pSup) {
|
||||||
taosArrayDestroy(pSup->pResultRows);
|
|
||||||
taosMemoryFreeClear(pSup->pKeyBuf);
|
taosMemoryFreeClear(pSup->pKeyBuf);
|
||||||
|
void **pIte = NULL;
|
||||||
|
while ((pIte = taosHashIterate(pSup->pResultRows, pIte)) != NULL) {
|
||||||
|
SArray *pWins = (SArray *) (*pIte);
|
||||||
|
taosArrayDestroy(pWins);
|
||||||
|
}
|
||||||
|
taosHashCleanup(pSup->pResultRows);
|
||||||
destroyDiskbasedBuf(pSup->pResultBuf);
|
destroyDiskbasedBuf(pSup->pResultBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2333,7 +2337,22 @@ static SResultWindowInfo* addNewSessionWindow(SArray* pWinInfos, TSKEY ts) {
|
||||||
return taosArrayPush(pWinInfos, &win);
|
return taosArrayPush(pWinInfos, &win);
|
||||||
}
|
}
|
||||||
|
|
||||||
SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap, int32_t* pIndex) {
|
SArray* getWinInfos(SStreamAggSupporter* pAggSup, uint64_t groupId) {
|
||||||
|
void** ite = taosHashGet(pAggSup->pResultRows, &groupId, sizeof(uint64_t));
|
||||||
|
SArray* pWinInfos = NULL;
|
||||||
|
if (ite == NULL) {
|
||||||
|
pWinInfos = taosArrayInit(1024, pAggSup->valueSize);
|
||||||
|
taosHashPut(pAggSup->pResultRows, &groupId, sizeof(uint64_t), &pWinInfos, sizeof(void *));
|
||||||
|
} else {
|
||||||
|
pWinInfos = *ite;
|
||||||
|
}
|
||||||
|
return pWinInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, int64_t gap, int32_t* pIndex) {
|
||||||
|
SArray* pWinInfos = getWinInfos(pAggSup, groupId);
|
||||||
|
pAggSup->pCurWins = pWinInfos;
|
||||||
|
|
||||||
int32_t size = taosArrayGetSize(pWinInfos);
|
int32_t size = taosArrayGetSize(pWinInfos);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
*pIndex = 0;
|
*pIndex = 0;
|
||||||
|
@ -2389,7 +2408,7 @@ static int32_t setWindowOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pRes
|
||||||
SStreamAggSupporter* pAggSup, SExecTaskInfo* pTaskInfo) {
|
SStreamAggSupporter* pAggSup, SExecTaskInfo* pTaskInfo) {
|
||||||
assert(pWinInfo->win.skey <= pWinInfo->win.ekey);
|
assert(pWinInfo->win.skey <= pWinInfo->win.ekey);
|
||||||
// too many time window in query
|
// too many time window in query
|
||||||
int32_t size = taosArrayGetSize(pAggSup->pResultRows);
|
int32_t size = taosArrayGetSize(pAggSup->pCurWins);
|
||||||
if (size > MAX_INTERVAL_TIME_WINDOW) {
|
if (size > MAX_INTERVAL_TIME_WINDOW) {
|
||||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW);
|
longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW);
|
||||||
}
|
}
|
||||||
|
@ -2449,25 +2468,6 @@ static int32_t doOneStateWindowAgg(SStreamStateAggOperatorInfo* pInfo, SSDataBlo
|
||||||
pSDataBlock, pCurWin, pResult, startIndex, winRows, numOutput, pTaskInfo);
|
pSDataBlock, pCurWin, pResult, startIndex, winRows, numOutput, pTaskInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t copyWinInfoToDataBlock(SSDataBlock* pBlock, SStreamAggSupporter* pAggSup, int32_t start, int32_t num,
|
|
||||||
int32_t numOfExprs, SOptrBasicInfo* pBinfo) {
|
|
||||||
for (int32_t i = start; i < num; i += 1) {
|
|
||||||
SResultWindowInfo* pWinInfo = taosArrayGet(pAggSup->pResultRows, start);
|
|
||||||
SFilePage* bufPage = getBufPage(pAggSup->pResultBuf, pWinInfo->pos.pageId);
|
|
||||||
SResultRow* pRow = (SResultRow*)((char*)bufPage + pWinInfo->pos.offset);
|
|
||||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
|
||||||
SResultRowEntryInfo* pResultInfo = getResultCell(pRow, j, pBinfo->rowCellInfoOffset);
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, j);
|
|
||||||
char* in = GET_ROWCELL_INTERBUF(pBinfo->pCtx[j].resultInfo);
|
|
||||||
colDataAppend(pColInfoData, pBlock->info.rows, in, pResultInfo->isNullRes);
|
|
||||||
}
|
|
||||||
pBlock->info.rows += pRow->numOfRows;
|
|
||||||
releaseBufPage(pAggSup->pResultBuf, bufPage);
|
|
||||||
}
|
|
||||||
blockDataUpdateTsWindow(pBlock, -1);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getNumCompactWindow(SArray* pWinInfos, int32_t startIndex, int64_t gap) {
|
int32_t getNumCompactWindow(SArray* pWinInfos, int32_t startIndex, int64_t gap) {
|
||||||
SResultWindowInfo* pCurWin = taosArrayGet(pWinInfos, startIndex);
|
SResultWindowInfo* pCurWin = taosArrayGet(pWinInfos, startIndex);
|
||||||
int32_t size = taosArrayGetSize(pWinInfos);
|
int32_t size = taosArrayGetSize(pWinInfos);
|
||||||
|
@ -2484,15 +2484,15 @@ int32_t getNumCompactWindow(SArray* pWinInfos, int32_t startIndex, int64_t gap)
|
||||||
|
|
||||||
void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex, int32_t num, int32_t groupId,
|
void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex, int32_t num, int32_t groupId,
|
||||||
int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SHashObj* pStUpdated, SHashObj* pStDeleted) {
|
int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SHashObj* pStUpdated, SHashObj* pStDeleted) {
|
||||||
SResultWindowInfo* pCurWin = taosArrayGet(pInfo->streamAggSup.pResultRows, startIndex);
|
SResultWindowInfo* pCurWin = taosArrayGet(pInfo->streamAggSup.pCurWins, startIndex);
|
||||||
SResultRow* pCurResult = NULL;
|
SResultRow* pCurResult = NULL;
|
||||||
setWindowOutputBuf(pCurWin, &pCurResult, pInfo->binfo.pCtx, groupId, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
setWindowOutputBuf(pCurWin, &pCurResult, pInfo->binfo.pCtx, groupId, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
||||||
&pInfo->streamAggSup, pTaskInfo);
|
&pInfo->streamAggSup, pTaskInfo);
|
||||||
num += startIndex + 1;
|
num += startIndex + 1;
|
||||||
ASSERT(num <= taosArrayGetSize(pInfo->streamAggSup.pResultRows));
|
ASSERT(num <= taosArrayGetSize(pInfo->streamAggSup.pCurWins));
|
||||||
// Just look for the window behind StartIndex
|
// Just look for the window behind StartIndex
|
||||||
for (int32_t i = startIndex + 1; i < num; i++) {
|
for (int32_t i = startIndex + 1; i < num; i++) {
|
||||||
SResultWindowInfo* pWinInfo = taosArrayGet(pInfo->streamAggSup.pResultRows, i);
|
SResultWindowInfo* pWinInfo = taosArrayGet(pInfo->streamAggSup.pCurWins, i);
|
||||||
SResultRow* pWinResult = NULL;
|
SResultRow* pWinResult = NULL;
|
||||||
setWindowOutputBuf(pWinInfo, &pWinResult, pInfo->pDummyCtx, groupId, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
setWindowOutputBuf(pWinInfo, &pWinResult, pInfo->pDummyCtx, groupId, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
||||||
&pInfo->streamAggSup, pTaskInfo);
|
&pInfo->streamAggSup, pTaskInfo);
|
||||||
|
@ -2503,7 +2503,7 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
|
||||||
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &pWinInfo->win.skey, sizeof(TSKEY));
|
taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &pWinInfo->win.skey, sizeof(TSKEY));
|
||||||
pWinInfo->isOutput = false;
|
pWinInfo->isOutput = false;
|
||||||
}
|
}
|
||||||
taosArrayRemove(pInfo->streamAggSup.pResultRows, i);
|
taosArrayRemove(pInfo->streamAggSup.pCurWins, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2533,7 +2533,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||||
for (int32_t i = 0; i < pSDataBlock->info.rows;) {
|
for (int32_t i = 0; i < pSDataBlock->info.rows;) {
|
||||||
int32_t winIndex = 0;
|
int32_t winIndex = 0;
|
||||||
SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup->pResultRows, tsCols[i], gap, &winIndex);
|
SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, tsCols[i], pSDataBlock->info.groupId, gap, &winIndex);
|
||||||
winRows = updateSessionWindowInfo(pCurWin, tsCols, pSDataBlock->info.rows, i, pInfo->gap, pStDeleted);
|
winRows = updateSessionWindowInfo(pCurWin, tsCols, pSDataBlock->info.rows, i, pInfo->gap, pStDeleted);
|
||||||
code = doOneWindowAgg(pInfo, pSDataBlock, pCurWin, &pResult, i, winRows, numOfOutput, pTaskInfo);
|
code = doOneWindowAgg(pInfo, pSDataBlock, pCurWin, &pResult, i, winRows, numOfOutput, pTaskInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||||
|
@ -2543,7 +2543,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
||||||
// doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos,
|
// doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos,
|
||||||
// forwardRows,
|
// forwardRows,
|
||||||
// pInfo->order, false);
|
// pInfo->order, false);
|
||||||
int32_t winNum = getNumCompactWindow(pAggSup->pResultRows, winIndex, gap);
|
int32_t winNum = getNumCompactWindow(pAggSup->pCurWins, winIndex, gap);
|
||||||
if (winNum > 0) {
|
if (winNum > 0) {
|
||||||
compactTimeWindow(pInfo, winIndex, winNum, groupId, numOfOutput, pTaskInfo, pStUpdated, pStDeleted);
|
compactTimeWindow(pInfo, winIndex, winNum, groupId, numOfOutput, pTaskInfo, pStUpdated, pStDeleted);
|
||||||
}
|
}
|
||||||
|
@ -2566,7 +2566,7 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SOptrBasicInfo*
|
||||||
int32_t step = 0;
|
int32_t step = 0;
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||||
int32_t winIndex = 0;
|
int32_t winIndex = 0;
|
||||||
SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup->pResultRows, tsCols[i], gap, &winIndex);
|
SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, tsCols[i], pBlock->info.groupId, gap, &winIndex);
|
||||||
step = updateSessionWindowInfo(pCurWin, tsCols, pBlock->info.rows, i, gap, NULL);
|
step = updateSessionWindowInfo(pCurWin, tsCols, pBlock->info.rows, i, gap, NULL);
|
||||||
ASSERT(isInWindow(pCurWin, tsCols[i], gap));
|
ASSERT(isInWindow(pCurWin, tsCols[i], gap));
|
||||||
doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pBinfo, numOfOutput);
|
doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pBinfo, numOfOutput);
|
||||||
|
@ -2627,7 +2627,7 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
|
||||||
for (int32_t j = 0; j < numOfChildren; j++) {
|
for (int32_t j = 0; j < numOfChildren; j++) {
|
||||||
SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j);
|
SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j);
|
||||||
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
|
||||||
SArray* pChWins = pChInfo->streamAggSup.pResultRows;
|
SArray* pChWins = getWinInfos(&pChInfo->streamAggSup, groupId);
|
||||||
int32_t chWinSize = taosArrayGetSize(pChWins);
|
int32_t chWinSize = taosArrayGetSize(pChWins);
|
||||||
int32_t index = binarySearch(pChWins, chWinSize, pParentWin->win.skey, TSDB_ORDER_DESC, getSessionWindowEndkey);
|
int32_t index = binarySearch(pChWins, chWinSize, pParentWin->win.skey, TSDB_ORDER_DESC, getSessionWindowEndkey);
|
||||||
for (int32_t k = index; k > 0 && k < chWinSize; k++) {
|
for (int32_t k = index; k > 0 && k < chWinSize; k++) {
|
||||||
|
@ -2651,9 +2651,12 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*);
|
||||||
SResultWindowInfo* getSessionWinInfo(void* pData) { return (SResultWindowInfo*)pData; }
|
SResultWindowInfo* getSessionWinInfo(void* pData) { return (SResultWindowInfo*)pData; }
|
||||||
SResultWindowInfo* getStateWinInfo(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; }
|
SResultWindowInfo* getStateWinInfo(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; }
|
||||||
|
|
||||||
int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pClosed,
|
int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed,
|
||||||
__get_win_info_ fn) {
|
__get_win_info_ fn) {
|
||||||
// Todo(liuyao) save window to tdb
|
// Todo(liuyao) save window to tdb
|
||||||
|
void **pIte = NULL;
|
||||||
|
while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) {
|
||||||
|
SArray *pWins = (SArray *) (*pIte);
|
||||||
int32_t size = taosArrayGetSize(pWins);
|
int32_t size = taosArrayGetSize(pWins);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
void* pWin = taosArrayGet(pWins, i);
|
void* pWin = taosArrayGet(pWins, i);
|
||||||
|
@ -2670,10 +2673,14 @@ int32_t closeSessionWindow(SArray* pWins, STimeWindowAggSupp* pTwSup, SArray* pC
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getAllSessionWindow(SArray* pWins, SArray* pClosed, __get_win_info_ fn) {
|
int32_t getAllSessionWindow(SHashObj* pHashMap, SArray* pClosed, __get_win_info_ fn) {
|
||||||
|
void **pIte = NULL;
|
||||||
|
while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) {
|
||||||
|
SArray *pWins = (SArray *) (*pIte);
|
||||||
int32_t size = taosArrayGetSize(pWins);
|
int32_t size = taosArrayGetSize(pWins);
|
||||||
for (int32_t i = 0; i < size; i++) {
|
for (int32_t i = 0; i < size; i++) {
|
||||||
void* pWin = taosArrayGet(pWins, i);
|
void* pWin = taosArrayGet(pWins, i);
|
||||||
|
@ -2683,6 +2690,7 @@ int32_t getAllSessionWindow(SArray* pWins, SArray* pClosed, __get_win_info_ fn)
|
||||||
pSeWin->isOutput = true;
|
pSeWin->isOutput = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2714,8 +2722,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
|
||||||
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
|
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
|
||||||
doClearSessionWindows(&pInfo->streamAggSup, &pInfo->binfo, pBlock, 0, pOperator->numOfExprs, pInfo->gap, pWins);
|
doClearSessionWindows(&pInfo->streamAggSup, &pInfo->binfo, pBlock, 0, pOperator->numOfExprs, pInfo->gap, pWins);
|
||||||
|
@ -2729,12 +2736,13 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pWins);
|
taosArrayDestroy(pWins);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL &&
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) {
|
|
||||||
getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getSessionWinInfo);
|
getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getSessionWinInfo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
|
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
if (isFinalSession(pInfo)) {
|
if (isFinalSession(pInfo)) {
|
||||||
int32_t childIndex = 0; // Todo(liuyao) get child id from SSDataBlock
|
int32_t childIndex = 0; // Todo(liuyao) get child id from SSDataBlock
|
||||||
SOptrBasicInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
|
SOptrBasicInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
|
||||||
|
@ -2873,7 +2881,9 @@ bool isEqualStateKey(SStateWindowInfo* pWin, char* pKeyData) {
|
||||||
return pKeyData && compareVal(pKeyData, &pWin->stateKey);
|
return pKeyData && compareVal(pKeyData, &pWin->stateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
SStateWindowInfo* getStateWindowByTs(SArray* pWinInfos, TSKEY ts, int32_t* pIndex) {
|
SStateWindowInfo* getStateWindowByTs(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, int32_t* pIndex) {
|
||||||
|
SArray* pWinInfos = getWinInfos(pAggSup, groupId);
|
||||||
|
pAggSup->pCurWins = pWinInfos;
|
||||||
int32_t size = taosArrayGetSize(pWinInfos);
|
int32_t size = taosArrayGetSize(pWinInfos);
|
||||||
int32_t index = binarySearch(pWinInfos, size, ts, TSDB_ORDER_DESC, getStateWinTsKey);
|
int32_t index = binarySearch(pWinInfos, size, ts, TSDB_ORDER_DESC, getStateWinTsKey);
|
||||||
SStateWindowInfo* pWin = NULL;
|
SStateWindowInfo* pWin = NULL;
|
||||||
|
@ -2896,7 +2906,10 @@ SStateWindowInfo* getStateWindowByTs(SArray* pWinInfos, TSKEY ts, int32_t* pInde
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStateWindowInfo* getStateWindow(SArray* pWinInfos, TSKEY ts, char* pKeyData, SColumn* pCol, int32_t* pIndex) {
|
SStateWindowInfo* getStateWindow(SStreamAggSupporter* pAggSup, TSKEY ts,
|
||||||
|
uint64_t groupId, char* pKeyData, SColumn* pCol, int32_t* pIndex) {
|
||||||
|
SArray* pWinInfos = getWinInfos(pAggSup, groupId);
|
||||||
|
pAggSup->pCurWins = pWinInfos;
|
||||||
int32_t size = taosArrayGetSize(pWinInfos);
|
int32_t size = taosArrayGetSize(pWinInfos);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
*pIndex = 0;
|
*pIndex = 0;
|
||||||
|
@ -2987,16 +3000,16 @@ static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
for (int32_t i = 0; i < pBlock->info.rows; i += step) {
|
||||||
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
||||||
int32_t winIndex = 0;
|
int32_t winIndex = 0;
|
||||||
SStateWindowInfo* pCurWin = getStateWindowByTs(pAggSup->pResultRows, tsCol[i], &winIndex);
|
SStateWindowInfo* pCurWin = getStateWindowByTs(pAggSup, tsCol[i], pBlock->info.groupId, &winIndex);
|
||||||
if (!pCurWin) {
|
if (!pCurWin) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
step = updateStateWindowInfo(pAggSup->pResultRows, winIndex, tsCol, pKeyColInfo, pBlock->info.rows, i, &allEqual,
|
step = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCol, pKeyColInfo, pBlock->info.rows, i, &allEqual,
|
||||||
pSeDeleted);
|
pSeDeleted);
|
||||||
ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData));
|
ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData));
|
||||||
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
||||||
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
||||||
deleteWindow(pAggSup->pResultRows, winIndex);
|
deleteWindow(pAggSup->pCurWins, winIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3026,13 +3039,15 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
||||||
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
char* pKeyData = colDataGetData(pKeyColInfo, i);
|
||||||
int32_t winIndex = 0;
|
int32_t winIndex = 0;
|
||||||
bool allEqual = true;
|
bool allEqual = true;
|
||||||
SStateWindowInfo* pCurWin = getStateWindow(pAggSup->pResultRows, tsCols[i], pKeyData, &pInfo->stateCol, &winIndex);
|
SStateWindowInfo* pCurWin =
|
||||||
winRows = updateStateWindowInfo(pAggSup->pResultRows, winIndex, tsCols, pKeyColInfo, pSDataBlock->info.rows, i,
|
getStateWindow(pAggSup, tsCols[i], pSDataBlock->info.groupId, pKeyData,
|
||||||
&allEqual, pInfo->pSeDeleted);
|
&pInfo->stateCol, &winIndex);
|
||||||
|
winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, pKeyColInfo,
|
||||||
|
pSDataBlock->info.rows, i, &allEqual, pInfo->pSeDeleted);
|
||||||
if (!allEqual) {
|
if (!allEqual) {
|
||||||
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win);
|
||||||
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
|
||||||
deleteWindow(pAggSup->pResultRows, winIndex);
|
deleteWindow(pAggSup->pCurWins, winIndex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows, numOfOutput, pTaskInfo);
|
code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows, numOfOutput, pTaskInfo);
|
||||||
|
@ -3079,17 +3094,18 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
|
||||||
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
|
||||||
if (pBlock->info.type == STREAM_REPROCESS) {
|
if (pBlock->info.type == STREAM_REPROCESS) {
|
||||||
doClearStateWindows(&pInfo->streamAggSup, pBlock, pInfo->primaryTsIndex, &pInfo->stateCol, pInfo->stateCol.slotId,
|
doClearStateWindows(&pInfo->streamAggSup, pBlock, pInfo->primaryTsIndex, &pInfo->stateCol, pInfo->stateCol.slotId,
|
||||||
pSeUpdated, pInfo->pSeDeleted);
|
pSeUpdated, pInfo->pSeDeleted);
|
||||||
continue;
|
continue;
|
||||||
} else if (pBlock->info.type == STREAM_GET_ALL &&
|
} else if (pBlock->info.type == STREAM_GET_ALL) {
|
||||||
pInfo->twAggSup.calTrigger == STREAM_TRIGGER_MAX_DELAY) {
|
|
||||||
getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getStateWinInfo);
|
getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getStateWinInfo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
|
setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
|
||||||
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
|
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1682,7 +1682,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "top",
|
.name = "top",
|
||||||
.type = FUNCTION_TYPE_TOP,
|
.type = FUNCTION_TYPE_TOP,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
.translateFunc = translateTopBot,
|
.translateFunc = translateTopBot,
|
||||||
.getEnvFunc = getTopBotFuncEnv,
|
.getEnvFunc = getTopBotFuncEnv,
|
||||||
.initFunc = topBotFunctionSetup,
|
.initFunc = topBotFunctionSetup,
|
||||||
|
@ -1717,7 +1717,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "bottom",
|
.name = "bottom",
|
||||||
.type = FUNCTION_TYPE_BOTTOM,
|
.type = FUNCTION_TYPE_BOTTOM,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC,
|
||||||
.translateFunc = translateTopBot,
|
.translateFunc = translateTopBot,
|
||||||
.getEnvFunc = getTopBotFuncEnv,
|
.getEnvFunc = getTopBotFuncEnv,
|
||||||
.initFunc = topBotFunctionSetup,
|
.initFunc = topBotFunctionSetup,
|
||||||
|
|
|
@ -2385,6 +2385,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t type = pInputCol->info.type;
|
||||||
int32_t bytes = pInputCol->info.bytes;
|
int32_t bytes = pInputCol->info.bytes;
|
||||||
pInfo->bytes = bytes;
|
pInfo->bytes = bytes;
|
||||||
|
|
||||||
|
@ -2421,6 +2422,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
|
|
||||||
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) {
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) {
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
memcpy(pInfo->buf, data, bytes);
|
memcpy(pInfo->buf, data, bytes);
|
||||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
|
@ -2451,6 +2456,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
|
|
||||||
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) {
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) > cts) {
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
memcpy(pInfo->buf, data, bytes);
|
memcpy(pInfo->buf, data, bytes);
|
||||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
|
@ -2474,6 +2483,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
SInputColumnInfoData* pInput = &pCtx->input;
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
|
||||||
|
int32_t type = pInputCol->info.type;
|
||||||
int32_t bytes = pInputCol->info.bytes;
|
int32_t bytes = pInputCol->info.bytes;
|
||||||
pInfo->bytes = bytes;
|
pInfo->bytes = bytes;
|
||||||
|
|
||||||
|
@ -2501,6 +2511,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) {
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) {
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
memcpy(pInfo->buf, data, bytes);
|
memcpy(pInfo->buf, data, bytes);
|
||||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
||||||
// DO_UPDATE_TAG_COLUMNS(pCtx, ts);
|
// DO_UPDATE_TAG_COLUMNS(pCtx, ts);
|
||||||
|
@ -2520,6 +2534,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
||||||
char* data = colDataGetData(pInputCol, i);
|
char* data = colDataGetData(pInputCol, i);
|
||||||
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
TSKEY cts = getRowPTs(pInput->pPTS, i);
|
||||||
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) {
|
if (pResInfo->numOfRes == 0 || *(TSKEY*)(pInfo->buf + bytes) < cts) {
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
bytes = varDataTLen(data);
|
||||||
|
pInfo->bytes = bytes;
|
||||||
|
}
|
||||||
memcpy(pInfo->buf, data, bytes);
|
memcpy(pInfo->buf, data, bytes);
|
||||||
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
*(TSKEY*)(pInfo->buf + bytes) = cts;
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
|
|
|
@ -1117,6 +1117,7 @@ static const char* jkLogicSubplanVgroupsSize = "VgroupsSize";
|
||||||
static const char* jkLogicSubplanVgroups = "Vgroups";
|
static const char* jkLogicSubplanVgroups = "Vgroups";
|
||||||
static const char* jkLogicSubplanLevel = "Level";
|
static const char* jkLogicSubplanLevel = "Level";
|
||||||
static const char* jkLogicSubplanSplitFlag = "SplitFlag";
|
static const char* jkLogicSubplanSplitFlag = "SplitFlag";
|
||||||
|
static const char* jkLogicSubplanNumOfComputeNodes = "NumOfComputeNodes";
|
||||||
|
|
||||||
static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
||||||
const SLogicSubplan* pNode = (const SLogicSubplan*)pObj;
|
const SLogicSubplan* pNode = (const SLogicSubplan*)pObj;
|
||||||
|
@ -1143,6 +1144,9 @@ static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanSplitFlag, pNode->splitFlag);
|
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanSplitFlag, pNode->splitFlag);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanNumOfComputeNodes, pNode->numOfComputeNodes);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1163,6 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType, code);
|
tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType, code);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
int32_t objSize = 0;
|
int32_t objSize = 0;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -1174,6 +1177,9 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkLogicSubplanSplitFlag, &pNode->splitFlag);
|
code = tjsonGetIntValue(pJson, jkLogicSubplanSplitFlag, &pNode->splitFlag);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetIntValue(pJson, jkLogicSubplanNumOfComputeNodes, &pNode->numOfComputeNodes);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3257,6 +3257,8 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
||||||
strcpy(createReq.user, pStmt->useName);
|
strcpy(createReq.user, pStmt->useName);
|
||||||
createReq.createType = 0;
|
createReq.createType = 0;
|
||||||
createReq.superUser = 0;
|
createReq.superUser = 0;
|
||||||
|
createReq.sysInfo = 1;
|
||||||
|
createReq.enable = 1;
|
||||||
strcpy(createReq.pass, pStmt->password);
|
strcpy(createReq.pass, pStmt->password);
|
||||||
|
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq);
|
return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq);
|
||||||
|
|
|
@ -115,7 +115,45 @@ static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
static int32_t scaleOutForCompute(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
for (int32_t i = 0; i < pSubplan->numOfComputeNodes; ++i) {
|
||||||
|
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||||
|
if (NULL == pNewSubplan) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlanForCompute(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
SNode* pParent = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
FORBOTH(pChild, pCurrentGroup, pParent, pParentsGroup) {
|
||||||
|
code = nodesListMakeAppend(&(((SLogicSubplan*)pParent)->pChildren), pChild);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeAppend(&(((SLogicSubplan*)pChild)->pParents), pParent);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isComputeGroup(SNodeList* pGroup) {
|
||||||
|
if (0 == LIST_LENGTH(pGroup)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return SUBPLAN_TYPE_COMPUTE == ((SLogicSubplan*)nodesListGetNode(pGroup, 0))->subplanType;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlanForNormal(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
bool topLevel = (0 == LIST_LENGTH(pParentsGroup));
|
bool topLevel = (0 == LIST_LENGTH(pParentsGroup));
|
||||||
SNode* pChild = NULL;
|
SNode* pChild = NULL;
|
||||||
|
@ -138,6 +176,13 @@ static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurren
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurrentGroup) {
|
||||||
|
if (isComputeGroup(pParentsGroup)) {
|
||||||
|
return pushHierarchicalPlanForCompute(pParentsGroup, pCurrentGroup);
|
||||||
|
}
|
||||||
|
return pushHierarchicalPlanForNormal(pParentsGroup, pCurrentGroup);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pParentsGroup) {
|
static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pParentsGroup) {
|
||||||
SNodeList* pCurrentGroup = nodesMakeList();
|
SNodeList* pCurrentGroup = nodesMakeList();
|
||||||
if (NULL == pCurrentGroup) {
|
if (NULL == pCurrentGroup) {
|
||||||
|
@ -155,6 +200,9 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
|
||||||
case SUBPLAN_TYPE_MODIFY:
|
case SUBPLAN_TYPE_MODIFY:
|
||||||
code = scaleOutForModify(pCxt, pSubplan, level, pCurrentGroup);
|
code = scaleOutForModify(pCxt, pSubplan, level, pCurrentGroup);
|
||||||
break;
|
break;
|
||||||
|
case SUBPLAN_TYPE_COMPUTE:
|
||||||
|
code = scaleOutForCompute(pCxt, pSubplan, level, pCurrentGroup);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,8 +994,20 @@ static int32_t qnodeSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
}
|
}
|
||||||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
|
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pSplitNode, 0));
|
SLogicSubplan* pScanSubplan = splCreateScanSubplan(pCxt, info.pSplitNode, 0);
|
||||||
|
if (NULL != pScanSubplan) {
|
||||||
|
if (NULL != info.pSubplan->pVgroupList) {
|
||||||
|
info.pSubplan->numOfComputeNodes = info.pSubplan->pVgroupList->numOfVgroups;
|
||||||
|
TSWAP(pScanSubplan->pVgroupList, info.pSubplan->pVgroupList);
|
||||||
|
} else {
|
||||||
|
info.pSubplan->numOfComputeNodes = 1;
|
||||||
}
|
}
|
||||||
|
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pScanSubplan);
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info.pSubplan->subplanType = SUBPLAN_TYPE_COMPUTE;
|
||||||
++(pCxt->groupId);
|
++(pCxt->groupId);
|
||||||
pCxt->split = true;
|
pCxt->split = true;
|
||||||
return code;
|
return code;
|
||||||
|
@ -1007,8 +1019,7 @@ static const SSplitRule splitRuleSet[] = {
|
||||||
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
|
{.pName = "SingleTableJoinSplit", .splitFunc = singleTableJoinSplit},
|
||||||
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
|
{.pName = "UnionAllSplit", .splitFunc = unionAllSplit},
|
||||||
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
|
{.pName = "UnionDistinctSplit", .splitFunc = unionDistinctSplit},
|
||||||
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit},
|
{.pName = "SmaIndexSplit", .splitFunc = smaIndexSplit}
|
||||||
{.pName = "QnodeSplit", .splitFunc = qnodeSplit}
|
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -1039,7 +1050,7 @@ static int32_t applySplitRule(SPlanContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (split);
|
} while (split);
|
||||||
return TSDB_CODE_SUCCESS;
|
return qnodeSplit(&cxt, pSubplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
|
static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t inited;
|
||||||
|
void* timer;
|
||||||
|
} SStreamGlobalEnv;
|
||||||
|
|
||||||
|
static SStreamGlobalEnv streamEnv;
|
||||||
|
|
||||||
int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb);
|
int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb);
|
||||||
int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb);
|
int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb);
|
||||||
int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData);
|
int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData);
|
||||||
|
|
|
@ -14,8 +14,74 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "streamInc.h"
|
#include "streamInc.h"
|
||||||
|
#include "ttimer.h"
|
||||||
|
|
||||||
int32_t streamTriggerByWrite(SStreamTask* pTask, int32_t vgId, SMsgCb* pMsgCb) {
|
int32_t streamInit() {
|
||||||
|
int8_t old;
|
||||||
|
while (1) {
|
||||||
|
old = atomic_val_compare_exchange_8(&streamEnv.inited, 0, 2);
|
||||||
|
if (old != 2) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old == 0) {
|
||||||
|
streamEnv.timer = taosTmrInit(10000, 100, 10000, "STREAM");
|
||||||
|
if (streamEnv.timer == NULL) {
|
||||||
|
atomic_store_8(&streamEnv.inited, 0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
atomic_store_8(&streamEnv.inited, 1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void streamCleanUp() {
|
||||||
|
int8_t old;
|
||||||
|
while (1) {
|
||||||
|
old = atomic_val_compare_exchange_8(&streamEnv.inited, 1, 2);
|
||||||
|
if (old != 2) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old == 1) {
|
||||||
|
taosTmrCleanUp(streamEnv.timer);
|
||||||
|
atomic_store_8(&streamEnv.inited, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void streamTriggerByTimer(void* param, void* tmrId) {
|
||||||
|
SStreamTask* pTask = (void*)param;
|
||||||
|
|
||||||
|
if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) {
|
||||||
|
SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM);
|
||||||
|
if (trigger == NULL) return;
|
||||||
|
trigger->type = STREAM_INPUT__TRIGGER;
|
||||||
|
trigger->pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
if (trigger->pBlock == NULL) {
|
||||||
|
taosFreeQitem(trigger);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
trigger->pBlock->info.type = STREAM_GET_ALL;
|
||||||
|
|
||||||
|
atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__IN_ACTIVE);
|
||||||
|
|
||||||
|
streamTaskInput(pTask, (SStreamQueueItem*)trigger);
|
||||||
|
streamLaunchByWrite(pTask, pTask->nodeId, pTask->pMsgCb);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosTmrReset(streamTriggerByTimer, (int32_t)pTask->triggerParam, pTask, streamEnv.timer, &pTask->timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamSetupTrigger(SStreamTask* pTask) {
|
||||||
|
if (pTask->triggerParam != 0) {
|
||||||
|
if (streamInit() < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pTask->timer = taosTmrStart(streamTriggerByTimer, (int32_t)pTask->triggerParam, pTask, streamEnv.timer);
|
||||||
|
pTask->triggerStatus = TASK_TRIGGER_STATUS__IN_ACTIVE;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId, SMsgCb* pMsgCb) {
|
||||||
int8_t execStatus = atomic_load_8(&pTask->status);
|
int8_t execStatus = atomic_load_8(&pTask->status);
|
||||||
if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) {
|
if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) {
|
||||||
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
|
SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq));
|
||||||
|
|
|
@ -20,15 +20,17 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
|
||||||
void* exec = pTask->exec.executor;
|
void* exec = pTask->exec.executor;
|
||||||
|
|
||||||
// set input
|
// set input
|
||||||
if (pTask->inputType == STREAM_INPUT__DATA_SUBMIT) {
|
SStreamQueueItem* pItem = (SStreamQueueItem*)data;
|
||||||
|
if (pItem->type == STREAM_INPUT__TRIGGER) {
|
||||||
|
SStreamTrigger* pTrigger = (SStreamTrigger*)data;
|
||||||
|
qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_DATA_TYPE_SSDATA_BLOCK, false);
|
||||||
|
} else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
|
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
|
||||||
ASSERT(pSubmit->type == STREAM_INPUT__DATA_SUBMIT);
|
ASSERT(pTask->inputType == STREAM_INPUT__DATA_SUBMIT);
|
||||||
|
|
||||||
qSetStreamInput(exec, pSubmit->data, STREAM_DATA_TYPE_SUBMIT_BLOCK, false);
|
qSetStreamInput(exec, pSubmit->data, STREAM_DATA_TYPE_SUBMIT_BLOCK, false);
|
||||||
} else if (pTask->inputType == STREAM_INPUT__DATA_BLOCK) {
|
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK) {
|
||||||
SStreamDataBlock* pBlock = (SStreamDataBlock*)data;
|
SStreamDataBlock* pBlock = (SStreamDataBlock*)data;
|
||||||
ASSERT(pBlock->type == STREAM_INPUT__DATA_BLOCK);
|
ASSERT(pTask->inputType == STREAM_INPUT__DATA_BLOCK);
|
||||||
|
|
||||||
SArray* blocks = pBlock->blocks;
|
SArray* blocks = pBlock->blocks;
|
||||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false);
|
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
if (tSerializeSUseDbRspImp(pEncoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1;
|
if (tSerializeSUseDbRspImp(pEncoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1;
|
||||||
/*if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
|
/*if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
|
||||||
}
|
}
|
||||||
|
if (tEncodeI64(pEncoder, pTask->triggerParam) < 0) return -1;
|
||||||
|
|
||||||
/*tEndEncode(pEncoder);*/
|
/*tEndEncode(pEncoder);*/
|
||||||
return pEncoder->pos;
|
return pEncoder->pos;
|
||||||
|
@ -121,6 +122,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
/*if (tDecodeI8(pDecoder, &pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
|
/*if (tDecodeI8(pDecoder, &pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
|
||||||
if (tDeserializeSUseDbRspImp(pDecoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1;
|
if (tDeserializeSUseDbRspImp(pDecoder, &pTask->shuffleDispatcher.dbInfo) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
if (tDecodeI64(pDecoder, &pTask->triggerParam) < 0) return -1;
|
||||||
|
|
||||||
/*tEndDecode(pDecoder);*/
|
/*tEndDecode(pDecoder);*/
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -149,12 +149,14 @@ void syncStop(int64_t rid) {
|
||||||
int32_t syncSetStandby(int64_t rid) {
|
int32_t syncSetStandby(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// state change
|
// state change
|
||||||
|
@ -177,7 +179,8 @@ int32_t syncSetStandby(int64_t rid) {
|
||||||
int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) {
|
int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(rid == pSyncNode->rid);
|
ASSERT(rid == pSyncNode->rid);
|
||||||
|
|
||||||
|
@ -201,7 +204,8 @@ int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg
|
||||||
|
|
||||||
if (!IamInNew) {
|
if (!IamInNew) {
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_NOT_IN_NEW_CONFIG;
|
terrno = TSDB_CODE_SYN_NOT_IN_NEW_CONFIG;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
||||||
|
@ -219,7 +223,8 @@ int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg
|
||||||
int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
|
int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(rid == pSyncNode->rid);
|
ASSERT(rid == pSyncNode->rid);
|
||||||
|
|
||||||
|
@ -246,7 +251,8 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
|
||||||
if (!IamInNew) {
|
if (!IamInNew) {
|
||||||
sError("sync reconfig error, not in new config");
|
sError("sync reconfig error, not in new config");
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_NOT_IN_NEW_CONFIG;
|
terrno = TSDB_CODE_SYN_NOT_IN_NEW_CONFIG;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg);
|
||||||
|
@ -272,13 +278,15 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
|
||||||
int32_t syncLeaderTransfer(int64_t rid) {
|
int32_t syncLeaderTransfer(int64_t rid) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(rid == pSyncNode->rid);
|
ASSERT(rid == pSyncNode->rid);
|
||||||
|
|
||||||
if (pSyncNode->peersNum == 0) {
|
if (pSyncNode->peersNum == 0) {
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeInfo newLeader = (pSyncNode->peersNodeInfo)[0];
|
SNodeInfo newLeader = (pSyncNode->peersNodeInfo)[0];
|
||||||
|
@ -291,7 +299,8 @@ int32_t syncLeaderTransfer(int64_t rid) {
|
||||||
int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) {
|
int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
ASSERT(rid == pSyncNode->rid);
|
ASSERT(rid == pSyncNode->rid);
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
@ -299,7 +308,8 @@ int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) {
|
||||||
if (pSyncNode->replicaNum == 1) {
|
if (pSyncNode->replicaNum == 1) {
|
||||||
sError("only one replica, cannot drop leader");
|
sError("only one replica, cannot drop leader");
|
||||||
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
|
||||||
return TAOS_SYNC_ONLY_ONE_REPLICA;
|
terrno = TSDB_CODE_SYN_ONE_REPLICA;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncLeaderTransfer* pMsg = syncLeaderTransferBuild(pSyncNode->vgId);
|
SyncLeaderTransfer* pMsg = syncLeaderTransferBuild(pSyncNode->vgId);
|
||||||
|
@ -538,11 +548,12 @@ void setHeartbeatTimerMS(int64_t rid, int32_t hbTimerMS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
|
int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
|
||||||
int32_t ret = TAOS_SYNC_PROPOSE_SUCCESS;
|
int32_t ret = 0;
|
||||||
|
|
||||||
SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid);
|
SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
return TAOS_SYNC_OTHER_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
assert(rid == pSyncNode->rid);
|
assert(rid == pSyncNode->rid);
|
||||||
sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType));
|
sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType));
|
||||||
|
@ -553,7 +564,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak) {
|
int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak) {
|
||||||
int32_t ret = TAOS_SYNC_PROPOSE_SUCCESS;
|
int32_t ret = 0;
|
||||||
sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType));
|
sDebug("vgId:%d sync event propose msgType:%s", pSyncNode->vgId, TMSG_INFO(pMsg->msgType));
|
||||||
|
|
||||||
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
|
||||||
|
@ -567,14 +578,17 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak)
|
||||||
syncClientRequest2RpcMsg(pSyncMsg, &rpcMsg);
|
syncClientRequest2RpcMsg(pSyncMsg, &rpcMsg);
|
||||||
|
|
||||||
if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) {
|
if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) {
|
||||||
ret = TAOS_SYNC_PROPOSE_SUCCESS;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
|
ret = -1;
|
||||||
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
sError("syncPropose pSyncNode->FpEqMsg is NULL");
|
sError("syncPropose pSyncNode->FpEqMsg is NULL");
|
||||||
}
|
}
|
||||||
syncClientRequestDestroy(pSyncMsg);
|
syncClientRequestDestroy(pSyncMsg);
|
||||||
} else {
|
} else {
|
||||||
|
ret = -1;
|
||||||
|
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
sError("syncPropose not leader, %s", syncUtilState2String(pSyncNode->state));
|
sError("syncPropose not leader, %s", syncUtilState2String(pSyncNode->state));
|
||||||
ret = TAOS_SYNC_PROPOSE_NOT_LEADER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -945,9 +959,13 @@ int32_t syncNodePingAll(SSyncNode* pSyncNode) {
|
||||||
// timer control --------------
|
// timer control --------------
|
||||||
int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) {
|
int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pPingTimer);
|
&pSyncNode->pPingTimer);
|
||||||
atomic_store_64(&pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser);
|
atomic_store_64(&pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeStartPingTimer");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,10 +979,14 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
|
int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
pSyncNode->electTimerMS = ms;
|
pSyncNode->electTimerMS = ms;
|
||||||
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pElectTimer);
|
&pSyncNode->pElectTimer);
|
||||||
atomic_store_64(&pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
atomic_store_64(&pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeStartElectTimer");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,9 +1020,13 @@ int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) {
|
||||||
|
|
||||||
int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pHeartbeatTimer);
|
&pSyncNode->pHeartbeatTimer);
|
||||||
atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeStartHeartbeatTimer");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1720,14 +1746,25 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
|
||||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||||
syncRpcMsgLog2((char*)"==syncNodeEqPingTimer==", &rpcMsg);
|
syncRpcMsgLog2((char*)"==syncNodeEqPingTimer==", &rpcMsg);
|
||||||
if (pSyncNode->FpEqMsg != NULL) {
|
if (pSyncNode->FpEqMsg != NULL) {
|
||||||
pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||||
|
if (code != 0) {
|
||||||
|
sError("vgId:%d sync enqueue ping msg error, code:%d", pSyncNode->vgId, code);
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sTrace("syncNodeEqPingTimer pSyncNode->FpEqMsg is NULL");
|
sTrace("syncNodeEqPingTimer pSyncNode->FpEqMsg is NULL");
|
||||||
}
|
}
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pPingTimer);
|
&pSyncNode->pPingTimer);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeEqPingTimer");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "",
|
sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "",
|
||||||
pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser);
|
pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser);
|
||||||
|
@ -1743,16 +1780,26 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
||||||
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
syncTimeout2RpcMsg(pSyncMsg, &rpcMsg);
|
||||||
syncRpcMsgLog2((char*)"==syncNodeEqElectTimer==", &rpcMsg);
|
syncRpcMsgLog2((char*)"==syncNodeEqElectTimer==", &rpcMsg);
|
||||||
if (pSyncNode->FpEqMsg != NULL) {
|
if (pSyncNode->FpEqMsg != NULL) {
|
||||||
pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
int32_t code = pSyncNode->FpEqMsg(pSyncNode->msgcb, &rpcMsg);
|
||||||
|
if (code != 0) {
|
||||||
|
sError("vgId:%d sync enqueue elect msg error, code:%d", pSyncNode->vgId, code);
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sTrace("syncNodeEqElectTimer pSyncNode->FpEqMsg is NULL");
|
sTrace("syncNodeEqElectTimer FpEqMsg is NULL");
|
||||||
}
|
}
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
|
||||||
// reset timer ms
|
// reset timer ms
|
||||||
|
if (syncEnvIsStart()) {
|
||||||
pSyncNode->electTimerMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine);
|
pSyncNode->electTimerMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine);
|
||||||
taosTmrReset(syncNodeEqElectTimer, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(syncNodeEqElectTimer, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pElectTimer);
|
&pSyncNode->pElectTimer);
|
||||||
|
} else {
|
||||||
|
sError("sync env is stop, syncNodeEqElectTimer");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "",
|
sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "",
|
||||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser);
|
||||||
|
@ -1761,6 +1808,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
|
||||||
|
|
||||||
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
||||||
SSyncNode* pSyncNode = (SSyncNode*)param;
|
SSyncNode* pSyncNode = (SSyncNode*)param;
|
||||||
|
if (pSyncNode->replicaNum > 1) {
|
||||||
if (atomic_load_64(&pSyncNode->heartbeatTimerLogicClockUser) <=
|
if (atomic_load_64(&pSyncNode->heartbeatTimerLogicClockUser) <=
|
||||||
atomic_load_64(&pSyncNode->heartbeatTimerLogicClock)) {
|
atomic_load_64(&pSyncNode->heartbeatTimerLogicClock)) {
|
||||||
SyncTimeout* pSyncMsg =
|
SyncTimeout* pSyncMsg =
|
||||||
|
@ -1774,25 +1822,26 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sError("vgId:%d sync enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
sError("vgId:%d sync enqueue timer msg error, code:%d", pSyncNode->vgId, code);
|
||||||
rpcFreeCont(rpcMsg.pCont);
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sTrace("syncNodeEqHeartbeatTimer pSyncNode->FpEqMsg is NULL");
|
sError("syncNodeEqHeartbeatTimer FpEqMsg is NULL");
|
||||||
}
|
}
|
||||||
syncTimeoutDestroy(pSyncMsg);
|
syncTimeoutDestroy(pSyncMsg);
|
||||||
|
|
||||||
if (gSyncEnv != NULL) {
|
if (syncEnvIsStart()) {
|
||||||
taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager,
|
||||||
&pSyncNode->pHeartbeatTimer);
|
&pSyncNode->pHeartbeatTimer);
|
||||||
} else {
|
} else {
|
||||||
sError("sync env is already stop");
|
sError("sync env is stop, syncNodeEqHeartbeatTimer");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64
|
sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64
|
||||||
"",
|
"",
|
||||||
pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t syncNodeEqNoop(SSyncNode* ths) {
|
static int32_t syncNodeEqNoop(SSyncNode* ths) {
|
||||||
|
@ -2137,7 +2186,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
|
||||||
ths->pFsm->FpRestoreFinishCb(ths->pFsm);
|
ths->pFsm->FpRestoreFinishCb(ths->pFsm);
|
||||||
}
|
}
|
||||||
ths->restoreFinish = true;
|
ths->restoreFinish = true;
|
||||||
sDebug("vgId:%d sync event restore finish", ths->vgId);
|
sDebug("vgId:%d sync event restore finish, index:%ld", ths->vgId, pEntry->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ int main(int argc, char** argv) {
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
|
@ -251,7 +251,7 @@ int main(int argc, char** argv) {
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
|
@ -188,7 +188,7 @@ int main(int argc, char** argv) {
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader", s, alreadySend);
|
sTrace("%s value%d write not leader", s, alreadySend);
|
||||||
} else {
|
} else {
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
|
@ -391,7 +391,7 @@ int main(int argc, char** argv) {
|
||||||
if (alreadySend < writeRecordNum) {
|
if (alreadySend < writeRecordNum) {
|
||||||
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
SRpcMsg* pRpcMsg = createRpcMsg(alreadySend, writeRecordNum, myIndex);
|
||||||
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
int32_t ret = syncPropose(rid, pRpcMsg, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == -1 && terrno == TSDB_CODE_SYN_NOT_LEADER) {
|
||||||
sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait);
|
sTrace("%s value%d write not leader, leaderTransferWait:%d", simpleStr, alreadySend, leaderTransferWait);
|
||||||
} else {
|
} else {
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
|
@ -174,7 +174,11 @@ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taosArrayAddAll(SArray* pArray, const SArray* pInput) {
|
void* taosArrayAddAll(SArray* pArray, const SArray* pInput) {
|
||||||
|
if (pInput) {
|
||||||
return taosArrayAddBatch(pArray, pInput->pData, (int32_t)taosArrayGetSize(pInput));
|
return taosArrayAddBatch(pArray, pInput->pData, (int32_t)taosArrayGetSize(pInput));
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taosArrayPop(SArray* pArray) {
|
void* taosArrayPop(SArray* pArray) {
|
||||||
|
|
|
@ -138,6 +138,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CLAUSE_ERROR, "not supported stmt cl
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, "Mnode not ready")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, "Mnode not ready")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_USER_DISABLED, "User is disabled")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, "Invalid message connection")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, "Invalid message connection")
|
||||||
|
|
||||||
// mnode-show
|
// mnode-show
|
||||||
|
@ -414,6 +415,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGLEN, "Invalid msg length")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGTYPE, "Invalid msg type")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_MSGTYPE, "Invalid msg type")
|
||||||
|
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync not leader")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync not leader")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_ONE_REPLICA, "Sync one replica")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_IN_NEW_CONFIG, "Sync not in new config")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error")
|
||||||
|
|
||||||
// wal
|
// wal
|
||||||
|
|
|
@ -246,20 +246,26 @@ class TDTestCase:
|
||||||
user = self.root_user
|
user = self.root_user
|
||||||
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
with taos_connect(user=user.name, passwd=user.passwd) as use:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
if check_priv == PRIVILEGES_ALL:
|
||||||
use.query("use db")
|
use.query("use db")
|
||||||
use.query("show tables")
|
use.query("show tables")
|
||||||
if check_priv == PRIVILEGES_ALL:
|
|
||||||
use.query("select * from ct1")
|
use.query("select * from ct1")
|
||||||
use.query("insert into t1 (ts) values (now())")
|
use.query("insert into t1 (ts) values (now())")
|
||||||
elif check_priv == PRIVILEGES_READ:
|
elif check_priv == PRIVILEGES_READ:
|
||||||
|
use.query("use db")
|
||||||
|
use.query("show tables")
|
||||||
use.query("select * from ct1")
|
use.query("select * from ct1")
|
||||||
use.error("insert into t1 (ts) values (now())")
|
use.error("insert into t1 (ts) values (now())")
|
||||||
elif check_priv == PRIVILEGES_WRITE:
|
elif check_priv == PRIVILEGES_WRITE:
|
||||||
|
use.query("use db")
|
||||||
|
use.query("show tables")
|
||||||
use.error("select * from ct1")
|
use.error("select * from ct1")
|
||||||
use.query("insert into t1 (ts) values (now())")
|
use.query("insert into t1 (ts) values (now())")
|
||||||
elif check_priv is None:
|
elif check_priv is None:
|
||||||
use.error("select * from ct1")
|
use.error("use db")
|
||||||
use.error("insert into t1 (ts) values (now())")
|
use.error("show tables")
|
||||||
|
use.error("select * from db.ct1")
|
||||||
|
use.error("insert into db.t1 (ts) values (now())")
|
||||||
|
|
||||||
def __change_user_priv(self, user: User, pre_priv, invoke=False):
|
def __change_user_priv(self, user: User, pre_priv, invoke=False):
|
||||||
if user.priv == pre_priv and invoke :
|
if user.priv == pre_priv and invoke :
|
||||||
|
@ -610,7 +616,7 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix("==========step0: init, user list only has root account")
|
tdLog.printNoPrefix("==========step0: init, user list only has root account")
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
# root用户权限
|
# root用户权限
|
||||||
# 创建用户测试
|
# 创建用户测试
|
||||||
|
@ -676,7 +682,7 @@ class TDTestCase:
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
@ -690,7 +696,7 @@ class TDTestCase:
|
||||||
tdSql.query("show users")
|
tdSql.query("show users")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0, 0, "root")
|
tdSql.checkData(0, 0, "root")
|
||||||
tdSql.checkData(0, 1, "super")
|
tdSql.checkData(0, 1, "1")
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -134,7 +134,7 @@ class TDTestCase:
|
||||||
parameterDict['cfg'] = cfgPath
|
parameterDict['cfg'] = cfgPath
|
||||||
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
prepareEnvThread.start()
|
prepareEnvThread.start()
|
||||||
time.sleep(2)
|
prepareEnvThread.join()
|
||||||
|
|
||||||
# wait stb ready
|
# wait stb ready
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -245,6 +245,7 @@ class TDTestCase:
|
||||||
|
|
||||||
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
prepareEnvThread.start()
|
prepareEnvThread.start()
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
# wait db ready
|
# wait db ready
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -371,6 +372,7 @@ class TDTestCase:
|
||||||
|
|
||||||
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
prepareEnvThread.start()
|
prepareEnvThread.start()
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
# wait db ready
|
# wait db ready
|
||||||
while 1:
|
while 1:
|
||||||
|
|
|
@ -61,7 +61,8 @@ goto :eof
|
||||||
set tt=%1
|
set tt=%1
|
||||||
set tt=%tt:.= %
|
set tt=%tt:.= %
|
||||||
set tt=%tt::= %
|
set tt=%tt::= %
|
||||||
set index=1
|
set tt=%tt: 0= %
|
||||||
|
set /a index=1
|
||||||
for %%a in (%tt%) do (
|
for %%a in (%tt%) do (
|
||||||
if !index! EQU 1 (
|
if !index! EQU 1 (
|
||||||
set /a hh=%%a
|
set /a hh=%%a
|
||||||
|
@ -75,5 +76,5 @@ for %%a in (%tt%) do (
|
||||||
)
|
)
|
||||||
set /a index=index+1
|
set /a index=index+1
|
||||||
)
|
)
|
||||||
set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% || echo hh:%hh% mm:%mm% ss:%ss%
|
set /a _timeTemp=(%hh%*60+%mm%)*60+%ss%
|
||||||
goto :eof
|
goto :eof
|
|
@ -21,6 +21,7 @@ import base64
|
||||||
import json
|
import json
|
||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
|
import threading
|
||||||
from distutils.log import warn as printf
|
from distutils.log import warn as printf
|
||||||
from fabric2 import Connection
|
from fabric2 import Connection
|
||||||
sys.path.append("../pytest")
|
sys.path.append("../pytest")
|
||||||
|
@ -30,6 +31,13 @@ from util.cases import *
|
||||||
|
|
||||||
import taos
|
import taos
|
||||||
|
|
||||||
|
def checkRunTimeError():
|
||||||
|
import win32gui
|
||||||
|
while 1:
|
||||||
|
time.sleep(1)
|
||||||
|
hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library")
|
||||||
|
if hwnd:
|
||||||
|
os.system("TASKKILL /F /IM taosd.exe")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
@ -42,9 +50,6 @@ if __name__ == "__main__":
|
||||||
logSql = True
|
logSql = True
|
||||||
stop = 0
|
stop = 0
|
||||||
restart = False
|
restart = False
|
||||||
windows = 0
|
|
||||||
if platform.system().lower() == 'windows':
|
|
||||||
windows = 1
|
|
||||||
updateCfgDict = {}
|
updateCfgDict = {}
|
||||||
execCmd = ""
|
execCmd = ""
|
||||||
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:', [
|
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:', [
|
||||||
|
@ -159,7 +164,9 @@ if __name__ == "__main__":
|
||||||
host = masterIp
|
host = masterIp
|
||||||
|
|
||||||
tdLog.info("Procedures for tdengine deployed in %s" % (host))
|
tdLog.info("Procedures for tdengine deployed in %s" % (host))
|
||||||
if windows:
|
if platform.system().lower() == 'windows':
|
||||||
|
if (masterIp == "" and not fileName[0:12] == "0-others\\udf"):
|
||||||
|
threading.Thread(target=checkRunTimeError,daemon=True).start()
|
||||||
tdCases.logSql(logSql)
|
tdCases.logSql(logSql)
|
||||||
tdLog.info("Procedures for testing self-deployment")
|
tdLog.info("Procedures for testing self-deployment")
|
||||||
tdDnodes.init(deployPath, masterIp)
|
tdDnodes.init(deployPath, masterIp)
|
||||||
|
|
Loading…
Reference in New Issue