feat: not allowed to set WAL_RETENTION_PERIOD as zero when there are topics defined
This commit is contained in:
parent
22d92cd3dc
commit
235ef431d2
|
@ -32,6 +32,7 @@ bool mndTopicExistsForDb(SMnode *pMnode, SDbObj *pDb);
|
|||
const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]);
|
||||
|
||||
int32_t mndSetTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
||||
int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -849,6 +849,18 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t numOfTopics = 0;
|
||||
if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (numOfTopics != 0 && alterReq.walRetentionPeriod == 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||
mError("db:%s, not allowed to set WAL_RETENTION_PERIOD 0 when there are topics defined. numOfTopics:%d", pDb->name,
|
||||
numOfTopics);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||
if (dbObj.cfg.pRetensions != NULL) {
|
||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
|
||||
|
|
|
@ -793,7 +793,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) {
|
||||
int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) {
|
||||
*pNumOfTopics = 0;
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
Loading…
Reference in New Issue