fix[cluster]: redirect msg when mnode not deployed

This commit is contained in:
Shengliang Guan 2022-04-10 18:24:16 +08:00
parent a3ac72079e
commit 14ec5b672a
3 changed files with 13 additions and 8 deletions

View File

@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) {
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount);
} else { } else {
terrno = TSDB_CODE_NODE_REDIRECT; terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
pRetWrapper = NULL; pRetWrapper = NULL;
} }
taosRUnLockLatch(&pWrapper->latch); taosRUnLockLatch(&pWrapper->latch);
@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount);
} else { } else {
terrno = TSDB_CODE_NODE_REDIRECT; terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
code = -1; code = -1;
} }
taosRUnLockLatch(&pWrapper->latch); taosRUnLockLatch(&pWrapper->latch);

View File

@ -53,8 +53,9 @@ static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpS
int32_t code = -1; int32_t code = -1;
SNodeMsg *pMsg = NULL; SNodeMsg *pMsg = NULL;
NodeMsgFp msgFp = NULL; NodeMsgFp msgFp = NULL;
uint16_t msgType = pRpc->msgType;
if (pEpSet && pEpSet->numOfEps > 0 && pRpc->msgType == TDMT_MND_STATUS_RSP) { if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
dndUpdateMnodeEpSet(pWrapper->pDnode, pEpSet); dndUpdateMnodeEpSet(pWrapper->pDnode, pEpSet);
} }
@ -84,9 +85,15 @@ _OVER:
} }
} else { } else {
dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr()); dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr());
if (pRpc->msgType & 1U) { if (msgType & 1U) {
if (terrno != 0) code = terrno; if (terrno != 0) code = terrno;
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) {
if (msgType > TDMT_MND_MSG && msgType < TDMT_VND_MSG) {
code = TSDB_CODE_NODE_REDIRECT;
}
}
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = code};
tmsgSendRsp(&rsp); tmsgSendRsp(&rsp);
} }
dTrace("msg:%p, is freed", pMsg); dTrace("msg:%p, is freed", pMsg);
@ -348,8 +355,7 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p
} }
static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
if (pRsp->code == TSDB_CODE_APP_NOT_READY || pRsp->code == TSDB_CODE_NODE_REDIRECT || if (pRsp->code == TSDB_CODE_NODE_REDIRECT) {
pRsp->code == TSDB_CODE_NODE_OFFLINE) {
dmSendRedirectRsp(pWrapper->pMgmt, pRsp); dmSendRedirectRsp(pWrapper->pMgmt, pRsp);
} else { } else {
rpcSendResponse(pRsp); rpcSendResponse(pRsp);

View File

@ -75,7 +75,6 @@ if $data02 != master then
return -1 return -1
endi endi
return
print =============== create drop mnode 1 print =============== create drop mnode 1
sql_error create mnode on dnode 1 sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1 sql_error drop mnode on dnode 1