feat(stream): drop stream
This commit is contained in:
parent
69eb9daddb
commit
803249837a
|
@ -2008,7 +2008,7 @@ typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
uint64_t queryId;
|
uint64_t queryId;
|
||||||
int64_t useconds;
|
int64_t useconds;
|
||||||
int64_t stime; // timestamp precision ms
|
int64_t stime; // timestamp precision ms
|
||||||
int64_t reqRid;
|
int64_t reqRid;
|
||||||
int32_t pid;
|
int32_t pid;
|
||||||
bool stableQuery;
|
bool stableQuery;
|
||||||
|
@ -2257,8 +2257,8 @@ typedef struct {
|
||||||
} SMqVDeleteRsp;
|
} SMqVDeleteRsp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_STREAM_FNAME_LEN];
|
char name[TSDB_STREAM_FNAME_LEN];
|
||||||
int64_t streamId;
|
int8_t igNotExists;
|
||||||
} SMDropStreamTaskReq;
|
} SMDropStreamTaskReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -278,8 +278,8 @@ 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;
|
||||||
|
|
||||||
SMCreateStbReq createReq = {0};
|
SMCreateStbReq createReq = {0};
|
||||||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -321,7 +321,6 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
if (mndCheckDbAuth(pMnode, user, MND_OPER_WRITE_DB, pDb) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -520,13 +519,19 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
/*SDbObj *pDb = NULL;*/
|
/*SDbObj *pDb = NULL;*/
|
||||||
/*SUserObj *pUser = NULL;*/
|
/*SUserObj *pUser = NULL;*/
|
||||||
|
|
||||||
SMDropStreamTaskReq dropStreamReq = *(SMDropStreamTaskReq *)pReq->pCont;
|
SMDropStreamTaskReq dropReq = *(SMDropStreamTaskReq *)pReq->pCont;
|
||||||
|
|
||||||
pStream = mndAcquireStream(pMnode, dropStreamReq.name);
|
pStream = mndAcquireStream(pMnode, dropReq.name);
|
||||||
|
|
||||||
if (pStream == NULL) {
|
if (pStream == NULL) {
|
||||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
if (dropReq.igNotExists) {
|
||||||
return -1;
|
mDebug("stream:%s, not exist, ignore not exist is set", dropReq.name);
|
||||||
|
code = 0;
|
||||||
|
goto DROP_STREAM_OVER;
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -539,19 +544,19 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("stream:%s, failed to drop since %s", dropStreamReq.name, terrstr());
|
mError("stream:%s, failed to drop since %s", dropReq.name, terrstr());
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropStreamReq.name);
|
mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name);
|
||||||
|
|
||||||
// drop all tasks
|
// drop all tasks
|
||||||
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) {
|
||||||
mError("stream:%s, failed to drop task since %s", dropStreamReq.name, terrstr());
|
mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr());
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
DROP_STREAM_OVER:
|
DROP_STREAM_OVER:
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
||||||
|
|
Loading…
Reference in New Issue