Merge pull request #23886 from taosdata/revert-23730-enh/TD-26976-3.0
Revert "enh: grant and active codes"
This commit is contained in:
commit
32030ca130
|
@ -31,8 +31,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#define GRANT_HEART_BEAT_MIN 2
|
||||
#define GRANT_ACTIVE_CODE "activeCode"
|
||||
#define GRANT_C_ACTIVE_CODE "cActiveCode"
|
||||
|
||||
typedef enum {
|
||||
TSDB_GRANT_ALL,
|
||||
|
@ -52,11 +50,6 @@ typedef enum {
|
|||
TSDB_GRANT_TABLE,
|
||||
} EGrantType;
|
||||
|
||||
typedef struct {
|
||||
int64_t grantedTime;
|
||||
int64_t connGrantedTime;
|
||||
} SGrantedInfo;
|
||||
|
||||
int32_t grantCheck(EGrantType grant);
|
||||
int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type);
|
||||
|
||||
|
|
|
@ -558,7 +558,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_GRANT_GEN_IVLD_KEY TAOS_DEF_ERROR_CODE(0, 0x0812)
|
||||
#define TSDB_CODE_GRANT_GEN_APP_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0813)
|
||||
#define TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN TAOS_DEF_ERROR_CODE(0, 0x0814)
|
||||
#define TSDB_CODE_GRANT_PAR_IVLD_DIST TAOS_DEF_ERROR_CODE(0, 0x0815)
|
||||
|
||||
// sync
|
||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||
|
|
|
@ -27,8 +27,6 @@ void mndCleanupCluster(SMnode *pMnode);
|
|||
int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len);
|
||||
int64_t mndGetClusterId(SMnode *pMnode);
|
||||
int64_t mndGetClusterCreateTime(SMnode *pMnode);
|
||||
int32_t mndGetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo);
|
||||
int32_t mndSetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo);
|
||||
int64_t mndGetClusterUpTime(SMnode *pMnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -192,8 +192,6 @@ typedef struct {
|
|||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
int32_t upTime;
|
||||
int64_t grantedTime;
|
||||
int64_t connGrantedTime;
|
||||
} SClusterObj;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mndTrans.h"
|
||||
|
||||
#define CLUSTER_VER_NUMBE 1
|
||||
#define CLUSTER_RESERVE_SIZE 44
|
||||
#define CLUSTER_RESERVE_SIZE 60
|
||||
int64_t tsExpireTime = 0;
|
||||
|
||||
static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster);
|
||||
|
@ -112,19 +112,6 @@ int64_t mndGetClusterCreateTime(SMnode *pMnode) {
|
|||
return createTime;
|
||||
}
|
||||
|
||||
int32_t mndGetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo) {
|
||||
void *pIter = NULL;
|
||||
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||
if (pCluster != NULL) {
|
||||
pInfo->grantedTime = pCluster->grantedTime;
|
||||
pInfo->connGrantedTime = pCluster->connGrantedTime;
|
||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t mndGetClusterUpTimeImp(SClusterObj *pCluster) {
|
||||
#if 0
|
||||
int32_t upTime = taosGetTimestampSec() - pCluster->updateTime / 1000;
|
||||
|
@ -159,8 +146,6 @@ static SSdbRaw *mndClusterActionEncode(SClusterObj *pCluster) {
|
|||
SDB_SET_INT64(pRaw, dataPos, pCluster->updateTime, _OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pCluster->upTime, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pCluster->grantedTime, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pCluster->connGrantedTime, _OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
@ -201,8 +186,6 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT64(pRaw, dataPos, &pCluster->updateTime, _OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pCluster->name, TSDB_CLUSTER_ID_LEN, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pCluster->upTime, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pCluster->grantedTime, _OVER);
|
||||
SDB_GET_INT64(pRaw, dataPos, &pCluster->connGrantedTime, _OVER);
|
||||
SDB_GET_RESERVE(pRaw, dataPos, CLUSTER_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
@ -235,8 +218,6 @@ static int32_t mndClusterActionUpdate(SSdb *pSdb, SClusterObj *pOld, SClusterObj
|
|||
mTrace("cluster:%" PRId64 ", perform update action, old row:%p new row:%p, uptime from %d to %d", pOld->id, pOld,
|
||||
pNew, pOld->upTime, pNew->upTime);
|
||||
pOld->upTime = pNew->upTime;
|
||||
pOld->grantedTime = pNew->grantedTime;
|
||||
pOld->connGrantedTime = pNew->connGrantedTime;
|
||||
pOld->updateTime = taosGetTimestampMs();
|
||||
return 0;
|
||||
}
|
||||
|
@ -378,44 +359,3 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
|||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndSetClusterGrantedInfo(SMnode *pMnode, SGrantedInfo *pInfo) {
|
||||
SClusterObj clusterObj = {0};
|
||||
void *pIter = NULL;
|
||||
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
|
||||
if (pCluster != NULL) {
|
||||
if (pCluster->grantedTime >= pInfo->grantedTime && pCluster->connGrantedTime >= pInfo->connGrantedTime) {
|
||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
return 0;
|
||||
}
|
||||
memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
|
||||
if (pCluster->grantedTime < pInfo->grantedTime) clusterObj.grantedTime = pInfo->grantedTime;
|
||||
if (pCluster->connGrantedTime < pInfo->connGrantedTime) clusterObj.connGrantedTime = pInfo->connGrantedTime;
|
||||
mndReleaseCluster(pMnode, pCluster, pIter);
|
||||
}
|
||||
|
||||
if (clusterObj.id <= 0) {
|
||||
mError("can't get cluster info while update granted info");
|
||||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "granted-info");
|
||||
if (pTrans == NULL) return -1;
|
||||
|
||||
SSdbRaw *pCommitRaw = mndClusterActionEncode(&clusterObj);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
|
@ -790,9 +790,7 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
|||
if (cfgAll) { // alter all dnodes:
|
||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||
if (0 == cfgAllErr || cfgAllErr == TSDB_CODE_GRANT_PAR_IVLD_ACTIVE) {
|
||||
cfgAllErr = terrno; // output 1st or more specific error
|
||||
}
|
||||
if (0 == cfgAllErr) cfgAllErr = terrno; // output 1st terrno.
|
||||
}
|
||||
} else {
|
||||
terrno = 0; // no action for dup active code
|
||||
|
@ -808,9 +806,7 @@ static int32_t mndConfigDnode(SMnode *pMnode, SRpcMsg *pReq, SMCfgDnodeReq *pCfg
|
|||
if (cfgAll) {
|
||||
if (!failRecord) failRecord = taosArrayInit(1, sizeof(int32_t));
|
||||
if (failRecord) taosArrayPush(failRecord, &pDnode->id);
|
||||
if (0 == cfgAllErr || cfgAllErr == TSDB_CODE_GRANT_PAR_IVLD_ACTIVE) {
|
||||
cfgAllErr = terrno; // output 1st or more specific error
|
||||
}
|
||||
if (0 == cfgAllErr) cfgAllErr = terrno;
|
||||
}
|
||||
} else {
|
||||
terrno = 0;
|
||||
|
@ -1287,12 +1283,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
strcpy(dcfgReq.config, "supportvnodes");
|
||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||
} else if (strncasecmp(cfgReq.config, GRANT_ACTIVE_CODE, 10) == 0 ||
|
||||
strncasecmp(cfgReq.config, GRANT_C_ACTIVE_CODE, 11) == 0) {
|
||||
if (cfgReq.dnodeId != -1) {
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
goto _err_out;
|
||||
}
|
||||
} else if (strncasecmp(cfgReq.config, "activeCode", 10) == 0 || strncasecmp(cfgReq.config, "cActiveCode", 11) == 0) {
|
||||
int8_t opt = strncasecmp(cfgReq.config, "a", 1) == 0 ? DND_ACTIVE_CODE : DND_CONN_ACTIVE_CODE;
|
||||
int8_t index = opt == DND_ACTIVE_CODE ? 10 : 11;
|
||||
if (' ' != cfgReq.config[index] && 0 != cfgReq.config[index]) {
|
||||
|
@ -1310,11 +1301,12 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
goto _err_out;
|
||||
}
|
||||
|
||||
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? GRANT_ACTIVE_CODE : GRANT_C_ACTIVE_CODE);
|
||||
strcpy(dcfgReq.config, opt == DND_ACTIVE_CODE ? "activeCode" : "cActiveCode");
|
||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%s", cfgReq.value);
|
||||
|
||||
if ((terrno = mndConfigDnode(pMnode, pReq, &cfgReq, opt)) != 0) {
|
||||
if (mndConfigDnode(pMnode, pReq, &cfgReq, opt) != 0) {
|
||||
mError("dnode:%d, failed to config activeCode since %s", cfgReq.dnodeId, terrstr());
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
goto _err_out;
|
||||
}
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
|
|
|
@ -445,7 +445,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN, "Invalid klen to decod
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to gen active code")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_APP_LIMIT, "Limited app num to gen active code")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid dist to parse active code")
|
||||
|
||||
// sync
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout")
|
||||
|
|
|
@ -247,10 +247,7 @@ class TDTestCase:
|
|||
tdSql.error('alter all dnodes "activeCode" "' + self.str510 + '"')
|
||||
tdSql.query(f'select * from information_schema.ins_dnodes')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][8],"")
|
||||
tdSql.error('alter dnode 1 "activeCode" ""')
|
||||
tdSql.error('alter dnode 1 "activeCode"')
|
||||
tdSql.execute('alter all dnodes "activeCode" ""')
|
||||
tdSql.execute('alter all dnodes "activeCode"')
|
||||
tdSql.execute('alter dnode 1 "activeCode" ""')
|
||||
tdSql.query(f'select active_code,c_active_code from information_schema.ins_dnodes')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0],"")
|
||||
tdSql.checkEqual(tdSql.queryResult[0][1],'')
|
||||
|
@ -262,10 +259,6 @@ class TDTestCase:
|
|||
tdSql.error('alter all dnodes "cActiveCode" "' + self.str257 + '"')
|
||||
tdSql.error('alter all dnodes "cActiveCode" "' + self.str254 + '"')
|
||||
tdSql.error('alter dnode 1 "cActiveCode" "' + self.str510 + '"')
|
||||
tdSql.error('alter dnode 1 "cActiveCode" ""')
|
||||
tdSql.error('alter dnode 1 "cActiveCode"')
|
||||
tdSql.execute('alter all dnodes "cActiveCode" ""')
|
||||
tdSql.execute('alter all dnodes "cActiveCode"')
|
||||
tdSql.query(f'select active_code,c_active_code from information_schema.ins_dnodes')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0],"")
|
||||
tdSql.checkEqual(tdSql.queryResult[0][1],"")
|
||||
|
|
Loading…
Reference in New Issue