Merge pull request #21837 from taosdata/FIX/TD-24924-3.0
enh: not allow to split vgroup when streams or topics exist
This commit is contained in:
commit
8cea3302d7
|
@ -40,6 +40,8 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr
|
||||||
|
|
||||||
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||||
|
|
||||||
|
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
|
|
@ -20,10 +20,12 @@
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
#include "mndPrivilege.h"
|
#include "mndPrivilege.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
|
#include "mndStb.h"
|
||||||
|
#include "mndStream.h"
|
||||||
|
#include "mndTopic.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "tmisce.h"
|
#include "tmisce.h"
|
||||||
#include "mndStb.h"
|
|
||||||
|
|
||||||
#define VGROUP_VER_NUMBER 1
|
#define VGROUP_VER_NUMBER 1
|
||||||
#define VGROUP_RESERVE_SIZE 64
|
#define VGROUP_RESERVE_SIZE 64
|
||||||
|
@ -2290,6 +2292,24 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro
|
||||||
SDbObj dbObj = {0};
|
SDbObj dbObj = {0};
|
||||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||||
|
|
||||||
|
int32_t numOfTopics = 0;
|
||||||
|
if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
if (numOfTopics > 0) {
|
||||||
|
terrno = TSDB_CODE_MND_TOPIC_MUST_BE_DELETED;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfStreams = 0;
|
||||||
|
if (mndGetNumOfStreams(pMnode, pDb->name, &numOfStreams) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
if (numOfStreams > 0) {
|
||||||
|
terrno = TSDB_CODE_MND_STREAM_MUST_BE_DELETED;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "split-vgroup");
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "split-vgroup");
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
|
|
Loading…
Reference in New Issue