提交 7725aa1c 编写于 作者: S slguan

[TBASE-1129]

上级 86ad4166
...@@ -78,6 +78,8 @@ enum _TSDB_VN_STREAM_STATUS { ...@@ -78,6 +78,8 @@ enum _TSDB_VN_STREAM_STATUS {
TSDB_VN_STREAM_STATUS_START TSDB_VN_STREAM_STATUS_START
}; };
const char* taosGetVgroupStatusStr(int vgroupStatus);
const char* taosGetDbStatusStr(int dbStatus);
const char* taosGetVnodeStatusStr(int vnodeStatus); const char* taosGetVnodeStatusStr(int vnodeStatus);
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus); const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus);
const char* taosGetVnodeDropStatusStr(int dropping); const char* taosGetVnodeDropStatusStr(int dropping);
......
...@@ -350,33 +350,33 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) { ...@@ -350,33 +350,33 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
pCfg->rowsInFileBlock = htonl(pCfg->rowsInFileBlock); pCfg->rowsInFileBlock = htonl(pCfg->rowsInFileBlock);
if (pCfg->replications > 0) { if (pCfg->replications > 0) {
dTrace("vid:%d, vpeer cfg received, replica:%d session:%d, vnodeList replica:%d session:%d", dPrint("vid:%d, vpeer cfg received, replica:%d session:%d, vnodeList replica:%d session:%d",
vnode, pCfg->replications, pCfg->maxSessions, vnodeList[vnode].cfg.replications, vnodeList[vnode].cfg.maxSessions); vnode, pCfg->replications, pCfg->maxSessions, vnodeList[vnode].cfg.replications, vnodeList[vnode].cfg.maxSessions);
for (i = 0; i < pCfg->replications; ++i) { for (i = 0; i < pCfg->replications; ++i) {
pMsg->vpeerDesc[i].vnode = htonl(pMsg->vpeerDesc[i].vnode); pMsg->vpeerDesc[i].vnode = htonl(pMsg->vpeerDesc[i].vnode);
pMsg->vpeerDesc[i].ip = htonl(pMsg->vpeerDesc[i].ip); pMsg->vpeerDesc[i].ip = htonl(pMsg->vpeerDesc[i].ip);
dTrace("vid:%d, vpeer:%d ip:0x%x vid:%d ", vnode, i, pMsg->vpeerDesc[i].ip, pMsg->vpeerDesc[i].vnode); dPrint("vid:%d, vpeer:%d ip:0x%x vid:%d ", vnode, i, pMsg->vpeerDesc[i].ip, pMsg->vpeerDesc[i].vnode);
} }
} }
if (vnodeList[vnode].cfg.maxSessions == 0) { if (vnodeList[vnode].cfg.maxSessions == 0) {
dTrace("vid:%d, vnode is empty", vnode); dPrint("vid:%d, vnode is empty", vnode);
if (pCfg->maxSessions > 0) { if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_OFFLINE) { if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_OFFLINE) {
dTrace("vid:%d, status:%s, start to create vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus)); dPrint("vid:%d, status:%s, start to create vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return vnodeCreateVnode(vnode, pCfg, pMsg->vpeerDesc); return vnodeCreateVnode(vnode, pCfg, pMsg->vpeerDesc);
} else { } else {
dTrace("vid:%d, status:%s, cannot preform create vnode operation", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus)); dPrint("vid:%d, status:%s, cannot preform create vnode operation", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
return TSDB_CODE_INVALID_VNODE_STATUS; return TSDB_CODE_INVALID_VNODE_STATUS;
} }
} }
} else { } else {
dTrace("vid:%d, vnode is not empty", vnode); dPrint("vid:%d, vnode is not empty", vnode);
if (pCfg->maxSessions > 0) { if (pCfg->maxSessions > 0) {
if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_DELETING) { if (vnodeList[vnode].vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, wait vnode delete finished", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus)); dPrint("vid:%d, status:%s, wait vnode delete finished", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
} else { } else {
dTrace("vid:%d, status:%s, start to update vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus)); dPrint("vid:%d, status:%s, start to update vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) { if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
vnodeCleanUpOneVnode(vnode); vnodeCleanUpOneVnode(vnode);
...@@ -395,7 +395,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) { ...@@ -395,7 +395,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
} }
return 0; return 0;
} else { } else {
dTrace("vid:%d, status:%s, start to delete vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus)); dPrint("vid:%d, status:%s, start to delete vnode", vnode, taosGetVnodeStatusStr(vnodeList[vnode].vnodeStatus));
vnodeRemoveVnode(vnode); vnodeRemoveVnode(vnode);
} }
} }
......
...@@ -99,7 +99,7 @@ int mgmtProcessVpeerCfgMsg(char *cont, int contLen, SDnodeObj *pObj) { ...@@ -99,7 +99,7 @@ int mgmtProcessVpeerCfgMsg(char *cont, int contLen, SDnodeObj *pObj) {
*pMsg = 0; *pMsg = 0;
pMsg++; pMsg++;
pMsg = mgmtBuildVpeersIe(pMsg, pVgroup, vnode); pMsg = mgmtBuildVpeersIe(pMsg, pVgroup, vnode);
mTrace("dnode:%s, vnode:%d, vgroup:%d, send create meter msg, code:%d", taosIpStr(pObj->privateIp), vnode, pVgroup->vgId, *pMsg); mTrace("dnode:%s, vnode:%d, vgroup:%d, send create vnode msg, code:%d", taosIpStr(pObj->privateIp), vnode, pVgroup->vgId, *pMsg);
} else { } else {
mTrace("dnode:%s, vnode:%d, no vgroup info, vgroup:%d", taosIpStr(pObj->privateIp), vnode, pObj->vload[vnode].vgId); mTrace("dnode:%s, vnode:%d, no vgroup info, vgroup:%d", taosIpStr(pObj->privateIp), vnode, pObj->vload[vnode].vgId);
*pMsg = TSDB_CODE_NOT_ACTIVE_VNODE; *pMsg = TSDB_CODE_NOT_ACTIVE_VNODE;
...@@ -128,7 +128,8 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) { ...@@ -128,7 +128,8 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
} }
if (pDb->vgStatus != TSDB_VG_STATUS_IN_PROGRESS) { if (pDb->vgStatus != TSDB_VG_STATUS_IN_PROGRESS) {
mTrace("dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%d code:%d", taosIpStr(pObj->privateIp), pRsp->more, pDb->vgStatus, pRsp->code); mTrace("dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%s code:%d",
taosIpStr(pObj->privateIp), pRsp->more, taosGetVgroupStatusStr(pDb->vgStatus), pRsp->code);
return 0; return 0;
} }
......
...@@ -78,7 +78,7 @@ void *vnodeOpenCachePool(int vnode) { ...@@ -78,7 +78,7 @@ void *vnodeOpenCachePool(int vnode) {
} }
} }
dTrace("vid:%d, cache pool is allocated:0x%x", vnode, pCachePool); dPrint("vid:%d, cache pool is allocated:0x%x", vnode, pCachePool);
return pCachePool; return pCachePool;
...@@ -103,7 +103,7 @@ void vnodeCloseCachePool(int vnode) { ...@@ -103,7 +103,7 @@ void vnodeCloseCachePool(int vnode) {
taosTmrStopA(&pVnode->commitTimer); taosTmrStopA(&pVnode->commitTimer);
if (pVnode->commitInProcess) pthread_cancel(pVnode->commitThread); if (pVnode->commitInProcess) pthread_cancel(pVnode->commitThread);
dTrace("vid:%d, cache pool closed, count:%d", vnode, pCachePool->count); dPrint("vid:%d, cache pool closed, count:%d", vnode, pCachePool->count);
int maxAllocBlock = (1024 * 1024 * 1024) / pVnode->cfg.cacheBlockSize; int maxAllocBlock = (1024 * 1024 * 1024) / pVnode->cfg.cacheBlockSize;
while (blockId < pVnode->cfg.cacheNumOfBlocks.totalBlocks) { while (blockId < pVnode->cfg.cacheNumOfBlocks.totalBlocks) {
......
...@@ -125,10 +125,8 @@ int vnodeCreateHeadDataFile(int vnode, int fileId, char *headName, char *dataNam ...@@ -125,10 +125,8 @@ int vnodeCreateHeadDataFile(int vnode, int fileId, char *headName, char *dataNam
if (symlink(dDataName, dataName) != 0) return -1; if (symlink(dDataName, dataName) != 0) return -1;
if (symlink(dLastName, lastName) != 0) return -1; if (symlink(dLastName, lastName) != 0) return -1;
dTrace( dPrint("vid:%d, fileId:%d, empty header file:%s dataFile:%s lastFile:%s on disk:%s is created ",
"vid:%d, fileId:%d, empty header file:%s dataFile:%s lastFile:%s on " vnode, fileId, headName, dataName, lastName, path);
"disk:%s is created ",
vnode, fileId, headName, dataName, lastName, path);
return 0; return 0;
} }
...@@ -309,7 +307,7 @@ int vnodeOpenCommitFiles(SVnodeObj *pVnode, int noTempLast) { ...@@ -309,7 +307,7 @@ int vnodeOpenCommitFiles(SVnodeObj *pVnode, int noTempLast) {
vnodeRecoverFromPeer(pVnode, fileId); vnodeRecoverFromPeer(pVnode, fileId);
goto _error; goto _error;
} else { } else {
dTrace("vid:%d, data file:%s is opened to write", vnode, name); dPrint("vid:%d, data file:%s is opened to write", vnode, name);
} }
// open last file // open last file
...@@ -414,7 +412,7 @@ void vnodeRemoveFile(int vnode, int fileId) { ...@@ -414,7 +412,7 @@ void vnodeRemoveFile(int vnode, int fileId) {
remove(dDataName); remove(dDataName);
remove(dLastName); remove(dLastName);
dTrace("vid:%d fileId:%d on disk: %s is removed, numOfFiles:%d maxFiles:%d", vnode, fileId, path, dPrint("vid:%d fileId:%d on disk: %s is removed, numOfFiles:%d maxFiles:%d", vnode, fileId, path,
pVnode->numOfFiles, pVnode->maxFiles); pVnode->numOfFiles, pVnode->maxFiles);
} }
......
...@@ -59,7 +59,7 @@ static int vnodeInitStoreVnode(int vnode) { ...@@ -59,7 +59,7 @@ static int vnodeInitStoreVnode(int vnode) {
} }
pthread_mutex_init(&(pVnode->vmutex), NULL); pthread_mutex_init(&(pVnode->vmutex), NULL);
dTrace("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId, dPrint("vid:%d, storage initialized, version:%ld fileId:%d numOfFiles:%d", vnode, pVnode->version, pVnode->fileId,
pVnode->numOfFiles); pVnode->numOfFiles);
return 0; return 0;
...@@ -83,7 +83,7 @@ int vnodeOpenVnode(int vnode) { ...@@ -83,7 +83,7 @@ int vnodeOpenVnode(int vnode) {
return TSDB_CODE_INVALID_VNODE_STATUS; return TSDB_CODE_INVALID_VNODE_STATUS;
} }
dTrace("vid:%d, status:%s, start to open", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus)); dPrint("vid:%d, status:%s, start to open", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pthread_mutex_lock(&dmutex); pthread_mutex_lock(&dmutex);
// not enough memory, abort // not enough memory, abort
...@@ -104,7 +104,7 @@ int vnodeOpenVnode(int vnode) { ...@@ -104,7 +104,7 @@ int vnodeOpenVnode(int vnode) {
vnodeOpenStreams(pVnode, NULL); vnodeOpenStreams(pVnode, NULL);
#endif #endif
dTrace("vid:%d, vnode is opened, openVnodes:%d, status:%s", vnode, tsOpenVnodes, taosGetVnodeStatusStr(pVnode->vnodeStatus)); dPrint("vid:%d, vnode is opened, openVnodes:%d, status:%s", vnode, tsOpenVnodes, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -141,10 +141,10 @@ static int vnodeCloseVnode(int vnode) { ...@@ -141,10 +141,10 @@ static int vnodeCloseVnode(int vnode) {
} }
if (pVnode->vnodeStatus == TSDB_VN_STATUS_DELETING) { if (pVnode->vnodeStatus == TSDB_VN_STATUS_DELETING) {
dTrace("vid:%d, status:%s, another thread performed delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus)); dPrint("vid:%d, status:%s, another thread performed delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { } else {
dTrace("vid:%d, status:%s, enter close operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus)); dPrint("vid:%d, status:%s, enter close operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VN_STATUS_CLOSING; pVnode->vnodeStatus = TSDB_VN_STATUS_CLOSING;
} }
...@@ -154,7 +154,7 @@ static int vnodeCloseVnode(int vnode) { ...@@ -154,7 +154,7 @@ static int vnodeCloseVnode(int vnode) {
return TSDB_CODE_ACTION_IN_PROGRESS; return TSDB_CODE_ACTION_IN_PROGRESS;
} }
dTrace("vid:%d, status:%s, enter delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus)); dPrint("vid:%d, status:%s, enter delete operation", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus));
pVnode->vnodeStatus = TSDB_VN_STATUS_DELETING; pVnode->vnodeStatus = TSDB_VN_STATUS_DELETING;
vnodeCloseStream(vnodeList + vnode); vnodeCloseStream(vnodeList + vnode);
...@@ -235,7 +235,7 @@ static void vnodeRemoveDataFiles(int vnode) { ...@@ -235,7 +235,7 @@ static void vnodeRemoveDataFiles(int vnode) {
if (tcode >= 0) { if (tcode >= 0) {
remove(dfilePath); remove(dfilePath);
dTrace("Data file %s is removed, link file %s", dfilePath, linkFile); dPrint("Data file %s is removed, link file %s", dfilePath, linkFile);
} }
} else { } else {
remove(de->d_name); remove(de->d_name);
...@@ -250,7 +250,7 @@ static void vnodeRemoveDataFiles(int vnode) { ...@@ -250,7 +250,7 @@ static void vnodeRemoveDataFiles(int vnode) {
sprintf(vnodeDir, "%s/vnode%d", tsDirectory, vnode); sprintf(vnodeDir, "%s/vnode%d", tsDirectory, vnode);
rmdir(vnodeDir); rmdir(vnodeDir);
dTrace("vid:%d, vnode is removed!", vnode); dPrint("vid:%d, vnode is removed!", vnode);
} }
int vnodeRemoveVnode(int vnode) { int vnodeRemoveVnode(int vnode) {
...@@ -273,7 +273,7 @@ int vnodeRemoveVnode(int vnode) { ...@@ -273,7 +273,7 @@ int vnodeRemoveVnode(int vnode) {
} }
} else { } else {
dTrace("vid:%d, max sessions:%d, this vnode already dropped!!!", vnode, vnodeList[vnode].cfg.maxSessions); dPrint("vid:%d, max sessions:%d, this vnode already dropped!!!", vnode, vnodeList[vnode].cfg.maxSessions);
vnodeList[vnode].cfg.maxSessions = 0; //reset value vnodeList[vnode].cfg.maxSessions = 0; //reset value
vnodeCalcOpenVnodes(); vnodeCalcOpenVnodes();
} }
......
...@@ -155,7 +155,7 @@ void vnodeRemoveStream(SMeterObj *pObj) { ...@@ -155,7 +155,7 @@ void vnodeRemoveStream(SMeterObj *pObj) {
// Close all streams in a vnode // Close all streams in a vnode
void vnodeCloseStream(SVnodeObj *pVnode) { void vnodeCloseStream(SVnodeObj *pVnode) {
SMeterObj *pObj; SMeterObj *pObj;
dTrace("vid:%d, stream is closed, old role %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole)); dPrint("vid:%d, stream is closed, old role %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole));
// stop stream computing // stop stream computing
for (int sid = 0; sid < pVnode->cfg.maxSessions; ++sid) { for (int sid = 0; sid < pVnode->cfg.maxSessions; ++sid) {
...@@ -174,16 +174,16 @@ void vnodeUpdateStreamRole(SVnodeObj *pVnode) { ...@@ -174,16 +174,16 @@ void vnodeUpdateStreamRole(SVnodeObj *pVnode) {
int newRole = (pVnode->vnodeStatus == TSDB_VN_STATUS_MASTER) ? TSDB_VN_STREAM_STATUS_START : TSDB_VN_STREAM_STATUS_STOP; int newRole = (pVnode->vnodeStatus == TSDB_VN_STATUS_MASTER) ? TSDB_VN_STREAM_STATUS_START : TSDB_VN_STREAM_STATUS_STOP;
if (newRole != pVnode->streamRole) { if (newRole != pVnode->streamRole) {
dTrace("vid:%d, stream role is changed from %s to %s", dPrint("vid:%d, stream role is changed from %s to %s",
pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole), taosGetVnodeStreamStatusStr(newRole)); pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole), taosGetVnodeStreamStatusStr(newRole));
pVnode->streamRole = newRole; pVnode->streamRole = newRole;
if (newRole) { if (newRole == TSDB_VN_STREAM_STATUS_START) {
vnodeOpenStreams(pVnode, NULL); vnodeOpenStreams(pVnode, NULL);
} else { } else {
vnodeCloseStream(pVnode); vnodeCloseStream(pVnode);
} }
} else { } else {
dTrace("vid:%d, stream role is keep to %s", pVnode->vnode, taosGetVnodeStreamStatusStr(newRole)); dPrint("vid:%d, stream role is keep to %s", pVnode->vnode, taosGetVnodeStreamStatusStr(pVnode->streamRole));
} }
} }
......
...@@ -97,7 +97,7 @@ int vnodeCheckNewHeaderFile(int fd, SVnodeObj *pVnode) { ...@@ -97,7 +97,7 @@ int vnodeCheckNewHeaderFile(int fd, SVnodeObj *pVnode) {
} }
_correct_exit: _correct_exit:
dTrace("vid: %d new header file %s is correct", pVnode->vnode, pVnode->nfn); dPrint("vid: %d new header file %s is correct", pVnode->vnode, pVnode->nfn);
tfree(pBlocks); tfree(pBlocks);
tfree(pHeader); tfree(pHeader);
return 0; return 0;
......
...@@ -32,7 +32,7 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {} ...@@ -32,7 +32,7 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
int vnodeOpenPeerVnode(int vnode) { int vnodeOpenPeerVnode(int vnode) {
SVnodeObj *pVnode = vnodeList + vnode; SVnodeObj *pVnode = vnodeList + vnode;
pVnode->vnodeStatus = (pVnode->cfg.replications > 1) ? TSDB_VN_STATUS_UNSYNCED : TSDB_VN_STATUS_MASTER; pVnode->vnodeStatus = (pVnode->cfg.replications > 1) ? TSDB_VN_STATUS_UNSYNCED : TSDB_VN_STATUS_MASTER;
dTrace("vid:%d, status:%s numOfPeers:%d", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus), pVnode->cfg.replications - 1); dPrint("vid:%d, status:%s numOfPeers:%d", vnode, taosGetVnodeStatusStr(pVnode->vnodeStatus), pVnode->cfg.replications - 1);
vnodeUpdateStreamRole(pVnode); vnodeUpdateStreamRole(pVnode);
return 0; return 0;
} }
......
...@@ -17,6 +17,26 @@ ...@@ -17,6 +17,26 @@
#include "tsdb.h" #include "tsdb.h"
#include "tstatus.h" #include "tstatus.h"
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";
default: return "undefined";
}
}
const char* taosGetDbStatusStr(int dbStatus) {
switch (dbStatus) {
case TSDB_DB_STATUS_READY: return "ready";
case TSDB_DB_STATUS_DROPPING: return "dropping";
case TSDB_DB_STATUS_DROP_FROM_SDB: return "drop_from_sdb";
default: return "undefined";
}
}
const char* taosGetVnodeStatusStr(int vnodeStatus) { const char* taosGetVnodeStatusStr(int vnodeStatus) {
switch (vnodeStatus) { switch (vnodeStatus) {
case TSDB_VN_STATUS_OFFLINE: return "offline"; case TSDB_VN_STATUS_OFFLINE: return "offline";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册