未验证 提交 e505a6b4 编写于 作者: H haojun Liao 提交者: GitHub

Merge pull request #1101 from taosdata/hotfix/slguan

TBASE-1442 #1025
......@@ -91,7 +91,7 @@ extern "C" {
#define TSDB_CODE_INVALID_QHANDLE 70
#define TSDB_CODE_RELATED_TABLES_EXIST 71
#define TSDB_CODE_MONITOR_DB_FORBEIDDEN 72
#define TSDB_CODE_VG_COMMITLOG_INIT_FAILED 73
#define TSDB_CODE_NO_DISK_PERMISSIONS 73
#define TSDB_CODE_VG_INIT_FAILED 74
#define TSDB_CODE_DATA_ALREADY_IMPORTED 75
#define TSDB_CODE_OPS_NOT_SUPPORT 76
......
......@@ -16,16 +16,20 @@
#ifndef TDENGINE_TSTATUS_H
#define TDENGINE_TSTATUS_H
#include "taoserror.h"
#ifdef __cplusplus
extern "C" {
#endif
enum _TSDB_VG_STATUS {
TSDB_VG_STATUS_READY,
TSDB_VG_STATUS_IN_PROGRESS,
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED,
TSDB_VG_STATUS_INIT_FAILED,
TSDB_VG_STATUS_FULL
TSDB_VG_STATUS_READY = TSDB_CODE_SUCCESS,
TSDB_VG_STATUS_IN_PROGRESS = TSDB_CODE_ACTION_IN_PROGRESS,
TSDB_VG_STATUS_NO_DISK_PERMISSIONS = TSDB_CODE_NO_DISK_PERMISSIONS,
TSDB_VG_STATUS_SERVER_NO_PACE = TSDB_CODE_SERVER_NO_SPACE,
TSDB_VG_STATUS_SERV_OUT_OF_MEMORY = TSDB_CODE_SERV_OUT_OF_MEMORY,
TSDB_VG_STATUS_INIT_FAILED = TSDB_CODE_VG_INIT_FAILED,
TSDB_VG_STATUS_FULL = TSDB_CODE_NO_ENOUGH_DNODES,
};
enum _TSDB_DB_STATUS {
......
......@@ -197,7 +197,7 @@ char *tsError[] = {"success",
"invalid query handle", // 70
"tables related to metric exist",
"can't drop monitor database or tables",
"commit log init failed",
"no disk permissions",
"vgroup init failed",
"data is already imported", // 75
"not supported operation",
......@@ -234,7 +234,7 @@ char *tsError[] = {"success",
"timestamp disordered in cache block",
"timestamp disordered in file block",
"invalid commit log",
"server no disk space", //110
"no disk space on server", //110
"only super table has metric meta info",
"tags value not unique for join",
"invalid submit message",
......
......@@ -152,19 +152,15 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
return 0;
}
if (pRsp->code == 0) {
if (pRsp->code == TSDB_CODE_SUCCESS) {
pDb->vgStatus = TSDB_VG_STATUS_READY;
mTrace("dnode:%s, db:%s vgroup is created in dnode", taosIpStr(pObj->privateIp), pRsp->more);
return 0;
}
if (pRsp->code == TSDB_CODE_VG_COMMITLOG_INIT_FAILED) {
pDb->vgStatus = TSDB_VG_STATUS_COMMITLOG_INIT_FAILED;
mError("dnode:%s, db:%s vgroup commit log init failed, code:%d", taosIpStr(pObj->privateIp), pRsp->more, pRsp->code);
} else {
pDb->vgStatus = TSDB_VG_STATUS_INIT_FAILED;
mError("dnode:%s, db:%s vgroup init failed, code:%d", taosIpStr(pObj->privateIp), pRsp->more, pRsp->code);
}
pDb->vgStatus = pRsp->code;
mError("dnode:%s, db:%s vgroup init failed, code:%d %s",
taosIpStr(pObj->privateIp), pRsp->more, pRsp->code, taosGetVgroupStatusStr(pDb->vgStatus));
return 0;
}
......
......@@ -657,16 +657,10 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
return TSDB_CODE_NO_ENOUGH_DNODES;
}
if (pDb->vgStatus == TSDB_VG_STATUS_COMMITLOG_INIT_FAILED) {
if (pDb->vgStatus < TSDB_VG_STATUS_FULL && pDb->vgStatus > TSDB_CODE_ACTION_IN_PROGRESS) {
mgmtDestroyMeter(pMeter);
mError("table:%s, commit log init failed", pCreate->meterId);
return TSDB_CODE_VG_COMMITLOG_INIT_FAILED;
}
if (pDb->vgStatus == TSDB_VG_STATUS_INIT_FAILED) {
mgmtDestroyMeter(pMeter);
mError("table:%s, vgroup init failed", pCreate->meterId);
return TSDB_CODE_VG_INIT_FAILED;
mError("table:%s, vgroup init failed, reason:%d %s", pCreate->meterId, pDb->vgStatus, taosGetVgroupStatusStr(pDb->vgStatus));
return pDb->vgStatus;
}
if (pVgroup == NULL) {
......
......@@ -1823,7 +1823,7 @@ int vnodeUpdateFileMagic(int vnode, int fileId) {
}
int vnodeInitFile(int vnode) {
int code = 0;
int code = TSDB_CODE_SUCCESS;
SVnodeObj *pVnode = vnodeList + vnode;
pVnode->maxFiles = pVnode->cfg.daysToKeep / pVnode->cfg.daysPerFile + 1;
......
......@@ -79,8 +79,14 @@ int vnodeCreateMeterObjFile(int vnode) {
sprintf(fileName, "%s/vnode%d/meterObj.v%d", tsDirectory, vnode, vnode);
fp = fopen(fileName, "w+");
if (fp == NULL) {
dError("failed to create vnode:%d file:%s", vnode, fileName);
return -1;
dError("failed to create vnode:%d file:%s, reason:%s", vnode, fileName, strerror(errno));
if (errno == EACCES) {
return TSDB_CODE_NO_DISK_PERMISSIONS;
} else if (errno == ENOSPC) {
return TSDB_CODE_SERVER_NO_SPACE;
} else {
return TSDB_CODE_VG_INIT_FAILED;
}
} else {
vnodeCreateFileHeader(fp);
vnodeUpdateVnodeFileHeader(fp, vnodeList + vnode);
......@@ -95,7 +101,7 @@ int vnodeCreateMeterObjFile(int vnode) {
fclose(fp);
}
return 0;
return TSDB_CODE_SUCCESS;
}
FILE *vnodeOpenMeterObjFile(int vnode) {
......@@ -273,7 +279,7 @@ int vnodeSaveVnodeCfg(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
/* vnodeUpdateFileCheckSum(fp); */
fclose(fp);
return 0;
return TSDB_CODE_SUCCESS;
}
int vnodeSaveVnodeInfo(int vnode) {
......
......@@ -45,24 +45,24 @@ static int vnodeInitStoreVnode(int vnode) {
pVnode->pCachePool = vnodeOpenCachePool(vnode);
if (pVnode->pCachePool == NULL) {
dError("vid:%d, cache pool init failed.", pVnode->vnode);
return -1;
return TSDB_CODE_SERV_OUT_OF_MEMORY;
}
if (vnodeInitFile(vnode) < 0) {
if (vnodeInitFile(vnode) != TSDB_CODE_SUCCESS) {
dError("vid:%d, files init failed.", pVnode->vnode);
return -1;
return TSDB_CODE_VG_INIT_FAILED;
}
if (vnodeInitCommit(vnode) < 0) {
if (vnodeInitCommit(vnode) != TSDB_CODE_SUCCESS) {
dError("vid:%d, commit init failed.", pVnode->vnode);
return -1;
return TSDB_CODE_VG_INIT_FAILED;
}
pthread_mutex_init(&(pVnode->vmutex), NULL);
dPrint("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId,
pVnode->numOfFiles);
return 0;
return TSDB_CODE_SUCCESS;
}
int vnodeOpenVnode(int vnode) {
......@@ -192,16 +192,19 @@ int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
mkdir(fileName, 0755);
vnodeList[vnode].cfg = *pCfg;
if (vnodeCreateMeterObjFile(vnode) != 0) {
return TSDB_CODE_VG_INIT_FAILED;
int code = vnodeCreateMeterObjFile(vnode);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
if (vnodeSaveVnodeCfg(vnode, pCfg, pDesc) != 0) {
code = vnodeSaveVnodeCfg(vnode, pCfg, pDesc);
if (code != TSDB_CODE_SUCCESS) {
return TSDB_CODE_VG_INIT_FAILED;
}
if (vnodeInitStoreVnode(vnode) < 0) {
return TSDB_CODE_VG_COMMITLOG_INIT_FAILED;
code = vnodeInitStoreVnode(vnode);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
return vnodeOpenVnode(vnode);
......@@ -294,7 +297,8 @@ int vnodeInitStore() {
if (vnodeInitInfo() < 0) return -1;
for (vnode = 0; vnode < TSDB_MAX_VNODES; ++vnode) {
if (vnodeInitStoreVnode(vnode) < 0) {
int code = vnodeInitStoreVnode(vnode);
if (code != TSDB_CODE_SUCCESS) {
// one vnode is failed to recover from commit log, continue for remain
return -1;
}
......
......@@ -19,11 +19,13 @@
const char* taosGetVgroupStatusStr(int vgroupStatus) {
switch (vgroupStatus) {
case TSDB_VG_STATUS_READY: return "ready";
case TSDB_VG_STATUS_IN_PROGRESS: return "inprogress";
case TSDB_VG_STATUS_COMMITLOG_INIT_FAILED: return "commitlog_init_failed";
case TSDB_VG_STATUS_INIT_FAILED: return "init_failed";
case TSDB_VG_STATUS_FULL: return "full";
case TSDB_VG_STATUS_READY: return tsError[vgroupStatus];
case TSDB_VG_STATUS_IN_PROGRESS: return tsError[vgroupStatus];
case TSDB_VG_STATUS_NO_DISK_PERMISSIONS: return tsError[vgroupStatus];
case TSDB_VG_STATUS_SERVER_NO_PACE: return tsError[vgroupStatus];
case TSDB_VG_STATUS_SERV_OUT_OF_MEMORY: return tsError[vgroupStatus];
case TSDB_VG_STATUS_INIT_FAILED: return tsError[vgroupStatus];
case TSDB_VG_STATUS_FULL: return tsError[vgroupStatus];
default: return "undefined";
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册