feat: support customized taos/taosd (#29736)

* feat: support TDAcoreOS

* chore: cmake options for TD_ACORE

* chore: disable lemon for TD_ACORE

* chore: add lzma2 and msvcregex

* chore: cmake for lzma2

* chore: adapt for TD_ACORE

* chore: adapt strcasecmp for TD_ACORE

* chore: adapt for geos/threadName

* chore: build adapt for TD_ACORE

* chore: build adapt for TD_ACORE

* chore: build adapt for TD_ACORE

* chore: build adapt for TD_ACORE

* chore: build adapt for TD_ACORE termio

* chore: refact transComm.h for TD_ACORE

* chore: refact transportInt.h for TD_ACORE

* chore: refact trans.c for TD_ACORE

* chore: refact trpc.h for TD_ACORE

* chore: refact transCli.c/transComm.c/transSvr.c for TD_ACORE

* chore: refact uv.h for TD_ACORE

* chore: refact geosWrapper.h for TD_ACORE

* chore: refact token/builtins/udf for TD_ACORE

* chore: refact rocks for TD_ACORE

* chore: refact tsdbCache.c for TD_ACORE, use LRU cache for last/last_row, not use rocksdb

* chore: refact FAIL to _ERR to solve conflicts for TD_ACORE

* chore: restore lemon.c/lempar.c

* chore: support build lemon for TD_ACORE

* chore: refact trpc and siginfo_t for TD_ACORE

* chore: refact timezone for TD_ACORE

* chore: refact lz4 for TD_ACORE

* chore: refact TD_ACORE to make compile pass

* chore: code optimization for TD_ASTRA

* feat: support run taos with taosd integrated

* feat: support invoke taos shell

* feat: support invoke taos shell

* feat: support invoke taos shell

* chore: code optimization

* chore: fix undefined reference problem os TD_ASTRA

* chore: resolve compile problem for TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix undefined reference problem os TD_ASTRA

* chore: fix getpid

* chore: fix typo

* chore: set stack size and ajust min pack size for TD_ASTRA

* chore: fix pthread create parameters

* chore: chmod adapt for TD_ASTRA

* chore: fix trans compile problem

* chore: adapt chmod for TD_ASTRA

* chore: byte alignment for TD_ASTRA

* chore: more code for adaption of TD_ASTRA

* chore: more code for adaption of TD_ASTRA

* chore: more code for adaption of TD_ASTRA

* chore: byte alignment for TD_ASTRA

* chore: conditional compile option

* chore: adapt for TD_ASTRA

* chore: adjust taosPId and msvcregex for TD_ASTRA

* chore: log dir separator for wal build name

* chore: fix type of pointer parameter

* chore: fix compile problem of tsdbGetS3Size

* enh: get last ver from wal log for TD_ASTRA

* enh: refact wal meta ver

* enh: refact wal meta ver

* fix: typo of taosUcs4Compare

* enh: process return value of CI

* chore: more code for TD_ASTRA adaption

* chore: return value of taosCloseFile in walMeta.c

* chore: fix compile problem

* chore: fix compile problem of TD_ASTRA

* fix: update macro for tq and stream task

* chore: code optimization for TD_ASTRA

* chore: restore create log and init cfg interface

* chore: restore strncasecmp and strcasecmp

* fix: adjust the field position of SDataBlockInfo

* fix: pragma pack min size

* fix: pragma pack min size

* chore: more code for TD_ASTRA adaption

* fix: type of parameters

* chore: adapt strncasecmp and strcasecmp for TD_ASTRA

* chore: restore interface of init log

* enh: pack push optimization

* fix: taos init cfg

* add astra support

* fix: fetch the value of suid

* chore: switch of  build with udf

* add temp code

* chore: more code for TD_ASTRA adaption

* chore: add macro ERRNO to replace errno

* chore: bytes align for TD_ASTRA

* fix: remove obsolete codes

* enh: support USE_UDF macro

* fix compile error

* fix: resolve redefinition problem

* fix: compile problem of log.cpp

* fix: compile problem of osTimezone

* fix: resolve compile problem of udf

* fix: pragma definition on windows

* fix: ucs4 and stpncpy for TD_ASTRA

* fix: memory align problem for TD_ASTRA

* enh: solve memory leak for TD_ASTRA_RPC

* fix: compile problem of taosSetInt64Aligned

* fix: restore mndSubscribe.c

* fix: scalar for udf

* chore: code adaption for TD_ASTRA

* chore: code optimization for TD_ASTRA

* fix: typo of add definition

* fix: typo of macro in tudf.h

* chore: remove void to make CI pass

* enh: move macro from cmake.platform to cmake.options

* enh: byte align for hash node and error code

* chore: restore the size for lru cache

* enh: restore some code about pack push

* chore: restore the pack push in tmsg.h

* fix: add macro of pack pop for windows

---------

Co-authored-by: yihaoDeng <luomoxyz@126.com>
This commit is contained in:
Kaili Xu 2025-03-14 13:32:13 +08:00 committed by GitHub
parent c4af33740e
commit 13f9bddf3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
215 changed files with 4241 additions and 1179 deletions

View File

@ -9,61 +9,61 @@ option(
)
IF(${TD_WINDOWS})
IF(NOT TD_ASTRA)
MESSAGE("build pthread Win32")
option(
BUILD_PTHREAD
"If build pthread on Windows"
ON
)
MESSAGE("build pthread Win32")
option(
BUILD_PTHREAD
"If build pthread on Windows"
ON
)
MESSAGE("build gnu regex for Windows")
option(
BUILD_GNUREGEX
"If build gnu regex on Windows"
ON
)
MESSAGE("build gnu regex for Windows")
option(
BUILD_GNUREGEX
"If build gnu regex on Windows"
ON
)
MESSAGE("build iconv Win32")
option(
BUILD_WITH_ICONV
"If build iconv on Windows"
ON
)
MESSAGE("build iconv Win32")
option(
BUILD_WITH_ICONV
"If build iconv on Windows"
ON
)
MESSAGE("build msvcregex Win32")
option(
BUILD_MSVCREGEX
"If build msvcregex on Windows"
ON
)
MESSAGE("build msvcregex Win32")
option(
BUILD_MSVCREGEX
"If build msvcregex on Windows"
ON
)
MESSAGE("build wcwidth Win32")
option(
BUILD_WCWIDTH
"If build wcwidth on Windows"
ON
)
MESSAGE("build wcwidth Win32")
option(
BUILD_WCWIDTH
"If build wcwidth on Windows"
ON
)
MESSAGE("build wingetopt Win32")
option(
BUILD_WINGETOPT
"If build wingetopt on Windows"
ON
)
MESSAGE("build wingetopt Win32")
option(
BUILD_WINGETOPT
"If build wingetopt on Windows"
ON
)
option(
TDENGINE_3
"TDengine 3.x for taos-tools"
ON
)
option(
BUILD_CRASHDUMP
"If build crashdump on Windows"
ON
)
option(
TDENGINE_3
"TDengine 3.x for taos-tools"
ON
)
option(
BUILD_CRASHDUMP
"If build crashdump on Windows"
ON
)
ENDIF ()
ELSEIF (TD_DARWIN_64)
IF(${BUILD_TEST})
add_definitions(-DCOMPILER_SUPPORTS_CXX13)
@ -71,58 +71,102 @@ ELSEIF (TD_DARWIN_64)
ENDIF ()
option(
BUILD_GEOS
"If build with geos"
BUILD_WITH_LEMON
"If build with lemon"
ON
)
option(
BUILD_WITH_UDF
"If build with UDF"
ON
)
IF(NOT TD_ASTRA)
option(
BUILD_GEOS
"If build with geos"
ON
)
option(
BUILD_SHARED_LIBS
""
OFF
)
option(
RUST_BINDINGS
"If build with rust-bindings"
ON
)
option(
BUILD_PCRE2
"If build with pcre2"
ON
)
option(
BUILD_SHARED_LIBS
""
OFF
option(
JEMALLOC_ENABLED
"If build with jemalloc"
OFF
)
option(
BUILD_SANITIZER
"If build sanitizer"
OFF
)
option(
BUILD_ADDR2LINE
"If build addr2line"
OFF
)
option(
BUILD_WITH_LEVELDB
"If build with leveldb"
OFF
)
option(
RUST_BINDINGS
"If build with rust-bindings"
ON
option(
BUILD_WITH_ROCKSDB
"If build with rocksdb"
ON
)
option(
BUILD_PCRE2
"If build with pcre2"
ON
)
option(
BUILD_WITH_LZ4
"If build with lz4"
ON
)
ELSE ()
option(
JEMALLOC_ENABLED
"If build with jemalloc"
OFF
option(
BUILD_WITH_LZMA2
"If build with lzma2"
ON
)
option(
BUILD_SANITIZER
"If build sanitizer"
OFF
)
ENDIF ()
option(
BUILD_ADDR2LINE
"If build addr2line"
OFF
)
ADD_DEFINITIONS(-DUSE_AUDIT)
ADD_DEFINITIONS(-DUSE_GEOS)
ADD_DEFINITIONS(-DUSE_UDF)
ADD_DEFINITIONS(-DUSE_STREAM)
ADD_DEFINITIONS(-DUSE_PRCE2)
ADD_DEFINITIONS(-DUSE_RSMA)
ADD_DEFINITIONS(-DUSE_TSMA)
ADD_DEFINITIONS(-DUSE_TQ)
ADD_DEFINITIONS(-DUSE_TOPIC)
ADD_DEFINITIONS(-DUSE_MONITOR)
ADD_DEFINITIONS(-DUSE_REPORT)
option(
BUILD_WITH_LEVELDB
"If build with leveldb"
OFF
)
option(
BUILD_WITH_ROCKSDB
"If build with rocksdb"
ON
)
IF(${TD_ASTRA_RPC})
ADD_DEFINITIONS(-DTD_ASTRA_RPC)
ENDIF()
IF(${TD_LINUX})
@ -150,6 +194,12 @@ option(
ON
)
option(
BUILD_WITH_LZMA2
"If build with lzma2"
ON
)
ENDIF ()
IF(NOT TD_ENTERPRISE)
@ -191,6 +241,14 @@ option(BUILD_WITH_COS "If build with cos" OFF)
ENDIF ()
IF(${TAOSD_INTEGRATED})
add_definitions(-DTAOSD_INTEGRATED)
ENDIF()
IF(${TD_AS_LIB})
add_definitions(-DTD_AS_LIB)
ENDIF()
option(
BUILD_WITH_SQLITE
"If build with sqlite"
@ -209,6 +267,14 @@ option(
off
)
option(
BUILD_WITH_NURAFT
"If build with NuRaft"
OFF
)
IF(NOT TD_ASTRA)
option(
BUILD_WITH_UV
"If build with libuv"
@ -242,6 +308,7 @@ option(
"If use invertedIndex"
ON
)
ENDIF ()
option(
BUILD_RELEASE

View File

@ -1,7 +1,6 @@
# xz
if (${TD_LINUX})
if (${BUILD_WITH_LZMA2})
ExternalProject_Add(lzma2
GIT_REPOSITORY https://github.com/conor42/fast-lzma2.git
SOURCE_DIR "${TD_CONTRIB_DIR}/lzma2"

View File

@ -92,7 +92,9 @@ if(${BUILD_TEST})
endif(${BUILD_TEST})
# lz4
cat("${TD_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
if(${BUILD_WITH_LZ4})
cat("${TD_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${BUILD_WITH_LZ4})
# zlib
cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
@ -186,16 +188,22 @@ if(${BUILD_PCRE2})
cat("${TD_SUPPORT_DIR}/pcre2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif()
find_program(C_COMPILER_LEMON NAMES gcc)
if(C_COMPILER_LEMON)
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
else()
set(C_COMPILER_LEMON ${CMAKE_C_COMPILER})
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
endif()
# lemon
cat("${TD_SUPPORT_DIR}/lemon_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
if(${BUILD_WITH_LEMON})
if(${TD_ACORE})
set(C_COMPILER_LEMON ${CMAKE_C_COMPILER})
else()
find_program(C_COMPILER_LEMON NAMES gcc)
endif()
if(C_COMPILER_LEMON)
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
else()
set(C_COMPILER_LEMON ${CMAKE_C_COMPILER})
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
endif()
cat("${TD_SUPPORT_DIR}/lemon_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif()
# Force specify CC=cc on MacOS. Because the default CC setting in the generated Makefile has issues finding standard library headers
IF(${TD_DARWIN})
@ -273,11 +281,13 @@ unset(CMAKE_PROJECT_INCLUDE_BEFORE)
# endif()
# lz4
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
target_include_directories(
lz4_static
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lz4/lib
)
if(${BUILD_WITH_LZ4})
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
target_include_directories(
lz4_static
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lz4/lib
)
endif(${BUILD_WITH_LZ4})
# zlib
set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in")

View File

@ -204,8 +204,8 @@ typedef struct SPkInfo {
typedef struct SDataBlockInfo {
STimeWindow window;
int32_t rowSize;
int64_t rows; // todo hide this attribute
uint32_t capacity;
int64_t rows; // todo hide this attribute
SBlockID id;
int16_t hasVarCol;
int16_t dataLoad; // denote if the data is loaded or not

View File

@ -174,17 +174,17 @@ static FORCE_INLINE void colDataSetInt32(SColumnInfoData* pColumnInfoData, uint3
static FORCE_INLINE void colDataSetInt64(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, int64_t* v) {
int32_t type = pColumnInfoData->info.type;
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
*(int64_t*)p = *(int64_t*)v;
taosSetPInt64Aligned((int64_t*)p, v);
}
static FORCE_INLINE void colDataSetFloat(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, float* v) {
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
*(float*)p = *(float*)v;
taosSetPFloatAligned((float*)p, v);
}
static FORCE_INLINE void colDataSetDouble(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, double* v) {
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
*(double*)p = *(double*)v;
taosSetPDoubleAligned((double*)p, v);
}
int32_t getJsonValueLen(const char* data);

View File

@ -95,13 +95,13 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111
#define COL_VAL_IS_NULL(CV) ((CV)->flag == CV_FLAG_NULL)
#define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE)
#define tRowGetKey(_pRow, _pKey) \
do { \
(_pKey)->ts = (_pRow)->ts; \
(_pKey)->numOfPKs = 0; \
if ((_pRow)->numOfPKs > 0) { \
tRowGetPrimaryKey((_pRow), (_pKey)); \
} \
#define tRowGetKey(_pRow, _pKey) \
do { \
(_pKey)->ts = taosGetInt64Aligned(&((_pRow)->ts)); \
(_pKey)->numOfPKs = 0; \
if ((_pRow)->numOfPKs > 0) { \
tRowGetPrimaryKey((_pRow), (_pKey)); \
} \
} while (0)
// SValueColumn ================================

View File

@ -527,7 +527,6 @@ typedef struct SRetention {
#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0))
#pragma pack(push, 1)
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
typedef struct SEp {
char fqdn[TSDB_FQDN_LEN];
@ -4233,7 +4232,7 @@ typedef struct {
int8_t rawData;
int32_t minPollRows;
int8_t enableBatchMeta;
SHashObj *uidHash; // to find if uid is duplicated
SHashObj *uidHash; // to find if uid is duplicated
} SMqPollReq;
int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);

View File

@ -119,8 +119,8 @@ typedef struct SInputColumnInfoData {
int32_t startRowIndex; // handle started row index
int64_t numOfRows; // the number of rows needs to be handled
bool blankFill; // fill blank data to block for empty table
int32_t numOfInputCols; // PTS is not included
bool colDataSMAIsSet; // if agg is set or not
int32_t numOfInputCols; // PTS is not included
SColumnInfoData *pPTS; // primary timestamp column
SColumnInfoData *pPrimaryKey; // primary key column
SColumnInfoData **pData;

View File

@ -20,6 +20,7 @@
extern "C" {
#endif
#ifdef USE_GEOS
#include "function.h"
int32_t makePointFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
@ -33,6 +34,7 @@ int32_t touchesFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO
int32_t coversFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t containsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
int32_t containsProperlyFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
#endif
#ifdef __cplusplus
}

View File

@ -23,6 +23,7 @@ extern "C" {
#include <stdint.h>
#include "os.h"
#ifdef USE_GEOS
#include "tgeosctx.h"
void geosFreeBuffer(void *buffer);
@ -55,6 +56,13 @@ int32_t readGeometry(const unsigned char *input, GEOSGeometry **outputGeom,
const GEOSPreparedGeometry **outputPreparedGeom);
void destroyGeometry(GEOSGeometry **geom, const GEOSPreparedGeometry **preparedGeom);
#else
int32_t initCtxAsText();
int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT);
int32_t checkWKB(const unsigned char *wkb, size_t size);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -440,6 +440,7 @@ typedef struct SRangeAroundNode {
typedef struct SSelectStmt {
ENodeType type; // QUERY_NODE_SELECT_STMT
bool isDistinct;
STimeWindow timeRange;
SNodeList* pProjectionList;
SNodeList* pProjectionBindList;
SNode* pFromTable;
@ -457,7 +458,6 @@ typedef struct SSelectStmt {
SNodeList* pOrderByList; // SOrderByExprNode
SLimitNode* pLimit;
SLimitNode* pSlimit;
STimeWindow timeRange;
SNodeList* pHint;
char stmtName[TSDB_TABLE_NAME_LEN];
uint8_t precision;
@ -638,23 +638,23 @@ typedef struct SQuery {
ENodeType type;
EQueryExecStage execStage;
EQueryExecMode execMode;
int32_t msgType;
int32_t numOfResCols;
int32_t placeholderNum;
int8_t precision;
bool haveResultSet;
bool showRewrite;
bool stableQuery;
SNode* pPrevRoot;
SNode* pRoot;
SNode* pPostRoot;
int32_t numOfResCols;
SSchema* pResSchema;
int8_t precision;
SCmdMsgInfo* pCmdMsg;
int32_t msgType;
SArray* pTargetTableList;
SArray* pTableList;
SArray* pDbList;
bool showRewrite;
int32_t placeholderNum;
SArray* pPlaceholderValues;
SNode* pPrepareRoot;
bool stableQuery;
} SQuery;
void nodesWalkSelectStmtImpl(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);

View File

@ -18,7 +18,9 @@
#include "tdatablock.h"
#ifdef USE_ROCKSDB
#include "rocksdb/c.h"
#endif
#include "tdbInt.h"
#include "tsimplehash.h"
#include "tstreamFileState.h"

View File

@ -16,9 +16,7 @@
#ifndef _TD_UTIL_HTTP_H_
#define _TD_UTIL_HTTP_H_
#include "os.h"
#include "tdef.h"
#include "tref.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {

View File

@ -19,6 +19,7 @@
extern "C" {
#endif
#ifndef TD_ASTRA_RPC
#include <stdbool.h>
#include <stdint.h>
#include "taosdef.h"
@ -190,6 +191,198 @@ int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);
int32_t rpcUtilSWhiteListToStr(SIpWhiteList *pWhiteList, char **ppBuf);
int32_t rpcCvtErrCode(int32_t code);
#else
#include <stdbool.h>
#include <stdint.h>
#include "taosdef.h"
#include "tmsg.h"
#include "ttrace.h"
#define TAOS_CONN_SERVER 0
#define TAOS_CONN_CLIENT 1
#define IsReq(pMsg) (pMsg->msgType & 1U)
extern int32_t tsRpcHeadSize;
typedef struct {
uint32_t clientIp;
uint16_t clientPort;
int64_t applyIndex;
uint64_t applyTerm;
char user[TSDB_USER_LEN];
} SRpcConnInfo;
typedef enum {
TD_ASTRA_CLIENT = 1,
TD_ASTRA_DSVR_CLIENT = 2,
TD_ASTRA_DSVR_STA_CLIENT = 4,
TD_ASTRA_DSVR_SYNC_CLIENT = 8,
TD_ASTRA_DSVR = 16
} RPC_TYPE;
typedef struct SRpcHandleInfo {
// rpc info
void *handle; // rpc handle returned to app
int64_t refId; // refid, used by server
int8_t noResp; // has response or not(default 0, 0: resp, 1: no resp)
int8_t persistHandle; // persist handle or not
int8_t hasEpSet;
int32_t cliVer;
// app info
void *ahandle; // app handle set by client
void *wrapper; // wrapper handle
void *node; // node mgmt handle
#ifdef TD_ASTRA_32
void *ahandleEx; // app handle set by client
#endif
// resp info
void *rsp;
int32_t rspLen;
STraceId traceId;
SRpcConnInfo conn;
int8_t forbiddenIp;
int8_t notFreeAhandle;
int8_t compressed;
int16_t connType;
int64_t seq;
int64_t qId;
int32_t msgType;
void *reqWithSem;
int32_t refIdMgt;
} SRpcHandleInfo;
typedef struct SRpcMsg {
tmsg_t msgType;
void *pCont;
int32_t contLen;
int32_t code;
int32_t type;
void *parent;
SRpcHandleInfo info;
} SRpcMsg;
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
typedef bool (*RpcFFfp)(tmsg_t msgType);
typedef bool (*RpcNoDelayfp)(tmsg_t msgType);
typedef void (*RpcDfp)(void *ahandle);
typedef struct SRpcInit {
char localFqdn[TSDB_FQDN_LEN];
uint16_t localPort; // local port
char *label; // for debug purpose
int32_t numOfThreads; // number of threads to handle connections
int32_t sessions; // number of sessions allowed
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
int32_t compatibilityVer;
int32_t retryMinInterval; // retry init interval
int32_t retryStepFactor; // retry interval factor
int32_t retryMaxInterval; // retry max interval
int64_t retryMaxTimeout;
int32_t failFastThreshold;
int32_t failFastInterval;
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
int8_t encryption; // encrypt or not
// the following is for client app ecurity only
char *user; // user name
// call back to process incoming msg
RpcCfp cfp;
// retry not not for particular msg
RpcRfp rfp;
// set up timeout for particular msg
RpcTfp tfp;
// destroy client ahandle;
RpcDfp dfp;
// fail fast fp
RpcFFfp ffp;
RpcNoDelayfp noDelayFp;
int32_t connLimitNum;
int32_t connLimitLock;
int32_t timeToGetConn;
int8_t supportBatch; // 0: no batch, 1. batch
int32_t batchSize;
int8_t notWaitAvaliableConn; // 1: wait to get, 0: no wait
int32_t shareConnLimit;
int8_t shareConn; // 0: no share, 1. share
int8_t startReadTimer;
int64_t readTimeout; // s
void *parent;
} SRpcInit;
typedef struct {
void *val;
int32_t (*clone)(void *src, void **dst);
} SRpcCtxVal;
typedef struct {
int32_t msgType;
void *val;
int32_t (*clone)(void *src, void **dst);
} SRpcBrokenlinkVal;
typedef struct {
SHashObj *args;
SRpcBrokenlinkVal brokenVal;
void (*freeFunc)(const void *arg);
int64_t st;
} SRpcCtx;
int32_t rpcInit();
void rpcCleanup();
void *rpcOpen(const SRpcInit *pRpc);
void rpcClose(void *);
void rpcCloseImpl(void *);
void *rpcMallocCont(int64_t contLen);
void rpcFreeCont(void *pCont);
void *rpcReallocCont(void *ptr, int64_t contLen);
// Because taosd supports multi-process mode
// These functions should not be used on the server side
// Please use tmsg<xx> functions, which are defined in tmsgcb.h
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
int32_t rpcSendResponse(SRpcMsg *pMsg);
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
int32_t rpcReleaseHandle(void *handle, int8_t type,
int32_t status); // just release conn to rpc instance, no close sock
// These functions will not be called in the child process
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
int32_t rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
int32_t rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated,
int32_t timeoutMs);
int32_t rpcFreeConnById(void *shandle, int64_t connId);
int32_t rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
int32_t rpcAllocHandle(int64_t *refId);
int32_t rpcSetIpWhite(void *thandl, void *arg);
int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);
int32_t rpcUtilSWhiteListToStr(SIpWhiteList *pWhiteList, char **ppBuf);
int32_t rpcCvtErrCode(int32_t code);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -28,29 +28,34 @@ extern "C" {
#if !defined(WINDOWS)
#include <dirent.h>
#if !defined(_ALPINE)
#if !defined(_ALPINE) && !defined(TD_ASTRA)
#include <execinfo.h>
#endif
#if !defined(TD_ASTRA)
#include <libgen.h>
#include <sched.h>
#include <unistd.h>
#include <wordexp.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <termios.h>
#else
#include <astra.h>
#endif
#include <sched.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <termios.h>
#if defined(DARWIN)
#else
#if !defined(TD_ASTRA)
#include <argp.h>
#include <sys/prctl.h>
#include <sys/sysinfo.h>
@ -58,6 +63,7 @@ extern "C" {
#include <cpuid.h>
#endif
#endif
#endif
#else
#ifndef __func__

View File

@ -108,6 +108,9 @@ void wordfree(wordexp_t *pwordexp);
#define LOG_ERR 0
#define LOG_INFO 1
void syslog(int unused, const char *format, ...);
#elif defined(TD_ASTRA)
char *stpncpy(char *dest, const char *src, int n);
char *strsep(char **stringp, const char *delim);
#endif // WINDOWS
#ifndef WINDOWS
@ -216,6 +219,9 @@ void syslog(int unused, const char *format, ...);
// pthread_setname_np not defined
#define setThreadName(name)
#endif
#elif defined(TD_ASTRA)
#define setThreadName(name)
#define getThreadName(name)
#else
// Linux, length of name must <= 16 (the last '\0' included)
#define setThreadName(name) \
@ -237,12 +243,24 @@ void syslog(int unused, const char *format, ...);
#if defined(_WIN32)
#define TD_DIRSEP "\\"
#elif defined(TD_ASTRA)
#ifdef TD_ASTRA_TARGET
#define TD_DIRSEP "/"
#else
#define TD_DIRSEP "\\"
#endif
#else
#define TD_DIRSEP "/"
#endif
#if defined(_WIN32)
#define TD_DIRSEP_CHAR '\\'
#elif defined(TD_ASTRA)
#ifdef TD_ASTRA_TARGET
#define TD_DIRSEP_CHAR '/'
#else
#define TD_DIRSEP_CHAR '\\'
#endif
#else
#define TD_DIRSEP_CHAR '/'
#endif

View File

@ -60,6 +60,20 @@ extern "C" {
#define TD_LOG_DIR_PATH "/var/log/taos/"
#endif // CUS_PROMPT
#elif defined(TD_ASTRA)
#ifdef CUS_NAME
#define TD_TMP_DIR_PATH "C:\\" CUS_NAME "\\Temp\\"
#define TD_CFG_DIR_PATH "C:\\" CUS_NAME "\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\" CUS_NAME "\\data\\"
#define TD_LOG_DIR_PATH "C:\\" CUS_NAME "\\log\\"
#else
#define TD_TMP_DIR_PATH "C:\\TDengine\\Temp\\"
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
#endif // CUS_NAME
#else
#define TD_TMP_DIR_PATH "/tmp/"

View File

@ -20,6 +20,10 @@
extern "C" {
#endif
#ifdef TD_ASTRA
#include <endian.h>
#endif
typedef enum { TD_LITTLE_ENDIAN = 0, TD_BIG_ENDIAN } td_endian_t;
static const int32_t endian_test_var = 1;

View File

@ -72,6 +72,7 @@ TdFilePtr taosCreateFile(const char *path, int32_t tdFileOptions);
#define TD_FILE_ACCESS_EXIST_OK 0x1
#define TD_FILE_ACCESS_READ_OK 0x2
#define TD_FILE_ACCESS_WRITE_OK 0x4
#define TD_FILE_ACCESS_EXEC_OK 0x8
#define TD_TMP_FILE_PREFIX "tdengine-"

View File

@ -29,13 +29,23 @@ extern "C" {
#define TPOW2(x) ((x) * (x))
#define TABS(x) ((x) > 0 ? (x) : -(x))
#define TSWAP(a, b) \
do { \
char *__tmp = (char*)alloca(sizeof(a)); \
(void)memcpy(__tmp, &(a), sizeof(a)); \
(void)memcpy(&(a), &(b), sizeof(a)); \
(void)memcpy(&(b), __tmp, sizeof(a)); \
#ifndef TD_ASTRA
#define TSWAP(a, b) \
do { \
char *__tmp = (char *)alloca(sizeof(a)); \
(void)memcpy(__tmp, &(a), sizeof(a)); \
(void)memcpy(&(a), &(b), sizeof(a)); \
(void)memcpy(&(b), __tmp, sizeof(a)); \
} while (0)
#else
#define TSWAP(a, b) \
do { \
char __tmp[sizeof(a)]; \
(void)memcpy(__tmp, &(a), sizeof(a)); \
(void)memcpy(&(a), &(b), sizeof(a)); \
(void)memcpy(&(b), __tmp, sizeof(a)); \
} while (0)
#endif
#ifdef WINDOWS

View File

@ -149,8 +149,9 @@ int32_t taosMemoryPoolInit(mpReserveFailFp, mpReserveReachFp);
} while (0)
#ifndef BUILD_TEST
extern void* gMemPoolHandle;
#if !defined(BUILD_TEST) && !defined(TD_ASTRA)
extern threadlocal void* threadPoolSession;
extern threadlocal bool threadPoolEnabled;
extern int8_t tsMemPoolFullFunc;
@ -173,10 +174,10 @@ extern int8_t tsMemPoolFullFunc;
#define taosMemoryTrim(_size, _trimed) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolTrim(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__, _trimed)) : (taosMemTrim(_size, _trimed)))
#define taosMemoryMallocAlign(_alignment, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMallocAlign(gMemPoolHandle, threadPoolSession, _alignment, _size, (char*)__FILE__, __LINE__)) : (taosMemMallocAlign(_alignment, _size)))
#else
#define taosEnableMemoryPoolUsage(_pool, _session)
#define taosDisableMemoryPoolUsage()
#define taosSaveDisableMemoryPoolUsage()
#define taosRestoreEnableMemoryPoolUsage()
#define taosEnableMemPoolUsage(_session)
#define taosDisableMemPoolUsage()
#define taosSaveDisableMemPoolUsage(_enable, _randErr)
#define taosRestoreEnableMemPoolUsage(_enable, _randErr)
#define taosMemoryMalloc(_size) taosMemMalloc(_size)
#define taosMemoryCalloc(_num, _size) taosMemCalloc(_num, _size)

View File

@ -25,10 +25,22 @@ extern "C" {
#if !defined(WINDOWS)
#ifndef ALLOW_FORBID_FUNC
#define malloc MALLOC_FUNC_TAOS_FORBID
#define calloc CALLOC_FUNC_TAOS_FORBID
#ifdef malloc
#undef malloc
#endif
#define malloc MALLOC_FUNC_TAOS_FORBID
#ifdef calloc
#undef calloc
#endif
#define calloc CALLOC_FUNC_TAOS_FORBID
#ifdef realloc
#undef realloc
#endif
#define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID
#ifdef free
#undef free
#endif
#define free FREE_FUNC_TAOS_FORBID
#ifdef strdup
#undef strdup
#define strdup STRDUP_FUNC_TAOS_FORBID

View File

@ -20,6 +20,10 @@
extern "C" {
#endif
#ifdef TD_ASTRA
#define DISALLOW_NCHAR_WITHOUT_ICONV
#endif
typedef wchar_t TdWchar;
typedef int32_t TdUcs4;
#if !defined(DISALLOW_NCHAR_WITHOUT_ICONV)// && defined(DARWIN)
@ -101,8 +105,8 @@ void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type, void* charsetC
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, void* charsetCxt);
int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len, void* charsetCxt);
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
int32_t taosUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
int32_t taosUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
bool taosValidateEncodec(const char *encodec);
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len, int32_t bufSize);
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
@ -131,6 +135,13 @@ int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
bool isHex(const char *z, uint32_t n);
bool isValidateHex(const char *z, uint32_t n);
#ifdef TD_ASTRA
static FORCE_INLINE size_t strnlen(const char *s, size_t maxlen) {
const char *end = (const char *)memchr(s, '\0', maxlen);
return end ? (size_t)(end - s) : maxlen;
}
#endif
#ifdef __cplusplus
}
#endif

View File

@ -60,7 +60,7 @@ int32_t taosGetSystemUUIDLen(char *uid, int32_t uidlen);
char *taosGetCmdlineByPID(int32_t pid);
void taosSetCoreDump(bool enable);
#if !defined(LINUX)
#if !defined(LINUX) || defined(TD_ASTRA)
#define _UTSNAME_LENGTH 65
#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH

View File

@ -35,7 +35,7 @@ extern "C" {
// #endif
#endif
#if !defined(WINDOWS) && !defined(_ALPINE)
#if !defined(WINDOWS) && !defined(_ALPINE) && !defined(TD_ASTRA)
#ifndef __USE_XOPEN2K
#define TD_USE_SPINLOCK_AS_MUTEX
typedef pthread_mutex_t pthread_spinlock_t;
@ -70,12 +70,19 @@ typedef pthread_cond_t TdThreadCond;
typedef pthread_condattr_t TdThreadCondAttr;
typedef pthread_key_t TdThreadKey;
#endif
#ifdef TD_ASTRA
#define STACK_SIZE_DEFAULT (1048576 << 1)
#define STACK_SIZE_SMALL (1048576)
#else
#define STACK_SIZE_DEFAULT (10485760)
#endif
#define taosThreadCleanupPush pthread_cleanup_push
#define taosThreadCleanupPop pthread_cleanup_pop
#if !defined(WINDOWS)
#if defined(_TD_DARWIN_64) // MACOS
#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0)
#elif defined(TD_ASTRA)
#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0)
#else // LINUX
#if _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L
#define taosThreadRwlockAttrSetKindNP(A, B) pthread_rwlockattr_setkind_np(A, B)
@ -94,7 +101,7 @@ typedef pthread_key_t TdThreadKey;
#else
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif
#if 0
// If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC
@ -200,6 +207,7 @@ typedef pthread_key_t TdThreadKey;
#define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID
#define sigwait SIGWAIT_FUNC_TAOS_FORBID
#endif
#endif
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg);
int32_t taosThreadAttrDestroy(TdThreadAttr *attr);

View File

@ -20,7 +20,7 @@
// support OEM
//
#ifndef TD_PRODUCT_NAME
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA)
#define TD_PRODUCT_NAME "TDengine Enterprise Edition"
#else
#define TD_PRODUCT_NAME "TDengine Community Edition"

View File

@ -58,6 +58,11 @@ int32_t taosGetErrSize();
#define SET_ERROR_MSG(MSG, ...) \
(void)snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
#ifndef TD_ASTRA_RTP
#define SET_ERRNO(_code) (errno = (_code))
#define ERRNO errno
#endif
#define TSDB_CODE_SUCCESS 0
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error

View File

@ -31,8 +31,8 @@ void taosConvDestroy();
//int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, void* charsetCxt);
//int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
//bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len, void* charsetCxt);
//int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
//int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
//int32_t taosUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
//int32_t taosUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
#ifdef __cplusplus
}

View File

@ -25,6 +25,20 @@ extern "C" {
#define TSDB__packed
#if defined(TD_ASTRA_32)
#define PACK_PUSH_MIN _Pragma("pack(push, 4)")
#elif defined(WINDOWS)
#define PACK_PUSH_MIN __pragma(pack(push, 1))
#else
#define PACK_PUSH_MIN _Pragma("pack(push, 1)")
#endif
#if defined(WINDOWS)
#define PACK_POP __pragma(pack(pop))
#else
#define PACK_POP _Pragma("pack(pop)")
#endif
#define TSKEY int64_t
#define TSKEY_MIN INT64_MIN
#define TSKEY_MAX INT64_MAX

View File

@ -20,6 +20,7 @@
extern "C" {
#endif
#ifdef USE_GEOS
#include <geos_c.h>
#include <tpcre2.h>
@ -41,6 +42,7 @@ typedef struct SGeosContext {
SGeosContext *acquireThreadLocalGeosCtx();
int32_t getThreadLocalGeosCtx(SGeosContext **ppCtx);
const char *getGeosErrMsg(int32_t code);
#endif
#ifdef __cplusplus
}

View File

@ -34,6 +34,11 @@ typedef enum {
DEBUG_FILE = 128
} ELogLevel;
typedef enum {
LOG_MODE_TAOSC = 1,
LOG_MODE_TAOSD = 2
} ELogMode;
typedef void (*LogFp)(int64_t ts, ELogLevel level, const char *content);
extern bool tsLogEmbedded;

View File

@ -16,6 +16,7 @@
#ifndef _TD_ULIT_PCRE2_H_
#define _TD_ULIT_PCRE2_H_
#ifdef USE_PRCE2
#define PCRE2_CODE_UNIT_WIDTH 8
#include "pcre2.h"
@ -31,4 +32,5 @@ void destroyRegexes(pcre2_code* pWktRegex, pcre2_match_data* pWktMatchData);
}
#endif
#endif // USE_PRCE2
#endif // _TD_UTIL_PAGEDBUF_H_

View File

@ -54,6 +54,136 @@ int32_t parseCfgReal(const char *str, float *out);
bool tIsValidFileName(const char *fileName, const char *pattern);
bool tIsValidFilePath(const char *filePath, const char *pattern);
#ifdef TD_ASTRA
static FORCE_INLINE int32_t taosStrcasecmp(const char *s1, const char *s2) {
if (s1[0] == 0 && s2[0] == 0) return 0;
return strcasecmp(s1, s2);
}
static FORCE_INLINE int32_t taosStrncasecmp(const char *s1, const char *s2, size_t n) {
if (s1[0] == 0 && s2[0] == 0) return 0;
return strncasecmp(s1, s2, n);
}
#else
#define taosStrcasecmp strcasecmp
#define taosStrncasecmp strncasecmp
#endif
#ifdef NO_UNALIGNED_ACCESS
#define CHECK_ALIGNMENT
static FORCE_INLINE int64_t taosGetInt64Aligned(int64_t *pVal) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
#endif
int64_t val;
memcpy(&val, pVal, sizeof(int64_t));
return val;
}
static FORCE_INLINE uint64_t taosGetUInt64Aligned(uint64_t *pVal) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
#endif
uint64_t val;
memcpy(&val, pVal, sizeof(uint64_t));
return val;
}
static FORCE_INLINE float taosGetFloatAligned(float *pVal) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
#endif
float val;
memcpy(&val, pVal, sizeof(float));
return val;
}
static FORCE_INLINE double taosGetDoubleAligned(double *pVal) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
#endif
double val;
memcpy(&val, pVal, sizeof(double));
return val;
}
static FORCE_INLINE void taosSetInt64Aligned(int64_t *p, int64_t val) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)p) & 7) == 0) {
*p = val;
return;
}
#endif
memcpy(p, &val, sizeof(int64_t));
}
static FORCE_INLINE void taosSetUInt64Aligned(uint64_t *p, uint64_t val) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)p) & 7) == 0) {
*p = val;
return;
}
#endif
memcpy(p, &val, sizeof(uint64_t));
}
static FORCE_INLINE void taosSetPInt64Aligned(int64_t *to, int64_t *from) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
*to = *from;
return;
}
#endif
memcpy(to, from, sizeof(int64_t));
}
static FORCE_INLINE void taosSetPFloatAligned(float *to, float *from) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
*to = *from;
return;
}
#endif
memcpy(to, from, sizeof(float));
}
static FORCE_INLINE void taosSetPDoubleAligned(double *to, double *from) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
*to = *from;
return;
}
#endif
memcpy(to, from, sizeof(double));
}
static FORCE_INLINE void taosSetPUInt64Aligned(uint64_t *to, uint64_t *from) {
#ifdef CHECK_ALIGNMENT
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
*to = *from;
return;
}
#endif
memcpy(to, from, sizeof(uint64_t));
}
#define TAOS_SET_OBJ_ALIGNED(pTo, vFrom) memcpy((pTo), &(vFrom), sizeof(*(pTo)))
#define TAOS_SET_POBJ_ALIGNED(pTo, pFrom) memcpy((pTo), (pFrom), sizeof(*(pTo)))
#else
static FORCE_INLINE int64_t taosGetInt64Aligned(int64_t *pVal) { return *pVal; }
static FORCE_INLINE uint64_t taosGetUInt64Aligned(uint64_t *pVal) { return *pVal; }
static FORCE_INLINE float taosGetFloatAligned(float *pVal) { return *pVal; }
static FORCE_INLINE double taosGetDoubleAligned(double *pVal) { return *pVal; }
static FORCE_INLINE void taosSetInt64Aligned(int64_t *p, int64_t val) { *p = val; }
static FORCE_INLINE void taosSetUInt64Aligned(uint64_t *p, uint64_t val) { *p = val; }
static FORCE_INLINE void taosSetPInt64Aligned(int64_t *to, int64_t *from) { *to = *from; }
static FORCE_INLINE void taosSetPFloatAligned(float *to, float *from) { *to = *from; }
static FORCE_INLINE void taosSetPDoubleAligned(double *to, double *from) { *to = *from; }
static FORCE_INLINE void taosSetPUInt64Aligned(uint64_t *to, uint64_t *from) { *to = *from; }
#define TAOS_SET_OBJ_ALIGNED(pTo, vFrom) *(pTo) = (vFrom)
#define TAOS_SET_POBJ_ALIGNED(pTo, pFrom) *(pTo) = *(pFrom)
#endif
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
T_MD5_CTX context;
tMD5Init(&context);
@ -148,20 +278,20 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
#define QUERY_CHECK_CODE TSDB_CHECK_CODE
#define TSDB_CHECK_CONDITION(condition, CODE, LINO, LABEL, ERRNO) \
if (UNLIKELY(!(condition))) { \
(CODE) = (ERRNO); \
(LINO) = __LINE__; \
goto LABEL; \
#define TSDB_CHECK_CONDITION(condition, CODE, LINO, LABEL, _ERRNO) \
if (UNLIKELY(!(condition))) { \
(CODE) = (_ERRNO); \
(LINO) = __LINE__; \
goto LABEL; \
}
#define QUERY_CHECK_CONDITION TSDB_CHECK_CONDITION
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \
if (UNLIKELY((ptr) == NULL)) { \
(CODE) = (ERRNO); \
(LINO) = __LINE__; \
goto LABEL; \
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, _ERRNO) \
if (UNLIKELY((ptr) == NULL)) { \
(CODE) = (_ERRNO); \
(LINO) = __LINE__; \
goto LABEL; \
}
#define QUERY_CHECK_NULL TSDB_CHECK_NULL
@ -170,7 +300,7 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
#define TAOS_GET_TERRNO(code) (terrno == 0 ? code : terrno)
@ -187,13 +317,13 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
} \
} while (0)
#define TAOS_CHECK_RETURN_SET_CODE(CMD, CODE, ERRNO) \
do { \
int32_t __c = (CMD); \
if (__c != TSDB_CODE_SUCCESS) { \
(CODE) = (ERRNO); \
TAOS_RETURN(__c); \
} \
#define TAOS_CHECK_RETURN_SET_CODE(CMD, CODE, _ERRNO) \
do { \
int32_t __c = (CMD); \
if (__c != TSDB_CODE_SUCCESS) { \
(CODE) = (_ERRNO); \
TAOS_RETURN(__c); \
} \
} while (0)
#define TAOS_CHECK_RETURN_WITH_RELEASE(CMD, PTR1, PTR2) \
@ -234,14 +364,14 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
} \
} while (0)
#define TAOS_CHECK_EXIT_SET_CODE(CMD, CODE, ERRNO) \
do { \
code = (CMD); \
if (code < TSDB_CODE_SUCCESS) { \
(CODE) = (ERRNO); \
lino = __LINE__; \
goto _exit; \
} \
#define TAOS_CHECK_EXIT_SET_CODE(CMD, CODE, _ERRNO) \
do { \
code = (CMD); \
if (code < TSDB_CODE_SUCCESS) { \
(CODE) = (_ERRNO); \
lino = __LINE__; \
goto _exit; \
} \
} while (0)
#define TAOS_UNUSED(expr) (void)(expr)

View File

@ -21,10 +21,14 @@ target_include_directories(
PUBLIC "${TD_SOURCE_DIR}/include/client"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
set(TAOSD_MODULE "")
if(${TAOSD_INTEGRATED})
set(TAOSD_MODULE "taosd")
endif()
target_link_libraries(
${TAOS_LIB}
INTERFACE api
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry ${TAOSD_MODULE}
)
if(TD_WINDOWS)

View File

@ -119,17 +119,17 @@ typedef struct {
} SAppInstServerCFG;
struct SAppInstInfo {
int64_t numOfConns;
SCorEpSet mgmtEp;
int32_t totalDnodes;
int32_t onlineDnodes;
TdThreadMutex qnodeMutex;
SArray* pQnodeList;
SAppClusterSummary summary;
SList* pConnList; // STscObj linked list
int64_t clusterId;
SAppClusterSummary summary;
SArray* pQnodeList;
SList* pConnList; // STscObj linked list
void* pTransporter;
SAppHbMgr* pAppHbMgr;
char* instKey;
TdThreadMutex qnodeMutex;
SCorEpSet mgmtEp;
SAppInstServerCFG serverCfg;
};
@ -265,8 +265,9 @@ typedef struct SReqRelInfo {
typedef struct SRequestObj {
int8_t resType; // query or tmq
uint64_t requestId;
int32_t type; // request type
uint64_t requestId;
SQuery* pQuery;
STscObj* pTscObj;
char* pDb; // current database string
char* sqlstr; // sql string
@ -294,7 +295,6 @@ typedef struct SRequestObj {
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
uint32_t retry;
int64_t allocatorRefId;
SQuery* pQuery;
void* pPostPlan;
SReqRelInfo relation;
void* pWrapper;

View File

@ -54,9 +54,9 @@
#define ENV_ERR_RET(c, info) \
do { \
int32_t _code = c; \
int32_t _code = (c); \
if (_code != TSDB_CODE_SUCCESS) { \
errno = _code; \
terrno = _code; \
tscInitRes = _code; \
tscError(info); \
return; \
@ -128,7 +128,7 @@ static void concatStrings(SArray *list, char *buf, int size) {
}
}
}
#ifdef USE_REPORT
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration) {
cJSON *json = cJSON_CreateObject();
int32_t code = TSDB_CODE_SUCCESS;
@ -217,7 +217,7 @@ _end:
cJSON_Delete(json);
return code;
}
#endif
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char *exceptDb) {
if (pRequest->pDb != NULL) {
return strcmp(pRequest->pDb, exceptDb) != 0;
@ -283,6 +283,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
}
}
#ifdef USE_REPORT
if (pTscObj->pAppInfo->serverCfg.monitorParas.tsEnableMonitor) {
if (QUERY_NODE_VNODE_MODIFY_STMT == pRequest->stmtType || QUERY_NODE_INSERT_STMT == pRequest->stmtType) {
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPEINSERT);
@ -308,6 +309,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
}
}
}
#endif
releaseTscObj(pTscObj->id);
}
@ -789,7 +791,7 @@ void stopAllQueries(SRequestObj *pRequest) {
}
}
}
#ifdef USE_REPORT
void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop, -1); }
static void *tscCrashReportThreadFp(void *param) {
@ -888,15 +890,15 @@ int32_t tscCrashReportInit() {
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
TdThread crashReportThread;
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
tscError("failed to create crashReport thread since %s", strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
TSC_ERR_RET(errno);
tscError("failed to create crashReport thread since %s", strerror(ERRNO));
terrno = TAOS_SYSTEM_ERROR(ERRNO);
TSC_ERR_RET(terrno);
}
(void)taosThreadAttrDestroy(&thAttr);
_return:
if (code) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
TSC_ERR_RET(terrno);
}
@ -921,6 +923,113 @@ void tscStopCrashReport() {
void tscWriteCrashInfo(int signum, void *sigInfo, void *context) {
writeCrashLogToFile(signum, sigInfo, CUS_PROMPT, lastClusterId, appInfo.startTime);
}
#endif
#ifdef TAOSD_INTEGRATED
typedef struct {
TdThread pid;
int32_t stat; // < 0: start failed, 0: init(not start), 1: start successfully
} SDaemonObj;
extern int dmStartDaemon(int argc, char const *argv[]);
extern void dmStopDaemon();
SDaemonObj daemonObj = {0};
typedef struct {
int32_t argc;
char **argv;
} SExecArgs;
static void *dmStartDaemonFunc(void *param) {
int32_t code = 0;
SExecArgs *pArgs = (SExecArgs *)param;
int32_t argc = pArgs->argc;
char **argv = pArgs->argv;
code = dmStartDaemon(argc, (const char **)argv);
if (code != 0) {
printf("failed to start taosd since %s\r\n", tstrerror(code));
goto _exit;
}
_exit:
if (code != 0) {
atomic_store_32(&daemonObj.stat, code);
}
return NULL;
}
static int32_t shellStartDaemon(int argc, char *argv[]) {
int32_t code = 0, lino = 0;
SExecArgs *pArgs = NULL;
int64_t startMs = taosGetTimestampMs(), endMs = startMs;
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
pArgs = (SExecArgs *)taosMemoryCalloc(1, sizeof(SExecArgs));
if (pArgs == NULL) {
code = terrno;
TAOS_CHECK_EXIT(code);
}
pArgs->argc = argc;
pArgs->argv = argv;
#ifndef TD_AS_LIB
tsLogEmbedded = 1;
#endif
TAOS_CHECK_EXIT(taosThreadCreate(&daemonObj.pid, &thAttr, dmStartDaemonFunc, pArgs));
while (true) {
if (atomic_load_64(&tsDndStart)) {
atomic_store_32(&daemonObj.stat, 1);
break;
}
int32_t daemonstat = atomic_load_32(&daemonObj.stat);
if (daemonstat < 0) {
code = daemonstat;
TAOS_CHECK_EXIT(code);
}
if (daemonstat > 1) {
code = TSDB_CODE_APP_ERROR;
TAOS_CHECK_EXIT(code);
}
taosMsleep(1000);
}
_exit:
endMs = taosGetTimestampMs();
(void)taosThreadAttrDestroy(&thAttr);
taosMemoryFreeClear(pArgs);
if (code) {
printf("\r\n The daemon start failed at line %d since %s, cost %" PRIi64 " ms\r\n", lino, tstrerror(code),
endMs - startMs);
} else {
printf("\r\n The daemon started successfully, cost %" PRIi64 " ms\r\n", endMs - startMs);
}
#ifndef TD_AS_LIB
tsLogEmbedded = 0;
#endif
return code;
}
void shellStopDaemon() {
#ifndef TD_AS_LIB
tsLogEmbedded = 1;
#endif
dmStopDaemon();
if (taosCheckPthreadValid(daemonObj.pid)) {
(void)taosThreadJoin(daemonObj.pid, NULL);
taosThreadClear(&daemonObj.pid);
}
}
#endif
void taos_init_imp(void) {
#if defined(LINUX)
@ -938,7 +1047,8 @@ void taos_init_imp(void) {
// In the APIs of other program language, taos_cleanup is not available yet.
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
(void)atexit(taos_cleanup);
errno = TSDB_CODE_SUCCESS;
SET_ERRNO(TSDB_CODE_SUCCESS);
terrno = TSDB_CODE_SUCCESS;
taosSeedRand(taosGetTimestampSec());
appInfo.pid = taosGetPId();
@ -956,20 +1066,26 @@ void taos_init_imp(void) {
const char *logName = CUS_PROMPT "log";
ENV_ERR_RET(taosInitLogOutput(&logName), "failed to init log output");
if (taosCreateLog(logName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logName, strerror(errno), configDir);
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logName, strerror(ERRNO), configDir);
tscInitRes = terrno;
return;
}
#ifdef TAOSD_INTEGRATED
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0), "failed to init cfg");
#else
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1), "failed to init cfg");
#endif
initQueryModuleMsgHandle();
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
tscInitRes = terrno;
tscError("failed to init conv");
return;
}
#ifndef WINDOWS
#endif
#if !defined(WINDOWS) && !defined(TD_ASTRA)
ENV_ERR_RET(tzInit(), "failed to init timezone");
#endif
ENV_ERR_RET(monitorInit(), "failed to init monitor");
@ -997,9 +1113,13 @@ void taos_init_imp(void) {
ENV_ERR_RET(taosGetAppName(appInfo.appName, NULL), "failed to get app name");
ENV_ERR_RET(taosThreadMutexInit(&appInfo.mutex, NULL), "failed to init thread mutex");
#ifdef USE_REPORT
ENV_ERR_RET(tscCrashReportInit(), "failed to init crash report");
#endif
ENV_ERR_RET(qInitKeywordsTable(), "failed to init parser keywords table");
#ifdef TAOSD_INTEGRATED
ENV_ERR_RET(shellStartDaemon(0, NULL), "failed to start taosd daemon");
#endif
tscInfo("TAOS driver is initialized successfully");
}

View File

@ -187,7 +187,7 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
for (int32_t j = 0; j < rsp->vgNum; ++j) {
SVgroupInfo *pInfo = taosArrayGet(rsp->pVgroupInfos, j);
if (taosHashPut(vgInfo->vgHash, &pInfo->vgId, sizeof(int32_t), pInfo, sizeof(SVgroupInfo)) != 0) {
tscError("hash push failed, errno:%d", errno);
tscError("hash push failed, terrno:%d", terrno);
code = terrno;
goto _return;
}
@ -1401,16 +1401,19 @@ static int32_t hbCreateThread() {
TdThreadAttr thAttr;
TSC_ERR_JRET(taosThreadAttrInit(&thAttr));
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
#ifdef TD_COMPACT_OS
TSC_ERR_JRET(taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL));
#endif
if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
TSC_ERR_RET(terrno);
}
(void)taosThreadAttrDestroy(&thAttr);
_return:
if (code) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
TSC_ERR_RET(terrno);
}
@ -1431,12 +1434,12 @@ static void hbStopThread() {
if (clientHbMgr.quitByKill) {
code = taosThreadKill(clientHbMgr.thread, 0);
if (TSDB_CODE_SUCCESS != code) {
tscError("taosThreadKill failed since %s", tstrerror(TAOS_SYSTEM_ERROR(code)));
tscError("taosThreadKill failed since %s", tstrerror(code));
}
} else {
code = taosThreadJoin(clientHbMgr.thread, NULL);
if (TSDB_CODE_SUCCESS != code) {
tscError("taosThreadJoin failed since %s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
tscError("taosThreadJoin failed since %s", tstrerror(code));
}
}

View File

@ -2413,7 +2413,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, bool convertUcs4) {
int32_t hasColumnSeg = *(int32_t*)p;
p += sizeof(int32_t);
uint64_t groupId = *(uint64_t*)p;
uint64_t groupId = taosGetUInt64Aligned((uint64_t*)p);
p += sizeof(uint64_t);
// check fields
@ -2469,10 +2469,11 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, bool convertUcs4) {
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
if (convertUcs4) {
code = doConvertUCS4(pResultInfo, colLength);
}
#endif
return code;
}

View File

@ -35,6 +35,10 @@
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
#ifdef TAOSD_INTEGRATED
extern void shellStopDaemon();
#endif
static int32_t sentinel = TSC_VAR_NOT_RELEASE;
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SSqlCallbackWrapper *pWrapper);
@ -55,7 +59,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
return ret;
}
#ifndef WINDOWS
#if !defined(WINDOWS) && !defined(TD_ASTRA)
static void freeTz(void *p) {
timezone_t tz = *(timezone_t *)p;
tzfree(tz);
@ -95,7 +99,7 @@ static timezone_t setConnnectionTz(const char *val) {
tz = tzalloc("UTC");
if (tz == NULL) {
tscError("%s set timezone UTC error", __func__);
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
goto END;
}
}
@ -153,6 +157,7 @@ static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, co
val = NULL;
}
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
if (option == TSDB_OPTION_CONNECTION_CHARSET || option == TSDB_OPTION_CONNECTION_CLEAR) {
if (val != NULL) {
if (!taosValidateEncodec(val)) {
@ -169,9 +174,9 @@ static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, co
pObj->optionInfo.charsetCxt = NULL;
}
}
#endif
if (option == TSDB_OPTION_CONNECTION_TIMEZONE || option == TSDB_OPTION_CONNECTION_CLEAR) {
#ifndef WINDOWS
#if !defined(WINDOWS) && !defined(TD_ASTRA)
if (val != NULL) {
if (val[0] == 0) {
val = "UTC";
@ -239,7 +244,7 @@ void taos_cleanup(void) {
tscWarn("failed to cleanup task queue");
}
#ifndef WINDOWS
#if !defined(WINDOWS) && !defined(TD_ASTRA)
tzCleanup();
#endif
tmqMgmtClose();
@ -259,10 +264,14 @@ void taos_cleanup(void) {
taosConvDestroy();
DestroyRegexCache();
#ifdef TAOSD_INTEGRATED
shellStopDaemon();
#endif
tscInfo("all local resources released");
taosCleanupCfg();
#ifndef TAOSD_INTEGRATED
taosCloseLog();
#endif
}
static setConfRet taos_set_config_imp(const char *config) {
@ -2170,7 +2179,7 @@ int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col
}
STscStmt2 *pStmt = (STscStmt2 *)stmt;
if( atomic_load_8((int8_t*)&pStmt->asyncBindParam.asyncBindNum)>1) {
if (atomic_load_8((int8_t *)&pStmt->asyncBindParam.asyncBindNum) > 1) {
tscError("async bind param is still working, please try again later");
return TSDB_CODE_TSC_STMT_API_ERROR;
}
@ -2283,7 +2292,7 @@ int taos_stmt2_bind_param_a(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t c
(void)taosThreadCondSignal(&(pStmt->asyncBindParam.waitCond));
(void)atomic_sub_fetch_8(&pStmt->asyncBindParam.asyncBindNum, 1);
(void)taosThreadMutexUnlock(&(pStmt->asyncBindParam.mutex));
tscError("async bind failed, code:%d , %s", code_s, tstrerror(code_s));
tscError("async bind failed, code:%d , %s", code_s, tstrerror(code_s));
}
return code_s;

View File

@ -669,8 +669,8 @@ static void monitorSendAllSlowLog() {
int64_t size = getFileSize(pClient->path);
if (size <= 0) {
if (size < 0) {
tscError("monitor failed to get file size:%s, err:%d", pClient->path, errno);
if (errno == ENOENT) {
tscError("monitor failed to get file size:%s, err:%d", pClient->path, ERRNO);
if (ERRNO == ENOENT) {
processFileRemoved(pClient);
}
}
@ -810,16 +810,16 @@ static void* monitorThreadFunc(void* param) {
static int32_t tscMonitortInit() {
TdThreadAttr thAttr;
if (taosThreadAttrInit(&thAttr) != 0) {
tscError("failed to init thread attr since %s", strerror(errno));
tscError("failed to init thread attr since %s", strerror(ERRNO));
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) {
tscError("failed to set thread attr since %s", strerror(errno));
tscError("failed to set thread attr since %s", strerror(ERRNO));
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) {
tscError("failed to create monitor thread since %s", strerror(errno));
tscError("failed to create monitor thread since %s", strerror(ERRNO));
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
@ -873,7 +873,7 @@ int32_t monitorInit() {
if (tsem2_init(&monitorSem, 0, 0) != 0) {
tscError("sem init error since %s", terrstr());
return TAOS_SYSTEM_ERROR(errno);
return TAOS_SYSTEM_ERROR(ERRNO);
}
code = taosOpenQueue(&monitorQueue);

View File

@ -151,12 +151,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
POINTER_BYTES) != 0) {
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
} else {
#ifdef USE_MONITOR
MonitorSlowLogData data = {0};
data.clusterId = pTscObj->pAppInfo->clusterId;
data.type = SLOW_LOG_READ_BEGINNIG;
(void)monitorPutData2MonitorQueue(data); // ignore
monitorClientSlowQueryInit(connectRsp.clusterId);
monitorClientSQLReqInit(connectRsp.clusterId);
#endif
}
}

View File

@ -37,9 +37,9 @@
kvVal->f = (float)result;
#define SET_BIGINT \
errno = 0; \
SET_ERRNO(0); \
int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \
if (errno == ERANGE) { \
if (ERRNO == ERANGE) { \
smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \
return false; \
} \
@ -63,9 +63,9 @@
kvVal->i = result;
#define SET_UBIGINT \
errno = 0; \
SET_ERRNO(0); \
uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \
if (errno == ERANGE || result < 0) { \
if (ERRNO == ERANGE || result < 0) { \
smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \
return false; \
} \
@ -1247,7 +1247,9 @@ void freeSSmlKv(void *data) {
SSmlKv *kv = (SSmlKv *)data;
if (kv->keyEscaped) taosMemoryFreeClear(kv->key);
if (kv->valueEscaped) taosMemoryFreeClear(kv->value);
#ifdef USE_GEOS
if (kv->type == TSDB_DATA_TYPE_GEOMETRY) geosFreeBuffer((void *)(kv->value));
#endif
if (kv->type == TSDB_DATA_TYPE_VARBINARY) taosMemoryFreeClear(kv->value);
}

View File

@ -97,13 +97,14 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
}
if (pVal->value[0] == 'g' || pVal->value[0] == 'G') { // geometry
#ifdef USE_GEOS
if (pVal->length >= NCHAR_ADD_LEN && pVal->value[1] == '"' && pVal->value[pVal->length - 1] == '"') {
int32_t code = initCtxGeomFromText();
if (code != TSDB_CODE_SUCCESS) {
return code;
}
char* tmp = taosMemoryCalloc(pVal->length, 1);
if (tmp == NULL){
char *tmp = taosMemoryCalloc(pVal->length, 1);
if (tmp == NULL) {
return terrno;
}
(void)memcpy(tmp, pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN);
@ -115,12 +116,15 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
pVal->type = TSDB_DATA_TYPE_GEOMETRY;
if (pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
geosFreeBuffer((void*)(pVal->value));
geosFreeBuffer((void *)(pVal->value));
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
}
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_TSC_INVALID_VALUE;
#else
return TSDB_CODE_OPS_NOT_SUPPORT;
#endif
}
if (pVal->value[0] == 'b' || pVal->value[0] == 'B') { // varbinary

View File

@ -809,7 +809,7 @@ int32_t stmtStartBindThread(STscStmt* pStmt) {
}
if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
STMT_ERR_RET(terrno);
}

View File

@ -738,7 +738,7 @@ static int32_t stmtStartBindThread(STscStmt2* pStmt) {
}
if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
STMT_ERR_RET(terrno);
}
@ -852,7 +852,7 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
pStmt->sql.siInfo.tableColsReady = true;
if (pStmt->options.asyncExecFn) {
if (tsem_init(&pStmt->asyncExecSem, 0, 1) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
terrno = TAOS_SYSTEM_ERROR(ERRNO);
(void)stmtClose2(pStmt);
return NULL;
}

View File

@ -1346,13 +1346,13 @@ static void doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
static int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
if (pParam == NULL) {
goto FAIL;
goto _ERR;
}
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId);
if (tmq == NULL) {
code = TSDB_CODE_TMQ_CONSUMER_CLOSED;
goto FAIL;
goto _ERR;
}
if (code != TSDB_CODE_SUCCESS) {
@ -1408,7 +1408,7 @@ static int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
}
}
FAIL:
_ERR:
if (pParam && pParam->sync) {
SAskEpInfo* pInfo = pParam->pParam;
if (pInfo) {
@ -1760,7 +1760,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
// init semaphore
if (tsem2_init(&pTmq->rspSem, 0, 0) != 0) {
tqErrorC("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId,
tstrerror(TAOS_SYSTEM_ERROR(errno)), pTmq->groupId);
tstrerror(TAOS_SYSTEM_ERROR(ERRNO)), pTmq->groupId);
SET_ERROR_MSG_TMQ("init t_sem failed")
goto _failed;
}

View File

@ -217,7 +217,7 @@ static int32_t cos_cp_save_json(cJSON const* json, SCheckpoint* checkpoint) {
}
if (taosFsyncFile(fp) < 0) {
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(ERRNO), &lino, _exit);
}
_exit:

View File

@ -6,7 +6,7 @@
#include "tglobal.h"
#define ERRNO_ERR_FORMAT "errno:%d,msg:%s"
#define ERRNO_ERR_DATA errno, strerror(errno)
#define ERRNO_ERR_DATA ERRNO, strerror(ERRNO)
// deleteRsync function produce empty directories, traverse base directory to remove them
static void removeEmptyDir() {
@ -150,7 +150,7 @@ int32_t startRsync() {
if (taosMulMkDir(tsCheckpointBackupDir) != 0) {
uError("[rsync] build checkpoint backup dir failed, path:%s," ERRNO_ERR_FORMAT, tsCheckpointBackupDir,
ERRNO_ERR_DATA);
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
return code;
}
@ -170,10 +170,10 @@ int32_t startRsync() {
code = system(cmd);
if (code != 0) {
uError("[rsync] cmd:%s start server failed, code:%d," ERRNO_ERR_FORMAT, cmd, code, ERRNO_ERR_DATA);
if (errno == 0) {
if (ERRNO == 0) {
return 0;
} else {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
}
} else {
uInfo("[rsync] cmd:%s start server successful", cmd);
@ -223,7 +223,7 @@ int32_t uploadByRsync(const char* id, const char* path, int64_t checkpointId) {
if (code != 0) {
uError("[rsync] s-task:%s prepare checkpoint dir in %s to %s failed, code:%d," ERRNO_ERR_FORMAT, id, path,
tsSnodeAddress, code, ERRNO_ERR_DATA);
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
} else {
int64_t el = (taosGetTimestampMs() - st);
uDebug("[rsync] s-task:%s prepare checkpoint dir in:%s to %s successfully, elapsed time:%" PRId64 "ms", id, path,
@ -267,7 +267,7 @@ int32_t uploadByRsync(const char* id, const char* path, int64_t checkpointId) {
if (code != 0) {
uError("[rsync] s-task:%s upload checkpoint data in %s to %s failed, code:%d," ERRNO_ERR_FORMAT, id, path,
tsSnodeAddress, code, ERRNO_ERR_DATA);
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
} else {
int64_t el = (taosGetTimestampMs() - st);
uDebug("[rsync] s-task:%s upload checkpoint data in:%s to %s successfully, elapsed time:%" PRId64 "ms", id, path,
@ -355,7 +355,7 @@ int32_t deleteRsync(const char* id) {
int32_t code = taosMkDir(tmp);
if (code != 0) {
uError("[rsync] make tmp dir failed. code:%d," ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA);
return TAOS_SYSTEM_ERROR(errno);
return TAOS_SYSTEM_ERROR(ERRNO);
}
char command[PATH_MAX] = {0};
@ -367,7 +367,7 @@ int32_t deleteRsync(const char* id) {
taosRemoveDir(tmp);
if (code != 0) {
uError("[rsync] get failed code:%d," ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA);
return TAOS_SYSTEM_ERROR(errno);
return TAOS_SYSTEM_ERROR(ERRNO);
}
uDebug("[rsync] delete data:%s successful", id);

View File

@ -1472,7 +1472,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, 0);
SBlockOrderInfo* pOrder = taosArrayGet(pOrderInfo, 0);
if (pColInfoData == NULL || pOrder == NULL) {
return errno;
return terrno;
}
int64_t p0 = taosGetTimestampUs();
@ -1861,14 +1861,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
// window start ts
void* px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
// window end ts
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
@ -1878,14 +1878,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
// uid
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
// group id
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
@ -1895,14 +1895,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
// calculate start ts
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
// calculate end ts
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
@ -1911,7 +1911,7 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
infoData.info.bytes = VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN;
px = taosArrayPush(p->pDataBlock, &infoData);
if (px == NULL) {
code = errno;
code = terrno;
goto _err;
}
@ -3260,7 +3260,11 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, size_t dataBuflen, in
data += sizeof(bool);
*actualLen = dataLen;
#ifndef NO_UNALIGNED_ACCESS
*groupId = pBlock->info.id.groupId;
#else
taosSetPUInt64Aligned(groupId, &pBlock->info.id.groupId);
#endif
if (dataLen > dataBuflen) goto _exit;
return dataLen;
@ -3300,7 +3304,11 @@ int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos
pStart += sizeof(int32_t);
// group id sizeof(uint64_t)
#ifndef NO_UNALIGNED_ACCESS
pBlock->info.id.groupId = *(uint64_t*)pStart;
#else
taosSetPUInt64Aligned(&pBlock->info.id.groupId, (uint64_t*)pStart);
#endif
pStart += sizeof(uint64_t);
if (pBlock->pDataBlock == NULL) {

View File

@ -1372,7 +1372,7 @@ int32_t tValueCompare(const SValue *tv1, const SValue *tv2) {
return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0));
}
case TSDB_DATA_TYPE_NCHAR: {
int32_t ret = tasoUcs4Compare((TdUcs4 *)tv1->pData, (TdUcs4 *)tv2->pData,
int32_t ret = taosUcs4Compare((TdUcs4 *)tv1->pData, (TdUcs4 *)tv2->pData,
tv1->nData < tv2->nData ? tv1->nData : tv2->nData);
return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0));
}

View File

@ -61,8 +61,12 @@ int32_t tsMaxShellConns = 50000;
int32_t tsShellActivityTimer = 3; // second
// memory pool
int8_t tsMemPoolFullFunc = 0;
int8_t tsQueryUseMemoryPool = 1;
int8_t tsMemPoolFullFunc = 0;
#ifndef TD_ASTRA
int8_t tsQueryUseMemoryPool = 1;
#else
int8_t tsQueryUseMemoryPool = 0;
#endif
int32_t tsQueryBufferPoolSize = 0; // MB
int32_t tsSingleQueryMaxMemorySize = 0; // MB
int32_t tsMinReservedMemorySize = 0; // MB
@ -133,23 +137,38 @@ int8_t tsGrant = 1;
bool tsCompareAsStrInGreatest = true;
// monitor
bool tsEnableMonitor = true;
#ifdef USE_MONITOR
bool tsEnableMonitor = true;
#else
bool tsEnableMonitor = false;
#endif
int32_t tsMonitorInterval = 30;
char tsMonitorFqdn[TSDB_FQDN_LEN] = {0};
uint16_t tsMonitorPort = 6043;
int32_t tsMonitorMaxLogs = 100;
bool tsMonitorComp = false;
bool tsMonitorLogProtocol = false;
bool tsMonitorForceV2 = true;
#ifdef USE_MONITOR
bool tsMonitorForceV2 = true;
#else
bool tsMonitorForceV2 = false;
#endif
// audit
#ifdef USE_AUDIT
bool tsEnableAudit = true;
bool tsEnableAuditCreateTable = true;
bool tsEnableAuditDelete = true;
int32_t tsAuditInterval = 5000;
#else
bool tsEnableAudit = false;
bool tsEnableAuditCreateTable = false;
bool tsEnableAuditDelete = false;
int32_t tsAuditInterval = 200000;
#endif
// telem
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || !defined(USE_REPORT)
bool tsEnableTelem = false;
#else
bool tsEnableTelem = true;
@ -159,7 +178,7 @@ char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.tdengine.com";
uint16_t tsTelemPort = 80;
char *tsTelemUri = "/report";
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || !defined(USE_REPORT)
bool tsEnableCrashReport = false;
#else
bool tsEnableCrashReport = true;
@ -288,7 +307,7 @@ bool tsIfAdtFse = false; // ADT-FSE algorithom or origina
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
// udf
#ifdef WINDOWS
#if defined(WINDOWS) || !defined(USE_UDF)
bool tsStartUdfd = false;
#else
bool tsStartUdfd = true;
@ -322,7 +341,11 @@ int32_t tsGrantHBInterval = 60;
int32_t tsUptimeInterval = 300; // seconds
char tsUdfdResFuncs[512] = ""; // taosudf resident funcs that teardown when taosudf exits
char tsUdfdLdLibPath[512] = "";
bool tsDisableStream = false;
#ifdef USE_STREAM
bool tsDisableStream = false;
#else
bool tsDisableStream = true;
#endif
int64_t tsStreamBufferSize = 128 * 1024 * 1024;
bool tsFilterScalarMode = false;
int tsStreamAggCnt = 100000;
@ -382,7 +405,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
tsDiskCfg[0].disable = 0;
tstrncpy(tsDataDir, pItem->str, PATH_MAX);
if (taosMulMkDir(tsDataDir) != 0) {
int32_t code = TAOS_SYSTEM_ERROR(errno);
int32_t code = TAOS_SYSTEM_ERROR(ERRNO);
uError("failed to create dataDir:%s, since:%s", tsDataDir, tstrerror(code));
TAOS_RETURN(code);
}
@ -1358,7 +1381,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minimalTmpDirGB");
tsTempSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024);
if (taosMulMkDir(tsTempDir) != 0) {
int32_t code = TAOS_SYSTEM_ERROR(errno);
int32_t code = TAOS_SYSTEM_ERROR(ERRNO);
uError("failed to create tempDir:%s since %s", tsTempDir, tstrerror(code));
TAOS_RETURN(code);
}
@ -1615,6 +1638,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_RETURN(taosSetSlowLogScope(pItem->str, &scope));
tsSlowLogScope = scope;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRspPolicy");
tsQueryRspPolicy = pItem->i32;
#ifdef USE_MONITOR
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitor");
tsEnableMonitor = pItem->bval;
@ -1634,15 +1660,13 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorComp");
tsMonitorComp = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRspPolicy");
tsQueryRspPolicy = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorLogProtocol");
tsMonitorLogProtocol = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorForceV2");
tsMonitorForceV2 = pItem->i32;
#endif
#ifdef USE_AUDIT
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "audit");
tsEnableAudit = pItem->bval;
@ -1654,29 +1678,31 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "auditInterval");
tsAuditInterval = pItem->i32;
#endif
#ifdef USE_REPORT
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryReporting");
tsEnableTelem = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "crashReporting");
tsEnableCrashReport = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryInterval");
tsTelemInterval = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryServer");
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN);
#endif
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlChangeOnWrite");
tsTtlChangeOnWrite = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlFlushThreshold");
tsTtlFlushThreshold = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryInterval");
tsTelemInterval = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rsyncPort");
tsRsyncPort = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryServer");
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN);
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "snodeAddress");
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
tstrncpy(tsSnodeAddress, pItem->str, TSDB_FQDN_LEN);
@ -1768,7 +1794,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableWhiteList");
tsEnableWhiteList = pItem->bval;
#ifdef USE_UDF
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udf");
tsStartUdfd = pItem->bval;
@ -1782,7 +1808,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
if (tsQueryBufferSize >= 0) {
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
}
#endif
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "cacheLazyLoadThreshold");
tsCacheLazyLoadThreshold = pItem->i32;
@ -1834,7 +1860,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minDiskFreeSize");
tsMinDiskFreeSize = pItem->i64;
#ifdef USE_S3
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3MigrateIntervalSec");
tsS3MigrateIntervalSec = pItem->i32;
@ -1846,7 +1872,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3UploadDelaySec");
tsS3UploadDelaySec = pItem->i32;
#endif
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental");
tsExperimental = pItem->bval;
@ -1883,24 +1909,31 @@ int32_t taosSetReleaseCfg(SConfig *pCfg);
static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag);
static int8_t tsLogCreated = 0;
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
int32_t mode = tsc ? LOG_MODE_TAOSC : LOG_MODE_TAOSD;
SConfig *pCfg = NULL;
if (atomic_val_compare_exchange_8(&tsLogCreated, 0, 1) != 0) return 0;
if (tsCfg == NULL) {
TAOS_CHECK_GOTO(osDefaultInit(), &lino, _exit);
}
TAOS_CHECK_GOTO(cfgInit(&pCfg), &lino, _exit);
if (tsc) {
tsLogEmbedded = 0;
TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit);
} else {
tsLogEmbedded = 1;
TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit);
#ifdef TAOSD_INTEGRATED
mode |= LOG_MODE_TAOSD;
tsLogEmbedded = 1;
#else
tsLogEmbedded = (mode & LOG_MODE_TAOSC) ? 0 : 1;
#endif
TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit);
if (mode & LOG_MODE_TAOSD) {
TAOS_CHECK_GOTO(taosAddServerLogCfg(pCfg), &lino, _exit);
}
@ -1914,10 +1947,8 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
goto _exit;
}
if (tsc) {
TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit);
} else {
TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit);
TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit);
if (mode & LOG_MODE_TAOSD) {
TAOS_CHECK_GOTO(taosSetServerLogCfg(pCfg), &lino, _exit);
}
@ -1930,7 +1961,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
goto _exit;
}
if ((code = taosInitLog(logname, logFileNum, tsc)) != 0) {
if ((code = taosInitLog(logname, logFileNum, mode)) != 0) {
(void)printf("failed to init log file since %s\n", tstrerror(code));
goto _exit;
}
@ -2163,6 +2194,10 @@ int32_t readCfgFile(const char *path, bool isGlobal) {
uError("failed to stat file:%s , since %s", filename, tstrerror(code));
TAOS_RETURN(code);
}
if (fileSize == 0) {
uInfo("config file:%s is empty", filename);
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
TdFilePtr pFile = taosOpenFile(filename, TD_FILE_READ);
if (pFile == NULL) {
code = terrno;
@ -2309,7 +2344,7 @@ static int32_t taosCfgSetOption(OptionNameAndVar *pOptions, int32_t optionSize,
char *name = pItem->name;
for (int32_t d = 0; d < optionSize; ++d) {
const char *optName = pOptions[d].optionName;
if (strcasecmp(name, optName) != 0) continue;
if (taosStrcasecmp(name, optName) != 0) continue;
code = TSDB_CODE_SUCCESS;
switch (pItem->dtype) {
case CFG_DTYPE_BOOL: {
@ -2742,7 +2777,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
tstrncpy(tsTempDir, pItem->str, PATH_MAX);
TAOS_CHECK_GOTO(taosExpandDir(tsTempDir, tsTempDir, PATH_MAX), &lino, _out);
if (taosMulMkDir(tsTempDir) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
uError("failed to create tempDir:%s since %s", tsTempDir, tstrerror(code));
goto _out;
}
@ -2828,7 +2863,7 @@ int32_t taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVa
static int taosLogVarComp(void const *lp, void const *rp) {
SLogVar *lpVar = (SLogVar *)lp;
SLogVar *rpVar = (SLogVar *)rp;
return strcasecmp(lpVar->name, rpVar->name);
return taosStrcasecmp(lpVar->name, rpVar->name);
}
static void taosCheckAndSetDebugFlag(int32_t *pFlagPtr, char *name, int32_t flag, SArray *noNeedToSetVars) {
@ -3063,7 +3098,7 @@ int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version
taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
if (pConfigFile == NULL) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
uError("failed to open file:%s since %s", filename, tstrerror(code));
TAOS_RETURN(code);
}
@ -3072,7 +3107,7 @@ int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version
if (taosWriteFile(pConfigFile, serialized, strlen(serialized)) < 0) {
lino = __LINE__;
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
uError("failed to write file:%s since %s", filename, tstrerror(code));
goto _exit;
}

View File

@ -222,7 +222,7 @@ static int compareKv(const void* p1, const void* p2) {
SSmlKv* kv2 = (SSmlKv*)p2;
int32_t kvLen1 = kv1->keyLen;
int32_t kvLen2 = kv2->keyLen;
int32_t res = strncasecmp(kv1->key, kv2->key, TMIN(kvLen1, kvLen2));
int32_t res = taosStrncasecmp(kv1->key, kv2->key, TMIN(kvLen1, kvLen2));
if (res != 0) {
return res;
} else {

View File

@ -234,13 +234,13 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
}
/* mktime will be affected by TZ, set by using taos_options */
#ifdef WINDOWS
#if defined(WINDOWS) || defined(TD_ASTRA)
int64_t seconds = user_mktime64(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
// int64_t seconds = gmtime(&tm);
#else
int64_t seconds = taosTimeGm(&tm);
if (seconds == -1){
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
}
#endif
@ -591,13 +591,13 @@ int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecisi
*/
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit,
int32_t timePrecision) {
errno = 0;
SET_ERRNO(0);
char* endPtr = NULL;
/* get the basic numeric value */
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
if ((timestamp == 0 && token[0] != '0') || errno != 0) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
if ((timestamp == 0 && token[0] != '0') || ERRNO != 0) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
}
/* natual month/year are not allowed in absolute duration */
@ -611,12 +611,12 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision,
bool negativeAllow) {
errno = 0;
SET_ERRNO(0);
/* get the basic numeric value */
*duration = taosStr2Int64(token, NULL, 10);
if ((*duration < 0 && !negativeAllow) || errno != 0) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
if ((*duration < 0 && !negativeAllow) || ERRNO != 0) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
}
*unit = token[tokenLen - 1];
@ -648,7 +648,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision, t
struct tm tm;
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
if(taosLocalTime(&tt, &tm, NULL, 0, tz) == NULL) {
uError("failed to convert time to gm time, code:%d", errno);
uError("failed to convert time to gm time, code:%d", ERRNO);
return t;
}
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
@ -664,7 +664,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision, t
tt = taosMktime(&tm, tz);
if (tt == -1){
uError("failed to convert gm time to time, code:%d", errno);
uError("failed to convert gm time to time, code:%d", ERRNO);
return t;
}
return (int64_t)(tt * TSDB_TICK_PER_SECOND(precision) + fraction);
@ -718,14 +718,14 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
struct tm tm;
time_t t = (time_t)skey;
if (taosLocalTime(&t, &tm, NULL, 0, NULL) == NULL) {
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
return ret;
}
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
t = (time_t)ekey;
if (taosLocalTime(&t, &tm, NULL, 0, NULL) == NULL) {
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
return ret;
}
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
@ -752,7 +752,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
struct tm tm;
time_t tt = (time_t)start;
if (taosLocalTime(&tt, &tm, NULL, 0, pInterval->timezone) == NULL){
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
return ts;
}
tm.tm_sec = 0;
@ -772,7 +772,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
tt = taosMktime(&tm, pInterval->timezone);
if (tt == -1){
uError("%s failed to convert local time to time, code:%d", __FUNCTION__, errno);
uError("%s failed to convert local time to time, code:%d", __FUNCTION__, ERRNO);
return ts;
}
start = (int64_t)(tt * TSDB_TICK_PER_SECOND(precision));
@ -990,7 +990,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
}
if (NULL == taosLocalTime(&quot, &ptm, buf, bufLen, NULL)) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
}
int32_t length = (int32_t)taosStrfTime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
length += tsnprintf(ts + length, fractionLen, format, mod);
@ -1032,7 +1032,7 @@ int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm, timezone_t tz)
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
time_t t = ts / TICK_PER_SECOND[precision];
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0, tz)) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
}
return TSDB_CODE_SUCCESS;
}
@ -1508,6 +1508,8 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
case TSFKW_TZH:{
#ifdef WINDOWS
int32_t gmtoff = -_timezone;
#elif defined(TD_ASTRA)
int32_t gmtoff = -timezone;
#else
int32_t gmtoff = tm->tm.tm_gmtoff;
#endif
@ -1594,7 +1596,7 @@ static const char* tsFormatStr2Int32(int32_t* dest, const char* str, int32_t len
// no integers found
return NULL;
}
if (errno == ERANGE || res > INT32_MAX || res < INT32_MIN) {
if (ERRNO == ERANGE || res > INT32_MAX || res < INT32_MIN) {
// out of range
return NULL;
}
@ -1937,6 +1939,8 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec
if (tzHour != 0) {
#ifdef WINDOWS
int32_t gmtoff = -_timezone;
#elif defined(TD_ASTRA)
int32_t gmtoff = -timezone;
#else
int32_t gmtoff = tm.tm.tm_gmtoff;
#endif
@ -2136,7 +2140,7 @@ int64_t taosGetTimestampToday(int32_t precision, timezone_t tz) {
}
struct tm tm;
if (taosLocalTime(&t, &tm, NULL, 0, tz) == NULL){
uError("%s failed to get local time, code:%d", __FUNCTION__, errno);
uError("%s failed to get local time, code:%d", __FUNCTION__, ERRNO);
return t;
}
tm.tm_hour = 0;
@ -2145,7 +2149,7 @@ int64_t taosGetTimestampToday(int32_t precision, timezone_t tz) {
time_t tmp = taosMktime(&tm, tz);
if (tmp == (time_t)-1) {
uError("%s failed to get timestamp of today, code:%d", __FUNCTION__, errno);
uError("%s failed to get timestamp of today, code:%d", __FUNCTION__, ERRNO);
return t;
}
return (int64_t)tmp * factor;

View File

@ -64,7 +64,7 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
n--;
}
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
if (z[0] == '0' && n > 2) {
if (z[1] == 'b' || z[1] == 'B') {
@ -75,7 +75,7 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
if (z[1] == 'x' || z[1] == 'X') {
// parsing as hex
*value = taosStr2UInt64(z, &endPtr, 16);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
@ -85,11 +85,11 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
if (parseFloat) {
// parsing as double
double val = taosStr2Double(z, &endPtr);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
if (val > (double)UINT64_MAX) {
errno = ERANGE;
SET_ERRNO(ERANGE);
return TSDB_CODE_FAILED;
}
*value = round(val);
@ -101,14 +101,14 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) {
if (n == 0) {
errno = EINVAL;
SET_ERRNO(EINVAL);
return TSDB_CODE_FAILED;
}
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
*value = taosStr2Double(z, &endPtr); // 0x already converted here
if (errno == ERANGE || errno == EINVAL) return TSDB_CODE_FAILED;
if (ERRNO == ERANGE || ERRNO == EINVAL) return TSDB_CODE_FAILED;
if (endPtr - z == n) return TSDB_CODE_SUCCESS;
if (type == TK_NK_BIN || type == TK_NK_STRING) {
@ -124,12 +124,12 @@ int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) {
}
int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) {
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
*value = taosStr2Int64(z, &endPtr, base);
if (endPtr - z == n) {
if (errno == ERANGE || errno == EINVAL) {
if (ERRNO == ERANGE || ERRNO == EINVAL) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
@ -159,12 +159,12 @@ int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) {
}
int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
switch (type) {
case TK_NK_INTEGER: {
*value = taosStr2Int64(z, &endPtr, 10);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
@ -174,7 +174,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
if (val < (double)INT64_MIN || val > (double)INT64_MAX) {
return TSDB_CODE_FAILED;
}
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
*value = val;
@ -185,18 +185,18 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
}
if (n == 0) {
errno = EINVAL;
SET_ERRNO(EINVAL);
return TSDB_CODE_FAILED;
}
// 1. try to parse as integer
*value = taosStr2Int64(z, &endPtr, 10);
if (endPtr - z == n) {
if (errno == ERANGE || errno == EINVAL) {
if (ERRNO == ERANGE || ERRNO == EINVAL) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
} else if (errno == 0 && *endPtr == '.') {
} else if (ERRNO == 0 && *endPtr == '.') {
// pure decimal part
const char *s = endPtr + 1;
const char *end = z + n;
@ -254,7 +254,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
}
int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
const char *p = z;
switch (type) {
@ -263,7 +263,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
if (*p == '-' && *value) {
return TSDB_CODE_FAILED;
}
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
@ -273,7 +273,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
if (val < 0 || val > (double)UINT64_MAX) {
return TSDB_CODE_FAILED;
}
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
*value = val;
@ -284,7 +284,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
}
if (n == 0) {
errno = EINVAL;
SET_ERRNO(EINVAL);
return TSDB_CODE_FAILED;
}
@ -292,11 +292,11 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
*value = taosStr2UInt64(p, &endPtr, 10);
if (endPtr - z == n) {
if (errno == ERANGE || errno == EINVAL || (*p == '-' && *value)) {
if (ERRNO == ERANGE || ERRNO == EINVAL || (*p == '-' && *value)) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
} else if (errno == 0 && *endPtr == '.') {
} else if (ERRNO == 0 && *endPtr == '.') {
const char *s = endPtr + 1;
const char *end = z + n;
bool pure = true;
@ -331,12 +331,12 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
}
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
*value = taosStr2Int64(z, &endPtr, base);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
errno = 0;
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
SET_ERRNO(0);
return TSDB_CODE_FAILED;
}
@ -344,7 +344,7 @@ 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) {
errno = 0;
SET_ERRNO(0);
char *endPtr = NULL;
const char *p = z;
@ -354,8 +354,8 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
}
*value = taosStr2UInt64(z, &endPtr, base);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
errno = 0;
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
SET_ERRNO(0);
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;

View File

@ -8,7 +8,11 @@ add_subdirectory(mgmt_dnode)
add_subdirectory(test)
aux_source_directory(exe EXEC_SRC)
add_executable(taosd ${EXEC_SRC})
if(${TAOSD_INTEGRATED})
add_library(taosd ${EXEC_SRC})
else()
add_executable(taosd ${EXEC_SRC})
endif()
target_include_directories(
taosd
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc"

View File

@ -75,6 +75,7 @@ static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert
static void dmStopDnode(int signum, void *sigInfo, void *context) {
// taosIgnSignal(SIGUSR1);
// taosIgnSignal(SIGUSR2);
#ifndef TD_ASTRA
if (taosIgnSignal(SIGTERM) != 0) {
dWarn("failed to ignore signal SIGTERM");
}
@ -90,16 +91,20 @@ static void dmStopDnode(int signum, void *sigInfo, void *context) {
if (taosIgnSignal(SIGBREAK) != 0) {
dWarn("failed to ignore signal SIGBREAK");
}
#endif
dInfo("shut down signal is %d", signum);
#ifndef WINDOWS
dInfo("sender PID:%d cmdline:%s", ((siginfo_t *)sigInfo)->si_pid,
#if !defined(WINDOWS) && !defined(TD_ASTRA)
if (sigInfo != NULL) {
dInfo("sender PID:%d cmdline:%s", ((siginfo_t *)sigInfo)->si_pid,
taosGetCmdlineByPID(((siginfo_t *)sigInfo)->si_pid));
}
#endif
dmStop();
}
void dmStopDaemon() { dmStopDnode(SIGTERM, NULL, NULL); }
void dmLogCrash(int signum, void *sigInfo, void *context) {
// taosIgnSignal(SIGTERM);
// taosIgnSignal(SIGHUP);
@ -120,8 +125,9 @@ void dmLogCrash(int signum, void *sigInfo, void *context) {
if (taosIgnSignal(SIGSEGV) != 0) {
dWarn("failed to ignore signal SIGABRT");
}
#ifdef USE_REPORT
writeCrashLogToFile(signum, sigInfo, CUS_PROMPT "d", dmGetClusterId(), global.startTime);
#endif
#ifdef _TD_DARWIN_64
exit(signum);
#elif defined(WINDOWS)
@ -297,10 +303,12 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
char path[1024] = {0};
taosGetCwd(path, sizeof(path));
char args[1024] = {0};
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
for (int32_t i = 1; i < argc; ++i) {
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
char args[1024] = {0};
if (argc > 0) {
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
for (int32_t i = 1; i < argc; ++i) {
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
}
}
dInfo("startup path:%s args:%s", path, args);
@ -366,7 +374,11 @@ static void taosCleanupArgs() {
if (global.envCmd != NULL) taosMemoryFreeClear(global.envCmd);
}
#ifdef TAOSD_INTEGRATED
int dmStartDaemon(int argc, char const *argv[]) {
#else
int main(int argc, char const *argv[]) {
#endif
int32_t code = 0;
#ifdef TD_JEMALLOC_ENABLED
bool jeBackgroundThread = true;
@ -469,13 +481,14 @@ int mainWindows(int argc, char **argv) {
return code;
}
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
dError("failed to init conv");
taosCloseLog();
taosCleanupArgs();
return code;
}
#endif
if (global.checkS3) {
code = dmCheckS3();
taosCleanupCfg();
@ -546,8 +559,6 @@ int mainWindows(int argc, char **argv) {
dInfo("start to init service");
dmSetSignalHandle();
tsDndStart = taosGetTimestampMs();
tsDndStartOsUptime = taosGetOsUptime();
code = dmRun();
dInfo("shutting down the service");

View File

@ -95,6 +95,7 @@ static void *dmStatusInfoThreadFp(void *param) {
return NULL;
}
#if defined(TD_ENTERPRISE)
SDmNotifyHandle dmNotifyHdl = {.state = 0};
#define TIMESERIES_STASH_NUM 5
static void *dmNotifyThreadFp(void *param) {
@ -196,7 +197,9 @@ static void *dmNotifyThreadFp(void *param) {
return NULL;
}
#endif
#ifdef USE_MONITOR
static void *dmMonitorThreadFp(void *param) {
SDnodeMgmt *pMgmt = param;
int64_t lastTime = taosGetTimestampMs();
@ -231,7 +234,8 @@ static void *dmMonitorThreadFp(void *param) {
return NULL;
}
#endif
#ifdef USE_AUDIT
static void *dmAuditThreadFp(void *param) {
SDnodeMgmt *pMgmt = param;
int64_t lastTime = taosGetTimestampMs();
@ -252,7 +256,8 @@ static void *dmAuditThreadFp(void *param) {
return NULL;
}
#endif
#ifdef USE_REPORT
static void *dmCrashReportThreadFp(void *param) {
int32_t code = 0;
SDnodeMgmt *pMgmt = param;
@ -330,14 +335,18 @@ static void *dmCrashReportThreadFp(void *param) {
return NULL;
}
#endif
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pMgmt->statusThread, &thAttr, dmStatusThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create status thread since %s", tstrerror(code));
return code;
}
@ -352,8 +361,11 @@ int32_t dmStartConfigThread(SDnodeMgmt *pMgmt) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pMgmt->configThread, &thAttr, dmConfigThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create config thread since %s", tstrerror(code));
return code;
}
@ -368,8 +380,11 @@ int32_t dmStartStatusInfoThread(SDnodeMgmt *pMgmt) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pMgmt->statusInfoThread, &thAttr, dmStatusInfoThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create status Info thread since %s", tstrerror(code));
return code;
}
@ -399,14 +414,14 @@ void dmStopStatusInfoThread(SDnodeMgmt *pMgmt) {
taosThreadClear(&pMgmt->statusInfoThread);
}
}
#ifdef TD_ENTERPRISE
int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&pMgmt->notifyThread, &thAttr, dmNotifyThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create notify thread since %s", tstrerror(code));
return code;
}
@ -429,55 +444,64 @@ void dmStopNotifyThread(SDnodeMgmt *pMgmt) {
dError("failed to destroy notify sem");
}
}
#endif
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
#ifdef USE_MONITOR
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&pMgmt->monitorThread, &thAttr, dmMonitorThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create monitor thread since %s", tstrerror(code));
return code;
}
(void)taosThreadAttrDestroy(&thAttr);
tmsgReportStartup("dnode-monitor", "initialized");
#endif
return 0;
}
int32_t dmStartAuditThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
#ifdef USE_AUDIT
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&pMgmt->auditThread, &thAttr, dmAuditThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create audit thread since %s", tstrerror(code));
return code;
}
(void)taosThreadAttrDestroy(&thAttr);
tmsgReportStartup("dnode-audit", "initialized");
#endif
return 0;
}
void dmStopMonitorThread(SDnodeMgmt *pMgmt) {
#ifdef USE_MONITOR
if (taosCheckPthreadValid(pMgmt->monitorThread)) {
(void)taosThreadJoin(pMgmt->monitorThread, NULL);
taosThreadClear(&pMgmt->monitorThread);
}
#endif
}
void dmStopAuditThread(SDnodeMgmt *pMgmt) {
#ifdef USE_AUDIT
if (taosCheckPthreadValid(pMgmt->auditThread)) {
(void)taosThreadJoin(pMgmt->auditThread, NULL);
taosThreadClear(&pMgmt->auditThread);
}
#endif
}
int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
#ifdef USE_REPORT
if (!tsEnableCrashReport) {
return 0;
}
@ -486,17 +510,19 @@ int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) {
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&pMgmt->crashReportThread, &thAttr, dmCrashReportThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create crashReport thread since %s", tstrerror(code));
return code;
}
(void)taosThreadAttrDestroy(&thAttr);
tmsgReportStartup("dnode-crashReport", "initialized");
#endif
return 0;
}
void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
#ifdef USE_REPORT
if (!tsEnableCrashReport) {
return;
}
@ -505,6 +531,7 @@ void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
(void)taosThreadJoin(pMgmt->crashReportThread, NULL);
taosThreadClear(&pMgmt->crashReportThread);
}
#endif
}
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {

View File

@ -212,7 +212,7 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
}
if (taosCloseFile(&pFile) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);

View File

@ -18,6 +18,8 @@
#include "libs/function/function.h"
#include "libs/function/tudf.h"
#ifdef USE_STREAM
static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) {
return dmReadFile(pInput->path, pInput->name, required);
}
@ -98,3 +100,4 @@ SMgmtFunc smGetMgmtFunc() {
return mgmtFunc;
}
#endif

View File

@ -350,14 +350,14 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
goto _OVER1;
}
if (taosFsyncFile(pFile) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
lino = __LINE__;
goto _OVER1;
}
code = taosCloseFile(&pFile);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
lino = __LINE__;
goto _OVER1;
}

View File

@ -183,7 +183,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1;
}
}
#if defined(TD_ENTERPRISE)
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
if (pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4) {
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
@ -199,7 +199,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg->walCfg.retentionSize = pCreate->walRetentionSize;
pCfg->walCfg.segSize = pCreate->walSegmentSize;
pCfg->walCfg.level = pCreate->walLevel;
#if defined(TD_ENTERPRISE)
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
if (pCfg->walCfg.encryptAlgorithm == DND_CA_SM4) {
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
@ -208,7 +208,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg->walCfg.encryptAlgorithm = 0;
#endif
#if defined(TD_ENTERPRISE)
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);

View File

@ -584,9 +584,10 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
SWrapperCfg *pCfgs = NULL;
int32_t numOfVnodes = 0;
if (vmGetVnodeListFromFile(pMgmt, &pCfgs, &numOfVnodes) != 0) {
dInfo("failed to get vnode list from disk since %s", terrstr());
return -1;
int32_t code = 0;
if ((code = vmGetVnodeListFromFile(pMgmt, &pCfgs, &numOfVnodes)) != 0) {
dInfo("failed to get vnode list from disk since %s", tstrerror(code));
return code;
}
pMgmt->state.totalVnodes = numOfVnodes;
@ -623,8 +624,11 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pThread->thread, &thAttr, vmOpenVnodeInThread, pThread) != 0) {
dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(errno));
dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(ERRNO));
}
(void)taosThreadAttrDestroy(&thAttr);
@ -646,13 +650,12 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
if ((pMgmt->state.openVnodes + pMgmt->state.dropVnodes) != pMgmt->state.totalVnodes) {
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
terrno = TSDB_CODE_VND_INIT_FAILED;
return -1;
return terrno = TSDB_CODE_VND_INIT_FAILED;
}
if (updateVnodesList && vmWriteVnodeListToFile(pMgmt) != 0) {
dError("failed to write vnode list since %s", terrstr());
return -1;
if (updateVnodesList && (code = vmWriteVnodeListToFile(pMgmt)) != 0) {
dError("failed to write vnode list since %s", tstrerror(code));
return code;
}
dInfo("successfully opened %d vnodes", pMgmt->state.totalVnodes);
@ -741,9 +744,11 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pThread->thread, &thAttr, vmCloseVnodeInThread, pThread) != 0) {
dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(errno));
dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(ERRNO));
}
(void)taosThreadAttrDestroy(&thAttr);
@ -852,8 +857,11 @@ static int32_t vmInitTimer(SVnodeMgmt *pMgmt) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if (taosThreadCreate(&pMgmt->thread, &thAttr, vmThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
dError("failed to create vnode timer thread since %s", tstrerror(code));
return code;
}
@ -889,19 +897,19 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
code = taosThreadRwlockInit(&pMgmt->hashLock, NULL);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
code = taosThreadMutexInit(&pMgmt->mutex, NULL);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
code = taosThreadMutexInit(&pMgmt->fileLock, NULL);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
@ -1049,7 +1057,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
if (taosThreadCreate(&pThread->thread, &thAttr, vmRestoreVnodeInThread, pThread) != 0) {
dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(errno));
dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(ERRNO));
}
(void)taosThreadAttrDestroy(&thAttr);

View File

@ -120,6 +120,7 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
}
static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
#ifdef USE_STREAM
SVnodeObj *pVnode = pInfo->ahandle;
const STraceId *trace = &pMsg->info.traceId;
@ -135,9 +136,11 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
#endif
}
static void vmProcessStreamCtrlQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_t numOfItems) {
#ifdef USE_STREAM
SVnodeObj *pVnode = pInfo->ahandle;
void *pItem = NULL;
int32_t code = 0;
@ -163,6 +166,7 @@ static void vmProcessStreamCtrlQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
}
#endif
}
static void vmProcessStreamChkptQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_t numOfItems) {

View File

@ -17,7 +17,9 @@
#define _TD_DND_MGMT_H_
// tobe deleted
#ifdef USE_UDF
#include "uv.h"
#endif
#include "dmInt.h"
#include "tfs.h"
@ -58,6 +60,7 @@ typedef struct {
char desc[TSDB_STEP_DESC_LEN];
} SStartupInfo;
#ifdef USE_UDF
typedef struct SUdfdData {
bool startCalled;
bool needCleanUp;
@ -71,6 +74,7 @@ typedef struct SUdfdData {
int32_t stopCalled;
int32_t dnodeId;
} SUdfdData;
#endif
typedef struct SDnode {
int8_t once;
@ -78,7 +82,9 @@ typedef struct SDnode {
EDndRunStatus status;
SStartupInfo startup;
SDnodeData data;
#ifdef USE_UDF
SUdfdData udfdData;
#endif
TdThreadMutex mutex;
TdFilePtr lockfile;
STfs *pTfs;

View File

@ -101,8 +101,8 @@ static int32_t dmCheckDiskSpace() {
int32_t code = 0;
code = osUpdate();
if (code != 0) {
code = 0; // ignore the error, just log it
dError("failed to update os info since %s", tstrerror(code));
code = 0; // ignore the error, just log it
}
if (!dmDataSpaceAvailable()) {
code = TSDB_CODE_NO_DISKSPACE;

View File

@ -169,7 +169,7 @@ int32_t dmInitVars(SDnode *pDnode) {
return code;
}
#if defined(TD_ENTERPRISE)
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
tsiEncryptAlgorithm = pData->encryptAlgorigthm;
tsiEncryptScope = pData->encryptScope;
/*

View File

@ -154,6 +154,9 @@ int32_t dmRunDnode(SDnode *pDnode) {
dmCloseNodes(pDnode);
return code;
}
tsDndStart = taosGetTimestampMs();
if (tsDndStart == 0) ++tsDndStart; // avoid 0
tsDndStartOsUptime = taosGetOsUptime();
while (1) {
if (pDnode->stop) {

View File

@ -64,7 +64,7 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
if (code < 0) return -1;
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
if (code < 0) return -1;
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
tjsonGetInt32ValueFromDouble(pJson, "encryptAlgor", pData->encryptAlgorigthm, code);
if (code < 0) return -1;
tjsonGetInt32ValueFromDouble(pJson, "encryptScope", pData->encryptScope, code);
@ -131,7 +131,7 @@ int32_t dmReadEps(SDnodeData *pData) {
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
dInfo("dnode file:%s not exist", file);
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
if (strlen(tsEncryptAlgorithm) > 0) {
if (strcmp(tsEncryptAlgorithm, "sm4") == 0) {
pData->encryptAlgorigthm = DND_CA_SM4;
@ -289,7 +289,7 @@ static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
if (tjsonAddDoubleToObject(pJson, "encryptAlgor", pData->encryptAlgorigthm) < 0) return -1;
if (tjsonAddDoubleToObject(pJson, "encryptScope", pData->encryptScope) < 0) return -1;
#endif
@ -657,7 +657,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
pData->oldDnodeEps = taosArrayInit(1, sizeof(SDnodeEpPair));
if (pData->oldDnodeEps == NULL) {
code = terrno;
dError("failed to calloc dnodeEp array since %s", strerror(errno));
dError("failed to calloc dnodeEp array since %s", strerror(ERRNO));
goto _OVER;
}

View File

@ -163,7 +163,7 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
}
if (taosCloseFile(&pFile) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
@ -206,7 +206,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) {
} while (retryTimes < 12);
if (ret < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
(void)taosCloseFile(pFile);
*pFile = NULL;
return code;
@ -249,12 +249,12 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
}
if (taosFsyncFile(pFile) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
if (taosCloseFile(&pFile) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
@ -291,7 +291,7 @@ static int32_t dmWriteEncryptCodeFile(char *file, char *realfile, char *encryptC
}
if (taosCloseFile(&pFile) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
@ -373,7 +373,7 @@ _OVER:
}
int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
int32_t code = -1;
int32_t lino = 0;
char *machineId = NULL;
@ -499,7 +499,7 @@ _OVER:
}
int32_t dmGetEncryptKey() {
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
int32_t code = -1;
char encryptFile[PATH_MAX] = {0};
char checkFile[PATH_MAX] = {0};

View File

@ -925,7 +925,7 @@ static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) {
SDnodeObj *pDnode = NULL;
void *pIter = NULL;
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
TAOS_CHECK_GOTO(grantCheck(TSDB_GRANT_DB_ENCRYPTION), NULL, _exit);
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {

View File

@ -18,6 +18,7 @@
#include "taoserror.h"
#include "tunit.h"
#ifdef USE_STREAM
static void *freeStreamTasks(SArray *pTaskLevel);
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
@ -233,6 +234,7 @@ void tFreeStreamObj(SStreamObj *pStream) {
taosMemoryFree(pStream->tagSchema.pSchema);
}
}
#endif
SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));

View File

@ -294,7 +294,7 @@ static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode) {
static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew) {
mTrace("dnode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew);
pOld->updateTime = pNew->updateTime;
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
tstrncpy(pOld->machineId, pNew->machineId, TSDB_MACHINE_ID_LEN + 1);
#endif
return 0;
@ -350,7 +350,7 @@ static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) {
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
if (pIter == NULL) break;
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
if (taosStrncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
sdbCancelFetch(pSdb, pIter);
return pDnode;
}
@ -372,7 +372,7 @@ static SDnodeObj *mndAcquireDnodeAllStatusByEp(SMnode *pMnode, char *pEpStr) {
pIter = sdbFetchAll(pSdb, SDB_DNODE, pIter, (void **)&pDnode, &objStatus, true);
if (pIter == NULL) break;
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
if (taosStrncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
sdbCancelFetch(pSdb, pIter);
return pDnode;
}
@ -478,7 +478,7 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
CHECK_MONITOR_PARA(tsSlowLogMaxLen, DND_REASON_STATUS_MONITOR_SLOW_LOG_SQL_MAX_LEN_NOT_MATCH);
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
if (0 != taosStrcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id,
pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
@ -492,20 +492,20 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
}
if ((0 != strcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
if ((0 != taosStrcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
mError("dnode:%d, timezone:%s checkTime:%" PRId64 " inconsistent with cluster %s %" PRId64, pDnode->id,
pCfg->timezone, pCfg->checkTime, tsTimezoneStr, pMnode->checkTime);
terrno = TSDB_CODE_DNODE_INVALID_TIMEZONE;
return DND_REASON_TIME_ZONE_NOT_MATCH;
}
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
if (0 != taosStrcasecmp(pCfg->locale, tsLocale)) {
mError("dnode:%d, locale:%s inconsistent with cluster:%s", pDnode->id, pCfg->locale, tsLocale);
terrno = TSDB_CODE_DNODE_INVALID_LOCALE;
return DND_REASON_LOCALE_NOT_MATCH;
}
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
if (0 != taosStrcasecmp(pCfg->charset, tsCharset)) {
mError("dnode:%d, charset:%s inconsistent with cluster:%s", pDnode->id, pCfg->charset, tsCharset);
terrno = TSDB_CODE_DNODE_INVALID_CHARSET;
return DND_REASON_CHARSET_NOT_MATCH;
@ -1424,7 +1424,7 @@ _exit:
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
int32_t code = 0;
#ifdef TD_ENTERPRISE
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
SMnode *pMnode = pReq->info.node;
SMCfgDnodeReq cfgReq = {0};
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));

View File

@ -81,7 +81,7 @@ int32_t mndInitIdx(SMnode *pMnode) {
static int32_t mndFindSuperTableTagId(const SStbObj *pStb, const char *tagName, int8_t *hasIdx) {
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
if (taosStrcasecmp(pStb->pTags[tag].name, tagName) == 0) {
if (IS_IDX_ON(&pStb->pTags[tag])) {
*hasIdx = 1;
}
@ -936,7 +936,7 @@ int32_t mndGetIdxsByTagName(SMnode *pMnode, SStbObj *pStb, char *tagName, SIdxOb
pIter = sdbFetch(pSdb, SDB_IDX, pIter, (void **)&pIdx);
if (pIter == NULL) break;
if (pIdx->stbUid == pStb->uid && strcasecmp(pIdx->colName, tagName) == 0) {
if (pIdx->stbUid == pStb->uid && taosStrcasecmp(pIdx->colName, tagName) == 0) {
memcpy((char *)idx, (char *)pIdx, sizeof(SIdxObj));
sdbRelease(pSdb, pIdx);
sdbCancelFetch(pSdb, pIter);

View File

@ -375,6 +375,7 @@ static int32_t minCronTime() {
}
void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
int32_t code = 0;
#ifndef TD_ASTRA
if (sec % tsTtlPushIntervalSec == 0) {
mndPullupTtl(pMnode);
}
@ -382,11 +383,12 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
if (sec % tsTrimVDbIntervalSec == 0) {
mndPullupTrimDb(pMnode);
}
#endif
#ifdef USE_S3
if (tsS3MigrateEnabled && sec % tsS3MigrateIntervalSec == 0) {
mndPullupS3MigrateDb(pMnode);
}
#endif
if (sec % tsTransPullupInterval == 0) {
mndPullupTrans(pMnode);
}
@ -394,11 +396,12 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
if (sec % tsCompactPullupInterval == 0) {
mndPullupCompacts(pMnode);
}
#ifdef USE_TOPIC
if (sec % tsMqRebalanceInterval == 0) {
mndCalMqRebalance(pMnode);
}
#endif
#ifdef USE_STREAM
if (sec % 30 == 0) { // send the checkpoint info every 30 sec
mndStreamCheckpointTimer(pMnode);
}
@ -410,19 +413,21 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
if (sec % 5 == 0) {
mndStreamConsensusChkpt(pMnode);
}
#endif
#ifdef USE_REPORT
if (sec % tsTelemInterval == (TMIN(86400, (tsTelemInterval - 1)))) {
mndPullupTelem(pMnode);
}
#endif
#ifndef TD_ASTRA
if (sec % tsGrantHBInterval == 0) {
mndPullupGrant(pMnode);
}
#endif
if (sec % tsUptimeInterval == 0) {
mndIncreaseUpTime(pMnode);
}
#ifndef TD_ASTRA
if (sec % (tsArbHeartBeatIntervalSec) == 0) {
if ((code = mndPullupArbHeartbeat(pMnode)) != 0) {
mError("failed to pullup arb heartbeat, since:%s", tstrerror(code));
@ -434,6 +439,7 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
mError("failed to pullup arb check sync, since:%s", tstrerror(code));
}
}
#endif
}
void mndDoTimerCheckTask(SMnode *pMnode, int64_t sec) {
if (sec % (tsStatusInterval * 5) == 0) {
@ -476,6 +482,9 @@ static int32_t mndInitTimer(SMnode *pMnode) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
if ((code = taosThreadCreate(&pMnode->thread, &thAttr, mndThreadFp, pMnode)) != 0) {
mError("failed to create timer thread since %s", tstrerror(code));
TAOS_RETURN(code);
@ -524,7 +533,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
.encryptAlgorithm = 0,
.encryptKey = {0}};
#if defined(TD_ENTERPRISE)
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
if (tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL) {
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL) ? tsiEncryptAlgorithm : 0;
if (tsEncryptKey[0] == '\0') {

View File

@ -103,7 +103,7 @@ END:
if (pPlan) nodesDestroyNode((SNode*)pPlan);
TAOS_RETURN(code);
}
#ifdef USE_STREAM
int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) {
STaskOutputInfo* pInfo = &pTask->outputInfo;
@ -814,7 +814,9 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t skey, SAr
TAOS_RETURN(code);
}
#endif
#ifdef USE_TOPIC
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub) {
int32_t code = 0;
SSdb* pSdb = pMnode->pSdb;
@ -911,3 +913,4 @@ END:
qDestroyQueryPlan(pPlan);
return code;
}
#endif

View File

@ -846,7 +846,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
static SSchema *mndFindStbColumns(const SStbObj *pStb, const char *colName) {
for (int32_t col = 0; col < pStb->numOfColumns; ++col) {
SSchema *pSchema = &pStb->pColumns[col];
if (strncasecmp(pSchema->name, colName, TSDB_COL_NAME_LEN) == 0) {
if (taosStrncasecmp(pSchema->name, colName, TSDB_COL_NAME_LEN) == 0) {
return pSchema;
}
}

View File

@ -362,7 +362,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
code = terrno;
mInfo("stream:%s failed to create, source db %s not exist since %s", pCreate->name, pObj->sourceDb,
tstrerror(code));
goto FAIL;
goto _ERR;
}
pObj->sourceDbUid = pSourceDb->uid;
@ -375,7 +375,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
code = terrno;
mError("stream:%s failed to create, target db %s not exist since %s", pCreate->name, pObj->targetDb,
tstrerror(code));
goto FAIL;
goto _ERR;
}
tstrncpy(pObj->targetDb, pTargetDb->name, TSDB_DB_FNAME_LEN);
@ -396,12 +396,12 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
// deserialize ast
if ((code = nodesStringToNode(pObj->ast, &pAst)) < 0) {
goto FAIL;
goto _ERR;
}
// create output schema
if ((code = createSchemaByFields(pCreate->pCols, &pObj->outputSchema)) != TSDB_CODE_SUCCESS) {
goto FAIL;
goto _ERR;
}
int32_t numOfNULL = taosArrayGetSize(pCreate->fillNullCols);
@ -410,7 +410,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
SSchema *pFullSchema = taosMemoryCalloc(pObj->outputSchema.nCols, sizeof(SSchema));
if (!pFullSchema) {
code = terrno;
goto FAIL;
goto _ERR;
}
int32_t nullIndex = 0;
@ -471,12 +471,12 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
// using ast and param to build physical plan
if ((code = qCreateQueryPlan(&cxt, &pPlan, NULL)) < 0) {
goto FAIL;
goto _ERR;
}
// save physcial plan
if ((code = nodesNodeToString((SNode *)pPlan, false, &pObj->physicalPlan, NULL)) != 0) {
goto FAIL;
goto _ERR;
}
pObj->tagSchema.nCols = pCreate->numOfTags;
@ -484,7 +484,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
pObj->tagSchema.pSchema = taosMemoryCalloc(pCreate->numOfTags, sizeof(SSchema));
if (pObj->tagSchema.pSchema == NULL) {
code = terrno;
goto FAIL;
goto _ERR;
}
}
@ -502,7 +502,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
memcpy(pObj->tagSchema.pSchema[i].name, pField->name, TSDB_COL_NAME_LEN);
}
FAIL:
_ERR:
if (pAst != NULL) nodesDestroyNode(pAst);
if (pPlan != NULL) qDestroyQueryPlan(pPlan);
return code;

View File

@ -795,7 +795,7 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c
if (pIter == NULL) break;
if (pTrans->oper == oper) {
if (strcasecmp(dbname, pTrans->dbname) == 0) {
if (taosStrcasecmp(dbname, pTrans->dbname) == 0) {
mInfo("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper);
taosWLockLatch(&pTrans->lockRpcArray);
if (pTrans->pRpcArray == NULL) {
@ -874,13 +874,13 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
static bool mndCheckDbConflict(const char *conflict, STrans *pTrans) {
if (conflict[0] == 0) return false;
if (strcasecmp(conflict, pTrans->dbname) == 0) return true;
if (taosStrcasecmp(conflict, pTrans->dbname) == 0) return true;
return false;
}
static bool mndCheckStbConflict(const char *conflict, STrans *pTrans) {
if (conflict[0] == 0) return false;
if (strcasecmp(conflict, pTrans->stbname) == 0) return true;
if (taosStrcasecmp(conflict, pTrans->stbname) == 0) return true;
return false;
}
@ -996,7 +996,7 @@ int32_t mndTransCheckConflictWithCompact(SMnode *pMnode, STrans *pTrans) {
thisConflict = true;
}
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
if (taosStrcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
}
if (thisConflict) {
@ -1292,10 +1292,14 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
int32_t code = 0;
SMnode *pMnode = pRsp->info.node;
#ifndef TD_ASTRA_32
int64_t signature = (int64_t)(pRsp->info.ahandle);
int32_t transId = (int32_t)(signature >> 32);
int32_t action = (int32_t)((signature << 32) >> 32);
#else
int32_t transId = (int32_t)(pRsp->info.ahandle);
int32_t action = (int32_t)(pRsp->info.ahandleEx);
#endif
STrans *pTrans = mndAcquireTrans(pMnode, transId);
if (pTrans == NULL) {
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
@ -1418,11 +1422,18 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
TAOS_RETURN(TSDB_CODE_MND_TRANS_CTX_SWITCH);
}
#ifndef TD_ASTRA_32
int64_t signature = pTrans->id;
signature = (signature << 32);
signature += pAction->id;
SRpcMsg rpcMsg = {.msgType = pAction->msgType, .contLen = pAction->contLen, .info.ahandle = (void *)signature};
#else
SRpcMsg rpcMsg = {.msgType = pAction->msgType,
.contLen = pAction->contLen,
.info.ahandle = (void *)pTrans->id,
.info.ahandleEx = (void *)pAction->id};
#endif
rpcMsg.pCont = rpcMallocCont(pAction->contLen);
if (rpcMsg.pCont == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;

View File

@ -15,7 +15,9 @@
#define _DEFAULT_SOURCE
// clang-format off
#ifndef TD_ASTRA
#include <uv.h>
#endif
#include "mndUser.h"
#include "audit.h"
#include "mndDb.h"
@ -688,11 +690,12 @@ void mndCleanupUser(SMnode *pMnode) { ipWhiteMgtCleanup(); }
static void ipRangeToStr(SIpV4Range *range, char *buf) {
struct in_addr addr;
addr.s_addr = range->ip;
#ifndef TD_ASTRA
(void)uv_inet_ntop(AF_INET, &addr, buf, 32);
if (range->mask != 32) {
(void)tsnprintf(buf + strlen(buf), 36 - strlen(buf), "/%d", range->mask);
}
#endif
return;
}
static bool isDefaultRange(SIpV4Range *pRange) {
@ -839,12 +842,13 @@ static int32_t createDefaultIpWhiteList(SIpWhiteList **ppWhiteList) {
}
(*ppWhiteList)->num = 1;
SIpV4Range *range = &((*ppWhiteList)->pIpRange[0]);
#ifndef TD_ASTRA
struct in_addr addr;
if (uv_inet_pton(AF_INET, "127.0.0.1", &addr) == 0) {
range->ip = addr.s_addr;
range->mask = 32;
}
#endif
return 0;
}
@ -2330,6 +2334,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
TAOS_CHECK_GOTO(mndRemoveTablePriviledge(pMnode, pAlterTbs, pNewUser->useDbs, pAlterReq, pSdb), &lino, _OVER);
}
#ifdef USE_TOPIC
if (ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) {
int32_t len = strlen(pAlterReq->objname) + 1;
SMqTopicObj *pTopic = NULL;
@ -2357,7 +2362,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
}
mndReleaseTopic(pMnode, pTopic);
}
#endif
_OVER:
if (code < 0) {
mError("user:%s, failed to alter user privileges at line %d since %s", pAlterReq->user, lino, tstrerror(code));

View File

@ -154,13 +154,13 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
static int32_t sdbCreateDir(SSdb *pSdb) {
int32_t code = 0;
if (taosMulMkDir(pSdb->currDir) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
mError("failed to create dir:%s since %s", pSdb->currDir, tstrerror(code));
TAOS_RETURN(code);
}
if (taosMkDir(pSdb->tmpDir) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
mError("failed to create dir:%s since %s", pSdb->tmpDir, tstrerror(code));
TAOS_RETURN(code);
}

View File

@ -182,7 +182,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
int64_t maxId = 0;
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
if (ret < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
TAOS_RETURN(code);
}
if (ret != sizeof(int64_t)) {
@ -196,7 +196,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
int64_t ver = 0;
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
if (ret < 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
TAOS_RETURN(code);
}
if (ret != sizeof(int64_t)) {
@ -556,7 +556,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
code = errno;
code = terrno;
taosHashCancelIterate(hash, ppRow);
sdbFreeRaw(pRaw);
break;
@ -576,7 +576,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
if (code == 0) {
code = taosFsyncFile(pFile);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
mError("failed to sync sdb file:%s since %s", tmpfile, tstrerror(code));
}
}
@ -822,13 +822,13 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i
}
if (taosFsyncFile(pIter->file) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
mError("sdbiter:%p, failed to fasync file %s since %s", pIter, pIter->name, tstrerror(code));
goto _OVER;
}
if (taosCloseFile(&pIter->file) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
goto _OVER;
}
pIter->file = NULL;

View File

@ -136,7 +136,7 @@ int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val) {
TAOS_RETURN(code);
}
*(int64_t *)(pRaw->pData + dataPos) = val;
taosSetInt64Aligned((int64_t *)(pRaw->pData + dataPos), val);
return 0;
}
@ -297,7 +297,7 @@ int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val) {
TAOS_RETURN(code);
}
*val = *(int64_t *)(pRaw->pData + dataPos);
taosSetPInt64Aligned(val, (int64_t *)(pRaw->pData + dataPos));
return 0;
}

View File

@ -72,7 +72,7 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
code = startRsync();
if (code != 0) {
terrno = code;
goto FAIL;
goto _ERR;
}
pSnode->msgCb = pOption->msgCb;
@ -80,13 +80,13 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
taosGetTimestampMs(), tqStartTaskCompleteCallback, &pSnode->pMeta);
if (code != TSDB_CODE_SUCCESS) {
terrno = code;
goto FAIL;
goto _ERR;
}
streamMetaLoadAllTasks(pSnode->pMeta);
return pSnode;
FAIL:
_ERR:
taosMemoryFree(pSnode);
return NULL;
}

View File

@ -164,7 +164,7 @@ int32_t metaFilterTableName(void* pVnode, SMetaFltParam* param, SArray* pUids);
int32_t metaFilterTtl(void* pVnode, SMetaFltParam* param, SArray* pUids);
int32_t metaGetColCmpr(SMeta* pMeta, tb_uid_t uid, SHashObj** colCmprObj);
#ifndef META_REFACT
#if !defined(META_REFACT) && !defined(TD_ASTRA)
// SMetaDB
int metaOpenDB(SMeta* pMeta);
void metaCloseDB(SMeta* pMeta);

View File

@ -334,6 +334,7 @@ struct STsdbFS {
};
typedef struct {
#ifdef USE_ROCKSDB
rocksdb_t *db;
rocksdb_comparator_t *my_comparator;
rocksdb_block_based_table_options_t *tableoptions;
@ -343,6 +344,7 @@ typedef struct {
rocksdb_readoptions_t *readoptions;
rocksdb_writebatch_t *writebatch;
TdThreadMutex writeBatchMutex;
#endif
int32_t sver;
tb_uid_t suid;
tb_uid_t uid;

View File

@ -19,7 +19,9 @@
#include "executor.h"
#include "filter.h"
#include "qworker.h"
#ifdef USE_ROCKSDB
#include "rocksdb/c.h"
#endif
#include "sync.h"
#include "tRealloc.h"
#include "tchecksum.h"
@ -466,12 +468,12 @@ typedef struct {
} SVATaskID;
struct SVnode {
char* path;
SVnodeCfg config;
SVState state;
SVStatis statis;
char* path;
STfs* pTfs;
int32_t diskPrimary;
SVnodeCfg config;
SMsgCb msgCb;
bool disableWrite;

View File

@ -999,7 +999,7 @@ static void metaTimeSeriesNotifyCheck(SMeta *pMeta) {
if (deltaTS > tsTimeSeriesThreshold) {
if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) {
if (tsem_post(&dmNotifyHdl.sem) != 0) {
metaError("vgId:%d, failed to post semaphore, errno:%d", TD_VID(pMeta->pVnode), errno);
metaError("vgId:%d, failed to post semaphore, errno:%d", TD_VID(pMeta->pVnode), ERRNO);
}
}
}

View File

@ -16,6 +16,21 @@
#include "meta.h"
#include "vnd.h"
#ifndef NO_UNALIGNED_ACCESS
#define TDB_KEY_ALIGN(k1, k2, kType)
#else
#define TDB_KEY_ALIGN(k1, k2, kType) \
kType _k1, _k2; \
if (((uintptr_t)(k1) & 7)) { \
memcpy(&_k1, (k1), sizeof(kType)); \
(k1) = &_k1; \
} \
if (((uintptr_t)(k2) & 7)) { \
memcpy(&_k2, (k2), sizeof(kType)); \
(k2) = &_k2; \
}
#endif
static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
static int skmDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
static int ctbIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
@ -248,7 +263,7 @@ _exit:
metaDebug("vgId:%d %s success", TD_VID(pVnode), __func__);
*ppMeta = pMeta;
}
return code;
TAOS_RETURN(code);
}
void vnodeGetMetaPath(SVnode *pVnode, const char *metaDir, char *fname) {
@ -424,14 +439,14 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|| (metaBackupExists && metaExists && metaTempExists) //
) {
metaError("vgId:%d, invalid meta state, please check!", TD_VID(pVnode));
return TSDB_CODE_FAILED;
TAOS_RETURN(TSDB_CODE_FAILED);
} else if (!metaBackupExists && metaExists && metaTempExists) {
taosRemoveDir(metaTempDir);
} else if (metaBackupExists && !metaExists && metaTempExists) {
code = taosRenameFile(metaTempDir, metaDir);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
return code;
TAOS_RETURN(code);
}
taosRemoveDir(metaBackupDir);
} else if (metaBackupExists && metaExists && !metaTempExists) {
@ -442,14 +457,14 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
code = metaOpenImpl(pVnode, ppMeta, VNODE_META_DIR, rollback);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
return code;
TAOS_RETURN(code);
}
if (generateNewMeta) {
code = metaGenerateNewMeta(ppMeta);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
return code;
TAOS_RETURN(code);
}
}
@ -551,6 +566,8 @@ static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen
STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1;
STbDbKey *pTbDbKey2 = (STbDbKey *)pKey2;
TDB_KEY_ALIGN(pTbDbKey1, pTbDbKey2, STbDbKey);
if (pTbDbKey1->version > pTbDbKey2->version) {
return 1;
} else if (pTbDbKey1->version < pTbDbKey2->version) {
@ -570,6 +587,8 @@ static int skmDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLe
SSkmDbKey *pSkmDbKey1 = (SSkmDbKey *)pKey1;
SSkmDbKey *pSkmDbKey2 = (SSkmDbKey *)pKey2;
TDB_KEY_ALIGN(pSkmDbKey1, pSkmDbKey2, SSkmDbKey);
if (pSkmDbKey1->uid > pSkmDbKey2->uid) {
return 1;
} else if (pSkmDbKey1->uid < pSkmDbKey2->uid) {
@ -586,8 +605,8 @@ static int skmDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLe
}
static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
tb_uid_t uid1 = *(tb_uid_t *)pKey1;
tb_uid_t uid2 = *(tb_uid_t *)pKey2;
tb_uid_t uid1 = taosGetInt64Aligned((int64_t*)pKey1);
tb_uid_t uid2 = taosGetInt64Aligned((int64_t*)pKey2);
if (uid1 > uid2) {
return 1;
@ -602,6 +621,8 @@ static int ctbIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
SCtbIdxKey *pCtbIdxKey1 = (SCtbIdxKey *)pKey1;
SCtbIdxKey *pCtbIdxKey2 = (SCtbIdxKey *)pKey2;
TDB_KEY_ALIGN(pCtbIdxKey1, pCtbIdxKey2, SCtbIdxKey);
if (pCtbIdxKey1->suid > pCtbIdxKey2->suid) {
return 1;
} else if (pCtbIdxKey1->suid < pCtbIdxKey2->suid) {
@ -623,6 +644,8 @@ int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
tb_uid_t uid1 = 0, uid2 = 0;
int c;
TDB_KEY_ALIGN(pTagIdxKey1, pTagIdxKey2, STagIdxKey);
// compare suid
if (pTagIdxKey1->suid > pTagIdxKey2->suid) {
return 1;
@ -682,6 +705,9 @@ int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
static int btimeIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
SBtimeIdxKey *pBtimeIdxKey1 = (SBtimeIdxKey *)pKey1;
SBtimeIdxKey *pBtimeIdxKey2 = (SBtimeIdxKey *)pKey2;
TDB_KEY_ALIGN(pBtimeIdxKey1, pBtimeIdxKey2, SBtimeIdxKey);
if (pBtimeIdxKey1->btime > pBtimeIdxKey2->btime) {
return 1;
} else if (pBtimeIdxKey1->btime < pBtimeIdxKey2->btime) {
@ -701,6 +727,8 @@ static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen
SNcolIdxKey *pNcolIdxKey1 = (SNcolIdxKey *)pKey1;
SNcolIdxKey *pNcolIdxKey2 = (SNcolIdxKey *)pKey2;
TDB_KEY_ALIGN(pNcolIdxKey1, pNcolIdxKey2, SNcolIdxKey);
if (pNcolIdxKey1->ncol > pNcolIdxKey2->ncol) {
return 1;
} else if (pNcolIdxKey1->ncol < pNcolIdxKey2->ncol) {
@ -720,6 +748,8 @@ static int smaIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
SSmaIdxKey *pSmaIdxKey1 = (SSmaIdxKey *)pKey1;
SSmaIdxKey *pSmaIdxKey2 = (SSmaIdxKey *)pKey2;
TDB_KEY_ALIGN(pSmaIdxKey1, pSmaIdxKey2, SSmaIdxKey);
if (pSmaIdxKey1->uid > pSmaIdxKey2->uid) {
return 1;
} else if (pSmaIdxKey1->uid < pSmaIdxKey2->uid) {

View File

@ -171,14 +171,15 @@ int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchem
indexMultiTermDestroy(terms);
taosArrayDestroy(pTagVals);
#endif
return code;
_exception:
indexMultiTermDestroy(terms);
taosArrayDestroy(pTagVals);
#endif
return code;
}
int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema) {
int32_t code = 0;
#ifdef USE_INVERTED_INDEX
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
return TSDB_CODE_INVALID_PARA;
@ -192,7 +193,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
int32_t nTagData = 0;
SArray *pTagVals = NULL;
int32_t code = tTagToValArray((const STag *)data, &pTagVals);
code = tTagToValArray((const STag *)data, &pTagVals);
if (code) {
return code;
}
@ -253,11 +254,11 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
code = indexJsonPut(pMeta->pTagIvtIdx, terms, tuid);
indexMultiTermDestroy(terms);
taosArrayDestroy(pTagVals);
#endif
return code;
_exception:
indexMultiTermDestroy(terms);
taosArrayDestroy(pTagVals);
#endif
return code;
}
@ -730,7 +731,7 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_
return terrno;
}
(*ppTagIdxKey)->suid = suid;
taosSetInt64Aligned(&((*ppTagIdxKey)->suid), suid);
(*ppTagIdxKey)->cid = cid;
(*ppTagIdxKey)->isNull = (pTagData == NULL) ? 1 : 0;
(*ppTagIdxKey)->type = type;
@ -739,10 +740,10 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_
if (IS_VAR_DATA_TYPE(type)) {
memcpy((*ppTagIdxKey)->data, (uint16_t *)&nTagData, VARSTR_HEADER_SIZE);
if (pTagData != NULL) memcpy((*ppTagIdxKey)->data + VARSTR_HEADER_SIZE, pTagData, nTagData);
*(tb_uid_t *)((*ppTagIdxKey)->data + VARSTR_HEADER_SIZE + nTagData) = uid;
taosSetInt64Aligned((tb_uid_t *)((*ppTagIdxKey)->data + VARSTR_HEADER_SIZE + nTagData), uid);
} else {
if (pTagData != NULL) memcpy((*ppTagIdxKey)->data, pTagData, nTagData);
*(tb_uid_t *)((*ppTagIdxKey)->data + nTagData) = uid;
taosSetInt64Aligned((tb_uid_t *)((*ppTagIdxKey)->data + nTagData), uid);
}
return 0;

View File

@ -423,7 +423,7 @@ static int32_t tdRsmaStartExecutor(const SSma *pSma) {
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
if (taosThreadCreate(&pthread[i], &thAttr, tdRSmaExecutorFunc, (void *)pSma) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
smaError("vgId:%d, failed to create pthread for rsma since %s", SMA_VID(pSma), tstrerror(code));
TAOS_RETURN(code);
}

View File

@ -288,7 +288,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
TAOS_RETURN(terrno);
}
if (taosMulMkDir(s) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
taosMemoryFree(s);
TAOS_RETURN(code);
}

View File

@ -36,9 +36,13 @@ int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) {
}
int32_t tdProcessTSmaCreate(SSma *pSma, int64_t ver, const char *msg) {
#ifdef USE_TSMA
int32_t code = tdProcessTSmaCreateImpl(pSma, ver, msg);
TAOS_RETURN(code);
#else
return TSDB_CODE_SUCCESS;
#endif
}
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) {

View File

@ -138,7 +138,7 @@ int32_t streamStateSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamS
pWriter->ever = ever;
if (taosMkDir(pTq->pStreamMeta->path) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
code = TAOS_SYSTEM_ERROR(ERRNO);
tqError("vgId:%d, vnode %s snapshot writer failed to create directory %s since %s", TD_VID(pTq->pVnode),
STREAM_STATE_TRANSFER, pTq->pStreamMeta->path, tstrerror(code));
goto _err;

View File

@ -29,7 +29,8 @@ void tsdbLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRe
}
static int32_t tsdbOpenBCache(STsdb *pTsdb) {
int32_t code = 0, lino = 0;
int32_t code = 0, lino = 0;
#ifdef USE_S3
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
int64_t szBlock = tsS3BlockSize <= 1024 ? 1024 : tsS3BlockSize;
SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3BlockCacheSize * szBlock * szPage, 0, .5);
@ -48,11 +49,12 @@ _err:
tsdbError("tsdb/bcache: vgId:%d, %s failed at line %d since %s.", TD_VID(pTsdb->pVnode), __func__, lino,
tstrerror(code));
}
#endif
TAOS_RETURN(code);
}
static void tsdbCloseBCache(STsdb *pTsdb) {
#ifdef USE_S3
SLRUCache *pCache = pTsdb->bCache;
if (pCache) {
int32_t elems = taosLRUCacheGetElems(pCache);
@ -65,10 +67,12 @@ static void tsdbCloseBCache(STsdb *pTsdb) {
(void)taosThreadMutexDestroy(&pTsdb->bMutex);
}
#endif
}
static int32_t tsdbOpenPgCache(STsdb *pTsdb) {
int32_t code = 0, lino = 0;
#ifdef USE_S3
int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3PageCacheSize * szPage, 0, .5);
@ -86,11 +90,12 @@ _err:
if (code) {
tsdbError("tsdb/pgcache: vgId:%d, open failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino, tstrerror(code));
}
#endif
TAOS_RETURN(code);
}
static void tsdbClosePgCache(STsdb *pTsdb) {
#ifdef USE_S3
SLRUCache *pCache = pTsdb->pgCache;
if (pCache) {
int32_t elems = taosLRUCacheGetElems(pCache);
@ -103,6 +108,7 @@ static void tsdbClosePgCache(STsdb *pTsdb) {
(void)taosThreadMutexDestroy(&pTsdb->bMutex);
}
#endif
}
#define ROCKS_KEY_LEN (sizeof(tb_uid_t) + sizeof(int16_t) + sizeof(int8_t))
@ -166,7 +172,7 @@ static int myCmp(void *state, const char *a, size_t alen, const char *b, size_t
static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
int32_t code = 0, lino = 0;
#ifdef USE_ROCKSDB
rocksdb_comparator_t *cmp = rocksdb_comparator_create(NULL, myCmpDestroy, myCmp, myCmpName);
if (NULL == cmp) {
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
@ -252,11 +258,12 @@ _err2:
rocksdb_block_based_options_destroy(tableoptions);
_err:
rocksdb_comparator_destroy(cmp);
#endif
TAOS_RETURN(code);
}
static void tsdbCloseRocksCache(STsdb *pTsdb) {
#ifdef USE_ROCKSDB
rocksdb_close(pTsdb->rCache.db);
(void)taosThreadMutexDestroy(&pTsdb->rCache.writeBatchMutex);
rocksdb_flushoptions_destroy(pTsdb->rCache.flushoptions);
@ -268,9 +275,11 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
rocksdb_comparator_destroy(pTsdb->rCache.my_comparator);
taosMemoryFree(pTsdb->rCache.pTSchema);
taosArrayDestroy(pTsdb->rCache.ctxArray);
#endif
}
static void rocksMayWrite(STsdb *pTsdb, bool force) {
#ifdef USE_ROCKSDB
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
int count = rocksdb_writebatch_count(wb);
@ -286,6 +295,7 @@ static void rocksMayWrite(STsdb *pTsdb, bool force) {
rocksdb_writebatch_clear(wb);
}
#endif
}
typedef struct {
@ -769,23 +779,24 @@ int32_t tsdbCacheCommit(STsdb *pTsdb) {
char *err = NULL;
SLRUCache *pCache = pTsdb->lruCache;
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
// rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
(void)taosThreadMutexLock(&pTsdb->lruMutex);
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, pTsdb);
#ifdef USE_ROCKSDB
rocksMayWrite(pTsdb, true);
rocksdb_flush(pTsdb->rCache.db, pTsdb->rCache.flushoptions, &err);
#endif
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
#ifdef USE_ROCKSDB
if (NULL != err) {
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, err);
rocksdb_free(err);
code = TSDB_CODE_FAILED;
}
#endif
TAOS_RETURN(code);
}
@ -895,7 +906,7 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i
int32_t code = 0, lino = 0;
SLRUCache *pCache = pTsdb->lruCache;
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
// rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
SRowKey emptyRowKey = {.ts = TSKEY_MIN, .numOfPKs = 0};
SLastCol emptyCol = {
.rowKey = emptyRowKey, .colVal = COL_VAL_NONE(cid, col_type), .dirty = 1, .cacheStatus = TSDB_LAST_CACHE_VALID};
@ -914,24 +925,24 @@ int32_t tsdbCacheCommitNoLock(STsdb *pTsdb) {
char *err = NULL;
SLRUCache *pCache = pTsdb->lruCache;
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
// rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, pTsdb);
#ifdef USE_ROCKSDB
rocksMayWrite(pTsdb, true);
rocksdb_flush(pTsdb->rCache.db, pTsdb->rCache.flushoptions, &err);
if (NULL != err) {
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, err);
rocksdb_free(err);
code = TSDB_CODE_FAILED;
}
#endif
TAOS_RETURN(code);
}
static int32_t tsdbCacheGetValuesFromRocks(STsdb *pTsdb, size_t numKeys, const char *const *ppKeysList,
size_t *pKeysListSizes, char ***pppValuesList, size_t **ppValuesListSizes) {
#ifdef USE_ROCKSDB
char **valuesList = taosMemoryCalloc(numKeys, sizeof(char *));
if (!valuesList) return terrno;
size_t *valuesListSizes = taosMemoryCalloc(numKeys, sizeof(size_t));
@ -954,6 +965,7 @@ static int32_t tsdbCacheGetValuesFromRocks(STsdb *pTsdb, size_t numKeys, const c
*pppValuesList = valuesList;
*ppValuesListSizes = valuesListSizes;
#endif
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
@ -995,9 +1007,11 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
TAOS_CHECK_GOTO(tsdbCacheGetValuesFromRocks(pTsdb, 2, (const char *const *)keys_list, keys_list_sizes, &values_list,
&values_list_sizes),
NULL, _exit);
#ifdef USE_ROCKSDB
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
#endif
{
#ifdef USE_ROCKSDB
SLastCol *pLastCol = NULL;
if (values_list[0] != NULL) {
code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol);
@ -1028,6 +1042,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
rocksdb_free(values_list[0]);
rocksdb_free(values_list[1]);
#endif
for (int i = 0; i < 2; i++) {
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
@ -1346,6 +1361,7 @@ static void tsdbCacheUpdateLastColToNone(SLastCol *pLastCol, ELastCacheStatus ca
static int32_t tsdbCachePutToRocksdb(STsdb *pTsdb, SLastKey *pLastKey, SLastCol *pLastCol) {
int32_t code = 0;
#ifdef USE_ROCKSDB
char *rocks_value = NULL;
size_t vlen = 0;
@ -1361,7 +1377,7 @@ static int32_t tsdbCachePutToRocksdb(STsdb *pTsdb, SLastKey *pLastKey, SLastCol
(void)taosThreadMutexUnlock(&pTsdb->rCache.writeBatchMutex);
taosMemoryFree(rocks_value);
#endif
TAOS_RETURN(code);
}
@ -1482,7 +1498,7 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
goto _exit;
}
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
// rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
for (int i = 0; i < num_keys; ++i) {
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[i];
SLastUpdateCtx *updCtx = (SLastUpdateCtx *)taosArrayGet(updCtxArray, idxKey->idx);
@ -1553,9 +1569,11 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
if (values_list) {
#ifdef USE_ROCKSDB
for (int i = 0; i < num_keys; ++i) {
rocksdb_free(values_list[i]);
}
#endif
taosMemoryFree(values_list);
}
taosMemoryFree(values_list_sizes);
@ -1754,7 +1772,7 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray,
static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SArray *remainCols,
SCacheRowsReader *pr, int8_t ltype) {
int32_t code = 0, lino = 0;
rocksdb_writebatch_t *wb = NULL;
// rocksdb_writebatch_t *wb = NULL;
SArray *pTmpColArray = NULL;
bool extraTS = false;
@ -2007,9 +2025,11 @@ _exit:
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
if (values_list) {
#ifdef USE_ROCKSDB
for (int i = 0; i < num_keys; ++i) {
rocksdb_free(values_list[i]);
}
#endif
taosMemoryFree(values_list);
}
taosMemoryFree(values_list_sizes);
@ -2707,7 +2727,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
&values_list, &values_list_sizes),
NULL, _exit);
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
// rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
for (int i = 0; i < numKeys; ++i) {
SLastCol *pLastCol = NULL;
if (values_list[i] != NULL) {
@ -2757,9 +2777,11 @@ _exit:
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
if (values_list) {
#if USE_ROCKSDB
for (int i = 0; i < numKeys; ++i) {
rocksdb_free(values_list[i]);
}
#endif
taosMemoryFree(values_list);
}
taosMemoryFree(values_list_sizes);
@ -4083,6 +4105,7 @@ int32_t tsdbCacheGetElems(SVnode *pVnode) {
return elems;
}
#ifdef USE_S3
// block cache
static void getBCacheKey(int32_t fid, int64_t commitID, int64_t blkno, char *key, int *len) {
struct {
@ -4202,3 +4225,4 @@ void tsdbCacheSetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, uint8_t *
tsdbCacheRelease(pFD->pTsdb->pgCache, handle);
}
#endif

View File

@ -122,7 +122,7 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) {
}
if (taosFsyncFile(pFD) < 0) {
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(ERRNO), lino, _exit);
}
_exit:
@ -744,7 +744,7 @@ static int32_t tsdbFSRollback(STsdb *pTsdb) {
_exit:
if (code) {
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(ERRNO));
}
return code;
}

View File

@ -286,7 +286,7 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
tsdbRemoveFile(fobj->fname);
return;
}
#ifdef USE_S3
if (!remove_all) {
// remove local last chunk file
char lc_path[TSDB_FILENAME_LEN];
@ -330,6 +330,7 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
tsdbRemoveFile(lc_path);
}
#endif
}
int32_t tsdbTFileObjRemove(STFileObj *fobj) {

View File

@ -342,7 +342,7 @@ _exit:
}
return code;
}
#ifdef USE_S3
static int32_t tsdbReadFileBlock(STsdbFD *pFD, int64_t offset, int64_t size, bool check, uint8_t **ppBlock) {
int32_t code = 0;
int32_t lino;
@ -409,8 +409,9 @@ _exit:
}
return code;
}
#endif
static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint) {
#ifdef USE_S3
int32_t code = 0;
int32_t lino;
int64_t n = 0;
@ -513,6 +514,9 @@ _exit:
TSDB_ERROR_LOG(TD_VID(pFD->pTsdb->pVnode), lino, code);
}
return code;
#else
return TSDB_CODE_INTERNAL_ERROR;
#endif
}
int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint,
@ -568,7 +572,7 @@ int32_t tsdbFsyncFile(STsdbFD *pFD, int32_t encryptAlgorithm, char *encryptKey)
TSDB_CHECK_CODE(code, lino, _exit);
if (taosFsyncFile(pFD->pFD) < 0) {
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(ERRNO), lino, _exit);
}
_exit:

View File

@ -356,7 +356,9 @@ static int32_t tsdbRetention(void *arg) {
// do retention
if (rtner.fset) {
if (rtnArg->s3Migrate) {
#ifdef USE_S3
TAOS_CHECK_GOTO(tsdbDoS3Migrate(&rtner), &lino, _exit);
#endif
} else {
TAOS_CHECK_GOTO(tsdbDoRetention(&rtner), &lino, _exit);
}
@ -426,6 +428,7 @@ int32_t tsdbAsyncRetention(STsdb *tsdb, int64_t now) {
return code;
}
#ifdef USE_S3
static int32_t tsdbS3FidLevel(int32_t fid, STsdbKeepCfg *pKeepCfg, int32_t s3KeepLocal, int64_t nowSec) {
int32_t localFid;
TSKEY key;
@ -777,10 +780,14 @@ static int32_t tsdbGetS3SizeImpl(STsdb *tsdb, int64_t *size) {
return code;
}
#endif
int32_t tsdbGetS3Size(STsdb *tsdb, int64_t *size) {
int32_t code = 0;
#ifdef USE_S3
(void)taosThreadMutexLock(&tsdb->mutex);
code = tsdbGetS3SizeImpl(tsdb, size);
(void)taosThreadMutexUnlock(&tsdb->mutex);
#endif
return code;
}

View File

@ -438,6 +438,12 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
}
static void vnodeAsyncLaunchWorker(SVAsync *async) {
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
#ifdef TD_COMPACT_OS
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
#endif
for (int32_t i = 0; i < async->numWorkers; i++) {
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
continue;
@ -446,7 +452,7 @@ static void vnodeAsyncLaunchWorker(SVAsync *async) {
async->workers[i].state = EVA_WORKER_STATE_UINIT;
}
int32_t ret = taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]);
int32_t ret = taosThreadCreate(&async->workers[i].thread, &thAttr, vnodeAsyncLoop, &async->workers[i]);
if (ret) {
vError("failed to create worker thread since %s", tstrerror(ret));
} else {
@ -455,6 +461,9 @@ static void vnodeAsyncLaunchWorker(SVAsync *async) {
}
break;
}
#ifdef TD_ASTRA
(void)taosThreadAttrDestroy(&thAttr);
#endif
}
int32_t vnodeAsyncOpen() {

View File

@ -48,7 +48,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu
if (taosThreadSpinInit(pPool->lock, 0) != 0) {
taosMemoryFree((void *)pPool->lock);
taosMemoryFree(pPool);
return terrno = TAOS_SYSTEM_ERROR(errno);
return terrno = TAOS_SYSTEM_ERROR(ERRNO);
}
} else {
pPool->lock = NULL;
@ -227,7 +227,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
SVBufPool *pNewPool = NULL;
if (vnodeBufPoolCreate(pVnode, pPool->id, size, &pNewPool) < 0) {
vWarn("vgId:%d, failed to change buffer pool of id %d size from %" PRId64 " to %" PRId64 " since %s",
TD_VID(pVnode), pPool->id, pPool->node.size, size, tstrerror(errno));
TD_VID(pVnode), pPool->id, pPool->node.size, size, tstrerror(ERRNO));
} else {
vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id,
pPool->node.size, size);

Some files were not shown because too many files have changed in this diff Show More