From b74721d3cb672cc0c264a13bfa376bdaf4b58993 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 14 Jan 2022 19:04:01 +0800 Subject: [PATCH] [TD-11437](connector,query,insert,other,tools,taosAdapter):add shortcutFlag to facilitate analysis of insert performance --- src/client/src/tscAsync.c | 7 ++++++- src/client/src/tscServer.c | 7 ++++++- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 12 ++++++++++++ src/inc/taosdef.h | 5 +++++ src/rpc/src/rpcMain.c | 13 +++++++++++++ src/tsdb/src/tsdbCommit.c | 5 +++++ src/util/inc/tconfig.h | 2 +- src/vnode/src/vnodeWrite.c | 4 +++- 9 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 2ddae0f903..036a95fe15 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -313,7 +313,12 @@ static void tscAsyncResultCallback(SSchedMsg *pMsg) { } assert(pSql->res.code != TSDB_CODE_SUCCESS); - tscError("0x%"PRIx64" async result callback, code:%s", pSql->self, tstrerror(pSql->res.code)); + if (tsShortcutFlag) { + tscDebug("0x%" PRIx64 " async result callback, code:%s", pSql->self, tstrerror(pSql->res.code)); + pSql->res.code = TSDB_CODE_SUCCESS; + } else { + tscError("0x%" PRIx64 " async result callback, code:%s", pSql->self, tstrerror(pSql->res.code)); + } SSqlRes *pRes = &pSql->res; if (pSql->fp == NULL || pSql->fetchFp == NULL){ diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 3849e90ce4..22ddea557e 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -332,7 +332,12 @@ int tscSendMsgToServer(SSqlObj *pSql) { .handle = NULL, .code = 0 }; - + + if ((rpcMsg.msgType == TSDB_MSG_TYPE_SUBMIT) && (tsShortcutFlag & TSDB_SHORTCUT_RPC_SEND_SUBMIT)) { + rpcFreeCont(rpcMsg.pCont); + return TSDB_CODE_FAILED; + } + rpcSendRequest(pObj->pRpcObj->pDnodeConn, &pSql->epSet, &rpcMsg, &pSql->rpcRid); return TSDB_CODE_SUCCESS; } diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 890bed123b..e1a4fe6eb8 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -64,6 +64,7 @@ extern int32_t tsCompressMsgSize; extern int32_t tsCompressColData; extern int32_t tsMaxNumOfDistinctResults; extern char tsTempDir[]; +extern int32_t tsShortcutFlag; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 2b84c486a3..3c82a97d61 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -65,6 +65,7 @@ char tsLocale[TSDB_LOCALE_LEN] = {0}; char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string int8_t tsEnableCoreFile = 0; int32_t tsMaxBinaryDisplayWidth = 30; +int32_t tsShortcutFlag = 0; // shortcut flag to facilitate debugging /* * denote if the server needs to compress response message at the application layer to client, including query rsp, @@ -1749,6 +1750,17 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_MB; taosInitConfigOption(cfg); + // shortcut flag to facilitate debugging + cfg.option = "shortcutFlag"; + cfg.ptr = &tsShortcutFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = INT32_MAX; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + #ifdef TD_TSZ // lossy compress cfg.option = "lossyColumns"; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index c5d65b831a..b23e3f3e1c 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -417,6 +417,11 @@ do { \ #define TSDB_DEFAULT_STABLES_HASH_SIZE 100 #define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000 +#define TSDB_SHORTCUT_RPC_SEND_SUBMIT 0x01u +#define TSDB_SHORTCUT_RPC_RECV_SUBMIT 0x02u +#define TSDB_SHORTCUT_VNODE_WAL_WRITE 0x04u +#define TSDB_SHORTCUT_TSDB_COMMIT 0x08u + #define TSDB_PORT_DNODESHELL 0 #define TSDB_PORT_DNODEDNODE 5 #define TSDB_PORT_SYNC 10 diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index c2bebaeee6..60a5837fec 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1160,6 +1160,19 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte rpcMsg.handle = pConn; rpcAddRef(pRpc); // add the refCount for requests + switch (rpcMsg.msgType) { + case TSDB_MSG_TYPE_SUBMIT: + if ((tsShortcutFlag & TSDB_SHORTCUT_RPC_RECV_SUBMIT)) { + SRpcMsg rMsg = {.handle = rpcMsg.handle, .pCont = NULL, .contLen = 0}; + rpcSendResponse(&rMsg); + rpcFreeCont(rpcMsg.pCont); + return; + } + break; + default: + break; + } + // notify the server app (*(pRpc->cfp))(&rpcMsg, NULL); } else { diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index db675d0427..cd2ea7214a 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -98,6 +98,11 @@ void *tsdbCommitData(STsdbRepo *pRepo) { } tsdbStartCommit(pRepo); + if (tsShortcutFlag & TSDB_SHORTCUT_TSDB_COMMIT) { + tsdbEndCommit(pRepo, terrno); + return NULL; + } + // Commit to update meta file if (tsdbCommitMeta(pRepo) < 0) { tsdbError("vgId:%d error occurs while committing META data since %s", REPO_ID(pRepo), tstrerror(terrno)); diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index fd9a340a25..752930ed7e 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 131 +#define TSDB_CFG_MAX_NUM 132 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 40148fcc6d..a3464f75ba 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -103,7 +103,9 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara } // write into WAL - code = walWrite(pVnode->wal, pHead); + if (!(tsShortcutFlag & TSDB_SHORTCUT_VNODE_WAL_WRITE)) { + code = walWrite(pVnode->wal, pHead); + } if (code < 0) { if (syncCode > 0) atomic_sub_fetch_32(&pWrite->processedCount, 1); vError("vgId:%d, hver:%" PRIu64 " vver:%" PRIu64 " code:0x%x", pVnode->vgId, pHead->version, pVnode->version, code); -- GitLab