diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index a4c2c60aa34f513550e64c2a6c83d4589dbc512a..7ae8b5670ca7be60c4f4f5633cedf27c5a1f0e1b 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -487,8 +487,14 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) { sdbDebug("table:%s, insert record:%s to hash, rowSize:%d numOfRows:%" PRId64 ", msg:%p", pTable->tableName, sdbGetKeyStrFromObj(pTable, pOper->pObj), pOper->rowSize, pTable->numOfRows, pOper->pMsg); - (*pTable->insertFp)(pOper); - return TSDB_CODE_SUCCESS; + int32_t code = (*pTable->insertFp)(pOper); + if (code != TSDB_CODE_SUCCESS) { + sdbError("table:%s, failed to insert record:%s to hash, remove it", pTable->tableName, + sdbGetKeyStrFromObj(pTable, pOper->pObj)); + sdbDeleteHash(pTable, pOper); + } + + return code; } static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) { diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 1d14ec030714f5f2c6ab9703fbdc67cc654155e8..14cc052c4995e56e17ecb5aca1d2cde181fa3a50 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2351,11 +2351,11 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { // if the vgroup is already dropped from hash, it can't be accquired by pTable->vgId // so the refCount of vgroup can not be decreased - SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId); - if (pVgroup == NULL) { - mnodeRemoveTableFromVgroup(pVgroup, pTable); - } - mnodeDecVgroupRef(pVgroup); + // SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId); + // if (pVgroup == NULL) { + // mnodeRemoveTableFromVgroup(mnodeMsg->pVgroup, pTable); + // } + // mnodeDecVgroupRef(pVgroup); mnodeSendDropChildTableMsg(mnodeMsg, false); rpcMsg->code = TSDB_CODE_SUCCESS; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index e46da1d8920c12a2a6b8ead97fa625df43180efe..0c5df5aa1127f215eea6b69fb917e6504c80b332 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -83,11 +83,12 @@ static int32_t mnodeVgroupActionInsert(SSdbOper *pOper) { // refer to db SDbObj *pDb = mnodeGetDb(pVgroup->dbName); if (pDb == NULL) { + mError("vgId:%d, db:%s is not exist while insert into hash", pVgroup->vgId, pVgroup->dbName); return TSDB_CODE_MND_INVALID_DB; } if (pDb->status != TSDB_DB_STATUS_READY) { - mError("db:%s, status:%d, in dropping", pDb->name, pDb->status); + mError("vgId:%d, db:%s status:%d, in dropping", pVgroup->vgId, pDb->name, pDb->status); return TSDB_CODE_MND_DB_IN_DROPPING; } @@ -116,10 +117,12 @@ static int32_t mnodeVgroupActionInsert(SSdbOper *pOper) { static int32_t mnodeVgroupActionDelete(SSdbOper *pOper) { SVgObj *pVgroup = pOper->pObj; - if (pVgroup->pDb != NULL) { - mnodeRemoveVgroupFromDb(pVgroup); + if (pVgroup->pDb == NULL) { + mError("vgId:%d, db:%s is not exist while insert into hash", pVgroup->vgId, pVgroup->dbName); + return TSDB_CODE_MND_VGROUP_NOT_EXIST; } + mnodeRemoveVgroupFromDb(pVgroup); mnodeDecDbRef(pVgroup->pDb); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { @@ -517,6 +520,19 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { dnodeReprocessMnodeWriteMsg(pMsg); return TSDB_CODE_MND_ACTION_IN_PROGRESS; + // if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_READY) { + // mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId, + // pDb->name, pVgroup->numOfVnodes); + // pVgroup->status = TAOS_VG_STATUS_READY; + // SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb}; + // (void)sdbUpdateRow(&desc); + // dnodeReprocessMnodeWriteMsg(pMsg); + // return TSDB_CODE_MND_ACTION_IN_PROGRESS; + // } else { + // mError("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d, but vgroup is dropping", pMsg->rpcMsg.ahandle, + // pMsg, pVgroup->vgId, pDb->name, pVgroup->numOfVnodes); + // return TSDB_CODE_MND_VGROUP_NOT_EXIST; + // } } } @@ -955,7 +971,7 @@ void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle) { static void mnodeSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) { pVgroup->status = TAOS_VG_STATUS_DROPPING; // deleting - mDebug("vgId:%d, send drop all vnodes msg, ahandle:%p", pVgroup->vgId, ahandle); + mDebug("vgId:%d, send drop all vnodes msg, ahandle:%p db:%s", pVgroup->vgId, ahandle, pVgroup->dbName); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { SRpcEpSet epSet = mnodeGetEpSetFromIp(pVgroup->vnodeGid[i].pDnode->dnodeEp); mDebug("vgId:%d, send drop vnode msg to dnode:%d, ahandle:%p", pVgroup->vgId, pVgroup->vnodeGid[i].dnodeId, ahandle); @@ -1117,6 +1133,7 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) { } mnodeDecVgroupRef(pVgroup); + numOfVgroups++; } sdbFreeIter(pIter);