Merge pull request #7435 from taosdata/hotfix/TD-6131
[TD-6131]<fix> taosd crash when 'show vnodes ' return too many results
This commit is contained in:
commit
00d082806e
|
@ -107,6 +107,9 @@ extern int32_t tsQuorum;
|
||||||
extern int8_t tsUpdate;
|
extern int8_t tsUpdate;
|
||||||
extern int8_t tsCacheLastRow;
|
extern int8_t tsCacheLastRow;
|
||||||
|
|
||||||
|
//tsdb
|
||||||
|
extern bool tsdbForceKeepFile;
|
||||||
|
|
||||||
// balance
|
// balance
|
||||||
extern int8_t tsEnableBalance;
|
extern int8_t tsEnableBalance;
|
||||||
extern int8_t tsAlternativeRole;
|
extern int8_t tsAlternativeRole;
|
||||||
|
|
|
@ -151,6 +151,11 @@ int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
|
||||||
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
||||||
int32_t tsTableIncStepPerVnode = TSDB_TABLES_STEP;
|
int32_t tsTableIncStepPerVnode = TSDB_TABLES_STEP;
|
||||||
|
|
||||||
|
// tsdb config
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
bool tsdbForceKeepFile = false;
|
||||||
|
|
||||||
// balance
|
// balance
|
||||||
int8_t tsEnableBalance = 1;
|
int8_t tsEnableBalance = 1;
|
||||||
int8_t tsAlternativeRole = 0;
|
int8_t tsAlternativeRole = 0;
|
||||||
|
|
|
@ -274,6 +274,7 @@ typedef struct {
|
||||||
int32_t rowSize;
|
int32_t rowSize;
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
void * pIter;
|
void * pIter;
|
||||||
|
void * pVgIter;
|
||||||
void ** ppShow;
|
void ** ppShow;
|
||||||
int16_t offset[TSDB_MAX_COLUMNS];
|
int16_t offset[TSDB_MAX_COLUMNS];
|
||||||
int32_t bytes[TSDB_MAX_COLUMNS];
|
int32_t bytes[TSDB_MAX_COLUMNS];
|
||||||
|
|
|
@ -196,14 +196,20 @@ int32_t mnodeInitDnodes() {
|
||||||
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_CREATE_DNODE, mnodeProcessCreateDnodeMsg);
|
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_CREATE_DNODE, mnodeProcessCreateDnodeMsg);
|
||||||
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mnodeProcessDropDnodeMsg);
|
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mnodeProcessDropDnodeMsg);
|
||||||
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mnodeProcessCfgDnodeMsg);
|
mnodeAddWriteMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mnodeProcessCfgDnodeMsg);
|
||||||
|
|
||||||
mnodeAddPeerRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mnodeProcessCfgDnodeMsgRsp);
|
mnodeAddPeerRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mnodeProcessCfgDnodeMsgRsp);
|
||||||
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mnodeProcessDnodeStatusMsg);
|
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mnodeProcessDnodeStatusMsg);
|
||||||
|
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mnodeGetModuleMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mnodeGetModuleMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mnodeRetrieveModules);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mnodeRetrieveModules);
|
||||||
|
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeGetConfigMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeGetConfigMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeRetrieveConfigs);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeRetrieveConfigs);
|
||||||
|
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VNODES, mnodeGetVnodeMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VNODES, mnodeGetVnodeMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VNODES, mnodeRetrieveVnodes);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VNODES, mnodeRetrieveVnodes);
|
||||||
|
mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_VNODES, mnodeCancelGetNextVgroup);
|
||||||
|
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DNODE, mnodeGetDnodeMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DNODE, mnodeGetDnodeMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_DNODE, mnodeRetrieveDnodes);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_DNODE, mnodeRetrieveDnodes);
|
||||||
mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_DNODE, mnodeCancelGetNextDnode);
|
mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_DNODE, mnodeCancelGetNextDnode);
|
||||||
|
@ -1232,13 +1238,12 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
||||||
|
|
||||||
pDnode = (SDnodeObj *)(pShow->pIter);
|
pDnode = (SDnodeObj *)(pShow->pIter);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
void *pIter = NULL;
|
|
||||||
SVgObj *pVgroup;
|
SVgObj *pVgroup;
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
|
pShow->pVgIter = mnodeGetNextVgroup(pShow->pVgIter, &pVgroup);
|
||||||
if (pVgroup == NULL) break;
|
if (pVgroup == NULL) break;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) {
|
for (int32_t i = 0; i < pVgroup->numOfVnodes && numOfRows < rows; ++i) {
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[i];
|
SVnodeGid *pVgid = &pVgroup->vnodeGid[i];
|
||||||
if (pVgid->pDnode == pDnode) {
|
if (pVgid->pDnode == pDnode) {
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
@ -1250,10 +1255,13 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
STR_TO_VARSTR(pWrite, syncRole[pVgid->role]);
|
STR_TO_VARSTR(pWrite, syncRole[pVgid->role]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (numOfRows >= rows) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,8 +422,13 @@ static void* mnodePutShowObj(SShowObj *pShow) {
|
||||||
|
|
||||||
static void mnodeFreeShowObj(void *data) {
|
static void mnodeFreeShowObj(void *data) {
|
||||||
SShowObj *pShow = *(SShowObj **)data;
|
SShowObj *pShow = *(SShowObj **)data;
|
||||||
if (tsMnodeShowFreeIterFp[pShow->type] != NULL && pShow->pIter != NULL) {
|
if (tsMnodeShowFreeIterFp[pShow->type] != NULL) {
|
||||||
(*tsMnodeShowFreeIterFp[pShow->type])(pShow->pIter);
|
if (pShow->pVgIter != NULL) {
|
||||||
|
// only used in 'show vnodes "ep"'
|
||||||
|
(*tsMnodeShowFreeIterFp[pShow->type])(pShow->pVgIter);
|
||||||
|
} else {
|
||||||
|
if (pShow->pIter != NULL) (*tsMnodeShowFreeIterFp[pShow->type])(pShow->pIter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("%p, show is destroyed, data:%p index:%d", pShow, data, pShow->index);
|
mDebug("%p, show is destroyed, data:%p index:%d", pShow, data, pShow->index);
|
||||||
|
|
|
@ -37,8 +37,6 @@ static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo, int32_t *nExpired);
|
||||||
static int tsdbProcessExpiredFS(STsdbRepo *pRepo);
|
static int tsdbProcessExpiredFS(STsdbRepo *pRepo);
|
||||||
static int tsdbCreateMeta(STsdbRepo *pRepo);
|
static int tsdbCreateMeta(STsdbRepo *pRepo);
|
||||||
|
|
||||||
// For backward compatibility
|
|
||||||
bool tsdbForceKeepFile = false;
|
|
||||||
// ================== CURRENT file header info
|
// ================== CURRENT file header info
|
||||||
static int tsdbEncodeFSHeader(void **buf, SFSHeader *pHeader) {
|
static int tsdbEncodeFSHeader(void **buf, SFSHeader *pHeader) {
|
||||||
int tlen = 0;
|
int tlen = 0;
|
||||||
|
@ -1354,4 +1352,4 @@ static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo, int32_t *nExpired) {
|
||||||
|
|
||||||
tsdbCloseDFileSet(&fset);
|
tsdbCloseDFileSet(&fset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ typedef struct {
|
||||||
extern SGlobalCfg tsGlobalConfig[];
|
extern SGlobalCfg tsGlobalConfig[];
|
||||||
extern int32_t tsGlobalConfigNum;
|
extern int32_t tsGlobalConfigNum;
|
||||||
extern char * tsCfgStatusStr[];
|
extern char * tsCfgStatusStr[];
|
||||||
extern bool tsdbForceKeepFile;
|
|
||||||
|
|
||||||
void taosReadGlobalLogCfg();
|
void taosReadGlobalLogCfg();
|
||||||
bool taosReadGlobalCfg();
|
bool taosReadGlobalCfg();
|
||||||
|
|
Loading…
Reference in New Issue