From 87e80f8f9873e47915c76c506ef59474aa4a3385 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 6 Jul 2020 13:24:31 +0000 Subject: [PATCH 1/4] dont free pReqMsg until a good solution is found --- src/rpc/src/rpcMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 96066b8b9d..d14a98ab30 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -602,10 +602,10 @@ static void rpcReleaseConn(SRpcConn *pConn) { taosHashRemove(pRpc->hash, hashstr, size); rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg pConn->pRspMsg = NULL; + if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg); } // memset could not be used, since lockeBy can not be reset - if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg); pConn->inType = 0; pConn->outType = 0; pConn->inTranId = 0; From ffc98a26b8c88a72b0862316d902f7ed2640ae39 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 6 Jul 2020 14:08:38 +0000 Subject: [PATCH 2/4] check vnode status before alter or build status --- src/inc/taoserror.h | 3 ++- src/vnode/src/vnodeMain.c | 11 ++++++++++- src/vnode/src/vnodeRead.c | 6 +++--- src/vnode/src/vnodeWrite.c | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 4a7d86c434..388e22a561 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -180,7 +180,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, 0, 0x0506, "vnode no d TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "vnode no such file or directory") TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "vnode out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "vnode app error") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0214, "vnode no write auth") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_STATUS, 0, 0x0510, "vnode not in ready state") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0511, "vnode no write auth") // tsdb TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "tsdb invalid table id") diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index b469a5836e..bdc3b69d84 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -162,6 +162,12 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { SVnodeObj *pVnode = param; pVnode->status = TAOS_VN_STATUS_UPDATING; + if (pVnode->status != TAOS_VN_STATUS_READY) + return TSDB_CODE_VND_INVALID_STATUS; + + if (pVnode->syncCfg.replica > 1 && pVnode->role == TAOS_SYNC_ROLE_UNSYNCED) + return TSDB_CODE_VND_INVALID_STATUS; + int32_t code = vnodeSaveCfg(pVnodeCfg); if (code != TSDB_CODE_SUCCESS) return code; @@ -408,8 +414,11 @@ void *vnodeGetWal(void *pVnode) { } static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SDMStatusMsg *pStatus) { - if (pVnode->status == TAOS_VN_STATUS_DELETING) return; + if (pVnode->status != TAOS_VN_STATUS_READY) return; if (pStatus->openVnodes >= TSDB_MAX_VNODES) return; + if (pVnode->syncCfg.replica > 1 && pVnode->role == TAOS_SYNC_ROLE_UNSYNCED) return; + if (pVnode->tsdb == NULL) return; + int64_t totalStorage, compStorage, pointsWritten = 0; tsdbReportStat(pVnode->tsdb, &pointsWritten, &totalStorage, &compStorage); diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 9938b34741..cbce3f6cf2 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -46,9 +46,9 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) { return TSDB_CODE_VND_MSG_NOT_PROCESSED; } - if (pVnode->status == TAOS_VN_STATUS_DELETING || pVnode->status == TAOS_VN_STATUS_CLOSING) { + if (pVnode->status != TAOS_VN_STATUS_READY) { vDebug("vgId:%d, msgType:%s not processed, vnode status is %d", pVnode->vgId, taosMsg[msgType], pVnode->status); - return TSDB_CODE_VND_INVALID_VGROUP_ID; + return TSDB_CODE_VND_INVALID_STATUS; } // TODO: Later, let slave to support query @@ -225,4 +225,4 @@ int32_t vnodeNotifyCurrentQhandle(void* handle, void* qhandle, int32_t vgId) { vDebug("QInfo:%p register qhandle to connect:%p", qhandle, handle); return rpcReportProgress(handle, (char*) killQueryMsg, sizeof(SRetrieveTableMsg)); -} \ No newline at end of file +} diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 3dc2f43fc8..cc522c5d5a 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -58,10 +58,10 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { if (pHead->version == 0) { // from client or CQ if (pVnode->status != TAOS_VN_STATUS_READY) - return TSDB_CODE_VND_INVALID_VGROUP_ID; // it may be in deleting or closing state + return TSDB_CODE_VND_INVALID_STATUS; // it may be in deleting or closing state if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) - return TSDB_CODE_RPC_NOT_READY; + return TSDB_CODE_VND_INVALID_STATUS; // assign version pVnode->version++; From 0568c10c4eb01e2f8b4de3dcf5b146829aed44c9 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 6 Jul 2020 23:11:36 +0000 Subject: [PATCH 3/4] status check not right --- src/inc/taoserror.h | 3 ++- src/vnode/src/vnodeMain.c | 7 ++++--- src/vnode/src/vnodeWrite.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 388e22a561..e90bcf3d88 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -181,7 +181,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "vnode no s TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "vnode out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "vnode app error") TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_STATUS, 0, 0x0510, "vnode not in ready state") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0511, "vnode no write auth") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, 0, 0x0511, "vnode not in synced state") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0512, "vnode no write auth") // tsdb TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "tsdb invalid table id") diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index bdc3b69d84..0ee4ef4837 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -160,13 +160,14 @@ int32_t vnodeDrop(int32_t vgId) { int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { SVnodeObj *pVnode = param; - pVnode->status = TAOS_VN_STATUS_UPDATING; if (pVnode->status != TAOS_VN_STATUS_READY) return TSDB_CODE_VND_INVALID_STATUS; - if (pVnode->syncCfg.replica > 1 && pVnode->role == TAOS_SYNC_ROLE_UNSYNCED) - return TSDB_CODE_VND_INVALID_STATUS; + if (pVnode->syncCfg.replica > 1 && pVnode->role == TAOS_SYNC_ROLE_UNSYNCED) + return TSDB_CODE_VND_NOT_SYNCED; + + pVnode->status = TAOS_VN_STATUS_UPDATING; int32_t code = vnodeSaveCfg(pVnodeCfg); if (code != TSDB_CODE_SUCCESS) return code; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index cc522c5d5a..031915809e 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -61,7 +61,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { return TSDB_CODE_VND_INVALID_STATUS; // it may be in deleting or closing state if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) - return TSDB_CODE_VND_INVALID_STATUS; + return TSDB_CODE_RPC_NOT_READY; // assign version pVnode->version++; From 6b3d0a18385bc024d8324bf93fbb960c1d0e8f5a Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 6 Jul 2020 23:31:07 +0000 Subject: [PATCH 4/4] free pReqMsg if outType is not 0 --- src/rpc/src/rpcMain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index d14a98ab30..e432e47e36 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -603,7 +603,10 @@ static void rpcReleaseConn(SRpcConn *pConn) { rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg pConn->pRspMsg = NULL; if (pConn->pReqMsg) rpcFreeCont(pConn->pReqMsg); - } + } else { + if (pConn->outType && pConn->pReqMsg) + rpcFreeCont(pConn->pReqMsg); + } // memset could not be used, since lockeBy can not be reset pConn->inType = 0;