[td-1747]
This commit is contained in:
parent
67ffdd17be
commit
05325532ec
|
@ -5259,26 +5259,6 @@ int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void tscAddTimestampColumn(SQueryInfo* pQueryInfo, int16_t functionId, int16_t tableIndex) {
|
|
||||||
// // the first column not timestamp column, add it
|
|
||||||
// SSqlExpr* pExpr = NULL;
|
|
||||||
// if (tscSqlExprNumOfExprs(pQueryInfo) > 0) {
|
|
||||||
// pExpr = tscSqlExprGet(pQueryInfo, 0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (pExpr == NULL || pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX || pExpr->functionId != functionId) {
|
|
||||||
// SColumnIndex index = {tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
|
||||||
//
|
|
||||||
// pExpr = tscSqlExprInsert(pQueryInfo, 0, functionId, &index, TSDB_DATA_TYPE_TIMESTAMP, TSDB_KEYSIZE, TSDB_KEYSIZE, false);
|
|
||||||
// pExpr->colInfo.flag = TSDB_COL_NORMAL;
|
|
||||||
//
|
|
||||||
// // NOTE: tag column does not add to source column list
|
|
||||||
// SColumnList ids = getColumnList(1, tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX);
|
|
||||||
//
|
|
||||||
// insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, "ts", pExpr);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex) {
|
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex) {
|
||||||
SQueryInfo* pParentQueryInfo = tscGetQueryInfoDetail(&pParentObj->cmd, subClauseIndex);
|
SQueryInfo* pParentQueryInfo = tscGetQueryInfoDetail(&pParentObj->cmd, subClauseIndex);
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
|
||||||
.numOfColumns = pTableMetaMsg->numOfColumns,
|
.numOfColumns = pTableMetaMsg->numOfColumns,
|
||||||
};
|
};
|
||||||
|
|
||||||
pTableMeta->id.tid = pTableMetaMsg->sid;
|
pTableMeta->id.tid = pTableMetaMsg->tid;
|
||||||
pTableMeta->id.uid = pTableMetaMsg->uid;
|
pTableMeta->id.uid = pTableMetaMsg->uid;
|
||||||
|
|
||||||
SCMVgroupInfo* pVgroupInfo = &pTableMeta->vgroupInfo;
|
SCMVgroupInfo* pVgroupInfo = &pTableMeta->vgroupInfo;
|
||||||
|
|
|
@ -1650,7 +1650,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
STableMetaMsg *pMetaMsg = (STableMetaMsg *)pSql->res.pRsp;
|
STableMetaMsg *pMetaMsg = (STableMetaMsg *)pSql->res.pRsp;
|
||||||
|
|
||||||
pMetaMsg->sid = htonl(pMetaMsg->sid);
|
pMetaMsg->tid = htonl(pMetaMsg->tid);
|
||||||
pMetaMsg->sversion = htons(pMetaMsg->sversion);
|
pMetaMsg->sversion = htons(pMetaMsg->sversion);
|
||||||
pMetaMsg->tversion = htons(pMetaMsg->tversion);
|
pMetaMsg->tversion = htons(pMetaMsg->tversion);
|
||||||
pMetaMsg->vgroup.vgId = htonl(pMetaMsg->vgroup.vgId);
|
pMetaMsg->vgroup.vgId = htonl(pMetaMsg->vgroup.vgId);
|
||||||
|
@ -1660,9 +1660,9 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
pMetaMsg->numOfColumns = htons(pMetaMsg->numOfColumns);
|
||||||
|
|
||||||
if ((pMetaMsg->tableType != TSDB_SUPER_TABLE) &&
|
if ((pMetaMsg->tableType != TSDB_SUPER_TABLE) &&
|
||||||
(pMetaMsg->sid <= 0 || pMetaMsg->vgroup.vgId < 2 || pMetaMsg->vgroup.numOfEps <= 0)) {
|
(pMetaMsg->tid <= 0 || pMetaMsg->vgroup.vgId < 2 || pMetaMsg->vgroup.numOfEps <= 0)) {
|
||||||
tscError("invalid value in table numOfEps:%d, vgId:%d tid:%d, name:%s", pMetaMsg->vgroup.numOfEps, pMetaMsg->vgroup.vgId,
|
tscError("invalid value in table numOfEps:%d, vgId:%d tid:%d, name:%s", pMetaMsg->vgroup.numOfEps, pMetaMsg->vgroup.vgId,
|
||||||
pMetaMsg->sid, pMetaMsg->tableId);
|
pMetaMsg->tid, pMetaMsg->tableId);
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1845,8 +1845,10 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
|
||||||
SVgroupsMsg * pVgroupMsg = (SVgroupsMsg *) pMsg;
|
SVgroupsMsg * pVgroupMsg = (SVgroupsMsg *) pMsg;
|
||||||
pVgroupMsg->numOfVgroups = htonl(pVgroupMsg->numOfVgroups);
|
pVgroupMsg->numOfVgroups = htonl(pVgroupMsg->numOfVgroups);
|
||||||
|
|
||||||
size_t size = sizeof(SCMVgroupInfo) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsInfo);
|
size_t size = sizeof(SCMVgroupMsg) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsMsg);
|
||||||
pInfo->vgroupList = calloc(1, size);
|
|
||||||
|
size_t vgroupsz = sizeof(SCMVgroupInfo) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsInfo);
|
||||||
|
pInfo->vgroupList = calloc(1, vgroupsz);
|
||||||
assert(pInfo->vgroupList != NULL);
|
assert(pInfo->vgroupList != NULL);
|
||||||
|
|
||||||
pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups;
|
pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups;
|
||||||
|
@ -1898,7 +1900,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
pMetaMsg->numOfColumns = ntohs(pMetaMsg->numOfColumns);
|
pMetaMsg->numOfColumns = ntohs(pMetaMsg->numOfColumns);
|
||||||
|
|
||||||
pSchema = pMetaMsg->schema;
|
pSchema = pMetaMsg->schema;
|
||||||
pMetaMsg->sid = ntohs(pMetaMsg->sid);
|
pMetaMsg->tid = ntohs(pMetaMsg->tid);
|
||||||
for (int i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
for (int i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
||||||
pSchema->bytes = htons(pSchema->bytes);
|
pSchema->bytes = htons(pSchema->bytes);
|
||||||
pSchema++;
|
pSchema++;
|
||||||
|
|
|
@ -1142,7 +1142,6 @@ static void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code);
|
||||||
|
|
||||||
static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
||||||
|
|
||||||
// TODO
|
|
||||||
int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) {
|
int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) {
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
SSqlCmd * pCmd = &pSql->cmd;
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
@ -1298,14 +1297,6 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// todo add test
|
|
||||||
// SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
|
||||||
// if (pState == NULL) {
|
|
||||||
// code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
// goto _error;
|
|
||||||
// }
|
|
||||||
|
|
||||||
pSql->subState.numOfSub = pQueryInfo->numOfTables;
|
pSql->subState.numOfSub = pQueryInfo->numOfTables;
|
||||||
|
|
||||||
bool hasEmptySub = false;
|
bool hasEmptySub = false;
|
||||||
|
|
|
@ -173,15 +173,15 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
|
||||||
return rpcRsp.code;
|
return rpcRsp.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
|
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid) {
|
||||||
dDebug("vgId:%d, sid:%d send config table msg to mnode", vgId, sid);
|
dDebug("vgId:%d, tid:%d send config table msg to mnode", vgId, tid);
|
||||||
|
|
||||||
int32_t contLen = sizeof(SDMConfigTableMsg);
|
int32_t contLen = sizeof(SDMConfigTableMsg);
|
||||||
SDMConfigTableMsg *pMsg = rpcMallocCont(contLen);
|
SDMConfigTableMsg *pMsg = rpcMallocCont(contLen);
|
||||||
|
|
||||||
pMsg->dnodeId = htonl(dnodeGetDnodeId());
|
pMsg->dnodeId = htonl(dnodeGetDnodeId());
|
||||||
pMsg->vgId = htonl(vgId);
|
pMsg->vgId = htonl(vgId);
|
||||||
pMsg->sid = htonl(sid);
|
pMsg->tid = htonl(tid);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {0};
|
SRpcMsg rpcMsg = {0};
|
||||||
rpcMsg.pCont = pMsg;
|
rpcMsg.pCont = pMsg;
|
||||||
|
@ -194,18 +194,18 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
|
||||||
|
|
||||||
if (rpcRsp.code != 0) {
|
if (rpcRsp.code != 0) {
|
||||||
rpcFreeCont(rpcRsp.pCont);
|
rpcFreeCont(rpcRsp.pCont);
|
||||||
dError("vgId:%d, sid:%d failed to config table from mnode", vgId, sid);
|
dError("vgId:%d, tid:%d failed to config table from mnode", vgId, tid);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
dInfo("vgId:%d, sid:%d config table msg is received", vgId, sid);
|
dInfo("vgId:%d, tid:%d config table msg is received", vgId, tid);
|
||||||
|
|
||||||
// delete this after debug finished
|
// delete this after debug finished
|
||||||
SMDCreateTableMsg *pTable = rpcRsp.pCont;
|
SMDCreateTableMsg *pTable = rpcRsp.pCont;
|
||||||
int16_t numOfColumns = htons(pTable->numOfColumns);
|
int16_t numOfColumns = htons(pTable->numOfColumns);
|
||||||
int16_t numOfTags = htons(pTable->numOfTags);
|
int16_t numOfTags = htons(pTable->numOfTags);
|
||||||
int32_t sid = htonl(pTable->sid);
|
int32_t tableId = htonl(pTable->tid);
|
||||||
uint64_t uid = htobe64(pTable->uid);
|
uint64_t uid = htobe64(pTable->uid);
|
||||||
dInfo("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, sid, uid);
|
dInfo("table:%s, numOfColumns:%d numOfTags:%d tid:%d uid:%" PRIu64, pTable->tableId, numOfColumns, numOfTags, tableId, uid);
|
||||||
|
|
||||||
return rpcRsp.pCont;
|
return rpcRsp.pCont;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
|
||||||
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg);
|
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg);
|
||||||
void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
|
void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
|
||||||
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet);
|
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet);
|
||||||
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid);
|
void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid);
|
||||||
|
|
||||||
void *dnodeAllocateVnodeWqueue(void *pVnode);
|
void *dnodeAllocateVnodeWqueue(void *pVnode);
|
||||||
void dnodeFreeVnodeWqueue(void *queue);
|
void dnodeFreeVnodeWqueue(void *queue);
|
||||||
|
|
|
@ -251,7 +251,7 @@ typedef struct {
|
||||||
int8_t tableType;
|
int8_t tableType;
|
||||||
int16_t numOfColumns;
|
int16_t numOfColumns;
|
||||||
int16_t numOfTags;
|
int16_t numOfTags;
|
||||||
int32_t sid;
|
int32_t tid;
|
||||||
int32_t sversion;
|
int32_t sversion;
|
||||||
int32_t tversion;
|
int32_t tversion;
|
||||||
int32_t tagDataLen;
|
int32_t tagDataLen;
|
||||||
|
@ -360,7 +360,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t sid;
|
int32_t tid;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
char tableId[TSDB_TABLE_FNAME_LEN];
|
char tableId[TSDB_TABLE_FNAME_LEN];
|
||||||
} SMDDropTableMsg;
|
} SMDDropTableMsg;
|
||||||
|
@ -699,7 +699,7 @@ typedef struct STableMetaMsg {
|
||||||
int16_t numOfColumns;
|
int16_t numOfColumns;
|
||||||
int16_t sversion;
|
int16_t sversion;
|
||||||
int16_t tversion;
|
int16_t tversion;
|
||||||
int32_t sid;
|
int32_t tid;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
SCMVgroupMsg vgroup;
|
SCMVgroupMsg vgroup;
|
||||||
SSchema schema[];
|
SSchema schema[];
|
||||||
|
@ -747,7 +747,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t sid;
|
int32_t tid;
|
||||||
} SDMConfigTableMsg;
|
} SDMConfigTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -115,7 +115,7 @@ typedef struct {
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int32_t numOfColumns; //used by normal table
|
int32_t numOfColumns; //used by normal table
|
||||||
int32_t sid;
|
int32_t tid;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
int8_t updateEnd[4];
|
int8_t updateEnd[4];
|
||||||
|
|
|
@ -303,7 +303,7 @@ static int32_t mnodeChildTableActionRestored() {
|
||||||
|
|
||||||
SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId);
|
SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId);
|
||||||
if (pVgroup == NULL) {
|
if (pVgroup == NULL) {
|
||||||
mError("ctable:%s, failed to get vgId:%d sid:%d, discard it", pTable->info.tableId, pTable->vgId, pTable->sid);
|
mError("ctable:%s, failed to get vgId:%d tid:%d, discard it", pTable->info.tableId, pTable->vgId, pTable->tid);
|
||||||
pTable->vgId = 0;
|
pTable->vgId = 0;
|
||||||
SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb};
|
SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb};
|
||||||
sdbDeleteRow(&desc);
|
sdbDeleteRow(&desc);
|
||||||
|
@ -314,7 +314,7 @@ static int32_t mnodeChildTableActionRestored() {
|
||||||
|
|
||||||
if (strcmp(pVgroup->dbName, pDb->name) != 0) {
|
if (strcmp(pVgroup->dbName, pDb->name) != 0) {
|
||||||
mError("ctable:%s, db:%s not match with vgId:%d db:%s sid:%d, discard it",
|
mError("ctable:%s, db:%s not match with vgId:%d db:%s sid:%d, discard it",
|
||||||
pTable->info.tableId, pDb->name, pTable->vgId, pVgroup->dbName, pTable->sid);
|
pTable->info.tableId, pDb->name, pTable->vgId, pVgroup->dbName, pTable->tid);
|
||||||
pTable->vgId = 0;
|
pTable->vgId = 0;
|
||||||
SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb};
|
SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb};
|
||||||
sdbDeleteRow(&desc);
|
sdbDeleteRow(&desc);
|
||||||
|
@ -771,8 +771,8 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
return mnodeProcessDropSuperTableMsg(pMsg);
|
return mnodeProcessDropSuperTableMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable;
|
SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable;
|
||||||
mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pDrop->tableId, pCTable->vgId, pCTable->sid, pCTable->uid);
|
pDrop->tableId, pCTable->vgId, pCTable->tid, pCTable->uid);
|
||||||
return mnodeProcessDropChildTableMsg(pMsg);
|
return mnodeProcessDropChildTableMsg(pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1479,6 +1479,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
|
||||||
if (pTable != NULL && pTable->vgHash != NULL) {
|
if (pTable != NULL && pTable->vgHash != NULL) {
|
||||||
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupMsg) + sizeof(SVgroupsMsg));
|
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupMsg) + sizeof(SVgroupsMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1593,7 +1594,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
|
||||||
pCreate->vgId = htonl(pTable->vgId);
|
pCreate->vgId = htonl(pTable->vgId);
|
||||||
pCreate->tableType = pTable->info.type;
|
pCreate->tableType = pTable->info.type;
|
||||||
pCreate->createdTime = htobe64(pTable->createdTime);
|
pCreate->createdTime = htobe64(pTable->createdTime);
|
||||||
pCreate->sid = htonl(pTable->sid);
|
pCreate->tid = htonl(pTable->tid);
|
||||||
pCreate->sqlDataLen = htonl(pTable->sqlLen);
|
pCreate->sqlDataLen = htonl(pTable->sqlLen);
|
||||||
pCreate->uid = htobe64(pTable->uid);
|
pCreate->uid = htobe64(pTable->uid);
|
||||||
|
|
||||||
|
@ -1642,7 +1643,7 @@ static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid);
|
pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid);
|
||||||
|
|
||||||
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||||
SMDCreateTableMsg *pMDCreate = mnodeBuildCreateChildTableMsg(pCreate, pTable);
|
SMDCreateTableMsg *pMDCreate = mnodeBuildCreateChildTableMsg(pCreate, pTable);
|
||||||
|
@ -1684,7 +1685,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg,
|
mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code));
|
pTable->info.tableId, pTable->tid, pTable->uid, tstrerror(code));
|
||||||
SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .table = tsChildTableSdb};
|
SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .table = tsChildTableSdb};
|
||||||
sdbDeleteRow(&desc);
|
sdbDeleteRow(&desc);
|
||||||
return code;
|
return code;
|
||||||
|
@ -1708,7 +1709,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
|
|
||||||
pTable->info.tableId = strdup(pCreate->tableId);
|
pTable->info.tableId = strdup(pCreate->tableId);
|
||||||
pTable->createdTime = taosGetTimestampMs();
|
pTable->createdTime = taosGetTimestampMs();
|
||||||
pTable->sid = tid;
|
pTable->tid = tid;
|
||||||
pTable->vgId = pVgroup->vgId;
|
pTable->vgId = pVgroup->vgId;
|
||||||
|
|
||||||
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
||||||
|
@ -1722,7 +1723,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pTable->suid = pMsg->pSTable->uid;
|
pTable->suid = pMsg->pSTable->uid;
|
||||||
pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 24) +
|
pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) +
|
||||||
((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||||
pTable->superTable = pMsg->pSTable;
|
pTable->superTable = pMsg->pSTable;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1730,7 +1731,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
int64_t us = taosGetTimestampUs();
|
int64_t us = taosGetTimestampUs();
|
||||||
pTable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
pTable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||||
} else {
|
} else {
|
||||||
pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 24) +
|
pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) +
|
||||||
((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1787,7 +1788,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mDebug("app:%p:%p, table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pTable->info.tableId, pVgroup->vgId, pTable->sid, pTable->uid);
|
pTable->info.tableId, pVgroup->vgId, pTable->tid, pTable->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1805,8 +1806,8 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
if (pMsg->retry == 0) {
|
if (pMsg->retry == 0) {
|
||||||
if (pMsg->pTable == NULL) {
|
if (pMsg->pTable == NULL) {
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
int32_t sid = 0;
|
int32_t tid = 0;
|
||||||
code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &sid);
|
code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mDebug("app:%p:%p, table:%s, failed to get available vgroup, reason:%s", pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, failed to get available vgroup, reason:%s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pCreate->tableId, tstrerror(code));
|
pCreate->tableId, tstrerror(code));
|
||||||
|
@ -1820,7 +1821,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
pMsg->pVgroup = pVgroup;
|
pMsg->pVgroup = pVgroup;
|
||||||
mnodeIncVgroupRef(pVgroup);
|
mnodeIncVgroupRef(pVgroup);
|
||||||
|
|
||||||
return mnodeDoCreateChildTable(pMsg, sid);
|
return mnodeDoCreateChildTable(pMsg, tid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableId);
|
||||||
|
@ -1850,13 +1851,13 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
||||||
tstrncpy(pDrop->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(pDrop->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN);
|
||||||
pDrop->vgId = htonl(pTable->vgId);
|
pDrop->vgId = htonl(pTable->vgId);
|
||||||
pDrop->contLen = htonl(sizeof(SMDDropTableMsg));
|
pDrop->contLen = htonl(sizeof(SMDDropTableMsg));
|
||||||
pDrop->sid = htonl(pTable->sid);
|
pDrop->tid = htonl(pTable->tid);
|
||||||
pDrop->uid = htobe64(pTable->uid);
|
pDrop->uid = htobe64(pTable->uid);
|
||||||
|
|
||||||
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup);
|
SRpcEpSet epSet = mnodeGetEpSetFromVgroup(pMsg->pVgroup);
|
||||||
|
|
||||||
mInfo("app:%p:%p, ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mInfo("app:%p:%p, ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pDrop->tableId, pTable->vgId, pTable->sid, pTable->uid);
|
pDrop->tableId, pTable->vgId, pTable->tid, pTable->uid);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.ahandle = pMsg,
|
.ahandle = pMsg,
|
||||||
|
@ -2095,7 +2096,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
||||||
|
|
||||||
pMeta->uid = htobe64(pTable->uid);
|
pMeta->uid = htobe64(pTable->uid);
|
||||||
pMeta->sid = htonl(pTable->sid);
|
pMeta->tid = htonl(pTable->tid);
|
||||||
pMeta->precision = pDb->cfg.precision;
|
pMeta->precision = pDb->cfg.precision;
|
||||||
pMeta->tableType = pTable->info.type;
|
pMeta->tableType = pTable->info.type;
|
||||||
tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -2135,7 +2136,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
||||||
pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId);
|
pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId);
|
||||||
|
|
||||||
mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pTable->info.tableId, pTable->uid, pTable->vgId, pTable->sid);
|
pTable->info.tableId, pTable->uid, pTable->vgId, pTable->tid);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2283,11 +2284,11 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) {
|
static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) {
|
||||||
SVgObj *pVgroup = mnodeGetVgroup(vnode);
|
SVgObj *pVgroup = mnodeGetVgroup(vnode);
|
||||||
if (pVgroup == NULL) return NULL;
|
if (pVgroup == NULL) return NULL;
|
||||||
|
|
||||||
SChildTableObj *pTable = pVgroup->tableList[sid - 1];
|
SChildTableObj *pTable = pVgroup->tableList[tid - 1];
|
||||||
mnodeIncTableRef((STableObj *)pTable);
|
mnodeIncTableRef((STableObj *)pTable);
|
||||||
|
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
|
@ -2335,12 +2336,12 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s",
|
mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||||
mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
|
mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
|
||||||
|
|
||||||
if (rpcMsg->code != TSDB_CODE_SUCCESS) {
|
if (rpcMsg->code != TSDB_CODE_SUCCESS) {
|
||||||
mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s",
|
mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||||
tstrerror(rpcMsg->code));
|
tstrerror(rpcMsg->code));
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
||||||
return;
|
return;
|
||||||
|
@ -2378,7 +2379,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
|
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
|
||||||
if (sdbCheckRowDeleted(tsChildTableSdb, pTable)) {
|
if (sdbCheckRowDeleted(tsChildTableSdb, pTable)) {
|
||||||
mDebug("app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%" PRIu64,
|
mDebug("app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%" PRIu64,
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid);
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid);
|
||||||
|
|
||||||
// if the vgroup is already dropped from hash, it can't be accquired by pTable->vgId
|
// 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
|
// so the refCount of vgroup can not be decreased
|
||||||
|
@ -2413,13 +2414,13 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
if (mnodeMsg->retry++ < 10) {
|
if (mnodeMsg->retry++ < 10) {
|
||||||
mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%" PRIu64
|
mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%" PRIu64
|
||||||
" result:%s thandle:%p",
|
" result:%s thandle:%p",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, pTable->vgId, pTable->sid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, pTable->vgId, pTable->tid,
|
||||||
pTable->uid, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
pTable->uid, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
||||||
|
|
||||||
dnodeDelayReprocessMnodeWriteMsg(mnodeMsg);
|
dnodeDelayReprocessMnodeWriteMsg(mnodeMsg);
|
||||||
} else {
|
} else {
|
||||||
mError("app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%" PRIu64 ", result:%s thandle:%p",
|
mError("app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%" PRIu64 ", result:%s thandle:%p",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||||
tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
||||||
|
|
||||||
SSdbOper oper = {.type = SDB_OPER_GLOBAL, .table = tsChildTableSdb, .pObj = pTable};
|
SSdbOper oper = {.type = SDB_OPER_GLOBAL, .table = tsChildTableSdb, .pObj = pTable};
|
||||||
|
@ -2674,7 +2675,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
// tid
|
// tid
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int32_t*) pWrite = pTable->sid;
|
*(int32_t*) pWrite = pTable->tid;
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
//vgid
|
//vgid
|
||||||
|
|
|
@ -793,12 +793,12 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v
|
||||||
|
|
||||||
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
||||||
int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool);
|
int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool);
|
||||||
if (pTable->sid > idPoolSize) {
|
if (pTable->tid > idPoolSize) {
|
||||||
mnodeAllocVgroupIdPool(pVgroup);
|
mnodeAllocVgroupIdPool(pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTable->sid >= 1) {
|
if (pTable->tid >= 1) {
|
||||||
taosIdPoolMarkStatus(pVgroup->idPool, pTable->sid);
|
taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid);
|
||||||
pVgroup->numOfTables++;
|
pVgroup->numOfTables++;
|
||||||
// The create vgroup message may be received later than the create table message
|
// The create vgroup message may be received later than the create table message
|
||||||
// and the writing order in sdb is therefore uncertain
|
// and the writing order in sdb is therefore uncertain
|
||||||
|
@ -808,8 +808,8 @@ void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
||||||
if (pTable->sid >= 1) {
|
if (pTable->tid >= 1) {
|
||||||
taosFreeId(pVgroup->idPool, pTable->sid);
|
taosFreeId(pVgroup->idPool, pTable->tid);
|
||||||
pVgroup->numOfTables--;
|
pVgroup->numOfTables--;
|
||||||
// The create vgroup message may be received later than the create table message
|
// The create vgroup message may be received later than the create table message
|
||||||
// and the writing order in sdb is therefore uncertain
|
// and the writing order in sdb is therefore uncertain
|
||||||
|
|
|
@ -239,7 +239,7 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbInitTableCfg(pCfg, pMsg->tableType, htobe64(pMsg->uid), htonl(pMsg->sid)) < 0) goto _err;
|
if (tsdbInitTableCfg(pCfg, pMsg->tableType, htobe64(pMsg->uid), htonl(pMsg->tid)) < 0) goto _err;
|
||||||
if (tdInitTSchemaBuilder(&schemaBuilder, htonl(pMsg->sversion)) < 0) {
|
if (tdInitTSchemaBuilder(&schemaBuilder, htonl(pMsg->sversion)) < 0) {
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -149,7 +149,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
vDebug("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId);
|
vDebug("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId);
|
||||||
STableId tableId = {.uid = htobe64(pTable->uid), .tid = htonl(pTable->sid)};
|
STableId tableId = {.uid = htobe64(pTable->uid), .tid = htonl(pTable->tid)};
|
||||||
|
|
||||||
if (tsdbDropTable(pVnode->tsdb, tableId) < 0) code = terrno;
|
if (tsdbDropTable(pVnode->tsdb, tableId) < 0) code = terrno;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue