commit
8f886b890a
|
@ -214,8 +214,8 @@ static bool balanceCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
|
||||||
* desc: remove one vnode from vgroup
|
* desc: remove one vnode from vgroup
|
||||||
* all vnodes in vgroup should in ready state, except the balancing one
|
* all vnodes in vgroup should in ready state, except the balancing one
|
||||||
**/
|
**/
|
||||||
static void balanceRemoveVnode(SVgObj *pVgroup) {
|
static int32_t balanceRemoveVnode(SVgObj *pVgroup) {
|
||||||
if (pVgroup->numOfVnodes <= 1) return;
|
if (pVgroup->numOfVnodes <= 1) return -1;
|
||||||
|
|
||||||
SVnodeGid *pRmVnode = NULL;
|
SVnodeGid *pRmVnode = NULL;
|
||||||
SVnodeGid *pSelVnode = NULL;
|
SVnodeGid *pSelVnode = NULL;
|
||||||
|
@ -258,9 +258,11 @@ static void balanceRemoveVnode(SVgObj *pVgroup) {
|
||||||
|
|
||||||
if (!balanceCheckVgroupReady(pVgroup, pSelVnode)) {
|
if (!balanceCheckVgroupReady(pVgroup, pSelVnode)) {
|
||||||
mDebug("vgId:%d, is not ready", pVgroup->vgId);
|
mDebug("vgId:%d, is not ready", pVgroup->vgId);
|
||||||
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
mDebug("vgId:%d, is ready, discard dnode:%d", pVgroup->vgId, pSelVnode->dnodeId);
|
mDebug("vgId:%d, is ready, discard dnode:%d", pVgroup->vgId, pSelVnode->dnodeId);
|
||||||
balanceDiscardVnode(pVgroup, pSelVnode);
|
balanceDiscardVnode(pVgroup, pSelVnode);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,22 +409,22 @@ static int32_t balanceMonitorVgroups() {
|
||||||
|
|
||||||
int32_t dbReplica = pVgroup->pDb->cfg.replications;
|
int32_t dbReplica = pVgroup->pDb->cfg.replications;
|
||||||
int32_t vgReplica = pVgroup->numOfVnodes;
|
int32_t vgReplica = pVgroup->numOfVnodes;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
if (vgReplica > dbReplica) {
|
if (vgReplica > dbReplica) {
|
||||||
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try remove one vnode", pVgroup->vgId, dbReplica, vgReplica);
|
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try remove one vnode", pVgroup->vgId, dbReplica, vgReplica);
|
||||||
hasUpdatingVgroup = true;
|
hasUpdatingVgroup = true;
|
||||||
balanceRemoveVnode(pVgroup);
|
code = balanceRemoveVnode(pVgroup);
|
||||||
} else if (vgReplica < dbReplica) {
|
} else if (vgReplica < dbReplica) {
|
||||||
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try add one vnode", pVgroup->vgId, dbReplica, vgReplica);
|
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try add one vnode", pVgroup->vgId, dbReplica, vgReplica);
|
||||||
hasUpdatingVgroup = true;
|
hasUpdatingVgroup = true;
|
||||||
int32_t code = balanceAddVnode(pVgroup, NULL, NULL);
|
code = balanceAddVnode(pVgroup, NULL, NULL);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
|
||||||
mnodeDecVgroupRef(pVgroup);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbFreeIter(pIter);
|
sdbFreeIter(pIter);
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
#include "mnodeVgroup.h"
|
#include "mnodeVgroup.h"
|
||||||
#include "mnodeWrite.h"
|
#include "mnodeWrite.h"
|
||||||
|
|
||||||
#define CONN_KEEP_TIME (tsShellActivityTimer * 3)
|
#define CONN_KEEP_TIME (tsShellActivityTimer * 3000)
|
||||||
#define CONN_CHECK_TIME (tsShellActivityTimer * 2)
|
#define CONN_CHECK_TIME (tsShellActivityTimer * 2000)
|
||||||
#define QUERY_ID_SIZE 20
|
#define QUERY_ID_SIZE 20
|
||||||
#define QUERY_STREAM_SAVE_SIZE 20
|
#define QUERY_STREAM_SAVE_SIZE 20
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,8 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mnodeAccquireShowObj(SShowObj *pShow) {
|
static bool mnodeAccquireShowObj(SShowObj *pShow) {
|
||||||
SShowObj **ppShow = taosCacheAcquireByKey(tsMnodeShowCache, &pShow, sizeof(int64_t));
|
uint64_t handleVal = (uint64_t)pShow;
|
||||||
|
SShowObj **ppShow = taosCacheAcquireByKey(tsMnodeShowCache, &handleVal, sizeof(int64_t));
|
||||||
if (ppShow) {
|
if (ppShow) {
|
||||||
mDebug("%p, show is accquired from cache, data:%p, index:%d", pShow, ppShow, pShow->index);
|
mDebug("%p, show is accquired from cache, data:%p, index:%d", pShow, ppShow, pShow->index);
|
||||||
return true;
|
return true;
|
||||||
|
@ -389,7 +390,8 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) {
|
||||||
static void* mnodePutShowObj(SShowObj *pShow) {
|
static void* mnodePutShowObj(SShowObj *pShow) {
|
||||||
if (tsMnodeShowCache != NULL) {
|
if (tsMnodeShowCache != NULL) {
|
||||||
pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1);
|
pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1);
|
||||||
SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &pShow, sizeof(int64_t), &pShow, sizeof(int64_t), 6);
|
uint64_t handleVal = (uint64_t)pShow;
|
||||||
|
SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), 6000);
|
||||||
pShow->ppShow = (void**)ppShow;
|
pShow->ppShow = (void**)ppShow;
|
||||||
mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index);
|
mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index);
|
||||||
return pShow;
|
return pShow;
|
||||||
|
|
|
@ -108,7 +108,8 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
pContext->lastAccessTime = taosGetTimestampSec();
|
pContext->lastAccessTime = taosGetTimestampSec();
|
||||||
pContext->state = HTTP_CONTEXT_STATE_READY;
|
pContext->state = HTTP_CONTEXT_STATE_READY;
|
||||||
|
|
||||||
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &pContext, sizeof(int64_t), &pContext, sizeof(int64_t), 3);
|
uint64_t handleVal = (uint64_t)pContext;
|
||||||
|
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(int64_t), &pContext, sizeof(int64_t), 3000);
|
||||||
pContext->ppContext = ppContext;
|
pContext->ppContext = ppContext;
|
||||||
httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext);
|
httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext);
|
||||||
|
|
||||||
|
@ -119,7 +120,8 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpContext *httpGetContext(void *ptr) {
|
HttpContext *httpGetContext(void *ptr) {
|
||||||
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &ptr, sizeof(HttpContext *));
|
uint64_t handleVal = (uint64_t)ptr;
|
||||||
|
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(HttpContext *));
|
||||||
|
|
||||||
if (ppContext) {
|
if (ppContext) {
|
||||||
HttpContext *pContext = *ppContext;
|
HttpContext *pContext = *ppContext;
|
||||||
|
|
|
@ -34,7 +34,7 @@ void httpCreateSession(HttpContext *pContext, void *taos) {
|
||||||
session.refCount = 1;
|
session.refCount = 1;
|
||||||
int32_t len = snprintf(session.id, HTTP_SESSION_ID_LEN, "%s.%s", pContext->user, pContext->pass);
|
int32_t len = snprintf(session.id, HTTP_SESSION_ID_LEN, "%s.%s", pContext->user, pContext->pass);
|
||||||
|
|
||||||
pContext->session = taosCachePut(server->sessionCache, session.id, len, &session, sizeof(HttpSession), tsHttpSessionExpire);
|
pContext->session = taosCachePut(server->sessionCache, session.id, len, &session, sizeof(HttpSession), tsHttpSessionExpire * 1000);
|
||||||
// void *temp = pContext->session;
|
// void *temp = pContext->session;
|
||||||
// taosCacheRelease(server->sessionCache, (void **)&temp, false);
|
// taosCacheRelease(server->sessionCache, (void **)&temp, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue