feat(stream): drop stream
This commit is contained in:
parent
69eb9daddb
commit
803249837a
|
@ -2258,7 +2258,7 @@ typedef struct {
|
||||||
|
|
||||||
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 {
|
||||||
|
|
|
@ -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,14 +519,20 @@ 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) {
|
||||||
|
if (dropReq.igNotExists) {
|
||||||
|
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;
|
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// todo check auth
|
// todo check auth
|
||||||
|
@ -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