[TD-437] fix crash while drop super table
This commit is contained in:
parent
3fcb47fb5b
commit
47c15a9e6f
|
@ -48,6 +48,7 @@ typedef struct SMnodeMsg {
|
|||
struct SDbObj * pDb;
|
||||
struct SVgObj * pVgroup;
|
||||
struct STableObj *pTable;
|
||||
struct SSuperTableObj *pSTable;
|
||||
} SMnodeMsg;
|
||||
|
||||
void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg);
|
||||
|
|
|
@ -311,6 +311,15 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
|
|||
if (pCfg->replications < 0) pCfg->replications = tsReplications;
|
||||
}
|
||||
|
||||
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
|
||||
SDbObj *pDb = pMsg->pDb;
|
||||
if (pDb != NULL) {
|
||||
mLPrint("db:%s, is created by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMsg) {
|
||||
int32_t code = acctCheck(pAcct, ACCT_GRANT_DB);
|
||||
if (code != 0) return code;
|
||||
|
@ -364,18 +373,18 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs
|
|||
.table = tsDbSdb,
|
||||
.pObj = pDb,
|
||||
.rowSize = sizeof(SDbObj),
|
||||
.pMsg = pMsg
|
||||
.pMsg = pMsg,
|
||||
.cb = mnodeCreateDbCb
|
||||
};
|
||||
|
||||
code = sdbInsertRow(&oper);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tfree(pDb);
|
||||
mLPrint("db:%s, failed to create, reason:%s", pDb->name, tstrerror(code));
|
||||
return code;
|
||||
} else {
|
||||
mLPrint("db:%s, is created by %s", pDb->name, mnodeGetUserFromMsg(pMsg));
|
||||
if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
|
||||
|
|
|
@ -54,6 +54,7 @@ void mnodeCleanupMsg(SMnodeMsg *pMsg) {
|
|||
if (pMsg->pDb) mnodeDecDbRef(pMsg->pDb);
|
||||
if (pMsg->pVgroup) mnodeDecVgroupRef(pMsg->pVgroup);
|
||||
if (pMsg->pTable) mnodeDecTableRef(pMsg->pTable);
|
||||
if (pMsg->pSTable) mnodeDecTableRef(pMsg->pSTable);
|
||||
if (pMsg->pAcct) mnodeDecAcctRef(pMsg->pAcct);
|
||||
if (pMsg->pDnode) mnodeDecDnodeRef(pMsg->pDnode);
|
||||
}
|
||||
|
|
|
@ -783,7 +783,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
|
|||
static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
||||
if (pTable != NULL) {
|
||||
mLPrint("app:%p:%p, stable:%s, create result:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||
mLPrint("app:%p:%p, stable:%s, is created in sdb, result:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||
tstrerror(code));
|
||||
}
|
||||
|
||||
|
@ -852,6 +852,15 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
||||
if (pTable != NULL) {
|
||||
mLPrint("app:%p:%p, stable:%s, is dropped from sdb, result:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||
tstrerror(code));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
||||
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
||||
|
||||
|
@ -882,19 +891,20 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
|
||||
SSdbOper oper = {
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.type = SDB_OPER_GLOBAL,
|
||||
.table = tsSuperTableSdb,
|
||||
.pObj = pStable,
|
||||
.pMsg = pMsg
|
||||
.pObj = pStable,
|
||||
.pMsg = pMsg,
|
||||
.cb = mnodeDropSuperTableCb
|
||||
};
|
||||
|
||||
int32_t code = sdbDeleteRow(&oper);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code));
|
||||
code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
return code;
|
||||
int32_t code = sdbDeleteRow(&oper);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("app:%p:%p, table:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
|
||||
return code;
|
||||
} else {
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) {
|
||||
|
@ -1596,19 +1606,18 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
|||
|
||||
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
||||
STagData *pTagData = (STagData *) pCreate->schema; // it is a tag key
|
||||
SSuperTableObj *pSuperTable = mnodeGetSuperTable(pTagData->name);
|
||||
if (pSuperTable == NULL) {
|
||||
if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(pTagData->name);
|
||||
if (pMsg->pSTable == NULL) {
|
||||
mError("app:%p:%p, table:%s, corresponding super table:%s does not exist", pMsg->rpcMsg.ahandle, pMsg,
|
||||
pCreate->tableId, pTagData->name);
|
||||
mnodeDestroyChildTable(pTable);
|
||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||
}
|
||||
mnodeDecTableRef(pSuperTable);
|
||||
|
||||
pTable->suid = pSuperTable->uid;
|
||||
|
||||
pTable->suid = pMsg->pSTable->uid;
|
||||
pTable->uid = (((uint64_t)pTable->vgId) << 40) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 16) +
|
||||
(sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||
pTable->superTable = pSuperTable;
|
||||
pTable->superTable = pMsg->pSTable;
|
||||
} else {
|
||||
pTable->uid = (((uint64_t) pTable->createdTime) << 16) + (sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||
pTable->sversion = 0;
|
||||
|
@ -1661,9 +1670,10 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
|||
pMsg->pTable = NULL;
|
||||
mError("app:%p:%p, table:%s, update sdb error, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
|
||||
tstrerror(code));
|
||||
}
|
||||
|
||||
return code;
|
||||
return code;
|
||||
} else {
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||
|
@ -1698,12 +1708,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
|||
mTrace("app:%p:%p, table:%s, create table in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId,
|
||||
pVgroup->vgId, sid);
|
||||
|
||||
code = mnodeDoCreateChildTable(pMsg, sid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
} else {
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
return mnodeDoCreateChildTable(pMsg, sid);
|
||||
}
|
||||
} else {
|
||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId);
|
||||
|
|
|
@ -30,10 +30,15 @@ done
|
|||
echo LOOP_TIMES ${LOOP_TIMES}
|
||||
echo CMD_NAME ${CMD_NAME}
|
||||
|
||||
GREEN='\033[1;32m'
|
||||
GREEN_DARK='\033[0;32m'
|
||||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
for ((i=0; i<$LOOP_TIMES; i++ ))
|
||||
do
|
||||
echo loop $i
|
||||
echo cmd $CMD_NAME
|
||||
echo -e $GREEN loop $i $NC
|
||||
echo -e $GREEN cmd $CMD_NAME $NC
|
||||
$CMD_NAME
|
||||
sleep 2
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue