diff --git a/cmake/cmake.define b/cmake/cmake.define
index 5d64815a9a..78eab0a59a 100644
--- a/cmake/cmake.define
+++ b/cmake/cmake.define
@@ -117,8 +117,8 @@ ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
MESSAGE(STATUS "Will compile with Address Sanitizer!")
ELSE ()
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
ENDIF ()
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
diff --git a/cmake/cmake.version b/cmake/cmake.version
index 05094f10cc..1a83126cd7 100644
--- a/cmake/cmake.version
+++ b/cmake/cmake.version
@@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
- SET(TD_VER_NUMBER "3.0.1.4")
+ SET(TD_VER_NUMBER "3.0.1.5")
ENDIF ()
IF (DEFINED VERCOMPATIBLE)
diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md
index 808a21474e..14096bd400 100644
--- a/docs/en/28-releases/01-tdengine.md
+++ b/docs/en/28-releases/01-tdengine.md
@@ -6,6 +6,10 @@ description: TDengine release history, Release Notes and download links.
import Release from "/components/ReleaseV3";
+## 3.0.1.5
+
+
+
## 3.0.1.4
diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md
index 5d6693ae73..a7446be4e3 100644
--- a/docs/en/28-releases/02-tools.md
+++ b/docs/en/28-releases/02-tools.md
@@ -6,6 +6,10 @@ description: taosTools release history, Release Notes, download links.
import Release from "/components/ReleaseV3";
+## 2.2.6
+
+
+
## 2.2.4
diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md
index 59e0d0f761..a5b3534250 100644
--- a/docs/zh/28-releases/01-tdengine.md
+++ b/docs/zh/28-releases/01-tdengine.md
@@ -6,6 +6,10 @@ description: TDengine 发布历史、Release Notes 及下载链接
import Release from "/components/ReleaseV3";
+## 3.0.1.5
+
+
+
## 3.0.1.4
diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md
index 83ccdec387..e86481435c 100644
--- a/docs/zh/28-releases/02-tools.md
+++ b/docs/zh/28-releases/02-tools.md
@@ -6,6 +6,10 @@ description: taosTools 的发布历史、Release Notes 和下载链接
import Release from "/components/ReleaseV3";
+## 2.2.6
+
+
+
## 2.2.4
diff --git a/include/common/tglobal.h b/include/common/tglobal.h
index 2d196be44c..4a2e14eb78 100644
--- a/include/common/tglobal.h
+++ b/include/common/tglobal.h
@@ -45,14 +45,6 @@ extern bool tsPrintAuth;
extern int64_t tsTickPerMin[3];
extern int32_t tsCountAlwaysReturnValue;
-// multi-process
-extern int32_t tsMultiProcess;
-extern int32_t tsMnodeShmSize;
-extern int32_t tsVnodeShmSize;
-extern int32_t tsQnodeShmSize;
-extern int32_t tsSnodeShmSize;
-extern int32_t tsNumOfShmThreads;
-
// queue & threads
extern int32_t tsNumOfRpcThreads;
extern int32_t tsNumOfCommitThreads;
diff --git a/include/common/tmsg.h b/include/common/tmsg.h
index 42bdc3af16..3409071932 100644
--- a/include/common/tmsg.h
+++ b/include/common/tmsg.h
@@ -1074,7 +1074,8 @@ typedef struct {
typedef struct {
int32_t vgId;
- int32_t syncState;
+ int8_t syncState;
+ int8_t syncRestore;
int64_t cacheUsage;
int64_t numOfTables;
int64_t numOfTimeSeries;
@@ -1089,7 +1090,8 @@ typedef struct {
} SVnodeLoad;
typedef struct {
- int32_t syncState;
+ int8_t syncState;
+ int8_t syncRestore;
} SMnodeLoad;
typedef struct {
diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h
index 1a8865bf83..7b4e930485 100644
--- a/include/common/tmsgdef.h
+++ b/include/common/tmsgdef.h
@@ -239,13 +239,6 @@ enum {
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
TD_NEW_MSG_SEG(TDMT_MON_MSG)
- TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_QM_INFO, "monitor-qinfo", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_SM_INFO, "monitor-sinfo", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_VM_LOAD, "monitor-vload", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_MM_LOAD, "monitor-mload", NULL, NULL)
- TD_DEF_MSG_TYPE(TDMT_MON_QM_LOAD, "monitor-qload", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL)
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
diff --git a/include/common/ttypes.h b/include/common/ttypes.h
index 14e9a5af87..733270dbed 100644
--- a/include/common/ttypes.h
+++ b/include/common/ttypes.h
@@ -337,21 +337,16 @@ typedef struct tDataTypeDescriptor {
int32_t nBuf);
int32_t (*decompFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
int32_t nBuf);
- void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull);
} tDataTypeDescriptor;
extern tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX];
bool isValidDataType(int32_t type);
-void setVardataNull(void *val, int32_t type);
-void setNull(void *val, int32_t type, int32_t bytes);
-void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems);
-const void *getNullValue(int32_t type);
-
+void setVardataNull(void *val, int32_t type);
+//void setNull(void *val, int32_t type, int32_t bytes);
+//void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems);
void assignVal(char *val, const char *src, int32_t len, int32_t type);
-void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void *buf);
void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
void *getDataMin(int32_t type);
void *getDataMax(int32_t type);
diff --git a/include/common/tvariant.h b/include/common/tvariant.h
index 9728e5ecd5..0507934e6a 100644
--- a/include/common/tvariant.h
+++ b/include/common/tvariant.h
@@ -39,8 +39,6 @@ typedef struct SVariant {
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
-bool taosVariantIsValid(SVariant *pVar);
-
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
void taosVariantDestroy(SVariant *pV);
@@ -49,15 +47,6 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc);
int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2);
-int32_t taosVariantToString(SVariant *pVar, char *dst);
-
-int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix);
-
-#if 0
-int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo);
-#endif
-
-int32_t taosVariantTypeSetType(SVariant *pVariant, char type);
char *taosVariantGet(SVariant *pVar, int32_t type);
#ifdef __cplusplus
diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h
index fe1692c50f..82823e3f57 100644
--- a/include/dnode/mgmt/dnode.h
+++ b/include/dnode/mgmt/dnode.h
@@ -25,10 +25,9 @@ extern "C" {
/**
* @brief Initialize the dnode
*
- * @param rtype for internal debug usage, default is 0
* @return int32_t 0 for success and -1 for failure
*/
-int32_t dmInit(int8_t rtype);
+int32_t dmInit();
/**
* @brief Cleanup the dnode
diff --git a/include/os/os.h b/include/os/os.h
index 28a3ebee81..e780611c41 100644
--- a/include/os/os.h
+++ b/include/os/os.h
@@ -94,10 +94,8 @@ extern "C" {
#include "osLz4.h"
#include "osMath.h"
#include "osMemory.h"
-#include "osProc.h"
#include "osRand.h"
#include "osSemaphore.h"
-#include "osShm.h"
#include "osSignal.h"
#include "osSleep.h"
#include "osSocket.h"
diff --git a/include/os/osEnv.h b/include/os/osEnv.h
index d4e94d6173..c1fdc9e404 100644
--- a/include/os/osEnv.h
+++ b/include/os/osEnv.h
@@ -60,6 +60,7 @@ bool osTempSpaceSufficient();
void osSetTimezone(const char *timezone);
void osSetSystemLocale(const char *inLocale, const char *inCharSet);
+void osSetProcPath(int32_t argc, char **argv);
#ifdef __cplusplus
}
diff --git a/include/os/osProc.h b/include/os/osProc.h
deleted file mode 100644
index f09b695ef4..0000000000
--- a/include/os/osProc.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef _TD_OS_PROC_H_
-#define _TD_OS_PROC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int32_t taosNewProc(char **args);
-void taosWaitProc(int32_t pid);
-void taosKillProc(int32_t pid);
-bool taosProcExist(int32_t pid);
-void taosSetProcName(int32_t argc, char **argv, const char *name);
-void taosSetProcPath(int32_t argc, char **argv);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_TD_OS_PROC_H_*/
diff --git a/include/os/osShm.h b/include/os/osShm.h
deleted file mode 100644
index 87efb1ab16..0000000000
--- a/include/os/osShm.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef _TD_OS_SHM_H_
-#define _TD_OS_SHM_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- int32_t id;
- int32_t size;
- void *ptr;
-} SShm;
-
-int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize);
-void taosDropShm(SShm *pShm);
-int32_t taosAttachShm(SShm *pShm);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_TD_OS_SHM_H_*/
diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c
index 7b9009c34b..f222334605 100644
--- a/source/client/src/clientImpl.c
+++ b/source/client/src/clientImpl.c
@@ -186,7 +186,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
STscObj* pTscObj = (*pRequest)->pTscObj;
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
sizeof((*pRequest)->self))) {
- tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s",
+ tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
taosMemoryFree(param);
@@ -369,8 +369,8 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
if (pNodeList) {
pInfo->pQnodeList = taosArrayDup(pNodeList);
taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad);
- tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%d", pInfo->clusterId,
- (int)taosArrayGetSize(pInfo->pQnodeList));
+ tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%ld", pInfo->clusterId,
+ taosArrayGetSize(pInfo->pQnodeList));
}
taosThreadMutexUnlock(&pInfo->qnodeMutex);
diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c
index 1dc319be94..dfcd8c4a79 100644
--- a/source/client/src/clientRawBlockWrite.c
+++ b/source/client/src/clientRawBlockWrite.c
@@ -1071,8 +1071,8 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
// getTbName(req.tableFName);
char sql[256] = {0};
- sprintf(sql, "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, req.tsColName,
- req.skey, req.tsColName, req.ekey);
+ snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName,
+ req.tsColName, req.skey, req.tsColName, req.ekey);
printf("delete sql:%s\n", sql);
TAOS_RES* res = taos_query(taos, sql);
diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c
index 0bc33739c6..e279c1fef5 100644
--- a/source/client/src/clientTmq.c
+++ b/source/client/src/clientTmq.c
@@ -638,7 +638,7 @@ static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async,
pVg->vgId);
if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) {
- tscDebug("consumer: %ld, vg:%d, current %ld, committed %ld", tmq->consumerId, pVg->vgId,
+ tscDebug("consumer: %" PRId64 ", vg:%d, current %" PRId64 ", committed %" PRId64 "", tmq->consumerId, pVg->vgId,
pVg->currentOffset.version, pVg->committedOffset.version);
if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) {
continue;
@@ -982,7 +982,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
SCMSubscribeReq req = {0};
int32_t code = -1;
- tscDebug("call tmq subscribe, consumer: %ld, topic num %d", tmq->consumerId, sz);
+ tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
req.consumerId = tmq->consumerId;
tstrncpy(req.clientId, tmq->clientId, 256);
@@ -990,6 +990,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
req.topicNames = taosArrayInit(sz, sizeof(void*));
if (req.topicNames == NULL) goto FAIL;
+ tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz);
+
for (int32_t i = 0; i < sz; i++) {
char* topic = taosArrayGetP(container, i);
@@ -1620,7 +1622,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
return NULL;
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
- tscDebug("consumer %ld actual process poll rsp", tmq->consumerId);
+ tscDebug("consumer %" PRId64 " actual process poll rsp", tmq->consumerId);
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) {
diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c
index 62706db980..a22837d981 100644
--- a/source/common/src/tdatablock.c
+++ b/source/common/src/tdatablock.c
@@ -1836,10 +1836,10 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
printf(" %15u |", *(uint32_t*)var);
break;
case TSDB_DATA_TYPE_BIGINT:
- printf(" %15ld |", *(int64_t*)var);
+ printf(" %15" PRId64 " |", *(int64_t*)var);
break;
case TSDB_DATA_TYPE_UBIGINT:
- printf(" %15lu |", *(uint64_t*)var);
+ printf(" %15" PRIu64 " |", *(uint64_t*)var);
break;
case TSDB_DATA_TYPE_FLOAT:
printf(" %15f |", *(float*)var);
@@ -1915,11 +1915,11 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
if (len >= size - 1) return dumpBuf;
break;
case TSDB_DATA_TYPE_BIGINT:
- len += snprintf(dumpBuf + len, size - len, " %15ld |", *(int64_t*)var);
+ len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
if (len >= size - 1) return dumpBuf;
break;
case TSDB_DATA_TYPE_UBIGINT:
- len += snprintf(dumpBuf + len, size - len, " %15lu |", *(uint64_t*)var);
+ len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
if (len >= size - 1) return dumpBuf;
break;
case TSDB_DATA_TYPE_FLOAT:
diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c
index 7967b6885a..a11c67c1fd 100644
--- a/source/common/src/tdataformat.c
+++ b/source/common/src/tdataformat.c
@@ -114,7 +114,7 @@ static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
((uint32_t *)(p))[i] = (n); \
} \
} while (0)
-
+#if 0
int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, STSRow2 **ppRow) {
int32_t code = 0;
#if 0
@@ -432,7 +432,6 @@ void tTSRowFree(STSRow2 *pRow) {
}
void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
-#if 0
uint8_t isTuple = ((pRow->flags & 0xf0) == 0) ? 1 : 0;
STColumn *pTColumn = &pTSchema->columns[iCol];
uint8_t flags = pRow->flags & (uint8_t)0xf;
@@ -577,12 +576,10 @@ _return_null:
_return_value:
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, value);
return;
-#endif
}
int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray) {
int32_t code = 0;
-#if 0
SColVal cv;
(*ppArray) = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal));
@@ -596,11 +593,11 @@ int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray) {
taosArrayPush(*ppArray, &cv);
}
-#endif
+
_exit:
return code;
}
-
+#endif
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow) {
int32_t n = 0;
diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c
index 2b64d3f1ee..3edeeee49a 100644
--- a/source/common/src/tglobal.c
+++ b/source/common/src/tglobal.c
@@ -40,14 +40,6 @@ int32_t tsMaxShellConns = 50000;
int32_t tsShellActivityTimer = 3; // second
bool tsPrintAuth = false;
-// multi process
-int32_t tsMultiProcess = 0;
-int32_t tsMnodeShmSize = TSDB_MAX_MSG_SIZE * 2 + 1024;
-int32_t tsVnodeShmSize = TSDB_MAX_MSG_SIZE * 10 + 1024;
-int32_t tsQnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
-int32_t tsSnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
-int32_t tsNumOfShmThreads = 1;
-
// queue & threads
int32_t tsNumOfRpcThreads = 1;
int32_t tsNumOfCommitThreads = 2;
@@ -352,13 +344,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
- if (cfgAddInt32(pCfg, "numOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1;
-
tsNumOfRpcThreads = tsNumOfCores / 2;
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, 4);
if (cfgAddInt32(pCfg, "numOfRpcThreads", tsNumOfRpcThreads, 1, 1024, 0) != 0) return -1;
@@ -698,14 +683,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
-#if !defined(WINDOWS) && !defined(DARWIN)
- tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
-#endif
- tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
- tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
- tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
- tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32;
-
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
@@ -903,12 +880,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
}
break;
}
- case 'n': {
- if (strcasecmp("mnodeShmSize", name) == 0) {
- tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
- }
- break;
- }
case 'o': {
if (strcasecmp("monitor", name) == 0) {
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
@@ -932,11 +903,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
break;
}
case 'u': {
- if (strcasecmp("multiProcess", name) == 0) {
-#if !defined(WINDOWS) && !defined(DARWIN)
- tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
-#endif
- } else if (strcasecmp("udfDebugFlag", name) == 0) {
+ if (strcasecmp("udfDebugFlag", name) == 0) {
udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32;
}
break;
@@ -999,8 +966,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
if (tsQueryBufferSize >= 0) {
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
}
- } else if (strcasecmp("qnodeShmSize", name) == 0) {
- tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
} else if (strcasecmp("qDebugFlag", name) == 0) {
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
} else if (strcasecmp("queryPlannerTrace", name) == 0) {
@@ -1041,8 +1006,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
} else if (strcasecmp("statusInterval", name) == 0) {
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
- } else if (strcasecmp("snodeShmSize", name) == 0) {
- tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32;
} else if (strcasecmp("serverPort", name) == 0) {
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN);
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
@@ -1110,9 +1073,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
break;
}
case 'v': {
- if (strcasecmp("vnodeShmSize", name) == 0) {
- tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
- } else if (strcasecmp("vDebugFlag", name) == 0) {
+ if (strcasecmp("vDebugFlag", name) == 0) {
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
}
break;
@@ -1235,6 +1196,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
if (cfgLoadFromArray(tsCfg, pArgs) != 0) {
uError("failed to load cfg from array since %s", terrstr());
cfgCleanup(tsCfg);
+ tsCfg = NULL;
return -1;
}
diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c
index 1f0023278f..65541ca9cc 100644
--- a/source/common/src/tmsg.c
+++ b/source/common/src/tmsg.c
@@ -993,7 +993,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
for (int32_t i = 0; i < vlen; ++i) {
SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i);
if (tEncodeI32(&encoder, pload->vgId) < 0) return -1;
- if (tEncodeI32(&encoder, pload->syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pload->syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pload->syncRestore) < 0) return -1;
if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1;
if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1;
if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1;
@@ -1003,7 +1004,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
}
// mnode loads
- if (tEncodeI32(&encoder, pReq->mload.syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pReq->mload.syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pReq->mload.syncRestore) < 0) return -1;
if (tEncodeI32(&encoder, pReq->qload.dnodeId) < 0) return -1;
if (tEncodeI64(&encoder, pReq->qload.numOfProcessedQuery) < 0) return -1;
@@ -1063,7 +1065,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
for (int32_t i = 0; i < vlen; ++i) {
SVnodeLoad vload = {0};
if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1;
- if (tDecodeI32(&decoder, &vload.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &vload.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &vload.syncRestore) < 0) return -1;
if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1;
if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1;
if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1;
@@ -1076,7 +1079,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
}
}
- if (tDecodeI32(&decoder, &pReq->mload.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &pReq->mload.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &pReq->mload.syncRestore) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->qload.dnodeId) < 0) return -1;
if (tDecodeI64(&decoder, &pReq->qload.numOfProcessedQuery) < 0) return -1;
diff --git a/source/common/src/trow.c b/source/common/src/trow.c
index e1085ce5d8..d5c0f2ddf8 100644
--- a/source/common/src/trow.c
+++ b/source/common/src/trow.c
@@ -41,286 +41,6 @@ static bool tdSKvRowGetVal(STSRow *pRow, col_id_t colId, col_id_t colIdx, SCe
static void tdSCellValPrint(SCellVal *pVal, int8_t colType);
// implementation
-/**
- * @brief Compress bitmap bytes comprised of 2-bits to counterpart of 1-bit.
- * e.g.
- * TD_VTYPE_NORM 0x00U(00000000) to 00000000 Normal
- * TD_VTYPE_NULL 0x01U(00000001) to 00000001 Null
- * TD_VTYPE_NONE 0x02U(00000010) to 00000001 Null
- *
- * 00000000 0x00 0x00
- * 01000000 0x40 0x08
- * 10000000 0x80 0x08
- * ...
- * @param byte
- * @return uint8_t
- */
-static uint8_t tdGetMergedBitmapByte(uint8_t byte) {
- switch (byte) {
- case 0x00:
- return 0x00;
- case 0x40:
- return 0x08;
- case 0x80:
- return 0x08;
- case 0x10:
- return 0x04;
- case 0x50:
- return 0x0c;
- case 0x90:
- return 0x0c;
- case 0x20:
- return 0x04;
- case 0x60:
- return 0x0c;
- case 0xa0:
- return 0x0c;
- case 0x04:
- return 0x02;
- case 0x44:
- return 0x0a;
- case 0x84:
- return 0x0a;
- case 0x14:
- return 0x06;
- case 0x54:
- return 0x0e;
- case 0x94:
- return 0x0e;
- case 0x24:
- return 0x06;
- case 0x64:
- return 0x0e;
- case 0xa4:
- return 0x0e;
- case 0x08:
- return 0x02;
- case 0x48:
- return 0x0a;
- case 0x88:
- return 0x0a;
- case 0x18:
- return 0x06;
- case 0x58:
- return 0x0e;
- case 0x98:
- return 0x0e;
- case 0x28:
- return 0x06;
- case 0x68:
- return 0x0e;
- case 0xa8:
- return 0x0e;
- case 0x01:
- return 0x01;
- case 0x41:
- return 0x09;
- case 0x81:
- return 0x09;
- case 0x11:
- return 0x05;
- case 0x51:
- return 0x0d;
- case 0x91:
- return 0x0d;
- case 0x21:
- return 0x05;
- case 0x61:
- return 0x0d;
- case 0xa1:
- return 0x0d;
- case 0x05:
- return 0x03;
- case 0x45:
- return 0x0b;
- case 0x85:
- return 0x0b;
- case 0x15:
- return 0x07;
- case 0x55:
- return 0x0f;
- case 0x95:
- return 0x0f;
- case 0x25:
- return 0x07;
- case 0x65:
- return 0x0f;
- case 0xa5:
- return 0x0f;
- case 0x09:
- return 0x03;
- case 0x49:
- return 0x0b;
- case 0x89:
- return 0x0b;
- case 0x19:
- return 0x07;
- case 0x59:
- return 0x0f;
- case 0x99:
- return 0x0f;
- case 0x29:
- return 0x07;
- case 0x69:
- return 0x0f;
- case 0xa9:
- return 0x0f;
- case 0x02:
- return 0x01;
- case 0x42:
- return 0x09;
- case 0x82:
- return 0x09;
- case 0x12:
- return 0x05;
- case 0x52:
- return 0x0d;
- case 0x92:
- return 0x0d;
- case 0x22:
- return 0x05;
- case 0x62:
- return 0x0d;
- case 0xa2:
- return 0x0d;
- case 0x06:
- return 0x03;
- case 0x46:
- return 0x0b;
- case 0x86:
- return 0x0b;
- case 0x16:
- return 0x07;
- case 0x56:
- return 0x0f;
- case 0x96:
- return 0x0f;
- case 0x26:
- return 0x07;
- case 0x66:
- return 0x0f;
- case 0xa6:
- return 0x0f;
- case 0x0a:
- return 0x03;
- case 0x4a:
- return 0x0b;
- case 0x8a:
- return 0x0b;
- case 0x1a:
- return 0x07;
- case 0x5a:
- return 0x0f;
- case 0x9a:
- return 0x0f;
- case 0x2a:
- return 0x07;
- case 0x6a:
- return 0x0f;
- case 0xaa:
- return 0x0f;
- default:
- // make sure the bitmap area is set to 0 firstly
- ASSERT(0);
- return 0x0f; // return NULL bitmap for exception
- }
-}
-
-/**
- * @brief Merge bitmap from 2 bits to 1 bit, and the memory buffer should be guaranteed by the invoker.
- *
- * @param srcBitmap
- * @param nBits
- * @param dstBitmap
- */
-void tdMergeBitmap(uint8_t *srcBitmap, int32_t nBits, uint8_t *dstBitmap) {
- int32_t i = 0, j = 0;
- int32_t nBytes = TD_BITMAP_BYTES(nBits);
- int32_t nRoundBytes = nBits / 4;
- int32_t nRemainderBits = nBits - nRoundBytes * 4;
-
- switch (nRemainderBits) {
- case 0:
- // NOTHING TODO
- break;
- case 1: {
- void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
- *(uint8_t *)lastByte &= 0xC0;
- } break;
- case 2: {
- void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
- *(uint8_t *)lastByte &= 0xF0;
- } break;
- case 3: {
- void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
- *(uint8_t *)lastByte &= 0xFC;
- } break;
- default:
- ASSERT(0);
- }
-
- if (nBytes > 0) {
- dstBitmap[j] = (tdGetMergedBitmapByte(srcBitmap[i]) << 4);
- }
-
- while ((++i) < nBytes) {
- if ((i & 1) == 0) {
- dstBitmap[j] = (tdGetMergedBitmapByte(srcBitmap[i]) << 4);
- } else {
- dstBitmap[j] |= tdGetMergedBitmapByte(srcBitmap[i]);
- ++j;
- }
- }
-}
-
-/**
- * @brief Set bitmap area by byte preferentially and then by bit.
- *
- * @param pBitmap
- * @param nEle
- * @param valType
- * @param bitmapMode 0 for 2 bits, 1 for 1 bit
- * @return int32_t
- */
-int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode) {
- TASSERT(valType < TD_VTYPE_MAX);
- int32_t nBytes = (bitmapMode == 0 ? nEle / TD_VTYPE_PARTS : nEle / TD_VTYPE_PARTS_I);
- uint8_t vTypeByte = tdVTypeByte[bitmapMode][valType];
- for (int i = 0; i < nBytes; ++i) {
- *(uint8_t *)pBitmap = vTypeByte;
- pBitmap = POINTER_SHIFT(pBitmap, 1);
- }
-
- int32_t nLeft = nEle - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
- for (int j = 0; j < nLeft; ++j) {
- tdSetBitmapValType(pBitmap, j, valType, bitmapMode);
- }
- return TSDB_CODE_SUCCESS;
-}
-
-bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode) {
- int32_t nBytes = (bitmapMode == 0 ? numOfBits / TD_VTYPE_PARTS : numOfBits / TD_VTYPE_PARTS_I);
- uint8_t vTypeByte = tdVTypeByte[bitmapMode][TD_VTYPE_NORM];
- uint8_t *qBitmap = (uint8_t *)pBitmap;
- for (int i = 0; i < nBytes; ++i) {
- if (*qBitmap != vTypeByte) {
- return false;
- }
- qBitmap = (uint8_t *)POINTER_SHIFT(pBitmap, i);
- }
-
- int32_t nLeft = numOfBits - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
-
- for (int j = 0; j < nLeft; ++j) {
- uint8_t vType;
- tdGetBitmapValType(qBitmap, j, &vType, bitmapMode);
- if (vType != TD_VTYPE_NORM) {
- return false;
- }
- }
- return true;
-}
-
STSRow *tdRowDup(STSRow *row) {
STSRow *trow = taosMemoryMalloc(TD_ROW_LEN(row));
if (trow == NULL) return NULL;
diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c
index fee89e2f37..3dbd8a05a2 100644
--- a/source/common/src/ttypes.c
+++ b/source/common/src/ttypes.c
@@ -37,394 +37,30 @@ const int32_t TYPE_BYTES[16] = {
TSDB_MAX_JSON_TAG_LEN, // TSDB_DATA_TYPE_JSON
};
-#define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \
- do { \
- (__sum) += (_list)[(_index)]; \
- if ((__min) > (_list)[(_index)]) { \
- (__min) = (_list)[(_index)]; \
- (__minIndex) = (_index); \
- } \
- \
- if ((__max) < (_list)[(_index)]) { \
- (__max) = (_list)[(_index)]; \
- (__maxIndex) = (_index); \
- } \
- } while (0)
-
-static void getStatics_bool(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- int8_t *data = (int8_t *)pData;
- *min = INT64_MAX;
- *max = INT64_MIN;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (data[i] == TSDB_DATA_BOOL_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
- }
-}
-
-static void getStatics_i8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- int8_t *data = (int8_t *)pData;
- *min = INT64_MAX;
- *max = INT64_MIN;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
- }
-}
-
-static void getStatics_u8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- uint8_t *data = (uint8_t *)pData;
- uint64_t _min = UINT64_MAX;
- uint64_t _max = 0;
- uint64_t _sum = 0;
-
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
- }
-
- *min = _min;
- *max = _max;
- *sum = _sum;
-}
-
-static void getStatics_i16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- int16_t *data = (int16_t *)pData;
- *min = INT64_MAX;
- *max = INT64_MIN;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
- }
-}
-
-static void getStatics_u16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- uint16_t *data = (uint16_t *)pData;
- uint64_t _min = UINT64_MAX;
- uint64_t _max = 0;
- uint64_t _sum = 0;
-
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
- }
-
- *min = _min;
- *max = _max;
- *sum = _sum;
-}
-
-static void getStatics_i32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- int32_t *data = (int32_t *)pData;
- *min = INT64_MAX;
- *max = INT64_MIN;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
- }
-}
-
-static void getStatics_u32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- uint32_t *data = (uint32_t *)pData;
- uint64_t _min = UINT64_MAX;
- uint64_t _max = 0;
- uint64_t _sum = 0;
-
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
- }
-
- *min = _min;
- *max = _max;
- *sum = _sum;
-}
-
-static void getStatics_i64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- int64_t *data = (int64_t *)pData;
- *min = INT64_MAX;
- *max = INT64_MIN;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
- }
-}
-
-static void getStatics_u64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- uint64_t *data = (uint64_t *)pData;
- uint64_t _min = UINT64_MAX;
- uint64_t _max = 0;
- uint64_t _sum = 0;
-
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
- }
-
- *min = _min;
- *max = _max;
- *sum = _sum;
-}
-
-static void getStatics_f(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- float *data = (float *)pData;
- float fmin = FLT_MAX;
- float fmax = -FLT_MAX;
- double dsum = 0;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- float fv = GET_FLOAT_VAL((const char *)&(data[i]));
-
- dsum += fv;
- if (fmin > fv) {
- fmin = fv;
- *minIndex = i;
- }
-
- if (fmax < fv) {
- fmax = fv;
- *maxIndex = i;
- }
- }
-
- SET_DOUBLE_VAL(sum, dsum);
- SET_DOUBLE_VAL(max, fmax);
- SET_DOUBLE_VAL(min, fmin);
-}
-
-static void getStatics_d(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- double *data = (double *)pData;
- double dmin = DBL_MAX;
- double dmax = -DBL_MAX;
- double dsum = 0;
- *minIndex = 0;
- *maxIndex = 0;
-
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- continue;
- }
-
- double dv = 0;
- dv = GET_DOUBLE_VAL((const char *)&(data[i]));
- dsum += dv;
- if (dmin > dv) {
- dmin = dv;
- *minIndex = i;
- }
-
- if (dmax < dv) {
- dmax = dv;
- *maxIndex = i;
- }
- }
-
- SET_DOUBLE_PTR(sum, &dsum);
- SET_DOUBLE_PTR(max, &dmax);
- SET_DOUBLE_PTR(min, &dmin);
-}
-
-static void getStatics_bin(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- const char *data = pData;
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- }
-
- data += varDataTLen(data);
- }
-
- *sum = 0;
- *max = 0;
- *min = 0;
- *minIndex = 0;
- *maxIndex = 0;
-}
-
-static void getStatics_nchr(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
- int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
- const char *data = pData;
- assert(numOfRow <= INT16_MAX);
-
- for (int32_t i = 0; i < numOfRow; ++i) {
- // if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
- if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
- (*numOfNull) += 1;
- }
-
- data += varDataTLen(data);
- }
-
- *sum = 0;
- *max = 0;
- *min = 0;
- *minIndex = 0;
- *maxIndex = 0;
-}
-
tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
- {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL, NULL},
- {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool, getStatics_bool},
- {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint,
- getStatics_i8},
+ {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL},
+ {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool},
+ {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint},
{TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", INT16_MIN, INT16_MAX, tsCompressSmallint,
- tsDecompressSmallint, getStatics_i16},
- {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", INT32_MIN, INT32_MAX, tsCompressInt, tsDecompressInt, getStatics_i32},
- {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint, tsDecompressBigint,
- getStatics_i64},
- {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat, getStatics_f},
- {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble, getStatics_d},
- {TSDB_DATA_TYPE_VARCHAR, 6, 1, "VARCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_bin},
+ tsDecompressSmallint},
+ {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", INT32_MIN, INT32_MAX, tsCompressInt, tsDecompressInt},
+ {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint, tsDecompressBigint},
+ {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat},
+ {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble},
+ {TSDB_DATA_TYPE_VARCHAR, 6, 1, "VARCHAR", 0, 0, tsCompressString, tsDecompressString},
{TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", INT64_MIN, INT64_MAX, tsCompressTimestamp,
- tsDecompressTimestamp, getStatics_i64},
- {TSDB_DATA_TYPE_NCHAR, 5, 1, "NCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr},
- {TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint, tsDecompressTinyint,
- getStatics_u8},
+ tsDecompressTimestamp},
+ {TSDB_DATA_TYPE_NCHAR, 5, 1, "NCHAR", 0, 0, tsCompressString, tsDecompressString},
+ {TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint, tsDecompressTinyint},
{TSDB_DATA_TYPE_USMALLINT, 17, SHORT_BYTES, "SMALLINT UNSIGNED", 0, UINT16_MAX, tsCompressSmallint,
- tsDecompressSmallint, getStatics_u16},
- {TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt, getStatics_u32},
- {TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint,
- getStatics_u64},
- {TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString,
- getStatics_nchr},
+ tsDecompressSmallint},
+ {TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt},
+ {TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint},
+ {TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString},
};
-char tTokenTypeSwitcher[13] = {
- TSDB_DATA_TYPE_NULL, // no type
- TSDB_DATA_TYPE_BINARY, // TK_ID
- TSDB_DATA_TYPE_BOOL, // TK_BOOL
- TSDB_DATA_TYPE_BIGINT, // TK_TINYINT
- TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT
- TSDB_DATA_TYPE_BIGINT, // TK_INTEGER
- TSDB_DATA_TYPE_BIGINT, // TK_BIGINT
- TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT
- TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE
- TSDB_DATA_TYPE_BINARY, // TK_STRING
- TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP
- TSDB_DATA_TYPE_VARCHAR, // TK_BINARY
- TSDB_DATA_TYPE_NCHAR, // TK_NCHAR
-};
-
-float floatMin = -FLT_MAX, floatMax = FLT_MAX;
-double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
+static float floatMin = -FLT_MAX, floatMax = FLT_MAX;
+static double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
FORCE_INLINE void *getDataMin(int32_t type) {
switch (type) {
@@ -462,107 +98,8 @@ void setVardataNull(void *val, int32_t type) {
}
}
-void setNull(void *val, int32_t type, int32_t bytes) { setNullN(val, type, bytes, 1); }
-
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
-void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems) {
- switch (type) {
- case TSDB_DATA_TYPE_BOOL:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_BOOL_NULL;
- }
- break;
- case TSDB_DATA_TYPE_TINYINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_TINYINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_SMALLINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint16_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_SMALLINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_INT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_INT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_BIGINT:
- case TSDB_DATA_TYPE_TIMESTAMP:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_BIGINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_UTINYINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UTINYINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_USMALLINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint16_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_USMALLINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_UINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_UBIGINT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UBIGINT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_FLOAT:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_FLOAT_NULL;
- }
- break;
- case TSDB_DATA_TYPE_DOUBLE:
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_DOUBLE_NULL;
- }
- break;
- case TSDB_DATA_TYPE_NCHAR:
- case TSDB_DATA_TYPE_BINARY:
- for (int32_t i = 0; i < numOfElems; ++i) {
- setVardataNull(POINTER_SHIFT(val, i * bytes), type);
- }
- break;
- default: {
- for (int32_t i = 0; i < numOfElems; ++i) {
- *(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[TSDB_DATA_TYPE_INT].bytes)) = TSDB_DATA_INT_NULL;
- }
- break;
- }
- }
-}
-
-static uint8_t nullBool = TSDB_DATA_BOOL_NULL;
-static uint8_t nullTinyInt = TSDB_DATA_TINYINT_NULL;
-static uint16_t nullSmallInt = TSDB_DATA_SMALLINT_NULL;
-static uint32_t nullInt = TSDB_DATA_INT_NULL;
-static uint64_t nullBigInt = TSDB_DATA_BIGINT_NULL;
-static uint32_t nullFloat = TSDB_DATA_FLOAT_NULL;
-static uint64_t nullDouble = TSDB_DATA_DOUBLE_NULL;
-static uint8_t nullTinyIntu = TSDB_DATA_UTINYINT_NULL;
-static uint16_t nullSmallIntu = TSDB_DATA_USMALLINT_NULL;
-static uint32_t nullIntu = TSDB_DATA_UINT_NULL;
-static uint64_t nullBigIntu = TSDB_DATA_UBIGINT_NULL;
-static SBinaryNullT nullBinary = {1, TSDB_DATA_BINARY_NULL};
-static SNCharNullT nullNchar = {4, TSDB_DATA_NCHAR_NULL};
-
-static const void *nullValues[] = {
- &nullBool, &nullTinyInt, &nullSmallInt, &nullInt, &nullBigInt, &nullFloat, &nullDouble,
- &nullBinary, &nullBigInt, &nullNchar, &nullTinyIntu, &nullSmallIntu, &nullIntu, &nullBigIntu,
-};
-
-const void *getNullValue(int32_t type) {
- assert(type >= TSDB_DATA_TYPE_BOOL && type <= TSDB_DATA_TYPE_UBIGINT); // TODO: extend the types
- return nullValues[type - 1];
-}
-
void assignVal(char *val, const char *src, int32_t len, int32_t type) {
switch (type) {
case TSDB_DATA_TYPE_BOOL:
@@ -648,48 +185,3 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) {
assert(0);
}
}
-
-void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void *buf) {
- switch (type) {
- case TSDB_DATA_TYPE_INT:
- case TSDB_DATA_TYPE_UINT: {
- TSWAP(*(int32_t *)(pLeft), *(int32_t *)(pRight));
- break;
- }
-
- case TSDB_DATA_TYPE_BIGINT:
- case TSDB_DATA_TYPE_UBIGINT:
- case TSDB_DATA_TYPE_TIMESTAMP: {
- TSWAP(*(int64_t *)(pLeft), *(int64_t *)(pRight));
- break;
- }
- case TSDB_DATA_TYPE_DOUBLE: {
- TSWAP(*(double *)(pLeft), *(double *)(pRight));
- break;
- }
- case TSDB_DATA_TYPE_SMALLINT:
- case TSDB_DATA_TYPE_USMALLINT: {
- TSWAP(*(int16_t *)(pLeft), *(int16_t *)(pRight));
- break;
- }
-
- case TSDB_DATA_TYPE_FLOAT: {
- TSWAP(*(float *)(pLeft), *(float *)(pRight));
- break;
- }
-
- case TSDB_DATA_TYPE_BOOL:
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_UTINYINT: {
- TSWAP(*(int8_t *)(pLeft), *(int8_t *)(pRight));
- break;
- }
-
- default: {
- memcpy(buf, pLeft, size);
- memcpy(pLeft, pRight, size);
- memcpy(pRight, buf, size);
- break;
- }
- }
-}
diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c
index 9660a37f48..8d4c17a821 100644
--- a/source/common/src/tvariant.c
+++ b/source/common/src/tvariant.c
@@ -19,22 +19,6 @@
#include "ttokendef.h"
#include "tvariant.h"
-#define SET_EXT_INFO(converted, res, minv, maxv, exti) \
- do { \
- if (converted == NULL || exti == NULL || *converted == false) { \
- break; \
- } \
- if ((res) < (minv)) { \
- *exti = -1; \
- break; \
- } \
- if ((res) > (maxv)) { \
- *exti = 1; \
- break; \
- } \
- assert(0); \
- } while (0)
-
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
errno = 0;
char *endPtr = NULL;
@@ -53,8 +37,8 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
char *endPtr = NULL;
const char *p = z;
- while (*p != 0 && *p == ' ') p++;
- if (*p != 0 && *p == '-') {
+ while (*p == ' ') p++;
+ if (*p == '-') {
return -1;
}
@@ -176,11 +160,6 @@ void taosVariantDestroy(SVariant *pVar) {
}
}
-bool taosVariantIsValid(SVariant *pVar) {
- assert(pVar != NULL);
- return isValidDataType(pVar->nType);
-}
-
void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
if (pSrc == NULL || pDst == NULL) return;
@@ -265,702 +244,6 @@ int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2) {
}
}
-int32_t taosVariantToString(SVariant *pVar, char *dst) {
- if (pVar == NULL || dst == NULL) return 0;
-
- switch (pVar->nType) {
- case TSDB_DATA_TYPE_BINARY: {
- int32_t len = sprintf(dst, "\'%s\'", pVar->pz);
- assert(len <= pVar->nLen + sizeof("\'") * 2); // two more chars
- return len;
- }
-
- case TSDB_DATA_TYPE_NCHAR: {
- dst[0] = '\'';
- taosUcs4ToMbs(pVar->ucs4, (taosUcs4len(pVar->ucs4) + 1) * TSDB_NCHAR_SIZE, dst + 1);
- int32_t len = (int32_t)strlen(dst);
- dst[len] = '\'';
- dst[len + 1] = 0;
- return len + 1;
- }
-
- case TSDB_DATA_TYPE_BOOL:
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_SMALLINT:
- case TSDB_DATA_TYPE_INT:
- case TSDB_DATA_TYPE_UTINYINT:
- case TSDB_DATA_TYPE_USMALLINT:
- case TSDB_DATA_TYPE_UINT:
- return sprintf(dst, "%d", (int32_t)pVar->i);
-
- case TSDB_DATA_TYPE_BIGINT:
- return sprintf(dst, "%" PRId64, pVar->i);
- case TSDB_DATA_TYPE_UBIGINT:
- return sprintf(dst, "%" PRIu64, pVar->u);
- case TSDB_DATA_TYPE_FLOAT:
- case TSDB_DATA_TYPE_DOUBLE:
- return sprintf(dst, "%.9lf", pVar->d);
-
- default:
- return 0;
- }
-}
-
-static FORCE_INLINE int32_t convertToBoolImpl(char *pStr, int32_t len) {
- if ((strncasecmp(pStr, "true", len) == 0) && (len == 4)) {
- return TSDB_TRUE;
- } else if ((strncasecmp(pStr, "false", len) == 0) && (len == 5)) {
- return TSDB_FALSE;
- } else if (strcasecmp(pStr, TSDB_DATA_NULL_STR_L) == 0) {
- return TSDB_DATA_BOOL_NULL;
- } else {
- return -1;
- }
-}
-
-static FORCE_INLINE int32_t wcsconvertToBoolImpl(TdUcs4 *pstr, int32_t len) {
- if ((wcsncasecmp(pstr, L"true", len) == 0) && (len == 4)) {
- return TSDB_TRUE;
- } else if (wcsncasecmp(pstr, L"false", len) == 0 && (len == 5)) {
- return TSDB_FALSE;
- } else if (memcmp(pstr, L"null", wcslen(L"null")) == 0) {
- return TSDB_DATA_BOOL_NULL;
- } else {
- return -1;
- }
-}
-
-static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
- const int32_t INITIAL_ALLOC_SIZE = 40;
- char *pBuf = NULL;
-
- // it is a in-place convert type for SVariant, local buffer is needed
- if (*pDest == pVariant->pz) {
- pBuf = taosMemoryCalloc(1, INITIAL_ALLOC_SIZE);
- }
-
- if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
- size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE;
- if (pBuf != NULL) {
- if (newSize >= INITIAL_ALLOC_SIZE) {
- pBuf = taosMemoryRealloc(pBuf, newSize + 1);
- }
-
- taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf);
- taosMemoryFree(pVariant->ucs4);
- pBuf[newSize] = 0;
- } else {
- taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest);
- }
-
- } else {
- if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) {
- sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i);
- } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
- sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->d);
- } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
- sprintf(pBuf == NULL ? *pDest : pBuf, "%s", (pVariant->i == TSDB_TRUE) ? "TRUE" : "FALSE");
- } else if (pVariant->nType == 0) { // null data
- setNull(pBuf == NULL ? *pDest : pBuf, TSDB_DATA_TYPE_BINARY, 0);
- }
- }
-
- if (pBuf != NULL) {
- taosMemoryFree(pVariant->pz);
- *pDest = pBuf;
- }
-
- *pDestSize = (int32_t)strlen(*pDest);
- return 0;
-}
-
-static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
- char tmpBuf[40] = {0};
-
- char *pDst = tmpBuf;
- int32_t nLen = 0;
-
- // convert the number to string, than convert it to wchar string.
- if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) {
- nLen = sprintf(pDst, "%" PRId64, pVariant->i);
- } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
- nLen = sprintf(pDst, "%" PRIu64, pVariant->u);
- } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
- nLen = sprintf(pDst, "%lf", pVariant->d);
- } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- pDst = pVariant->pz;
- nLen = pVariant->nLen;
- } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
- nLen = sprintf(pDst, "%s", (pVariant->i == TSDB_TRUE) ? "TRUE" : "FALSE");
- }
-
- if (*pDest == pVariant->pz) {
- TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
- bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
- if (!ret) {
- taosMemoryFreeClear(pWStr);
- return -1;
- }
-
- // free the binary buffer in the first place
- if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- taosMemoryFree(pVariant->ucs4);
- }
-
- pVariant->ucs4 = pWStr;
- *pDestSize = taosUcs4len(pVariant->ucs4);
-
- // shrink the allocate memory, no need to check here.
- char *tmp = taosMemoryRealloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE);
- assert(tmp != NULL);
-
- pVariant->ucs4 = (TdUcs4 *)tmp;
- } else {
- int32_t output = 0;
-
- bool ret = taosMbsToUcs4(pDst, nLen, (TdUcs4 *)*pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
- if (!ret) {
- return -1;
- }
-
- if (pDestSize != NULL) {
- *pDestSize = output;
- }
- }
-
- return 0;
-}
-
-static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) {
- // SToken stoken = {.z = pStr, .n = len};
- // if (TK_ILLEGAL == tGetNumericStringType(&stoken)) {
- // return -1;
- // }
- //
- // *value = taosStr2Double(pStr, NULL);
- return 0;
-}
-
-static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result, int32_t type, bool issigned,
- bool releaseVariantPtr, bool *converted) {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- setNull((char *)result, type, tDataTypes[type].bytes);
- return 0;
- }
-
- if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) {
- *result = pVariant->i;
- } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
- *result = pVariant->u;
- } else if (IS_FLOAT_TYPE(pVariant->nType)) {
- *result = (int64_t)pVariant->d;
- } else {
- // TODO: handling var types
- }
-#if 0
- errno = 0;
- if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) {
- *result = pVariant->i;
- } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
- *result = pVariant->u;
- } else if (IS_FLOAT_TYPE(pVariant->nType)) {
- *result = (int64_t) pVariant->d;
- } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- SToken token = {.z = pVariant->pz, .n = pVariant->nLen};
- /*int32_t n = */tGetToken(pVariant->pz, &token.type);
-
- if (token.type == TK_NULL) {
- if (releaseVariantPtr) {
- taosMemoryFree(pVariant->pz);
- pVariant->nLen = 0;
- }
-
- setNull((char *)result, type, tDataTypes[type].bytes);
- return 0;
- }
-
- // decide if it is a valid number
- token.type = tGetNumericStringType(&token);
- if (token.type == TK_ILLEGAL) {
- return -1;
- }
-
- int64_t res = 0;
- int32_t t = tStrToInteger(token.z, token.type, token.n, &res, issigned);
- if (t != 0) {
- return -1;
- }
-
- if (releaseVariantPtr) {
- taosMemoryFree(pVariant->pz);
- pVariant->nLen = 0;
- }
-
- *result = res;
- } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
- errno = 0;
- TdUcs4 *endPtr = NULL;
-
- SToken token = {0};
- token.n = tGetToken(pVariant->pz, &token.type);
-
- if (token.type == TK_MINUS || token.type == TK_PLUS) {
- token.n = tGetToken(pVariant->pz + token.n, &token.type);
- }
-
- if (token.type == TK_FLOAT) {
- double v = wcstod(pVariant->ucs4, &endPtr);
- if (releaseVariantPtr) {
- taosMemoryFree(pVariant->pz);
- pVariant->nLen = 0;
- }
-
- if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
- return -1;
- }
-
- *result = (int64_t)v;
- } else if (token.type == TK_NULL) {
- if (releaseVariantPtr) {
- taosMemoryFree(pVariant->pz);
- pVariant->nLen = 0;
- }
- setNull((char *)result, type, tDataTypes[type].bytes);
- return 0;
- } else {
- int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10);
- if (releaseVariantPtr) {
- taosMemoryFree(pVariant->pz);
- pVariant->nLen = 0;
- }
-
- if (errno == ERANGE) {
- return -1; // data overflow
- }
-
- *result = val;
- }
- }
-
- if (converted) {
- *converted = true;
- }
-
- bool code = false;
-
- uint64_t ui = 0;
- switch(type) {
- case TSDB_DATA_TYPE_TINYINT:
- code = IS_VALID_TINYINT(*result); break;
- case TSDB_DATA_TYPE_SMALLINT:
- code = IS_VALID_SMALLINT(*result); break;
- case TSDB_DATA_TYPE_INT:
- code = IS_VALID_INT(*result); break;
- case TSDB_DATA_TYPE_BIGINT:
- code = IS_VALID_BIGINT(*result); break;
- case TSDB_DATA_TYPE_UTINYINT:
- ui = *result;
- code = IS_VALID_UTINYINT(ui); break;
- case TSDB_DATA_TYPE_USMALLINT:
- ui = *result;
- code = IS_VALID_USMALLINT(ui); break;
- case TSDB_DATA_TYPE_UINT:
- ui = *result;
- code = IS_VALID_UINT(ui); break;
- case TSDB_DATA_TYPE_UBIGINT:
- ui = *result;
- code = IS_VALID_UBIGINT(ui); break;
- }
-
-
- return code? 0:-1;
-#endif
- return 0;
-}
-
-static int32_t convertToBool(SVariant *pVariant, int64_t *pDest) {
- if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
- *pDest = pVariant->i; // in order to be compatible to null of bool
- } else if (IS_NUMERIC_TYPE(pVariant->nType)) {
- *pDest = ((pVariant->i != 0) ? TSDB_TRUE : TSDB_FALSE);
- } else if (pVariant->nType == TSDB_DATA_TYPE_FLOAT || pVariant->nType == TSDB_DATA_TYPE_DOUBLE) {
- *pDest = ((pVariant->d != 0) ? TSDB_TRUE : TSDB_FALSE);
- } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- int32_t ret = 0;
- if ((ret = convertToBoolImpl(pVariant->pz, pVariant->nLen)) < 0) {
- return ret;
- }
-
- *pDest = ret;
- } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
- int32_t ret = 0;
- if ((ret = wcsconvertToBoolImpl(pVariant->ucs4, pVariant->nLen)) < 0) {
- return ret;
- }
- *pDest = ret;
- } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *pDest = TSDB_DATA_BOOL_NULL;
- }
-
- assert(*pDest == TSDB_TRUE || *pDest == TSDB_FALSE || *pDest == TSDB_DATA_BOOL_NULL);
- return 0;
-}
-
-/*
- * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType
- * to column type defined in schema
- */
-int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted,
- char *extInfo) {
- if (converted) {
- *converted = false;
- }
-
- if (pVariant == NULL || (pVariant->nType != 0 && !isValidDataType(pVariant->nType))) {
- return -1;
- }
-
- errno = 0; // reset global error code
- int64_t result = 0;
-
- switch (type) {
- case TSDB_DATA_TYPE_BOOL: {
- if (convertToBool(pVariant, &result) < 0) {
- return -1;
- }
-
- *(int8_t *)payload = (int8_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_TINYINT: {
- if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
- SET_EXT_INFO(converted, result, INT8_MIN + 1, INT8_MAX, extInfo);
- return -1;
- }
- *((int8_t *)payload) = (int8_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_UTINYINT: {
- if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
- SET_EXT_INFO(converted, result, 0, UINT8_MAX - 1, extInfo);
- return -1;
- }
- *((uint8_t *)payload) = (uint8_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_SMALLINT: {
- if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
- SET_EXT_INFO(converted, result, INT16_MIN + 1, INT16_MAX, extInfo);
- return -1;
- }
- *((int16_t *)payload) = (int16_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_USMALLINT: {
- if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
- SET_EXT_INFO(converted, result, 0, UINT16_MAX - 1, extInfo);
- return -1;
- }
- *((uint16_t *)payload) = (uint16_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_INT: {
- if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
- SET_EXT_INFO(converted, result, INT32_MIN + 1, INT32_MAX, extInfo);
- return -1;
- }
- *((int32_t *)payload) = (int32_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_UINT: {
- if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
- SET_EXT_INFO(converted, result, 0, UINT32_MAX - 1, extInfo);
- return -1;
- }
- *((uint32_t *)payload) = (uint32_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_BIGINT: {
- if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
- SET_EXT_INFO(converted, result, INT64_MIN + 1, INT64_MAX, extInfo);
- return -1;
- }
- *((int64_t *)payload) = (int64_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_UBIGINT: {
- if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
- SET_EXT_INFO(converted, result, 0, UINT64_MAX - 1, extInfo);
- return -1;
- }
- *((uint64_t *)payload) = (uint64_t)result;
- break;
- }
-
- case TSDB_DATA_TYPE_FLOAT: {
- if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- if (strncasecmp(TSDB_DATA_NULL_STR_L, pVariant->pz, pVariant->nLen) == 0 &&
- strlen(TSDB_DATA_NULL_STR_L) == pVariant->nLen) {
- *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL;
- return 0;
- } else {
- double value = -1;
- int32_t ret = convertToDouble(pVariant->pz, pVariant->nLen, &value);
- if ((errno == ERANGE && (float)value == -1) || (ret != 0)) {
- return -1;
- }
-
- if (converted) {
- *converted = true;
- }
-
- if (value > FLT_MAX || value < -FLT_MAX) {
- SET_EXT_INFO(converted, value, -FLT_MAX, FLT_MAX, extInfo);
- return -1;
- }
- SET_FLOAT_VAL(payload, value);
- }
- } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) ||
- IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
- if (converted) {
- *converted = true;
- }
-
- if (pVariant->i > FLT_MAX || pVariant->i < -FLT_MAX) {
- SET_EXT_INFO(converted, pVariant->i, -FLT_MAX, FLT_MAX, extInfo);
- return -1;
- }
-
- SET_FLOAT_VAL(payload, pVariant->i);
- } else if (IS_FLOAT_TYPE(pVariant->nType)) {
- if (converted) {
- *converted = true;
- }
-
- if (pVariant->d > FLT_MAX || pVariant->d < -FLT_MAX) {
- SET_EXT_INFO(converted, pVariant->d, -FLT_MAX, FLT_MAX, extInfo);
- return -1;
- }
-
- SET_FLOAT_VAL(payload, pVariant->d);
- } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *((uint32_t *)payload) = TSDB_DATA_FLOAT_NULL;
- return 0;
- }
-
- float fv = GET_FLOAT_VAL(payload);
- if (isinf(fv) || isnan(fv) || fv > FLT_MAX || fv < -FLT_MAX) {
- return -1;
- }
- break;
- }
- case TSDB_DATA_TYPE_DOUBLE: {
- if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- if (strncasecmp(TSDB_DATA_NULL_STR_L, pVariant->pz, pVariant->nLen) == 0 &&
- strlen(TSDB_DATA_NULL_STR_L) == pVariant->nLen) {
- *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL;
- return 0;
- } else {
- double value = 0;
- int32_t ret;
- ret = convertToDouble(pVariant->pz, pVariant->nLen, &value);
- if ((errno == ERANGE && value == -1) || (ret != 0)) {
- return -1;
- }
-
- SET_DOUBLE_VAL(payload, value);
- }
- } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) ||
- IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
- SET_DOUBLE_VAL(payload, pVariant->i);
- } else if (IS_FLOAT_TYPE(pVariant->nType)) {
- SET_DOUBLE_VAL(payload, pVariant->d);
- } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL;
- return 0;
- }
-
- double dv = GET_DOUBLE_VAL(payload);
- if (errno == ERANGE || isinf(dv) || isnan(dv)) {
- return -1;
- }
-
- break;
- }
-
- case TSDB_DATA_TYPE_BINARY: {
- if (!includeLengthPrefix) {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *(uint8_t *)payload = TSDB_DATA_BINARY_NULL;
- } else {
- if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
- toBinary(pVariant, &payload, &pVariant->nLen);
- } else {
- strncpy(payload, pVariant->pz, pVariant->nLen);
- }
- }
- } else {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- setVardataNull(payload, TSDB_DATA_TYPE_BINARY);
- } else {
- char *p = varDataVal(payload);
-
- if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
- toBinary(pVariant, &p, &pVariant->nLen);
- } else {
- strncpy(p, pVariant->pz, pVariant->nLen);
- }
-
- varDataSetLen(payload, pVariant->nLen);
- assert(p == varDataVal(payload));
- }
- }
- break;
- }
- case TSDB_DATA_TYPE_TIMESTAMP: {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL;
- } else {
- *((int64_t *)payload) = pVariant->i;
- }
- break;
- }
- case TSDB_DATA_TYPE_NCHAR: {
- int32_t newlen = 0;
- if (!includeLengthPrefix) {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- *(uint32_t *)payload = TSDB_DATA_NCHAR_NULL;
- } else {
- if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
- if (toNchar(pVariant, &payload, &newlen) != 0) {
- return -1;
- }
- } else {
- tasoUcs4Copy((TdUcs4 *)payload, pVariant->ucs4, pVariant->nLen);
- }
- }
- } else {
- if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
- setVardataNull(payload, TSDB_DATA_TYPE_NCHAR);
- } else {
- char *p = varDataVal(payload);
-
- if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
- if (toNchar(pVariant, &p, &newlen) != 0) {
- return -1;
- }
- } else {
- memcpy(p, pVariant->ucs4, pVariant->nLen);
- newlen = pVariant->nLen;
- }
-
- varDataSetLen(payload, newlen); // the length may be changed after toNchar function called
- assert(p == varDataVal(payload));
- }
- }
-
- break;
- }
- }
-
- return 0;
-}
-
-/*
- * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType
- * to column type defined in schema
- */
-int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) {
- return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL);
-}
-
-/*
- * In variant, bool/smallint/tinyint/int/bigint share the same attribution of
- * structure, also ignore the convert the type required
- *
- * It is actually the bigint/binary/bool/nchar type transfer
- */
-int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
- if (pVariant == NULL || pVariant->nType == 0) { // value is not set
- return 0;
- }
-
- switch (type) {
- case TSDB_DATA_TYPE_BOOL: { // bool
- if (convertToBool(pVariant, &pVariant->i) < 0) {
- return -1;
- }
-
- pVariant->nType = type;
- break;
- }
- case TSDB_DATA_TYPE_INT:
- case TSDB_DATA_TYPE_BIGINT:
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_SMALLINT: {
- convertToInteger(pVariant, &(pVariant->i), type, true, true, NULL);
- pVariant->nType = TSDB_DATA_TYPE_BIGINT;
- break;
- }
- case TSDB_DATA_TYPE_FLOAT:
- case TSDB_DATA_TYPE_DOUBLE: {
- if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
- errno = 0;
- double v = taosStr2Double(pVariant->pz, NULL);
- if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
- taosMemoryFree(pVariant->pz);
- return -1;
- }
-
- taosMemoryFree(pVariant->pz);
- pVariant->d = v;
- } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
- errno = 0;
- double v = wcstod(pVariant->ucs4, NULL);
- if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
- taosMemoryFree(pVariant->pz);
- return -1;
- }
-
- taosMemoryFree(pVariant->pz);
- pVariant->d = v;
- } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
- double tmp = (double)pVariant->i;
- pVariant->d = tmp;
- }
-
- pVariant->nType = TSDB_DATA_TYPE_DOUBLE;
- break;
- }
- case TSDB_DATA_TYPE_BINARY: {
- if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
- toBinary(pVariant, &pVariant->pz, &pVariant->nLen);
- }
- pVariant->nType = type;
- break;
- }
- case TSDB_DATA_TYPE_NCHAR: {
- if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
- if (toNchar(pVariant, &pVariant->pz, &pVariant->nLen) != 0) {
- return -1;
- }
- }
- pVariant->nType = type;
- break;
- }
- }
-
- return 0;
-}
-
char *taosVariantGet(SVariant *pVar, int32_t type) {
switch (type) {
case TSDB_DATA_TYPE_BOOL:
diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c
index acc3fc5658..188677656a 100644
--- a/source/dnode/mgmt/exe/dmMain.c
+++ b/source/dnode/mgmt/exe/dmMain.c
@@ -25,7 +25,6 @@
#define DM_SDB_INFO "Dump sdb info."
#define DM_ENV_CMD "The env cmd variable string to use when configuring the server, such as: -e 'TAOS_FQDN=td1'."
#define DM_ENV_FILE "The env variable file path to use when configuring the server, default is './.env', .env text can be 'TAOS_FQDN=td1'."
-#define DM_NODE_TYPE "Startup type of the node, default is 0."
#define DM_MACHINE_CODE "Get machine code."
#define DM_VERSION "Print program version."
#define DM_EMAIL ""
@@ -44,7 +43,6 @@ static struct {
char apolloUrl[PATH_MAX];
const char **envCmd;
SArray *pArgs; // SConfigPair
- EDndNodeType ntype;
} global = {0};
static void dmStopDnode(int signum, void *info, void *ctx) { dmStop(); }
@@ -59,13 +57,6 @@ static void dmSetSignalHandle() {
taosSetSignal(SIGTSTP, dmStopDnode);
taosSetSignal(SIGQUIT, dmStopDnode);
#endif
-
- if (!tsMultiProcess) {
- } else if (global.ntype == DNODE || global.ntype == NODE_END) {
- taosIgnSignal(SIGCHLD);
- } else {
- taosKillChildOnParentStopped();
- }
}
static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
@@ -91,12 +82,6 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global.dumpSdb = true;
} else if (strcmp(argv[i], "-E") == 0) {
tstrncpy(global.envFile, argv[++i], PATH_MAX);
- } else if (strcmp(argv[i], "-n") == 0) {
- global.ntype = atoi(argv[++i]);
- if (global.ntype <= DNODE || global.ntype > NODE_END) {
- printf("'-n' range is [1 - %d], default is 0\n", NODE_END - 1);
- return -1;
- }
} else if (strcmp(argv[i], "-k") == 0) {
global.generateGrant = true;
} else if (strcmp(argv[i], "-C") == 0) {
@@ -142,7 +127,6 @@ static void dmPrintHelp() {
printf("%s%s%s%s\n", indent, "-C,", indent, DM_DMP_CFG);
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
- printf("%s%s%s%s\n", indent, "-n,", indent, DM_NODE_TYPE);
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
@@ -155,17 +139,7 @@ static void dmDumpCfg() {
}
static int32_t dmInitLog() {
- char logName[12] = {0};
- snprintf(logName, sizeof(logName), "%slog", dmNodeLogName(global.ntype));
- return taosCreateLog(logName, 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0);
-}
-
-static void dmSetProcInfo(int32_t argc, char **argv) {
- taosSetProcPath(argc, argv);
- if (global.ntype != DNODE && global.ntype != NODE_END) {
- const char *name = dmNodeProcName(global.ntype);
- taosSetProcName(argc, argv, name);
- }
+ return taosCreateLog("taosdlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0);
}
static void taosCleanupArgs() {
@@ -234,6 +208,7 @@ int mainWindows(int argc, char **argv) {
taosCleanupCfg();
taosCloseLog();
taosCleanupArgs();
+ taosConvDestroy();
return 0;
}
@@ -242,13 +217,14 @@ int mainWindows(int argc, char **argv) {
taosCleanupCfg();
taosCloseLog();
taosCleanupArgs();
+ taosConvDestroy();
return 0;
}
- dmSetProcInfo(argc, (char **)argv);
+ osSetProcPath(argc, (char **)argv);
taosCleanupArgs();
- if (dmInit(global.ntype) != 0) {
+ if (dmInit() != 0) {
dError("failed to init dnode since %s", terrstr());
return -1;
}
diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
index 17cbde437b..6d06535447 100644
--- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
@@ -34,7 +34,6 @@ typedef struct SMnodeMgmt {
SSingleWorker readWorker;
SSingleWorker writeWorker;
SSingleWorker syncWorker;
- SSingleWorker monitorWorker;
bool stopped;
int32_t refCount;
TdThreadRwlock lock;
@@ -48,8 +47,6 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption);
SArray *mmGetMsgHandles();
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
-int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
// mmWorker.c
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
@@ -59,7 +56,6 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
#ifdef __cplusplus
diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
index 105b6e542e..7fb700e776 100644
--- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
@@ -20,58 +20,11 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->stb, &pInfo->grant);
}
-int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonMmInfo mmInfo = {0};
- mmGetMonitorInfo(pMgmt, &mmInfo);
- dmGetMonitorSystemInfo(&mmInfo.sys);
- monGetLogs(&mmInfo.log);
-
- int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonMmInfo(pRsp, rspLen, &mmInfo);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- tFreeSMonMmInfo(&mmInfo);
- return 0;
-}
-
void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
pInfo->isMnode = 1;
mndGetLoad(pMgmt->pMnode, &pInfo->load);
}
-int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonMloadInfo mloads = {0};
- mmGetMnodeLoads(pMgmt, &mloads);
-
- int32_t rspLen = tSerializeSMonMloadInfo(NULL, 0, &mloads);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonMloadInfo(pRsp, rspLen, &mloads);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- return 0;
-}
-
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
const STraceId *trace = &pMsg->info.traceId;
SDCreateMnodeReq createReq = {0};
@@ -230,9 +183,6 @@ SArray *mmGetMsgHandles() {
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
-
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
index 849d3ef390..16e6f67409 100644
--- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
@@ -46,22 +46,12 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
SMnodeMgmt *pMgmt = pInfo->ahandle;
- int32_t code = -1;
+ pMsg->info.node = pMgmt->pMnode;
const STraceId *trace = &pMsg->info.traceId;
dGTrace("msg:%p, get from mnode queue", pMsg);
- switch (pMsg->msgType) {
- case TDMT_MON_MM_INFO:
- code = mmProcessGetMonitorInfoReq(pMgmt, pMsg);
- break;
- case TDMT_MON_MM_LOAD:
- code = mmProcessGetLoadsReq(pMgmt, pMsg);
- break;
- default:
- pMsg->info.node = pMgmt->pMnode;
- code = mndProcessRpcMsg(pMsg);
- }
+ int32_t code = mndProcessRpcMsg(pMsg);
if (IsReq(pMsg) && pMsg->info.handle != NULL && code != TSDB_CODE_ACTION_IN_PROGRESS) {
if (code != 0 && terrno != 0) code = terrno;
@@ -136,10 +126,6 @@ int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return mmPutMsgToWorker(pMgmt, &pMgmt->fetchWorker, pMsg);
}
-int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- return mmPutMsgToWorker(pMgmt, &pMgmt->monitorWorker, pMsg);
-}
-
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
SSingleWorker *pWorker = NULL;
switch (qtype) {
@@ -237,18 +223,6 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
return -1;
}
- SSingleWorkerCfg mCfg = {
- .min = 1,
- .max = 1,
- .name = "mnode-monitor",
- .fp = (FItem)mmProcessRpcMsg,
- .param = pMgmt,
- };
- if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
- dError("failed to start mnode mnode-monitor worker since %s", terrstr());
- return -1;
- }
-
dDebug("mnode workers are initialized");
return 0;
}
@@ -256,7 +230,6 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
void mmStopWorker(SMnodeMgmt *pMgmt) {
while (pMgmt->refCount > 0) taosMsleep(10);
- tSingleWorkerCleanup(&pMgmt->monitorWorker);
tSingleWorkerCleanup(&pMgmt->queryWorker);
tSingleWorkerCleanup(&pMgmt->fetchWorker);
tSingleWorkerCleanup(&pMgmt->readWorker);
diff --git a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
index 56bf56f25e..c6c239bdcc 100644
--- a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
+++ b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
@@ -32,14 +32,12 @@ typedef struct SQnodeMgmt {
const char *name;
SSingleWorker queryWorker;
SSingleWorker fetchWorker;
- SSingleWorker monitorWorker;
} SQnodeMgmt;
// qmHandle.c
SArray *qmGetMsgHandles();
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
-int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
// qmWorker.c
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pMsg);
@@ -49,7 +47,6 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt);
void qmStopWorker(SQnodeMgmt *pMgmt);
int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg);
diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
index 0573be90ea..5017ad7b74 100644
--- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
+++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c
@@ -29,31 +29,6 @@ void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) {
pInfo->dnodeId = pMgmt->pData->dnodeId;
}
-int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonQmInfo qmInfo = {0};
- qmGetMonitorInfo(pMgmt, &qmInfo);
- dmGetMonitorSystemInfo(&qmInfo.sys);
- monGetLogs(&qmInfo.log);
-
- int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonQmInfo(pRsp, rspLen, &qmInfo);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- tFreeSMonQmInfo(&qmInfo);
- return 0;
-}
-
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
SDCreateQnodeReq createReq = {0};
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
@@ -103,8 +78,6 @@ SArray *qmGetMsgHandles() {
SArray *pArray = taosArrayInit(16, sizeof(SMgmtHandle));
if (pArray == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_QM_INFO, qmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
-
// Requests handled by VNODE
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
index 66386b0ee0..edbe9882a4 100644
--- a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
+++ b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
@@ -28,18 +28,9 @@ static inline void qmSendRsp(SRpcMsg *pMsg, int32_t code) {
static void qmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
SQnodeMgmt *pMgmt = pInfo->ahandle;
- int32_t code = -1;
dTrace("msg:%p, get from qnode queue", pMsg);
- switch (pMsg->msgType) {
- case TDMT_MON_QM_INFO:
- code = qmProcessGetMonitorInfoReq(pMgmt, pMsg);
- break;
- default:
- code = qndProcessQueryMsg(pMgmt->pQnode, pInfo->timestamp, pMsg);
- break;
- }
-
+ int32_t code = qndProcessQueryMsg(pMgmt->pQnode, pInfo->timestamp, pMsg);
if (IsReq(pMsg) && code != TSDB_CODE_ACTION_IN_PROGRESS) {
if (code != 0 && terrno != 0) code = terrno;
qmSendRsp(pMsg, code);
@@ -66,10 +57,6 @@ int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return qmPutNodeMsgToWorker(&pMgmt->fetchWorker, pMsg);
}
-int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- return qmPutNodeMsgToWorker(&pMgmt->monitorWorker, pMsg);
-}
-
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
if (pMsg == NULL) return -1;
@@ -136,24 +123,11 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
return -1;
}
- SSingleWorkerCfg mCfg = {
- .min = 1,
- .max = 1,
- .name = "qnode-monitor",
- .fp = (FItem)qmProcessQueue,
- .param = pMgmt,
- };
- if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
- dError("failed to start qnode-monitor worker since %s", terrstr());
- return -1;
- }
-
dDebug("qnode workers are initialized");
return 0;
}
void qmStopWorker(SQnodeMgmt *pMgmt) {
- tSingleWorkerCleanup(&pMgmt->monitorWorker);
tSingleWorkerCleanup(&pMgmt->queryWorker);
tSingleWorkerCleanup(&pMgmt->fetchWorker);
dDebug("qnode workers are closed");
diff --git a/source/dnode/mgmt/mgmt_snode/inc/smInt.h b/source/dnode/mgmt/mgmt_snode/inc/smInt.h
index fbf63dda43..4efe1c997b 100644
--- a/source/dnode/mgmt/mgmt_snode/inc/smInt.h
+++ b/source/dnode/mgmt/mgmt_snode/inc/smInt.h
@@ -33,14 +33,12 @@ typedef struct SSnodeMgmt {
int8_t uniqueWorkerInUse;
SArray *uniqueWorkers; // SArray
SSingleWorker sharedWorker;
- SSingleWorker monitorWorker;
} SSnodeMgmt;
// smHandle.c
SArray *smGetMsgHandles();
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
-int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
// smWorker.c
int32_t smStartWorker(SSnodeMgmt *pMgmt);
@@ -49,7 +47,6 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t smPutNodeMsgToSharedQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t smPutNodeMsgToExecQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t smPutNodeMsgToMonitorQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
#ifdef __cplusplus
}
diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c
index c6e3b3611f..65c96767ab 100644
--- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c
+++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c
@@ -18,31 +18,6 @@
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
-int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonSmInfo smInfo = {0};
- smGetMonitorInfo(pMgmt, &smInfo);
- dmGetMonitorSystemInfo(&smInfo.sys);
- monGetLogs(&smInfo.log);
-
- int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonSmInfo(pRsp, rspLen, &smInfo);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- tFreeSMonSmInfo(&smInfo);
- return 0;
-}
-
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
SDCreateSnodeReq createReq = {0};
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
@@ -92,8 +67,6 @@ SArray *smGetMsgHandles() {
SArray *pArray = taosArrayInit(4, sizeof(SMgmtHandle));
if (pArray == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_SM_INFO, smPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
-
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c
index 19c1b9b5c7..ad56d57f69 100644
--- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c
+++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c
@@ -26,27 +26,6 @@ static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) {
tmsgSendRsp(&rsp);
}
-static void smProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
- SSnodeMgmt *pMgmt = pInfo->ahandle;
- int32_t code = -1;
- dTrace("msg:%p, get from snode-monitor queue", pMsg);
-
- if (pMsg->msgType == TDMT_MON_SM_INFO) {
- code = smProcessGetMonitorInfoReq(pMgmt, pMsg);
- } else {
- terrno = TSDB_CODE_MSG_NOT_PROCESSED;
- }
-
- if (IsReq(pMsg)) {
- if (code != 0 && terrno != 0) code = terrno;
- smSendRsp(pMsg, code);
- }
-
- dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
- rpcFreeCont(pMsg->pCont);
- taosFreeQitem(pMsg);
-}
-
static void smProcessUniqueQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
SSnodeMgmt *pMgmt = pInfo->ahandle;
@@ -123,24 +102,11 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
return -1;
}
- SSingleWorkerCfg mCfg = {
- .min = 1,
- .max = 1,
- .name = "snode-monitor",
- .fp = (FItem)smProcessMonitorQueue,
- .param = pMgmt,
- };
- if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
- dError("failed to start snode-monitor worker since %s", terrstr());
- return -1;
- }
-
dDebug("snode workers are initialized");
return 0;
}
void smStopWorker(SSnodeMgmt *pMgmt) {
- tSingleWorkerCleanup(&pMgmt->monitorWorker);
for (int32_t i = 0; i < taosArrayGetSize(pMgmt->uniqueWorkers); i++) {
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, i);
tMultiWorkerCleanup(pWorker);
@@ -175,14 +141,6 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return 0;
}
-int32_t smPutNodeMsgToMonitorQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SSingleWorker *pWorker = &pMgmt->monitorWorker;
-
- dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
- taosWriteQitem(pWorker->queue, pMsg);
- return 0;
-}
-
int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t index = smGetSWIdFromMsg(pMsg);
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index);
diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
index 32649464c1..1bd68e6d41 100644
--- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
@@ -38,7 +38,6 @@ typedef struct SVnodeMgmt {
SWWorkerPool writePool;
SWWorkerPool applyPool;
SSingleWorker mgmtWorker;
- SSingleWorker monitorWorker;
SHashObj *hash;
TdThreadRwlock lock;
SVnodesStat state;
@@ -89,8 +88,6 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
SArray *vmGetMsgHandles();
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
// vmFile.c
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
@@ -114,7 +111,6 @@ int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
#ifdef __cplusplus
}
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
index fe9f114084..c92b6c4c4d 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
@@ -83,54 +83,6 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
taosArrayDestroy(pVloads);
}
-int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonVmInfo vmInfo = {0};
- vmGetMonitorInfo(pMgmt, &vmInfo);
- dmGetMonitorSystemInfo(&vmInfo.sys);
- monGetLogs(&vmInfo.log);
-
- int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonVmInfo(pRsp, rspLen, &vmInfo);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- tFreeSMonVmInfo(&vmInfo);
- return 0;
-}
-
-int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- SMonVloadInfo vloads = {0};
- vmGetVnodeLoads(pMgmt, &vloads, false);
-
- int32_t rspLen = tSerializeSMonVloadInfo(NULL, 0, &vloads);
- if (rspLen < 0) {
- terrno = TSDB_CODE_INVALID_MSG;
- return -1;
- }
-
- void *pRsp = rpcMallocCont(rspLen);
- if (pRsp == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- tSerializeSMonVloadInfo(pRsp, rspLen, &vloads);
- pMsg->info.rsp = pRsp;
- pMsg->info.rspLen = rspLen;
- tFreeSMonVloadInfo(&vloads);
- return 0;
-}
-
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
memcpy(pCfg, &vnodeCfgDefault, sizeof(SVnodeCfg));
@@ -348,9 +300,6 @@ SArray *vmGetMsgHandles() {
SArray *pArray = taosArrayInit(32, sizeof(SMgmtHandle));
if (pArray == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_VM_INFO, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_MON_VM_LOAD, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
-
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
index e08f5963cd..fd1dbe00ce 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
@@ -34,12 +34,6 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
dGTrace("msg:%p, get from vnode-mgmt queue", pMsg);
switch (pMsg->msgType) {
- case TDMT_MON_VM_INFO:
- code = vmProcessGetMonitorInfoReq(pMgmt, pMsg);
- break;
- case TDMT_MON_VM_LOAD:
- code = vmProcessGetLoadsReq(pMgmt, pMsg);
- break;
case TDMT_DND_CREATE_VNODE:
code = vmProcessCreateVnodeReq(pMgmt, pMsg);
break;
@@ -258,13 +252,6 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return 0;
}
-int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
- const STraceId *trace = &pMsg->info.traceId;
- dGTrace("msg:%p, put into vnode-monitor queue", pMsg);
- taosWriteQitem(pMgmt->monitorWorker.queue, pMsg);
- return 0;
-}
-
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
if (pMsg == NULL) {
@@ -410,21 +397,11 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
};
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &mgmtCfg) != 0) return -1;
- SSingleWorkerCfg monitorCfg = {
- .min = 1,
- .max = 1,
- .name = "vnode-monitor",
- .fp = (FItem)vmProcessMgmtQueue,
- .param = pMgmt,
- };
- if (tSingleWorkerInit(&pMgmt->monitorWorker, &monitorCfg) != 0) return -1;
-
dDebug("vnode workers are initialized");
return 0;
}
void vmStopWorker(SVnodeMgmt *pMgmt) {
- tSingleWorkerCleanup(&pMgmt->monitorWorker);
tSingleWorkerCleanup(&pMgmt->mgmtWorker);
tWWorkerCleanup(&pMgmt->writePool);
tWWorkerCleanup(&pMgmt->applyPool);
diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
index adde055796..7e85e6b722 100644
--- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
+++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
@@ -25,44 +25,6 @@
extern "C" {
#endif
-typedef struct SMgmtWrapper SMgmtWrapper;
-
-#define SINGLE_PROC 0
-#define CHILD_PROC 1
-#define PARENT_PROC 2
-#define TEST_PROC 3
-#define OnlyInSingleProc(wrapper) ((wrapper)->proc.ptype == SINGLE_PROC)
-#define OnlyInChildProc(wrapper) ((wrapper)->proc.ptype == CHILD_PROC)
-#define OnlyInParentProc(wrapper) ((wrapper)->proc.ptype == PARENT_PROC)
-#define InChildProc(wrapper) ((wrapper)->proc.ptype & CHILD_PROC)
-#define InParentProc(wrapper) ((wrapper)->proc.ptype & PARENT_PROC)
-
-typedef struct {
- int32_t head;
- int32_t tail;
- int32_t total;
- int32_t avail;
- int32_t items;
- char name[8];
- TdThreadMutex mutex;
- tsem_t sem;
- char pBuffer[];
-} SProcQueue;
-
-typedef struct {
- SMgmtWrapper *wrapper;
- const char *name;
- SHashObj *hash;
- SProcQueue *pqueue;
- SProcQueue *cqueue;
- TdThread pthread;
- TdThread cthread;
- SShm shm;
- int32_t pid;
- EDndProcType ptype;
- bool stop;
-} SProc;
-
typedef struct SMgmtWrapper {
SMgmtFunc func;
struct SDnode *pDnode;
@@ -74,7 +36,6 @@ typedef struct SMgmtWrapper {
EDndNodeType ntype;
bool deployed;
bool required;
- SProc proc;
NodeMsgFp msgFps[TDMT_MAX];
} SMgmtWrapper;
@@ -111,8 +72,6 @@ typedef struct SUdfdData {
typedef struct SDnode {
int8_t once;
bool stop;
- EDndProcType ptype;
- EDndNodeType rtype;
EDndRunStatus status;
SStartupInfo startup;
SDnodeTrans trans;
@@ -128,7 +87,7 @@ SDnode *dmInstance();
void dmReportStartup(const char *pName, const char *pDesc);
// dmMgmt.c
-int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype);
+int32_t dmInitDnode(SDnode *pDnode);
void dmCleanupDnode(SDnode *pDnode);
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
@@ -145,16 +104,6 @@ void dmStopNode(SMgmtWrapper *pWrapper);
void dmCloseNode(SMgmtWrapper *pWrapper);
int32_t dmRunDnode(SDnode *pDnode);
-// dmProc.c
-int32_t dmInitProc(struct SMgmtWrapper *pWrapper);
-void dmCleanupProc(struct SMgmtWrapper *pWrapper);
-int32_t dmRunProc(SProc *proc);
-void dmStopProc(SProc *proc);
-void dmRemoveProcRpcHandle(SProc *proc, void *handle);
-void dmCloseProcRpcHandles(SProc *proc);
-int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
-void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
-
// dmTransport.c
int32_t dmInitServer(SDnode *pDnode);
void dmCleanupServer(SDnode *pDnode);
diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c
index 5a7f149bc6..a222ad3f7d 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c
@@ -53,13 +53,19 @@ static bool dmCheckDiskSpace() {
osUpdate();
// sufficiency
if (!osDataSpaceSufficient()) {
- dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
+ dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least",
+ (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
+ (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
}
if (!osLogSpaceSufficient()) {
- dWarn("free log disk size: %f GB, not sufficient, expected %f GB at least", (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
+ dWarn("free log disk size: %f GB, not sufficient, expected %f GB at least",
+ (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
+ (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
}
if (!osTempSpaceSufficient()) {
- dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
+ dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least",
+ (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
+ (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
}
// availability
bool ret = true;
@@ -82,7 +88,7 @@ static bool dmCheckDiskSpace() {
}
static bool dmCheckDataDirVersion() {
- char checkDataDirJsonFileName[PATH_MAX];
+ char checkDataDirJsonFileName[PATH_MAX] = {0};
snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir);
if (taosCheckExistFile(checkDataDirJsonFileName)) {
dError("The default data directory %s contains old data of tdengine 2.x, please clear it before running!",
@@ -92,14 +98,14 @@ static bool dmCheckDataDirVersion() {
return true;
}
-int32_t dmInit(int8_t rtype) {
+int32_t dmInit() {
dInfo("start to init dnode env");
if (!dmCheckDataDirVersion()) return -1;
if (!dmCheckDiskSpace()) return -1;
if (dmCheckRepeatInit(dmInstance()) != 0) return -1;
if (dmInitSystem() != 0) return -1;
if (dmInitMonitor() != 0) return -1;
- if (dmInitDnode(dmInstance(), rtype) != 0) return -1;
+ if (dmInitDnode(dmInstance()) != 0) return -1;
dInfo("dnode env is initialized");
return 0;
@@ -126,8 +132,8 @@ void dmCleanup() {
taosStopCacheRefreshWorker();
dInfo("dnode env is cleaned up");
- taosCloseLog();
taosCleanupCfg();
+ taosCloseLog();
}
void dmStop() {
@@ -174,7 +180,6 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
}
pWrapper->deployed = true;
pWrapper->required = true;
- pWrapper->proc.ptype = pDnode->ptype;
}
taosThreadMutexUnlock(&pDnode->mutex);
diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c
index 75c76a1f54..2c9020b668 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c
@@ -26,47 +26,14 @@ static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) {
int32_t code = (*pWrapper->func.requiredFp)(&input, &required);
if (!required) {
dDebug("node:%s, does not require startup", pWrapper->name);
- }
-
- if (pWrapper->ntype == DNODE) {
- if (pDnode->rtype != DNODE && pDnode->rtype != NODE_END) {
- required = false;
- dDebug("node:%s, does not require startup in child process", pWrapper->name);
- }
} else {
- if (OnlyInChildProc(pWrapper)) {
- if (pWrapper->ntype != pDnode->rtype) {
- dDebug("node:%s, does not require startup in child process", pWrapper->name);
- required = false;
- }
- }
- }
-
- if (required) {
dDebug("node:%s, required to startup", pWrapper->name);
}
return required;
}
-static int32_t dmInitVars(SDnode *pDnode, EDndNodeType rtype) {
- pDnode->rtype = rtype;
-
- if (tsMultiProcess == 0) {
- pDnode->ptype = DND_PROC_SINGLE;
- dInfo("dnode will run in single-process mode");
- } else if (tsMultiProcess > 1) {
- pDnode->ptype = DND_PROC_TEST;
- dInfo("dnode will run in multi-process test mode");
- } else if (pDnode->rtype == DNODE || pDnode->rtype == NODE_END) {
- pDnode->ptype = DND_PROC_PARENT;
- dInfo("dnode will run in parent-process mode");
- } else {
- pDnode->ptype = DND_PROC_CHILD;
- SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->rtype];
- dInfo("dnode will run in child-process mode, node:%s", dmNodeName(pDnode->rtype));
- }
-
+static int32_t dmInitVars(SDnode *pDnode) {
SDnodeData *pData = &pDnode->data;
pData->dnodeId = 0;
pData->clusterId = 0;
@@ -127,12 +94,12 @@ static void dmClearVars(SDnode *pDnode) {
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
}
-int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
+int32_t dmInitDnode(SDnode *pDnode) {
dDebug("start to create dnode");
int32_t code = -1;
char path[PATH_MAX + 100] = {0};
- if (dmInitVars(pDnode, rtype) != 0) {
+ if (dmInitVars(pDnode) != 0) {
goto _OVER;
}
@@ -147,13 +114,6 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
pWrapper->pDnode = pDnode;
pWrapper->name = dmNodeName(ntype);
pWrapper->ntype = ntype;
- pWrapper->proc.wrapper = pWrapper;
- pWrapper->proc.shm.id = -1;
- pWrapper->proc.pid = -1;
- pWrapper->proc.ptype = pDnode->ptype;
- if (ntype == DNODE) {
- pWrapper->proc.ptype = DND_PROC_SINGLE;
- }
taosThreadRwlockInit(&pWrapper->lock, NULL);
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
@@ -164,11 +124,6 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
}
pWrapper->required = dmRequireNode(pDnode, pWrapper);
-
- if (ntype != DNODE && dmReadShmFile(pWrapper->path, pWrapper->name, pDnode->rtype, &pWrapper->proc.shm) != 0) {
- dError("node:%s, failed to read shm file since %s", pWrapper->name, terrstr());
- goto _OVER;
- }
}
if (dmInitMsgHandle(pDnode) != 0) {
@@ -176,16 +131,14 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
goto _OVER;
}
- if (pDnode->ptype == SINGLE_PROC || (pDnode->ptype & PARENT_PROC)) {
- pDnode->lockfile = dmCheckRunning(tsDataDir);
- if (pDnode->lockfile == NULL) {
- goto _OVER;
- }
+ pDnode->lockfile = dmCheckRunning(tsDataDir);
+ if (pDnode->lockfile == NULL) {
+ goto _OVER;
+ }
- if (dmInitServer(pDnode) != 0) {
- dError("failed to init transport since %s", terrstr());
- goto _OVER;
- }
+ if (dmInitServer(pDnode) != 0) {
+ dError("failed to init transport since %s", terrstr());
+ goto _OVER;
}
if (dmInitClient(pDnode) != 0) {
@@ -248,7 +201,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
int32_t code = 0;
taosThreadRwlockRdlock(&pWrapper->lock);
- if (pWrapper->deployed || (InParentProc(pWrapper) && pWrapper->required)) {
+ if (pWrapper->deployed) {
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
// dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
} else {
diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c
index be1de02e6a..4ab56ed682 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c
@@ -17,18 +17,6 @@
#include "dmMgmt.h"
#include "dmNodes.h"
-#define dmSendLocalRecv(pDnode, mtype, func, pInfo) \
- SRpcMsg rsp = {0}; \
- SRpcMsg req = {.msgType = mtype}; \
- SEpSet epset = {.inUse = 0, .numOfEps = 1}; \
- tstrncpy(epset.eps[0].fqdn, tsLocalFqdn, TSDB_FQDN_LEN); \
- epset.eps[0].port = tsServerPort; \
- rpcSendRecv(pDnode->trans.clientRpc, &epset, &req, &rsp); \
- if (rsp.code == 0 && rsp.contLen > 0) { \
- func(rsp.pCont, rsp.contLen, pInfo); \
- } \
- rpcFreeCont(rsp.pCont);
-
static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
pInfo->protocol = 1;
pInfo->dnode_id = pDnode->data.dnodeId;
@@ -59,9 +47,7 @@ static void dmGetMmMonitorInfo(SDnode *pDnode) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
if (dmMarkWrapper(pWrapper) == 0) {
SMonMmInfo mmInfo = {0};
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_MM_INFO, tDeserializeSMonMmInfo, &mmInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
mmGetMonitorInfo(pWrapper->pMgmt, &mmInfo);
}
dmReleaseWrapper(pWrapper);
@@ -74,9 +60,7 @@ static void dmGetVmMonitorInfo(SDnode *pDnode) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
if (dmMarkWrapper(pWrapper) == 0) {
SMonVmInfo vmInfo = {0};
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_VM_INFO, tDeserializeSMonVmInfo, &vmInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
vmGetMonitorInfo(pWrapper->pMgmt, &vmInfo);
}
dmReleaseWrapper(pWrapper);
@@ -89,9 +73,7 @@ static void dmGetQmMonitorInfo(SDnode *pDnode) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[QNODE];
if (dmMarkWrapper(pWrapper) == 0) {
SMonQmInfo qmInfo = {0};
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_QM_INFO, tDeserializeSMonQmInfo, &qmInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
qmGetMonitorInfo(pWrapper->pMgmt, &qmInfo);
}
dmReleaseWrapper(pWrapper);
@@ -104,9 +86,7 @@ static void dmGetSmMonitorInfo(SDnode *pDnode) {
SMgmtWrapper *pWrapper = &pDnode->wrappers[SNODE];
if (dmMarkWrapper(pWrapper) == 0) {
SMonSmInfo smInfo = {0};
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_SM_INFO, tDeserializeSMonSmInfo, &smInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
smGetMonitorInfo(pWrapper->pMgmt, &smInfo);
}
dmReleaseWrapper(pWrapper);
@@ -132,9 +112,7 @@ void dmGetVnodeLoads(SMonVloadInfo *pInfo) {
SDnode *pDnode = dmInstance();
SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE];
if (dmMarkWrapper(pWrapper) == 0) {
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_VM_LOAD, tDeserializeSMonVloadInfo, pInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
vmGetVnodeLoads(pWrapper->pMgmt, pInfo, false);
}
dmReleaseWrapper(pWrapper);
@@ -145,9 +123,7 @@ void dmGetMnodeLoads(SMonMloadInfo *pInfo) {
SDnode *pDnode = dmInstance();
SMgmtWrapper *pWrapper = &pDnode->wrappers[MNODE];
if (dmMarkWrapper(pWrapper) == 0) {
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_MM_LOAD, tDeserializeSMonMloadInfo, pInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
mmGetMnodeLoads(pWrapper->pMgmt, pInfo);
}
dmReleaseWrapper(pWrapper);
@@ -158,9 +134,7 @@ void dmGetQnodeLoads(SQnodeLoad *pInfo) {
SDnode *pDnode = dmInstance();
SMgmtWrapper *pWrapper = &pDnode->wrappers[QNODE];
if (dmMarkWrapper(pWrapper) == 0) {
- if (tsMultiProcess) {
- dmSendLocalRecv(pDnode, TDMT_MON_QM_LOAD, tDeserializeSQnodeLoad, pInfo);
- } else if (pWrapper->pMgmt != NULL) {
+ if (pWrapper->pMgmt != NULL) {
qmGetQnodeLoads(pWrapper->pMgmt, pInfo);
}
dmReleaseWrapper(pWrapper);
diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c
index ec5f3589e0..6893e486bb 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmNodes.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmNodes.c
@@ -16,53 +16,6 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
-static int32_t dmCreateShm(SMgmtWrapper *pWrapper) {
- int32_t shmsize = tsMnodeShmSize;
- if (pWrapper->ntype == VNODE) {
- shmsize = tsVnodeShmSize;
- } else if (pWrapper->ntype == QNODE) {
- shmsize = tsQnodeShmSize;
- } else if (pWrapper->ntype == SNODE) {
- shmsize = tsSnodeShmSize;
- } else if (pWrapper->ntype == MNODE) {
- shmsize = tsMnodeShmSize;
- } else {
- return -1;
- }
-
- if (taosCreateShm(&pWrapper->proc.shm, pWrapper->ntype, shmsize) != 0) {
- terrno = TAOS_SYSTEM_ERROR(terrno);
- dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
- return -1;
- }
-
- dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->proc.shm.id, shmsize);
- return 0;
-}
-
-static int32_t dmNewProc(SMgmtWrapper *pWrapper, EDndNodeType ntype) {
- char tstr[8] = {0};
- char *args[6] = {0};
- snprintf(tstr, sizeof(tstr), "%d", ntype);
- args[1] = "-c";
- args[2] = configDir;
- args[3] = "-n";
- args[4] = tstr;
- args[5] = NULL;
-
- int32_t pid = taosNewProc(args);
- if (pid <= 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to exec in new process since %s", pWrapper->name, terrstr());
- return -1;
- }
-
- taosIgnSignal(SIGCHLD);
- pWrapper->proc.pid = pid;
- dInfo("node:%s, continue running in new pid:%d", pWrapper->name, pid);
- return 0;
-}
-
int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
SDnode *pDnode = pWrapper->pDnode;
@@ -75,64 +28,14 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
SMgmtOutputOpt output = {0};
SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper);
- if (pWrapper->ntype == DNODE || InChildProc(pWrapper)) {
- tmsgSetDefault(&input.msgCb);
- }
-
- if (OnlyInSingleProc(pWrapper)) {
- dInfo("node:%s, start to open", pWrapper->name);
- if ((*pWrapper->func.openFp)(&input, &output) != 0) {
- dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
- return -1;
- }
- dInfo("node:%s, has been opened", pWrapper->name);
- pWrapper->deployed = true;
- }
-
- if (InParentProc(pWrapper)) {
- dDebug("node:%s, start to open", pWrapper->name);
- if (dmCreateShm(pWrapper) != 0) {
- return -1;
- }
- if (dmWriteShmFile(pWrapper->path, pWrapper->name, &pWrapper->proc.shm) != 0) {
- return -1;
- }
-
- if (OnlyInParentProc(pWrapper)) {
- if (dmInitProc(pWrapper) != 0) {
- dError("node:%s, failed to init proc since %s", pWrapper->name, terrstr());
- return -1;
- }
- if (pDnode->rtype == NODE_END) {
- dInfo("node:%s, should be started manually in child process", pWrapper->name);
- } else {
- if (dmNewProc(pWrapper, pWrapper->ntype) != 0) {
- return -1;
- }
- }
- if (dmRunProc(&pWrapper->proc) != 0) {
- dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
- return -1;
- }
- }
- dDebug("node:%s, has been opened in parent process", pWrapper->name);
- }
-
- if (InChildProc(pWrapper)) {
- dDebug("node:%s, start to open", pWrapper->name);
- if ((*pWrapper->func.openFp)(&input, &output) != 0) {
- dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
- return -1;
- }
- if (dmInitProc(pWrapper) != 0) {
- return -1;
- }
- if (dmRunProc(&pWrapper->proc) != 0) {
- return -1;
- }
- dDebug("node:%s, has been opened in child process", pWrapper->name);
- pWrapper->deployed = true;
+ dInfo("node:%s, start to open", pWrapper->name);
+ tmsgSetDefault(&input.msgCb);
+ if ((*pWrapper->func.openFp)(&input, &output) != 0) {
+ dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
+ return -1;
}
+ dInfo("node:%s, has been opened", pWrapper->name);
+ pWrapper->deployed = true;
if (output.pMgmt != NULL) {
pWrapper->pMgmt = output.pMgmt;
@@ -143,7 +46,6 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
}
int32_t dmStartNode(SMgmtWrapper *pWrapper) {
- if (OnlyInParentProc(pWrapper)) return 0;
if (pWrapper->func.startFp != NULL) {
dDebug("node:%s, start to start", pWrapper->name);
if ((*pWrapper->func.startFp)(pWrapper->pMgmt) != 0) {
@@ -173,17 +75,6 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
taosMsleep(10);
}
- if (OnlyInParentProc(pWrapper)) {
- int32_t pid = pWrapper->proc.pid;
- if (pid > 0 && taosProcExist(pid)) {
- dInfo("node:%s, send kill signal to the child pid:%d", pWrapper->name, pid);
- taosKillProc(pid);
- dInfo("node:%s, wait for child pid:%d to stop", pWrapper->name, pid);
- taosWaitProc(pid);
- dInfo("node:%s, child pid:%d is stopped", pWrapper->name, pid);
- }
- }
-
taosThreadRwlockWrlock(&pWrapper->lock);
if (pWrapper->pMgmt != NULL) {
(*pWrapper->func.closeFp)(pWrapper->pMgmt);
@@ -191,10 +82,6 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
}
taosThreadRwlockUnlock(&pWrapper->lock);
- if (!OnlyInSingleProc(pWrapper)) {
- dmCleanupProc(pWrapper);
- }
-
dInfo("node:%s, has been closed", pWrapper->name);
}
@@ -241,29 +128,8 @@ static void dmCloseNodes(SDnode *pDnode) {
}
}
-static void dmWatchNodes(SDnode *pDnode) {
- if (pDnode->ptype != PARENT_PROC) return;
- if (pDnode->rtype == NODE_END) return;
-
- taosThreadMutexLock(&pDnode->mutex);
- for (EDndNodeType ntype = DNODE + 1; ntype < NODE_END; ++ntype) {
- SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
- SProc *proc = &pWrapper->proc;
-
- if (!pWrapper->required) continue;
- if (!OnlyInParentProc(pWrapper)) continue;
-
- if (proc->pid <= 0 || !taosProcExist(proc->pid)) {
- dError("node:%s, pid:%d is killed and needs to restart", pWrapper->name, proc->pid);
- dmCloseProcRpcHandles(&pWrapper->proc);
- dmNewProc(pWrapper, ntype);
- }
- }
- taosThreadMutexUnlock(&pDnode->mutex);
-}
-
int32_t dmRunDnode(SDnode *pDnode) {
- int count = 0;
+ int32_t count = 0;
if (dmOpenNodes(pDnode) != 0) {
dError("failed to open nodes since %s", terrstr());
return -1;
@@ -273,6 +139,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
dError("failed to start nodes since %s", terrstr());
return -1;
}
+
while (1) {
if (pDnode->stop) {
dInfo("TDengine is about to stop");
@@ -282,8 +149,8 @@ int32_t dmRunDnode(SDnode *pDnode) {
return 0;
}
- dmWatchNodes(pDnode);
if (count == 0) osUpdate();
+
count %= 10;
count++;
taosMsleep(100);
diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c
deleted file mode 100644
index dc07455e6b..0000000000
--- a/source/dnode/mgmt/node_mgmt/src/dmProc.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#define _DEFAULT_SOURCE
-#include "dmMgmt.h"
-
-static inline int32_t CEIL8(int32_t v) { return ceil((float)(v) / 8) * 8; }
-
-static int32_t dmInitProcMutex(SProcQueue *queue) {
- TdThreadMutexAttr mattr = {0};
-
- if (taosThreadMutexAttrInit(&mattr) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to init mutex while init attr since %s", queue->name, terrstr());
- return -1;
- }
-
- if (taosThreadMutexAttrSetPshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) {
- taosThreadMutexAttrDestroy(&mattr);
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to init mutex while set shared since %s", queue->name, terrstr());
- return -1;
- }
-
- if (taosThreadMutexInit(&queue->mutex, &mattr) != 0) {
- taosThreadMutexAttrDestroy(&mattr);
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to init mutex since %s", queue->name, terrstr());
- return -1;
- }
-
- taosThreadMutexAttrDestroy(&mattr);
- return 0;
-}
-
-static int32_t dmInitProcSem(SProcQueue *queue) {
- if (tsem_init(&queue->sem, 1, 0) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to init sem since %s", queue->name, terrstr());
- return -1;
- }
-
- return 0;
-}
-
-static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
- SProcQueue *queue = (SProcQueue *)(ptr);
-
- int32_t bufSize = size - CEIL8(sizeof(SProcQueue));
- if (bufSize <= 1024) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return NULL;
- }
-
- if (proc->ptype & DND_PROC_PARENT) {
- memset(ptr, 0, sizeof(SProcQueue));
- if (dmInitProcMutex(queue) != 0) {
- return NULL;
- }
-
- if (dmInitProcSem(queue) != 0) {
- return NULL;
- }
-
- tstrncpy(queue->name, proc->name, sizeof(queue->name));
-
- taosThreadMutexLock(&queue->mutex);
- // queue->head = 0;
- // queue->tail = 0;
- queue->total = bufSize;
- queue->avail = bufSize;
- // queue->items = 0;
- taosThreadMutexUnlock(&queue->mutex);
- }
-
- return queue;
-}
-
-static void dmCleanupProcQueue(SProcQueue *queue) {}
-
-static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg *pMsg, EProcFuncType ftype) {
- const void *pHead = pMsg;
- const void *pBody = pMsg->pCont;
- const int16_t rawHeadLen = sizeof(SRpcMsg);
- const int32_t rawBodyLen = pMsg->contLen;
- const int16_t headLen = CEIL8(rawHeadLen);
- const int32_t bodyLen = CEIL8(rawBodyLen);
- const int32_t fullLen = headLen + bodyLen + 8;
- const int64_t handle = (int64_t)pMsg->info.handle;
-
- if (fullLen > queue->total) {
- terrno = TSDB_CODE_OUT_OF_RANGE;
- return -1;
- }
-
- taosThreadMutexLock(&queue->mutex);
- if (fullLen > queue->avail) {
- taosThreadMutexUnlock(&queue->mutex);
- terrno = TSDB_CODE_OUT_OF_SHM_MEM;
- return -1;
- }
-
- if (ftype == DND_FUNC_REQ && IsReq(pMsg) && pMsg->code == 0 && handle != 0 && pMsg->info.noResp == 0) {
- if (taosHashPut(proc->hash, &handle, sizeof(int64_t), &pMsg->info, sizeof(SRpcConnInfo)) != 0) {
- taosThreadMutexUnlock(&queue->mutex);
- return -1;
- }
- }
-
- const int32_t pos = queue->tail;
- if (queue->tail < queue->total) {
- *(int16_t *)(queue->pBuffer + queue->tail) = rawHeadLen;
- *(int8_t *)(queue->pBuffer + queue->tail + 2) = (int8_t)ftype;
- *(int32_t *)(queue->pBuffer + queue->tail + 4) = rawBodyLen;
- } else {
- *(int16_t *)(queue->pBuffer) = rawHeadLen;
- *(int8_t *)(queue->pBuffer + 2) = (int8_t)ftype;
- *(int32_t *)(queue->pBuffer + 4) = rawBodyLen;
- }
-
- if (queue->tail < queue->head) {
- memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
- if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, rawBodyLen);
- queue->tail = queue->tail + 8 + headLen + bodyLen;
- } else {
- int32_t remain = queue->total - queue->tail;
- if (remain == 0) {
- memcpy(queue->pBuffer + 8, pHead, rawHeadLen);
- if (rawBodyLen > 0) memcpy(queue->pBuffer + 8 + headLen, pBody, rawBodyLen);
- queue->tail = 8 + headLen + bodyLen;
- } else if (remain == 8) {
- memcpy(queue->pBuffer, pHead, rawHeadLen);
- if (rawBodyLen > 0) memcpy(queue->pBuffer + headLen, pBody, rawBodyLen);
- queue->tail = headLen + bodyLen;
- } else if (remain < 8 + headLen) {
- memcpy(queue->pBuffer + queue->tail + 8, pHead, remain - 8);
- memcpy(queue->pBuffer, (char *)pHead + remain - 8, rawHeadLen - (remain - 8));
- if (rawBodyLen > 0) memcpy(queue->pBuffer + headLen - (remain - 8), pBody, rawBodyLen);
- queue->tail = headLen - (remain - 8) + bodyLen;
- } else if (remain < 8 + headLen + bodyLen) {
- memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
- if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + 8 + headLen, pBody, remain - 8 - headLen);
- if (rawBodyLen > 0)
- memcpy(queue->pBuffer, (char *)pBody + remain - 8 - headLen, rawBodyLen - (remain - 8 - headLen));
- queue->tail = bodyLen - (remain - 8 - headLen);
- } else {
- memcpy(queue->pBuffer + queue->tail + 8, pHead, rawHeadLen);
- if (rawBodyLen > 0) memcpy(queue->pBuffer + queue->tail + headLen + 8, pBody, rawBodyLen);
- queue->tail = queue->tail + headLen + bodyLen + 8;
- }
- }
-
- queue->avail -= fullLen;
- queue->items++;
- taosThreadMutexUnlock(&queue->mutex);
- tsem_post(&queue->sem);
-
- dTrace("node:%s, push %s msg:%p type:%d handle:%p len:%d code:0x%x, pos:%d remain:%d", queue->name, dmFuncStr(ftype),
- pMsg, pMsg->msgType, pMsg->info.handle, pMsg->contLen, pMsg->code, pos, queue->items);
- return 0;
-}
-
-static inline int32_t dmPopFromProcQueue(SProcQueue *queue, SRpcMsg **ppMsg, EProcFuncType *pFuncType) {
- tsem_wait(&queue->sem);
-
- taosThreadMutexLock(&queue->mutex);
- if (queue->total - queue->avail <= 0) {
- taosThreadMutexUnlock(&queue->mutex);
- terrno = TSDB_CODE_OUT_OF_SHM_MEM;
- return 0;
- }
-
- int16_t rawHeadLen = 0;
- int8_t ftype = 0;
- int32_t rawBodyLen = 0;
- if (queue->head < queue->total) {
- rawHeadLen = *(int16_t *)(queue->pBuffer + queue->head);
- ftype = *(int8_t *)(queue->pBuffer + queue->head + 2);
- rawBodyLen = *(int32_t *)(queue->pBuffer + queue->head + 4);
- } else {
- rawHeadLen = *(int16_t *)(queue->pBuffer);
- ftype = *(int8_t *)(queue->pBuffer + 2);
- rawBodyLen = *(int32_t *)(queue->pBuffer + 4);
- }
- int16_t headLen = CEIL8(rawHeadLen);
- int32_t bodyLen = CEIL8(rawBodyLen);
-
- void *pHead = taosAllocateQitem(headLen, DEF_QITEM);
- void *pBody = NULL;
- if (bodyLen > 0) pBody = rpcMallocCont(bodyLen);
- if (pHead == NULL || (bodyLen > 0 && pBody == NULL)) {
- taosThreadMutexUnlock(&queue->mutex);
- tsem_post(&queue->sem);
- taosFreeQitem(pHead);
- rpcFreeCont(pBody);
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return -1;
- }
-
- const int32_t pos = queue->head;
- if (queue->head < queue->tail) {
- memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, bodyLen);
- queue->head = queue->head + 8 + headLen + bodyLen;
- } else {
- int32_t remain = queue->total - queue->head;
- if (remain == 0) {
- memcpy(pHead, queue->pBuffer + 8, headLen);
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + 8 + headLen, bodyLen);
- queue->head = 8 + headLen + bodyLen;
- } else if (remain == 8) {
- memcpy(pHead, queue->pBuffer, headLen);
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + headLen, bodyLen);
- queue->head = headLen + bodyLen;
- } else if (remain < 8 + headLen) {
- memcpy(pHead, queue->pBuffer + queue->head + 8, remain - 8);
- memcpy((char *)pHead + remain - 8, queue->pBuffer, headLen - (remain - 8));
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + headLen - (remain - 8), bodyLen);
- queue->head = headLen - (remain - 8) + bodyLen;
- } else if (remain < 8 + headLen + bodyLen) {
- memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + 8 + headLen, remain - 8 - headLen);
- if (bodyLen > 0) memcpy((char *)pBody + remain - 8 - headLen, queue->pBuffer, bodyLen - (remain - 8 - headLen));
- queue->head = bodyLen - (remain - 8 - headLen);
- } else {
- memcpy(pHead, queue->pBuffer + queue->head + 8, headLen);
- if (bodyLen > 0) memcpy(pBody, queue->pBuffer + queue->head + headLen + 8, bodyLen);
- queue->head = queue->head + headLen + bodyLen + 8;
- }
- }
-
- queue->avail = queue->avail + headLen + bodyLen + 8;
- queue->items--;
- taosThreadMutexUnlock(&queue->mutex);
-
- *ppMsg = pHead;
- (*ppMsg)->pCont = pBody;
- *pFuncType = (EProcFuncType)ftype;
-
- dTrace("node:%s, pop %s msg:%p type:%d handle:%p len:%d code:0x%x, pos:%d remain:%d", queue->name, dmFuncStr(ftype),
- (*ppMsg), (*ppMsg)->msgType, (*ppMsg)->info.handle, (*ppMsg)->contLen, (*ppMsg)->code, pos, queue->items);
- return 1;
-}
-
-int32_t dmInitProc(struct SMgmtWrapper *pWrapper) {
- SProc *proc = &pWrapper->proc;
- if (proc->name != NULL) return 0;
-
- proc->wrapper = pWrapper;
- proc->name = pWrapper->name;
-
- SShm *shm = &proc->shm;
- int32_t cstart = 0;
- int32_t csize = CEIL8(shm->size / 2);
- int32_t pstart = csize;
- int32_t psize = CEIL8(shm->size - pstart);
- if (pstart + psize > shm->size) {
- psize -= 8;
- }
-
- proc->hash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
- proc->cqueue = dmInitProcQueue(proc, (char *)shm->ptr + cstart, csize);
- proc->pqueue = dmInitProcQueue(proc, (char *)shm->ptr + pstart, psize);
- if (proc->cqueue == NULL || proc->pqueue == NULL || proc->hash == NULL) {
- dmCleanupProcQueue(proc->cqueue);
- dmCleanupProcQueue(proc->pqueue);
- taosHashCleanup(proc->hash);
- return -1;
- }
-
- dDebug("node:%s, proc is initialized, cqueue:%p pqueue:%p", proc->name, proc->cqueue, proc->pqueue);
- return 0;
-}
-
-static void *dmConsumChildQueue(void *param) {
- SProc *proc = param;
- SMgmtWrapper *pWrapper = proc->wrapper;
- SProcQueue *queue = proc->cqueue;
- int32_t numOfMsgs = 0;
- int32_t code = 0;
- EProcFuncType ftype = DND_FUNC_REQ;
- SRpcMsg *pMsg = NULL;
-
- dDebug("node:%s, start to consume from cqueue", proc->name);
- do {
- numOfMsgs = dmPopFromProcQueue(queue, &pMsg, &ftype);
- if (numOfMsgs == 0) {
- dDebug("node:%s, get no msg from cqueue and exit thread", proc->name);
- break;
- }
-
- if (numOfMsgs < 0) {
- dError("node:%s, get no msg from cqueue since %s", proc->name, terrstr());
- taosMsleep(1);
- continue;
- }
-
- if (ftype != DND_FUNC_REQ) {
- dError("node:%s, invalid ftype:%d from cqueue", proc->name, ftype);
- rpcFreeCont(pMsg->pCont);
- taosFreeQitem(pMsg);
- continue;
- }
-
- code = dmProcessNodeMsg(pWrapper, pMsg);
- if (code != 0) {
- dError("node:%s, failed to process msg:%p since %s, put into pqueue", proc->name, pMsg, terrstr());
- SRpcMsg rsp = {.code = (terrno != 0 ? terrno : code), .info = pMsg->info};
- dmPutToProcPQueue(proc, &rsp, DND_FUNC_RSP);
- rpcFreeCont(pMsg->pCont);
- taosFreeQitem(pMsg);
- }
- } while (1);
-
- return NULL;
-}
-
-static void *dmConsumParentQueue(void *param) {
- SProc *proc = param;
- SMgmtWrapper *pWrapper = proc->wrapper;
- SProcQueue *queue = proc->pqueue;
- int32_t numOfMsgs = 0;
- int32_t code = 0;
- EProcFuncType ftype = DND_FUNC_REQ;
- SRpcMsg *pMsg = NULL;
-
- dDebug("node:%s, start to consume from pqueue", proc->name);
- do {
- numOfMsgs = dmPopFromProcQueue(queue, &pMsg, &ftype);
- if (numOfMsgs == 0) {
- dDebug("node:%s, get no msg from pqueue and exit thread", proc->name);
- break;
- }
-
- if (numOfMsgs < 0) {
- dError("node:%s, get no msg from pqueue since %s", proc->name, terrstr());
- taosMsleep(1);
- continue;
- }
-
- if (ftype == DND_FUNC_RSP) {
- dmRemoveProcRpcHandle(proc, pMsg->info.handle);
- rpcSendResponse(pMsg);
- } else if (ftype == DND_FUNC_REGIST) {
- rpcRegisterBrokenLinkArg(pMsg);
- } else if (ftype == DND_FUNC_RELEASE) {
- dmRemoveProcRpcHandle(proc, pMsg->info.handle);
- rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER);
- } else {
- dError("node:%s, invalid ftype:%d from pqueue", proc->name, ftype);
- rpcFreeCont(pMsg->pCont);
- }
-
- taosFreeQitem(pMsg);
- } while (1);
-
- return NULL;
-}
-
-int32_t dmRunProc(SProc *proc) {
- TdThreadAttr thAttr = {0};
- taosThreadAttrInit(&thAttr);
- taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
-
- if (proc->ptype & DND_PROC_PARENT) {
- if (taosThreadCreate(&proc->pthread, &thAttr, dmConsumParentQueue, proc) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to create pthread since %s", proc->name, terrstr());
- return -1;
- }
- dDebug("node:%s, thread:%" PRId64 " is created to consume pqueue", proc->name, proc->pthread);
- }
-
- if (proc->ptype & DND_PROC_CHILD) {
- if (taosThreadCreate(&proc->cthread, &thAttr, dmConsumChildQueue, proc) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to create cthread since %s", proc->name, terrstr());
- return -1;
- }
- dDebug("node:%s, thread:%" PRId64 " is created to consume cqueue", proc->name, proc->cthread);
- }
-
- taosThreadAttrDestroy(&thAttr);
- return 0;
-}
-
-void dmStopProc(SProc *proc) {
- proc->stop = true;
- if (taosCheckPthreadValid(proc->pthread)) {
- dDebug("node:%s, start to join pthread:%" PRId64, proc->name, proc->pthread);
- tsem_post(&proc->pqueue->sem);
- taosThreadJoin(proc->pthread, NULL);
- taosThreadClear(&proc->pthread);
- }
-
- if (taosCheckPthreadValid(proc->cthread)) {
- dDebug("node:%s, start to join cthread:%" PRId64, proc->name, proc->cthread);
- tsem_post(&proc->cqueue->sem);
- taosThreadJoin(proc->cthread, NULL);
- taosThreadClear(&proc->cthread);
- }
-}
-
-void dmCleanupProc(struct SMgmtWrapper *pWrapper) {
- SProc *proc = &pWrapper->proc;
- if (proc->name == NULL) return;
-
- dDebug("node:%s, start to cleanup proc", pWrapper->name);
- dmStopProc(proc);
- dmCleanupProcQueue(proc->cqueue);
- dmCleanupProcQueue(proc->pqueue);
- taosHashCleanup(proc->hash);
- proc->hash = NULL;
- dDebug("node:%s, proc is cleaned up", pWrapper->name);
-}
-
-void dmRemoveProcRpcHandle(SProc *proc, void *handle) {
- int64_t h = (int64_t)handle;
- taosThreadMutexLock(&proc->cqueue->mutex);
- taosHashRemove(proc->hash, &h, sizeof(int64_t));
- taosThreadMutexUnlock(&proc->cqueue->mutex);
-}
-
-void dmCloseProcRpcHandles(SProc *proc) {
- taosThreadMutexLock(&proc->cqueue->mutex);
- SRpcHandleInfo *pInfo = taosHashIterate(proc->hash, NULL);
- while (pInfo != NULL) {
- dError("node:%s, the child process dies and send an offline rsp to handle:%p", proc->name, pInfo->handle);
- SRpcMsg rpcMsg = {.code = TSDB_CODE_NODE_OFFLINE, .info = *pInfo};
- rpcSendResponse(&rpcMsg);
- pInfo = taosHashIterate(proc->hash, pInfo);
- }
- taosHashClear(proc->hash);
- taosThreadMutexUnlock(&proc->cqueue->mutex);
-}
-
-void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
- int32_t retry = 0;
- while (1) {
- if (dmPushToProcQueue(proc, proc->pqueue, pMsg, ftype) == 0) {
- break;
- }
-
- if (terrno != TSDB_CODE_OUT_OF_SHM_MEM) {
- pMsg->code = terrno;
- if (pMsg->contLen > 0) {
- rpcFreeCont(pMsg->pCont);
- pMsg->pCont = NULL;
- pMsg->contLen = 0;
- }
- dError("node:%s, failed to push %s msg:%p type:%d handle:%p then discard data and return error", proc->name,
- dmFuncStr(ftype), pMsg, pMsg->msgType, pMsg->info.handle);
- } else {
- dError("node:%s, failed to push %s msg:%p type:%d handle:%p len:%d since %s, retry:%d", proc->name,
- dmFuncStr(ftype), pMsg, pMsg->msgType, pMsg->info.handle, pMsg->contLen, terrstr(), retry);
- retry++;
- taosMsleep(retry);
- }
- }
-
- rpcFreeCont(pMsg->pCont);
- pMsg->pCont = NULL;
- pMsg->contLen = 0;
-}
-
-int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
- int32_t code = dmPushToProcQueue(proc, proc->cqueue, pMsg, ftype);
- if (code == 0) {
- dTrace("msg:%p, is freed after push to cqueue", pMsg);
- rpcFreeCont(pMsg->pCont);
- taosFreeQitem(pMsg);
- }
- return code;
-}
diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c
index 542baaec09..7ad24be258 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c
@@ -17,14 +17,7 @@
#include "dmMgmt.h"
#include "qworker.h"
-static inline void dmSendRsp(SRpcMsg *pMsg) {
- SMgmtWrapper *pWrapper = pMsg->info.wrapper;
- if (InChildProc(pWrapper)) {
- dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP);
- } else {
- rpcSendResponse(pMsg);
- }
-}
+static inline void dmSendRsp(SRpcMsg *pMsg) { rpcSendResponse(pMsg); }
static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
SEpSet epSet = {0};
@@ -157,11 +150,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
dGTrace("msg:%p, is created, type:%s handle:%p", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle);
- if (InParentProc(pWrapper)) {
- code = dmPutToProcCQueue(&pWrapper->proc, pMsg, DND_FUNC_REQ);
- } else {
- code = dmProcessNodeMsg(pWrapper, pMsg);
- }
+ code = dmProcessNodeMsg(pWrapper, pMsg);
_OVER:
if (code != 0) {
@@ -233,24 +222,9 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
}
}
-static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) {
- SMgmtWrapper *pWrapper = pMsg->info.wrapper;
- if (InChildProc(pWrapper)) {
- dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_REGIST);
- } else {
- rpcRegisterBrokenLinkArg(pMsg);
- }
-}
+static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { rpcRegisterBrokenLinkArg(pMsg); }
-static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) {
- SMgmtWrapper *pWrapper = pHandle->wrapper;
- if (InChildProc(pWrapper)) {
- SRpcMsg msg = {.code = type, .info = *pHandle};
- dmPutToProcPQueue(&pWrapper->proc, &msg, DND_FUNC_RELEASE);
- } else {
- rpcReleaseHandle(pHandle, type);
- }
-}
+static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcReleaseHandle(pHandle, type); }
static bool rpcRfp(int32_t code, tmsg_t msgType) {
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED ||
diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h
index 2f9c0aff2f..8719e988e7 100644
--- a/source/dnode/mgmt/node_util/inc/dmUtil.h
+++ b/source/dnode/mgmt/node_util/inc/dmUtil.h
@@ -83,20 +83,6 @@ typedef enum {
DND_ENV_CLEANUP,
} EDndEnvStatus;
-typedef enum {
- DND_PROC_SINGLE,
- DND_PROC_CHILD,
- DND_PROC_PARENT,
- DND_PROC_TEST,
-} EDndProcType;
-
-typedef enum {
- DND_FUNC_REQ = 1,
- DND_FUNC_RSP = 2,
- DND_FUNC_REGIST = 3,
- DND_FUNC_RELEASE = 4,
-} EProcFuncType;
-
typedef int32_t (*ProcessCreateNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
typedef int32_t (*ProcessDropNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg);
typedef void (*SendMonitorReportFp)();
@@ -165,11 +151,7 @@ typedef struct {
// dmUtil.c
const char *dmStatStr(EDndRunStatus stype);
-const char *dmNodeLogName(EDndNodeType ntype);
-const char *dmNodeProcName(EDndNodeType ntype);
const char *dmNodeName(EDndNodeType ntype);
-const char *dmProcStr(EDndProcType ptype);
-const char *dmFuncStr(EProcFuncType etype);
void *dmSetMgmtHandle(SArray *pArray, tmsg_t msgType, void *nodeMsgFp, bool needCheckVgId);
void dmGetMonitorSystemInfo(SMonSysInfo *pInfo);
@@ -177,8 +159,6 @@ void dmGetMonitorSystemInfo(SMonSysInfo *pInfo);
int32_t dmReadFile(const char *path, const char *name, bool *pDeployed);
int32_t dmWriteFile(const char *path, const char *name, bool deployed);
TdFilePtr dmCheckRunning(const char *dataDir);
-int32_t dmReadShmFile(const char *path, const char *name, EDndNodeType runType, SShm *pShm);
-int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm);
// dmEps.c
int32_t dmReadEps(SDnodeData *pData);
diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c
index 9ec17a18b5..d387fe4a3f 100644
--- a/source/dnode/mgmt/node_util/src/dmFile.c
+++ b/source/dnode/mgmt/node_util/src/dmFile.c
@@ -148,114 +148,3 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
dDebug("lock file:%s to prevent repeated starts", filepath);
return pFile;
}
-
-int32_t dmReadShmFile(const char *path, const char *name, EDndNodeType runType, SShm *pShm) {
- int32_t code = -1;
- char content[MAXLEN + 1] = {0};
- char file[PATH_MAX] = {0};
- cJSON *root = NULL;
- TdFilePtr pFile = NULL;
-
- snprintf(file, sizeof(file), "%s%sshmfile", path, TD_DIRSEP);
- pFile = taosOpenFile(file, TD_FILE_READ);
- if (pFile == NULL) {
- code = 0;
- goto _OVER;
- }
-
- if (taosReadFile(pFile, content, MAXLEN) > 0) {
- root = cJSON_Parse(content);
- if (root == NULL) {
- terrno = TSDB_CODE_INVALID_JSON_FORMAT;
- dError("node:%s, failed to read %s since invalid json format", name, file);
- goto _OVER;
- }
-
- cJSON *shmid = cJSON_GetObjectItem(root, "shmid");
- if (shmid && shmid->type == cJSON_Number) {
- pShm->id = shmid->valueint;
- }
-
- cJSON *shmsize = cJSON_GetObjectItem(root, "shmsize");
- if (shmsize && shmsize->type == cJSON_Number) {
- pShm->size = shmsize->valueint;
- }
- }
-
- if (!tsMultiProcess || runType == DNODE || runType == NODE_END) {
- if (pShm->id >= 0) {
- dDebug("node:%s, shmid:%d, is closed, size:%d", name, pShm->id, pShm->size);
- taosDropShm(pShm);
- }
- } else {
- if (taosAttachShm(pShm) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("shmid:%d, failed to attach shm since %s", pShm->id, terrstr());
- goto _OVER;
- }
- dInfo("node:%s, shmid:%d is attached, size:%d", name, pShm->id, pShm->size);
- }
-
- dDebug("node:%s, successed to load %s", name, file);
- code = 0;
-
-_OVER:
- if (root != NULL) cJSON_Delete(root);
- if (pFile != NULL) taosCloseFile(&pFile);
-
- return code;
-}
-
-int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm) {
- int32_t code = -1;
- int32_t len = 0;
- char content[MAXLEN + 1] = {0};
- char file[PATH_MAX] = {0};
- char realfile[PATH_MAX] = {0};
- TdFilePtr pFile = NULL;
-
- snprintf(file, sizeof(file), "%s%sshmfile.bak", path, TD_DIRSEP);
- snprintf(realfile, sizeof(realfile), "%s%sshmfile", path, TD_DIRSEP);
-
- pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
- if (pFile == NULL) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to open file:%s since %s", name, file, terrstr());
- goto _OVER;
- }
-
- len += snprintf(content + len, MAXLEN - len, "{\n");
- len += snprintf(content + len, MAXLEN - len, " \"shmid\":%d,\n", pShm->id);
- len += snprintf(content + len, MAXLEN - len, " \"shmsize\":%d\n", pShm->size);
- len += snprintf(content + len, MAXLEN - len, "}\n");
-
- if (taosWriteFile(pFile, content, len) != len) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to write file:%s since %s", name, file, terrstr());
- goto _OVER;
- }
-
- if (taosFsyncFile(pFile) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to fsync file:%s since %s", name, file, terrstr());
- goto _OVER;
- }
-
- taosCloseFile(&pFile);
-
- if (taosRenameFile(file, realfile) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- dError("node:%s, failed to rename %s to %s since %s", name, file, realfile, terrstr());
- return -1;
- }
-
- dInfo("node:%s, successed to write %s", name, realfile);
- code = 0;
-
-_OVER:
- if (pFile != NULL) {
- taosCloseFile(&pFile);
- }
-
- return code;
-}
diff --git a/source/dnode/mgmt/node_util/src/dmUtil.c b/source/dnode/mgmt/node_util/src/dmUtil.c
index f5364b3195..80bb8debd2 100644
--- a/source/dnode/mgmt/node_util/src/dmUtil.c
+++ b/source/dnode/mgmt/node_util/src/dmUtil.c
@@ -29,36 +29,6 @@ const char *dmStatStr(EDndRunStatus stype) {
}
}
-const char *dmNodeLogName(EDndNodeType ntype) {
- switch (ntype) {
- case VNODE:
- return "vnode";
- case QNODE:
- return "qnode";
- case SNODE:
- return "snode";
- case MNODE:
- return "mnode";
- default:
- return "taosd";
- }
-}
-
-const char *dmNodeProcName(EDndNodeType ntype) {
- switch (ntype) {
- case VNODE:
- return "taosv";
- case QNODE:
- return "taosq";
- case SNODE:
- return "taoss";
- case MNODE:
- return "taosm";
- default:
- return "taosd";
- }
-}
-
const char *dmNodeName(EDndNodeType ntype) {
switch (ntype) {
case VNODE:
@@ -74,36 +44,6 @@ const char *dmNodeName(EDndNodeType ntype) {
}
}
-const char *dmProcStr(EDndProcType etype) {
- switch (etype) {
- case DND_PROC_SINGLE:
- return "start";
- case DND_PROC_CHILD:
- return "stop";
- case DND_PROC_PARENT:
- return "child";
- case DND_PROC_TEST:
- return "test";
- default:
- return "UNKNOWN";
- }
-}
-
-const char *dmFuncStr(EProcFuncType etype) {
- switch (etype) {
- case DND_FUNC_REQ:
- return "req";
- case DND_FUNC_RSP:
- return "rsp";
- case DND_FUNC_REGIST:
- return "regist";
- case DND_FUNC_RELEASE:
- return "release";
- default:
- return "UNKNOWN";
- }
-}
-
void *dmSetMgmtHandle(SArray *pArray, tmsg_t msgType, void *nodeMsgFp, bool needCheckVgId) {
SMgmtHandle handle = {
.msgType = msgType,
diff --git a/source/dnode/mgmt/test/sut/src/server.cpp b/source/dnode/mgmt/test/sut/src/server.cpp
index de35b06b05..98c59a1614 100644
--- a/source/dnode/mgmt/test/sut/src/server.cpp
+++ b/source/dnode/mgmt/test/sut/src/server.cpp
@@ -16,7 +16,7 @@
#include "sut.h"
void* serverLoop(void* param) {
- dmInit(0);
+ dmInit();
dmRun();
dmCleanup();
return NULL;
diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h
index 48eea7daea..2ee732e797 100644
--- a/source/dnode/mnode/impl/inc/mndDef.h
+++ b/source/dnode/mnode/impl/inc/mndDef.h
@@ -204,7 +204,8 @@ typedef struct {
int32_t id;
int64_t createdTime;
int64_t updateTime;
- ESyncState state;
+ ESyncState syncState;
+ bool syncRestore;
int64_t stateStartTime;
SDnodeObj* pDnode;
} SMnodeObj;
@@ -324,7 +325,8 @@ typedef struct {
typedef struct {
int32_t dnodeId;
- ESyncState role;
+ ESyncState syncState;
+ bool syncRestore;
} SVnodeGid;
typedef struct {
diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c
index 46aaa7ffe1..77f91b6d29 100644
--- a/source/dnode/mnode/impl/src/mndConsumer.c
+++ b/source/dnode/mnode/impl/src/mndConsumer.c
@@ -278,7 +278,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
if (pConsumer == NULL) {
- mError("consumer %ld not exist", consumerId);
+ mError("consumer %" PRId64 " not exist", consumerId);
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
return -1;
}
@@ -288,7 +288,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
int32_t status = atomic_load_32(&pConsumer->status);
if (status == MQ_CONSUMER_STATUS__LOST_REBD) {
- mInfo("try to recover consumer %ld", consumerId);
+ mInfo("try to recover consumer %" PRId64 "", consumerId);
SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg));
pRecoverMsg->consumerId = consumerId;
@@ -327,7 +327,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
#if 1
if (status == MQ_CONSUMER_STATUS__LOST_REBD) {
- mInfo("try to recover consumer %ld", consumerId);
+ mInfo("try to recover consumer %" PRId64 "", consumerId);
SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg));
pRecoverMsg->consumerId = consumerId;
@@ -341,7 +341,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
#endif
if (status != MQ_CONSUMER_STATUS__READY) {
- mInfo("consumer %ld not ready, status: %s", consumerId, mndConsumerStatusName(status));
+ mInfo("consumer %" PRId64 " not ready, status: %s", consumerId, mndConsumerStatusName(status));
terrno = TSDB_CODE_MND_CONSUMER_NOT_READY;
return -1;
}
diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c
index 3b31873857..654664269d 100644
--- a/source/dnode/mnode/impl/src/mndDb.c
+++ b/source/dnode/mnode/impl/src/mndDb.c
@@ -1157,7 +1157,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
pEp->port = pDnode->port;
}
mndReleaseDnode(pMnode, pDnode);
- if (pVgid->role == TAOS_SYNC_STATE_LEADER) {
+ if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) {
vgInfo.epSet.inUse = gid;
}
}
@@ -1553,7 +1553,7 @@ bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) {
if (pVgroup->dbUid == pDb->uid && pVgroup->replica > 1) {
bool hasLeader = false;
for (int32_t i = 0; i < pVgroup->replica; ++i) {
- if (pVgroup->vnodeGid[i].role == TAOS_SYNC_STATE_LEADER) {
+ if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) {
hasLeader = true;
}
}
diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c
index fba1fd94d6..264b8d979b 100644
--- a/source/dnode/mnode/impl/src/mndDnode.c
+++ b/source/dnode/mnode/impl/src/mndDnode.c
@@ -361,10 +361,12 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
bool roleChanged = false;
for (int32_t vg = 0; vg < pVgroup->replica; ++vg) {
if (pVgroup->vnodeGid[vg].dnodeId == statusReq.dnodeId) {
- if (pVgroup->vnodeGid[vg].role != pVload->syncState) {
+ if (pVgroup->vnodeGid[vg].syncState != pVload->syncState ||
+ pVgroup->vnodeGid[vg].syncRestore != pVload->syncRestore) {
+ pVgroup->vnodeGid[vg].syncState = pVload->syncState;
+ pVgroup->vnodeGid[vg].syncRestore = pVload->syncRestore;
roleChanged = true;
}
- pVgroup->vnodeGid[vg].role = pVload->syncState;
break;
}
}
@@ -378,10 +380,11 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
SMnodeObj *pObj = mndAcquireMnode(pMnode, pDnode->id);
if (pObj != NULL) {
- if (pObj->state != statusReq.mload.syncState) {
- mInfo("dnode:%d, mnode syncstate from %s to %s", pObj->id, syncStr(pObj->state),
- syncStr(statusReq.mload.syncState));
- pObj->state = statusReq.mload.syncState;
+ if (pObj->syncState != statusReq.mload.syncState || pObj->syncRestore != statusReq.mload.syncRestore) {
+ mInfo("dnode:%d, mnode syncState from %s to %s, restoreState from %d to %d", pObj->id, syncStr(pObj->syncState),
+ syncStr(statusReq.mload.syncState), pObj->syncRestore, statusReq.mload.syncRestore);
+ pObj->syncState = statusReq.mload.syncState;
+ pObj->syncRestore = statusReq.mload.syncRestore;
pObj->stateStartTime = taosGetTimestampMs();
}
mndReleaseMnode(pMnode, pObj);
diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c
index 4eb2e2978b..a6177fc69f 100644
--- a/source/dnode/mnode/impl/src/mndMain.c
+++ b/source/dnode/mnode/impl/src/mndMain.c
@@ -765,7 +765,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
// pClusterInfo->master_uptime = (ms - pObj->stateStartTime) / (86400000.0f);
tstrncpy(desc.role, syncStr(TAOS_SYNC_STATE_LEADER), sizeof(desc.role));
} else {
- tstrncpy(desc.role, syncStr(pObj->state), sizeof(desc.role));
+ tstrncpy(desc.role, syncStr(pObj->syncState), sizeof(desc.role));
}
taosArrayPush(pClusterInfo->mnodes, &desc);
sdbRelease(pSdb, pObj);
@@ -795,12 +795,12 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
SVnodeGid *pVgid = &pVgroup->vnodeGid[i];
SMonVnodeDesc *pVnDesc = &desc.vnodes[i];
pVnDesc->dnode_id = pVgid->dnodeId;
- tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->role), sizeof(pVnDesc->vnode_role));
- if (pVgid->role == TAOS_SYNC_STATE_LEADER) {
+ tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->syncState), sizeof(pVnDesc->vnode_role));
+ if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) {
tstrncpy(desc.status, "ready", sizeof(desc.status));
pClusterInfo->vgroups_alive++;
}
- if (pVgid->role != TAOS_SYNC_STATE_ERROR) {
+ if (pVgid->syncState != TAOS_SYNC_STATE_ERROR) {
pClusterInfo->vnodes_alive++;
}
pClusterInfo->vnodes_total++;
@@ -845,7 +845,8 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) {
pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync);
- mTrace("mnode current syncstate is %s", syncStr(pLoad->syncState));
+ pLoad->syncRestore = pMnode->restored;
+ mTrace("mnode current syncState is %s, syncRestore:%d", syncStr(pLoad->syncState), pLoad->syncRestore);
return 0;
}
diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c
index f6ea81c565..1ab0ba8a16 100644
--- a/source/dnode/mnode/impl/src/mndMnode.c
+++ b/source/dnode/mnode/impl/src/mndMnode.c
@@ -187,7 +187,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) {
return -1;
}
- pObj->state = TAOS_SYNC_STATE_ERROR;
+ pObj->syncState = TAOS_SYNC_STATE_ERROR;
mndReloadSyncConfig(pSdb->pMnode);
return 0;
}
@@ -604,19 +604,19 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, b1, false);
- const char *roles = "offline";
+ char role[20] = "offline";
if (pObj->id == pMnode->selfDnodeId) {
- roles = syncStr(TAOS_SYNC_STATE_LEADER);
+ snprintf(role, sizeof(role), "%s%s", syncStr(TAOS_SYNC_STATE_LEADER), pMnode->restored ? "" : "*");
}
if (mndIsDnodeOnline(pObj->pDnode, curMs)) {
- roles = syncStr(pObj->state);
- if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) {
- roles = syncStr(TAOS_SYNC_STATE_ERROR);
+ tstrncpy(role, syncStr(pObj->syncState), sizeof(role));
+ if (pObj->syncState == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) {
+ tstrncpy(role, syncStr(TAOS_SYNC_STATE_ERROR), sizeof(role));
mError("mnode:%d, is leader too", pObj->id);
}
}
char b2[12 + VARSTR_HEADER_SIZE] = {0};
- STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
+ STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, (const char *)b2, false);
diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c
index b797bfb4b2..739b8bbf01 100644
--- a/source/dnode/mnode/impl/src/mndSubscribe.c
+++ b/source/dnode/mnode/impl/src/mndSubscribe.c
@@ -426,10 +426,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
if (pIter == NULL) break;
SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
int32_t sz = taosArrayGetSize(pConsumerEp->vgs);
- mInfo("mq rebalance: final cfg: consumer %ld has %d vg", pConsumerEp->consumerId, sz);
+ mInfo("mq rebalance: final cfg: consumer %" PRId64 " has %d vg", pConsumerEp->consumerId, sz);
for (int32_t i = 0; i < sz; i++) {
SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i);
- mInfo("mq rebalance: final cfg: vg %d to consumer %ld", pVgEp->vgId, pConsumerEp->consumerId);
+ mInfo("mq rebalance: final cfg: vg %d to consumer %" PRId64 "", pVgEp->vgId, pConsumerEp->consumerId);
}
}
}
diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c
index 4ab80b0a40..47245fa2c4 100644
--- a/source/dnode/mnode/impl/src/mndVgroup.c
+++ b/source/dnode/mnode/impl/src/mndVgroup.c
@@ -142,7 +142,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
SVnodeGid *pVgid = &pVgroup->vnodeGid[i];
SDB_GET_INT32(pRaw, dataPos, &pVgid->dnodeId, _OVER)
if (pVgroup->replica == 1) {
- pVgid->role = TAOS_SYNC_STATE_LEADER;
+ pVgid->syncState = TAOS_SYNC_STATE_LEADER;
}
}
SDB_GET_RESERVE(pRaw, dataPos, VGROUP_RESERVE_SIZE, _OVER)
@@ -485,9 +485,9 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup
pVgid->dnodeId = pDnode->id;
if (pVgroup->replica == 1) {
- pVgid->role = TAOS_SYNC_STATE_LEADER;
+ pVgid->syncState = TAOS_SYNC_STATE_LEADER;
} else {
- pVgid->role = TAOS_SYNC_STATE_FOLLOWER;
+ pVgid->syncState = TAOS_SYNC_STATE_FOLLOWER;
}
mInfo("db:%s, vgId:%d, vn:%d is alloced, memory:%" PRId64 ", dnode:%d avail:%" PRId64 " used:%" PRId64,
@@ -587,7 +587,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) {
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
if (pDnode == NULL) continue;
- if (pVgid->role == TAOS_SYNC_STATE_LEADER) {
+ if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) {
epset.inUse = epset.numOfEps;
}
@@ -681,8 +681,12 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
mndReleaseDnode(pMnode, pDnode);
}
- char buf1[20] = {0};
- const char *role = online ? syncStr(pVgroup->vnodeGid[i].role) : "offline";
+ char buf1[20] = {0};
+ char role[20] = "offline";
+ if (online) {
+ bool show = (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER && !pVgroup->vnodeGid[i].syncRestore);
+ snprintf(role, sizeof(role), "%s%s", syncStr(pVgroup->vnodeGid[i].syncState), show ? "*" : "");
+ }
STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
@@ -809,7 +813,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->replica, false);
char buf[20] = {0};
- STR_TO_VARSTR(buf, syncStr(pVgid->role));
+ STR_TO_VARSTR(buf, syncStr(pVgid->syncState));
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, (const char *)buf, false);
@@ -887,7 +891,7 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
}
pVgid->dnodeId = pDnode->id;
- pVgid->role = TAOS_SYNC_STATE_ERROR;
+ pVgid->syncState = TAOS_SYNC_STATE_ERROR;
mInfo("db:%s, vgId:%d, vn:%d is added, memory:%" PRId64 ", dnode:%d avail:%" PRId64 " used:%" PRId64,
pVgroup->dbName, pVgroup->vgId, pVgroup->replica, vgMem, pVgid->dnodeId, pDnode->memAvail, pDnode->memUsed);
@@ -1179,7 +1183,7 @@ static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDb
SVnodeGid *pGid = &pVgroup->vnodeGid[pVgroup->replica];
pVgroup->replica++;
pGid->dnodeId = newDnodeId;
- pGid->role = TAOS_SYNC_STATE_ERROR;
+ pGid->syncState = TAOS_SYNC_STATE_ERROR;
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid, true) != 0) return -1;
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
@@ -1233,7 +1237,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
mInfo("vgId:%d, vgroup info before redistribute, replica:%d", newVg.vgId, newVg.replica);
for (int32_t i = 0; i < newVg.replica; ++i) {
mInfo("vgId:%d, vnode:%d dnode:%d role:%s", newVg.vgId, i, newVg.vnodeGid[i].dnodeId,
- syncStr(newVg.vnodeGid[i].role));
+ syncStr(newVg.vnodeGid[i].syncState));
}
if (pNew1 != NULL && pOld1 != NULL) {
diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c
index efd0220a7e..87c788cc37 100644
--- a/source/dnode/vnode/src/meta/metaQuery.c
+++ b/source/dnode/vnode/src/meta/metaQuery.c
@@ -687,7 +687,12 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
SSchema *pSchema = pSchemaWrapper->pSchema + i;
tdAddColToSchema(&sb, pSchema->type, pSchema->flags, pSchema->colId, pSchema->bytes);
}
+
STSchema *pTSchema = tdGetSchemaFromBuilder(&sb);
+ if (pTSchema == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ }
+
tdDestroyTSchemaBuilder(&sb);
*ppTSchema = pTSchema;
diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c
index 2d055acd2f..0e8b3cf949 100644
--- a/source/dnode/vnode/src/meta/metaTable.c
+++ b/source/dnode/vnode/src/meta/metaTable.c
@@ -15,17 +15,18 @@
#include "meta.h"
-static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
-static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
-static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME);
-static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
-static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry);
-static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type);
+static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
+static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
+static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME);
+static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME);
+static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry);
+static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type);
+static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey);
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
pInfo->uid = pEntry->uid;
@@ -594,6 +595,28 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
const SSchema *pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
if (pTagColumn->type == TSDB_DATA_TYPE_JSON) {
metaDelJsonVarFromIdx(pMeta, &e, pTagColumn);
+ } else {
+ STagIdxKey *pTagIdxKey = NULL;
+ int32_t nTagIdxKey;
+
+ const void *pTagData = NULL;
+ int32_t nTagData = 0;
+
+ STagVal tagVal = {.cid = pTagColumn->colId};
+ tTagGet((const STag *)e.ctbEntry.pTags, &tagVal);
+ if (IS_VAR_DATA_TYPE(pTagColumn->type)) {
+ pTagData = tagVal.pData;
+ nTagData = (int32_t)tagVal.nData;
+ } else {
+ pTagData = &(tagVal.i64);
+ nTagData = tDataTypes[pTagColumn->type].bytes;
+ }
+
+ if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
+ &pTagIdxKey, &nTagIdxKey) == 0) {
+ tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, &pMeta->txn);
+ }
+ metaDestroyTagIdxKey(pTagIdxKey);
}
tDecoderClear(&tdc);
}
diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c
index 64e5e49d0b..a272f5fc97 100644
--- a/source/dnode/vnode/src/sma/smaEnv.c
+++ b/source/dnode/vnode/src/sma/smaEnv.c
@@ -455,7 +455,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
if (taosCheckPthreadValid(pthread[i])) {
- smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64, SMA_VID(pSma), pthread[i]);
+ smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64 "", SMA_VID(pSma), taosGetPthreadId(pthread[i]));
taosThreadJoin(pthread[i], NULL);
}
}
@@ -463,4 +463,4 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
smaInfo("vgId:%d, rsma executor stopped, number:%d", SMA_VID(pSma), tsNumOfVnodeRsmaThreads);
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c
index 850e4c5697..2a769b68fe 100644
--- a/source/dnode/vnode/src/sma/smaOpen.c
+++ b/source/dnode/vnode/src/sma/smaOpen.c
@@ -92,8 +92,7 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p
days = freqDuration;
}
end:
- smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days,
- duration);
+ smaInfo("vgId:%d, evaluated duration for level %d is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration);
return days;
}
@@ -186,4 +185,4 @@ int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer) {
ASSERT(VND_IS_RSMA(pSma->pVnode));
return tdRSmaProcessRestoreImpl(pSma, type, committedVer);
-}
\ No newline at end of file
+}
diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c
index 77c5955098..c56b32514a 100644
--- a/source/dnode/vnode/src/sma/smaRollup.c
+++ b/source/dnode/vnode/src/sma/smaRollup.c
@@ -342,7 +342,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
", finally maxdelay:%" PRIi32,
- TD_VID(pVnode), pItem, pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx],
+ TD_VID(pVnode), pItem, pRSmaInfo->suid, (int8_t)(idx + 1), param->maxdelay[idx], param->watermark[idx],
pItem->maxDelay);
}
return TSDB_CODE_SUCCESS;
@@ -1387,7 +1387,7 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
}
if ((++pItem->nScanned * pItem->maxDelay) > RSMA_FETCH_DELAY_MAX) {
- smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch executed",
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16 " maxDelay:%d, fetch executed",
SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay);
} else {
int64_t curMs = taosGetTimestampMs();
@@ -1411,10 +1411,10 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
goto _err;
}
- smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch finished",
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16 " maxDelay:%d, fetch finished",
SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay);
} else {
- smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16
" maxDelay:%d, fetch not executed as fetch level is %" PRIi8,
SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay, pItem->fetchLevel);
}
@@ -1513,7 +1513,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
int32_t qallItemSize = taosQallItemSize(pInfo->qall);
if (qallItemSize > 0) {
tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type);
- smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi8, SMA_VID(pSma), qallItemSize, type);
+ smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi32, SMA_VID(pSma), qallItemSize, type);
}
if (RSMA_INFO_ITEM(pInfo, 0)->fetchLevel || RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) {
diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c
index 6d71496008..da22d0d951 100644
--- a/source/dnode/vnode/src/tq/tq.c
+++ b/source/dnode/vnode/src/tq/tq.c
@@ -564,7 +564,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
pPushEntry->dataRsp.head.epoch = reqEpoch;
pPushEntry->dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*));
- tqDebug("tmq poll: consumer %ld, subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey,
+ tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey,
TD_VID(pTq->pVnode));
// unlock
taosWUnLockLatch(&pTq->pushLock);
@@ -578,7 +578,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
code = -1;
}
- tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%ld, version:%ld",
+ tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%" PRId64
+ ", version:%" PRId64 "",
consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type,
dataRsp.rspOffset.uid, dataRsp.rspOffset.version);
@@ -601,8 +602,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
code = -1;
}
- tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send meta offset type:%d,uid:%ld,version:%ld", consumerId,
- pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid,
+ tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send meta offset type:%d,uid:%" PRId64
+ ",version:%" PRId64 "",
+ consumerId, pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid,
metaRsp.rspOffset.version);
taosMemoryFree(metaRsp.metaRsp);
tDeleteSTaosxRsp(&taosxRsp);
@@ -619,7 +621,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
fetchOffsetNew = taosxRsp.rspOffset;
}
- tqDebug("taosx poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%ld,version:%ld",
+ tqDebug("taosx poll: consumer %" PRId64 ", subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%" PRId64
+ ",version:%" PRId64 "",
consumerId, pHandle->subKey, TD_VID(pTq->pVnode), taosxRsp.blockNum, taosxRsp.rspOffset.type,
taosxRsp.rspOffset.uid, taosxRsp.rspOffset.version);
}
@@ -769,11 +772,11 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
if (pHandle == NULL) {
if (req.oldConsumerId != -1) {
- tqError("vgId:%d, build new consumer handle %s for consumer %ld, but old consumerId is %ld", req.vgId, req.subKey,
- req.newConsumerId, req.oldConsumerId);
+ tqError("vgId:%d, build new consumer handle %s for consumer %" PRId64 ", but old consumerId is %" PRId64 "",
+ req.vgId, req.subKey, req.newConsumerId, req.oldConsumerId);
}
if (req.newConsumerId == -1) {
- tqError("vgId:%d, tq invalid rebalance request, new consumerId %ld", req.vgId, req.newConsumerId);
+ tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId);
return 0;
}
STqHandle tqHandle = {0};
diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c
index 7e3ba57dea..b852acb936 100644
--- a/source/dnode/vnode/src/tq/tqMeta.c
+++ b/source/dnode/vnode/src/tq/tqMeta.c
@@ -193,8 +193,8 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code);
ASSERT(code == 0);
- tqDebug("tq save %s(%d) consumer %ld vgId:%d", pHandle->subKey, (int32_t)strlen(pHandle->subKey), pHandle->consumerId,
- TD_VID(pTq->pVnode));
+ tqDebug("tq save %s(%d) consumer %" PRId64 " vgId:%d", pHandle->subKey, (int32_t)strlen(pHandle->subKey),
+ pHandle->consumerId, TD_VID(pTq->pVnode));
void* buf = taosMemoryCalloc(1, vlen);
if (buf == NULL) {
diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c
index 4083a1a0ae..5ffbc41eb5 100644
--- a/source/dnode/vnode/src/tq/tqPush.c
+++ b/source/dnode/vnode/src/tq/tqPush.c
@@ -213,7 +213,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
#endif
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
- tqDebug("vgId:%d tq push msg ver %ld, type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType));
+ tqDebug("vgId:%d tq push msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType));
if (msgType == TDMT_VND_SUBMIT) {
// lock push mgr to avoid potential msg lost
@@ -246,8 +246,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
continue;
}
if (pPushEntry->dataRsp.reqOffset.version >= ver) {
- tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId,
- pPushEntry->dataRsp.reqOffset.version, ver);
+ tqDebug("vgId:%d push entry req version %" PRId64 ", while push version %" PRId64 ", skip",
+ pTq->pVnode->config.vgId, pPushEntry->dataRsp.reqOffset.version, ver);
continue;
}
STqExecHandle* pExec = &pHandle->execHandle;
diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c
index 79d7e27642..3e59e0fd45 100644
--- a/source/dnode/vnode/src/tq/tqSink.c
+++ b/source/dnode/vnode/src/tq/tqSink.c
@@ -36,7 +36,7 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
} else {
name = buildCtbNameByGroupId(stbFullName, groupId);
}
- tqDebug("stream delete msg: groupId :%ld, name: %s", groupId, name);
+ tqDebug("stream delete msg: groupId :%" PRId64 ", name: %s", groupId, name);
SMetaReader mr = {0};
metaReaderInit(&mr, pVnode->pMeta, 0);
if (metaGetTableEntryByName(&mr, name) < 0) {
@@ -435,7 +435,8 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
continue;
}
if (mr.me.ctbEntry.suid != suid) {
- tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %ld, actual suid %ld",
+ tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %" PRId64
+ ", actual suid %" PRId64 "",
TD_VID(pVnode), ctbName, suid, mr.me.ctbEntry.suid);
metaReaderClear(&mr);
taosMemoryFree(ctbName);
@@ -446,7 +447,8 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
uid = mr.me.uid;
metaReaderClear(&mr);
- tqDebug("vgId:%d, stream write, table %s, uid %ld already exist, skip create", TD_VID(pVnode), ctbName, uid);
+ tqDebug("vgId:%d, stream write, table %s, uid %" PRId64 " already exist, skip create", TD_VID(pVnode), ctbName,
+ uid);
taosMemoryFreeClear(ctbName);
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c
index 81219e1442..20352bb502 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c
@@ -84,6 +84,7 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList
p->transferBuf = taosMemoryCalloc(p->pSchema->numOfCols, POINTER_BYTES);
if (p->transferBuf == NULL) {
+ tsdbCacherowsReaderClose(p);
return TSDB_CODE_OUT_OF_MEMORY;
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c
index 3f88d478e2..ea4e86fb78 100644
--- a/source/dnode/vnode/src/tsdb/tsdbRead.c
+++ b/source/dnode/vnode/src/tsdb/tsdbRead.c
@@ -340,7 +340,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
pIter->pLastBlockReader = taosMemoryCalloc(1, sizeof(struct SLastBlockReader));
if (pIter->pLastBlockReader == NULL) {
int32_t code = TSDB_CODE_OUT_OF_MEMORY;
- tsdbError("failed to prepare the last block iterator, code:%s %s", tstrerror(code), pReader->idStr);
+ tsdbError("failed to prepare the last block iterator, since:%s %s", tstrerror(code), pReader->idStr);
return code;
}
}
@@ -645,11 +645,11 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
int32_t total = pBlockNum->numOfLastFiles + pBlockNum->numOfBlocks;
double el = (taosGetTimestampUs() - st) / 1000.0;
- tsdbDebug("load block of %" PRIzu
- " tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed "
- "time:%.2f ms %s",
- numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el,
- pReader->idStr);
+ tsdbDebug(
+ "load block of %ld tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed "
+ "time:%.2f ms %s",
+ numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el,
+ pReader->idStr);
pReader->cost.numOfBlocks += total;
pReader->cost.headFileLoadTime += el;
@@ -2554,6 +2554,12 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
pScanInfo = pReader->status.pTableIter;
}
+ if (pScanInfo == NULL) {
+ tsdbError("failed to get table, uid:%" PRIu64 ", %s", pBlockInfo->uid, pReader->idStr);
+ code = TSDB_CODE_INVALID_PARA;
+ return code;
+ }
+
if (pBlockInfo != NULL) {
pBlock = getCurrentBlock(pBlockIter);
}
diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c
index 64df3aa1eb..6a18ae2fa1 100644
--- a/source/dnode/vnode/src/vnd/vnodeQuery.c
+++ b/source/dnode/vnode/src/vnd/vnodeQuery.c
@@ -385,6 +385,7 @@ _exit:
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
pLoad->vgId = TD_VID(pVnode);
pLoad->syncState = syncGetMyRole(pVnode->sync);
+ pLoad->syncRestore = pVnode->restored;
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c
index 4dbefd659c..be6eaccb3b 100644
--- a/source/dnode/vnode/src/vnd/vnodeSvr.c
+++ b/source/dnode/vnode/src/vnd/vnodeSvr.c
@@ -1090,7 +1090,7 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void
if (pVnode->config.szBuf != req.buffer * 1024LL * 1024LL) {
vInfo("vgId:%d vnode buffer is changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pVnode->config.szBuf,
- req.buffer * 1024LL * 1024LL);
+ (uint64_t)(req.buffer * 1024LL * 1024LL));
pVnode->config.szBuf = req.buffer * 1024LL * 1024LL;
}
diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c
index 44eee79574..6bcf603f7f 100644
--- a/source/dnode/vnode/src/vnd/vnodeSync.c
+++ b/source/dnode/vnode/src/vnd/vnodeSync.c
@@ -328,14 +328,14 @@ int32_t vnodeProcessSyncCtrlMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
const STraceId *trace = &pMsg->info.traceId;
if (!syncEnvIsStart()) {
- vGError("vgId:%d, msg:%p failed to process since sync env not start", pVnode->config.vgId);
+ vGError("vgId:%d, msg:%p failed to process since sync env not start", pVnode->config.vgId, pMsg);
terrno = TSDB_CODE_APP_ERROR;
return -1;
}
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
if (pSyncNode == NULL) {
- vGError("vgId:%d, msg:%p failed to process since invalid sync node", pVnode->config.vgId);
+ vGError("vgId:%d, msg:%p failed to process since invalid sync node", pVnode->config.vgId, pMsg);
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
return -1;
}
@@ -353,7 +353,7 @@ int32_t vnodeProcessSyncCtrlMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
syncHeartbeatReplyDestroy(pSyncMsg);
} else {
- vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg->msgType);
+ vGError("vgId:%d, msg:%p failed to process since error msg type:%d", pVnode->config.vgId, pMsg, pMsg->msgType);
code = -1;
}
diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c
index 93d36bc4b3..1f1a210699 100644
--- a/source/libs/catalog/src/ctgAsync.c
+++ b/source/libs/catalog/src/ctgAsync.c
@@ -70,8 +70,8 @@ int32_t ctgInitGetTbMetasTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
taosArrayPush(pJob->pTasks, &task);
- qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx,
- ctgTaskTypeStr(task.type), (int32_t)taosArrayGetSize(ctx->pNames), pJob->tbMetaNum);
+ qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%lu, tbNum:%d", pJob->queryId, taskIdx,
+ ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbMetaNum);
return TSDB_CODE_SUCCESS;
}
@@ -201,8 +201,8 @@ int32_t ctgInitGetTbHashsTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
taosArrayPush(pJob->pTasks, &task);
- qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx,
- ctgTaskTypeStr(task.type), (int32_t)taosArrayGetSize(ctx->pNames), pJob->tbHashNum);
+ qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%lu, tbNum:%d", pJob->queryId, taskIdx,
+ ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbHashNum);
return TSDB_CODE_SUCCESS;
}
@@ -1667,7 +1667,7 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask* pTask) {
int32_t baseResIdx = 0;
for (int32_t i = 0; i < dbNum; ++i) {
STablesReq* pReq = taosArrayGet(pCtx->pNames, i);
- ctgDebug("start to check tb metas in db %s, tbNum %d", pReq->dbFName, (int32_t)taosArrayGetSize(pReq->pTables));
+ ctgDebug("start to check tb metas in db %s, tbNum %ld", pReq->dbFName, taosArrayGetSize(pReq->pTables));
CTG_ERR_RET(ctgGetTbMetasFromCache(pCtg, pConn, pCtx, i, &fetchIdx, baseResIdx, pReq->pTables));
baseResIdx += taosArrayGetSize(pReq->pTables);
}
diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c
index a462d9d61d..c02b5d2c50 100644
--- a/source/libs/executor/src/dataDeleter.c
+++ b/source/libs/executor/src/dataDeleter.c
@@ -103,7 +103,7 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
}
- qDebug("delete %ld rows, from %ld to %ld", pRes->affectedRows, pRes->skey, pRes->ekey);
+ qDebug("delete %" PRId64 " rows, from %" PRId64 " to %" PRId64 "", pRes->affectedRows, pRes->skey, pRes->ekey);
pBuf->useSize += pEntry->dataLen;
diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c
index 79f6166079..bf24fe3a3e 100644
--- a/source/libs/executor/src/executil.c
+++ b/source/libs/executor/src/executil.c
@@ -930,7 +930,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
int64_t* uid = taosArrayGet(res, i);
- qDebug("tagfilter get uid:%ld, res:%d", *uid, *(bool*)var);
+ qDebug("tagfilter get uid:%" PRId64 ", res:%d", *uid, *(bool*)var);
if (*(bool*)var == false) {
taosArrayRemove(res, i);
j++;
@@ -952,7 +952,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
return TSDB_CODE_OUT_OF_MEMORY;
}
- qDebug("tagfilter get uid:%ld", info.uid);
+ qDebug("tagfilter get uid:%" PRId64 "", info.uid);
}
taosArrayDestroy(res);
diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c
index 0d861c1fb9..c60c8ff301 100644
--- a/source/libs/executor/src/executor.c
+++ b/source/libs/executor/src/executor.c
@@ -250,6 +250,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
qDebug(" %d qualified child tables added into stream scanner", (int32_t)taosArrayGetSize(qa));
code = tqReaderAddTbUidList(pScanInfo->tqReader, qa);
if (code != TSDB_CODE_SUCCESS) {
+ taosArrayDestroy(qa);
return code;
}
@@ -261,6 +262,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
assignUid = groupbyTbname(pScanInfo->pGroupTags);
keyBuf = taosMemoryMalloc(bufLen);
if (keyBuf == NULL) {
+ taosArrayDestroy(qa);
return TSDB_CODE_OUT_OF_MEMORY;
}
}
@@ -277,6 +279,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
&keyInfo.groupId);
if (code != TSDB_CODE_SUCCESS) {
taosMemoryFree(keyBuf);
+ taosArrayDestroy(qa);
return code;
}
}
@@ -298,8 +301,6 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
taosHashPut(pTaskInfo->tableqinfoList.map, uid, sizeof(*uid), &keyInfo.groupId, sizeof(keyInfo.groupId));
}
- /*}*/
-
if (keyBuf != NULL) {
taosMemoryFree(keyBuf);
}
@@ -857,7 +858,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema);
pTaskInfo->streamInfo.schema = mtInfo.schema;
- qDebug("tmqsnap qStreamPrepareScan snapshot data uid %ld ts %"PRId64, mtInfo.uid, pOffset->ts);
+ qDebug("tmqsnap qStreamPrepareScan snapshot data uid %" PRId64 " ts %" PRId64, mtInfo.uid, pOffset->ts);
} else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) {
SStreamRawScanInfo* pInfo = pOperator->info;
SSnapContext* sContext = pInfo->sContext;
@@ -865,7 +866,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version);
return -1;
}
- qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %"PRId64, pOffset->uid, pOffset->ts);
+ qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %" PRId64 " ts %" PRId64, pOffset->uid, pOffset->ts);
} else if (pOffset->type == TMQ_OFFSET__LOG) {
SStreamRawScanInfo* pInfo = pOperator->info;
tsdbReaderClose(pInfo->dataReader);
diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c
index ea91cc06c8..feced8dc60 100644
--- a/source/libs/executor/src/executorimpl.c
+++ b/source/libs/executor/src/executorimpl.c
@@ -462,6 +462,7 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc
for (int32_t i = 0; i < numOfRows; ++i) {
colDataAppend(pColInfo, i, tmp, false);
}
+ taosMemoryFree(tmp);
}
return TSDB_CODE_SUCCESS;
@@ -1775,7 +1776,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
} else {
taosMemoryFree(pMsg->pData);
pSourceDataInfo->code = code;
- qDebug("%s fetch rsp received, index:%d, code:%s", pSourceDataInfo->taskId, index, tstrerror(code));
+ qDebug("%s fetch rsp received, index:%d, error:%s", pSourceDataInfo->taskId, index, tstrerror(code));
}
pSourceDataInfo->status = EX_SOURCE_DATA_READY;
diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c
index e62f72c8f8..4ca4ef7b3f 100644
--- a/source/libs/executor/src/groupoperator.c
+++ b/source/libs/executor/src/groupoperator.c
@@ -757,7 +757,6 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
goto _error;
}
- SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc);
int32_t numOfCols = 0;
SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols);
@@ -781,14 +780,18 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
uint32_t defaultPgsz = 0;
uint32_t defaultBufsz = 0;
+
+ SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc);
getBufferPgSize(pResBlock->info.rowSize, &defaultPgsz, &defaultBufsz);
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK;
pTaskInfo->code = terrno;
qError("Create partition operator info failed since %s", terrstr(terrno));
+ blockDataDestroy(pResBlock);
goto _error;
}
+
int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
@@ -819,7 +822,9 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
_error:
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
- taosMemoryFreeClear(pInfo);
+ if (pInfo != NULL) {
+ destroyPartitionOperatorInfo(pInfo);
+ }
taosMemoryFreeClear(pOperator);
return NULL;
}
diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c
index 7385e9bb92..058b9b1b44 100644
--- a/source/libs/executor/src/scanoperator.c
+++ b/source/libs/executor/src/scanoperator.c
@@ -737,7 +737,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
int32_t numOfCols = 0;
- SArray* pColList = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
+ pInfo->pColMatchInfo = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
if (code != TSDB_CODE_SUCCESS) {
@@ -765,7 +765,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
}
pInfo->scanFlag = MAIN_SCAN;
- pInfo->pColMatchInfo = pColList;
pInfo->currentGroupId = -1;
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
@@ -1550,7 +1549,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
tsdbReaderClose(pTSInfo->dataReader);
pTSInfo->dataReader = NULL;
tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer);
- qDebug("queue scan tsdb over, switch to wal ver %"PRId64, pTaskInfo->streamInfo.snapshotVer + 1);
+ qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1);
if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) {
return NULL;
}
@@ -1768,8 +1767,9 @@ FETCH_NEXT_BLOCK:
generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes);
pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
printDataBlock(pDelBlock, "stream scan delete result");
+ blockDataDestroy(pDelBlock);
+
if (pInfo->pDeleteDataRes->info.rows > 0) {
- blockDataDestroy(pDelBlock);
return pInfo->pDeleteDataRes;
} else {
goto FETCH_NEXT_BLOCK;
@@ -1982,7 +1982,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
longjmp(pTaskInfo->env, terrno);
}
- qDebug("tmqsnap doRawScan get data uid:%ld", pBlock->info.uid);
+ qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.uid);
pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA;
pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.uid;
pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey;
@@ -1998,7 +1998,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
} else {
pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid;
pTaskInfo->streamInfo.prepareStatus.ts = INT64_MIN;
- qDebug("tmqsnap change get data uid:%ld", mtInfo.uid);
+ qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid);
qStreamPrepareScan(pTaskInfo, &pTaskInfo->streamInfo.prepareStatus, pInfo->sContext->subType);
}
tDeleteSSchemaWrapper(mtInfo.schema);
@@ -2090,24 +2090,30 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT
// create meta reader
// create tq reader
+ int32_t code = TSDB_CODE_SUCCESS;
+
SStreamRawScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamRawScanInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) {
- terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
- return NULL;
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _end;
}
pInfo->vnode = pHandle->vnode;
pInfo->sContext = pHandle->sContext;
pOperator->name = "RawStreamScanOperator";
- // pOperator->blocking = false;
- // pOperator->status = OP_NOT_OPENED;
pOperator->info = pInfo;
pOperator->pTaskInfo = pTaskInfo;
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL, NULL, NULL);
return pOperator;
+
+ _end:
+ taosMemoryFree(pInfo);
+ taosMemoryFree(pOperator);
+ pTaskInfo->code = code;
+ return NULL;
}
static void destroyStreamScanOperatorInfo(void* param) {
@@ -2285,7 +2291,14 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
return pOperator;
_error:
- taosMemoryFreeClear(pInfo);
+ if (pColIds != NULL) {
+ taosArrayDestroy(pColIds);
+ }
+
+ if (pInfo != NULL) {
+ destroyStreamScanOperatorInfo(pInfo);
+ }
+
taosMemoryFreeClear(pOperator);
return NULL;
}
@@ -3333,7 +3346,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
int64_t st = taosGetTimestampUs();
if (pHandle == NULL) {
- qError("invalid handle, in creating operator tree", idStr);
+ qError("invalid handle, in creating operator tree, %s", idStr);
return TSDB_CODE_INVALID_PARA;
}
diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c
index 599e46c5fc..98a46fd4eb 100644
--- a/source/libs/executor/src/tfill.c
+++ b/source/libs/executor/src/tfill.c
@@ -467,9 +467,11 @@ struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t
case FILL_MODE_VALUE:
pFillInfo->type = TSDB_FILL_SET_VALUE;
break;
- default:
+ default: {
+ taosMemoryFree(pFillInfo);
terrno = TSDB_CODE_INVALID_PARA;
return NULL;
+ }
}
pFillInfo->type = fillType;
diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c
index add5f44847..505654d967 100644
--- a/source/libs/executor/src/timewindowoperator.c
+++ b/source/libs/executor/src/timewindowoperator.c
@@ -2669,14 +2669,13 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
int32_t num = 0;
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num);
- SSDataBlock* pResBlock = createResDataBlock(pStateNode->window.node.pOutputDataBlockDesc);
-
initResultSizeInfo(&pOperator->resultInfo, 4096);
int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
+ SSDataBlock* pResBlock = createResDataBlock(pStateNode->window.node.pOutputDataBlockDesc);
initBasicInfo(&pInfo->binfo, pResBlock);
initResultRowInfo(&pInfo->binfo.resultRowInfo);
@@ -2704,7 +2703,10 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
return pOperator;
_error:
- destroyStateWindowOperatorInfo(pInfo);
+ if (pInfo != NULL) {
+ destroyStateWindowOperatorInfo(pInfo);
+ }
+
taosMemoryFreeClear(pOperator);
pTaskInfo->code = code;
return NULL;
@@ -4973,9 +4975,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
goto _error;
}
- int32_t num = 0;
- SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num);
- SSDataBlock* pResBlock = createResDataBlock(pNode->window.node.pOutputDataBlockDesc);
+
SInterval interval = {.interval = pNode->interval,
.sliding = pNode->sliding,
@@ -4999,11 +4999,14 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
initResultSizeInfo(&pOperator->resultInfo, 4096);
- int32_t code = initAggInfo(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
+ int32_t num = 0;
+ SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num);
+ int32_t code = initAggInfo(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
+ SSDataBlock* pResBlock = createResDataBlock(pNode->window.node.pOutputDataBlockDesc);
initBasicInfo(&iaInfo->binfo, pResBlock);
initExecTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &iaInfo->win);
diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c
index b66a6f6770..a5168d24ba 100644
--- a/source/libs/executor/src/tsimplehash.c
+++ b/source/libs/executor/src/tsimplehash.c
@@ -105,8 +105,8 @@ static void tSimpleHashTableResize(SSHashObj *pHashObj) {
int32_t newCapacity = (int32_t)(pHashObj->capacity << 1u);
if (newCapacity > HASH_MAX_CAPACITY) {
- uDebug("current capacity:%"PRIzu", maximum capacity:%" PRIu64 ", no resize applied due to limitation is reached",
- pHashObj->capacity, HASH_MAX_CAPACITY);
+ uDebug("current capacity:%" PRIzu ", maximum capacity:%" PRId32 ", no resize applied due to limitation is reached",
+ pHashObj->capacity, (int32_t)HASH_MAX_CAPACITY);
return;
}
@@ -388,4 +388,4 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
}
return NULL;
-}
\ No newline at end of file
+}
diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c
index 85582cbd39..03248f5069 100644
--- a/source/libs/executor/src/tsort.c
+++ b/source/libs/executor/src/tsort.c
@@ -181,6 +181,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
blockDataSplitRows(pDataBlock, pDataBlock->info.hasVarCol, start, &stop, pHandle->pageSize);
SSDataBlock* p = blockDataExtractBlock(pDataBlock, start, stop - start + 1);
if (p == NULL) {
+ taosArrayDestroy(pPageIdList);
return terrno;
}
@@ -422,7 +423,7 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId);
bool rightNull = false;
if (pRightColInfoData->hasNull) {
- if (pLeftBlock->pBlockAgg == NULL) {
+ if (pRightBlock->pBlockAgg == NULL) {
rightNull = colDataIsNull_s(pRightColInfoData, pRightSource->src.rowIndex);
} else {
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex,
diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c
index 874822106e..49b2168dff 100644
--- a/source/libs/function/src/builtinsimpl.c
+++ b/source/libs/function/src/builtinsimpl.c
@@ -2545,7 +2545,7 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
// might be a race condition here that pHisto can be overwritten or setup function
// has not been called, need to relink the buffer pHisto points to.
buildHistogramInfo(pInfo);
- qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
+ qDebug("%s before add %d elements into histogram, total:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
if (colDataIsNull_f(pCol->nullbitmap, i)) {
@@ -2559,8 +2559,9 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
tHistogramAdd(&pInfo->pHisto, v);
}
- qDebug("%s after add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
- numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
+ qDebug("%s after add %d elements into histogram, total:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems: %p",
+ __FUNCTION__, numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto,
+ pInfo->pHisto->elems);
}
SET_VAL(pResInfo, numOfElems, 1);
@@ -2640,7 +2641,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
}
if (pInfo->algo != APERCT_ALGO_TDIGEST) {
- qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems,
+ qDebug("%s after merge, total:%" PRId64 ", numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems,
pInfo->pHisto->numOfEntries, pInfo->pHisto);
}
@@ -6186,99 +6187,6 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return pResInfo->numOfRes;
}
-int32_t interpFunction(SqlFunctionCtx* pCtx) {
-#if 0
- int32_t fillType = (int32_t) pCtx->param[2].i64;
- //bool ascQuery = (pCtx->order == TSDB_ORDER_ASC);
-
- if (pCtx->start.key == pCtx->startTs) {
- assert(pCtx->start.key != INT64_MIN);
-
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->start.val);
-
- goto interp_success_exit;
- } else if (pCtx->end.key == pCtx->startTs && pCtx->end.key != INT64_MIN && fillType == TSDB_FILL_NEXT) {
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val);
-
- goto interp_success_exit;
- }
-
- switch (fillType) {
- case TSDB_FILL_NULL:
- setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes);
- break;
-
- case TSDB_FILL_SET_VALUE:
- tVariantDump(&pCtx->param[1], pCtx->pOutput, pCtx->inputType, true);
- break;
-
- case TSDB_FILL_LINEAR:
- if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
- || pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
- goto interp_exit;
- }
-
- double v1 = -1, v2 = -1;
- GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
- GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
-
- SPoint point1 = {.key = pCtx->start.key, .val = &v1};
- SPoint point2 = {.key = pCtx->end.key, .val = &v2};
- SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
-
- int32_t srcType = pCtx->inputType;
- if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
- setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
- } else {
- bool exceedMax = false, exceedMin = false;
- taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
- if (exceedMax || exceedMin) {
- __compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
- if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
- } else {
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
- }
- }
- }
- break;
-
- case TSDB_FILL_PREV:
- if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs) {
- goto interp_exit;
- }
-
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->start.val);
- break;
-
- case TSDB_FILL_NEXT:
- if (pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
- goto interp_exit;
- }
-
- COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val);
- break;
-
- case TSDB_FILL_NONE:
- // do nothing
- default:
- goto interp_exit;
- }
-
-
- interp_success_exit:
- *(TSKEY*)pCtx->ptsOutputBuf = pCtx->startTs;
- INC_INIT_VAL(pCtx, 1);
-
- interp_exit:
- pCtx->start.key = INT64_MIN;
- pCtx->end.key = INT64_MIN;
- pCtx->endTs = pCtx->startTs;
-#endif
-
- return TSDB_CODE_SUCCESS;
-}
-
int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx) {
int32_t numOfElems = 0;
diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c
index 1483394509..5b8389078f 100644
--- a/source/libs/function/src/tudf.c
+++ b/source/libs/function/src/tudf.c
@@ -1269,7 +1269,7 @@ void udfcUvHandleRsp(SClientUvConn *conn) {
SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, connTaskQueue);
while (h != &conn->taskQueue) {
- fnDebug("udfc handle response iterate through queue. uvTask:%d-%p", task->seqNum, task);
+ fnDebug("udfc handle response iterate through queue. uvTask:%" PRId64 "-%p", task->seqNum, task);
if (task->seqNum == seqNum) {
if (found == false) {
found = true;
diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c
index bbee8b1166..dd371f874c 100644
--- a/source/libs/monitor/src/monMsg.c
+++ b/source/libs/monitor/src/monMsg.c
@@ -509,7 +509,8 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo)
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pVloads); ++i) {
SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i);
if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1;
- if (tEncodeI32(&encoder, pLoad->syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pLoad->syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pLoad->syncRestore) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->cacheUsage) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1;
@@ -544,7 +545,8 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf
for (int32_t i = 0; i < arraySize; ++i) {
SVnodeLoad load = {0};
if (tDecodeI32(&decoder, &load.vgId) < 0) return -1;
- if (tDecodeI32(&decoder, &load.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &load.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &load.syncRestore) < 0) return -1;
if (tDecodeI64(&decoder, &load.cacheUsage) < 0) return -1;
if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1;
if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1;
@@ -575,7 +577,8 @@ int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo)
if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI8(&encoder, pInfo->isMnode) < 0) return -1;
- if (tEncodeI32(&encoder, pInfo->load.syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pInfo->load.syncState) < 0) return -1;
+ if (tEncodeI8(&encoder, pInfo->load.syncRestore) < 0) return -1;
tEndEncode(&encoder);
int32_t tlen = encoder.pos;
@@ -589,7 +592,8 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf
if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI8(&decoder, &pInfo->isMnode) < 0) return -1;
- if (tDecodeI32(&decoder, &pInfo->load.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &pInfo->load.syncState) < 0) return -1;
+ if (tDecodeI8(&decoder, &pInfo->load.syncRestore) < 0) return -1;
tEndDecode(&decoder);
tDecoderClear(&decoder);
diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c
index 3df16563e2..001a1972a0 100644
--- a/source/libs/qworker/src/qworker.c
+++ b/source/libs/qworker/src/qworker.c
@@ -258,7 +258,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
dsGetDataLength(ctx->sinkHandle, &len, &queryEnd);
if (len < 0) {
- QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64, len);
+ QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64 "", len);
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
@@ -292,7 +292,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
}
// Got data from sink
- QW_TASK_DLOG("there are data in sink, dataLength:%" PRId64, len);
+ QW_TASK_DLOG("there are data in sink, dataLength:%" PRId64 "", len);
*dataLen += len;
diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c
index 4a35a15d3e..939dcac3d6 100644
--- a/source/libs/sync/src/syncAppendEntries.c
+++ b/source/libs/sync/src/syncAppendEntries.c
@@ -408,7 +408,7 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) {
do {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "update delete begin to %ld", delBegin);
+ snprintf(logBuf, sizeof(logBuf), "update delete begin to %" PRId64, delBegin);
syncNodeEventLog(ths, logBuf);
} while (0);
}
@@ -419,7 +419,8 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) {
do {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "make log same from:%ld, delbegin:%ld, pass:%d", FromIndex, delBegin, pass);
+ snprintf(logBuf, sizeof(logBuf), "make log same from:%" PRId64 ", delbegin:%" PRId64 ", pass:%d", FromIndex,
+ delBegin, pass);
syncNodeEventLog(ths, logBuf);
} while (0);
diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c
index 511113352e..6239726823 100644
--- a/source/libs/sync/src/syncCommit.c
+++ b/source/libs/sync/src/syncCommit.c
@@ -77,8 +77,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
} else {
pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index);
if (pEntry == NULL) {
- sError("failed to get entry since %s. index:%lld", tstrerror(terrno), index);
- return;
+ sError("failed to get entry since %s. index:%" PRId64, tstrerror(terrno), index);
+ return;
}
}
// cannot commit, even if quorum agree. need check term!
diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c
index 28b5313ac5..fcbf4a9032 100644
--- a/source/libs/sync/src/syncIndexMgr.c
+++ b/source/libs/sync/src/syncIndexMgr.c
@@ -200,28 +200,28 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa
// for debug -------------------
void syncIndexMgrPrint(SSyncIndexMgr *pObj) {
char *serialized = syncIndexMgr2Str(pObj);
- printf("syncIndexMgrPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncIndexMgrPrint | len:%" PRIu64 " | %s \n", (uint64_t)strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncIndexMgrPrint2(char *s, SSyncIndexMgr *pObj) {
char *serialized = syncIndexMgr2Str(pObj);
- printf("syncIndexMgrPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncIndexMgrPrint2 | len:%" PRIu64 " | %s | %s \n", (uint64_t)strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncIndexMgrLog(SSyncIndexMgr *pObj) {
char *serialized = syncIndexMgr2Str(pObj);
- sTrace("syncIndexMgrLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncIndexMgrLog | len:%" PRIu64 " | %s", (uint64_t)strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncIndexMgrLog2(char *s, SSyncIndexMgr *pObj) {
if (gRaftDetailLog) {
char *serialized = syncIndexMgr2Str(pObj);
- sTrace("syncIndexMgrLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncIndexMgrLog2 | len:%" PRIu64 " | %s | %s", (uint64_t)strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c
index 8ccfce603d..2a0c5d9d7c 100644
--- a/source/libs/sync/src/syncMain.c
+++ b/source/libs/sync/src/syncMain.c
@@ -67,7 +67,7 @@ int32_t syncInit() {
syncCleanUp();
ret = -1;
} else {
- sDebug("sync rsetId:%" PRId64 " is open", tsNodeRefId);
+ sDebug("sync rsetId:%" PRId32 " is open", tsNodeRefId);
ret = syncEnvStart();
}
}
@@ -80,7 +80,7 @@ void syncCleanUp() {
ASSERT(ret == 0);
if (tsNodeRefId != -1) {
- sDebug("sync rsetId:%" PRId64 " is closed", tsNodeRefId);
+ sDebug("sync rsetId:%" PRId32 " is closed", tsNodeRefId);
taosCloseRef(tsNodeRefId);
tsNodeRefId = -1;
}
@@ -100,7 +100,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) {
return -1;
}
- sDebug("vgId:%d, sync rid:%" PRId64 " is added to rsetId:%" PRId64, pSyncInfo->vgId, pSyncNode->rid, tsNodeRefId);
+ sDebug("vgId:%d, sync rid:%" PRId64 " is added to rsetId:%" PRId32, pSyncInfo->vgId, pSyncNode->rid, tsNodeRefId);
return pSyncNode->rid;
}
@@ -146,7 +146,7 @@ void syncStop(int64_t rid) {
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
taosRemoveRef(tsNodeRefId, rid);
- sDebug("vgId:%d, sync rid:%" PRId64 " is removed from rsetId:%" PRId64, vgId, rid, tsNodeRefId);
+ sDebug("vgId:%d, sync rid:%" PRId64 " is removed from rsetId:%" PRId64, vgId, rid, (int64_t)tsNodeRefId);
}
int32_t syncSetStandby(int64_t rid) {
@@ -316,7 +316,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
}
do {
- char logBuf[128];
+ char logBuf[256];
snprintf(logBuf, sizeof(logBuf), "begin leader transfer to %s:%u", newLeader.nodeFqdn, newLeader.nodePort);
syncNodeEventLog(pSyncNode, logBuf);
} while (0);
@@ -867,8 +867,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
if (!pSyncNode->restoreFinish && pSyncNode->vgId != 1) {
ret = -1;
terrno = TSDB_CODE_SYN_PROPOSE_NOT_READY;
- sError("vgId:%d, failed to sync propose since not ready, type:%s, last:%ld, cmt:%ld", pSyncNode->vgId,
- TMSG_INFO(pMsg->msgType), syncNodeGetLastIndex(pSyncNode), pSyncNode->commitIndex);
+ sError("vgId:%d, failed to sync propose since not ready, type:%s, last:%" PRId64 ", cmt:%" PRId64 "",
+ pSyncNode->vgId, TMSG_INFO(pMsg->msgType), syncNodeGetLastIndex(pSyncNode), pSyncNode->commitIndex);
goto _END;
}
@@ -2475,35 +2475,35 @@ int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex
// for debug --------------
void syncNodePrint(SSyncNode* pObj) {
char* serialized = syncNode2Str(pObj);
- printf("syncNodePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncNodePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncNodePrint2(char* s, SSyncNode* pObj) {
char* serialized = syncNode2Str(pObj);
- printf("syncNodePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncNodePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncNodeLog(SSyncNode* pObj) {
char* serialized = syncNode2Str(pObj);
- sTraceLong("syncNodeLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTraceLong("syncNodeLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncNodeLog2(char* s, SSyncNode* pObj) {
if (gRaftDetailLog) {
char* serialized = syncNode2Str(pObj);
- sTraceLong("syncNodeLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("syncNodeLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
void syncNodeLog3(char* s, SSyncNode* pObj) {
char* serialized = syncNode2Str(pObj);
- sTraceLong("syncNodeLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("syncNodeLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
@@ -2919,14 +2919,14 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
if (pEntry->term < ths->pRaftStore->currentTerm) {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "little term:%lu, can not do leader transfer", pEntry->term);
+ snprintf(logBuf, sizeof(logBuf), "little term:%" PRIu64 ", can not do leader transfer", pEntry->term);
syncNodeEventLog(ths, logBuf);
return 0;
}
if (pEntry->index < syncNodeGetLastIndex(ths)) {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "little index:%ld, can not do leader transfer", pEntry->index);
+ snprintf(logBuf, sizeof(logBuf), "little index:%" PRId64 ", can not do leader transfer", pEntry->index);
syncNodeEventLog(ths, logBuf);
return 0;
}
@@ -2942,7 +2942,7 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
do {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "do leader transfer, index:%ld", pEntry->index);
+ snprintf(logBuf, sizeof(logBuf), "do leader transfer, index:%" PRId64 "", pEntry->index);
syncNodeEventLog(ths, logBuf);
} while (0);
@@ -3122,9 +3122,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
} else {
code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry);
if (code != 0) {
- sError("vgId:%d, failed to get log entry since %s. index:%lld", ths->vgId, tstrerror(terrno), i);
+ sError("vgId:%d, failed to get log entry since %s. index:%" PRId64 "", ths->vgId, tstrerror(terrno), i);
return -1;
- }
+ }
ASSERT(pEntry != NULL);
}
@@ -3203,8 +3203,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
int64_t restoreDelay = taosGetTimestampMs() - ths->leaderTime;
char eventLog[128];
- snprintf(eventLog, sizeof(eventLog), "restore finish, index:%ld, elapsed:%ld ms, ", pEntry->index,
- restoreDelay);
+ snprintf(eventLog, sizeof(eventLog), "restore finish, index:%" PRId64 ", elapsed:%" PRId64 " ms, ",
+ pEntry->index, restoreDelay);
syncNodeEventLog(ths, eventLog);
}
}
@@ -3427,4 +3427,4 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p
snprintf(logBuf, sizeof(logBuf), "recv sync-heartbeat-reply from %s:%d {term:%" PRIu64 ", pterm:%" PRIu64 "}, %s",
host, port, pMsg->term, pMsg->privateTerm, s);
syncNodeEventLog(pSyncNode, logBuf);
-}
\ No newline at end of file
+}
diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c
index faebe5bbec..7c871d0542 100644
--- a/source/libs/sync/src/syncMessage.c
+++ b/source/libs/sync/src/syncMessage.c
@@ -133,28 +133,28 @@ char* syncRpcMsg2Str(SRpcMsg* pRpcMsg) {
// for debug ----------------------
void syncRpcMsgPrint(SRpcMsg* pMsg) {
char* serialized = syncRpcMsg2Str(pMsg);
- printf("syncRpcMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncRpcMsgPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRpcMsgPrint2(char* s, SRpcMsg* pMsg) {
char* serialized = syncRpcMsg2Str(pMsg);
- printf("syncRpcMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncRpcMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRpcMsgLog(SRpcMsg* pMsg) {
char* serialized = syncRpcMsg2Str(pMsg);
- sTrace("syncRpcMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncRpcMsgLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncRpcMsgLog2(char* s, SRpcMsg* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncRpcMsg2Str(pMsg);
- sTrace("syncRpcMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncRpcMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -271,21 +271,21 @@ void syncTimeoutPrint(const SyncTimeout* pMsg) {
void syncTimeoutPrint2(char* s, const SyncTimeout* pMsg) {
char* serialized = syncTimeout2Str(pMsg);
- printf("syncTimeoutPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncTimeoutPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncTimeoutLog(const SyncTimeout* pMsg) {
char* serialized = syncTimeout2Str(pMsg);
- sTrace("syncTimeoutLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncTimeoutLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncTimeoutLog2(char* s, const SyncTimeout* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncTimeout2Str(pMsg);
- sTrace("syncTimeoutLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncTimeoutLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -526,28 +526,28 @@ char* syncPing2Str(const SyncPing* pMsg) {
// for debug ----------------------
void syncPingPrint(const SyncPing* pMsg) {
char* serialized = syncPing2Str(pMsg);
- printf("syncPingPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncPingPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncPingPrint2(char* s, const SyncPing* pMsg) {
char* serialized = syncPing2Str(pMsg);
- printf("syncPingPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncPingPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncPingLog(const SyncPing* pMsg) {
char* serialized = syncPing2Str(pMsg);
- sTrace("syncPingLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncPingLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncPingLog2(char* s, const SyncPing* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncPing2Str(pMsg);
- sTrace("syncPingLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncPingLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -931,28 +931,28 @@ char* syncClientRequest2Str(const SyncClientRequest* pMsg) {
// for debug ----------------------
void syncClientRequestPrint(const SyncClientRequest* pMsg) {
char* serialized = syncClientRequest2Str(pMsg);
- printf("syncClientRequestPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncClientRequestPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg) {
char* serialized = syncClientRequest2Str(pMsg);
- printf("syncClientRequestPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncClientRequestPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncClientRequestLog(const SyncClientRequest* pMsg) {
char* serialized = syncClientRequest2Str(pMsg);
- sTrace("syncClientRequestLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncClientRequestLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncClientRequest2Str(pMsg);
- sTrace("syncClientRequestLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncClientRequestLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1101,28 +1101,28 @@ char* syncClientRequestBatch2Str(const SyncClientRequestBatch* pMsg) {
// for debug ----------------------
void syncClientRequestBatchPrint(const SyncClientRequestBatch* pMsg) {
char* serialized = syncClientRequestBatch2Str(pMsg);
- printf("syncClientRequestBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncClientRequestBatchPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncClientRequestBatchPrint2(char* s, const SyncClientRequestBatch* pMsg) {
char* serialized = syncClientRequestBatch2Str(pMsg);
- printf("syncClientRequestBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncClientRequestBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncClientRequestBatchLog(const SyncClientRequestBatch* pMsg) {
char* serialized = syncClientRequestBatch2Str(pMsg);
- sTrace("syncClientRequestBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncClientRequestBatchLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncClientRequestBatchLog2(char* s, const SyncClientRequestBatch* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncClientRequestBatch2Str(pMsg);
- sTraceLong("syncClientRequestBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("syncClientRequestBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1252,28 +1252,28 @@ char* syncRequestVote2Str(const SyncRequestVote* pMsg) {
// for debug ----------------------
void syncRequestVotePrint(const SyncRequestVote* pMsg) {
char* serialized = syncRequestVote2Str(pMsg);
- printf("syncRequestVotePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncRequestVotePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRequestVotePrint2(char* s, const SyncRequestVote* pMsg) {
char* serialized = syncRequestVote2Str(pMsg);
- printf("syncRequestVotePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncRequestVotePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRequestVoteLog(const SyncRequestVote* pMsg) {
char* serialized = syncRequestVote2Str(pMsg);
- sTrace("syncRequestVoteLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncRequestVoteLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncRequestVoteLog2(char* s, const SyncRequestVote* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncRequestVote2Str(pMsg);
- sTrace("syncRequestVoteLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncRequestVoteLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1400,28 +1400,28 @@ char* syncRequestVoteReply2Str(const SyncRequestVoteReply* pMsg) {
// for debug ----------------------
void syncRequestVoteReplyPrint(const SyncRequestVoteReply* pMsg) {
char* serialized = syncRequestVoteReply2Str(pMsg);
- printf("syncRequestVoteReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncRequestVoteReplyPrint | len:%ld | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRequestVoteReplyPrint2(char* s, const SyncRequestVoteReply* pMsg) {
char* serialized = syncRequestVoteReply2Str(pMsg);
- printf("syncRequestVoteReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncRequestVoteReplyPrint2 | len:%ld | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncRequestVoteReplyLog(const SyncRequestVoteReply* pMsg) {
char* serialized = syncRequestVoteReply2Str(pMsg);
- sTrace("syncRequestVoteReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncRequestVoteReplyLog | len:%ld | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncRequestVoteReplyLog2(char* s, const SyncRequestVoteReply* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncRequestVoteReply2Str(pMsg);
- sTrace("syncRequestVoteReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncRequestVoteReplyLog2 | len:%ld | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1571,28 +1571,28 @@ char* syncAppendEntries2Str(const SyncAppendEntries* pMsg) {
// for debug ----------------------
void syncAppendEntriesPrint(const SyncAppendEntries* pMsg) {
char* serialized = syncAppendEntries2Str(pMsg);
- printf("syncAppendEntriesPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncAppendEntriesPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesPrint2(char* s, const SyncAppendEntries* pMsg) {
char* serialized = syncAppendEntries2Str(pMsg);
- printf("syncAppendEntriesPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncAppendEntriesPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesLog(const SyncAppendEntries* pMsg) {
char* serialized = syncAppendEntries2Str(pMsg);
- sTrace("syncAppendEntriesLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncAppendEntriesLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncAppendEntries2Str(pMsg);
- sTrace("syncAppendEntriesLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncAppendEntriesLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1810,28 +1810,28 @@ char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg) {
// for debug ----------------------
void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg) {
char* serialized = syncAppendEntriesBatch2Str(pMsg);
- printf("syncAppendEntriesBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncAppendEntriesBatchPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg) {
char* serialized = syncAppendEntriesBatch2Str(pMsg);
- printf("syncAppendEntriesBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncAppendEntriesBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg) {
char* serialized = syncAppendEntriesBatch2Str(pMsg);
- sTrace("syncAppendEntriesBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncAppendEntriesBatchLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncAppendEntriesBatch2Str(pMsg);
- sTraceLong("syncAppendEntriesBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("syncAppendEntriesBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -1966,28 +1966,28 @@ char* syncAppendEntriesReply2Str(const SyncAppendEntriesReply* pMsg) {
// for debug ----------------------
void syncAppendEntriesReplyPrint(const SyncAppendEntriesReply* pMsg) {
char* serialized = syncAppendEntriesReply2Str(pMsg);
- printf("syncAppendEntriesReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncAppendEntriesReplyPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesReplyPrint2(char* s, const SyncAppendEntriesReply* pMsg) {
char* serialized = syncAppendEntriesReply2Str(pMsg);
- printf("syncAppendEntriesReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncAppendEntriesReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncAppendEntriesReplyLog(const SyncAppendEntriesReply* pMsg) {
char* serialized = syncAppendEntriesReply2Str(pMsg);
- sTrace("syncAppendEntriesReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncAppendEntriesReplyLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncAppendEntriesReplyLog2(char* s, const SyncAppendEntriesReply* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncAppendEntriesReply2Str(pMsg);
- sTrace("syncAppendEntriesReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncAppendEntriesReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2119,28 +2119,28 @@ char* syncHeartbeat2Str(const SyncHeartbeat* pMsg) {
void syncHeartbeatPrint(const SyncHeartbeat* pMsg) {
char* serialized = syncHeartbeat2Str(pMsg);
- printf("syncHeartbeatPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncHeartbeatPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncHeartbeatPrint2(char* s, const SyncHeartbeat* pMsg) {
char* serialized = syncHeartbeat2Str(pMsg);
- printf("syncHeartbeatPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncHeartbeatPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncHeartbeatLog(const SyncHeartbeat* pMsg) {
char* serialized = syncHeartbeat2Str(pMsg);
- sTrace("syncHeartbeatLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncHeartbeatLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncHeartbeatLog2(char* s, const SyncHeartbeat* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncHeartbeat2Str(pMsg);
- sTrace("syncHeartbeatLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncHeartbeatLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2273,28 +2273,28 @@ char* syncHeartbeatReply2Str(const SyncHeartbeatReply* pMsg) {
void syncHeartbeatReplyPrint(const SyncHeartbeatReply* pMsg) {
char* serialized = syncHeartbeatReply2Str(pMsg);
- printf("syncHeartbeatReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncHeartbeatReplyPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncHeartbeatReplyPrint2(char* s, const SyncHeartbeatReply* pMsg) {
char* serialized = syncHeartbeatReply2Str(pMsg);
- printf("syncHeartbeatReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncHeartbeatReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg) {
char* serialized = syncHeartbeatReply2Str(pMsg);
- sTrace("syncHeartbeatReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncHeartbeatReplyLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncHeartbeatReply2Str(pMsg);
- sTrace("syncHeartbeatReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncHeartbeatReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2426,28 +2426,28 @@ char* syncApplyMsg2Str(const SyncApplyMsg* pMsg) {
// for debug ----------------------
void syncApplyMsgPrint(const SyncApplyMsg* pMsg) {
char* serialized = syncApplyMsg2Str(pMsg);
- printf("syncApplyMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncApplyMsgPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncApplyMsgPrint2(char* s, const SyncApplyMsg* pMsg) {
char* serialized = syncApplyMsg2Str(pMsg);
- printf("syncApplyMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncApplyMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncApplyMsgLog(const SyncApplyMsg* pMsg) {
char* serialized = syncApplyMsg2Str(pMsg);
- sTrace("ssyncApplyMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("ssyncApplyMsgLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncApplyMsgLog2(char* s, const SyncApplyMsg* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncApplyMsg2Str(pMsg);
- sTrace("syncApplyMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncApplyMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2603,28 +2603,28 @@ char* syncSnapshotSend2Str(const SyncSnapshotSend* pMsg) {
// for debug ----------------------
void syncSnapshotSendPrint(const SyncSnapshotSend* pMsg) {
char* serialized = syncSnapshotSend2Str(pMsg);
- printf("syncSnapshotSendPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncSnapshotSendPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncSnapshotSendPrint2(char* s, const SyncSnapshotSend* pMsg) {
char* serialized = syncSnapshotSend2Str(pMsg);
- printf("syncSnapshotSendPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncSnapshotSendPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncSnapshotSendLog(const SyncSnapshotSend* pMsg) {
char* serialized = syncSnapshotSend2Str(pMsg);
- sTrace("syncSnapshotSendLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncSnapshotSendLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncSnapshotSendLog2(char* s, const SyncSnapshotSend* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncSnapshotSend2Str(pMsg);
- sTrace("syncSnapshotSendLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncSnapshotSendLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2763,28 +2763,28 @@ char* syncSnapshotRsp2Str(const SyncSnapshotRsp* pMsg) {
// for debug ----------------------
void syncSnapshotRspPrint(const SyncSnapshotRsp* pMsg) {
char* serialized = syncSnapshotRsp2Str(pMsg);
- printf("syncSnapshotRspPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncSnapshotRspPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncSnapshotRspPrint2(char* s, const SyncSnapshotRsp* pMsg) {
char* serialized = syncSnapshotRsp2Str(pMsg);
- printf("syncSnapshotRspPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncSnapshotRspPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncSnapshotRspLog(const SyncSnapshotRsp* pMsg) {
char* serialized = syncSnapshotRsp2Str(pMsg);
- sTrace("syncSnapshotRspLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncSnapshotRspLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncSnapshotRspLog2(char* s, const SyncSnapshotRsp* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncSnapshotRsp2Str(pMsg);
- sTrace("syncSnapshotRspLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncSnapshotRspLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -2925,28 +2925,28 @@ char* syncLeaderTransfer2Str(const SyncLeaderTransfer* pMsg) {
// for debug ----------------------
void syncLeaderTransferPrint(const SyncLeaderTransfer* pMsg) {
char* serialized = syncLeaderTransfer2Str(pMsg);
- printf("syncLeaderTransferPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncLeaderTransferPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg) {
char* serialized = syncLeaderTransfer2Str(pMsg);
- printf("syncLeaderTransferPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncLeaderTransferPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncLeaderTransferLog(const SyncLeaderTransfer* pMsg) {
char* serialized = syncLeaderTransfer2Str(pMsg);
- sTrace("syncLeaderTransferLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncLeaderTransferLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncLeaderTransferLog2(char* s, const SyncLeaderTransfer* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncLeaderTransfer2Str(pMsg);
- sTrace("syncLeaderTransferLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncLeaderTransferLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -3054,28 +3054,28 @@ char* syncReconfigFinish2Str(const SyncReconfigFinish* pMsg) {
// for debug ----------------------
void syncReconfigFinishPrint(const SyncReconfigFinish* pMsg) {
char* serialized = syncReconfigFinish2Str(pMsg);
- printf("syncReconfigFinishPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncReconfigFinishPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncReconfigFinishPrint2(char* s, const SyncReconfigFinish* pMsg) {
char* serialized = syncReconfigFinish2Str(pMsg);
- printf("syncReconfigFinishPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncReconfigFinishPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncReconfigFinishLog(const SyncReconfigFinish* pMsg) {
char* serialized = syncReconfigFinish2Str(pMsg);
- sTrace("syncReconfigFinishLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncReconfigFinishLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg) {
if (gRaftDetailLog) {
char* serialized = syncReconfigFinish2Str(pMsg);
- sTrace("syncReconfigFinishLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncReconfigFinishLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
-}
\ No newline at end of file
+}
diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c
index 57126d0871..cf5bd24899 100644
--- a/source/libs/sync/src/syncRaftCfg.c
+++ b/source/libs/sync/src/syncRaftCfg.c
@@ -447,85 +447,85 @@ int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg) {
// for debug ----------------------
void syncCfgPrint(SSyncCfg *pCfg) {
char *serialized = syncCfg2Str(pCfg);
- printf("syncCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("syncCfgPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncCfgPrint2(char *s, SSyncCfg *pCfg) {
char *serialized = syncCfg2Str(pCfg);
- printf("syncCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("syncCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void syncCfgLog(SSyncCfg *pCfg) {
char *serialized = syncCfg2Str(pCfg);
- sTrace("syncCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("syncCfgLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void syncCfgLog2(char *s, SSyncCfg *pCfg) {
char *serialized = syncCfg2Str(pCfg);
- sTrace("syncCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
void syncCfgLog3(char *s, SSyncCfg *pCfg) {
char *serialized = syncCfg2SimpleStr(pCfg);
- sTrace("syncCfgLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("syncCfgLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
void raftCfgPrint(SRaftCfg *pCfg) {
char *serialized = raftCfg2Str(pCfg);
- printf("raftCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("raftCfgPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCfgPrint2(char *s, SRaftCfg *pCfg) {
char *serialized = raftCfg2Str(pCfg);
- printf("raftCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("raftCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCfgLog(SRaftCfg *pCfg) {
char *serialized = raftCfg2Str(pCfg);
- sTrace("raftCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("raftCfgLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void raftCfgLog2(char *s, SRaftCfg *pCfg) {
char *serialized = raftCfg2Str(pCfg);
- sTrace("raftCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("raftCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
// ---------
void raftCfgIndexPrint(SRaftCfgIndex *pCfg) {
char *serialized = raftCfgIndex2Str(pCfg);
- printf("raftCfgIndexPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("raftCfgIndexPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCfgIndexPrint2(char *s, SRaftCfgIndex *pCfg) {
char *serialized = raftCfgIndex2Str(pCfg);
- printf("raftCfgIndexPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("raftCfgIndexPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCfgIndexLog(SRaftCfgIndex *pCfg) {
char *serialized = raftCfgIndex2Str(pCfg);
- sTrace("raftCfgIndexLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("raftCfgIndexLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void raftCfgIndexLog2(char *s, SRaftCfgIndex *pCfg) {
char *serialized = raftCfgIndex2Str(pCfg);
- sTrace("raftCfgIndexLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("raftCfgIndexLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c
index c481c55e1c..818ffa57a6 100644
--- a/source/libs/sync/src/syncRaftEntry.c
+++ b/source/libs/sync/src/syncRaftEntry.c
@@ -418,28 +418,28 @@ char* raftCache2Str(SRaftEntryHashCache* pCache) {
void raftCachePrint(SRaftEntryHashCache* pCache) {
char* serialized = raftCache2Str(pCache);
- printf("raftCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("raftCachePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCachePrint2(char* s, SRaftEntryHashCache* pCache) {
char* serialized = raftCache2Str(pCache);
- printf("raftCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("raftCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftCacheLog(SRaftEntryHashCache* pCache) {
char* serialized = raftCache2Str(pCache);
- sTrace("raftCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("raftCacheLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void raftCacheLog2(char* s, SRaftEntryHashCache* pCache) {
if (gRaftDetailLog) {
char* serialized = raftCache2Str(pCache);
- sTraceLong("raftCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("raftCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -677,28 +677,28 @@ char* raftEntryCache2Str(SRaftEntryCache* pObj) {
void raftEntryCachePrint(SRaftEntryCache* pObj) {
char* serialized = raftEntryCache2Str(pObj);
- printf("raftEntryCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("raftEntryCachePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftEntryCachePrint2(char* s, SRaftEntryCache* pObj) {
char* serialized = raftEntryCache2Str(pObj);
- printf("raftEntryCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("raftEntryCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftEntryCacheLog(SRaftEntryCache* pObj) {
char* serialized = raftEntryCache2Str(pObj);
- sTrace("raftEntryCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("raftEntryCacheLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void raftEntryCacheLog2(char* s, SRaftEntryCache* pObj) {
if (gRaftDetailLog) {
char* serialized = raftEntryCache2Str(pObj);
- sTraceLong("raftEntryCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("raftEntryCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
-}
\ No newline at end of file
+}
diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c
index c3dad104d1..3e806a0fb7 100644
--- a/source/libs/sync/src/syncRaftLog.c
+++ b/source/libs/sync/src/syncRaftLog.c
@@ -440,7 +440,7 @@ SSyncRaftEntry* logStoreGetEntryWithoutLock(SSyncLogStore* pLogStore, SyncIndex
}
} while (0);
- sError("failed to read ver since %s. index:%lld", tstrerror(terrno), index);
+ sError("failed to read ver since %s. index:%" PRId64 "", tstrerror(terrno), index);
return NULL;
}
@@ -675,14 +675,14 @@ SyncIndex logStoreWalCommitVer(SSyncLogStore* pLogStore) {
// for debug -----------------
void logStorePrint(SSyncLogStore* pLogStore) {
char* serialized = logStore2Str(pLogStore);
- printf("logStorePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("logStorePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void logStorePrint2(char* s, SSyncLogStore* pLogStore) {
char* serialized = logStore2Str(pLogStore);
- printf("logStorePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("logStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
@@ -690,7 +690,7 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore) {
void logStoreLog(SSyncLogStore* pLogStore) {
if (gRaftDetailLog) {
char* serialized = logStore2Str(pLogStore);
- sTraceLong("logStoreLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTraceLong("logStoreLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
}
@@ -698,7 +698,7 @@ void logStoreLog(SSyncLogStore* pLogStore) {
void logStoreLog2(char* s, SSyncLogStore* pLogStore) {
if (gRaftDetailLog) {
char* serialized = logStore2Str(pLogStore);
- sTraceLong("logStoreLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTraceLong("logStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
@@ -706,28 +706,28 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) {
// for debug -----------------
void logStoreSimplePrint(SSyncLogStore* pLogStore) {
char* serialized = logStoreSimple2Str(pLogStore);
- printf("logStoreSimplePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("logStoreSimplePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void logStoreSimplePrint2(char* s, SSyncLogStore* pLogStore) {
char* serialized = logStoreSimple2Str(pLogStore);
- printf("logStoreSimplePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("logStoreSimplePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void logStoreSimpleLog(SSyncLogStore* pLogStore) {
char* serialized = logStoreSimple2Str(pLogStore);
- sTrace("logStoreSimpleLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("logStoreSimpleLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void logStoreSimpleLog2(char* s, SSyncLogStore* pLogStore) {
if (gRaftDetailLog) {
char* serialized = logStoreSimple2Str(pLogStore);
- sTrace("logStoreSimpleLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("logStoreSimpleLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
}
diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c
index 6d4d54a9b1..a714a2c403 100644
--- a/source/libs/sync/src/syncRaftStore.c
+++ b/source/libs/sync/src/syncRaftStore.c
@@ -226,25 +226,25 @@ char *raftStore2Str(SRaftStore *pRaftStore) {
// for debug -------------------
void raftStorePrint(SRaftStore *pObj) {
char *serialized = raftStore2Str(pObj);
- printf("raftStorePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("raftStorePrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftStorePrint2(char *s, SRaftStore *pObj) {
char *serialized = raftStore2Str(pObj);
- printf("raftStorePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("raftStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void raftStoreLog(SRaftStore *pObj) {
char *serialized = raftStore2Str(pObj);
- sTrace("raftStoreLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("raftStoreLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void raftStoreLog2(char *s, SRaftStore *pObj) {
char *serialized = raftStore2Str(pObj);
- sTrace("raftStoreLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("raftStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c
index 55553d5048..ff91315de7 100644
--- a/source/libs/sync/src/syncRequestVoteReply.c
+++ b/source/libs/sync/src/syncRequestVoteReply.c
@@ -127,7 +127,7 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl
if (ths->state == TAOS_SYNC_STATE_CANDIDATE) {
if (ths->pVotesRespond->term != pMsg->term) {
char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "vote respond error vote-respond-mgr term:%lu, msg term:lu",
+ snprintf(logBuf, sizeof(logBuf), "vote respond error vote-respond-mgr term:%" PRIu64 ", msg term:%" PRIu64 "",
ths->pVotesRespond->term, pMsg->term);
syncNodeErrorLog(ths, logBuf);
return -1;
@@ -155,4 +155,4 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c
index 103c225476..30b29d335c 100644
--- a/source/libs/sync/src/syncRespMgr.c
+++ b/source/libs/sync/src/syncRespMgr.c
@@ -177,7 +177,7 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
for (int32_t i = 0; i < arraySize; ++i) {
uint64_t *pSeqNum = taosArrayGet(delIndexArray, i);
taosHashRemove(pObj->pRespHash, pSeqNum, sizeof(uint64_t));
- sDebug("vgId:%d, resp mgr clean by ttl, seq:%d", pSyncNode->vgId, *pSeqNum);
+ sDebug("vgId:%d, resp mgr clean by ttl, seq:%" PRId64 "", pSyncNode->vgId, *pSeqNum);
}
taosArrayDestroy(delIndexArray);
}
diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c
index c3c8131cbb..fd7443222f 100644
--- a/source/libs/sync/src/syncTimeout.c
+++ b/source/libs/sync/src/syncTimeout.c
@@ -91,7 +91,7 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
} else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) {
if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) {
++(ths->electTimerCounter);
- sTrace("vgId:%d, sync timer, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId,
+ sTrace("vgId:%d, sync timer, type:election count:%" PRId64 ", electTimerLogicClockUser:%" PRId64 "", ths->vgId,
ths->electTimerCounter, ths->electTimerLogicClockUser);
syncNodeElect(ths);
}
@@ -99,8 +99,8 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
} else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) {
if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) {
++(ths->heartbeatTimerCounter);
- sTrace("vgId:%d, sync timer, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId,
- ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser);
+ sTrace("vgId:%d, sync timer, type:replicate count:%" PRId64 ", heartbeatTimerLogicClockUser:%" PRId64 "",
+ ths->vgId, ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser);
syncNodeReplicate(ths, true);
}
} else {
@@ -108,4 +108,4 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
}
return ret;
-}
\ No newline at end of file
+}
diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c
index 09b79825d0..e10041d976 100644
--- a/source/libs/sync/src/syncVoteMgr.c
+++ b/source/libs/sync/src/syncVoteMgr.c
@@ -138,27 +138,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) {
// for debug -------------------
void voteGrantedPrint(SVotesGranted *pObj) {
char *serialized = voteGranted2Str(pObj);
- printf("voteGrantedPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void voteGrantedPrint2(char *s, SVotesGranted *pObj) {
char *serialized = voteGranted2Str(pObj);
- printf("voteGrantedPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void voteGrantedLog(SVotesGranted *pObj) {
char *serialized = voteGranted2Str(pObj);
- sTrace("voteGrantedLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void voteGrantedLog2(char *s, SVotesGranted *pObj) {
char *serialized = voteGranted2Str(pObj);
- sTrace("voteGrantedLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
@@ -267,26 +267,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) {
// for debug -------------------
void votesRespondPrint(SVotesRespond *pObj) {
char *serialized = votesRespond2Str(pObj);
- printf("votesRespondPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void votesRespondPrint2(char *s, SVotesRespond *pObj) {
char *serialized = votesRespond2Str(pObj);
- printf("votesRespondPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized);
fflush(NULL);
taosMemoryFree(serialized);
}
void votesRespondLog(SVotesRespond *pObj) {
char *serialized = votesRespond2Str(pObj);
- sTrace("votesRespondLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized);
taosMemoryFree(serialized);
}
void votesRespondLog2(char *s, SVotesRespond *pObj) {
char *serialized = votesRespond2Str(pObj);
- sTrace("votesRespondLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized);
taosMemoryFree(serialized);
}
diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c
index 1e2b059adb..855e3510f2 100644
--- a/source/libs/tdb/src/db/tdbDb.c
+++ b/source/libs/tdb/src/db/tdbDb.c
@@ -138,7 +138,7 @@ int32_t tdbPostCommit(TDB *pDb, TXN *pTxn) {
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
ret = tdbPagerPostCommit(pPager, pTxn);
if (ret < 0) {
- tdbError("failed to commit pager since %s. dbName:%s, txnId:%d", tstrerror(terrno), pDb->dbName, pTxn->txnId);
+ tdbError("failed to commit pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName, pTxn->txnId);
return -1;
}
}
diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c
index 667cd706c5..bdbd6c2f3d 100644
--- a/source/libs/tdb/src/db/tdbPCache.c
+++ b/source/libs/tdb/src/db/tdbPCache.c
@@ -301,8 +301,8 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
pPage->pPager = pPageH->pPager;
memcpy(pPage->pData, pPageH->pData, pPage->pageSize);
- // tdbDebug("pcache/pPageH: %p %d %p %p %d", pPageH, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize, pPage,
- // TDB_PAGE_PGNO(pPageH));
+ // tdbDebug("pcache/pPageH: %p %ld %p %p %u", pPageH, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize, pPage,
+ // TDB_PAGE_PGNO(pPageH));
tdbPageInit(pPage, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize);
pPage->kLen = pPageH->kLen;
pPage->vLen = pPageH->vLen;
diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c
index 7c8ab16ec7..88729f0b69 100644
--- a/source/libs/tdb/src/db/tdbPager.c
+++ b/source/libs/tdb/src/db/tdbPager.c
@@ -553,8 +553,8 @@ static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage) {
ret = tdbOsWrite(pPager->jfd, pPage->pData, pPage->pageSize);
if (ret < 0) {
- tdbError("failed to write page data due to %s. file:%s, pageSize:%d", strerror(errno), pPager->jFileName,
- pPage->pageSize);
+ tdbError("failed to write page data due to %s. file:%s, pageSize:%ld", strerror(errno), pPager->jFileName,
+ (long)pPage->pageSize);
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c
index 237a4b6059..f784b4c53e 100644
--- a/source/libs/transport/src/trans.c
+++ b/source/libs/transport/src/trans.c
@@ -100,11 +100,11 @@ void* rpcMallocCont(int64_t contLen) {
int64_t size = contLen + TRANS_MSG_OVERHEAD;
char* start = taosMemoryCalloc(1, size);
if (start == NULL) {
- tError("failed to malloc msg, size:%d", size);
+ tError("failed to malloc msg, size:%" PRId64, size);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
} else {
- tTrace("malloc mem:%p size:%d", start, size);
+ tTrace("malloc mem:%p size:%" PRId64, start, size);
}
return start + sizeof(STransMsgHead);
diff --git a/source/libs/transport/test/svrBench.c b/source/libs/transport/test/svrBench.c
index 6eb80c8504..ce465d989a 100644
--- a/source/libs/transport/test/svrBench.c
+++ b/source/libs/transport/test/svrBench.c
@@ -134,7 +134,7 @@ int main(int argc, char *argv[]) {
dDebugFlag = rpcDebugFlag;
uDebugFlag = rpcDebugFlag;
} else {
- printf("\nusage:% [options] \n", argv[0]);
+ printf("\nusage:%s [options] \n", argv[0]);
printf(" [-p port]: server port number, default is:%d\n", rpcInit.localPort);
printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads);
printf(" [-s sessions]: number of sessions, default is:%d\n", rpcInit.sessions);
diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c
index fa22805df2..55de61eb74 100644
--- a/source/libs/wal/src/walMeta.c
+++ b/source/libs/wal/src/walMeta.c
@@ -69,8 +69,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
int64_t walCkHeadSz = sizeof(SWalCkHead);
int64_t end = fileSize;
int64_t offset = 0;
- int32_t capacity = 0;
- int32_t readSize = 0;
+ int64_t capacity = 0;
+ int64_t readSize = 0;
char* buf = NULL;
char* found = NULL;
bool firstTrial = pFileInfo->fileSize < fileSize;
@@ -200,8 +200,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
// truncate file
if (lastEntryEndOffset != fileSize) {
- wWarn("vgId:%d, repair meta truncate file %s to %ld, orig size %ld", pWal->cfg.vgId, fnameStr, lastEntryEndOffset,
- fileSize);
+ wWarn("vgId:%d, repair meta truncate file %s to %" PRId64 ", orig size %" PRId64, pWal->cfg.vgId, fnameStr,
+ lastEntryEndOffset, fileSize);
if (taosFtruncateFile(pFile, lastEntryEndOffset) < 0) {
wError("failed to truncate file due to %s. file:%s", strerror(errno), fnameStr);
terrno = TAOS_SYSTEM_ERROR(errno);
@@ -464,7 +464,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
// determine the last valid entry end, i.e. offset
while ((offset -= sizeof(SWalIdxEntry)) >= 0) {
if (taosLSeekFile(pIdxFile, offset, SEEK_SET) < 0) {
- wError("vgId:%d, failed to seek file due to %s. offset:" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
+ wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
offset, fnameStr);
terrno = TAOS_SYSTEM_ERROR(errno);
goto _err;
@@ -511,7 +511,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
// rebuild idx file
if (taosLSeekFile(pIdxFile, 0, SEEK_END) < 0) {
- wError("vgId:%d, failed to seek file due to %s. offset:" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
+ wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
offset, fnameStr);
terrno = TAOS_SYSTEM_ERROR(errno);
goto _err;
@@ -528,7 +528,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
idxEntry.offset, fLogNameStr);
goto _err;
}
- wWarn("vgId:%d wal idx append new entry %ld %ld", pWal->cfg.vgId, idxEntry.ver, idxEntry.offset);
+ wWarn("vgId:%d wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset);
if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
goto _err;
diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c
index 179d809c84..60c8591823 100644
--- a/source/libs/wal/src/walRead.c
+++ b/source/libs/wal/src/walRead.c
@@ -126,7 +126,7 @@ static int64_t walReadSeekFilePos(SWalReader *pReader, int64_t fileFirstVer, int
wError("vgId:%d, failed to read idx file, since %s", pReader->pWal->cfg.vgId, terrstr());
} else {
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
- wError("vgId:%d, read idx file incompletely, read bytes %" PRId64 ", bytes should be %" PRIu64,
+ wError("vgId:%d, read idx file incompletely, read bytes %" PRId64 ", bytes should be %ld",
pReader->pWal->cfg.vgId, ret, sizeof(SWalIdxEntry));
}
return -1;
@@ -182,7 +182,7 @@ int32_t walReadSeekVerImpl(SWalReader *pReader, int64_t ver) {
tmpInfo.firstVer = ver;
SWalFileInfo *pRet = taosArraySearch(pWal->fileInfoSet, &tmpInfo, compareWalFileInfo, TD_LE);
if (pRet == NULL) {
- wError("failed to find WAL log file with ver:%lld", ver);
+ wError("failed to find WAL log file with ver:%" PRId64, ver);
terrno = TSDB_CODE_WAL_INVALID_VER;
return -1;
}
diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c
index 0562bbad27..3354308c49 100644
--- a/source/libs/wal/src/walWrite.c
+++ b/source/libs/wal/src/walWrite.c
@@ -419,7 +419,7 @@ static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) {
int64_t size = taosWriteFile(pWal->pIdxFile, &entry, sizeof(SWalIdxEntry));
if (size != sizeof(SWalIdxEntry)) {
- wError("vgId:%d, failed to write idx entry due to %s. ver:%lld", pWal->cfg.vgId, strerror(errno), ver);
+ wError("vgId:%d, failed to write idx entry due to %s. ver:%" PRId64, pWal->cfg.vgId, strerror(errno), ver);
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
@@ -449,7 +449,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead);
pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen);
- wDebug("vgId:%d, wal write log %ld, msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType));
+ wDebug("vgId:%d, wal write log %" PRId64 ", msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType));
code = walWriteIndex(pWal, index, offset);
if (code < 0) {
@@ -484,16 +484,16 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
END:
// recover in a reverse order
if (taosFtruncateFile(pWal->pLogFile, offset) < 0) {
- wFatal("vgId:%d, failed to ftruncate logfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, offset,
- strerror(errno));
+ wFatal("vgId:%d, failed to ftruncate logfile to offset:%" PRId64 " during recovery due to %s", pWal->cfg.vgId,
+ offset, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
ASSERT(0 && "failed to recover from error");
}
int64_t idxOffset = (index - pFileInfo->firstVer) * sizeof(SWalIdxEntry);
if (taosFtruncateFile(pWal->pIdxFile, idxOffset) < 0) {
- wFatal("vgId:%d, failed to ftruncate idxfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, idxOffset,
- strerror(errno));
+ wFatal("vgId:%d, failed to ftruncate idxfile to offset:%" PRId64 "during recovery due to %s", pWal->cfg.vgId,
+ idxOffset, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
ASSERT(0 && "failed to recover from error");
}
diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c
index 616ab7875d..ac1881fc6d 100644
--- a/source/os/src/osEnv.c
+++ b/source/os/src/osEnv.c
@@ -105,3 +105,5 @@ void osSetSystemLocale(const char *inLocale, const char *inCharSet) {
memcpy(tsLocale, inLocale, strlen(inLocale) + 1);
memcpy(tsCharset, inCharSet, strlen(inCharSet) + 1);
}
+
+void osSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; }
diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c
deleted file mode 100644
index f060ab48c9..0000000000
--- a/source/os/src/osProc.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#define ALLOW_FORBID_FUNC
-#define _DEFAULT_SOURCE
-#include "os.h"
-
-int32_t taosNewProc(char **args) {
-#ifdef WINDOWS
- assert(0);
- return 0;
-#else
- int32_t pid = fork();
- if (pid == 0) {
- args[0] = tsProcPath;
- // close(STDIN_FILENO);
- // close(STDOUT_FILENO);
- // close(STDERR_FILENO);
- return execvp(tsProcPath, args);
- } else {
- return pid;
- }
-#endif
-}
-
-void taosWaitProc(int32_t pid) {
-#ifdef WINDOWS
- assert(0);
-#else
- int32_t status = -1;
- waitpid(pid, &status, 0);
-#endif
-}
-
-void taosKillProc(int32_t pid) {
-#ifdef WINDOWS
- assert(0);
-#else
- kill(pid, SIGINT);
-#endif
-}
-
-bool taosProcExist(int32_t pid) {
-#ifdef WINDOWS
- assert(0);
- return false;
-#else
- int32_t p = getpgid(pid);
- return p >= 0;
-#endif
-}
-
-// the length of the new name must be less than the original name to take effect
-void taosSetProcName(int32_t argc, char **argv, const char *name) {
- setThreadName(name);
-
- for (int32_t i = 0; i < argc; ++i) {
- int32_t len = strlen(argv[i]);
- for (int32_t j = 0; j < len; ++j) {
- argv[i][j] = 0;
- }
- if (i == 0) {
- tstrncpy(argv[0], name, len + 1);
- }
- }
-}
-
-void taosSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; }
diff --git a/source/os/src/osShm.c b/source/os/src/osShm.c
deleted file mode 100644
index cb09e2fb38..0000000000
--- a/source/os/src/osShm.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#define ALLOW_FORBID_FUNC
-#define _DEFAULT_SOURCE
-#include "os.h"
-
-#define MAX_SHMIDS 6
-
-static int32_t shmids[MAX_SHMIDS] = {0};
-
-static void taosDeleteCreatedShms() {
-#if defined(WINDOWS)
- assert(0);
-#else
- for (int32_t i = 0; i < MAX_SHMIDS; ++i) {
- int32_t shmid = shmids[i] - 1;
- if (shmid >= 0) {
- shmctl(shmid, IPC_RMID, NULL);
- }
- }
-#endif
-}
-
-int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) {
-#if defined(WINDOWS)
- assert(0);
-#else
- pShm->id = -1;
-
-#if 1
- key_t __shkey = IPC_PRIVATE;
- int32_t __shmflag = IPC_CREAT | IPC_EXCL | 0600;
-#else
- key_t __shkey = 0X95270000 + key;
- int32_t __shmflag = IPC_CREAT | 0600;
-#endif
-
- int32_t shmid = shmget(__shkey, shmsize, __shmflag);
- if (shmid < 0) {
- return -1;
- }
-
- void* shmptr = shmat(shmid, NULL, 0);
- if (shmptr == NULL) {
- return -1;
- }
-
- pShm->id = shmid;
- pShm->size = shmsize;
- pShm->ptr = shmptr;
-
-#if 0
- if (key >= 0 && key < MAX_SHMIDS) {
- shmids[key] = pShm->id + 1;
- }
- atexit(taosDeleteCreatedShms);
-#else
- shmctl(pShm->id, IPC_RMID, NULL);
-#endif
-
-#endif
- return 0;
-}
-
-void taosDropShm(SShm* pShm) {
-#if defined(WINDOWS)
- assert(0);
-#else
- if (pShm->id >= 0) {
- if (pShm->ptr != NULL) {
- shmdt(pShm->ptr);
- }
- shmctl(pShm->id, IPC_RMID, NULL);
- }
- pShm->id = -1;
- pShm->size = 0;
- pShm->ptr = NULL;
-#endif
-}
-
-int32_t taosAttachShm(SShm* pShm) {
-#if defined(WINDOWS)
- assert(0);
-#else
- errno = 0;
-
- void* ptr = shmat(pShm->id, NULL, 0);
- if (errno == 0) {
- pShm->ptr = ptr;
- }
-#endif
- return errno;
-}
diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c
index a559a9c000..7d1686ef80 100644
--- a/source/util/src/tcache.c
+++ b/source/util/src/tcache.c
@@ -227,7 +227,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheNode *
static FORCE_INLINE STrashElem *doRemoveElemInTrashcan(SCacheObj *pCacheObj, STrashElem *pElem) {
if (pElem->pData->signature != pElem->pData) {
- uWarn("key:sig:0x%" PRIx64 " %p data has been released, ignore", pElem->pData->signature, pElem->pData);
+ uWarn("key:sig:0x%" PRIx64 " %p data has been released, ignore", (int64_t)pElem->pData->signature, pElem->pData);
return NULL;
}
diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt
index 6e42ef7e75..2e307771b7 100644
--- a/source/util/test/CMakeLists.txt
+++ b/source/util/test/CMakeLists.txt
@@ -45,14 +45,6 @@ INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc)
# add_executable(encodeTest "encodeTest.cpp")
# target_link_libraries(encodeTest os util gtest gtest_main)
-# queueTest
-# add_executable(procTest "procTest.cpp")
-# target_link_libraries(procTest os util transport sut gtest_main)
-# add_test(
-# NAME procTest
-# COMMAND procTest
-# )
-
# cfgTest
add_executable(cfgTest "cfgTest.cpp")
target_link_libraries(cfgTest os util gtest_main)
diff --git a/source/util/test/procTest.cpp b/source/util/test/procTest.cpp
deleted file mode 100644
index 53d3fa2c4b..0000000000
--- a/source/util/test/procTest.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * @file queue.cpp
- * @author slguan (slguan@taosdata.com)
- * @brief UTIL module queue tests
- * @version 1.0
- * @date 2022-01-27
- *
- * @copyright Copyright (c) 2022
- *
- */
-#if 0
-#include
-#include "tlog.h"
-#include "tprocess.h"
-#include "tqueue.h"
-
-typedef struct STestMsg {
- uint16_t msgType;
- void *pCont;
- int contLen;
- int32_t code;
- void *handle; // rpc handle returned to app
- void *ahandle; // app handle set by client
- int noResp; // has response or not(default 0, 0: resp, 1: no resp);
- int persistHandle; // persist handle or not
-} STestMsg;
-
-class UtilTesProc : public ::testing::Test {
- public:
- void SetUp() override {
- shm.id = -1;
- for (int32_t i = 0; i < 4000; ++i) {
- body[i] = i % 26 + 'a';
- }
- head.pCont = body;
- head.code = 1;
- head.msgType = 2;
- head.noResp = 3;
- head.persistHandle = 4;
-
- taosRemoveDir(TD_TMP_DIR_PATH "td");
- taosMkDir(TD_TMP_DIR_PATH "td");
- tstrncpy(tsLogDir, TD_TMP_DIR_PATH "td", PATH_MAX);
- if (taosInitLog("taosdlog", 1) != 0) {
- printf("failed to init log file\n");
- }
- }
- void TearDown() override { taosDropShm(&shm); }
-
- public:
- static STestMsg head;
- static char body[4000];
- static SShm shm;
- static void SetUpTestSuite() {}
- static void TearDownTestSuite() {}
-};
-
-SShm UtilTesProc::shm;
-char UtilTesProc::body[4000];
-STestMsg UtilTesProc::head;
-
-TEST_F(UtilTesProc, 00_Init_Cleanup) {
- ASSERT_EQ(taosCreateShm(&shm, 1234, 1024 * 1024 * 2), 0);
-
- shm.size = 1023;
- SProcCfg cfg = {(ProcConsumeFp)NULL,
- (ProcMallocFp)taosAllocateQitem,
- (ProcFreeFp)taosFreeQitem,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryMalloc,
- (ProcConsumeFp)NULL,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryMalloc,
- shm,
- &shm,
- "1234"};
- SProc *proc = dmInitProc(&cfg);
- ASSERT_EQ(proc, nullptr);
-
- shm.size = 2468;
- cfg.shm = shm;
- proc = dmInitProc(&cfg);
- ASSERT_NE(proc, nullptr);
-
- ASSERT_EQ(dmRunProc(proc), 0);
- dmCleanupProc(proc);
- taosDropShm(&shm);
-}
-
-void ConsumeChild1(void *parent, void *pHead, int16_t headLen, void *pBody, int32_t bodyLen, EProcFuncType ftype) {
- STestMsg msg;
- memcpy(&msg, pHead, headLen);
- char body[2000] = {0};
- memcpy(body, pBody, bodyLen);
-
- uDebug("====> parent:%" PRId64 " ftype:%d, headLen:%d bodyLen:%d head:%d:%d:%d:%d body:%s <====", (int64_t)parent,
- ftype, headLen, bodyLen, msg.code, msg.msgType, msg.noResp, msg.persistHandle, body);
- taosMemoryFree(pBody);
- taosFreeQitem(pHead);
-}
-
-TEST_F(UtilTesProc, 01_Push_Pop_Child) {
- shm.size = 3000;
- ASSERT_EQ(taosCreateShm(&shm, 1235, shm.size), 0);
- SProcCfg cfg = {(ProcConsumeFp)ConsumeChild1,
- (ProcMallocFp)taosAllocateQitem,
- (ProcFreeFp)taosFreeQitem,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcConsumeFp)NULL,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- shm,
- (void *)((int64_t)1235),
- "1235_c"};
- SProc *cproc = dmInitProc(&cfg);
- ASSERT_NE(cproc, nullptr);
-
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, 0, body, 0, 0, 0, DND_FUNC_RSP), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, 0, body, 0, 0, 0, DND_FUNC_REGIST), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, 0, body, 0, 0, 0, DND_FUNC_RELEASE), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, NULL, 12, body, 0, 0, 0, DND_FUNC_REQ), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, 0, body, 0, 0, 0, DND_FUNC_REQ), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, shm.size, body, 0, 0, 0, DND_FUNC_REQ), 0);
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, sizeof(STestMsg), body, shm.size, 0, 0, DND_FUNC_REQ), 0);
-
- for (int32_t j = 0; j < 1000; j++) {
- int32_t i = 0;
- for (i = 0; i < 20; ++i) {
- ASSERT_EQ(dmPutToProcCQueue(cproc, &head, sizeof(STestMsg), body, i, 0, 0, DND_FUNC_REQ), 0);
- }
- ASSERT_NE(dmPutToProcCQueue(cproc, &head, sizeof(STestMsg), body, i, 0, 0, DND_FUNC_REQ), 0);
-
- cfg.isChild = true;
- cfg.name = "1235_p";
- SProc *pproc = dmInitProc(&cfg);
- ASSERT_NE(pproc, nullptr);
- dmRunProc(pproc);
- dmCleanupProc(pproc);
- }
-
- dmCleanupProc(cproc);
- taosDropShm(&shm);
-}
-
-void ConsumeParent1(void *parent, void *pHead, int16_t headLen, void *pBody, int32_t bodyLen, EProcFuncType ftype) {
- STestMsg msg;
- memcpy(&msg, pHead, headLen);
- char body[2000] = {0};
- memcpy(body, pBody, bodyLen);
-
- uDebug("----> parent:%" PRId64 " ftype:%d, headLen:%d bodyLen:%d head:%d:%d:%d:%d body:%s <----", (int64_t)parent,
- ftype, headLen, bodyLen, msg.code, msg.msgType, msg.noResp, msg.persistHandle, body);
- taosMemoryFree(pBody);
- taosMemoryFree(pHead);
-}
-
-TEST_F(UtilTesProc, 02_Push_Pop_Parent) {
- shm.size = 3000;
- ASSERT_EQ(taosCreateShm(&shm, 1236, shm.size), 0);
- SProcCfg cfg = {(ProcConsumeFp)NULL,
- (ProcMallocFp)taosAllocateQitem,
- (ProcFreeFp)taosFreeQitem,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcConsumeFp)ConsumeParent1,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- shm,
- (void *)((int64_t)1236),
- "1236_c"};
- SProc *cproc = dmInitProc(&cfg);
- ASSERT_NE(cproc, nullptr);
-
- cfg.name = "1236_p";
- cfg.isChild = true;
- SProc *pproc = dmInitProc(&cfg);
- ASSERT_NE(pproc, nullptr);
-
- for (int32_t j = 0; j < 1000; j++) {
- int32_t i = 0;
- for (i = 0; i < 20; ++i) {
- dmPutToProcPQueue(pproc, &head, sizeof(STestMsg), body, i, DND_FUNC_REQ);
- }
-
- dmRunProc(cproc);
- dmStopProc(cproc);
- }
-
- dmCleanupProc(pproc);
- dmCleanupProc(cproc);
- taosDropShm(&shm);
-}
-
-void ConsumeChild3(void *parent, void *pHead, int16_t headLen, void *pBody, int32_t bodyLen, EProcFuncType ftype) {
- STestMsg msg;
- memcpy(&msg, pHead, headLen);
- char body[2000] = {0};
- memcpy(body, pBody, bodyLen);
-
- uDebug("====> parent:%" PRId64 " ftype:%d, headLen:%d bodyLen:%d handle:%" PRId64 " body:%s <====", (int64_t)parent,
- ftype, headLen, bodyLen, (int64_t)msg.handle, body);
- taosMemoryFree(pBody);
- taosFreeQitem(pHead);
-}
-
-void processHandle(void *handle) { uDebug("----> remove handle:%" PRId64 " <----", (int64_t)handle); }
-
-TEST_F(UtilTesProc, 03_Handle) {
- // uDebugFlag = 207;
- shm.size = 3000;
- ASSERT_EQ(taosCreateShm(&shm, 1237, shm.size), 0);
- SProcCfg cfg = {(ProcConsumeFp)ConsumeChild3,
- (ProcMallocFp)taosAllocateQitem,
- (ProcFreeFp)taosFreeQitem,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcConsumeFp)NULL,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- (ProcMallocFp)taosMemoryMalloc,
- (ProcFreeFp)taosMemoryFree,
- shm,
- (void *)((int64_t)1235),
- "1237_p"};
- SProc *cproc = dmInitProc(&cfg);
- ASSERT_NE(cproc, nullptr);
-
- for (int32_t j = 0; j < 1; j++) {
- int32_t i = 0;
- for (i = 0; i < 20; ++i) {
- head.handle = (void *)((int64_t)i);
- ASSERT_EQ(dmPutToProcCQueue(cproc, &head, sizeof(STestMsg), body, i, (void *)((int64_t)i), i, DND_FUNC_REQ), 0);
- }
-
- cfg.isChild = true;
- cfg.name = "child_queue";
- SProc *pproc = dmInitProc(&cfg);
- ASSERT_NE(pproc, nullptr);
- dmRunProc(pproc);
- dmCleanupProc(pproc);
-
- int64_t ref = 0;
-
- ref = dmRemoveProcRpcHandle(cproc, (void *)((int64_t)3));
- EXPECT_EQ(ref, 3);
- ref = dmRemoveProcRpcHandle(cproc, (void *)((int64_t)5));
- EXPECT_EQ(ref, 5);
- ref = dmRemoveProcRpcHandle(cproc, (void *)((int64_t)6));
- EXPECT_EQ(ref, 6);
- dmCloseProcRpcHandles(cproc, processHandle);
- }
-
- dmCleanupProc(cproc);
- taosDropShm(&shm);
-}
-
-#endif
\ No newline at end of file
diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt
index 81625d55e5..fc139a1533 100644
--- a/tests/script/jenkins/basic.txt
+++ b/tests/script/jenkins/basic.txt
@@ -299,18 +299,6 @@
./test.sh -f tsim/stable/values.sim
./test.sh -f tsim/stable/vnode3.sim
-# --- for multi process mode
-./test.sh -f tsim/user/basic.sim -m
-./test.sh -f tsim/db/basic3.sim -m
-./test.sh -f tsim/db/error1.sim -m
-./test.sh -f tsim/insert/backquote.sim -m
-# unsupport ./test.sh -f tsim/parser/fourArithmetic-basic.sim -m
-./test.sh -f tsim/query/interval-offset.sim -m
-# unsupport ./test.sh -f tsim/tmq/basic3.sim -m
-./test.sh -f tsim/stable/vnode3.sim -m
-./test.sh -f tsim/qnode/basic1.sim -m
-# unsupport ./test.sh -f tsim/mnode/basic1.sim -m
-
# --- sma
./test.sh -f tsim/sma/drop_sma.sim
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
@@ -457,5 +445,7 @@
./test.sh -f tsim/tag/set.sim
./test.sh -f tsim/tag/smallint.sim
./test.sh -f tsim/tag/tinyint.sim
+./test.sh -f tsim/tag/drop_tag.sim
+
#======================b1-end===============
diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh
index 5f497a248f..606afe164b 100755
--- a/tests/script/sh/deploy.sh
+++ b/tests/script/sh/deploy.sh
@@ -9,7 +9,6 @@ UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
NODE_NAME=
NODE=
-MULTIPROCESS=0
while getopts "n:i:m" arg
do
case $arg in
@@ -19,9 +18,6 @@ do
i)
NODE=$OPTARG
;;
- m)
- MULTIPROCESS=1
- ;;
?)
echo "unkonw argument"
;;
@@ -148,5 +144,4 @@ echo "numOfLogLines 20000000" >> $TAOS_CFG
echo "asyncLog 0" >> $TAOS_CFG
echo "locale en_US.UTF-8" >> $TAOS_CFG
echo "telemetryReporting 0" >> $TAOS_CFG
-echo "multiProcess ${MULTIPROCESS}" >> $TAOS_CFG
echo " " >> $TAOS_CFG
diff --git a/tests/script/test.sh b/tests/script/test.sh
index 0ffe8cf8f1..1530567987 100755
--- a/tests/script/test.sh
+++ b/tests/script/test.sh
@@ -15,7 +15,6 @@ VALGRIND=0
UNIQUE=0
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
-MULTIPROCESS=0
while getopts "f:avum" arg
do
case $arg in
@@ -28,9 +27,6 @@ do
u)
UNIQUE=1
;;
- m)
- MULTIPROCESS=1
- ;;
?)
echo "unknow argument"
;;
@@ -126,22 +122,12 @@ ulimit -c unlimited
if [ -n "$FILE_NAME" ]; then
echo "------------------------------------------------------------------------"
if [ $VALGRIND -eq 1 ]; then
- if [[ $MULTIPROCESS -eq 1 ]];then
- FLAG="-m -v"
- else
- FLAG="-v"
- fi
-
+ FLAG="-v"
echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --child-silent-after-fork=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes --log-file=${LOG_DIR}/valgrind-tsim.log $PROGRAM -c $CFG_DIR -f $FILE_NAME $FLAG
valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --child-silent-after-fork=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes --log-file=${LOG_DIR}/valgrind-tsim.log $PROGRAM -c $CFG_DIR -f $FILE_NAME $FLAG
else
- if [[ $MULTIPROCESS -eq 1 ]];then
- echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME
- $PROGRAM -m -c $CFG_DIR -f $FILE_NAME
- else
- echo "ExcuteCmd(singleprocess):" $PROGRAM -c $CFG_DIR -f $FILE_NAME
- $PROGRAM -c $CFG_DIR -f $FILE_NAME
- fi
+ echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME
+ $PROGRAM -c $CFG_DIR -f $FILE_NAME
fi
else
echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim
diff --git a/tests/script/tsim/tag/drop_tag.sim b/tests/script/tsim/tag/drop_tag.sim
new file mode 100644
index 0000000000..03892039f9
--- /dev/null
+++ b/tests/script/tsim/tag/drop_tag.sim
@@ -0,0 +1,84 @@
+
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sql connect
+
+
+$dbPrefix = ta_bib_db
+$tbPrefix = ta_bib_tb
+$mtPrefix = ta_bib_mt
+$tbNum = 10
+$rowNum = 20
+$totalNum = 200
+
+print =============== step1
+$i = 0
+$db = $dbPrefix . $i
+$mt = $mtPrefix . $i
+
+sql drop database if exists $db
+
+sql create database $db vgroups 1
+sql use $db
+
+print ======== test bigint
+sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id bigint)
+
+sql create table t1 using st tags(111)
+sql create table t2 using st tags(222)
+
+sql insert into t1(ts, order_id) values(1648791213001, 1)
+sql insert into t2(ts, order_id) values(1648791213002, 2)
+sql select account_id,count(*) from st where account_id = 111 group by account_id
+
+sql drop table t1
+
+sql create table t1 using st tags(111)
+
+sql insert into t1(ts, order_id) values(1648791213001, 1)
+sql insert into t2(ts, order_id) values(1648791213002, 2)
+
+sql select account_id,count(*) from st where account_id = 111 group by account_id
+
+if $rows != 1 then
+ return -1
+endi
+
+print ======== test varchar
+
+sql drop stable st
+
+sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id binary(16))
+
+sql create table t1 using st tags("aac")
+sql create table t2 using st tags("abc")
+
+sql insert into t1(ts, order_id) values(1648791213001, 1)
+sql insert into t2(ts, order_id) values(1648791213002, 2)
+sql select account_id,count(*) from st where account_id = "aac" group by account_id
+
+sql drop table t1
+
+sql create table t1 using st tags("aac")
+
+sql insert into t1(ts, order_id) values(1648791213001, 1)
+sql insert into t2(ts, order_id) values(1648791213002, 2)
+
+sql select account_id,count(*) from st where account_id = "aac" group by account_id
+
+if $rows != 1 then
+ return -1
+endi
+
+print ====== test empty table
+sql drop table t1
+
+sql select account_id,count(*) from st where account_id = "aac" group by account_id
+if $rows != 0 then
+ return -1
+endi
+
+
+sql drop database $db
+
diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py
new file mode 100644
index 0000000000..6d62420efe
--- /dev/null
+++ b/tests/system-test/0-others/taosdShell.py
@@ -0,0 +1,185 @@
+
+import taos
+import sys
+import time
+import socket
+import os
+import platform
+if platform.system().lower() == 'windows':
+ import wexpect as taosExpect
+else:
+ import pexpect as taosExpect
+
+from util.log import *
+from util.sql import *
+from util.cases import *
+from util.dnodes import *
+
+class TDTestCase:
+ #updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\
+ # 'serverPort': 7080, 'firstEp': 'trd02:7080'}
+ # hostname = socket.gethostname()
+ # if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""):
+ # try:
+ # config = eval(tdDnodes.dnodes[0].remoteIP)
+ # hostname = config["host"]
+ # except Exception:
+ # hostname = tdDnodes.dnodes[0].remoteIP
+ # serverPort = '7080'
+ # rpcDebugFlagVal = '143'
+ # clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
+ # clientCfgDict["serverPort"] = serverPort
+ # clientCfgDict["firstEp"] = hostname + ':' + serverPort
+ # clientCfgDict["secondEp"] = hostname + ':' + serverPort
+ # clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
+ # clientCfgDict["fqdn"] = hostname
+
+ # updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
+ # updatecfgDict["clientCfg"] = clientCfgDict
+ # updatecfgDict["serverPort"] = serverPort
+ # updatecfgDict["firstEp"] = hostname + ':' + serverPort
+ # updatecfgDict["secondEp"] = hostname + ':' + serverPort
+ # updatecfgDict["fqdn"] = hostname
+
+ # print ("===================: ", updatecfgDict)
+
+ def init(self, conn, logSql):
+ tdLog.debug(f"start to excute {__file__}")
+ tdSql.init(conn.cursor())
+
+ def getBuildPath(self):
+ selfPath = os.path.dirname(os.path.realpath(__file__))
+
+ if ("community" in selfPath):
+ projPath = selfPath[:selfPath.find("community")]
+ else:
+ projPath = selfPath[:selfPath.find("tests")]
+
+ for root, dirs, files in os.walk(projPath):
+ if ("taosd" in files or "taosd.exe" in files):
+ rootRealPath = os.path.dirname(os.path.realpath(root))
+ if ("packaging" not in rootRealPath):
+ buildPath = root[:len(root) - len("/build/bin")]
+ break
+ return buildPath
+
+ def get_process_pid(self,processname):
+ #origin artical link:https://blog.csdn.net/weixin_45623536/article/details/122099062
+ process_info_list = []
+ process = os.popen('ps -A | grep %s'% processname)
+ process_info = process.read()
+ for i in process_info.split(' '):
+ if i != "":
+ process_info_list.append(i)
+ print(process_info_list)
+ if len(process_info_list) != 0 :
+ pid = int(process_info_list[0])
+ else :
+ pid = 0
+ return pid
+
+ def checkAndstopPro(self,processName,startAction):
+ i = 1
+ count = 10
+ for i in range(count):
+ taosdPid=self.get_process_pid(processName)
+ if taosdPid != 0 and taosdPid != "" :
+ tdLog.info("stop taosd %s ,kill pid :%s "%(startAction,taosdPid))
+ os.system("kill -9 %d"%taosdPid)
+ break
+ else:
+ tdLog.info( "wait start taosd ,times: %d "%i)
+ sleep
+ i+= 1
+ else :
+ tdLog.exit("taosd %s is not running "%startAction)
+
+ def taosdCommandStop(self,startAction,taosdCmdRun):
+ processName="taosd"
+ taosdCmd = taosdCmdRun + startAction
+ tdLog.printNoPrefix("%s"%taosdCmd)
+ os.system(f"nohup {taosdCmd} & ")
+ self.checkAndstopPro(processName,startAction)
+
+ def taosdCommandExe(self,startAction,taosdCmdRun):
+ taosdCmd = taosdCmdRun + startAction
+ tdLog.printNoPrefix("%s"%taosdCmd)
+ os.system(f"{taosdCmd}")
+
+ def run(self):
+ tdSql.prepare()
+ # time.sleep(2)
+ tdSql.query("create user testpy pass 'testpy'")
+
+ #hostname = socket.gethostname()
+ #tdLog.info ("hostname: %s" % hostname)
+
+ buildPath = self.getBuildPath()
+ if (buildPath == ""):
+ tdLog.exit("taosd not found!")
+ else:
+ tdLog.info("taosd found in %s" % buildPath)
+ cfgPath = buildPath + "/../sim/psim/cfg"
+ taosdCfgPath = buildPath + "/../sim/dnode1/cfg"
+
+
+ taosdCmdRun= buildPath + '/build/bin/taosd'
+ tdLog.info("cfgPath: %s" % cfgPath)
+ # keyDict['h'] = self.hostname
+ # keyDict['c'] = cfgPath
+ # keyDict['P'] = self.serverPort
+ tdDnodes.stop(1)
+
+ startAction = " --help"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ startAction = " -h"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ startAction=" -a jsonFile:./taosdCaseTmp.json"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ os.system("echo \'{\"queryPolicy\":\"3\"}\' > taosdCaseTmp.json")
+ self.taosdCommandStop(startAction,taosdCmdRun)
+
+ startAction = " -a jsonFile:./taosdCaseTmp.json -C "
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ os.system("rm -rf taosdCaseTmp.json")
+
+ startAction = " -c " + taosdCfgPath
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandStop(startAction,taosdCmdRun)
+
+ startAction = " -s"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ startAction = " -e TAOS_QUERY_POLICY=2 "
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandStop(startAction,taosdCmdRun)
+
+
+ startAction=" -E taosdCaseTmp/.env"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ os.system(" mkdir -p taosdCaseTmp/.env ")
+ os.system("echo \'TAOS_QUERY_POLICY=3\' > taosdCaseTmp/.env ")
+ self.taosdCommandStop(startAction,taosdCmdRun)
+ os.system(" rm -rf taosdCaseTmp/.env ")
+
+ startAction = " -V"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ startAction = " -k"
+ tdLog.printNoPrefix("================================ parameter: %s"%startAction)
+ self.taosdCommandExe(startAction,taosdCmdRun)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success(f"{__file__} successfully executed")
+
+tdCases.addLinux(__file__, TDTestCase())
+tdCases.addWindows(__file__, TDTestCase())
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
index 050c10d093..8d07dc6b38 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py
@@ -61,7 +61,7 @@ class TDTestCase:
# only for 1 mnode
mnode_name = k
- if v[2] =='leader':
+ if v[2] in ['leader', 'leader*']:
is_leader=True
if count==1 and is_leader:
@@ -109,12 +109,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader', 'leader*', 'follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
index 1e1f45d65e..470278cd8e 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py
@@ -115,12 +115,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py
index ca12dd6c9d..a5ce8171c7 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py
@@ -116,12 +116,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
index 2d3e5e3178..60e3167304 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py
@@ -115,12 +115,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py
index c8fa8ee435..9d96ab1e9e 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py
@@ -116,12 +116,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py
index 447da77db3..8e7ac388fb 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py
@@ -119,12 +119,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py
index 6175f4e7cc..39bd0133cf 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py
@@ -118,12 +118,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py
index 27405774cc..6d4a9172f7 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py
@@ -118,12 +118,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py
index 1dc364c2fd..90358069aa 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py
@@ -124,12 +124,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
index 3873040d20..55a2318817 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py
@@ -124,12 +124,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py
index 188b0030f2..f5e4ea0663 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py
@@ -124,12 +124,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
index 5ba6c6ab8d..4ec558655f 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py
@@ -207,12 +207,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py
index 0a4162bd99..0a1c4e1183 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py
@@ -116,12 +116,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
index 8a6412dfcc..bd7c05b03c 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py
@@ -115,12 +115,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
index 5475d1cc37..00f20abe84 100644
--- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
+++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py
@@ -118,12 +118,12 @@ class TDTestCase:
vgroup_id = vgroup_info[0]
tmp_list = []
for role in vgroup_info[3:-4]:
- if role in ['leader','follower']:
+ if role in ['leader','leader*','follower']:
tmp_list.append(role)
vgroups_infos[vgroup_id]=tmp_list
for k , v in vgroups_infos.items():
- if len(v) ==1 and v[0]=="leader":
+ if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
diff --git a/utils/test/c/tmqSim.c b/utils/test/c/tmqSim.c
index 25e83363ee..7452a67fed 100644
--- a/utils/test/c/tmqSim.c
+++ b/utils/test/c/tmqSim.c
@@ -1262,7 +1262,7 @@ void* ombProduceThreadFunc(void* param) {
printf("Produce Info: totalSendLoopTimes: %d, batchPerTblTimes: %d, producerRate: %d\n", totalSendLoopTimes, batchPerTblTimes, pInfo->producerRate);
- char ctbName[64] = {0};
+ char ctbName[128] = {0};
sprintf(ctbName, "%s.ctb%d", g_stConfInfo.dbName, pInfo->consumerId);
int64_t lastPrintTime = taosGetTimestampUs();
diff --git a/utils/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h
index f9e96fc67b..9438e11fbd 100644
--- a/utils/tsim/inc/simInt.h
+++ b/utils/tsim/inc/simInt.h
@@ -155,7 +155,6 @@ extern int32_t simScriptSucced;
extern int32_t simDebugFlag;
extern char simScriptDir[];
extern bool abortExecution;
-extern bool useMultiProcess;
extern bool useValgrind;
SScript *simParseScript(char *fileName);
diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c
index 6f693cf015..7218ea39f8 100644
--- a/utils/tsim/src/simExe.c
+++ b/utils/tsim/src/simExe.c
@@ -292,7 +292,7 @@ int32_t simExecuteExpression(SScript *script, char *exp) {
sprintf(t3, "%" PRId64, t1l / t2l);
}
} else if (op2[0] == '.') {
- sprintf(t3, "%s%s", t1, t2);
+ snprintf(t3, sizeof(t3), "%s%s", t1, t2);
}
} else {
tstrncpy(t3, t1, sizeof(t3));
@@ -442,10 +442,6 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
simReplaceStr(buf, ".sh", ".bat");
#endif
- if (useMultiProcess) {
- simReplaceStr(buf, "deploy.sh", "deploy.sh -m");
- }
-
if (useValgrind) {
replaced = simReplaceStr(buf, "exec.sh", "exec.sh -v");
}
@@ -1044,4 +1040,4 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
return true;
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/utils/tsim/src/simMain.c b/utils/tsim/src/simMain.c
index e58a22cf68..cd4a5117b2 100644
--- a/utils/tsim/src/simMain.c
+++ b/utils/tsim/src/simMain.c
@@ -18,7 +18,6 @@
bool simExecSuccess = false;
bool abortExecution = false;
-bool useMultiProcess = false;
bool useValgrind = false;
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
@@ -34,8 +33,6 @@ int32_t main(int32_t argc, char *argv[]) {
tstrncpy(configDir, argv[++i], 128);
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
tstrncpy(scriptFile, argv[++i], MAX_FILE_NAME_LEN);
- } else if (strcmp(argv[i], "-m") == 0) {
- useMultiProcess = true;
} else if (strcmp(argv[i], "-v") == 0) {
useValgrind = true;
} else {