未验证 提交 54b033bb 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2443 from taosdata/hotfix/crash

crash while drop stable
......@@ -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;
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;
}
return code;
}
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);
......
......@@ -76,7 +76,7 @@ endi
# insert nchar data with a pair of single quotes
$col = 'NCHAR'
$col_ = NCHAR
sql insert into $tb values (now, $col )
sql insert into $tb values (now+1s, $col )
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
......@@ -87,7 +87,7 @@ endi
# insert nchar data with a pair of double quotes
$col = "NCHAR"
$col_ = NCHAR
sql insert into $tb values (now, $col )
sql insert into $tb values (now+2s, $col )
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
......@@ -98,7 +98,7 @@ endi
# insert nchar data without quotes
$col = NCHAR
$col_ = nchar
sql_error insert into $tb values (now, $col )
sql_error insert into $tb values (now+3s, $col )
sql select * from $tb order by ts desc
#print expected: $col_
#print returned: $data01
......@@ -107,10 +107,10 @@ sql select * from $tb order by ts desc
#endi
# insert nchar data with space and no quotes
sql_error insert into $tb values (now, n char )
sql_error insert into $tb values (now+4s, n char )
# insert nchar data with space and a pair of single quotes
sql insert into $tb values (now, 'NCHAR' )
sql insert into $tb values (now+5s, 'NCHAR' )
sql select * from $tb order by ts desc
print expected: NCHAR
print returned: $data01
......@@ -126,7 +126,7 @@ endi
label1:
# insert nchar data with space and a pair of double quotes
sql insert into $tb values (now, "NCHAR" )
sql insert into $tb values (now+6s, "NCHAR" )
sql select * from $tb order by ts desc
print expected: N CHAR
print returned: $data01
......@@ -141,7 +141,7 @@ else
endi
label2:
sql insert into $tb values (now, "涛思" )
sql insert into $tb values (now+7s, "涛思" )
sql select * from $tb order by ts desc
print expected: 涛思
print returned: $data01
......@@ -150,9 +150,9 @@ if $data01 != 涛思 then
endi
# insert nchar data with a single quote and a double quote
#sql insert into $tb values (now, 'NCHAR")
sql_error insert into $tb values (now, 'NCHAR")
sql_error insert into $tb values (now, 'NCHAR])
#sql insert into $tb values (now+8s, 'NCHAR")
sql_error insert into $tb values (now+9s, 'NCHAR")
sql_error insert into $tb values (now+10s, 'NCHAR])
sql drop table $tb
sql drop table $mt
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册