Merge pull request #27434 from taosdata/enh/TD-31543-3.0
enh: rm ASSERT in mndArbGroup.c/geosWrapper.c/geomFuncTestUtil.cpp
This commit is contained in:
commit
f240c78f76
|
@ -29,7 +29,7 @@ void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pObj);
|
|||
SSdbRaw *mndArbGroupActionEncode(SArbGroup *pGroup);
|
||||
SSdbRow *mndArbGroupActionDecode(SSdbRaw *pRaw);
|
||||
|
||||
void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup);
|
||||
int32_t mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup);
|
||||
|
||||
int32_t mndSetCreateArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
int32_t mndSetCreateArbGroupUndoLogs(STrans *pTrans, SArbGroup *pGroup);
|
||||
|
|
|
@ -102,8 +102,10 @@ void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pGroup) {
|
|||
sdbRelease(pSdb, pGroup);
|
||||
}
|
||||
|
||||
void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
||||
ASSERT(pVgObj->replica == 2);
|
||||
int32_t mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
||||
if (pVgObj->replica != 2) {
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
(void)memset(outGroup, 0, sizeof(SArbGroup));
|
||||
outGroup->dbUid = pVgObj->dbUid;
|
||||
outGroup->vgId = pVgObj->vgId;
|
||||
|
@ -111,6 +113,8 @@ void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) {
|
|||
SArbGroupMember *pMember = &outGroup->members[i];
|
||||
pMember->info.dnodeId = pVgObj->vnodeGid[i].dnodeId;
|
||||
}
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
SSdbRaw *mndArbGroupActionEncode(SArbGroup *pGroup) {
|
||||
|
|
|
@ -629,7 +629,7 @@ static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
|
|||
for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SVgObj *pVgObj = pVgroups + v;
|
||||
SArbGroup arbGroup = {0};
|
||||
mndArbGroupInitFromVgObj(pVgObj, &arbGroup);
|
||||
TAOS_CHECK_RETURN(mndArbGroupInitFromVgObj(pVgObj, &arbGroup));
|
||||
TAOS_CHECK_RETURN(mndSetCreateArbGroupRedoLogs(pTrans, &arbGroup));
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ static int32_t mndSetCreateDbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
|
|||
for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SVgObj *pVgObj = pVgroups + v;
|
||||
SArbGroup arbGroup = {0};
|
||||
mndArbGroupInitFromVgObj(pVgObj, &arbGroup);
|
||||
TAOS_CHECK_RETURN(mndArbGroupInitFromVgObj(pVgObj, &arbGroup));
|
||||
TAOS_CHECK_RETURN(mndSetCreateArbGroupUndoLogs(pTrans, &arbGroup));
|
||||
}
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ static int32_t mndSetCreateDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) {
|
||||
SVgObj *pVgObj = pVgroups + v;
|
||||
SArbGroup arbGroup = {0};
|
||||
mndArbGroupInitFromVgObj(pVgObj, &arbGroup);
|
||||
TAOS_CHECK_RETURN(mndArbGroupInitFromVgObj(pVgObj, &arbGroup));
|
||||
TAOS_CHECK_RETURN(mndSetCreateArbGroupCommitLogs(pTrans, &arbGroup));
|
||||
}
|
||||
}
|
||||
|
@ -1156,44 +1156,30 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
|||
}
|
||||
|
||||
static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb) {
|
||||
int32_t code = 0;
|
||||
int32_t code = 0, lino = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SVgObj *pVgroup = NULL;
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
|
||||
while (1) {
|
||||
SVgObj *pVgroup = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (mndVgroupInDb(pVgroup, pNewDb->uid)) {
|
||||
SVgObj newVgroup = {0};
|
||||
if ((code = mndBuildAlterVgroupAction(pMnode, pTrans, pOldDb, pNewDb, pVgroup, pArray, &newVgroup)) != 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndBuildAlterVgroupAction(pMnode, pTrans, pOldDb, pNewDb, pVgroup, pArray, &newVgroup), &lino,
|
||||
_err);
|
||||
|
||||
if (pNewDb->cfg.withArbitrator != pOldDb->cfg.withArbitrator) {
|
||||
if (pNewDb->cfg.withArbitrator) {
|
||||
SArbGroup arbGroup = {0};
|
||||
mndArbGroupInitFromVgObj(&newVgroup, &arbGroup);
|
||||
if ((code = mndSetCreateArbGroupCommitLogs(pTrans, &arbGroup)) != 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(mndArbGroupInitFromVgObj(&newVgroup, &arbGroup), &lino, _err);
|
||||
TAOS_CHECK_GOTO(mndSetCreateArbGroupCommitLogs(pTrans, &arbGroup), &lino, _err);
|
||||
} else {
|
||||
SArbGroup arbGroup = {0};
|
||||
mndArbGroupInitFromVgObj(pVgroup, &arbGroup);
|
||||
if ((code = mndSetDropArbGroupCommitLogs(pTrans, &arbGroup)) != 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
TAOS_CHECK_GOTO(mndArbGroupInitFromVgObj(pVgroup, &arbGroup), &lino, _err);
|
||||
TAOS_CHECK_GOTO(mndSetDropArbGroupCommitLogs(pTrans, &arbGroup), &lino, _err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1203,6 +1189,14 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
|||
|
||||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
|
||||
_err:
|
||||
mError("db:%s, %s failed at %d since %s", pNewDb->name, __func__, lino, tstrerror(code));
|
||||
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
taosArrayDestroy(pArray);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *pNew) {
|
||||
|
|
|
@ -331,18 +331,26 @@ int32_t doGeosRelation(const GEOSGeometry *geom1, const GEOSPreparedGeometry *pr
|
|||
|
||||
if (!preparedGeom1) {
|
||||
if (!swapped) {
|
||||
ASSERT(relationFn);
|
||||
if (!relationFn) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
*res = relationFn(geosCtx->handle, geom1, geom2);
|
||||
} else {
|
||||
ASSERT(swappedRelationFn);
|
||||
if (!swappedRelationFn) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
*res = swappedRelationFn(geosCtx->handle, geom1, geom2);
|
||||
}
|
||||
} else {
|
||||
if (!swapped) {
|
||||
ASSERT(preparedRelationFn);
|
||||
if (!preparedRelationFn) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
*res = preparedRelationFn(geosCtx->handle, preparedGeom1, geom2);
|
||||
} else {
|
||||
ASSERT(swappedPreparedRelationFn);
|
||||
if (!swappedPreparedRelationFn) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
*res = swappedPreparedRelationFn(geosCtx->handle, preparedGeom1, geom2);
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +399,9 @@ int32_t readGeometry(const unsigned char *input, GEOSGeometry **outputGeom,
|
|||
const GEOSPreparedGeometry **outputPreparedGeom) {
|
||||
SGeosContext *geosCtx = getThreadLocalGeosCtx();
|
||||
|
||||
ASSERT(outputGeom); // it is not allowed if outputGeom is NULL
|
||||
if (!outputGeom) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
*outputGeom = NULL;
|
||||
|
||||
if (outputPreparedGeom) { // it means not to generate PreparedGeometry if outputPreparedGeom is NULL
|
||||
|
|
|
@ -66,7 +66,7 @@ void setScalarParam(SScalarParam *sclParam, int32_t type, void *valueArray, TDRo
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
ASSERT(0);
|
||||
ASSERT_TRUE(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue