Merge remote-tracking branch 'origin/3.0' into docs/join
This commit is contained in:
commit
f6741c160d
|
@ -109,6 +109,13 @@ cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
# cJson
|
# cJson
|
||||||
cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
# xz
|
||||||
|
#cat("${TD_SUPPORT_DIR}/xz_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
#lzma2
|
||||||
|
cat("${TD_SUPPORT_DIR}/lzma_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
|
|
||||||
if (${BUILD_CONTRIB})
|
if (${BUILD_CONTRIB})
|
||||||
if(${BUILD_WITH_ROCKSDB})
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
@ -127,6 +134,8 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#cat("${TD_SUPPORT_DIR}/zstd_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
|
||||||
#libuv
|
#libuv
|
||||||
if(${BUILD_WITH_UV})
|
if(${BUILD_WITH_UV})
|
||||||
cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
@ -254,6 +263,13 @@ target_include_directories(
|
||||||
)
|
)
|
||||||
unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
||||||
|
|
||||||
|
# add_subdirectory(xz EXCLUDE_FROM_ALL)
|
||||||
|
# target_include_directories(
|
||||||
|
# xz
|
||||||
|
# PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/xz
|
||||||
|
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/xz
|
||||||
|
# )
|
||||||
|
|
||||||
# leveldb
|
# leveldb
|
||||||
if(${BUILD_WITH_LEVELDB})
|
if(${BUILD_WITH_LEVELDB})
|
||||||
option(LEVELDB_BUILD_TESTS "" OFF)
|
option(LEVELDB_BUILD_TESTS "" OFF)
|
||||||
|
@ -388,7 +404,6 @@ endif()
|
||||||
if(${BUILD_WITH_S3})
|
if(${BUILD_WITH_S3})
|
||||||
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.2/include)
|
INCLUDE_DIRECTORIES($ENV{HOME}/.cos-local.2/include)
|
||||||
MESSAGE("build with s3: ${BUILD_WITH_S3}")
|
MESSAGE("build with s3: ${BUILD_WITH_S3}")
|
||||||
|
|
||||||
# cos
|
# cos
|
||||||
elseif(${BUILD_WITH_COS})
|
elseif(${BUILD_WITH_COS})
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
|
@ -427,6 +442,7 @@ if(${BUILD_PTHREAD})
|
||||||
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
target_link_libraries(pthread INTERFACE libpthreadVC3)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# jemalloc
|
# jemalloc
|
||||||
if(${JEMALLOC_ENABLED})
|
if(${JEMALLOC_ENABLED})
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
|
@ -56,6 +56,7 @@ extern "C" {
|
||||||
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
|
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
|
||||||
#define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs"
|
#define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs"
|
||||||
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
#define TSDB_INS_TABLE_MACHINES "ins_machines"
|
||||||
|
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
|
||||||
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
|
||||||
|
|
||||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||||
|
|
|
@ -176,6 +176,7 @@ typedef enum EStreamType {
|
||||||
STREAM_CREATE_CHILD_TABLE,
|
STREAM_CREATE_CHILD_TABLE,
|
||||||
STREAM_TRANS_STATE,
|
STREAM_TRANS_STATE,
|
||||||
STREAM_MID_RETRIEVE,
|
STREAM_MID_RETRIEVE,
|
||||||
|
STREAM_PARTITION_DELETE_DATA,
|
||||||
} EStreamType;
|
} EStreamType;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
|
@ -29,6 +29,17 @@ extern "C" {
|
||||||
#define SLOW_LOG_TYPE_OTHERS 0x4
|
#define SLOW_LOG_TYPE_OTHERS 0x4
|
||||||
#define SLOW_LOG_TYPE_ALL 0xFFFFFFFF
|
#define SLOW_LOG_TYPE_ALL 0xFFFFFFFF
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DND_CA_SM4 = 1,
|
||||||
|
} EEncryptAlgor;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DND_CS_TSDB = 1,
|
||||||
|
DND_CS_VNODE_WAL = 2,
|
||||||
|
DND_CS_SDB = 4,
|
||||||
|
DND_CS_MNODE_WAL = 8,
|
||||||
|
} EEncryptScope;
|
||||||
|
|
||||||
// cluster
|
// cluster
|
||||||
extern char tsFirst[];
|
extern char tsFirst[];
|
||||||
extern char tsSecond[];
|
extern char tsSecond[];
|
||||||
|
@ -39,6 +50,12 @@ extern uint16_t tsServerPort;
|
||||||
extern int32_t tsVersion;
|
extern int32_t tsVersion;
|
||||||
extern int32_t tsStatusInterval;
|
extern int32_t tsStatusInterval;
|
||||||
extern int32_t tsNumOfSupportVnodes;
|
extern int32_t tsNumOfSupportVnodes;
|
||||||
|
extern char tsEncryptAlgorithm[];
|
||||||
|
extern char tsEncryptScope[];
|
||||||
|
extern EEncryptAlgor tsiEncryptAlgorithm;
|
||||||
|
extern EEncryptScope tsiEncryptScope;
|
||||||
|
//extern char tsAuthCode[];
|
||||||
|
extern char tsEncryptKey[];
|
||||||
|
|
||||||
// common
|
// common
|
||||||
extern int32_t tsMaxShellConns;
|
extern int32_t tsMaxShellConns;
|
||||||
|
@ -94,8 +111,6 @@ extern char tsSnodeAddress[]; // 127.0.0.1:873
|
||||||
// mnode
|
// mnode
|
||||||
extern int64_t tsMndSdbWriteDelta;
|
extern int64_t tsMndSdbWriteDelta;
|
||||||
extern int64_t tsMndLogRetention;
|
extern int64_t tsMndLogRetention;
|
||||||
extern int8_t tsGrant;
|
|
||||||
extern int32_t tsMndGrantMode;
|
|
||||||
extern bool tsMndSkipGrant;
|
extern bool tsMndSkipGrant;
|
||||||
extern bool tsEnableWhiteList;
|
extern bool tsEnableWhiteList;
|
||||||
|
|
||||||
|
@ -104,6 +119,11 @@ extern int64_t tsDndStart;
|
||||||
extern int64_t tsDndStartOsUptime;
|
extern int64_t tsDndStartOsUptime;
|
||||||
extern int64_t tsDndUpTime;
|
extern int64_t tsDndUpTime;
|
||||||
|
|
||||||
|
// dnode misc
|
||||||
|
extern uint32_t tsEncryptionKeyChksum;
|
||||||
|
extern int8_t tsEncryptionKeyStat;
|
||||||
|
extern int8_t tsGrant;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
extern bool tsEnableMonitor;
|
extern bool tsEnableMonitor;
|
||||||
extern int32_t tsMonitorInterval;
|
extern int32_t tsMonitorInterval;
|
||||||
|
|
|
@ -58,9 +58,11 @@ typedef enum {
|
||||||
TSDB_GRANT_BACKUP_RESTORE,
|
TSDB_GRANT_BACKUP_RESTORE,
|
||||||
} EGrantType;
|
} EGrantType;
|
||||||
|
|
||||||
|
int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
||||||
|
int32_t generateEncryptCode(const char *key, const char *machineId, char **encryptCode);
|
||||||
int32_t grantCheck(EGrantType grant);
|
int32_t grantCheck(EGrantType grant);
|
||||||
int32_t grantCheckExpire(EGrantType grant);
|
int32_t grantCheckExpire(EGrantType grant);
|
||||||
char* tGetMachineId();
|
char *tGetMachineId();
|
||||||
|
|
||||||
// #ifndef GRANTS_CFG
|
// #ifndef GRANTS_CFG
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
|
|
|
@ -154,6 +154,7 @@ typedef enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_GRANTS_LOGS,
|
TSDB_MGMT_TABLE_GRANTS_LOGS,
|
||||||
TSDB_MGMT_TABLE_MACHINES,
|
TSDB_MGMT_TABLE_MACHINES,
|
||||||
TSDB_MGMT_TABLE_ARBGROUP,
|
TSDB_MGMT_TABLE_ARBGROUP,
|
||||||
|
TSDB_MGMT_TABLE_ENCRYPTIONS,
|
||||||
TSDB_MGMT_TABLE_MAX,
|
TSDB_MGMT_TABLE_MAX,
|
||||||
} EShowType;
|
} EShowType;
|
||||||
|
|
||||||
|
@ -374,6 +375,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||||
QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
|
QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
|
||||||
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
|
||||||
|
QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
|
||||||
QUERY_NODE_SHOW_TSMAS_STMT,
|
QUERY_NODE_SHOW_TSMAS_STMT,
|
||||||
QUERY_NODE_CREATE_TSMA_STMT,
|
QUERY_NODE_CREATE_TSMA_STMT,
|
||||||
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
|
||||||
|
@ -1247,6 +1249,7 @@ typedef struct {
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
char* sql;
|
char* sql;
|
||||||
int8_t withArbitrator;
|
int8_t withArbitrator;
|
||||||
|
int8_t encryptAlgorithm;
|
||||||
} SCreateDbReq;
|
} SCreateDbReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
|
||||||
|
@ -1405,6 +1408,7 @@ typedef struct {
|
||||||
int8_t replications;
|
int8_t replications;
|
||||||
int8_t strict;
|
int8_t strict;
|
||||||
int8_t cacheLast;
|
int8_t cacheLast;
|
||||||
|
int8_t encryptAlgorithm;
|
||||||
int32_t s3ChunkSize;
|
int32_t s3ChunkSize;
|
||||||
int32_t s3KeepLocal;
|
int32_t s3KeepLocal;
|
||||||
int8_t s3Compact;
|
int8_t s3Compact;
|
||||||
|
@ -1605,13 +1609,15 @@ void tFreeSFuncInfo(SFuncInfo* pInfo);
|
||||||
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
|
void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t statusInterval;
|
int32_t statusInterval;
|
||||||
int64_t checkTime; // 1970-01-01 00:00:00.000
|
int64_t checkTime; // 1970-01-01 00:00:00.000
|
||||||
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
|
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
|
||||||
char locale[TD_LOCALE_LEN]; // tsLocale
|
char locale[TD_LOCALE_LEN]; // tsLocale
|
||||||
char charset[TD_LOCALE_LEN]; // tsCharset
|
char charset[TD_LOCALE_LEN]; // tsCharset
|
||||||
int8_t ttlChangeOnWrite;
|
int8_t ttlChangeOnWrite;
|
||||||
int8_t enableWhiteList;
|
int8_t enableWhiteList;
|
||||||
|
int8_t encryptionKeyStat;
|
||||||
|
uint32_t encryptionKeyChksum;
|
||||||
} SClusterCfg;
|
} SClusterCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1823,6 +1829,7 @@ typedef struct {
|
||||||
int8_t learnerSelfIndex;
|
int8_t learnerSelfIndex;
|
||||||
SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
|
SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
|
||||||
int32_t changeVersion;
|
int32_t changeVersion;
|
||||||
|
int8_t encryptAlgorithm;
|
||||||
} SCreateVnodeReq;
|
} SCreateVnodeReq;
|
||||||
|
|
||||||
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||||
|
@ -3935,6 +3942,7 @@ int32_t tDecodeMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp);
|
||||||
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp);
|
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp);
|
||||||
|
|
||||||
#define MQ_DATA_RSP_VERSION 100
|
#define MQ_DATA_RSP_VERSION 100
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
SMqRspHead head;
|
||||||
STqOffsetVal reqOffset;
|
STqOffsetVal reqOffset;
|
||||||
|
@ -3946,33 +3954,27 @@ typedef struct {
|
||||||
SArray* blockData;
|
SArray* blockData;
|
||||||
SArray* blockTbName;
|
SArray* blockTbName;
|
||||||
SArray* blockSchema;
|
SArray* blockSchema;
|
||||||
int64_t sleepTime;
|
} SMqDataRspCommon;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMqDataRspCommon common;
|
||||||
|
int64_t sleepTime;
|
||||||
} SMqDataRsp;
|
} SMqDataRsp;
|
||||||
|
|
||||||
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
|
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const void* pRsp);
|
||||||
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp, int8_t dataVersion);
|
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, void* pRsp);
|
||||||
void tDeleteMqDataRsp(SMqDataRsp* pRsp);
|
void tDeleteMqDataRsp(void* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
SMqDataRspCommon common;
|
||||||
STqOffsetVal reqOffset;
|
int32_t createTableNum;
|
||||||
STqOffsetVal rspOffset;
|
SArray* createTableLen;
|
||||||
int32_t blockNum;
|
SArray* createTableReq;
|
||||||
int8_t withTbName;
|
|
||||||
int8_t withSchema;
|
|
||||||
SArray* blockDataLen;
|
|
||||||
SArray* blockData;
|
|
||||||
SArray* blockTbName;
|
|
||||||
SArray* blockSchema;
|
|
||||||
// the following attributes are extended from SMqDataRsp
|
|
||||||
int32_t createTableNum;
|
|
||||||
SArray* createTableLen;
|
|
||||||
SArray* createTableReq;
|
|
||||||
} STaosxRsp;
|
} STaosxRsp;
|
||||||
|
|
||||||
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const STaosxRsp* pRsp);
|
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const void* pRsp);
|
||||||
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, STaosxRsp* pRsp, int8_t dateVersion);
|
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, void* pRsp);
|
||||||
void tDeleteSTaosxRsp(STaosxRsp* pRsp);
|
void tDeleteSTaosxRsp(void* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
SMqRspHead head;
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_MNODE_TYPE, "dnode-alter-mnode-type", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_MNODE_TYPE, "dnode-alter-mnode-type", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL)
|
||||||
TD_CLOSE_MSG_SEG(TDMT_END_DND_MSG)
|
TD_CLOSE_MSG_SEG(TDMT_END_DND_MSG)
|
||||||
|
|
||||||
|
@ -220,6 +221,7 @@
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_REQ_CHKPT, "stream-req-checkpoint", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_REQ_CHKPT, "stream-req-checkpoint", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_CLUSTER, "config-cluster", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG_CLUSTER, "config-cluster", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_ENCRYPT_KEY, "create-encrypt-key", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB, "s3migrate-db", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB, "s3migrate-db", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB_TIMER, "s3migrate-db-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB_TIMER, "s3migrate-db-tmr", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)
|
||||||
|
|
|
@ -16,378 +16,381 @@
|
||||||
#ifndef _TD_COMMON_TOKEN_H_
|
#ifndef _TD_COMMON_TOKEN_H_
|
||||||
#define _TD_COMMON_TOKEN_H_
|
#define _TD_COMMON_TOKEN_H_
|
||||||
|
|
||||||
#define TK_OR 1
|
#define TK_OR 1
|
||||||
#define TK_AND 2
|
#define TK_AND 2
|
||||||
#define TK_UNION 3
|
#define TK_UNION 3
|
||||||
#define TK_ALL 4
|
#define TK_ALL 4
|
||||||
#define TK_MINUS 5
|
#define TK_MINUS 5
|
||||||
#define TK_EXCEPT 6
|
#define TK_EXCEPT 6
|
||||||
#define TK_INTERSECT 7
|
#define TK_INTERSECT 7
|
||||||
#define TK_NK_BITAND 8
|
#define TK_NK_BITAND 8
|
||||||
#define TK_NK_BITOR 9
|
#define TK_NK_BITOR 9
|
||||||
#define TK_NK_LSHIFT 10
|
#define TK_NK_LSHIFT 10
|
||||||
#define TK_NK_RSHIFT 11
|
#define TK_NK_RSHIFT 11
|
||||||
#define TK_NK_PLUS 12
|
#define TK_NK_PLUS 12
|
||||||
#define TK_NK_MINUS 13
|
#define TK_NK_MINUS 13
|
||||||
#define TK_NK_STAR 14
|
#define TK_NK_STAR 14
|
||||||
#define TK_NK_SLASH 15
|
#define TK_NK_SLASH 15
|
||||||
#define TK_NK_REM 16
|
#define TK_NK_REM 16
|
||||||
#define TK_NK_CONCAT 17
|
#define TK_NK_CONCAT 17
|
||||||
#define TK_CREATE 18
|
#define TK_CREATE 18
|
||||||
#define TK_ACCOUNT 19
|
#define TK_ACCOUNT 19
|
||||||
#define TK_NK_ID 20
|
#define TK_NK_ID 20
|
||||||
#define TK_PASS 21
|
#define TK_PASS 21
|
||||||
#define TK_NK_STRING 22
|
#define TK_NK_STRING 22
|
||||||
#define TK_ALTER 23
|
#define TK_ALTER 23
|
||||||
#define TK_PPS 24
|
#define TK_PPS 24
|
||||||
#define TK_TSERIES 25
|
#define TK_TSERIES 25
|
||||||
#define TK_STORAGE 26
|
#define TK_STORAGE 26
|
||||||
#define TK_STREAMS 27
|
#define TK_STREAMS 27
|
||||||
#define TK_QTIME 28
|
#define TK_QTIME 28
|
||||||
#define TK_DBS 29
|
#define TK_DBS 29
|
||||||
#define TK_USERS 30
|
#define TK_USERS 30
|
||||||
#define TK_CONNS 31
|
#define TK_CONNS 31
|
||||||
#define TK_STATE 32
|
#define TK_STATE 32
|
||||||
#define TK_NK_COMMA 33
|
#define TK_NK_COMMA 33
|
||||||
#define TK_HOST 34
|
#define TK_HOST 34
|
||||||
#define TK_USER 35
|
#define TK_USER 35
|
||||||
#define TK_ENABLE 36
|
#define TK_ENABLE 36
|
||||||
#define TK_NK_INTEGER 37
|
#define TK_NK_INTEGER 37
|
||||||
#define TK_SYSINFO 38
|
#define TK_SYSINFO 38
|
||||||
#define TK_ADD 39
|
#define TK_ADD 39
|
||||||
#define TK_DROP 40
|
#define TK_DROP 40
|
||||||
#define TK_GRANT 41
|
#define TK_GRANT 41
|
||||||
#define TK_ON 42
|
#define TK_ON 42
|
||||||
#define TK_TO 43
|
#define TK_TO 43
|
||||||
#define TK_REVOKE 44
|
#define TK_REVOKE 44
|
||||||
#define TK_FROM 45
|
#define TK_FROM 45
|
||||||
#define TK_SUBSCRIBE 46
|
#define TK_SUBSCRIBE 46
|
||||||
#define TK_READ 47
|
#define TK_READ 47
|
||||||
#define TK_WRITE 48
|
#define TK_WRITE 48
|
||||||
#define TK_NK_DOT 49
|
#define TK_NK_DOT 49
|
||||||
#define TK_WITH 50
|
#define TK_WITH 50
|
||||||
#define TK_DNODE 51
|
#define TK_ENCRYPT_KEY 51
|
||||||
#define TK_PORT 52
|
#define TK_DNODE 52
|
||||||
#define TK_DNODES 53
|
#define TK_PORT 53
|
||||||
#define TK_RESTORE 54
|
#define TK_DNODES 54
|
||||||
#define TK_NK_IPTOKEN 55
|
#define TK_RESTORE 55
|
||||||
#define TK_FORCE 56
|
#define TK_NK_IPTOKEN 56
|
||||||
#define TK_UNSAFE 57
|
#define TK_FORCE 57
|
||||||
#define TK_CLUSTER 58
|
#define TK_UNSAFE 58
|
||||||
#define TK_LOCAL 59
|
#define TK_CLUSTER 59
|
||||||
#define TK_QNODE 60
|
#define TK_LOCAL 60
|
||||||
#define TK_BNODE 61
|
#define TK_QNODE 61
|
||||||
#define TK_SNODE 62
|
#define TK_BNODE 62
|
||||||
#define TK_MNODE 63
|
#define TK_SNODE 63
|
||||||
#define TK_VNODE 64
|
#define TK_MNODE 64
|
||||||
#define TK_DATABASE 65
|
#define TK_VNODE 65
|
||||||
#define TK_USE 66
|
#define TK_DATABASE 66
|
||||||
#define TK_FLUSH 67
|
#define TK_USE 67
|
||||||
#define TK_TRIM 68
|
#define TK_FLUSH 68
|
||||||
#define TK_S3MIGRATE 69
|
#define TK_TRIM 69
|
||||||
#define TK_COMPACT 70
|
#define TK_S3MIGRATE 70
|
||||||
#define TK_IF 71
|
#define TK_COMPACT 71
|
||||||
#define TK_NOT 72
|
#define TK_IF 72
|
||||||
#define TK_EXISTS 73
|
#define TK_NOT 73
|
||||||
#define TK_BUFFER 74
|
#define TK_EXISTS 74
|
||||||
#define TK_CACHEMODEL 75
|
#define TK_BUFFER 75
|
||||||
#define TK_CACHESIZE 76
|
#define TK_CACHEMODEL 76
|
||||||
#define TK_COMP 77
|
#define TK_CACHESIZE 77
|
||||||
#define TK_DURATION 78
|
#define TK_COMP 78
|
||||||
#define TK_NK_VARIABLE 79
|
#define TK_DURATION 79
|
||||||
#define TK_MAXROWS 80
|
#define TK_NK_VARIABLE 80
|
||||||
#define TK_MINROWS 81
|
#define TK_MAXROWS 81
|
||||||
#define TK_KEEP 82
|
#define TK_MINROWS 82
|
||||||
#define TK_PAGES 83
|
#define TK_KEEP 83
|
||||||
#define TK_PAGESIZE 84
|
#define TK_PAGES 84
|
||||||
#define TK_TSDB_PAGESIZE 85
|
#define TK_PAGESIZE 85
|
||||||
#define TK_PRECISION 86
|
#define TK_TSDB_PAGESIZE 86
|
||||||
#define TK_REPLICA 87
|
#define TK_PRECISION 87
|
||||||
#define TK_VGROUPS 88
|
#define TK_REPLICA 88
|
||||||
#define TK_SINGLE_STABLE 89
|
#define TK_VGROUPS 89
|
||||||
#define TK_RETENTIONS 90
|
#define TK_SINGLE_STABLE 90
|
||||||
#define TK_SCHEMALESS 91
|
#define TK_RETENTIONS 91
|
||||||
#define TK_WAL_LEVEL 92
|
#define TK_SCHEMALESS 92
|
||||||
#define TK_WAL_FSYNC_PERIOD 93
|
#define TK_WAL_LEVEL 93
|
||||||
#define TK_WAL_RETENTION_PERIOD 94
|
#define TK_WAL_FSYNC_PERIOD 94
|
||||||
#define TK_WAL_RETENTION_SIZE 95
|
#define TK_WAL_RETENTION_PERIOD 95
|
||||||
#define TK_WAL_ROLL_PERIOD 96
|
#define TK_WAL_RETENTION_SIZE 96
|
||||||
#define TK_WAL_SEGMENT_SIZE 97
|
#define TK_WAL_ROLL_PERIOD 97
|
||||||
#define TK_STT_TRIGGER 98
|
#define TK_WAL_SEGMENT_SIZE 98
|
||||||
#define TK_TABLE_PREFIX 99
|
#define TK_STT_TRIGGER 99
|
||||||
#define TK_TABLE_SUFFIX 100
|
#define TK_TABLE_PREFIX 100
|
||||||
#define TK_S3_CHUNKSIZE 101
|
#define TK_TABLE_SUFFIX 101
|
||||||
#define TK_S3_KEEPLOCAL 102
|
#define TK_S3_CHUNKSIZE 102
|
||||||
#define TK_S3_COMPACT 103
|
#define TK_S3_KEEPLOCAL 103
|
||||||
#define TK_KEEP_TIME_OFFSET 104
|
#define TK_S3_COMPACT 104
|
||||||
#define TK_NK_COLON 105
|
#define TK_KEEP_TIME_OFFSET 105
|
||||||
#define TK_BWLIMIT 106
|
#define TK_ENCRYPT_ALGORITHM 106
|
||||||
#define TK_START 107
|
#define TK_NK_COLON 107
|
||||||
#define TK_TIMESTAMP 108
|
#define TK_BWLIMIT 108
|
||||||
#define TK_END 109
|
#define TK_START 109
|
||||||
#define TK_TABLE 110
|
#define TK_TIMESTAMP 110
|
||||||
#define TK_NK_LP 111
|
#define TK_END 111
|
||||||
#define TK_NK_RP 112
|
#define TK_TABLE 112
|
||||||
#define TK_STABLE 113
|
#define TK_NK_LP 113
|
||||||
#define TK_COLUMN 114
|
#define TK_NK_RP 114
|
||||||
#define TK_MODIFY 115
|
#define TK_STABLE 115
|
||||||
#define TK_RENAME 116
|
#define TK_COLUMN 116
|
||||||
#define TK_TAG 117
|
#define TK_MODIFY 117
|
||||||
#define TK_SET 118
|
#define TK_RENAME 118
|
||||||
#define TK_NK_EQ 119
|
#define TK_TAG 119
|
||||||
#define TK_USING 120
|
#define TK_SET 120
|
||||||
#define TK_TAGS 121
|
#define TK_NK_EQ 121
|
||||||
#define TK_BOOL 122
|
#define TK_USING 122
|
||||||
#define TK_TINYINT 123
|
#define TK_TAGS 123
|
||||||
#define TK_SMALLINT 124
|
#define TK_BOOL 124
|
||||||
#define TK_INT 125
|
#define TK_TINYINT 125
|
||||||
#define TK_INTEGER 126
|
#define TK_SMALLINT 126
|
||||||
#define TK_BIGINT 127
|
#define TK_INT 127
|
||||||
#define TK_FLOAT 128
|
#define TK_INTEGER 128
|
||||||
#define TK_DOUBLE 129
|
#define TK_BIGINT 129
|
||||||
#define TK_BINARY 130
|
#define TK_FLOAT 130
|
||||||
#define TK_NCHAR 131
|
#define TK_DOUBLE 131
|
||||||
#define TK_UNSIGNED 132
|
#define TK_BINARY 132
|
||||||
#define TK_JSON 133
|
#define TK_NCHAR 133
|
||||||
#define TK_VARCHAR 134
|
#define TK_UNSIGNED 134
|
||||||
#define TK_MEDIUMBLOB 135
|
#define TK_JSON 135
|
||||||
#define TK_BLOB 136
|
#define TK_VARCHAR 136
|
||||||
#define TK_VARBINARY 137
|
#define TK_MEDIUMBLOB 137
|
||||||
#define TK_GEOMETRY 138
|
#define TK_BLOB 138
|
||||||
#define TK_DECIMAL 139
|
#define TK_VARBINARY 139
|
||||||
#define TK_COMMENT 140
|
#define TK_GEOMETRY 140
|
||||||
#define TK_MAX_DELAY 141
|
#define TK_DECIMAL 141
|
||||||
#define TK_WATERMARK 142
|
#define TK_COMMENT 142
|
||||||
#define TK_ROLLUP 143
|
#define TK_MAX_DELAY 143
|
||||||
#define TK_TTL 144
|
#define TK_WATERMARK 144
|
||||||
#define TK_SMA 145
|
#define TK_ROLLUP 145
|
||||||
#define TK_DELETE_MARK 146
|
#define TK_TTL 146
|
||||||
#define TK_FIRST 147
|
#define TK_SMA 147
|
||||||
#define TK_LAST 148
|
#define TK_DELETE_MARK 148
|
||||||
#define TK_SHOW 149
|
#define TK_FIRST 149
|
||||||
#define TK_PRIVILEGES 150
|
#define TK_LAST 150
|
||||||
#define TK_DATABASES 151
|
#define TK_SHOW 151
|
||||||
#define TK_TABLES 152
|
#define TK_PRIVILEGES 152
|
||||||
#define TK_STABLES 153
|
#define TK_DATABASES 153
|
||||||
#define TK_MNODES 154
|
#define TK_TABLES 154
|
||||||
#define TK_QNODES 155
|
#define TK_STABLES 155
|
||||||
#define TK_ARBGROUPS 156
|
#define TK_MNODES 156
|
||||||
#define TK_FUNCTIONS 157
|
#define TK_QNODES 157
|
||||||
#define TK_INDEXES 158
|
#define TK_ARBGROUPS 158
|
||||||
#define TK_ACCOUNTS 159
|
#define TK_FUNCTIONS 159
|
||||||
#define TK_APPS 160
|
#define TK_INDEXES 160
|
||||||
#define TK_CONNECTIONS 161
|
#define TK_ACCOUNTS 161
|
||||||
#define TK_LICENCES 162
|
#define TK_APPS 162
|
||||||
#define TK_GRANTS 163
|
#define TK_CONNECTIONS 163
|
||||||
#define TK_FULL 164
|
#define TK_LICENCES 164
|
||||||
#define TK_LOGS 165
|
#define TK_GRANTS 165
|
||||||
#define TK_MACHINES 166
|
#define TK_FULL 166
|
||||||
#define TK_QUERIES 167
|
#define TK_LOGS 167
|
||||||
#define TK_SCORES 168
|
#define TK_MACHINES 168
|
||||||
#define TK_TOPICS 169
|
#define TK_ENCRYPTIONS 169
|
||||||
#define TK_VARIABLES 170
|
#define TK_QUERIES 170
|
||||||
#define TK_BNODES 171
|
#define TK_SCORES 171
|
||||||
#define TK_SNODES 172
|
#define TK_TOPICS 172
|
||||||
#define TK_TRANSACTIONS 173
|
#define TK_VARIABLES 173
|
||||||
#define TK_DISTRIBUTED 174
|
#define TK_BNODES 174
|
||||||
#define TK_CONSUMERS 175
|
#define TK_SNODES 175
|
||||||
#define TK_SUBSCRIPTIONS 176
|
#define TK_TRANSACTIONS 176
|
||||||
#define TK_VNODES 177
|
#define TK_DISTRIBUTED 177
|
||||||
#define TK_ALIVE 178
|
#define TK_CONSUMERS 178
|
||||||
#define TK_VIEWS 179
|
#define TK_SUBSCRIPTIONS 179
|
||||||
#define TK_VIEW 180
|
#define TK_VNODES 180
|
||||||
#define TK_COMPACTS 181
|
#define TK_ALIVE 181
|
||||||
#define TK_NORMAL 182
|
#define TK_VIEWS 182
|
||||||
#define TK_CHILD 183
|
#define TK_VIEW 183
|
||||||
#define TK_LIKE 184
|
#define TK_COMPACTS 184
|
||||||
#define TK_TBNAME 185
|
#define TK_NORMAL 185
|
||||||
#define TK_QTAGS 186
|
#define TK_CHILD 186
|
||||||
#define TK_AS 187
|
#define TK_LIKE 187
|
||||||
#define TK_SYSTEM 188
|
#define TK_TBNAME 188
|
||||||
#define TK_TSMA 189
|
#define TK_QTAGS 189
|
||||||
#define TK_INTERVAL 190
|
#define TK_AS 190
|
||||||
#define TK_RECURSIVE 191
|
#define TK_SYSTEM 191
|
||||||
#define TK_TSMAS 192
|
#define TK_TSMA 192
|
||||||
#define TK_FUNCTION 193
|
#define TK_INTERVAL 193
|
||||||
#define TK_INDEX 194
|
#define TK_RECURSIVE 194
|
||||||
#define TK_COUNT 195
|
#define TK_TSMAS 195
|
||||||
#define TK_LAST_ROW 196
|
#define TK_FUNCTION 196
|
||||||
#define TK_META 197
|
#define TK_INDEX 197
|
||||||
#define TK_ONLY 198
|
#define TK_COUNT 198
|
||||||
#define TK_TOPIC 199
|
#define TK_LAST_ROW 199
|
||||||
#define TK_CONSUMER 200
|
#define TK_META 200
|
||||||
#define TK_GROUP 201
|
#define TK_ONLY 201
|
||||||
#define TK_DESC 202
|
#define TK_TOPIC 202
|
||||||
#define TK_DESCRIBE 203
|
#define TK_CONSUMER 203
|
||||||
#define TK_RESET 204
|
#define TK_GROUP 204
|
||||||
#define TK_QUERY 205
|
#define TK_DESC 205
|
||||||
#define TK_CACHE 206
|
#define TK_DESCRIBE 206
|
||||||
#define TK_EXPLAIN 207
|
#define TK_RESET 207
|
||||||
#define TK_ANALYZE 208
|
#define TK_QUERY 208
|
||||||
#define TK_VERBOSE 209
|
#define TK_CACHE 209
|
||||||
#define TK_NK_BOOL 210
|
#define TK_EXPLAIN 210
|
||||||
#define TK_RATIO 211
|
#define TK_ANALYZE 211
|
||||||
#define TK_NK_FLOAT 212
|
#define TK_VERBOSE 212
|
||||||
#define TK_OUTPUTTYPE 213
|
#define TK_NK_BOOL 213
|
||||||
#define TK_AGGREGATE 214
|
#define TK_RATIO 214
|
||||||
#define TK_BUFSIZE 215
|
#define TK_NK_FLOAT 215
|
||||||
#define TK_LANGUAGE 216
|
#define TK_OUTPUTTYPE 216
|
||||||
#define TK_REPLACE 217
|
#define TK_AGGREGATE 217
|
||||||
#define TK_STREAM 218
|
#define TK_BUFSIZE 218
|
||||||
#define TK_INTO 219
|
#define TK_LANGUAGE 219
|
||||||
#define TK_PAUSE 220
|
#define TK_REPLACE 220
|
||||||
#define TK_RESUME 221
|
#define TK_STREAM 221
|
||||||
#define TK_PRIMARY 222
|
#define TK_INTO 222
|
||||||
#define TK_KEY 223
|
#define TK_PAUSE 223
|
||||||
#define TK_TRIGGER 224
|
#define TK_RESUME 224
|
||||||
#define TK_AT_ONCE 225
|
#define TK_PRIMARY 225
|
||||||
#define TK_WINDOW_CLOSE 226
|
#define TK_KEY 226
|
||||||
#define TK_IGNORE 227
|
#define TK_TRIGGER 227
|
||||||
#define TK_EXPIRED 228
|
#define TK_AT_ONCE 228
|
||||||
#define TK_FILL_HISTORY 229
|
#define TK_WINDOW_CLOSE 229
|
||||||
#define TK_UPDATE 230
|
#define TK_IGNORE 230
|
||||||
#define TK_SUBTABLE 231
|
#define TK_EXPIRED 231
|
||||||
#define TK_UNTREATED 232
|
#define TK_FILL_HISTORY 232
|
||||||
#define TK_KILL 233
|
#define TK_UPDATE 233
|
||||||
#define TK_CONNECTION 234
|
#define TK_SUBTABLE 234
|
||||||
#define TK_TRANSACTION 235
|
#define TK_UNTREATED 235
|
||||||
#define TK_BALANCE 236
|
#define TK_KILL 236
|
||||||
#define TK_VGROUP 237
|
#define TK_CONNECTION 237
|
||||||
#define TK_LEADER 238
|
#define TK_TRANSACTION 238
|
||||||
#define TK_MERGE 239
|
#define TK_BALANCE 239
|
||||||
#define TK_REDISTRIBUTE 240
|
#define TK_VGROUP 240
|
||||||
#define TK_SPLIT 241
|
#define TK_LEADER 241
|
||||||
#define TK_DELETE 242
|
#define TK_MERGE 242
|
||||||
#define TK_INSERT 243
|
#define TK_REDISTRIBUTE 243
|
||||||
#define TK_NK_BIN 244
|
#define TK_SPLIT 244
|
||||||
#define TK_NK_HEX 245
|
#define TK_DELETE 245
|
||||||
#define TK_NULL 246
|
#define TK_INSERT 246
|
||||||
#define TK_NK_QUESTION 247
|
#define TK_NK_BIN 247
|
||||||
#define TK_NK_ALIAS 248
|
#define TK_NK_HEX 248
|
||||||
#define TK_NK_ARROW 249
|
#define TK_NULL 249
|
||||||
#define TK_ROWTS 250
|
#define TK_NK_QUESTION 250
|
||||||
#define TK_QSTART 251
|
#define TK_NK_ALIAS 251
|
||||||
#define TK_QEND 252
|
#define TK_NK_ARROW 252
|
||||||
#define TK_QDURATION 253
|
#define TK_ROWTS 253
|
||||||
#define TK_WSTART 254
|
#define TK_QSTART 254
|
||||||
#define TK_WEND 255
|
#define TK_QEND 255
|
||||||
#define TK_WDURATION 256
|
#define TK_QDURATION 256
|
||||||
#define TK_IROWTS 257
|
#define TK_WSTART 257
|
||||||
#define TK_ISFILLED 258
|
#define TK_WEND 258
|
||||||
#define TK_CAST 259
|
#define TK_WDURATION 259
|
||||||
#define TK_NOW 260
|
#define TK_IROWTS 260
|
||||||
#define TK_TODAY 261
|
#define TK_ISFILLED 261
|
||||||
#define TK_TIMEZONE 262
|
#define TK_CAST 262
|
||||||
#define TK_CLIENT_VERSION 263
|
#define TK_NOW 263
|
||||||
#define TK_SERVER_VERSION 264
|
#define TK_TODAY 264
|
||||||
#define TK_SERVER_STATUS 265
|
#define TK_TIMEZONE 265
|
||||||
#define TK_CURRENT_USER 266
|
#define TK_CLIENT_VERSION 266
|
||||||
#define TK_CASE 267
|
#define TK_SERVER_VERSION 267
|
||||||
#define TK_WHEN 268
|
#define TK_SERVER_STATUS 268
|
||||||
#define TK_THEN 269
|
#define TK_CURRENT_USER 269
|
||||||
#define TK_ELSE 270
|
#define TK_CASE 270
|
||||||
#define TK_BETWEEN 271
|
#define TK_WHEN 271
|
||||||
#define TK_IS 272
|
#define TK_THEN 272
|
||||||
#define TK_NK_LT 273
|
#define TK_ELSE 273
|
||||||
#define TK_NK_GT 274
|
#define TK_BETWEEN 274
|
||||||
#define TK_NK_LE 275
|
#define TK_IS 275
|
||||||
#define TK_NK_GE 276
|
#define TK_NK_LT 276
|
||||||
#define TK_NK_NE 277
|
#define TK_NK_GT 277
|
||||||
#define TK_MATCH 278
|
#define TK_NK_LE 278
|
||||||
#define TK_NMATCH 279
|
#define TK_NK_GE 279
|
||||||
#define TK_CONTAINS 280
|
#define TK_NK_NE 280
|
||||||
#define TK_IN 281
|
#define TK_MATCH 281
|
||||||
#define TK_JOIN 282
|
#define TK_NMATCH 282
|
||||||
#define TK_INNER 283
|
#define TK_CONTAINS 283
|
||||||
#define TK_LEFT 284
|
#define TK_IN 284
|
||||||
#define TK_RIGHT 285
|
#define TK_JOIN 285
|
||||||
#define TK_OUTER 286
|
#define TK_INNER 286
|
||||||
#define TK_SEMI 287
|
#define TK_LEFT 287
|
||||||
#define TK_ANTI 288
|
#define TK_RIGHT 288
|
||||||
#define TK_ASOF 289
|
#define TK_OUTER 289
|
||||||
#define TK_WINDOW 290
|
#define TK_SEMI 290
|
||||||
#define TK_WINDOW_OFFSET 291
|
#define TK_ANTI 291
|
||||||
#define TK_JLIMIT 292
|
#define TK_ASOF 292
|
||||||
#define TK_SELECT 293
|
#define TK_WINDOW 293
|
||||||
#define TK_NK_HINT 294
|
#define TK_WINDOW_OFFSET 294
|
||||||
#define TK_DISTINCT 295
|
#define TK_JLIMIT 295
|
||||||
#define TK_WHERE 296
|
#define TK_SELECT 296
|
||||||
#define TK_PARTITION 297
|
#define TK_NK_HINT 297
|
||||||
#define TK_BY 298
|
#define TK_DISTINCT 298
|
||||||
#define TK_SESSION 299
|
#define TK_WHERE 299
|
||||||
#define TK_STATE_WINDOW 300
|
#define TK_PARTITION 300
|
||||||
#define TK_EVENT_WINDOW 301
|
#define TK_BY 301
|
||||||
#define TK_COUNT_WINDOW 302
|
#define TK_SESSION 302
|
||||||
#define TK_SLIDING 303
|
#define TK_STATE_WINDOW 303
|
||||||
#define TK_FILL 304
|
#define TK_EVENT_WINDOW 304
|
||||||
#define TK_VALUE 305
|
#define TK_COUNT_WINDOW 305
|
||||||
#define TK_VALUE_F 306
|
#define TK_SLIDING 306
|
||||||
#define TK_NONE 307
|
#define TK_FILL 307
|
||||||
#define TK_PREV 308
|
#define TK_VALUE 308
|
||||||
#define TK_NULL_F 309
|
#define TK_VALUE_F 309
|
||||||
#define TK_LINEAR 310
|
#define TK_NONE 310
|
||||||
#define TK_NEXT 311
|
#define TK_PREV 311
|
||||||
#define TK_HAVING 312
|
#define TK_NULL_F 312
|
||||||
#define TK_RANGE 313
|
#define TK_LINEAR 313
|
||||||
#define TK_EVERY 314
|
#define TK_NEXT 314
|
||||||
#define TK_ORDER 315
|
#define TK_HAVING 315
|
||||||
#define TK_SLIMIT 316
|
#define TK_RANGE 316
|
||||||
#define TK_SOFFSET 317
|
#define TK_EVERY 317
|
||||||
#define TK_LIMIT 318
|
#define TK_ORDER 318
|
||||||
#define TK_OFFSET 319
|
#define TK_SLIMIT 319
|
||||||
#define TK_ASC 320
|
#define TK_SOFFSET 320
|
||||||
#define TK_NULLS 321
|
#define TK_LIMIT 321
|
||||||
#define TK_ABORT 322
|
#define TK_OFFSET 322
|
||||||
#define TK_AFTER 323
|
#define TK_ASC 323
|
||||||
#define TK_ATTACH 324
|
#define TK_NULLS 324
|
||||||
#define TK_BEFORE 325
|
#define TK_ABORT 325
|
||||||
#define TK_BEGIN 326
|
#define TK_AFTER 326
|
||||||
#define TK_BITAND 327
|
#define TK_ATTACH 327
|
||||||
#define TK_BITNOT 328
|
#define TK_BEFORE 328
|
||||||
#define TK_BITOR 329
|
#define TK_BEGIN 329
|
||||||
#define TK_BLOCKS 330
|
#define TK_BITAND 330
|
||||||
#define TK_CHANGE 331
|
#define TK_BITNOT 331
|
||||||
#define TK_COMMA 332
|
#define TK_BITOR 332
|
||||||
#define TK_CONCAT 333
|
#define TK_BLOCKS 333
|
||||||
#define TK_CONFLICT 334
|
#define TK_CHANGE 334
|
||||||
#define TK_COPY 335
|
#define TK_COMMA 335
|
||||||
#define TK_DEFERRED 336
|
#define TK_CONCAT 336
|
||||||
#define TK_DELIMITERS 337
|
#define TK_CONFLICT 337
|
||||||
#define TK_DETACH 338
|
#define TK_COPY 338
|
||||||
#define TK_DIVIDE 339
|
#define TK_DEFERRED 339
|
||||||
#define TK_DOT 340
|
#define TK_DELIMITERS 340
|
||||||
#define TK_EACH 341
|
#define TK_DETACH 341
|
||||||
#define TK_FAIL 342
|
#define TK_DIVIDE 342
|
||||||
#define TK_FILE 343
|
#define TK_DOT 343
|
||||||
#define TK_FOR 344
|
#define TK_EACH 344
|
||||||
#define TK_GLOB 345
|
#define TK_FAIL 345
|
||||||
#define TK_ID 346
|
#define TK_FILE 346
|
||||||
#define TK_IMMEDIATE 347
|
#define TK_FOR 347
|
||||||
#define TK_IMPORT 348
|
#define TK_GLOB 348
|
||||||
#define TK_INITIALLY 349
|
#define TK_ID 349
|
||||||
#define TK_INSTEAD 350
|
#define TK_IMMEDIATE 350
|
||||||
#define TK_ISNULL 351
|
#define TK_IMPORT 351
|
||||||
#define TK_MODULES 352
|
#define TK_INITIALLY 352
|
||||||
#define TK_NK_BITNOT 353
|
#define TK_INSTEAD 353
|
||||||
#define TK_NK_SEMI 354
|
#define TK_ISNULL 354
|
||||||
#define TK_NOTNULL 355
|
#define TK_MODULES 355
|
||||||
#define TK_OF 356
|
#define TK_NK_BITNOT 356
|
||||||
#define TK_PLUS 357
|
#define TK_NK_SEMI 357
|
||||||
#define TK_PRIVILEGE 358
|
#define TK_NOTNULL 358
|
||||||
#define TK_RAISE 359
|
#define TK_OF 359
|
||||||
#define TK_RESTRICT 360
|
#define TK_PLUS 360
|
||||||
#define TK_ROW 361
|
#define TK_PRIVILEGE 361
|
||||||
#define TK_STAR 362
|
#define TK_RAISE 362
|
||||||
#define TK_STATEMENT 363
|
#define TK_RESTRICT 363
|
||||||
#define TK_STRICT 364
|
#define TK_ROW 364
|
||||||
#define TK_STRING 365
|
#define TK_STAR 365
|
||||||
#define TK_TIMES 366
|
#define TK_STATEMENT 366
|
||||||
#define TK_VALUES 367
|
#define TK_STRICT 367
|
||||||
#define TK_VARIABLE 368
|
#define TK_STRING 368
|
||||||
#define TK_WAL 369
|
#define TK_TIMES 369
|
||||||
#define TK_ENCODE 370
|
#define TK_VALUES 370
|
||||||
#define TK_COMPRESS 371
|
#define TK_VARIABLE 371
|
||||||
#define TK_LEVEL 372
|
#define TK_WAL 372
|
||||||
|
#define TK_ENCODE 373
|
||||||
|
#define TK_COMPRESS 374
|
||||||
|
#define TK_LEVEL 375
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
|
|
|
@ -41,5 +41,6 @@ int32_t tqStreamTaskProcessTaskPauseReq(SStreamMeta* pMeta, char* pMsg);
|
||||||
int32_t tqStreamTaskProcessTaskResumeReq(void* handle, int64_t sversion, char* pMsg, bool fromVnode);
|
int32_t tqStreamTaskProcessTaskResumeReq(void* handle, int64_t sversion, char* pMsg, bool fromVnode);
|
||||||
|
|
||||||
int32_t tqExpandStreamTask(SStreamTask* pTask, SStreamMeta* pMeta, void* pVnode);
|
int32_t tqExpandStreamTask(SStreamTask* pTask, SStreamMeta* pMeta, void* pVnode);
|
||||||
|
void tqSetRestoreVersionInfo(SStreamTask* pTask);
|
||||||
|
|
||||||
#endif // TDENGINE_TQ_COMMON_H
|
#endif // TDENGINE_TQ_COMMON_H
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CRYPT_H_
|
||||||
|
#define _CRYPT_H_
|
||||||
|
#include "tdef.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct SCryptOpts{
|
||||||
|
int32_t len;
|
||||||
|
char* source;
|
||||||
|
char* result;
|
||||||
|
int32_t unitLen;
|
||||||
|
unsigned char key[17];
|
||||||
|
}SCryptOpts;
|
||||||
|
|
||||||
|
int32_t CBC_Decrypt(SCryptOpts *opts);
|
||||||
|
int32_t CBC_Encrypt(SCryptOpts *opts);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _CRYPT_H_
|
|
@ -70,7 +70,9 @@ typedef struct SDatabaseOptions {
|
||||||
int8_t cacheModel;
|
int8_t cacheModel;
|
||||||
int32_t cacheLastSize;
|
int32_t cacheLastSize;
|
||||||
int8_t compressionLevel;
|
int8_t compressionLevel;
|
||||||
|
int8_t encryptAlgorithm;
|
||||||
int32_t daysPerFile;
|
int32_t daysPerFile;
|
||||||
|
char encryptAlgorithmStr[TSDB_ENCRYPT_ALGO_STR_LEN];
|
||||||
SValueNode* pDaysPerFile;
|
SValueNode* pDaysPerFile;
|
||||||
int32_t fsyncPeriod;
|
int32_t fsyncPeriod;
|
||||||
int32_t maxRowsPerBlock;
|
int32_t maxRowsPerBlock;
|
||||||
|
|
|
@ -152,7 +152,8 @@ int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsS
|
||||||
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
||||||
char* msgBuf, int32_t msgBufLen);
|
char* msgBuf, int32_t msgBufLen);
|
||||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
|
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
|
||||||
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD *fields, int numFields, bool needChangeLength);
|
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD *fields,
|
||||||
|
int numFields, bool needChangeLength, char* errstr, int32_t errstrLen);
|
||||||
|
|
||||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||||
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <time.h>
|
||||||
|
#ifndef _SM4_H_
|
||||||
|
#define _SM4_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int SM4_ECB_Encrypt( unsigned char *pKey,
|
||||||
|
unsigned int KeyLen,
|
||||||
|
unsigned char *pInData,
|
||||||
|
unsigned int inDataLen,
|
||||||
|
unsigned char *pOutData,
|
||||||
|
unsigned int *pOutDataLen);
|
||||||
|
|
||||||
|
int SM4_ECB_Decrypt( unsigned char *pKey,
|
||||||
|
unsigned int KeyLen,
|
||||||
|
unsigned char *pInData,
|
||||||
|
unsigned int inDataLen,
|
||||||
|
unsigned char *pOutData,
|
||||||
|
unsigned int *pOutDataLen);
|
||||||
|
|
||||||
|
int SM4_CBC_Encrypt( unsigned char *pKey,
|
||||||
|
unsigned int KeyLen,
|
||||||
|
unsigned char *pIV,
|
||||||
|
unsigned int ivLen,
|
||||||
|
unsigned char *pInData,
|
||||||
|
unsigned int inDataLen,
|
||||||
|
unsigned char *pOutData,
|
||||||
|
unsigned int *pOutDataLen);
|
||||||
|
|
||||||
|
int SM4_CBC_Decrypt(unsigned char *pKey,
|
||||||
|
unsigned int KeyLen,
|
||||||
|
unsigned char *pIV,
|
||||||
|
unsigned int ivLen,
|
||||||
|
unsigned char *pInData,
|
||||||
|
unsigned int inDataLen,
|
||||||
|
unsigned char *pOutData,
|
||||||
|
unsigned int *pOutDataLen);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _SM4_H_
|
|
@ -384,8 +384,8 @@ typedef struct SSinkRecorder {
|
||||||
|
|
||||||
typedef struct STaskExecStatisInfo {
|
typedef struct STaskExecStatisInfo {
|
||||||
int64_t created;
|
int64_t created;
|
||||||
int64_t init;
|
int64_t checkTs;
|
||||||
int64_t start;
|
int64_t readyTs;
|
||||||
int64_t startCheckpointId;
|
int64_t startCheckpointId;
|
||||||
int64_t startCheckpointVer;
|
int64_t startCheckpointVer;
|
||||||
|
|
||||||
|
@ -432,6 +432,22 @@ typedef struct SUpstreamInfo {
|
||||||
int32_t numOfClosed;
|
int32_t numOfClosed;
|
||||||
} SUpstreamInfo;
|
} SUpstreamInfo;
|
||||||
|
|
||||||
|
typedef struct SDownstreamStatusInfo {
|
||||||
|
int64_t reqId;
|
||||||
|
int32_t taskId;
|
||||||
|
int64_t rspTs;
|
||||||
|
int32_t status;
|
||||||
|
} SDownstreamStatusInfo;
|
||||||
|
|
||||||
|
typedef struct STaskCheckInfo {
|
||||||
|
SArray* pList;
|
||||||
|
int64_t startTs;
|
||||||
|
int32_t notReadyTasks;
|
||||||
|
int32_t inCheckProcess;
|
||||||
|
tmr_h checkRspTmr;
|
||||||
|
TdThreadMutex checkInfoLock;
|
||||||
|
} STaskCheckInfo;
|
||||||
|
|
||||||
struct SStreamTask {
|
struct SStreamTask {
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
SStreamTaskId id;
|
SStreamTaskId id;
|
||||||
|
@ -455,14 +471,12 @@ struct SStreamTask {
|
||||||
SStreamState* pState; // state backend
|
SStreamState* pState; // state backend
|
||||||
SArray* pRspMsgList;
|
SArray* pRspMsgList;
|
||||||
SUpstreamInfo upstreamInfo;
|
SUpstreamInfo upstreamInfo;
|
||||||
|
STaskCheckInfo taskCheckInfo;
|
||||||
|
|
||||||
// the followings attributes don't be serialized
|
// the followings attributes don't be serialized
|
||||||
SScanhistorySchedInfo schedHistoryInfo;
|
SScanhistorySchedInfo schedHistoryInfo;
|
||||||
|
|
||||||
int32_t notReadyTasks;
|
|
||||||
int32_t numOfWaitingUpstream;
|
int32_t numOfWaitingUpstream;
|
||||||
int64_t checkReqId;
|
|
||||||
SArray* checkReqIds; // shuffle
|
|
||||||
int32_t refCnt;
|
int32_t refCnt;
|
||||||
int32_t transferStateAlignCnt;
|
int32_t transferStateAlignCnt;
|
||||||
struct SStreamMeta* pMeta;
|
struct SStreamMeta* pMeta;
|
||||||
|
@ -478,7 +492,7 @@ typedef struct STaskStartInfo {
|
||||||
int64_t startTs;
|
int64_t startTs;
|
||||||
int64_t readyTs;
|
int64_t readyTs;
|
||||||
int32_t tasksWillRestart;
|
int32_t tasksWillRestart;
|
||||||
int32_t taskStarting; // restart flag, sentinel to guard the restart procedure.
|
int32_t startAllTasks; // restart flag, sentinel to guard the restart procedure.
|
||||||
SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing
|
SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing
|
||||||
SHashObj* pFailedTaskSet; // tasks that are done the check downstream process, may be successful or failed
|
SHashObj* pFailedTaskSet; // tasks that are done the check downstream process, may be successful or failed
|
||||||
int64_t elapsedTime;
|
int64_t elapsedTime;
|
||||||
|
@ -821,8 +835,6 @@ void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||||
void streamTaskResume(SStreamTask* pTask);
|
void streamTaskResume(SStreamTask* pTask);
|
||||||
int32_t streamTaskStop(SStreamTask* pTask);
|
int32_t streamTaskStop(SStreamTask* pTask);
|
||||||
int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask);
|
int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask);
|
||||||
void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet);
|
|
||||||
void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet);
|
|
||||||
void streamTaskSetFixedDownstreamInfo(SStreamTask* pTask, const SStreamTask* pDownstreamTask);
|
void streamTaskSetFixedDownstreamInfo(SStreamTask* pTask, const SStreamTask* pDownstreamTask);
|
||||||
int32_t streamTaskReleaseState(SStreamTask* pTask);
|
int32_t streamTaskReleaseState(SStreamTask* pTask);
|
||||||
int32_t streamTaskReloadState(SStreamTask* pTask);
|
int32_t streamTaskReloadState(SStreamTask* pTask);
|
||||||
|
@ -832,6 +844,15 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key);
|
||||||
bool streamTaskIsSinkTask(const SStreamTask* pTask);
|
bool streamTaskIsSinkTask(const SStreamTask* pTask);
|
||||||
int32_t streamTaskSendCheckpointReq(SStreamTask* pTask);
|
int32_t streamTaskSendCheckpointReq(SStreamTask* pTask);
|
||||||
|
|
||||||
|
int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs);
|
||||||
|
int32_t streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, const char* id);
|
||||||
|
int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs, int64_t reqId,
|
||||||
|
int32_t* pNotReady, const char* id);
|
||||||
|
void streamTaskCleanCheckInfo(STaskCheckInfo* pInfo);
|
||||||
|
int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id);
|
||||||
|
int32_t streamTaskCompleteCheck(STaskCheckInfo* pInfo, const char* id);
|
||||||
|
int32_t streamTaskStartMonitorCheckRsp(SStreamTask* pTask);
|
||||||
|
|
||||||
void streamTaskStatusInit(STaskStatusEntry* pEntry, const SStreamTask* pTask);
|
void streamTaskStatusInit(STaskStatusEntry* pEntry, const SStreamTask* pTask);
|
||||||
void streamTaskStatusCopy(STaskStatusEntry* pDst, const STaskStatusEntry* pSrc);
|
void streamTaskStatusCopy(STaskStatusEntry* pDst, const STaskStatusEntry* pSrc);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ typedef struct {
|
||||||
int64_t retentionSize;
|
int64_t retentionSize;
|
||||||
int64_t segSize;
|
int64_t segSize;
|
||||||
EWalType level; // wal level
|
EWalType level; // wal level
|
||||||
|
int32_t encryptAlgorithm;
|
||||||
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
} SWalCfg;
|
} SWalCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -196,6 +198,7 @@ SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id);
|
||||||
void walCloseReader(SWalReader *pRead);
|
void walCloseReader(SWalReader *pRead);
|
||||||
void walReadReset(SWalReader *pReader);
|
void walReadReset(SWalReader *pReader);
|
||||||
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
||||||
|
void decryptBody(SWalCfg* cfg, SWalCkHead* pHead, int32_t plainBodyLen, const char* func);
|
||||||
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
||||||
int32_t walNextValidMsg(SWalReader *pRead);
|
int32_t walNextValidMsg(SWalReader *pRead);
|
||||||
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
||||||
|
|
|
@ -22,6 +22,8 @@ extern "C" {
|
||||||
|
|
||||||
typedef wchar_t TdWchar;
|
typedef wchar_t TdWchar;
|
||||||
typedef int32_t TdUcs4;
|
typedef int32_t TdUcs4;
|
||||||
|
typedef void *iconv_t;
|
||||||
|
typedef enum { M2C = 0, C2M } ConvType;
|
||||||
|
|
||||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
// 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.
|
// When you want to use this feature, you should find or add the same function in the following section.
|
||||||
|
@ -59,7 +61,10 @@ int64_t taosStr2int64(const char *str);
|
||||||
|
|
||||||
int32_t taosConvInit(void);
|
int32_t taosConvInit(void);
|
||||||
void taosConvDestroy();
|
void taosConvDestroy();
|
||||||
|
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
||||||
|
void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type);
|
||||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
||||||
|
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);
|
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||||
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||||
|
|
|
@ -33,8 +33,16 @@ extern "C" {
|
||||||
const char* tstrerror(int32_t err);
|
const char* tstrerror(int32_t err);
|
||||||
const char* terrstr();
|
const char* terrstr();
|
||||||
|
|
||||||
|
#define ERR_MSG_LEN 256
|
||||||
|
|
||||||
|
char* taosGetErrMsgReturn();
|
||||||
|
char* taosGetErrMsg();
|
||||||
int32_t* taosGetErrno();
|
int32_t* taosGetErrno();
|
||||||
#define terrno (*taosGetErrno())
|
#define terrno (*taosGetErrno())
|
||||||
|
#define terrMsg (taosGetErrMsg())
|
||||||
|
|
||||||
|
#define SET_ERROR_MSG(MSG, ...) \
|
||||||
|
snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define TSDB_CODE_SUCCESS 0
|
#define TSDB_CODE_SUCCESS 0
|
||||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||||
|
@ -306,6 +314,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
#define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) //
|
||||||
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
#define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B)
|
||||||
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C)
|
||||||
|
#define TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038D)
|
||||||
|
#define TSDB_CODE_MND_INVALID_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x038E)
|
||||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
// #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
// #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x
|
||||||
// #define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) // 2.x
|
// #define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) // 2.x
|
||||||
|
@ -314,6 +324,7 @@ int32_t* taosGetErrno();
|
||||||
// #define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0395) // 2.x
|
// #define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0395) // 2.x
|
||||||
#define TSDB_CODE_MND_DB_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x0396) //
|
#define TSDB_CODE_MND_DB_IN_CREATING TAOS_DEF_ERROR_CODE(0, 0x0396) //
|
||||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A)
|
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x039A)
|
||||||
|
#define TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE TAOS_DEF_ERROR_CODE(0, 0x039B)
|
||||||
|
|
||||||
// mnode-node
|
// mnode-node
|
||||||
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
|
||||||
|
@ -421,6 +432,17 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal
|
#define TSDB_CODE_MNODE_NO_NEED_RESTORE TAOS_DEF_ERROR_CODE(0, 0x0415) // internal
|
||||||
#define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416)
|
#define TSDB_CODE_DNODE_ONLY_USE_WHEN_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0416)
|
||||||
#define TSDB_CODE_DNODE_NO_MACHINE_CODE TAOS_DEF_ERROR_CODE(0, 0x0417)
|
#define TSDB_CODE_DNODE_NO_MACHINE_CODE TAOS_DEF_ERROR_CODE(0, 0x0417)
|
||||||
|
#define TSDB_CODE_DNODE_NO_ENCRYPT_KEY TAOS_DEF_ERROR_CODE(0, 0x0418)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0419)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_ENCRYPTKEY TAOS_DEF_ERROR_CODE(0, 0x0420)
|
||||||
|
#define TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0421)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_ENCRYPT_KLEN TAOS_DEF_ERROR_CODE(0, 0x0422)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_STATUS_INTERVAL TAOS_DEF_ERROR_CODE(0, 0x0423)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_TIMEZONE TAOS_DEF_ERROR_CODE(0, 0x0424)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_CHARSET TAOS_DEF_ERROR_CODE(0, 0x0425)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_LOCALE TAOS_DEF_ERROR_CODE(0, 0x0426)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR TAOS_DEF_ERROR_CODE(0, 0x0427)
|
||||||
|
#define TSDB_CODE_DNODE_INVALID_EN_WHITELIST TAOS_DEF_ERROR_CODE(0, 0x0428)
|
||||||
|
|
||||||
// mnode-sma
|
// mnode-sma
|
||||||
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
|
||||||
|
|
|
@ -188,6 +188,10 @@ typedef enum ELogicConditionType {
|
||||||
LOGIC_COND_TYPE_NOT,
|
LOGIC_COND_TYPE_NOT,
|
||||||
} ELogicConditionType;
|
} ELogicConditionType;
|
||||||
|
|
||||||
|
#define ENCRYPTED_LEN(len) (len/16) * 16 + (len%16?1:0) * 16
|
||||||
|
#define ENCRYPT_KEY_LEN 16
|
||||||
|
#define ENCRYPT_KEY_LEN_MIN 8
|
||||||
|
|
||||||
#define TSDB_INT32_ID_LEN 11
|
#define TSDB_INT32_ID_LEN 11
|
||||||
|
|
||||||
#define TSDB_NAME_DELIMITER_LEN 1
|
#define TSDB_NAME_DELIMITER_LEN 1
|
||||||
|
@ -388,6 +392,14 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_CACHE_MODEL_LAST_ROW 1
|
#define TSDB_CACHE_MODEL_LAST_ROW 1
|
||||||
#define TSDB_CACHE_MODEL_LAST_VALUE 2
|
#define TSDB_CACHE_MODEL_LAST_VALUE 2
|
||||||
#define TSDB_CACHE_MODEL_BOTH 3
|
#define TSDB_CACHE_MODEL_BOTH 3
|
||||||
|
#define TSDB_ENCRYPT_ALGO_STR_LEN 16
|
||||||
|
#define TSDB_ENCRYPT_ALGO_NONE_STR "none"
|
||||||
|
#define TSDB_ENCRYPT_ALGO_SM4_STR "sm4"
|
||||||
|
#define TSDB_ENCRYPT_ALGO_NONE 0
|
||||||
|
#define TSDB_ENCRYPT_ALGO_SM4 1
|
||||||
|
#define TSDB_DEFAULT_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_NONE
|
||||||
|
#define TSDB_MIN_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_NONE
|
||||||
|
#define TSDB_MAX_ENCRYPT_ALGO TSDB_ENCRYPT_ALGO_SM4
|
||||||
#define TSDB_DEFAULT_CACHE_MODEL TSDB_CACHE_MODEL_NONE
|
#define TSDB_DEFAULT_CACHE_MODEL TSDB_CACHE_MODEL_NONE
|
||||||
#define TSDB_MIN_DB_CACHE_SIZE 1 // MB
|
#define TSDB_MIN_DB_CACHE_SIZE 1 // MB
|
||||||
#define TSDB_MAX_DB_CACHE_SIZE 65536
|
#define TSDB_MAX_DB_CACHE_SIZE 65536
|
||||||
|
@ -523,6 +535,7 @@ typedef enum ELogicConditionType {
|
||||||
|
|
||||||
enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED };
|
enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED };
|
||||||
enum { TRANS_OPER_INIT = 0, TRANS_OPER_EXECUTE, TRANS_OPER_ROLLBACK };
|
enum { TRANS_OPER_INIT = 0, TRANS_OPER_EXECUTE, TRANS_OPER_ROLLBACK };
|
||||||
|
enum { ENCRYPT_KEY_STAT_UNKNOWN = 0, ENCRYPT_KEY_STAT_UNSET, ENCRYPT_KEY_STAT_SET, ENCRYPT_KEY_STAT_LOADED};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
|
|
@ -221,7 +221,11 @@ typedef struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
int32_t resIter;
|
int32_t resIter;
|
||||||
SReqResultInfo resInfo;
|
SReqResultInfo resInfo;
|
||||||
SMqDataRsp rsp;
|
} SMqRspObjCommon;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMqRspObjCommon common;
|
||||||
|
SMqDataRsp rsp;
|
||||||
} SMqRspObj;
|
} SMqRspObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -233,14 +237,8 @@ typedef struct {
|
||||||
} SMqMetaRspObj;
|
} SMqMetaRspObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t resType;
|
SMqRspObjCommon common;
|
||||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
STaosxRsp rsp;
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
|
||||||
int32_t vgId;
|
|
||||||
SSchemaWrapper schema;
|
|
||||||
int32_t resIter;
|
|
||||||
SReqResultInfo resInfo;
|
|
||||||
STaosxRsp rsp;
|
|
||||||
} SMqTaosxRspObj;
|
} SMqTaosxRspObj;
|
||||||
|
|
||||||
typedef struct SReqRelInfo {
|
typedef struct SReqRelInfo {
|
||||||
|
@ -320,7 +318,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
||||||
|
|
||||||
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
||||||
SMqRspObj* msg = (SMqRspObj*)res;
|
SMqRspObj* msg = (SMqRspObj*)res;
|
||||||
return (SReqResultInfo*)&msg->resInfo;
|
return (SReqResultInfo*)&msg->common.resInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4);
|
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4);
|
||||||
|
|
|
@ -1804,6 +1804,10 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) {
|
static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) {
|
||||||
|
int32_t idx = -1;
|
||||||
|
iconv_t conv = taosAcquireConv(&idx, C2M);
|
||||||
|
if (!conv) return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int32_t type = pResultInfo->fields[i].type;
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
@ -1811,6 +1815,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
if (type == TSDB_DATA_TYPE_NCHAR && colLength[i] > 0) {
|
if (type == TSDB_DATA_TYPE_NCHAR && colLength[i] > 0) {
|
||||||
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
taosReleaseConv(idx, conv, C2M);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1821,12 +1826,13 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
if (pCol->offset[j] != -1) {
|
if (pCol->offset[j] != -1) {
|
||||||
char* pStart = pCol->offset[j] + pCol->pData;
|
char* pStart = pCol->offset[j] + pCol->pData;
|
||||||
|
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
int32_t len = taosUcs4ToMbsEx((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p), conv);
|
||||||
if (len > bytes || (p + len) >= (pResultInfo->convertBuf[i] + colLength[i])) {
|
if (len < 0 || len > bytes || (p + len) >= (pResultInfo->convertBuf[i] + colLength[i])) {
|
||||||
tscError(
|
tscError(
|
||||||
"doConvertUCS4 error, invalid data. len:%d, bytes:%d, (p + len):%p, (pResultInfo->convertBuf[i] + "
|
"doConvertUCS4 error, invalid data. len:%d, bytes:%d, (p + len):%p, (pResultInfo->convertBuf[i] + "
|
||||||
"colLength[i]):%p",
|
"colLength[i]):%p",
|
||||||
len, bytes, (p + len), (pResultInfo->convertBuf[i] + colLength[i]));
|
len, bytes, (p + len), (pResultInfo->convertBuf[i] + colLength[i]));
|
||||||
|
taosReleaseConv(idx, conv, C2M);
|
||||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1840,7 +1846,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
|
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taosReleaseConv(idx, conv, C2M);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2620,8 +2626,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
||||||
setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4);
|
setQueryResultFromRsp(pResultInfo, (const SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4);
|
||||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
pRequest->code = code;
|
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(pRequest->code),
|
||||||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
|
||||||
pRequest->requestId);
|
pRequest->requestId);
|
||||||
} else {
|
} else {
|
||||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||||
|
|
|
@ -343,12 +343,12 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res;
|
||||||
tDeleteSTaosxRsp(&pRsp->rsp);
|
tDeleteSTaosxRsp(&pRsp->rsp);
|
||||||
doFreeReqResultInfo(&pRsp->resInfo);
|
doFreeReqResultInfo(&pRsp->common.resInfo);
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
} else if (TD_RES_TMQ(res)) {
|
} else if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj *pRsp = (SMqRspObj *)res;
|
SMqRspObj *pRsp = (SMqRspObj *)res;
|
||||||
tDeleteMqDataRsp(&pRsp->rsp);
|
tDeleteMqDataRsp(&pRsp->rsp);
|
||||||
doFreeReqResultInfo(&pRsp->resInfo);
|
doFreeReqResultInfo(&pRsp->common.resInfo);
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res;
|
SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res;
|
||||||
|
@ -417,7 +417,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||||
SReqResultInfo *pResultInfo;
|
SReqResultInfo *pResultInfo;
|
||||||
if (msg->resIter == -1) {
|
if (msg->common.resIter == -1) {
|
||||||
pResultInfo = tmqGetNextResInfo(res, true);
|
pResultInfo = tmqGetNextResInfo(res, true);
|
||||||
} else {
|
} else {
|
||||||
pResultInfo = tmqGetCurResInfo(res);
|
pResultInfo = tmqGetCurResInfo(res);
|
||||||
|
|
|
@ -1486,7 +1486,7 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pDat
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
||||||
|
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false);
|
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false, NULL, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1570,7 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
|
||||||
|
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false);
|
code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false, NULL, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1608,6 +1608,7 @@ static void* getRawDataFromRes(void* pRetrieve) {
|
||||||
static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
if (taos == NULL || data == NULL) {
|
if (taos == NULL || data == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
SET_ERROR_MSG("taos:%p or data:%p is NULL", taos, data);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -1620,17 +1621,24 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||||
if (!pRequest) {
|
if (!pRequest) {
|
||||||
|
SET_ERROR_MSG("pRequest is NULL");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||||
pRequest->syncQuery = true;
|
pRequest->syncQuery = true;
|
||||||
rspObj.resIter = -1;
|
rspObj.common.resIter = -1;
|
||||||
rspObj.resType = RES_TYPE__TMQ;
|
rspObj.common.resType = RES_TYPE__TMQ;
|
||||||
|
|
||||||
|
int8_t dataVersion = *(int8_t*)data;
|
||||||
|
if (dataVersion >= MQ_DATA_RSP_VERSION){
|
||||||
|
data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t));
|
||||||
|
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
||||||
|
}
|
||||||
tDecoderInit(&decoder, data, dataLen);
|
tDecoderInit(&decoder, data, dataLen);
|
||||||
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp, *(int8_t*)data);
|
code = tDecodeMqDataRsp(&decoder, &rspObj.rsp);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
SET_ERROR_MSG("decode mq data rsp failed");
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1643,6 +1651,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get handle failed");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,17 +1664,19 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
pQuery = smlInitHandle();
|
pQuery = smlInitHandle();
|
||||||
if (pQuery == NULL) {
|
if (pQuery == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
SET_ERROR_MSG("init sml handle failed");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.common.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter);
|
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
||||||
if (!tbName) {
|
if (!tbName) {
|
||||||
|
SET_ERROR_MSG("block tbname is null");
|
||||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1681,12 +1692,14 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get table:%s meta failed", tbName);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVgroupInfo vg;
|
SVgroupInfo vg;
|
||||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get table:%s vgroup failed", tbName);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1695,9 +1708,11 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||||
if (fields == NULL) {
|
if (fields == NULL) {
|
||||||
|
SET_ERROR_MSG("calloc fields failed");
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
|
@ -1706,16 +1721,18 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||||
}
|
}
|
||||||
void* rawData = getRawDataFromRes(pRetrieve);
|
void* rawData = getRawDataFromRes(pRetrieve);
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, NULL, fields, pSW->nCols, true);
|
char err[ERR_MSG_LEN] = {0};
|
||||||
|
code = rawBlockBindData(pQuery, pTableMeta, rawData, NULL, fields, pSW->nCols, true, err, ERR_MSG_LEN);
|
||||||
taosMemoryFree(fields);
|
taosMemoryFree(fields);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("table:%s, err:%s", tbName, err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pTableMeta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = smlBuildOutput(pQuery, pVgHash);
|
code = smlBuildOutput(pQuery, pVgHash);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("sml build output failed");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1737,6 +1754,7 @@ end:
|
||||||
static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
if (taos == NULL || data == NULL) {
|
if (taos == NULL || data == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
SET_ERROR_MSG("taos:%p or data:%p is NULL", taos, data);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -1750,16 +1768,24 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||||
if (!pRequest) {
|
if (!pRequest) {
|
||||||
|
SET_ERROR_MSG("pRequest is NULL");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||||
pRequest->syncQuery = true;
|
pRequest->syncQuery = true;
|
||||||
rspObj.resIter = -1;
|
rspObj.common.resIter = -1;
|
||||||
rspObj.resType = RES_TYPE__TMQ_METADATA;
|
rspObj.common.resType = RES_TYPE__TMQ_METADATA;
|
||||||
|
|
||||||
|
int8_t dataVersion = *(int8_t*)data;
|
||||||
|
if (dataVersion >= MQ_DATA_RSP_VERSION){
|
||||||
|
data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t));
|
||||||
|
dataLen -= sizeof(int8_t) + sizeof(int32_t);
|
||||||
|
}
|
||||||
|
|
||||||
tDecoderInit(&decoder, data, dataLen);
|
tDecoderInit(&decoder, data, dataLen);
|
||||||
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp, *(int8_t*)data);
|
code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
SET_ERROR_MSG("decode mq taosx data rsp failed");
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1772,6 +1798,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get handle failed");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1783,20 +1810,22 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
|
|
||||||
pQuery = smlInitHandle();
|
pQuery = smlInitHandle();
|
||||||
if (pQuery == NULL) {
|
if (pQuery == NULL) {
|
||||||
|
SET_ERROR_MSG("init sml handle failed");
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum);
|
uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.common.blockNum);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.common.resIter < rspObj.rsp.common.blockNum) {
|
||||||
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.rsp.common.blockData, rspObj.common.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.common.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter);
|
const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.common.blockTbName, rspObj.common.resIter);
|
||||||
if (!tbName) {
|
if (!tbName) {
|
||||||
|
SET_ERROR_MSG("block tbname is null");
|
||||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1818,6 +1847,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
tDecoderClear(&decoderTmp);
|
tDecoderClear(&decoderTmp);
|
||||||
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
||||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||||
|
SET_ERROR_MSG("decode create table:%s req failed", tbName);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,6 +1855,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
code = TSDB_CODE_TSC_INVALID_VALUE;
|
code = TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
tDecoderClear(&decoderTmp);
|
tDecoderClear(&decoderTmp);
|
||||||
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE);
|
||||||
|
SET_ERROR_MSG("create table req type is not child table: %s, type: %d", tbName, pCreateReq.type);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (strcmp(tbName, pCreateReq.name) == 0) {
|
if (strcmp(tbName, pCreateReq.name) == 0) {
|
||||||
|
@ -1841,6 +1872,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
SVgroupInfo vg;
|
SVgroupInfo vg;
|
||||||
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get table:%s vgroup failed", tbName);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1854,6 +1886,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("cata log get table:%s meta failed", tbName);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1867,9 +1900,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.common.blockSchema, rspObj.common.resIter);
|
||||||
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
|
||||||
if (fields == NULL) {
|
if (fields == NULL) {
|
||||||
|
SET_ERROR_MSG("calloc fields failed");
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
|
@ -1878,12 +1913,13 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||||
}
|
}
|
||||||
void* rawData = getRawDataFromRes(pRetrieve);
|
void* rawData = getRawDataFromRes(pRetrieve);
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true);
|
char err[ERR_MSG_LEN] = {0};
|
||||||
|
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true, err, ERR_MSG_LEN);
|
||||||
taosMemoryFree(fields);
|
taosMemoryFree(fields);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SET_ERROR_MSG("table:%s, err:%s", tbName, err);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(pTableMeta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code = smlBuildOutput(pQuery, pVgHash);
|
code = smlBuildOutput(pQuery, pVgHash);
|
||||||
|
@ -1946,6 +1982,64 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
||||||
|
|
||||||
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); }
|
||||||
|
|
||||||
|
static int32_t getOffSetLen(const void *rsp){
|
||||||
|
const SMqDataRspCommon *pRsp = rsp;
|
||||||
|
SEncoder coder = {0};
|
||||||
|
tEncoderInit(&coder, NULL, 0);
|
||||||
|
if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1;
|
||||||
|
if (tEncodeSTqOffsetVal(&coder, &pRsp->rspOffset) < 0) return -1;
|
||||||
|
int32_t pos = coder.pos;
|
||||||
|
tEncoderClear(&coder);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef int32_t __encode_func__(SEncoder *pEncoder, const void *pRsp);
|
||||||
|
|
||||||
|
static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw){
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t code = 0;
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
void* buf = NULL;
|
||||||
|
tEncodeSize(encodeFunc, rspObj, len, code);
|
||||||
|
if (code < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
len += sizeof(int8_t) + sizeof(int32_t);
|
||||||
|
buf = taosMemoryCalloc(1, len);
|
||||||
|
if(buf == NULL){
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
tEncoderInit(&encoder, buf, len);
|
||||||
|
if (tEncodeI8(&encoder, MQ_DATA_RSP_VERSION) < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
int32_t offsetLen = getOffSetLen(rspObj);
|
||||||
|
if(offsetLen <= 0){
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
if (tEncodeI32(&encoder, offsetLen) < 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
if(encodeFunc(&encoder, rspObj) < 0){
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto FAILED;
|
||||||
|
}
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
|
raw->raw = buf;
|
||||||
|
raw->raw_len = len;
|
||||||
|
return 0;
|
||||||
|
FAILED:
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||||
if (!raw || !res) {
|
if (!raw || !res) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -1959,42 +2053,19 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) {
|
||||||
uDebug("tmq get raw type meta:%p", raw);
|
uDebug("tmq get raw type meta:%p", raw);
|
||||||
} else if (TD_RES_TMQ(res)) {
|
} else if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
SMqRspObj* rspObj = ((SMqRspObj*)res);
|
||||||
|
if(encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw) != 0){
|
||||||
int32_t len = 0;
|
uError("tmq get raw type error:%d", terrno);
|
||||||
int32_t code = 0;
|
return terrno;
|
||||||
tEncodeSize(tEncodeMqDataRsp, &rspObj->rsp, len, code);
|
|
||||||
if (code < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = taosMemoryCalloc(1, len);
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, buf, len);
|
|
||||||
tEncodeMqDataRsp(&encoder, &rspObj->rsp);
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
|
|
||||||
raw->raw = buf;
|
|
||||||
raw->raw_len = len;
|
|
||||||
raw->raw_type = RES_TYPE__TMQ;
|
raw->raw_type = RES_TYPE__TMQ;
|
||||||
uDebug("tmq get raw type data:%p", raw);
|
uDebug("tmq get raw type data:%p", raw);
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res);
|
SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res);
|
||||||
|
|
||||||
int32_t len = 0;
|
if(encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw) != 0){
|
||||||
int32_t code = 0;
|
uError("tmq get raw type error:%d", terrno);
|
||||||
tEncodeSize(tEncodeSTaosxRsp, &rspObj->rsp, len, code);
|
return terrno;
|
||||||
if (code < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = taosMemoryCalloc(1, len);
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, buf, len);
|
|
||||||
tEncodeSTaosxRsp(&encoder, &rspObj->rsp);
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
|
|
||||||
raw->raw = buf;
|
|
||||||
raw->raw_len = len;
|
|
||||||
raw->raw_type = RES_TYPE__TMQ_METADATA;
|
raw->raw_type = RES_TYPE__TMQ_METADATA;
|
||||||
uDebug("tmq get raw type metadata:%p", raw);
|
uDebug("tmq get raw type metadata:%p", raw);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2010,6 +2081,7 @@ void tmq_free_raw(tmq_raw_data raw) {
|
||||||
if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) {
|
if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) {
|
||||||
taosMemoryFree(raw.raw);
|
taosMemoryFree(raw.raw);
|
||||||
}
|
}
|
||||||
|
memset(terrMsg, 0, ERR_MSG_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) {
|
int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) {
|
||||||
|
|
|
@ -622,9 +622,9 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c
|
||||||
|
|
||||||
if (TD_RES_TMQ(pRes)) {
|
if (TD_RES_TMQ(pRes)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)pRes;
|
SMqRspObj* pRspObj = (SMqRspObj*)pRes;
|
||||||
pTopicName = pRspObj->topic;
|
pTopicName = pRspObj->common.topic;
|
||||||
vgId = pRspObj->vgId;
|
vgId = pRspObj->common.vgId;
|
||||||
offsetVal = pRspObj->rsp.rspOffset;
|
offsetVal = pRspObj->rsp.common.rspOffset;
|
||||||
} else if (TD_RES_TMQ_META(pRes)) {
|
} else if (TD_RES_TMQ_META(pRes)) {
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)pRes;
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)pRes;
|
||||||
pTopicName = pMetaRspObj->topic;
|
pTopicName = pMetaRspObj->topic;
|
||||||
|
@ -632,9 +632,9 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c
|
||||||
offsetVal = pMetaRspObj->metaRsp.rspOffset;
|
offsetVal = pMetaRspObj->metaRsp.rspOffset;
|
||||||
} else if (TD_RES_TMQ_METADATA(pRes)) {
|
} else if (TD_RES_TMQ_METADATA(pRes)) {
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)pRes;
|
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)pRes;
|
||||||
pTopicName = pRspObj->topic;
|
pTopicName = pRspObj->common.topic;
|
||||||
vgId = pRspObj->vgId;
|
vgId = pRspObj->common.vgId;
|
||||||
offsetVal = pRspObj->rsp.rspOffset;
|
offsetVal = pRspObj->rsp.common.rspOffset;
|
||||||
} else {
|
} else {
|
||||||
code = TSDB_CODE_TMQ_INVALID_MSG;
|
code = TSDB_CODE_TMQ_INVALID_MSG;
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1056,17 +1056,17 @@ static void tmqMgmtInit(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_ERROR_MSG(MSG) \
|
#define SET_ERROR_MSG_TMQ(MSG) \
|
||||||
if (errstr != NULL) snprintf(errstr, errstrLen, MSG);
|
if (errstr != NULL) snprintf(errstr, errstrLen, MSG);
|
||||||
tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
SET_ERROR_MSG("configure is null")
|
SET_ERROR_MSG_TMQ("configure is null")
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosThreadOnce(&tmqInit, tmqMgmtInit);
|
taosThreadOnce(&tmqInit, tmqMgmtInit);
|
||||||
if (tmqInitRes != 0) {
|
if (tmqInitRes != 0) {
|
||||||
terrno = tmqInitRes;
|
terrno = tmqInitRes;
|
||||||
SET_ERROR_MSG("tmq timer init error")
|
SET_ERROR_MSG_TMQ("tmq timer init error")
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1074,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
if (pTmq == NULL) {
|
if (pTmq == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tscError("failed to create consumer, groupId:%s, code:%s", conf->groupId, terrstr());
|
tscError("failed to create consumer, groupId:%s, code:%s", conf->groupId, terrstr());
|
||||||
SET_ERROR_MSG("malloc tmq failed")
|
SET_ERROR_MSG_TMQ("malloc tmq failed")
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,7 +1090,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
conf->groupId[0] == 0) {
|
conf->groupId[0] == 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||||
SET_ERROR_MSG("malloc tmq element failed or group is empty")
|
SET_ERROR_MSG_TMQ("malloc tmq element failed or group is empty")
|
||||||
goto _failed;
|
goto _failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,7 +1123,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
if (tsem_init(&pTmq->rspSem, 0, 0) != 0) {
|
if (tsem_init(&pTmq->rspSem, 0, 0) != 0) {
|
||||||
tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(),
|
||||||
pTmq->groupId);
|
pTmq->groupId);
|
||||||
SET_ERROR_MSG("init t_sem failed")
|
SET_ERROR_MSG_TMQ("init t_sem failed")
|
||||||
goto _failed;
|
goto _failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,13 +1132,13 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
if (pTmq->pTscObj == NULL) {
|
if (pTmq->pTscObj == NULL) {
|
||||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||||
tsem_destroy(&pTmq->rspSem);
|
tsem_destroy(&pTmq->rspSem);
|
||||||
SET_ERROR_MSG("init tscObj failed")
|
SET_ERROR_MSG_TMQ("init tscObj failed")
|
||||||
goto _failed;
|
goto _failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTmq->refId = taosAddRef(tmqMgmt.rsetId, pTmq);
|
pTmq->refId = taosAddRef(tmqMgmt.rsetId, pTmq);
|
||||||
if (pTmq->refId < 0) {
|
if (pTmq->refId < 0) {
|
||||||
SET_ERROR_MSG("add tscObj ref failed")
|
SET_ERROR_MSG_TMQ("add tscObj ref failed")
|
||||||
goto _failed;
|
goto _failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,7 +1377,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
if (rspType == TMQ_MSG_TYPE__POLL_DATA_RSP) {
|
if (rspType == TMQ_MSG_TYPE__POLL_DATA_RSP) {
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||||
if(tDecodeMqDataRsp(&decoder, &pRspWrapper->dataRsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead))) < 0){
|
if(tDecodeMqDataRsp(&decoder, &pRspWrapper->dataRsp) < 0){
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
taosReleaseRef(tmqMgmt.rsetId, refId);
|
taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1387,9 +1387,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||||
|
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.rspOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.common.rspOffset);
|
||||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.reqOffset.version, buf, rspType, requestId);
|
tmq->consumerId, vgId, pRspWrapper->dataRsp.common.reqOffset.version, buf, rspType, requestId);
|
||||||
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
} else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) {
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||||
|
@ -1404,7 +1404,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
} else if (rspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
} else if (rspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||||
if(tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead))) < 0){
|
if(tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp) < 0){
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
taosReleaseRef(tmqMgmt.rsetId, refId);
|
taosReleaseRef(tmqMgmt.rsetId, refId);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1598,6 +1598,9 @@ void tmqBuildConsumeReqImpl(SMqPollReq* pReq, tmq_t* tmq, int64_t timeout, SMqCl
|
||||||
|
|
||||||
SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj));
|
SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj));
|
||||||
|
if(pRspObj == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
pRspObj->resType = RES_TYPE__TMQ_META;
|
pRspObj->resType = RES_TYPE__TMQ_META;
|
||||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||||
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||||
|
@ -1611,8 +1614,7 @@ SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||||
void changeByteEndian(char* pData){
|
void changeByteEndian(char* pData){
|
||||||
char* p = pData;
|
char* p = pData;
|
||||||
|
|
||||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length | version:
|
||||||
// version:
|
|
||||||
int32_t blockVersion = *(int32_t*)p;
|
int32_t blockVersion = *(int32_t*)p;
|
||||||
ASSERT(blockVersion == BLOCK_VERSION_1);
|
ASSERT(blockVersion == BLOCK_VERSION_1);
|
||||||
*(int32_t*)p = BLOCK_VERSION_2;
|
*(int32_t*)p = BLOCK_VERSION_2;
|
||||||
|
@ -1649,7 +1651,7 @@ static void tmqGetRawDataRowsPrecisionFromRes(void *pRetrieve, void** rawData, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObj* pRspObj) {
|
static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows, SMqRspObjCommon* pRspObj, SMqDataRspCommon* pDataRsp) {
|
||||||
(*numOfRows) = 0;
|
(*numOfRows) = 0;
|
||||||
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||||
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN);
|
||||||
|
@ -1660,14 +1662,14 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
||||||
pRspObj->resInfo.totalRows = 0;
|
pRspObj->resInfo.totalRows = 0;
|
||||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
|
||||||
bool needTransformSchema = !pRspObj->rsp.withSchema;
|
bool needTransformSchema = !pDataRsp->withSchema;
|
||||||
if (!pRspObj->rsp.withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
if (!pDataRsp->withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||||
pRspObj->rsp.withSchema = true;
|
pDataRsp->withSchema = true;
|
||||||
pRspObj->rsp.blockSchema = taosArrayInit(pRspObj->rsp.blockNum, sizeof(void*));
|
pDataRsp->blockSchema = taosArrayInit(pDataRsp->blockNum, sizeof(void*));
|
||||||
}
|
}
|
||||||
// extract the rows in this data packet
|
// extract the rows in this data packet
|
||||||
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
for (int32_t i = 0; i < pDataRsp->blockNum; ++i) {
|
||||||
void* pRetrieve = taosArrayGetP(pRspObj->rsp.blockData, i);
|
void* pRetrieve = taosArrayGetP(pDataRsp->blockData, i);
|
||||||
void* rawData = NULL;
|
void* rawData = NULL;
|
||||||
int64_t rows = 0;
|
int64_t rows = 0;
|
||||||
// deal with compatibility
|
// deal with compatibility
|
||||||
|
@ -1679,7 +1681,7 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
||||||
if (needTransformSchema) { //withSchema is false if subscribe subquery, true if subscribe db or stable
|
if (needTransformSchema) { //withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||||
SSchemaWrapper *schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema);
|
SSchemaWrapper *schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema);
|
||||||
if(schema){
|
if(schema){
|
||||||
taosArrayPush(pRspObj->rsp.blockSchema, &schema);
|
taosArrayPush(pDataRsp->blockSchema, &schema);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1687,18 +1689,24 @@ static void tmqBuildRspFromWrapperInner(SMqPollRspWrapper* pWrapper, SMqClientVg
|
||||||
|
|
||||||
SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
||||||
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj));
|
||||||
pRspObj->resType = RES_TYPE__TMQ;
|
if(pRspObj == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pRspObj->common.resType = RES_TYPE__TMQ;
|
||||||
memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp));
|
memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp));
|
||||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, pRspObj);
|
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||||
return pRspObj;
|
return pRspObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) {
|
||||||
SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj));
|
SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj));
|
||||||
pRspObj->resType = RES_TYPE__TMQ_METADATA;
|
if(pRspObj == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pRspObj->common.resType = RES_TYPE__TMQ_METADATA;
|
||||||
memcpy(&pRspObj->rsp, &pWrapper->taosxRsp, sizeof(STaosxRsp));
|
memcpy(&pRspObj->rsp, &pWrapper->taosxRsp, sizeof(STaosxRsp));
|
||||||
|
|
||||||
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, (SMqRspObj*)pRspObj);
|
tmqBuildRspFromWrapperInner(pWrapper, pVg, numOfRows, &pRspObj->common, &pRspObj->rsp.common);
|
||||||
return pRspObj;
|
return pRspObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1891,7 +1899,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
||||||
|
|
||||||
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||||
SMqDataRsp* pDataRsp = &pollRspWrapper->dataRsp;
|
SMqDataRspCommon* pDataRsp = (SMqDataRspCommon*)&pollRspWrapper->dataRsp;
|
||||||
|
|
||||||
if (pDataRsp->head.epoch == consumerEpoch) {
|
if (pDataRsp->head.epoch == consumerEpoch) {
|
||||||
taosWLockLatch(&tmq->lock);
|
taosWLockLatch(&tmq->lock);
|
||||||
|
@ -1994,8 +2002,9 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
} else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
} else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper;
|
||||||
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||||
|
SMqDataRspCommon* pDataRsp = (SMqDataRspCommon*)&pollRspWrapper->taosxRsp;
|
||||||
|
|
||||||
if (pollRspWrapper->taosxRsp.head.epoch == consumerEpoch) {
|
if (pDataRsp->head.epoch == consumerEpoch) {
|
||||||
taosWLockLatch(&tmq->lock);
|
taosWLockLatch(&tmq->lock);
|
||||||
SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||||
pollRspWrapper->vgHandle = pVg;
|
pollRspWrapper->vgHandle = pVg;
|
||||||
|
@ -2009,11 +2018,11 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset,
|
updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset,
|
||||||
pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId,
|
pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId,
|
||||||
pollRspWrapper->taosxRsp.blockNum != 0);
|
pDataRsp->blockNum != 0);
|
||||||
|
|
||||||
if (pollRspWrapper->taosxRsp.blockNum == 0) {
|
if (pDataRsp->blockNum == 0) {
|
||||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, pVg->vgId, pVg->numOfRows, pollRspWrapper->reqId);
|
tmq->consumerId, pVg->vgId, pVg->numOfRows, pollRspWrapper->reqId);
|
||||||
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
pVg->emptyBlockReceiveTs = taosGetTimestampMs();
|
||||||
|
@ -2034,7 +2043,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset);
|
||||||
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||||
tmq->consumerId, pVg->vgId, buf, pollRspWrapper->dataRsp.blockNum, numOfRows, pVg->numOfRows,
|
tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows,
|
||||||
tmq->totalRows, pollRspWrapper->reqId);
|
tmq->totalRows, pollRspWrapper->reqId);
|
||||||
|
|
||||||
taosFreeQitem(pRspWrapper);
|
taosFreeQitem(pRspWrapper);
|
||||||
|
@ -2042,7 +2051,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) {
|
||||||
return pRsp;
|
return pRsp;
|
||||||
} else {
|
} else {
|
||||||
tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d",
|
||||||
tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch);
|
tmq->consumerId, pollRspWrapper->vgId, pDataRsp->head.epoch, consumerEpoch);
|
||||||
setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId);
|
||||||
tmqFreeRspWrapper(pRspWrapper);
|
tmqFreeRspWrapper(pRspWrapper);
|
||||||
taosFreeQitem(pRspWrapper);
|
taosFreeQitem(pRspWrapper);
|
||||||
|
@ -2182,7 +2191,12 @@ const char* tmq_err2str(int32_t err) {
|
||||||
} else if (err == -1) {
|
} else if (err == -1) {
|
||||||
return "fail";
|
return "fail";
|
||||||
} else {
|
} else {
|
||||||
return tstrerror(err);
|
if(*(taosGetErrMsg()) == 0){
|
||||||
|
return tstrerror(err);
|
||||||
|
} else{
|
||||||
|
snprintf(taosGetErrMsgReturn(), ERR_MSG_LEN, "%s,detail:%s", tstrerror(err), taosGetErrMsg());
|
||||||
|
return (const char*)taosGetErrMsgReturn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2205,15 +2219,11 @@ const char* tmq_get_topic_name(TAOS_RES* res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
return strchr(((SMqRspObjCommon*)res)->topic, '.') + 1;
|
||||||
return strchr(pRspObj->topic, '.') + 1;
|
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
return strchr(pMetaRspObj->topic, '.') + 1;
|
return strchr(pMetaRspObj->topic, '.') + 1;
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
|
||||||
return strchr(pRspObj->topic, '.') + 1;
|
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2224,15 +2234,11 @@ const char* tmq_get_db_name(TAOS_RES* res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
return strchr(((SMqRspObjCommon*)res)->db, '.') + 1;
|
||||||
return strchr(pRspObj->db, '.') + 1;
|
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
return strchr(pMetaRspObj->db, '.') + 1;
|
return strchr(pMetaRspObj->db, '.') + 1;
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
|
||||||
return strchr(pRspObj->db, '.') + 1;
|
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2242,15 +2248,11 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
return ((SMqRspObjCommon*)res)->vgId;
|
||||||
return pRspObj->vgId;
|
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res;
|
||||||
return pMetaRspObj->vgId;
|
return pMetaRspObj->vgId;
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
|
||||||
return pRspObj->vgId;
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -2260,24 +2262,19 @@ int64_t tmq_get_vgroup_offset(TAOS_RES* res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||||
STqOffsetVal* pOffset = &pRspObj->rsp.reqOffset;
|
STqOffsetVal* pOffset = &common->reqOffset;
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (common->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||||
return pRspObj->rsp.reqOffset.version;
|
return common->reqOffset.version;
|
||||||
} else {
|
} else {
|
||||||
tscError("invalid offset type:%d", pOffset->type);
|
tscError("invalid offset type:%d", common->reqOffset.type);
|
||||||
}
|
}
|
||||||
} else if (TD_RES_TMQ_META(res)) {
|
} else if (TD_RES_TMQ_META(res)) {
|
||||||
SMqMetaRspObj* pRspObj = (SMqMetaRspObj*)res;
|
SMqMetaRspObj* pRspObj = (SMqMetaRspObj*)res;
|
||||||
if (pRspObj->metaRsp.rspOffset.type == TMQ_OFFSET__LOG) {
|
if (pRspObj->metaRsp.rspOffset.type == TMQ_OFFSET__LOG) {
|
||||||
return pRspObj->metaRsp.rspOffset.version;
|
return pRspObj->metaRsp.rspOffset.version;
|
||||||
}
|
}
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
|
||||||
if (pRspObj->rsp.reqOffset.type == TMQ_OFFSET__LOG) {
|
|
||||||
return pRspObj->rsp.reqOffset.version;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tscError("invalid tmq type:%d", *(int8_t*)res);
|
tscError("invalid tmq type:%d", *(int8_t*)res);
|
||||||
}
|
}
|
||||||
|
@ -2290,20 +2287,15 @@ const char* tmq_get_table_name(TAOS_RES* res) {
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||||
if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 ||
|
|
||||||
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
SMqRspObjCommon* pRspObj = (SMqRspObjCommon*)res;
|
||||||
|
if (!common->withTbName || common->blockTbName == NULL || pRspObj->resIter < 0 ||
|
||||||
|
pRspObj->resIter >= common->blockNum) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
return (const char*)taosArrayGetP(common->blockTbName, pRspObj->resIter);
|
||||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
|
||||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res;
|
|
||||||
if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 ||
|
|
||||||
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2640,17 +2632,17 @@ void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqDataRspCommon* common = (SMqDataRspCommon*)POINTER_SHIFT(res, sizeof(SMqRspObjCommon));
|
||||||
|
SMqRspObjCommon* pRspObj = (SMqRspObjCommon*)res;
|
||||||
pRspObj->resIter++;
|
pRspObj->resIter++;
|
||||||
|
if (pRspObj->resIter < common->blockNum) {
|
||||||
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
if (common->withSchema) {
|
||||||
if (pRspObj->rsp.withSchema) {
|
|
||||||
doFreeReqResultInfo(&pRspObj->resInfo);
|
doFreeReqResultInfo(&pRspObj->resInfo);
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(common->blockSchema, pRspObj->resIter);
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* pRetrieve = taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
void* pRetrieve = taosArrayGetP(common->blockData, pRspObj->resIter);
|
||||||
void* rawData = NULL;
|
void* rawData = NULL;
|
||||||
int64_t rows = 0;
|
int64_t rows = 0;
|
||||||
int32_t precision = 0;
|
int32_t precision = 0;
|
||||||
|
@ -2685,14 +2677,14 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
SMqDataRsp rsp;
|
SMqDataRsp rsp;
|
||||||
SDecoder decoder;
|
SDecoder decoder;
|
||||||
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead));
|
||||||
tDecodeMqDataRsp(&decoder, &rsp, *(int8_t*)POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)));
|
tDecodeMqDataRsp(&decoder, &rsp);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
SMqRspHead* pHead = pMsg->pData;
|
SMqRspHead* pHead = pMsg->pData;
|
||||||
|
|
||||||
tmq_topic_assignment assignment = {.begin = pHead->walsver,
|
tmq_topic_assignment assignment = {.begin = pHead->walsver,
|
||||||
.end = pHead->walever + 1,
|
.end = pHead->walever + 1,
|
||||||
.currentOffset = rsp.rspOffset.version,
|
.currentOffset = rsp.common.rspOffset.version,
|
||||||
.vgId = pParam->vgId};
|
.vgId = pParam->vgId};
|
||||||
|
|
||||||
taosThreadMutexLock(&pCommon->mutex);
|
taosThreadMutexLock(&pCommon->mutex);
|
||||||
|
|
|
@ -121,6 +121,7 @@ static const SSysDbTableSchema userDBSchema[] = {
|
||||||
{.name = "s3_keeplocal", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "s3_keeplocal", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
{.name = "s3_compact", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
{.name = "s3_compact", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||||
{.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
{.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||||
|
{.name = "encrypt_algorithm", .bytes = TSDB_ENCRYPT_ALGO_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userFuncSchema[] = {
|
static const SSysDbTableSchema userFuncSchema[] = {
|
||||||
|
@ -400,12 +401,15 @@ static const SSysDbTableSchema userGrantsLogsSchema[] = {
|
||||||
|
|
||||||
static const SSysDbTableSchema userMachinesSchema[] = {
|
static const SSysDbTableSchema userMachinesSchema[] = {
|
||||||
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
#ifndef TD_UNIQ_GRANT
|
|
||||||
{.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
{.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
#endif
|
|
||||||
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SSysDbTableSchema encryptionsSchema[] = {
|
||||||
|
{.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||||
|
{.name = "key_status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||||
|
};
|
||||||
|
|
||||||
static const SSysTableMeta infosMeta[] = {
|
static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||||
|
@ -439,6 +443,7 @@ static const SSysTableMeta infosMeta[] = {
|
||||||
{TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true},
|
{TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true},
|
||||||
{TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true},
|
{TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true},
|
||||||
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
|
||||||
|
{TSDB_INS_TABLE_ENCRYPTIONS, encryptionsSchema, tListLen(encryptionsSchema), true},
|
||||||
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
{TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ uint8_t getDefaultEncode(uint8_t type) {
|
||||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||||
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||||
case TSDB_DATA_TYPE_GEOMETRY:
|
case TSDB_DATA_TYPE_GEOMETRY:
|
||||||
|
return TSDB_COLVAL_ENCODE_DISABLED;
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_MAX:
|
case TSDB_DATA_TYPE_MAX:
|
||||||
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
return TSDB_COLVAL_ENCODE_SIMPLE8B;
|
||||||
|
|
||||||
|
@ -365,7 +367,7 @@ int8_t validColEncode(uint8_t type, uint8_t l1) {
|
||||||
} else if (type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) {
|
} else if (type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) {
|
||||||
return TSDB_COLVAL_ENCODE_DELTAD == l1 ? 1 : 0;
|
return TSDB_COLVAL_ENCODE_DELTAD == l1 ? 1 : 0;
|
||||||
} else if ((type == TSDB_DATA_TYPE_VARCHAR || type == TSDB_DATA_TYPE_NCHAR) || type == TSDB_DATA_TYPE_JSON ||
|
} else if ((type == TSDB_DATA_TYPE_VARCHAR || type == TSDB_DATA_TYPE_NCHAR) || type == TSDB_DATA_TYPE_JSON ||
|
||||||
type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_BINARY) {
|
type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
return l1 == TSDB_COLVAL_ENCODE_DISABLED ? 1 : 0;
|
return l1 == TSDB_COLVAL_ENCODE_DISABLED ? 1 : 0;
|
||||||
// if (l1 >= TSDB_COLVAL_ENCODE_NOCHANGE || l1 <= TSDB_COLVAL_ENCODE_DELTAD) {
|
// if (l1 >= TSDB_COLVAL_ENCODE_NOCHANGE || l1 <= TSDB_COLVAL_ENCODE_DELTAD) {
|
||||||
// return 1;
|
// return 1;
|
||||||
|
|
|
@ -2450,7 +2450,7 @@ static int32_t tColDataUpdateValue72(SColData *pColData, uint8_t *pData, uint32_
|
||||||
pColData->numOfValue--;
|
pColData->numOfValue--;
|
||||||
pColData->nVal--;
|
pColData->nVal--;
|
||||||
if (pColData->numOfValue) {
|
if (pColData->numOfValue) {
|
||||||
if (IS_STR_DATA_TYPE(pColData->type)) {
|
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||||
pColData->nData = pColData->aOffset[pColData->nVal];
|
pColData->nData = pColData->aOffset[pColData->nVal];
|
||||||
} else {
|
} else {
|
||||||
pColData->nData -= TYPE_BYTES[pColData->type];
|
pColData->nData -= TYPE_BYTES[pColData->type];
|
||||||
|
|
|
@ -41,6 +41,13 @@ uint16_t tsServerPort = 6030;
|
||||||
int32_t tsVersion = 30000000;
|
int32_t tsVersion = 30000000;
|
||||||
int32_t tsStatusInterval = 1; // second
|
int32_t tsStatusInterval = 1; // second
|
||||||
int32_t tsNumOfSupportVnodes = 256;
|
int32_t tsNumOfSupportVnodes = 256;
|
||||||
|
char tsEncryptAlgorithm[16] = {0};
|
||||||
|
char tsEncryptScope[100] = {0};
|
||||||
|
EEncryptAlgor tsiEncryptAlgorithm = 0;
|
||||||
|
EEncryptScope tsiEncryptScope = 0;
|
||||||
|
//char tsAuthCode[500] = {0};
|
||||||
|
//char tsEncryptKey[17] = {0};
|
||||||
|
char tsEncryptKey[17] = {0};
|
||||||
|
|
||||||
// common
|
// common
|
||||||
int32_t tsMaxShellConns = 50000;
|
int32_t tsMaxShellConns = 50000;
|
||||||
|
@ -77,8 +84,6 @@ int32_t tsSnapReplMaxWaitN = 128;
|
||||||
// mnode
|
// mnode
|
||||||
int64_t tsMndSdbWriteDelta = 200;
|
int64_t tsMndSdbWriteDelta = 200;
|
||||||
int64_t tsMndLogRetention = 2000;
|
int64_t tsMndLogRetention = 2000;
|
||||||
int8_t tsGrant = 1;
|
|
||||||
int32_t tsMndGrantMode = 0;
|
|
||||||
bool tsMndSkipGrant = false;
|
bool tsMndSkipGrant = false;
|
||||||
bool tsEnableWhiteList = false; // ip white list cfg
|
bool tsEnableWhiteList = false; // ip white list cfg
|
||||||
|
|
||||||
|
@ -92,6 +97,11 @@ int64_t tsDndStart = 0;
|
||||||
int64_t tsDndStartOsUptime = 0;
|
int64_t tsDndStartOsUptime = 0;
|
||||||
int64_t tsDndUpTime = 0;
|
int64_t tsDndUpTime = 0;
|
||||||
|
|
||||||
|
// dnode misc
|
||||||
|
uint32_t tsEncryptionKeyChksum = 0;
|
||||||
|
int8_t tsEncryptionKeyStat = ENCRYPT_KEY_STAT_UNSET;
|
||||||
|
int8_t tsGrant = 1;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
bool tsEnableMonitor = true;
|
bool tsEnableMonitor = true;
|
||||||
int32_t tsMonitorInterval = 30;
|
int32_t tsMonitorInterval = 30;
|
||||||
|
@ -609,6 +619,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2);
|
||||||
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
if (cfgAddInt32(pCfg, "supportVnodes", tsNumOfSupportVnodes, 0, 4096, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||||
|
|
||||||
|
if (cfgAddString(pCfg, "encryptAlgorithm", tsEncryptAlgorithm, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
if (cfgAddString(pCfg, "encryptScope", tsEncryptScope, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
//if (cfgAddString(pCfg, "authCode", tsAuthCode, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -705,7 +719,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
return -1;
|
return -1;
|
||||||
if (cfgAddInt64(pCfg, "mndLogRetention", tsMndLogRetention, 500, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0)
|
if (cfgAddInt64(pCfg, "mndLogRetention", tsMndLogRetention, 500, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (cfgAddInt32(pCfg, "grantMode", tsMndGrantMode, 0, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
|
||||||
if (cfgAddBool(pCfg, "skipGrant", tsMndSkipGrant, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddBool(pCfg, "skipGrant", tsMndSkipGrant, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1;
|
||||||
|
@ -1163,6 +1176,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
|
tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32;
|
||||||
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
|
tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32;
|
||||||
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||||
|
tstrncpy(tsEncryptAlgorithm, cfgGetItem(pCfg, "encryptAlgorithm")->str, 16);
|
||||||
|
tstrncpy(tsEncryptScope, cfgGetItem(pCfg, "encryptScope")->str, 100);
|
||||||
|
//tstrncpy(tsAuthCode, cfgGetItem(pCfg, "authCode")->str, 100);
|
||||||
|
|
||||||
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
||||||
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
||||||
|
@ -1238,7 +1254,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsMndSdbWriteDelta = cfgGetItem(pCfg, "mndSdbWriteDelta")->i64;
|
tsMndSdbWriteDelta = cfgGetItem(pCfg, "mndSdbWriteDelta")->i64;
|
||||||
tsMndLogRetention = cfgGetItem(pCfg, "mndLogRetention")->i64;
|
tsMndLogRetention = cfgGetItem(pCfg, "mndLogRetention")->i64;
|
||||||
tsMndSkipGrant = cfgGetItem(pCfg, "skipGrant")->bval;
|
tsMndSkipGrant = cfgGetItem(pCfg, "skipGrant")->bval;
|
||||||
tsMndGrantMode = cfgGetItem(pCfg, "grantMode")->i32;
|
|
||||||
tsEnableWhiteList = cfgGetItem(pCfg, "enableWhiteList")->bval;
|
tsEnableWhiteList = cfgGetItem(pCfg, "enableWhiteList")->bval;
|
||||||
|
|
||||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||||
|
|
|
@ -1216,6 +1216,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tEncodeCStr(&encoder, pReq->clusterCfg.locale) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->clusterCfg.locale) < 0) return -1;
|
||||||
if (tEncodeCStr(&encoder, pReq->clusterCfg.charset) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->clusterCfg.charset) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->clusterCfg.enableWhiteList) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->clusterCfg.enableWhiteList) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->clusterCfg.encryptionKeyStat) < 0) return -1;
|
||||||
|
if (tEncodeU32(&encoder, pReq->clusterCfg.encryptionKeyChksum) < 0) return -1;
|
||||||
|
|
||||||
// vnode loads
|
// vnode loads
|
||||||
int32_t vlen = (int32_t)taosArrayGetSize(pReq->pVloads);
|
int32_t vlen = (int32_t)taosArrayGetSize(pReq->pVloads);
|
||||||
|
@ -1308,6 +1310,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
||||||
if (tDecodeCStrTo(&decoder, pReq->clusterCfg.locale) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->clusterCfg.locale) < 0) return -1;
|
||||||
if (tDecodeCStrTo(&decoder, pReq->clusterCfg.charset) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->clusterCfg.charset) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->clusterCfg.enableWhiteList) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->clusterCfg.enableWhiteList) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->clusterCfg.encryptionKeyStat) < 0) return -1;
|
||||||
|
if (tDecodeU32(&decoder, &pReq->clusterCfg.encryptionKeyChksum) < 0) return -1;
|
||||||
|
|
||||||
// vnode loads
|
// vnode loads
|
||||||
int32_t vlen = 0;
|
int32_t vlen = 0;
|
||||||
|
@ -3080,13 +3084,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
||||||
}
|
}
|
||||||
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->tsdbPageSize) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->s3ChunkSize) < 0) return -1;
|
|
||||||
if (tEncodeI32(&encoder, pReq->s3KeepLocal) < 0) return -1;
|
|
||||||
if (tEncodeI8(&encoder, pReq->s3Compact) < 0) return -1;
|
|
||||||
|
|
||||||
ENCODESQL();
|
ENCODESQL();
|
||||||
|
|
||||||
if (tEncodeI8(&encoder, pReq->withArbitrator) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->withArbitrator) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->encryptAlgorithm) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->s3ChunkSize) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->s3KeepLocal) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->s3Compact) < 0) return -1;
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
@ -3155,22 +3160,21 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
||||||
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECODESQL();
|
||||||
|
|
||||||
|
pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||||
|
pReq->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
||||||
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI8(&decoder, &pReq->withArbitrator) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->encryptAlgorithm) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->s3ChunkSize) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->s3ChunkSize) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->s3Compact) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->s3Compact) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODESQL();
|
|
||||||
|
|
||||||
pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
|
||||||
if (tDecodeI8(&decoder, &pReq->withArbitrator) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4137,6 +4141,7 @@ int32_t tSerializeSDbCfgRspImpl(SEncoder *encoder, const SDbCfgRsp *pRsp) {
|
||||||
if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1;
|
if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pRsp->keepTimeOffset) < 0) return -1;
|
if (tEncodeI32(encoder, pRsp->keepTimeOffset) < 0) return -1;
|
||||||
if (tEncodeI8(encoder, pRsp->withArbitrator) < 0) return -1;
|
if (tEncodeI8(encoder, pRsp->withArbitrator) < 0) return -1;
|
||||||
|
if (tEncodeI8(encoder, pRsp->encryptAlgorithm) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pRsp->s3ChunkSize) < 0) return -1;
|
if (tEncodeI32(encoder, pRsp->s3ChunkSize) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pRsp->s3KeepLocal) < 0) return -1;
|
if (tEncodeI32(encoder, pRsp->s3KeepLocal) < 0) return -1;
|
||||||
if (tEncodeI8(encoder, pRsp->s3Compact) < 0) return -1;
|
if (tEncodeI8(encoder, pRsp->s3Compact) < 0) return -1;
|
||||||
|
@ -4213,14 +4218,13 @@ int32_t tDeserializeSDbCfgRspImpl(SDecoder *decoder, SDbCfgRsp *pRsp) {
|
||||||
if (tDecodeI32(decoder, &pRsp->keepTimeOffset) < 0) return -1;
|
if (tDecodeI32(decoder, &pRsp->keepTimeOffset) < 0) return -1;
|
||||||
}
|
}
|
||||||
pRsp->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
pRsp->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||||
if (!tDecodeIsEnd(decoder)) {
|
pRsp->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
if (tDecodeI8(decoder, &pRsp->withArbitrator) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRsp->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
pRsp->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
||||||
pRsp->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
pRsp->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
pRsp->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
pRsp->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
if (!tDecodeIsEnd(decoder)) {
|
if (!tDecodeIsEnd(decoder)) {
|
||||||
|
if (tDecodeI8(decoder, &pRsp->withArbitrator) < 0) return -1;
|
||||||
|
if (tDecodeI8(decoder, &pRsp->encryptAlgorithm) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pRsp->s3ChunkSize) < 0) return -1;
|
if (tDecodeI32(decoder, &pRsp->s3ChunkSize) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pRsp->s3KeepLocal) < 0) return -1;
|
if (tDecodeI32(decoder, &pRsp->s3KeepLocal) < 0) return -1;
|
||||||
if (tDecodeI8(decoder, &pRsp->s3Compact) < 0) return -1;
|
if (tDecodeI8(decoder, &pRsp->s3Compact) < 0) return -1;
|
||||||
|
@ -5282,6 +5286,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
}
|
}
|
||||||
if (tEncodeI32(&encoder, pReq->changeVersion) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->changeVersion) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->encryptAlgorithm) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->s3ChunkSize) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->s3ChunkSize) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->s3KeepLocal) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->s3KeepLocal) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->s3Compact) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->s3Compact) < 0) return -1;
|
||||||
|
@ -5378,11 +5383,12 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
pReq->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
|
||||||
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
if (tDecodeI8(&decoder, &pReq->encryptAlgorithm) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->s3ChunkSize) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->s3ChunkSize) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0) return -1;
|
if (tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->s3Compact) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->s3Compact) < 0) return -1;
|
||||||
|
@ -9167,7 +9173,7 @@ int32_t tDecodeMqMetaRsp(SDecoder *pDecoder, SMqMetaRsp *pRsp) {
|
||||||
|
|
||||||
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp) { taosMemoryFree(pRsp->metaRsp); }
|
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp) { taosMemoryFree(pRsp->metaRsp); }
|
||||||
|
|
||||||
int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRspCommon *pRsp) {
|
||||||
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->reqOffset) < 0) return -1;
|
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->reqOffset) < 0) return -1;
|
||||||
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1;
|
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pRsp->blockNum) < 0) return -1;
|
if (tEncodeI32(pEncoder, pRsp->blockNum) < 0) return -1;
|
||||||
|
@ -9192,14 +9198,13 @@ int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const void *pRsp) {
|
||||||
if (tEncodeI8(pEncoder, MQ_DATA_RSP_VERSION) < 0) return -1;
|
|
||||||
if (tEncodeMqDataRspCommon(pEncoder, pRsp) < 0) return -1;
|
if (tEncodeMqDataRspCommon(pEncoder, pRsp) < 0) return -1;
|
||||||
if (tEncodeI64(pEncoder, pRsp->sleepTime) < 0) return -1;
|
if (tEncodeI64(pEncoder, ((SMqDataRsp*)pRsp)->sleepTime) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRspCommon *pRsp) {
|
||||||
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset) < 0) return -1;
|
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset) < 0) return -1;
|
||||||
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1;
|
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pRsp->blockNum) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->blockNum) < 0) return -1;
|
||||||
|
@ -9245,19 +9250,17 @@ int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRsp *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp, int8_t dataVersion) {
|
int32_t tDecodeMqDataRsp(SDecoder *pDecoder, void *pRsp) {
|
||||||
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
|
||||||
if (tDecodeI8(pDecoder, &dataVersion) < 0) return -1;
|
|
||||||
}
|
|
||||||
if (tDecodeMqDataRspCommon(pDecoder, pRsp) < 0) return -1;
|
if (tDecodeMqDataRspCommon(pDecoder, pRsp) < 0) return -1;
|
||||||
if (!tDecodeIsEnd(pDecoder)) {
|
if (!tDecodeIsEnd(pDecoder)) {
|
||||||
if (tDecodeI64(pDecoder, &pRsp->sleepTime) < 0) return -1;
|
if (tDecodeI64(pDecoder, &((SMqDataRsp*)pRsp)->sleepTime) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDeleteMqDataRsp(SMqDataRsp *pRsp) {
|
static void tDeleteMqDataRspCommon(void *rsp) {
|
||||||
|
SMqDataRspCommon *pRsp = rsp;
|
||||||
pRsp->blockDataLen = taosArrayDestroy(pRsp->blockDataLen);
|
pRsp->blockDataLen = taosArrayDestroy(pRsp->blockDataLen);
|
||||||
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
||||||
pRsp->blockData = NULL;
|
pRsp->blockData = NULL;
|
||||||
|
@ -9269,10 +9272,14 @@ void tDeleteMqDataRsp(SMqDataRsp *pRsp) {
|
||||||
tOffsetDestroy(&pRsp->rspOffset);
|
tOffsetDestroy(&pRsp->rspOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) {
|
void tDeleteMqDataRsp(void *rsp) {
|
||||||
if (tEncodeI8(pEncoder, MQ_DATA_RSP_VERSION) < 0) return -1;
|
tDeleteMqDataRspCommon(rsp);
|
||||||
if (tEncodeMqDataRspCommon(pEncoder, (const SMqDataRsp *)pRsp) < 0) return -1;
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const void *rsp) {
|
||||||
|
if (tEncodeMqDataRspCommon(pEncoder, rsp) < 0) return -1;
|
||||||
|
|
||||||
|
const STaosxRsp *pRsp = (const STaosxRsp *)rsp;
|
||||||
if (tEncodeI32(pEncoder, pRsp->createTableNum) < 0) return -1;
|
if (tEncodeI32(pEncoder, pRsp->createTableNum) < 0) return -1;
|
||||||
if (pRsp->createTableNum) {
|
if (pRsp->createTableNum) {
|
||||||
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
||||||
|
@ -9284,19 +9291,17 @@ int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp, int8_t dataVersion) {
|
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, void *rsp) {
|
||||||
if (dataVersion >= MQ_DATA_RSP_VERSION) {
|
if (tDecodeMqDataRspCommon(pDecoder, rsp) < 0) return -1;
|
||||||
if (tDecodeI8(pDecoder, &dataVersion) < 0) return -1;
|
|
||||||
}
|
|
||||||
if (tDecodeMqDataRspCommon(pDecoder, (SMqDataRsp *)pRsp) < 0) return -1;
|
|
||||||
|
|
||||||
|
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
||||||
if (tDecodeI32(pDecoder, &pRsp->createTableNum) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pRsp->createTableNum) < 0) return -1;
|
||||||
if (pRsp->createTableNum) {
|
if (pRsp->createTableNum) {
|
||||||
pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t));
|
pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t));
|
||||||
pRsp->createTableReq = taosArrayInit(pRsp->createTableNum, sizeof(void *));
|
pRsp->createTableReq = taosArrayInit(pRsp->createTableNum, sizeof(void *));
|
||||||
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
||||||
void *pCreate = NULL;
|
void * pCreate = NULL;
|
||||||
uint64_t len;
|
uint64_t len = 0;
|
||||||
if (tDecodeBinaryAlloc(pDecoder, &pCreate, &len) < 0) return -1;
|
if (tDecodeBinaryAlloc(pDecoder, &pCreate, &len) < 0) return -1;
|
||||||
int32_t l = (int32_t)len;
|
int32_t l = (int32_t)len;
|
||||||
taosArrayPush(pRsp->createTableLen, &l);
|
taosArrayPush(pRsp->createTableLen, &l);
|
||||||
|
@ -9307,20 +9312,13 @@ int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp, int8_t dataVersion
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDeleteSTaosxRsp(STaosxRsp *pRsp) {
|
void tDeleteSTaosxRsp(void *rsp) {
|
||||||
pRsp->blockDataLen = taosArrayDestroy(pRsp->blockDataLen);
|
tDeleteMqDataRspCommon(rsp);
|
||||||
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree);
|
|
||||||
pRsp->blockData = NULL;
|
|
||||||
taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSchemaWrapper);
|
|
||||||
pRsp->blockSchema = NULL;
|
|
||||||
taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree);
|
|
||||||
pRsp->blockTbName = NULL;
|
|
||||||
|
|
||||||
|
STaosxRsp *pRsp = (STaosxRsp *)rsp;
|
||||||
pRsp->createTableLen = taosArrayDestroy(pRsp->createTableLen);
|
pRsp->createTableLen = taosArrayDestroy(pRsp->createTableLen);
|
||||||
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree);
|
||||||
pRsp->createTableReq = NULL;
|
pRsp->createTableReq = NULL;
|
||||||
tOffsetDestroy(&pRsp->reqOffset);
|
|
||||||
tOffsetDestroy(&pRsp->rspOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSSingleDeleteReq(SEncoder *pEncoder, const SSingleDeleteReq *pReq) {
|
int32_t tEncodeSSingleDeleteReq(SEncoder *pEncoder, const SSingleDeleteReq *pReq) {
|
||||||
|
|
|
@ -31,8 +31,8 @@ ENDIF ()
|
||||||
|
|
||||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||||
ADD_DEPENDENCIES(taosd jemalloc)
|
ADD_DEPENDENCIES(taosd jemalloc)
|
||||||
target_link_libraries(taosd dnode ${LINK_JEMALLOC})
|
target_link_libraries(taosd dnode crypt ${LINK_JEMALLOC})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
target_link_libraries(taosd dnode)
|
target_link_libraries(taosd dnode crypt)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#ifdef TD_JEMALLOC_ENABLED
|
#ifdef TD_JEMALLOC_ENABLED
|
||||||
#include "jemalloc/jemalloc.h"
|
#include "jemalloc/jemalloc.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "dmUtil.h"
|
||||||
|
|
||||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||||
#include "cus_name.h"
|
#include "cus_name.h"
|
||||||
|
@ -49,6 +50,8 @@
|
||||||
#define DM_VERSION "Print program version."
|
#define DM_VERSION "Print program version."
|
||||||
#define DM_EMAIL "<support@taosdata.com>"
|
#define DM_EMAIL "<support@taosdata.com>"
|
||||||
#define DM_MEM_DBG "Enable memory debug"
|
#define DM_MEM_DBG "Enable memory debug"
|
||||||
|
#define DM_SET_ENCRYPTKEY "Set encrypt key. such as: -y 1234567890abcdef, the length should be less or equal to 16."
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
static struct {
|
static struct {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -67,6 +70,8 @@ static struct {
|
||||||
const char **envCmd;
|
const char **envCmd;
|
||||||
SArray *pArgs; // SConfigPair
|
SArray *pArgs; // SConfigPair
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
|
bool generateCode;
|
||||||
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetGlobalDebugFlag(143); }
|
static void dmSetDebugFlag(int32_t signum, void *sigInfo, void *context) { taosSetGlobalDebugFlag(143); }
|
||||||
|
@ -195,6 +200,23 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
global.generateGrant = true;
|
global.generateGrant = true;
|
||||||
|
} else if (strcmp(argv[i], "-y") == 0) {
|
||||||
|
global.generateCode = true;
|
||||||
|
if(i < argc - 1) {
|
||||||
|
int32_t len = strlen(argv[++i]);
|
||||||
|
if (len < ENCRYPT_KEY_LEN_MIN) {
|
||||||
|
printf("encrypt key is too short, it should be great or equal to %d\n", ENCRYPT_KEY_LEN_MIN);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (len > ENCRYPT_KEY_LEN) {
|
||||||
|
printf("encrypt key overflow, it should be less or equal to %d\n", ENCRYPT_KEY_LEN);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
||||||
|
} else {
|
||||||
|
printf("'-y' requires a parameter\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else if (strcmp(argv[i], "-C") == 0) {
|
} else if (strcmp(argv[i], "-C") == 0) {
|
||||||
global.dumpConfig = true;
|
global.dumpConfig = true;
|
||||||
} else if (strcmp(argv[i], "-V") == 0) {
|
} else if (strcmp(argv[i], "-V") == 0) {
|
||||||
|
@ -259,6 +281,7 @@ static void dmPrintHelp() {
|
||||||
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
||||||
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
||||||
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-y,", indent, DM_SET_ENCRYPTKEY);
|
||||||
printf("%s%s%s%s\n", indent, "-dm,", indent, DM_MEM_DBG);
|
printf("%s%s%s%s\n", indent, "-dm,", indent, DM_MEM_DBG);
|
||||||
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
||||||
|
|
||||||
|
@ -364,6 +387,24 @@ int mainWindows(int argc, char **argv) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(global.generateCode) {
|
||||||
|
if(dmCheckRunning(tsDataDir) == NULL) {
|
||||||
|
dError("failed to generate encrypt code since taosd is running, please stop it first");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int ret = dmUpdateEncryptKey(global.encryptKey);
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dmGetEncryptKey() != 0){
|
||||||
|
dError("failed to start since failed to get encrypt key");
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
if (taosConvInit() != 0) {
|
if (taosConvInit() != 0) {
|
||||||
dError("failed to init conv");
|
dError("failed to init conv");
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
|
|
|
@ -57,6 +57,7 @@ int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg);
|
int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg);
|
||||||
|
int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// dmWorker.c
|
// dmWorker.c
|
||||||
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmInt.h"
|
#include "dmInt.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
#include "tchecksum.h"
|
||||||
|
|
||||||
extern SConfig *tsCfg;
|
extern SConfig *tsCfg;
|
||||||
|
|
||||||
|
@ -113,6 +114,8 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
req.clusterCfg.checkTime = 0;
|
req.clusterCfg.checkTime = 0;
|
||||||
req.clusterCfg.ttlChangeOnWrite = tsTtlChangeOnWrite;
|
req.clusterCfg.ttlChangeOnWrite = tsTtlChangeOnWrite;
|
||||||
req.clusterCfg.enableWhiteList = tsEnableWhiteList ? 1 : 0;
|
req.clusterCfg.enableWhiteList = tsEnableWhiteList ? 1 : 0;
|
||||||
|
req.clusterCfg.encryptionKeyStat = tsEncryptionKeyStat;
|
||||||
|
req.clusterCfg.encryptionKeyChksum = tsEncryptionKeyChksum;
|
||||||
char timestr[32] = "1970-01-01 00:00:00.00";
|
char timestr[32] = "1970-01-01 00:00:00.00";
|
||||||
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
||||||
|
@ -221,6 +224,32 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
int32_t code = 0;
|
||||||
|
SDCfgDnodeReq cfgReq = {0};
|
||||||
|
if (tDeserializeSDCfgDnodeReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
|
||||||
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = dmUpdateEncryptKey(cfgReq.value);
|
||||||
|
if (code == 0) {
|
||||||
|
tsEncryptionKeyChksum = taosCalcChecksum(0, cfgReq.value, strlen(cfgReq.value));
|
||||||
|
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||||
|
tstrncpy(tsEncryptKey, cfgReq.value, ENCRYPT_KEY_LEN + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
pMsg->code = code;
|
||||||
|
pMsg->info.rsp = NULL;
|
||||||
|
pMsg->info.rspLen = 0;
|
||||||
|
return code;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
||||||
pStatus->details[0] = 0;
|
pStatus->details[0] = 0;
|
||||||
|
@ -421,6 +450,7 @@ SArray *dmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SERVER_STATUS, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_SERVER_STATUS, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_MNODE_TYPE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_MNODE_TYPE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_ENCRYPT_KEY, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -359,6 +359,9 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
case TDMT_MND_GRANT_NOTIFY:
|
case TDMT_MND_GRANT_NOTIFY:
|
||||||
code = dmProcessGrantNotify(NULL, pMsg);
|
code = dmProcessGrantNotify(NULL, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_DND_CREATE_ENCRYPT_KEY:
|
||||||
|
code = dmProcessCreateEncryptKeyReq(pMgmt, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
dGError("msg:%p, not processed in mgmt queue", pMsg);
|
dGError("msg:%p, not processed in mgmt queue", pMsg);
|
||||||
|
|
|
@ -113,6 +113,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_VNODE_TYPE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_ALTER_VNODE_TYPE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CONFIG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CONFIG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -204,6 +205,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_CLUSTER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ENCRYPT_KEY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
@ -142,6 +142,14 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1;
|
if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
|
if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
|
||||||
|
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pCfg->tsdbCfg.encryptAlgorithm = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
pCfg->walCfg.vgId = pCreate->vgId;
|
pCfg->walCfg.vgId = pCreate->vgId;
|
||||||
pCfg->walCfg.fsyncPeriod = pCreate->walFsyncPeriod;
|
pCfg->walCfg.fsyncPeriod = pCreate->walFsyncPeriod;
|
||||||
|
@ -150,6 +158,23 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->walCfg.retentionSize = pCreate->walRetentionSize;
|
pCfg->walCfg.retentionSize = pCreate->walRetentionSize;
|
||||||
pCfg->walCfg.segSize = pCreate->walSegmentSize;
|
pCfg->walCfg.segSize = pCreate->walSegmentSize;
|
||||||
pCfg->walCfg.level = pCreate->walLevel;
|
pCfg->walCfg.level = pCreate->walLevel;
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
|
if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
|
||||||
|
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pCfg->walCfg.encryptAlgorithm = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
|
if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
|
||||||
|
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pCfg->tdbEncryptAlgorithm = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
pCfg->sttTrigger = pCreate->sstTrigger;
|
pCfg->sttTrigger = pCreate->sstTrigger;
|
||||||
pCfg->hashBegin = pCreate->hashBegin;
|
pCfg->hashBegin = pCreate->hashBegin;
|
||||||
|
@ -246,14 +271,15 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
"precision:%d compression:%d minRows:%d maxRows:%d"
|
"precision:%d compression:%d minRows:%d maxRows:%d"
|
||||||
", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64
|
", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64
|
||||||
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d "
|
||||||
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d",
|
"learnerReplica:%d learnerSelfIndex:%d strict:%d changeVersion:%d encryptAlgorithm:%d",
|
||||||
req.vgId, TMSG_INFO(pMsg->msgType), req.pages, req.pageSize, req.buffer, req.pageSize * 1024,
|
req.vgId, TMSG_INFO(pMsg->msgType), req.pages, req.pageSize, req.buffer, req.pageSize * 1024,
|
||||||
(uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize,
|
(uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize,
|
||||||
req.tsdbPageSize * 1024, req.db, req.dbUid, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
req.tsdbPageSize * 1024, req.db, req.dbUid, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2,
|
||||||
req.keepTimeOffset, req.s3ChunkSize, req.s3KeepLocal, req.s3Compact, req.isTsma, req.precision, req.compression,
|
req.keepTimeOffset, req.s3ChunkSize, req.s3KeepLocal, req.s3Compact, req.isTsma, req.precision, req.compression,
|
||||||
req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize,
|
req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize,
|
||||||
req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix,
|
req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix,
|
||||||
req.replica, req.selfIndex, req.learnerReplica, req.learnerSelfIndex, req.strict, req.changeVersion);
|
req.replica, req.selfIndex, req.learnerReplica, req.learnerSelfIndex, req.strict, req.changeVersion,
|
||||||
|
req.encryptAlgorithm);
|
||||||
|
|
||||||
for (int32_t i = 0; i < req.replica; ++i) {
|
for (int32_t i = 0; i < req.replica; ++i) {
|
||||||
dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", req.vgId, i, req.replicas[i].fqdn, req.replicas[i].port,
|
dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", req.vgId, i, req.replicas[i].fqdn, req.replicas[i].port,
|
||||||
|
@ -278,6 +304,14 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.encryptAlgorithm == DND_CA_SM4){
|
||||||
|
if(strlen(tsEncryptKey) == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
dError("vgId:%d, failed to create vnode since encrypt key is empty", req.vgId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vmGenerateVnodeCfg(&req, &vnodeCfg);
|
vmGenerateVnodeCfg(&req, &vnodeCfg);
|
||||||
|
|
||||||
if (vmTsmaAdjustDays(&vnodeCfg, &req) < 0) {
|
if (vmTsmaAdjustDays(&vnodeCfg, &req) < 0) {
|
||||||
|
|
|
@ -161,6 +161,46 @@ int32_t dmInitVars(SDnode *pDnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
tsiEncryptAlgorithm = pData->encryptAlgorigthm;
|
||||||
|
tsiEncryptScope = pData->encryptScope;
|
||||||
|
/*
|
||||||
|
if(tsiEncryptAlgorithm != 0) {
|
||||||
|
if(pData->machineId != NULL && strlen(pData->machineId) > 0){
|
||||||
|
dInfo("get crypt key at startup, machineId:%s", pData->machineId);
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
//code = taosGetCryptKey(tsAuthCode, pData->machineId, tsCryptKey);
|
||||||
|
code = 0;
|
||||||
|
strncpy(tsEncryptKey, tsAuthCode, 16);
|
||||||
|
|
||||||
|
if(code != 0) {
|
||||||
|
if(code == -1){
|
||||||
|
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||||
|
dError("machine code changed, can't get crypt key");
|
||||||
|
}
|
||||||
|
if(code == -2){
|
||||||
|
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||||
|
dError("failed to get crypt key");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(tsEncryptKey) == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||||
|
dError("failed to get crypt key at startup since key is null, machineId:%s", pData->machineId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE;
|
||||||
|
dError("failed to get crypt key at startup, machineId:%s", pData->machineId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pData->dropped) {
|
if (pData->dropped) {
|
||||||
dError("dnode will not start since its already dropped");
|
dError("dnode will not start since its already dropped");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -110,6 +110,8 @@ typedef struct {
|
||||||
bool validMnodeEps;
|
bool validMnodeEps;
|
||||||
int64_t ipWhiteVer;
|
int64_t ipWhiteVer;
|
||||||
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
char machineId[TSDB_MACHINE_ID_LEN + 1];
|
||||||
|
EEncryptAlgor encryptAlgorigthm;
|
||||||
|
EEncryptScope encryptScope;
|
||||||
} SDnodeData;
|
} SDnodeData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -191,7 +193,8 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
|
||||||
bool dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port);
|
bool dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port);
|
||||||
void dmRemoveDnodePairs(SDnodeData *pData);
|
void dmRemoveDnodePairs(SDnodeData *pData);
|
||||||
void dmGetDnodeEp(void *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort);
|
void dmGetDnodeEp(void *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort);
|
||||||
|
int32_t dmUpdateEncryptKey(char *key);
|
||||||
|
int32_t dmGetEncryptKey();
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,7 +64,12 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
tjsonGetInt32ValueFromDouble(pJson, "encryptAlgor", pData->encryptAlgorigthm, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
|
tjsonGetInt32ValueFromDouble(pJson, "encryptScope", pData->encryptScope, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
|
#endif
|
||||||
SJson *dnodes = tjsonGetObjectItem(pJson, "dnodes");
|
SJson *dnodes = tjsonGetObjectItem(pJson, "dnodes");
|
||||||
if (dnodes == NULL) return 0;
|
if (dnodes == NULL) return 0;
|
||||||
int32_t numOfDnodes = tjsonGetArraySize(dnodes);
|
int32_t numOfDnodes = tjsonGetArraySize(dnodes);
|
||||||
|
@ -89,6 +94,25 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dmOccurrences(char *str, char *toSearch) {
|
||||||
|
int count = 0;
|
||||||
|
char *ptr = str;
|
||||||
|
while ((ptr = strstr(ptr, toSearch)) != NULL) {
|
||||||
|
count++;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dmSplitStr(char** arr, char* str, const char* del) {
|
||||||
|
char *lasts;
|
||||||
|
char* s = strsep(&str, del);
|
||||||
|
while (s != NULL) {
|
||||||
|
*arr++ = s;
|
||||||
|
s = strsep(&str, del);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t dmReadEps(SDnodeData *pData) {
|
int32_t dmReadEps(SDnodeData *pData) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
TdFilePtr pFile = NULL;
|
TdFilePtr pFile = NULL;
|
||||||
|
@ -106,6 +130,74 @@ int32_t dmReadEps(SDnodeData *pData) {
|
||||||
|
|
||||||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||||
dInfo("dnode file:%s not exist", file);
|
dInfo("dnode file:%s not exist", file);
|
||||||
|
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
if(strlen(tsEncryptAlgorithm) > 0){
|
||||||
|
if(strcmp(tsEncryptAlgorithm, "sm4") == 0) {
|
||||||
|
pData->encryptAlgorigthm = DND_CA_SM4;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||||
|
dError("invalid tsEncryptAlgorithm:%s", tsEncryptAlgorithm);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("start to parse encryptScope:%s", tsEncryptScope);
|
||||||
|
int32_t scopeLen = strlen(tsEncryptScope);
|
||||||
|
if(scopeLen == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||||
|
dError("invalid tsEncryptScope:%s", tsEncryptScope);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* tmp = taosMemoryMalloc(scopeLen + 1);
|
||||||
|
memset(tmp, 0, scopeLen + 1);
|
||||||
|
memcpy(tmp, tsEncryptScope, scopeLen);
|
||||||
|
|
||||||
|
int32_t count = dmOccurrences(tmp, ",");
|
||||||
|
|
||||||
|
char** array = taosMemoryMalloc(sizeof(char*) * (count + 1));
|
||||||
|
memset(array, 0, sizeof(char*) * (count + 1));
|
||||||
|
dmSplitStr(array, tmp, ",");
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < count + 1; i++){
|
||||||
|
char* str = *(array + i);
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
if(strcasecmp(str, "tsdb") == 0 || strcasecmp(str, "all") == 0){
|
||||||
|
pData->encryptScope |= DND_CS_TSDB;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
if(strcasecmp(str, "vnode_wal") == 0 || strcasecmp(str, "all") == 0){
|
||||||
|
pData->encryptScope |= DND_CS_VNODE_WAL;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
if(strcasecmp(str, "sdb") == 0 || strcasecmp(str, "all") == 0){
|
||||||
|
pData->encryptScope |= DND_CS_SDB;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
if(strcasecmp(str, "mnode_wal") == 0 || strcasecmp(str, "all") == 0){
|
||||||
|
pData->encryptScope |= DND_CS_MNODE_WAL;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!success){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||||
|
taosMemoryFree(tmp);
|
||||||
|
taosMemoryFree(array);
|
||||||
|
dError("invalid tsEncryptScope:%s", tsEncryptScope);
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFree(tmp);
|
||||||
|
taosMemoryFree(array);
|
||||||
|
|
||||||
|
dInfo("set tsCryptAlgorithm:%s, tsCryptScope:%s from cfg", tsEncryptAlgorithm, tsEncryptScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
code = 0;
|
code = 0;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +283,10 @@ static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
||||||
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
||||||
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
if (tjsonAddDoubleToObject(pJson, "encryptAlgor", pData->encryptAlgorigthm) < 0) return -1;
|
||||||
|
if (tjsonAddDoubleToObject(pJson, "encryptScope", pData->encryptScope) < 0) return -1;
|
||||||
|
#endif
|
||||||
SJson *dnodes = tjsonCreateArray();
|
SJson *dnodes = tjsonCreateArray();
|
||||||
if (dnodes == NULL) return -1;
|
if (dnodes == NULL) return -1;
|
||||||
if (tjsonAddItemToObject(pJson, "dnodes", dnodes) < 0) return -1;
|
if (tjsonAddItemToObject(pJson, "dnodes", dnodes) < 0) return -1;
|
||||||
|
|
|
@ -16,8 +16,14 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmUtil.h"
|
#include "dmUtil.h"
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
|
#include "tgrant.h"
|
||||||
|
#include "crypt.h"
|
||||||
|
#include "tchecksum.h"
|
||||||
|
|
||||||
#define MAXLEN 1024
|
#define MAXLEN 1024
|
||||||
|
#define DM_KEY_INDICATOR "this indicator!"
|
||||||
|
#define DM_ENCRYPT_CODE_FILE "encryptCode.cfg"
|
||||||
|
#define DM_CHECK_CODE_FILE "checkCode.bin"
|
||||||
|
|
||||||
static int32_t dmDecodeFile(SJson *pJson, bool *deployed) {
|
static int32_t dmDecodeFile(SJson *pJson, bool *deployed) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -177,3 +183,296 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
|
||||||
dDebug("lock file:%s to prevent repeated starts", filepath);
|
dDebug("lock file:%s to prevent repeated starts", filepath);
|
||||||
return pFile;
|
return pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int32_t generateEncryptCode(const char *key, const char *machineId, char **encryptCode);
|
||||||
|
|
||||||
|
static int32_t dmWriteCheckCodeFile(char* file, char* realfile, char* key){
|
||||||
|
TdFilePtr pFile = NULL;
|
||||||
|
char *result = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
int32_t len = ENCRYPTED_LEN(sizeof(DM_KEY_INDICATOR));
|
||||||
|
result = taosMemoryMalloc(len);
|
||||||
|
|
||||||
|
SCryptOpts opts;
|
||||||
|
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||||
|
opts.len = len;
|
||||||
|
opts.source = DM_KEY_INDICATOR;
|
||||||
|
opts.result = result;
|
||||||
|
opts.unitLen = 16;
|
||||||
|
CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||||
|
if (pFile == NULL) goto _OVER;
|
||||||
|
|
||||||
|
if (taosWriteFile(pFile, opts.result, len) <= 0) goto _OVER;
|
||||||
|
if (taosFsyncFile(pFile) < 0) goto _OVER;
|
||||||
|
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
if (taosRenameFile(file, realfile) != 0) goto _OVER;
|
||||||
|
|
||||||
|
dInfo("succeed to write checkCode file:%s", realfile);
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
if(pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
if(result != NULL) taosMemoryFree(result);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dmWriteEncryptCodeFile(char* file, char* realfile, char* encryptCode){
|
||||||
|
TdFilePtr pFile = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||||
|
if (pFile == NULL) goto _OVER;
|
||||||
|
|
||||||
|
int32_t len = strlen(encryptCode);
|
||||||
|
if (taosWriteFile(pFile, encryptCode, len) <= 0) goto _OVER;
|
||||||
|
if (taosFsyncFile(pFile) < 0) goto _OVER;
|
||||||
|
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
if (taosRenameFile(file, realfile) != 0) goto _OVER;
|
||||||
|
|
||||||
|
dInfo("succeed to write encryptCode file:%s", realfile);
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
if(pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dmCompareEncryptKey(char* file, char* key){
|
||||||
|
char *content = NULL;
|
||||||
|
int64_t size = 0;
|
||||||
|
TdFilePtr pFile = NULL;
|
||||||
|
char *result = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||||
|
if (pFile == NULL) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content = taosMemoryMalloc(size);
|
||||||
|
if (content == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosReadFile(pFile, content, size) != size) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("succeed to read checkCode file:%s", file);
|
||||||
|
|
||||||
|
int len = ENCRYPTED_LEN(size);
|
||||||
|
result = taosMemoryMalloc(len);
|
||||||
|
|
||||||
|
SCryptOpts opts = {0};
|
||||||
|
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||||
|
opts.len = len;
|
||||||
|
opts.source = content;
|
||||||
|
opts.result = result;
|
||||||
|
opts.unitLen = 16;
|
||||||
|
CBC_Decrypt(&opts);
|
||||||
|
|
||||||
|
if(strcmp(opts.result, DM_KEY_INDICATOR) != 0) {
|
||||||
|
terrno = TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED;
|
||||||
|
dError("failed to compare decrypted result");
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
dInfo("succeed to compare checkCode file:%s", file);
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
if(result != NULL) taosMemoryFree(result);
|
||||||
|
if(content != NULL) taosMemoryFree(content);
|
||||||
|
if(pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dmUpdateEncryptKey(char *key) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
int32_t code = -1;
|
||||||
|
char *machineId = NULL;
|
||||||
|
char *encryptCode = NULL;
|
||||||
|
|
||||||
|
char folder[PATH_MAX] = {0};
|
||||||
|
|
||||||
|
char encryptFile[PATH_MAX] = {0};
|
||||||
|
char realEncryptFile[PATH_MAX] = {0};
|
||||||
|
|
||||||
|
char checkFile[PATH_MAX] = {0};
|
||||||
|
char realCheckFile[PATH_MAX] = {0};
|
||||||
|
|
||||||
|
snprintf(folder, sizeof(folder), "%s%sdnode", tsDataDir, TD_DIRSEP);
|
||||||
|
snprintf(encryptFile, sizeof(realEncryptFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||||
|
snprintf(realEncryptFile, sizeof(realEncryptFile), "%s%s%s", folder, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||||
|
snprintf(checkFile, sizeof(checkFile), "%s%s%s.bak", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||||
|
snprintf(realCheckFile, sizeof(realCheckFile), "%s%s%s", folder, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||||
|
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
|
if (taosMkDir(folder) != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to create dir:%s since %s", folder, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(taosCheckExistFile(realCheckFile)){
|
||||||
|
if(dmCompareEncryptKey(realCheckFile, key) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(machineId = tGetMachineId())) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (generateEncryptCode(key, machineId, &encryptCode) != 0) {
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dmWriteEncryptCodeFile(encryptFile, realEncryptFile, encryptCode) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dmWriteCheckCodeFile(checkFile, realCheckFile, key) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
taosMemoryFree(encryptCode);
|
||||||
|
taosMemoryFree(machineId);
|
||||||
|
if (code != 0) {
|
||||||
|
if (terrno == 0) terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to update encrypt key since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key);
|
||||||
|
|
||||||
|
static int32_t dmReadEncryptCodeFile(char* file, char** output){
|
||||||
|
TdFilePtr pFile = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
char *content = NULL;
|
||||||
|
|
||||||
|
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||||
|
if (pFile == NULL) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t size = 0;
|
||||||
|
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content = taosMemoryMalloc(size + 1);
|
||||||
|
if (content == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosReadFile(pFile, content, size) != size) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
content[size] = '\0';
|
||||||
|
|
||||||
|
*output = content;
|
||||||
|
|
||||||
|
dInfo("succeed to read encryptCode file:%s", file);
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
if(pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dmGetEncryptKey(){
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
int32_t code = -1;
|
||||||
|
char encryptFile[PATH_MAX] = {0};
|
||||||
|
char checkFile[PATH_MAX] = {0};
|
||||||
|
char *machineId = NULL;
|
||||||
|
char *encryptKey = NULL;
|
||||||
|
char *content = NULL;
|
||||||
|
|
||||||
|
snprintf(encryptFile, sizeof(encryptFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_ENCRYPT_CODE_FILE);
|
||||||
|
snprintf(checkFile, sizeof(checkFile), "%s%sdnode%s%s", tsDataDir, TD_DIRSEP, TD_DIRSEP, DM_CHECK_CODE_FILE);
|
||||||
|
|
||||||
|
if(!taosCheckExistFile(encryptFile)){
|
||||||
|
dInfo("no exist, checkCode file:%s", encryptFile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dmReadEncryptCodeFile(encryptFile, &content) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(machineId = tGetMachineId())) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(checkAndGetCryptKey(content, machineId, &encryptKey) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(machineId);
|
||||||
|
taosMemoryFreeClear(content);
|
||||||
|
|
||||||
|
if(encryptKey[0] == '\0'){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
dError("failed to read key since %s", terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dmCompareEncryptKey(checkFile, encryptKey) != 0){
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
taosMemoryFreeClear(encryptKey);
|
||||||
|
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
|
||||||
|
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
_OVER:
|
||||||
|
if (content != NULL) taosMemoryFree(content);
|
||||||
|
if (encryptKey != NULL) taosMemoryFree(encryptKey);
|
||||||
|
if (machineId != NULL) taosMemoryFree(machineId);
|
||||||
|
if (code != 0) {
|
||||||
|
if (terrno == 0) terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("failed to get encrypt key since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -141,6 +141,7 @@ typedef enum {
|
||||||
DND_REASON_CHARSET_NOT_MATCH,
|
DND_REASON_CHARSET_NOT_MATCH,
|
||||||
DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH,
|
DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH,
|
||||||
DND_REASON_ENABLE_WHITELIST_NOT_MATCH,
|
DND_REASON_ENABLE_WHITELIST_NOT_MATCH,
|
||||||
|
DND_REASON_ENCRYPTION_KEY_NOT_MATCH,
|
||||||
DND_REASON_OTHERS
|
DND_REASON_OTHERS
|
||||||
} EDndReason;
|
} EDndReason;
|
||||||
|
|
||||||
|
@ -215,6 +216,8 @@ typedef struct {
|
||||||
int64_t memAvail;
|
int64_t memAvail;
|
||||||
int64_t memUsed;
|
int64_t memUsed;
|
||||||
EDndReason offlineReason;
|
EDndReason offlineReason;
|
||||||
|
uint32_t encryptionKeyChksum;
|
||||||
|
int8_t encryptionKeyStat;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
char fqdn[TSDB_FQDN_LEN];
|
char fqdn[TSDB_FQDN_LEN];
|
||||||
char ep[TSDB_EP_LEN];
|
char ep[TSDB_EP_LEN];
|
||||||
|
@ -383,6 +386,7 @@ typedef struct {
|
||||||
int32_t s3KeepLocal;
|
int32_t s3KeepLocal;
|
||||||
int8_t s3Compact;
|
int8_t s3Compact;
|
||||||
int8_t withArbitrator;
|
int8_t withArbitrator;
|
||||||
|
int8_t encryptAlgorithm;
|
||||||
} SDbCfg;
|
} SDbCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -104,6 +104,13 @@ typedef struct {
|
||||||
int64_t timeseriesAllowed;
|
int64_t timeseriesAllowed;
|
||||||
} SGrantInfo;
|
} SGrantInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t encrypting;
|
||||||
|
int16_t nEncrypt;
|
||||||
|
int16_t nSuccess;
|
||||||
|
int16_t nFailed;
|
||||||
|
} SEncryptMgmt;
|
||||||
|
|
||||||
typedef struct SMnode {
|
typedef struct SMnode {
|
||||||
int32_t selfDnodeId;
|
int32_t selfDnodeId;
|
||||||
int64_t clusterId;
|
int64_t clusterId;
|
||||||
|
@ -127,6 +134,7 @@ typedef struct SMnode {
|
||||||
SProfileMgmt profileMgmt;
|
SProfileMgmt profileMgmt;
|
||||||
STelemMgmt telemMgmt;
|
STelemMgmt telemMgmt;
|
||||||
SSyncMgmt syncMgmt;
|
SSyncMgmt syncMgmt;
|
||||||
|
SEncryptMgmt encryptMgmt;
|
||||||
SGrantInfo grant;
|
SGrantInfo grant;
|
||||||
MndMsgFp msgFp[TDMT_MAX];
|
MndMsgFp msgFp[TDMT_MAX];
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
|
|
|
@ -648,7 +648,6 @@ static SMqConsumerObj* buildSubConsumer(SMnode *pMnode, SCMSubscribeReq *subscri
|
||||||
_over:
|
_over:
|
||||||
mndReleaseConsumer(pMnode, pExistedConsumer);
|
mndReleaseConsumer(pMnode, pExistedConsumer);
|
||||||
tDeleteSMqConsumerObj(pConsumerNew);
|
tDeleteSMqConsumerObj(pConsumerNew);
|
||||||
taosArrayDestroyP(subscribe->topicNames, (FDelete)taosMemoryFree);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
|
|
||||||
#define DB_VER_NUMBER 1
|
#define DB_VER_NUMBER 1
|
||||||
#define DB_RESERVE_SIZE 28
|
#define DB_RESERVE_SIZE 27
|
||||||
|
|
||||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
||||||
|
@ -146,6 +146,7 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.s3KeepLocal, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.s3KeepLocal, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.s3Compact, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.s3Compact, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER)
|
||||||
|
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.encryptAlgorithm, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pDb->tsmaVersion, _OVER);
|
SDB_SET_INT32(pRaw, dataPos, pDb->tsmaVersion, _OVER);
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||||
|
@ -242,6 +243,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.s3KeepLocal, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.s3KeepLocal, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.s3Compact, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.s3Compact, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER)
|
||||||
|
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.encryptAlgorithm, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pDb->tsmaVersion, _OVER);
|
SDB_GET_INT32(pRaw, dataPos, &pDb->tsmaVersion, _OVER);
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
|
||||||
|
@ -425,9 +427,12 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||||
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
if ((pCfg->replications == 2) ^ (pCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1;
|
if ((pCfg->replications == 2) ^ (pCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1;
|
||||||
|
if (pCfg->encryptAlgorithm < TSDB_MIN_ENCRYPT_ALGO || pCfg->encryptAlgorithm > TSDB_MAX_ENCRYPT_ALGO) return -1;
|
||||||
#else
|
#else
|
||||||
if (pCfg->replications != 1 && pCfg->replications != 3) return -1;
|
if (pCfg->replications != 1 && pCfg->replications != 3) return -1;
|
||||||
|
if (pCfg->encryptAlgorithm != TSDB_DEFAULT_ENCRYPT_ALGO) return -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
||||||
if (pCfg->schemaless < TSDB_DB_SCHEMALESS_OFF || pCfg->schemaless > TSDB_DB_SCHEMALESS_ON) return -1;
|
if (pCfg->schemaless < TSDB_DB_SCHEMALESS_OFF || pCfg->schemaless > TSDB_DB_SCHEMALESS_ON) return -1;
|
||||||
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||||
|
@ -544,6 +549,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->s3KeepLocal <= 0) pCfg->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
if (pCfg->s3KeepLocal <= 0) pCfg->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
if (pCfg->s3Compact <= 0) pCfg->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
if (pCfg->s3Compact <= 0) pCfg->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
if (pCfg->withArbitrator < 0) pCfg->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
if (pCfg->withArbitrator < 0) pCfg->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||||
|
if (pCfg->encryptAlgorithm < 0) pCfg->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetCreateDbPrepareAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
static int32_t mndSetCreateDbPrepareAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
@ -721,6 +727,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
||||||
.s3Compact = pCreate->s3Compact,
|
.s3Compact = pCreate->s3Compact,
|
||||||
.tsdbPageSize = pCreate->tsdbPageSize,
|
.tsdbPageSize = pCreate->tsdbPageSize,
|
||||||
.withArbitrator = pCreate->withArbitrator,
|
.withArbitrator = pCreate->withArbitrator,
|
||||||
|
.encryptAlgorithm = pCreate->encryptAlgorithm,
|
||||||
};
|
};
|
||||||
|
|
||||||
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
|
||||||
|
@ -806,6 +813,46 @@ static void mndBuildAuditDetailInt64(char *detail, char *tmp, char *format, int6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
|
||||||
|
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {
|
||||||
|
code = TSDB_CODE_MND_INVALID_ENCRYPT_KEY;
|
||||||
|
mError("db:%s, failed to check encryption key:%" PRIi8 " in mnode leader since it's not loaded", pReq->db,
|
||||||
|
tsEncryptionKeyStat);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
while ((pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode))) {
|
||||||
|
bool online = false;
|
||||||
|
if ((pDnode->encryptionKeyStat != tsEncryptionKeyStat || pDnode->encryptionKeyChksum != tsEncryptionKeyChksum) &&
|
||||||
|
(online = mndIsDnodeOnline(pDnode, curMs))) {
|
||||||
|
code = TSDB_CODE_MND_INVALID_ENCRYPT_KEY;
|
||||||
|
mError("db:%s, failed to check encryption key:%" PRIi8
|
||||||
|
"-%u in dnode:%d since it's inconsitent with mnode leader:%" PRIi8 "-%u",
|
||||||
|
pReq->db, pDnode->encryptionKeyStat, pDnode->encryptionKeyChksum, pDnode->id, tsEncryptionKeyStat,
|
||||||
|
tsEncryptionKeyChksum);
|
||||||
|
sdbRelease(pSdb, pDnode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sdbRelease(pSdb, pDnode);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pReq->encryptAlgorithm != TSDB_ENCRYPT_ALGO_NONE) {
|
||||||
|
code = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
@ -856,6 +903,11 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) {
|
||||||
|
terrno = code;
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1207,6 +1259,7 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
|
||||||
cfgRsp->s3KeepLocal = pDb->cfg.s3KeepLocal;
|
cfgRsp->s3KeepLocal = pDb->cfg.s3KeepLocal;
|
||||||
cfgRsp->s3Compact = pDb->cfg.s3Compact;
|
cfgRsp->s3Compact = pDb->cfg.s3Compact;
|
||||||
cfgRsp->withArbitrator = pDb->cfg.withArbitrator;
|
cfgRsp->withArbitrator = pDb->cfg.withArbitrator;
|
||||||
|
cfgRsp->encryptAlgorithm = pDb->cfg.encryptAlgorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
|
static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
|
||||||
|
@ -2028,6 +2081,18 @@ static const char *getCacheModelStr(int8_t cacheModel) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *getEncryptAlgorithmStr(int8_t encryptAlgorithm) {
|
||||||
|
switch (encryptAlgorithm) {
|
||||||
|
case TSDB_ENCRYPT_ALGO_NONE:
|
||||||
|
return TSDB_ENCRYPT_ALGO_NONE_STR;
|
||||||
|
case TSDB_ENCRYPT_ALGO_SM4:
|
||||||
|
return TSDB_ENCRYPT_ALGO_SM4_STR;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) {
|
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) {
|
||||||
if (pDb->cfg.replications == 1) return true;
|
if (pDb->cfg.replications == 1) return true;
|
||||||
|
|
||||||
|
@ -2248,6 +2313,12 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false);
|
colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false);
|
||||||
|
|
||||||
|
const char *encryptAlgorithmStr = getEncryptAlgorithmStr(pDb->cfg.encryptAlgorithm);
|
||||||
|
char encryptAlgorithmVStr[24] = {0};
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(encryptAlgorithmVStr, encryptAlgorithmStr, 24);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
colDataSetVal(pColInfo, rows, (const char *)encryptAlgorithmVStr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
|
|
|
@ -42,11 +42,13 @@ static const char *offlineReason[] = {
|
||||||
"version not match",
|
"version not match",
|
||||||
"dnodeId not match",
|
"dnodeId not match",
|
||||||
"clusterId not match",
|
"clusterId not match",
|
||||||
"interval not match",
|
"statusInterval not match",
|
||||||
"timezone not match",
|
"timezone not match",
|
||||||
"locale not match",
|
"locale not match",
|
||||||
"charset not match",
|
"charset not match",
|
||||||
"ttlChangeOnWrite not match",
|
"ttlChangeOnWrite not match",
|
||||||
|
"enableWhiteList not match",
|
||||||
|
"encryptionKey not match",
|
||||||
"unknown",
|
"unknown",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,6 +80,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq);
|
static int32_t mndProcessStatisReq(SRpcMsg *pReq);
|
||||||
|
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pRsp);
|
||||||
|
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp);
|
||||||
|
|
||||||
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter);
|
||||||
|
@ -114,6 +118,8 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ENCRYPT_KEY, mndProcessCreateEncryptKeyReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mndProcessCreateEncryptKeyRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
||||||
|
@ -372,7 +378,7 @@ int32_t mndGetDbSize(SMnode *pMnode) {
|
||||||
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) {
|
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) {
|
||||||
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
||||||
if (interval > 5000 * (int64_t)tsStatusInterval) {
|
if (interval > 5000 * (int64_t)tsStatusInterval) {
|
||||||
if (pDnode->rebootTime > 0) {
|
if (pDnode->rebootTime > 0 && pDnode->offlineReason == DND_REASON_ONLINE) {
|
||||||
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -436,37 +442,51 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
||||||
if (pCfg->statusInterval != tsStatusInterval) {
|
if (pCfg->statusInterval != tsStatusInterval) {
|
||||||
mError("dnode:%d, statusInterval:%d inconsistent with cluster:%d", pDnode->id, pCfg->statusInterval,
|
mError("dnode:%d, statusInterval:%d inconsistent with cluster:%d", pDnode->id, pCfg->statusInterval,
|
||||||
tsStatusInterval);
|
tsStatusInterval);
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_STATUS_INTERVAL;
|
||||||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0 != strcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
|
if ((0 != strcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||||
mError("dnode:%d, timezone:%s checkTime:%" PRId64 " inconsistent with cluster %s %" PRId64, pDnode->id,
|
mError("dnode:%d, timezone:%s checkTime:%" PRId64 " inconsistent with cluster %s %" PRId64, pDnode->id,
|
||||||
pCfg->timezone, pCfg->checkTime, tsTimezoneStr, pMnode->checkTime);
|
pCfg->timezone, pCfg->checkTime, tsTimezoneStr, pMnode->checkTime);
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_TIMEZONE;
|
||||||
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
||||||
mError("dnode:%d, locale:%s inconsistent with cluster:%s", pDnode->id, 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;
|
return DND_REASON_LOCALE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
||||||
mError("dnode:%d, charset:%s inconsistent with cluster:%s", pDnode->id, 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;
|
return DND_REASON_CHARSET_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCfg->ttlChangeOnWrite != tsTtlChangeOnWrite) {
|
if (pCfg->ttlChangeOnWrite != tsTtlChangeOnWrite) {
|
||||||
mError("dnode:%d, ttlChangeOnWrite:%d inconsistent with cluster:%d", pDnode->id, pCfg->ttlChangeOnWrite,
|
mError("dnode:%d, ttlChangeOnWrite:%d inconsistent with cluster:%d", pDnode->id, pCfg->ttlChangeOnWrite,
|
||||||
tsTtlChangeOnWrite);
|
tsTtlChangeOnWrite);
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_TTL_CHG_ON_WR;
|
||||||
return DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH;
|
return DND_REASON_TTL_CHANGE_ON_WRITE_NOT_MATCH;
|
||||||
}
|
}
|
||||||
int8_t enable = tsEnableWhiteList ? 1 : 0;
|
int8_t enable = tsEnableWhiteList ? 1 : 0;
|
||||||
if (pCfg->enableWhiteList != enable) {
|
if (pCfg->enableWhiteList != enable) {
|
||||||
mError("dnode:%d, enable :%d inconsistent with cluster:%d", pDnode->id, pCfg->enableWhiteList, enable);
|
mError("dnode:%d, enableWhiteList:%d inconsistent with cluster:%d", pDnode->id, pCfg->enableWhiteList, enable);
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_EN_WHITELIST;
|
||||||
return DND_REASON_ENABLE_WHITELIST_NOT_MATCH;
|
return DND_REASON_ENABLE_WHITELIST_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (!atomic_load_8(&pMnode->encryptMgmt.encrypting) &&
|
||||||
|
(pCfg->encryptionKeyStat != tsEncryptionKeyStat || pCfg->encryptionKeyChksum != tsEncryptionKeyChksum)) {
|
||||||
|
mError("dnode:%d, encryptionKey:%" PRIi8 "-%u inconsistent with cluster:%" PRIi8 "-%u", pDnode->id,
|
||||||
|
pCfg->encryptionKeyStat, pCfg->encryptionKeyChksum, tsEncryptionKeyStat, tsEncryptionKeyChksum);
|
||||||
|
terrno = pCfg->encryptionKeyChksum ? TSDB_CODE_DNODE_INVALID_ENCRYPTKEY : TSDB_CODE_DNODE_NO_ENCRYPT_KEY;
|
||||||
|
return DND_REASON_ENCRYPTION_KEY_NOT_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DND_REASON_ONLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndUpdateVnodeState(int32_t vgId, SVnodeGid *pGid, SVnodeLoad *pVload) {
|
static bool mndUpdateVnodeState(int32_t vgId, SVnodeGid *pGid, SVnodeLoad *pVload) {
|
||||||
|
@ -795,8 +815,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||||
bool needCheck =
|
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
|
||||||
!online || dnodeChanged || reboot || supportVnodesChanged || pMnode->ipWhiteVer != statusReq.ipWhiteVer;
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
|
||||||
|
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged;
|
||||||
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
@ -891,7 +912,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pDnode->offlineReason = mndCheckClusterCfgPara(pMnode, pDnode, &statusReq.clusterCfg);
|
pDnode->offlineReason = mndCheckClusterCfgPara(pMnode, pDnode, &statusReq.clusterCfg);
|
||||||
if (pDnode->offlineReason != 0) {
|
if (pDnode->offlineReason != 0) {
|
||||||
mError("dnode:%d, cluster cfg inconsistent since:%s", pDnode->id, offlineReason[pDnode->offlineReason]);
|
mError("dnode:%d, cluster cfg inconsistent since:%s", pDnode->id, offlineReason[pDnode->offlineReason]);
|
||||||
terrno = TSDB_CODE_MND_INVALID_CLUSTER_CFG;
|
if (terrno == 0) terrno = TSDB_CODE_MND_INVALID_CLUSTER_CFG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,6 +930,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
pDnode->numOfDiskCfg = statusReq.numOfDiskCfg;
|
pDnode->numOfDiskCfg = statusReq.numOfDiskCfg;
|
||||||
pDnode->memAvail = statusReq.memAvail;
|
pDnode->memAvail = statusReq.memAvail;
|
||||||
pDnode->memTotal = statusReq.memTotal;
|
pDnode->memTotal = statusReq.memTotal;
|
||||||
|
pDnode->encryptionKeyStat = statusReq.clusterCfg.encryptionKeyStat;
|
||||||
|
pDnode->encryptionKeyChksum = statusReq.clusterCfg.encryptionKeyChksum;
|
||||||
if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) {
|
if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) {
|
||||||
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||||
mndUpdateDnodeObj(pMnode, pDnode);
|
mndUpdateDnodeObj(pMnode, pDnode);
|
||||||
|
@ -1494,6 +1517,136 @@ static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
void *pIter = NULL;
|
||||||
|
int8_t encrypting = 0;
|
||||||
|
|
||||||
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
|
|
||||||
|
int32_t klen = strlen(pDcfgReq->value);
|
||||||
|
if (klen > ENCRYPT_KEY_LEN || klen < ENCRYPT_KEY_LEN_MIN) {
|
||||||
|
code = TSDB_CODE_DNODE_INVALID_ENCRYPT_KLEN;
|
||||||
|
mGError("msg:%p, failed to create encrypt_key since invalid key length:%d, valid range:[%d, %d]", pReq, klen,
|
||||||
|
ENCRYPT_KEY_LEN_MIN, ENCRYPT_KEY_LEN);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != (encrypting = atomic_val_compare_exchange_8(&pMnode->encryptMgmt.encrypting, 0, 1))) {
|
||||||
|
code = TSDB_CODE_QRY_DUPLICATED_OPERATION;
|
||||||
|
mGWarn("msg:%p, failed to create encrypt key since %s, encrypting:%" PRIi8, pReq, tstrerror(code), encrypting);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsEncryptionKeyStat == ENCRYPT_KEY_STAT_SET || tsEncryptionKeyStat == ENCRYPT_KEY_STAT_LOADED) {
|
||||||
|
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||||
|
code = TSDB_CODE_QRY_DUPLICATED_OPERATION;
|
||||||
|
mGWarn("msg:%p, failed to create encrypt key since %s, stat:%" PRIi8 ", checksum:%u", pReq, tstrerror(code),
|
||||||
|
tsEncryptionKeyStat, tsEncryptionKeyChksum);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic_store_16(&pMnode->encryptMgmt.nEncrypt, 0);
|
||||||
|
atomic_store_16(&pMnode->encryptMgmt.nSuccess, 0);
|
||||||
|
atomic_store_16(&pMnode->encryptMgmt.nFailed, 0);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
if (pDnode->offlineReason != DND_REASON_ONLINE) {
|
||||||
|
mGWarn("msg:%p, don't send create encrypt_key req since dnode:%d in offline state:%s", pReq, pDnode->id,
|
||||||
|
offlineReason[pDnode->offlineReason]);
|
||||||
|
sdbRelease(pSdb, pDnode);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dnodeId == -1 || pDnode->id == dnodeId || dnodeId == 0) {
|
||||||
|
SEpSet epSet = mndGetDnodeEpset(pDnode);
|
||||||
|
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
|
||||||
|
void *pBuf = rpcMallocCont(bufLen);
|
||||||
|
|
||||||
|
if (pBuf != NULL) {
|
||||||
|
tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||||
|
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen};
|
||||||
|
if (0 == tmsgSendReq(&epSet, &rpcMsg)) {
|
||||||
|
atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pDnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atomic_load_16(&pMnode->encryptMgmt.nEncrypt) <= 0) {
|
||||||
|
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
if (code != 0) {
|
||||||
|
if (terrno == 0) terrno = code;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
SMCfgDnodeReq cfgReq = {0};
|
||||||
|
if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE) != 0) {
|
||||||
|
tFreeSMCfgDnodeReq(&cfgReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
|
SDCfgDnodeReq dcfgReq = {0};
|
||||||
|
if (strncasecmp(cfgReq.config, "encrypt_key", 12) == 0) {
|
||||||
|
strcpy(dcfgReq.config, cfgReq.config);
|
||||||
|
strcpy(dcfgReq.value, cfgReq.value);
|
||||||
|
tFreeSMCfgDnodeReq(&cfgReq);
|
||||||
|
return mndProcessCreateEncryptKeyReqImpl(pReq, cfgReq.dnodeId, &dcfgReq);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
|
tFreeSMCfgDnodeReq(&cfgReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp) {
|
||||||
|
SMnode *pMnode = pRsp->info.node;
|
||||||
|
int16_t nSuccess = 0;
|
||||||
|
int16_t nFailed = 0;
|
||||||
|
|
||||||
|
if (0 == pRsp->code) {
|
||||||
|
nSuccess = atomic_add_fetch_16(&pMnode->encryptMgmt.nSuccess, 1);
|
||||||
|
} else {
|
||||||
|
nFailed = atomic_add_fetch_16(&pMnode->encryptMgmt.nFailed, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t nReq = atomic_load_16(&pMnode->encryptMgmt.nEncrypt);
|
||||||
|
bool finished = nSuccess + nFailed >= nReq;
|
||||||
|
|
||||||
|
if (finished) {
|
||||||
|
atomic_store_8(&pMnode->encryptMgmt.encrypting, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const STraceId *trace = &pRsp->info.traceId;
|
||||||
|
mGInfo("msg:%p, create encrypt key rsp, nReq:%" PRIi16 ", nSucess:%" PRIi16 ", nFailed:%" PRIi16 ", %s", pRsp, nReq,
|
||||||
|
nSuccess, nFailed, finished ? "encrypt done" : "in encrypting");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveConfigs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t totalRows = 0;
|
int32_t totalRows = 0;
|
||||||
|
@ -1550,7 +1703,7 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
ESdbStatus objStatus = 0;
|
ESdbStatus objStatus = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
char buf[TSDB_CONN_ACTIVE_KEY_LEN + VARSTR_HEADER_SIZE]; // make sure TSDB_CONN_ACTIVE_KEY_LEN >= TSDB_EP_LEN
|
char buf[TSDB_EP_LEN + VARSTR_HEADER_SIZE];
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = sdbFetchAll(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode, &objStatus, true);
|
pShow->pIter = sdbFetchAll(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode, &objStatus, true);
|
||||||
|
|
|
@ -104,6 +104,7 @@ void dumpDb(SSdb *pSdb, SJson *json) {
|
||||||
tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows));
|
tjsonAddStringToObject(item, "maxRows", i642str(pObj->cfg.maxRows));
|
||||||
tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision));
|
tjsonAddStringToObject(item, "precision", i642str(pObj->cfg.precision));
|
||||||
tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
|
tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
|
||||||
|
tjsonAddStringToObject(item, "encryptAlgorithm", i642str(pObj->cfg.encryptAlgorithm));
|
||||||
tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
|
tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
|
||||||
tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
|
tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
|
||||||
tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
|
tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
|
||||||
|
|
|
@ -58,6 +58,7 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
static int32_t mndRetrieveGrantLogs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
static int32_t mndRetrieveMachines(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
|
static int32_t mndRetrieveEncryptions(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||||
|
|
||||||
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
|
@ -66,6 +67,7 @@ int32_t mndInitGrant(SMnode *pMnode) {
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOGS, mndRetrieveGrantLogs);
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MACHINES, mndRetrieveMachines);
|
||||||
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ENCRYPTIONS, mndRetrieveEncryptions);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,8 +485,23 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
||||||
.retentionPeriod = 0,
|
.retentionPeriod = 0,
|
||||||
.retentionSize = 0,
|
.retentionSize = 0,
|
||||||
.level = TAOS_WAL_FSYNC,
|
.level = TAOS_WAL_FSYNC,
|
||||||
|
.encryptAlgorithm = 0,
|
||||||
|
.encryptKey = {0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
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'){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pMnode->pWal = walOpen(path, &cfg);
|
pMnode->pWal = walOpen(path, &cfg);
|
||||||
if (pMnode->pWal == NULL) {
|
if (pMnode->pWal == NULL) {
|
||||||
mError("failed to open wal since %s. wal:%s", terrstr(), path);
|
mError("failed to open wal since %s. wal:%s", terrstr(), path);
|
||||||
|
|
|
@ -131,6 +131,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
||||||
type = TSDB_MGMT_TABLE_GRANTS_LOGS;
|
type = TSDB_MGMT_TABLE_GRANTS_LOGS;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_MACHINES;
|
type = TSDB_MGMT_TABLE_MACHINES;
|
||||||
|
} else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
|
||||||
|
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
|
||||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
} else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) {
|
||||||
type = TSDB_MGMT_TABLE_TSMAS;
|
type = TSDB_MGMT_TABLE_TSMAS;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -657,7 +657,9 @@ _OVER:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkForNumOfStreams(SMnode *pMnode, SStreamObj *pStreamObj) { // check for number of existed tasks
|
// 1. stream number check
|
||||||
|
// 2. target stable can not be target table of other existed streams.
|
||||||
|
static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
||||||
int32_t numOfStream = 0;
|
int32_t numOfStream = 0;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -670,14 +672,16 @@ static int32_t checkForNumOfStreams(SMnode *pMnode, SStreamObj *pStreamObj) { /
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
|
||||||
if (numOfStream > MND_STREAM_MAX_NUM) {
|
if (numOfStream > MND_STREAM_MAX_NUM) {
|
||||||
mError("too many streams, no more than %d for each database", MND_STREAM_MAX_NUM);
|
mError("too many streams, no more than %d for each database, failed to create stream:%s", MND_STREAM_MAX_NUM,
|
||||||
|
pStreamObj->name);
|
||||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
|
terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStream->targetStbUid == pStreamObj->targetStbUid) {
|
if (pStream->targetStbUid == pStreamObj->targetStbUid) {
|
||||||
mError("Cannot write the same stable as other stream:%s", pStream->name);
|
mError("Cannot write the same stable as other stream:%s, failed to create stream:%s", pStream->name,
|
||||||
|
pStreamObj->name);
|
||||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
terrno = TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
terrno = TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -742,7 +746,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkForNumOfStreams(pMnode, &streamObj) < 0) {
|
if (doStreamCheck(pMnode, &streamObj) < 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,7 +982,6 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
int64_t ts = taosGetTimestampMs();
|
int64_t ts = taosGetTimestampMs();
|
||||||
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
||||||
// mWarn("checkpoint interval less than the threshold, ignore it");
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,6 +1399,15 @@ int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void int64ToHexStr(int64_t id, char *pBuf, int32_t bufLen) {
|
||||||
|
memset(pBuf, 0, bufLen);
|
||||||
|
pBuf[2] = '0';
|
||||||
|
pBuf[3] = 'x';
|
||||||
|
|
||||||
|
int32_t len = tintToHex(id, &pBuf[4]);
|
||||||
|
varDataSetLen(pBuf, len + 2);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -1420,19 +1432,14 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
|
|
||||||
// stream id
|
// stream id
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
int32_t len = tintToHex(pStream->uid, &buf[4]);
|
int64ToHexStr(pStream->uid, buf, tListLen(buf));
|
||||||
buf[2] = '0';
|
|
||||||
buf[3] = 'x';
|
|
||||||
varDataSetLen(buf, len + 2);
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
|
|
||||||
// related fill-history stream id
|
// related fill-history stream id
|
||||||
memset(buf, 0, tListLen(buf));
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
if (pStream->hTaskUid != 0) {
|
if (pStream->hTaskUid != 0) {
|
||||||
len = tintToHex(pStream->hTaskUid, &buf[4]);
|
int64ToHexStr(pStream->hTaskUid, buf, tListLen(buf));
|
||||||
varDataSetLen(buf, len + 2);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||||
} else {
|
} else {
|
||||||
colDataSetVal(pColInfo, numOfRows, buf, true);
|
colDataSetVal(pColInfo, numOfRows, buf, true);
|
||||||
|
@ -1531,11 +1538,8 @@ static int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SS
|
||||||
// task id
|
// task id
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
||||||
char idstr[128] = {0};
|
char idstr[128] = {0};
|
||||||
int32_t len = tintToHex(pTask->id.taskId, &idstr[4]);
|
int64ToHexStr(pTask->id.taskId, idstr, tListLen(idstr));
|
||||||
idstr[2] = '0';
|
|
||||||
idstr[3] = 'x';
|
|
||||||
varDataSetLen(idstr, len + 2);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||||
|
|
||||||
// node type
|
// node type
|
||||||
|
@ -1651,11 +1655,7 @@ static int32_t setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SS
|
||||||
// history_task_id
|
// history_task_id
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
if (pe->hTaskId != 0) {
|
if (pe->hTaskId != 0) {
|
||||||
memset(idstr, 0, tListLen(idstr));
|
int64ToHexStr(pe->hTaskId, idstr, tListLen(idstr));
|
||||||
len = tintToHex(pe->hTaskId, &idstr[4]);
|
|
||||||
idstr[2] = '0';
|
|
||||||
idstr[3] = 'x';
|
|
||||||
varDataSetLen(idstr, len + 2);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
colDataSetVal(pColInfo, numOfRows, idstr, false);
|
||||||
} else {
|
} else {
|
||||||
colDataSetVal(pColInfo, numOfRows, 0, true);
|
colDataSetVal(pColInfo, numOfRows, 0, true);
|
||||||
|
@ -2029,7 +2029,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to build the trans to handle the vgroup upddate
|
// no need to build the trans to handle the vgroup update
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
|
||||||
|
|
||||||
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
int32_t numOfUpdated = taosArrayGetSize(req.pUpdateNodes);
|
||||||
if (numOfUpdated > 0) {
|
if (numOfUpdated > 0) {
|
||||||
mDebug("%d stream node(s) need updated from report of hbMsg(vgId:%d)", numOfUpdated, req.vgId);
|
mDebug("%d stream node(s) need updated from hbMsg(vgId:%d)", numOfUpdated, req.vgId);
|
||||||
setNodeEpsetExpiredFlag(req.pUpdateNodes);
|
setNodeEpsetExpiredFlag(req.pUpdateNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
||||||
createReq.hashSuffix = pDb->cfg.hashSuffix;
|
createReq.hashSuffix = pDb->cfg.hashSuffix;
|
||||||
createReq.tsdbPageSize = pDb->cfg.tsdbPageSize;
|
createReq.tsdbPageSize = pDb->cfg.tsdbPageSize;
|
||||||
createReq.changeVersion = ++(pVgroup->syncConfChangeVer);
|
createReq.changeVersion = ++(pVgroup->syncConfChangeVer);
|
||||||
|
createReq.encryptAlgorithm = pDb->cfg.encryptAlgorithm;
|
||||||
|
|
||||||
for (int32_t v = 0; v < pVgroup->replica; ++v) {
|
for (int32_t v = 0; v < pVgroup->replica; ++v) {
|
||||||
SReplica *pReplica = NULL;
|
SReplica *pReplica = NULL;
|
||||||
|
|
|
@ -5,5 +5,5 @@ target_include_directories(
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
sdb os common util wal sync
|
sdb os common util wal sync crypt
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "crypt.h"
|
||||||
|
|
||||||
#define SDB_TABLE_SIZE 24
|
#define SDB_TABLE_SIZE 24
|
||||||
#define SDB_RESERVE_SIZE 512
|
#define SDB_RESERVE_SIZE 512
|
||||||
|
@ -276,6 +278,9 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
readLen = pRaw->dataLen + sizeof(int32_t);
|
readLen = pRaw->dataLen + sizeof(int32_t);
|
||||||
|
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||||
|
readLen = ENCRYPTED_LEN(pRaw->dataLen) + sizeof(int32_t);
|
||||||
|
}
|
||||||
if (readLen >= bufLen) {
|
if (readLen >= bufLen) {
|
||||||
bufLen = pRaw->dataLen * 2;
|
bufLen = pRaw->dataLen * 2;
|
||||||
SSdbRaw *pNewRaw = taosMemoryMalloc(bufLen + 100);
|
SSdbRaw *pNewRaw = taosMemoryMalloc(bufLen + 100);
|
||||||
|
@ -303,6 +308,27 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||||
|
int32_t count = 0;
|
||||||
|
|
||||||
|
char *plantContent = taosMemoryMalloc(ENCRYPTED_LEN(pRaw->dataLen));
|
||||||
|
|
||||||
|
SCryptOpts opts;
|
||||||
|
opts.len = ENCRYPTED_LEN(pRaw->dataLen);
|
||||||
|
opts.source = pRaw->pData;
|
||||||
|
opts.result = plantContent;
|
||||||
|
opts.unitLen = 16;
|
||||||
|
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
|
||||||
|
count = CBC_Decrypt(&opts);
|
||||||
|
|
||||||
|
//mDebug("read sdb, CBC_Decrypt dataLen:%d, descrypted len:%d, %s", pRaw->dataLen, count, __FUNCTION__);
|
||||||
|
|
||||||
|
memcpy(pRaw->pData, plantContent, pRaw->dataLen);
|
||||||
|
taosMemoryFree(plantContent);
|
||||||
|
memcpy(pRaw->pData + pRaw->dataLen, &pRaw->pData[ENCRYPTED_LEN(pRaw->dataLen)], sizeof(int32_t));
|
||||||
|
}
|
||||||
|
|
||||||
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t);
|
||||||
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) {
|
||||||
code = TSDB_CODE_CHECKSUM_ERROR;
|
code = TSDB_CODE_CHECKSUM_ERROR;
|
||||||
|
@ -401,14 +427,50 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
SSdbRaw *pRaw = (*encodeFp)(pRow->pObj);
|
SSdbRaw *pRaw = (*encodeFp)(pRow->pObj);
|
||||||
if (pRaw != NULL) {
|
if (pRaw != NULL) {
|
||||||
pRaw->status = pRow->status;
|
pRaw->status = pRow->status;
|
||||||
int32_t writeLen = sizeof(SSdbRaw) + pRaw->dataLen;
|
|
||||||
if (taosWriteFile(pFile, pRaw, writeLen) != writeLen) {
|
if (taosWriteFile(pFile, pRaw, sizeof(SSdbRaw)) != sizeof(SSdbRaw)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
taosHashCancelIterate(hash, ppRow);
|
taosHashCancelIterate(hash, ppRow);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t newDataLen = pRaw->dataLen;
|
||||||
|
char* newData = pRaw->pData;
|
||||||
|
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||||
|
newDataLen = ENCRYPTED_LEN(pRaw->dataLen);
|
||||||
|
newData = taosMemoryMalloc(newDataLen);
|
||||||
|
if (newData == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosHashCancelIterate(hash, ppRow);
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCryptOpts opts;
|
||||||
|
opts.len = newDataLen;
|
||||||
|
opts.source = pRaw->pData;
|
||||||
|
opts.result = newData;
|
||||||
|
opts.unitLen = 16;
|
||||||
|
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
|
||||||
|
int32_t count = CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
//mDebug("write sdb, CBC_Encrypt encryptedDataLen:%d, dataLen:%d, %s",
|
||||||
|
// newDataLen, pRaw->dataLen, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosWriteFile(pFile, newData, newDataLen) != newDataLen) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
taosHashCancelIterate(hash, ppRow);
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_SDB) == DND_CS_SDB ){
|
||||||
|
taosMemoryFree(newData);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
|
@ -58,17 +58,7 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer
|
||||||
streamSetupScheduleTrigger(pTask);
|
streamSetupScheduleTrigger(pTask);
|
||||||
|
|
||||||
SCheckpointInfo *pChkInfo = &pTask->chkInfo;
|
SCheckpointInfo *pChkInfo = &pTask->chkInfo;
|
||||||
|
tqSetRestoreVersionInfo(pTask);
|
||||||
// checkpoint ver is the kept version, handled data should be the next version.
|
|
||||||
if (pChkInfo->checkpointId != 0) {
|
|
||||||
pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1;
|
|
||||||
pChkInfo->processedVer = pChkInfo->checkpointVer;
|
|
||||||
pTask->execInfo.startCheckpointVer = pChkInfo->nextProcessVer;
|
|
||||||
pTask->execInfo.startCheckpointId = pChkInfo->checkpointId;
|
|
||||||
|
|
||||||
sndInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " nextProcessVer:%" PRId64,
|
|
||||||
pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* p = streamTaskGetStatus(pTask)->name;
|
char* p = streamTaskGetStatus(pTask)->name;
|
||||||
if (pTask->info.fillHistory) {
|
if (pTask->info.fillHistory) {
|
||||||
|
|
|
@ -121,6 +121,7 @@ if (${BUILD_CONTRIB})
|
||||||
PUBLIC "inc"
|
PUBLIC "inc"
|
||||||
PUBLIC "src/inc"
|
PUBLIC "src/inc"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/contrib/rocksdb/include"
|
PUBLIC "${TD_SOURCE_DIR}/contrib/rocksdb/include"
|
||||||
)
|
)
|
||||||
|
@ -130,6 +131,7 @@ else()
|
||||||
PUBLIC "inc"
|
PUBLIC "inc"
|
||||||
PUBLIC "src/inc"
|
PUBLIC "src/inc"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/vnode"
|
||||||
)
|
)
|
||||||
if (${TD_LINUX})
|
if (${TD_LINUX})
|
||||||
|
@ -162,6 +164,7 @@ target_link_libraries(
|
||||||
PUBLIC scheduler
|
PUBLIC scheduler
|
||||||
PUBLIC tdb
|
PUBLIC tdb
|
||||||
PUBLIC audit
|
PUBLIC audit
|
||||||
|
PUBLIC crypt
|
||||||
|
|
||||||
# PUBLIC bdb
|
# PUBLIC bdb
|
||||||
# PUBLIC scalar
|
# PUBLIC scalar
|
||||||
|
|
|
@ -278,6 +278,8 @@ struct STsdbCfg {
|
||||||
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
||||||
int32_t keepTimeOffset; // just for save config, use STsdbKeepCfg in STsdb instead
|
int32_t keepTimeOffset; // just for save config, use STsdbKeepCfg in STsdb instead
|
||||||
SRetention retentions[TSDB_RETENTION_MAX];
|
SRetention retentions[TSDB_RETENTION_MAX];
|
||||||
|
int32_t encryptAlgorithm;
|
||||||
|
char encryptKey[ENCRYPT_KEY_LEN + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -319,6 +321,8 @@ struct SVnodeCfg {
|
||||||
int16_t hashPrefix;
|
int16_t hashPrefix;
|
||||||
int16_t hashSuffix;
|
int16_t hashSuffix;
|
||||||
int32_t tsdbPageSize;
|
int32_t tsdbPageSize;
|
||||||
|
int32_t tdbEncryptAlgorithm;
|
||||||
|
char tdbEncryptKey[ENCRYPT_KEY_LEN];
|
||||||
int32_t s3ChunkSize;
|
int32_t s3ChunkSize;
|
||||||
int32_t s3KeepLocal;
|
int32_t s3KeepLocal;
|
||||||
int8_t s3Compact;
|
int8_t s3Compact;
|
||||||
|
|
|
@ -119,8 +119,8 @@ int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t
|
||||||
|
|
||||||
// tqExec
|
// tqExec
|
||||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded);
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision);
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||||
int32_t type, int32_t vgId);
|
int32_t type, int32_t vgId);
|
||||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||||
|
|
||||||
|
@ -154,9 +154,9 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname);
|
||||||
// tq util
|
// tq util
|
||||||
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void** pRefBlock, int32_t type);
|
||||||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
||||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp, int32_t epoch, int64_t consumerId,
|
||||||
int32_t type, int64_t sver, int64_t ever);
|
int32_t type, int64_t sver, int64_t ever);
|
||||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset);
|
||||||
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
void tqUpdateNodeStage(STQ* pTq, bool isLeader);
|
||||||
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock,
|
||||||
SSubmitTbData* pTableData, const char* id);
|
SSubmitTbData* pTableData, const char* id);
|
||||||
|
|
|
@ -31,21 +31,21 @@ int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||||
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
|
int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) {
|
||||||
SColCmprWrapper *pWrapper = &pME->colCmpr;
|
SColCmprWrapper *pWrapper = &pME->colCmpr;
|
||||||
if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1;
|
||||||
|
if (pWrapper->nCols == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1;
|
if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1;
|
||||||
uDebug("dencode cols:%d", pWrapper->nCols);
|
uDebug("dencode cols:%d", pWrapper->nCols);
|
||||||
|
|
||||||
pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
|
pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr));
|
||||||
if (pWrapper->pColCmpr == NULL) return -1;
|
if (pWrapper->pColCmpr == NULL) return -1;
|
||||||
|
|
||||||
for (int i = 0; i < pWrapper->nCols; i++) {
|
for (int i = 0; i < pWrapper->nCols; i++) {
|
||||||
SColCmpr *p = &pWrapper->pColCmpr[i];
|
SColCmpr *p = &pWrapper->pColCmpr[i];
|
||||||
if (tDecodeI16v(pDecoder, &p->id) < 0) goto END;
|
if (tDecodeI16v(pDecoder, &p->id) < 0) return -1;
|
||||||
if (tDecodeU32(pDecoder, &p->alg) < 0) goto END;
|
if (tDecodeU32(pDecoder, &p->alg) < 0) return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
END:
|
|
||||||
// taosMemoryFree(pWrapper->pColCmpr);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
|
static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr,
|
||||||
SSchemaWrapper *pSchema) {
|
SSchemaWrapper *pSchema) {
|
||||||
|
@ -149,17 +149,29 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||||
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!tDecodeIsEnd(pCoder)) {
|
if (pME->type == TSDB_SUPER_TABLE) {
|
||||||
uDebug("set type: %d, tableName:%s", pME->type, pME->name);
|
if (TABLE_IS_COL_COMPRESSED(pME->flags)) {
|
||||||
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||||
TABLE_SET_COL_COMPRESSED(pME->flags);
|
|
||||||
} else {
|
if (pME->colCmpr.nCols == 0) {
|
||||||
uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
|
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
||||||
if (pME->type == TSDB_SUPER_TABLE) {
|
}
|
||||||
|
} else {
|
||||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow);
|
||||||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||||
|
}
|
||||||
|
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||||
|
if (!tDecodeIsEnd(pCoder)) {
|
||||||
|
uDebug("set type: %d, tableName:%s", pME->type, pME->name);
|
||||||
|
if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1;
|
||||||
|
if (pME->colCmpr.nCols == 0) {
|
||||||
|
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uDebug("set default type: %d, tableName:%s", pME->type, pME->name);
|
||||||
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow);
|
||||||
}
|
}
|
||||||
|
TABLE_SET_COL_COMPRESSED(pME->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(pCoder);
|
tEndDecode(pCoder);
|
||||||
|
|
|
@ -69,7 +69,8 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||||
taosMkDir(pMeta->path);
|
taosMkDir(pMeta->path);
|
||||||
|
|
||||||
// open env
|
// open env
|
||||||
ret = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback);
|
ret = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback,
|
||||||
|
pVnode->config.tdbEncryptAlgorithm, pVnode->config.tdbEncryptKey);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId:%d, failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d, failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -109,7 +109,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
|
||||||
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
|
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void * data = pCtbEntry->ctbEntry.pTags;
|
void *data = pCtbEntry->ctbEntry.pTags;
|
||||||
const char *tagName = pSchema->name;
|
const char *tagName = pSchema->name;
|
||||||
|
|
||||||
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
||||||
|
@ -128,7 +128,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
|
||||||
STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
|
STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
|
||||||
char type = pTagVal->type;
|
char type = pTagVal->type;
|
||||||
|
|
||||||
char * key = pTagVal->pKey;
|
char *key = pTagVal->pKey;
|
||||||
int32_t nKey = strlen(key);
|
int32_t nKey = strlen(key);
|
||||||
|
|
||||||
SIndexTerm *term = NULL;
|
SIndexTerm *term = NULL;
|
||||||
|
@ -136,7 +136,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
|
||||||
term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
|
term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
|
||||||
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
if (pTagVal->nData > 0) {
|
if (pTagVal->nData > 0) {
|
||||||
char * val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
|
char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE);
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE);
|
||||||
memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
|
memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
|
||||||
type = TSDB_DATA_TYPE_VARCHAR;
|
type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
@ -170,7 +170,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
||||||
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
|
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void * data = pCtbEntry->ctbEntry.pTags;
|
void *data = pCtbEntry->ctbEntry.pTags;
|
||||||
const char *tagName = pSchema->name;
|
const char *tagName = pSchema->name;
|
||||||
|
|
||||||
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
||||||
|
@ -189,7 +189,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
||||||
STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
|
STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
|
||||||
char type = pTagVal->type;
|
char type = pTagVal->type;
|
||||||
|
|
||||||
char * key = pTagVal->pKey;
|
char *key = pTagVal->pKey;
|
||||||
int32_t nKey = strlen(key);
|
int32_t nKey = strlen(key);
|
||||||
|
|
||||||
SIndexTerm *term = NULL;
|
SIndexTerm *term = NULL;
|
||||||
|
@ -197,7 +197,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
|
||||||
term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
|
term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0);
|
||||||
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
if (pTagVal->nData > 0) {
|
if (pTagVal->nData > 0) {
|
||||||
char * val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
|
char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE);
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE);
|
||||||
memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
|
memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
|
||||||
type = TSDB_DATA_TYPE_VARCHAR;
|
type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
@ -244,9 +244,9 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
const void *pKey = NULL;
|
const void *pKey = NULL;
|
||||||
const void *pVal = NULL;
|
const void *pVal = NULL;
|
||||||
void * pBuf = NULL;
|
void *pBuf = NULL;
|
||||||
int32_t szBuf = 0;
|
int32_t szBuf = 0;
|
||||||
void * p = NULL;
|
void *p = NULL;
|
||||||
|
|
||||||
// validate req
|
// validate req
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
|
@ -274,8 +274,6 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
me.name = pReq->name;
|
me.name = pReq->name;
|
||||||
me.stbEntry.schemaRow = pReq->schemaRow;
|
me.stbEntry.schemaRow = pReq->schemaRow;
|
||||||
me.stbEntry.schemaTag = pReq->schemaTag;
|
me.stbEntry.schemaTag = pReq->schemaTag;
|
||||||
// me.stbEntry.colCmpr = pReq->colCmpr;
|
|
||||||
// me.stbEntry.colCmpr = pReq->
|
|
||||||
if (pReq->rollup) {
|
if (pReq->rollup) {
|
||||||
TABLE_SET_ROLLUP(me.flags);
|
TABLE_SET_ROLLUP(me.flags);
|
||||||
me.stbEntry.rsmaParam = pReq->rsmaParam;
|
me.stbEntry.rsmaParam = pReq->rsmaParam;
|
||||||
|
@ -283,10 +281,6 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
if (pReq->colCmpred) {
|
if (pReq->colCmpred) {
|
||||||
TABLE_SET_COL_COMPRESSED(me.flags);
|
TABLE_SET_COL_COMPRESSED(me.flags);
|
||||||
me.colCmpr = pReq->colCmpr;
|
me.colCmpr = pReq->colCmpr;
|
||||||
} else {
|
|
||||||
TABLE_SET_COL_COMPRESSED(me.flags);
|
|
||||||
// TODO(yihao)
|
|
||||||
// SETUP default compress algr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||||
|
@ -385,7 +379,7 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
void *pKey = NULL;
|
void *pKey = NULL;
|
||||||
int nKey = 0;
|
int nKey = 0;
|
||||||
TBC * pCtbIdxc = NULL;
|
TBC *pCtbIdxc = NULL;
|
||||||
|
|
||||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
|
@ -416,8 +410,8 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
SMetaEntry oStbEntry = {0};
|
SMetaEntry oStbEntry = {0};
|
||||||
SMetaEntry nStbEntry = {0};
|
SMetaEntry nStbEntry = {0};
|
||||||
TBC * pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
TBC * pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
const void *pData;
|
const void *pData;
|
||||||
int nData;
|
int nData;
|
||||||
int64_t oversion;
|
int64_t oversion;
|
||||||
|
@ -484,7 +478,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
bool updStat = deltaCol != 0 && !metaTbInFilterCache(pMeta, pReq->name, 1);
|
bool updStat = deltaCol != 0 && !metaTbInFilterCache(pMeta, pReq->name, 1);
|
||||||
|
|
||||||
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
|
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
|
||||||
STsdb * pTsdb = pMeta->pVnode->pTsdb;
|
STsdb *pTsdb = pMeta->pVnode->pTsdb;
|
||||||
SArray *uids = taosArrayInit(8, sizeof(int64_t));
|
SArray *uids = taosArrayInit(8, sizeof(int64_t));
|
||||||
if (deltaCol == 1) {
|
if (deltaCol == 1) {
|
||||||
int16_t cid = pReq->schemaRow.pSchema[nCols - 1].colId;
|
int16_t cid = pReq->schemaRow.pSchema[nCols - 1].colId;
|
||||||
|
@ -554,9 +548,9 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
STbDbKey tbDbKey = {0};
|
STbDbKey tbDbKey = {0};
|
||||||
|
|
||||||
TBC * pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
TBC * pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int64_t oversion;
|
int64_t oversion;
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
@ -710,11 +704,11 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
SMetaEntry nStbEntry = {0};
|
SMetaEntry nStbEntry = {0};
|
||||||
|
|
||||||
STbDbKey tbDbKey = {0};
|
STbDbKey tbDbKey = {0};
|
||||||
TBC * pUidIdxc = NULL;
|
TBC *pUidIdxc = NULL;
|
||||||
TBC * pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int c = -2;
|
int c = -2;
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int64_t oversion;
|
int64_t oversion;
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
@ -817,8 +811,8 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
nStbEntry.uid = oStbEntry.uid;
|
nStbEntry.uid = oStbEntry.uid;
|
||||||
nStbEntry.name = oStbEntry.name;
|
nStbEntry.name = oStbEntry.name;
|
||||||
|
|
||||||
SSchemaWrapper * row = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaRow);
|
SSchemaWrapper *row = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaRow);
|
||||||
SSchemaWrapper * tag = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaTag);
|
SSchemaWrapper *tag = tCloneSSchemaWrapper(&oStbEntry.stbEntry.schemaTag);
|
||||||
SColCmprWrapper *cmpr = tCloneSColCmprWrapper(&oStbEntry.colCmpr);
|
SColCmprWrapper *cmpr = tCloneSColCmprWrapper(&oStbEntry.colCmpr);
|
||||||
|
|
||||||
nStbEntry.stbEntry.schemaRow = *row;
|
nStbEntry.stbEntry.schemaRow = *row;
|
||||||
|
@ -999,7 +993,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids, tb_uid_t *tbUid) {
|
int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids, tb_uid_t *tbUid) {
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
tb_uid_t uid = 0;
|
tb_uid_t uid = 0;
|
||||||
|
@ -1078,10 +1072,10 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
// update timeseries
|
// update timeseries
|
||||||
void * pCtbDropped = NULL;
|
void *pCtbDropped = NULL;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pCtbDropped = tSimpleHashIterate(suidHash, pCtbDropped, &iter))) {
|
while ((pCtbDropped = tSimpleHashIterate(suidHash, pCtbDropped, &iter))) {
|
||||||
tb_uid_t * pSuid = tSimpleHashGetKey(pCtbDropped, NULL);
|
tb_uid_t *pSuid = tSimpleHashGetKey(pCtbDropped, NULL);
|
||||||
int32_t nCols = 0;
|
int32_t nCols = 0;
|
||||||
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
|
if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
|
||||||
|
@ -1221,7 +1215,7 @@ static int metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl) {
|
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl) {
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
SMetaEntry e = {0};
|
SMetaEntry e = {0};
|
||||||
|
@ -1260,7 +1254,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
|
||||||
|
|
||||||
if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
|
if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
|
||||||
|
|
||||||
SSchema * pTagColumn = NULL;
|
SSchema *pTagColumn = NULL;
|
||||||
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
||||||
if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
|
if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
|
||||||
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
|
||||||
|
@ -1384,14 +1378,14 @@ int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
const void * pData = NULL;
|
const void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
int64_t oversion;
|
int64_t oversion;
|
||||||
SSchema * pColumn = NULL;
|
SSchema *pColumn = NULL;
|
||||||
SMetaEntry entry = {0};
|
SMetaEntry entry = {0};
|
||||||
SSchemaWrapper *pSchema;
|
SSchemaWrapper *pSchema;
|
||||||
int c;
|
int c;
|
||||||
|
@ -1652,7 +1646,7 @@ _err:
|
||||||
static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
||||||
SMetaEntry ctbEntry = {0};
|
SMetaEntry ctbEntry = {0};
|
||||||
SMetaEntry stbEntry = {0};
|
SMetaEntry stbEntry = {0};
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int c;
|
int c;
|
||||||
|
@ -1693,7 +1687,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||||
|
|
||||||
// search table.db
|
// search table.db
|
||||||
TBC * pTbDbc = NULL;
|
TBC *pTbDbc = NULL;
|
||||||
SDecoder dc1 = {0};
|
SDecoder dc1 = {0};
|
||||||
SDecoder dc2 = {0};
|
SDecoder dc2 = {0};
|
||||||
|
|
||||||
|
@ -1729,7 +1723,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
metaDecodeEntry(&dc2, &stbEntry);
|
metaDecodeEntry(&dc2, &stbEntry);
|
||||||
|
|
||||||
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
|
||||||
SSchema * pColumn = NULL;
|
SSchema *pColumn = NULL;
|
||||||
int32_t iCol = 0;
|
int32_t iCol = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pColumn = NULL;
|
pColumn = NULL;
|
||||||
|
@ -1756,8 +1750,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
memcpy((void *)ctbEntry.ctbEntry.pTags, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal);
|
memcpy((void *)ctbEntry.ctbEntry.pTags, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal);
|
||||||
} else {
|
} else {
|
||||||
const STag *pOldTag = (const STag *)ctbEntry.ctbEntry.pTags;
|
const STag *pOldTag = (const STag *)ctbEntry.ctbEntry.pTags;
|
||||||
STag * pNewTag = NULL;
|
STag *pNewTag = NULL;
|
||||||
SArray * pTagArray = taosArrayInit(pTagSchema->nCols, sizeof(STagVal));
|
SArray *pTagArray = taosArrayInit(pTagSchema->nCols, sizeof(STagVal));
|
||||||
if (!pTagArray) {
|
if (!pTagArray) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -1839,7 +1833,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
const void *pData = NULL;
|
const void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
|
@ -1943,7 +1937,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
|
|
||||||
static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
||||||
SMetaEntry stbEntry = {0};
|
SMetaEntry stbEntry = {0};
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int c;
|
int c;
|
||||||
|
@ -2076,7 +2070,7 @@ typedef struct SMetaPair {
|
||||||
|
|
||||||
static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
||||||
SMetaEntry stbEntry = {0};
|
SMetaEntry stbEntry = {0};
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int c;
|
int c;
|
||||||
|
@ -2186,7 +2180,7 @@ _err:
|
||||||
int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq) {
|
int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq) {
|
||||||
// impl later
|
// impl later
|
||||||
SMetaEntry tbEntry = {0};
|
SMetaEntry tbEntry = {0};
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int c;
|
int c;
|
||||||
|
@ -2296,8 +2290,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta
|
||||||
|
|
||||||
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
STbDbKey tbDbKey;
|
STbDbKey tbDbKey;
|
||||||
void * pKey = NULL;
|
void *pKey = NULL;
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int kLen = 0;
|
int kLen = 0;
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
SEncoder coder = {0};
|
SEncoder coder = {0};
|
||||||
|
@ -2448,14 +2442,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
STbDbKey tbDbKey = {0};
|
STbDbKey tbDbKey = {0};
|
||||||
SMetaEntry stbEntry = {0};
|
SMetaEntry stbEntry = {0};
|
||||||
STagIdxKey * pTagIdxKey = NULL;
|
STagIdxKey *pTagIdxKey = NULL;
|
||||||
int32_t nTagIdxKey;
|
int32_t nTagIdxKey;
|
||||||
const SSchema *pTagColumn;
|
const SSchema *pTagColumn;
|
||||||
const void * pTagData = NULL;
|
const void *pTagData = NULL;
|
||||||
int32_t nTagData = 0;
|
int32_t nTagData = 0;
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
@ -2524,7 +2518,7 @@ end:
|
||||||
|
|
||||||
static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SEncoder coder = {0};
|
SEncoder coder = {0};
|
||||||
void * pVal = NULL;
|
void *pVal = NULL;
|
||||||
int vLen = 0;
|
int vLen = 0;
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
SSkmDbKey skmDbKey = {0};
|
SSkmDbKey skmDbKey = {0};
|
||||||
|
@ -2652,15 +2646,15 @@ int32_t colCompressDebug(SHashObj *pColCmprObj) {
|
||||||
const char *l1str = columnEncodeStr(l1);
|
const char *l1str = columnEncodeStr(l1);
|
||||||
const char *l2str = columnCompressStr(l2);
|
const char *l2str = columnCompressStr(l2);
|
||||||
const char *lvlstr = columnLevelStr(lvl);
|
const char *lvlstr = columnLevelStr(lvl);
|
||||||
metaInfo("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr);
|
metaDebug("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
|
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
SHashObj * pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
SHashObj *pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||||
void * pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
SMetaEntry e = {0};
|
SMetaEntry e = {0};
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
|
|
@ -153,10 +153,10 @@ int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp, req.reqOffset);
|
tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||||
dataRsp.blockNum = 0;
|
dataRsp.common.blockNum = 0;
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.reqOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset);
|
||||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf,
|
tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf,
|
||||||
req.reqId);
|
req.reqId);
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const void* pRsp,
|
||||||
int32_t type, int32_t vgId) {
|
int32_t type, int32_t vgId) {
|
||||||
int64_t sver = 0, ever = 0;
|
int64_t sver = 0, ever = 0;
|
||||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||||
|
@ -174,11 +174,11 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq*
|
||||||
|
|
||||||
char buf1[TSDB_OFFSET_LEN] = {0};
|
char buf1[TSDB_OFFSET_LEN] = {0};
|
||||||
char buf2[TSDB_OFFSET_LEN] = {0};
|
char buf2[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf1, TSDB_OFFSET_LEN, &pRsp->reqOffset);
|
tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset);
|
||||||
tFormatOffset(buf2, TSDB_OFFSET_LEN, &pRsp->rspOffset);
|
tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset);
|
||||||
|
|
||||||
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64,
|
||||||
vgId, pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2, pReq->reqId);
|
vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
taosRUnLockLatch(&pTq->lock);
|
taosRUnLockLatch(&pTq->lock);
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp, req.reqOffset);
|
tqInitDataRsp(&dataRsp.common, req.reqOffset);
|
||||||
|
|
||||||
if (req.useSnapshot == true) {
|
if (req.useSnapshot == true) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||||
|
@ -508,10 +508,10 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.rspOffset.type = TMQ_OFFSET__LOG;
|
dataRsp.common.rspOffset.type = TMQ_OFFSET__LOG;
|
||||||
|
|
||||||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||||
dataRsp.rspOffset.version = reqOffset.version;
|
dataRsp.common.rspOffset.version = reqOffset.version;
|
||||||
} else if (reqOffset.type < 0) {
|
} else if (reqOffset.type < 0) {
|
||||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey);
|
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey);
|
||||||
if (pOffset != NULL) {
|
if (pOffset != NULL) {
|
||||||
|
@ -522,17 +522,17 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataRsp.rspOffset.version = pOffset->val.version;
|
dataRsp.common.rspOffset.version = pOffset->val.version;
|
||||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from store:%" PRId64, consumerId, vgId,
|
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from store:%" PRId64, consumerId, vgId,
|
||||||
req.subKey, dataRsp.rspOffset.version);
|
req.subKey, dataRsp.common.rspOffset.version);
|
||||||
} else {
|
} else {
|
||||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||||
dataRsp.rspOffset.version = sver; // not consume yet, set the earliest position
|
dataRsp.common.rspOffset.version = sver; // not consume yet, set the earliest position
|
||||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||||
dataRsp.rspOffset.version = ever;
|
dataRsp.common.rspOffset.version = ever;
|
||||||
}
|
}
|
||||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from init:%" PRId64, consumerId, vgId, req.subKey,
|
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from init:%" PRId64, consumerId, vgId, req.subKey,
|
||||||
dataRsp.rspOffset.version);
|
dataRsp.common.rspOffset.version);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||||
|
@ -760,16 +760,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) {
|
||||||
streamSetupScheduleTrigger(pTask);
|
streamSetupScheduleTrigger(pTask);
|
||||||
|
|
||||||
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
||||||
|
tqSetRestoreVersionInfo(pTask);
|
||||||
// checkpoint ver is the kept version, handled data should be the next version.
|
|
||||||
if (pChkInfo->checkpointId != 0) {
|
|
||||||
pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1;
|
|
||||||
pChkInfo->processedVer = pChkInfo->checkpointVer;
|
|
||||||
pTask->execInfo.startCheckpointVer = pChkInfo->nextProcessVer;
|
|
||||||
pTask->execInfo.startCheckpointId = pChkInfo->checkpointId;
|
|
||||||
tqInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " currentVer:%" PRId64, pTask->id.idStr,
|
|
||||||
pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* p = streamTaskGetStatus(pTask)->name;
|
char* p = streamTaskGetStatus(pTask)->name;
|
||||||
const char* pNext = streamTaskGetStatusStr(pTask->status.taskStatus);
|
const char* pNext = streamTaskGetStatusStr(pTask->status.taskStatus);
|
||||||
|
@ -1102,7 +1093,9 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pTq->pVnode->restored) {
|
if (!pTq->pVnode->restored) {
|
||||||
tqDebug("vgId:%d checkpoint-source msg received during restoring, s-task:0x%x ignore it", vgId, req.taskId);
|
tqDebug("vgId:%d checkpoint-source msg received during restoring, checkpointId:%" PRId64
|
||||||
|
", transId:%d s-task:0x%x ignore it",
|
||||||
|
vgId, req.checkpointId, req.transId, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
SRpcMsg rsp = {0};
|
||||||
buildCheckpointSourceRsp(&req, &pMsg->info, &rsp, 0);
|
buildCheckpointSourceRsp(&req, &pMsg->info, &rsp, 0);
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
tmsgSendRsp(&rsp); // error occurs
|
||||||
|
@ -1111,7 +1104,9 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.taskId);
|
SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.taskId);
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
tqError("vgId:%d failed to find s-task:0x%x, ignore checkpoint msg. it may have been destroyed", vgId, req.taskId);
|
tqError("vgId:%d failed to find s-task:0x%x, ignore checkpoint msg. checkpointId:%" PRId64
|
||||||
|
" transId:%d it may have been destroyed",
|
||||||
|
vgId, req.taskId, req.checkpointId, req.transId);
|
||||||
SRpcMsg rsp = {0};
|
SRpcMsg rsp = {0};
|
||||||
buildCheckpointSourceRsp(&req, &pMsg->info, &rsp, 0);
|
buildCheckpointSourceRsp(&req, &pMsg->info, &rsp, 0);
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
tmsgSendRsp(&rsp); // error occurs
|
||||||
|
@ -1123,7 +1118,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
pTask->chkInfo.checkpointingId = req.checkpointId;
|
pTask->chkInfo.checkpointingId = req.checkpointId;
|
||||||
pTask->chkInfo.transId = req.transId;
|
pTask->chkInfo.transId = req.transId;
|
||||||
|
|
||||||
tqError("s-task:%s not ready for checkpoint, since downstream not ready, ignore this checkpoint:%" PRId64
|
tqError("s-task:%s not ready for checkpoint, since downstream not ready, ignore this checkpointId:%" PRId64
|
||||||
", transId:%d set it failed",
|
", transId:%d set it failed",
|
||||||
pTask->id.idStr, req.checkpointId, req.transId);
|
pTask->id.idStr, req.checkpointId, req.transId);
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
@ -1140,7 +1135,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
if (req.mndTrigger == 1) {
|
if (req.mndTrigger == 1) {
|
||||||
if (status == TASK_STATUS__HALT || status == TASK_STATUS__PAUSE) {
|
if (status == TASK_STATUS__HALT || status == TASK_STATUS__PAUSE) {
|
||||||
tqError("s-task:%s not ready for checkpoint, since it is halt, ignore checkpoint:%" PRId64 ", set it failure",
|
tqError("s-task:%s not ready for checkpoint, since it is halt, ignore checkpointId:%" PRId64 ", set it failure",
|
||||||
pTask->id.idStr, req.checkpointId);
|
pTask->id.idStr, req.checkpointId);
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
|
|
@ -76,7 +76,7 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqMetaOpen(STQ* pTq) {
|
int32_t tqMetaOpen(STQ* pTq) {
|
||||||
if (tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0) < 0) {
|
if (tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0, 0, NULL) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema,
|
||||||
static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SColVal* pColVal) {
|
static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SColVal* pColVal) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (IS_STR_DATA_TYPE(pColVal->value.type)) {
|
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
|
||||||
char val[65535 + 2] = {0};
|
char val[65535 + 2] = {0};
|
||||||
if (COL_VAL_IS_VALUE(pColVal)) {
|
if (COL_VAL_IS_VALUE(pColVal)) {
|
||||||
if (pColVal->value.pData != NULL) {
|
if (pColVal->value.pData != NULL) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) {
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, void* pRsp, int32_t numOfCols, int8_t precision) {
|
||||||
int32_t dataStrLen = sizeof(SRetrieveTableRspForTmq) + blockGetEncodeSize(pBlock);
|
int32_t dataStrLen = sizeof(SRetrieveTableRspForTmq) + blockGetEncodeSize(pBlock);
|
||||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
|
@ -30,22 +30,22 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
|
||||||
|
|
||||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||||
actualLen += sizeof(SRetrieveTableRspForTmq);
|
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||||
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockDataLen, &actualLen);
|
||||||
taosArrayPush(pRsp->blockData, &buf);
|
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockData, &buf);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp) {
|
static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, void* pRsp) {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pTqReader->pSchemaWrapper);
|
||||||
if (pSW == NULL) {
|
if (pSW == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockSchema, &pSW);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, int32_t n) {
|
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, void* pRsp, int32_t n) {
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in
|
||||||
|
|
||||||
for (int32_t i = 0; i < n; i++) {
|
for (int32_t i = 0; i < n; i++) {
|
||||||
char* tbName = taosStrdup(mr.me.name);
|
char* tbName = taosStrdup(mr.me.name);
|
||||||
taosArrayPush(pRsp->blockTbName, &tbName);
|
taosArrayPush(((SMqDataRspCommon*)pRsp)->blockTbName, &tbName);
|
||||||
}
|
}
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -125,7 +125,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp->blockNum++;
|
pRsp->common.blockNum++;
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
blockDataDestroy(pHandle->block);
|
blockDataDestroy(pHandle->block);
|
||||||
pHandle->block = NULL;
|
pHandle->block = NULL;
|
||||||
|
@ -149,7 +149,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp->blockNum++;
|
pRsp->common.blockNum++;
|
||||||
totalRows += pDataBlock->info.rows;
|
totalRows += pDataBlock->info.rows;
|
||||||
if (totalRows >= tmqRowSize) {
|
if (totalRows >= tmqRowSize) {
|
||||||
break;
|
break;
|
||||||
|
@ -158,8 +158,8 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
||||||
pHandle->consumerId, vgId, pRsp->blockNum, totalRows);
|
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
||||||
qStreamExtractOffset(task, &pRsp->rspOffset);
|
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
|
||||||
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
tqDebug("tmqsnap task execute end, get %p", pDataBlock);
|
||||||
|
|
||||||
if (pDataBlock != NULL && pDataBlock->info.rows > 0) {
|
if (pDataBlock != NULL && pDataBlock->info.rows > 0) {
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->common.withTbName) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
|
||||||
|
@ -194,21 +194,21 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
|
||||||
taosArrayPush(pRsp->blockTbName, &tbName);
|
taosArrayPush(pRsp->common.blockTbName, &tbName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pRsp->withSchema) {
|
if (pRsp->common.withSchema) {
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
tqAddBlockSchemaToRsp(pExec, pRsp);
|
tqAddBlockSchemaToRsp(pExec, pRsp);
|
||||||
} else {
|
} else {
|
||||||
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
|
||||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock),
|
||||||
pTq->pVnode->config.tsdbCfg.precision);
|
pTq->pVnode->config.tsdbCfg.precision);
|
||||||
pRsp->blockNum++;
|
pRsp->common.blockNum++;
|
||||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,13 +234,13 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
|
||||||
}
|
}
|
||||||
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
||||||
pHandle->snapshotVer + 1);
|
pHandle->snapshotVer + 1);
|
||||||
qStreamExtractOffset(task, &pRsp->rspOffset);
|
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->blockNum > 0) {
|
if (pRsp->common.blockNum > 0) {
|
||||||
tqDebug("tmqsnap task exec exited, get data");
|
tqDebug("tmqsnap task exec exited, get data");
|
||||||
qStreamExtractOffset(task, &pRsp->rspOffset);
|
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
||||||
goto loop_table;
|
goto loop_table;
|
||||||
}
|
}
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->common.withTbName) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
||||||
goto loop_table;
|
goto loop_table;
|
||||||
|
@ -312,8 +312,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
*totalRows += pBlock->info.rows;
|
*totalRows += pBlock->info.rows;
|
||||||
blockDataFreeRes(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
||||||
pRsp->blockNum++;
|
pRsp->common.blockNum++;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
loop_table:
|
loop_table:
|
||||||
|
@ -336,7 +336,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
if ((pSubmitTbDataRet->flags & sourceExcluded) != 0) {
|
||||||
goto loop_db;
|
goto loop_db;
|
||||||
}
|
}
|
||||||
if (pRsp->withTbName) {
|
if (pRsp->common.withTbName) {
|
||||||
int64_t uid = pExec->pTqReader->lastBlkUid;
|
int64_t uid = pExec->pTqReader->lastBlkUid;
|
||||||
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
||||||
goto loop_db;
|
goto loop_db;
|
||||||
|
@ -380,8 +380,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
||||||
*totalRows += pBlock->info.rows;
|
*totalRows += pBlock->info.rows;
|
||||||
blockDataFreeRes(pBlock);
|
blockDataFreeRes(pBlock);
|
||||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
taosArrayPush(pRsp->common.blockSchema, &pSW);
|
||||||
pRsp->blockNum++;
|
pRsp->common.blockNum++;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
loop_db:
|
loop_db:
|
||||||
|
|
|
@ -309,11 +309,10 @@ int32_t doBuildAndSendSubmitMsg(SVnode* pVnode, SStreamTask* pTask, SSubmitReq2*
|
||||||
|
|
||||||
pRec->numOfSubmit += 1;
|
pRec->numOfSubmit += 1;
|
||||||
if ((pRec->numOfSubmit % 1000) == 0) {
|
if ((pRec->numOfSubmit % 1000) == 0) {
|
||||||
double el = (taosGetTimestampMs() - pTask->execInfo.start) / 1000.0;
|
double el = (taosGetTimestampMs() - pTask->execInfo.readyTs) / 1000.0;
|
||||||
tqInfo("s-task:%s vgId:%d write %" PRId64 " blocks (%" PRId64 " rows) in %" PRId64
|
tqInfo("s-task:%s vgId:%d write %" PRId64 " blocks (%" PRId64 " rows) in %" PRId64
|
||||||
" submit into dst table, %.2fMiB duration:%.2f Sec.",
|
" submit into dst table, %.2fMiB duration:%.2f Sec.",
|
||||||
pTask->id.idStr, vgId, pRec->numOfBlocks, pRec->numOfRows, pRec->numOfSubmit, SIZE_IN_MiB(pRec->dataSize),
|
id, vgId, pRec->numOfBlocks, pRec->numOfRows, pRec->numOfSubmit, SIZE_IN_MiB(pRec->dataSize), el);
|
||||||
el);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -604,7 +603,7 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat
|
||||||
dataIndex++;
|
dataIndex++;
|
||||||
} else {
|
} else {
|
||||||
void* colData = colDataGetData(pColData, j);
|
void* colData = colDataGetData(pColData, j);
|
||||||
if (IS_STR_DATA_TYPE(pCol->type)) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
// address copy, no value
|
// address copy, no value
|
||||||
SValue sv =
|
SValue sv =
|
||||||
(SValue){.type = pCol->type, .nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)};
|
(SValue){.type = pCol->type, .nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)};
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
static int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
|
static int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
|
||||||
const SMqMetaRsp* pRsp, int32_t vgId);
|
const SMqMetaRsp* pRsp, int32_t vgId);
|
||||||
|
|
||||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
|
int32_t tqInitDataRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||||
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
||||||
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void tqUpdateNodeStage(STQ* pTq, bool isLeader) {
|
||||||
streamMetaUpdateStageRole(pTq->pStreamMeta, state.term, isLeader);
|
streamMetaUpdateStageRole(pTq->pStreamMeta, state.term, isLeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, STqOffsetVal pOffset) {
|
static int32_t tqInitTaosxRsp(SMqDataRspCommon* pRsp, STqOffsetVal pOffset) {
|
||||||
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
tOffsetCopy(&pRsp->reqOffset, &pOffset);
|
||||||
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
tOffsetCopy(&pRsp->rspOffset, &pOffset);
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||||
|
|
||||||
tqInitDataRsp(&dataRsp, *pOffsetVal);
|
tqInitDataRsp(&dataRsp.common, *pOffsetVal);
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
||||||
pHandle->subKey, vgId, dataRsp.rspOffset.version);
|
pHandle->subKey, vgId, dataRsp.common.rspOffset.version);
|
||||||
int32_t code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
int32_t code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
SMqDataRsp dataRsp = {0};
|
SMqDataRsp dataRsp = {0};
|
||||||
tqInitDataRsp(&dataRsp, *pOffset);
|
tqInitDataRsp(&dataRsp.common, *pOffset);
|
||||||
|
|
||||||
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||||
int code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
int code = tqScanData(pTq, pHandle, &dataRsp, pOffset, pRequest);
|
||||||
|
@ -146,11 +146,11 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
|
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
|
||||||
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST && dataRsp.blockNum == 0) {
|
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST && dataRsp.common.blockNum == 0) {
|
||||||
// lock
|
// lock
|
||||||
taosWLockLatch(&pTq->lock);
|
taosWLockLatch(&pTq->lock);
|
||||||
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
|
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
|
||||||
if (dataRsp.rspOffset.version > ver) { // check if there are data again to avoid lost data
|
if (dataRsp.common.rspOffset.version > ver) { // check if there are data again to avoid lost data
|
||||||
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -158,15 +158,15 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
tOffsetCopy(&dataRsp.reqOffset, pOffset); // reqOffset represents the current date offset, may be changed if wal not exists
|
tOffsetCopy(&dataRsp.common.reqOffset, pOffset); // reqOffset represents the current date offset, may be changed if wal not exists
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
|
|
||||||
end : {
|
end : {
|
||||||
char buf[TSDB_OFFSET_LEN] = {0};
|
char buf[TSDB_OFFSET_LEN] = {0};
|
||||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.rspOffset);
|
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.rspOffset);
|
||||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%" PRIx64
|
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%" PRIx64
|
||||||
" code:%d",
|
" code:%d",
|
||||||
consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId, code);
|
consumerId, pHandle->subKey, vgId, dataRsp.common.blockNum, buf, pRequest->reqId, code);
|
||||||
tDeleteMqDataRsp(&dataRsp);
|
tDeleteMqDataRsp(&dataRsp);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
SMqMetaRsp metaRsp = {0};
|
SMqMetaRsp metaRsp = {0};
|
||||||
STaosxRsp taosxRsp = {0};
|
STaosxRsp taosxRsp = {0};
|
||||||
tqInitTaosxRsp(&taosxRsp, *offset);
|
tqInitTaosxRsp(&taosxRsp.common, *offset);
|
||||||
|
|
||||||
if (offset->type != TMQ_OFFSET__LOG) {
|
if (offset->type != TMQ_OFFSET__LOG) {
|
||||||
if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, offset) < 0) {
|
if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, offset) < 0) {
|
||||||
|
@ -214,13 +214,13 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
|
|
||||||
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64
|
||||||
",ts:%" PRId64,
|
",ts:%" PRId64,
|
||||||
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type,
|
pRequest->consumerId, pHandle->subKey, vgId, taosxRsp.common.blockNum, taosxRsp.common.rspOffset.type,
|
||||||
taosxRsp.rspOffset.uid, taosxRsp.rspOffset.ts);
|
taosxRsp.common.rspOffset.uid, taosxRsp.common.rspOffset.ts);
|
||||||
if (taosxRsp.blockNum > 0) {
|
if (taosxRsp.common.blockNum > 0) {
|
||||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
code = tqSendDataRsp(pHandle, pMsg, pRequest, &taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
tOffsetCopy(offset, &taosxRsp.rspOffset);
|
tOffsetCopy(offset, &taosxRsp.common.rspOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
ASSERT(savedEpoch <= pRequest->epoch);
|
ASSERT(savedEpoch <= pRequest->epoch);
|
||||||
|
|
||||||
if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
|
if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
|
||||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -249,9 +249,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
// process meta
|
// process meta
|
||||||
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
||||||
if (totalRows > 0) {
|
if (totalRows > 0) {
|
||||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -292,9 +292,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
if (totalRows >= tmqRowSize || (taosGetTimestampMs() - st > 1000)) {
|
||||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer + 1);
|
tqOffsetResetToLog(&taosxRsp.common.rspOffset, fetchVer + 1);
|
||||||
code = tqSendDataRsp(
|
code = tqSendDataRsp(
|
||||||
pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp,
|
pHandle, pMsg, pRequest, &taosxRsp,
|
||||||
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,7 +386,7 @@ int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPoll
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const void* pRsp, int32_t epoch, int64_t consumerId,
|
||||||
int32_t type, int64_t sver, int64_t ever) {
|
int32_t type, int64_t sver, int64_t ever) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -394,7 +394,7 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp*
|
||||||
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
||||||
tEncodeSize(tEncodeMqDataRsp, pRsp, len, code);
|
tEncodeSize(tEncodeMqDataRsp, pRsp, len, code);
|
||||||
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||||
tEncodeSize(tEncodeSTaosxRsp, (STaosxRsp*)pRsp, len, code);
|
tEncodeSize(tEncodeSTaosxRsp, pRsp, len, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
|
@ -418,7 +418,7 @@ int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp*
|
||||||
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
if (type == TMQ_MSG_TYPE__POLL_DATA_RSP || type == TMQ_MSG_TYPE__WALINFO_RSP) {
|
||||||
tEncodeMqDataRsp(&encoder, pRsp);
|
tEncodeMqDataRsp(&encoder, pRsp);
|
||||||
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
} else if (type == TMQ_MSG_TYPE__POLL_DATA_META_RSP) {
|
||||||
tEncodeSTaosxRsp(&encoder, (STaosxRsp*)pRsp);
|
tEncodeSTaosxRsp(&encoder, pRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
|
@ -86,6 +86,22 @@ int32_t tqExpandStreamTask(SStreamTask* pTask, SStreamMeta* pMeta, void* pVnode)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tqSetRestoreVersionInfo(SStreamTask* pTask) {
|
||||||
|
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
||||||
|
|
||||||
|
// checkpoint ver is the kept version, handled data should be the next version.
|
||||||
|
if (pChkInfo->checkpointId != 0) {
|
||||||
|
pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1;
|
||||||
|
pChkInfo->processedVer = pChkInfo->checkpointVer;
|
||||||
|
pTask->execInfo.startCheckpointId = pChkInfo->checkpointId;
|
||||||
|
|
||||||
|
tqInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " currentVer:%" PRId64, pTask->id.idStr,
|
||||||
|
pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer);
|
||||||
|
}
|
||||||
|
|
||||||
|
pTask->execInfo.startCheckpointVer = pChkInfo->nextProcessVer;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) {
|
int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) {
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
||||||
|
@ -200,6 +216,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
||||||
|
|
||||||
streamTaskUpdateEpsetInfo(pTask, req.pNodeList);
|
streamTaskUpdateEpsetInfo(pTask, req.pNodeList);
|
||||||
streamTaskResetStatus(pTask);
|
streamTaskResetStatus(pTask);
|
||||||
|
streamTaskCompleteCheck(&pTask->taskCheckInfo, pTask->id.idStr);
|
||||||
|
|
||||||
SStreamTask** ppHTask = NULL;
|
SStreamTask** ppHTask = NULL;
|
||||||
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
||||||
|
@ -213,6 +230,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
||||||
} else {
|
} else {
|
||||||
tqDebug("s-task:%s fill-history task update nodeEp along with stream task", (*ppHTask)->id.idStr);
|
tqDebug("s-task:%s fill-history task update nodeEp along with stream task", (*ppHTask)->id.idStr);
|
||||||
streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList);
|
streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList);
|
||||||
|
streamTaskResetStatus(*ppHTask);
|
||||||
|
streamTaskCompleteCheck(&(*ppHTask)->taskCheckInfo, (*ppHTask)->id.idStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,8 +474,8 @@ int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
return streamSendCheckRsp(pMeta, &req, &rsp, &pMsg->info, taskId);
|
return streamSendCheckRsp(pMeta, &req, &rsp, &pMsg->info, taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setParam(SStreamTask* pTask, int64_t* initTs, bool* hasHTask, STaskId* pId) {
|
static void setParam(SStreamTask* pTask, int64_t* startCheckTs, bool* hasHTask, STaskId* pId) {
|
||||||
*initTs = pTask->execInfo.init;
|
*startCheckTs = pTask->execInfo.checkTs;
|
||||||
|
|
||||||
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
|
||||||
*hasHTask = true;
|
*hasHTask = true;
|
||||||
|
@ -525,6 +544,7 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
streamMetaRLock(pMeta);
|
streamMetaRLock(pMeta);
|
||||||
|
|
||||||
|
// let's try to find this task in hashmap
|
||||||
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
SStreamTask** ppTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id));
|
||||||
if (ppTask != NULL) {
|
if (ppTask != NULL) {
|
||||||
setParam(*ppTask, &initTs, &hasHistoryTask, &fId);
|
setParam(*ppTask, &initTs, &hasHistoryTask, &fId);
|
||||||
|
@ -533,7 +553,7 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe
|
||||||
if (hasHistoryTask) {
|
if (hasHistoryTask) {
|
||||||
streamMetaAddTaskLaunchResult(pMeta, fId.streamId, fId.taskId, initTs, now, false);
|
streamMetaAddTaskLaunchResult(pMeta, fId.streamId, fId.taskId, initTs, now, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else { // not exist even in the hash map of meta, forget it
|
||||||
streamMetaRUnLock(pMeta);
|
streamMetaRUnLock(pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +782,7 @@ static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) {
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
if (pMeta->startInfo.taskStarting == 1) {
|
if (pMeta->startInfo.startAllTasks == 1) {
|
||||||
pMeta->startInfo.restartCount += 1;
|
pMeta->startInfo.restartCount += 1;
|
||||||
tqDebug("vgId:%d in start tasks procedure, inc restartCounter by 1, remaining restart:%d", vgId,
|
tqDebug("vgId:%d in start tasks procedure, inc restartCounter by 1, remaining restart:%d", vgId,
|
||||||
pMeta->startInfo.restartCount);
|
pMeta->startInfo.restartCount);
|
||||||
|
@ -770,7 +790,7 @@ static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMeta->startInfo.taskStarting = 1;
|
pMeta->startInfo.startAllTasks = 1;
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
@ -886,7 +906,7 @@ int32_t tqStartTaskCompleteCallback(SStreamMeta* pMeta) {
|
||||||
bool scanWal = false;
|
bool scanWal = false;
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
if (pStartInfo->taskStarting == 1) {
|
if (pStartInfo->startAllTasks == 1) {
|
||||||
tqDebug("vgId:%d already in start tasks procedure in other thread, restartCounter:%d, do nothing", vgId,
|
tqDebug("vgId:%d already in start tasks procedure in other thread, restartCounter:%d, do nothing", vgId,
|
||||||
pMeta->startInfo.restartCount);
|
pMeta->startInfo.restartCount);
|
||||||
} else { // not in starting procedure
|
} else { // not in starting procedure
|
||||||
|
@ -936,13 +956,20 @@ int32_t tqStreamTaskProcessTaskResetReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
||||||
tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr);
|
tqDebug("s-task:%s receive task-reset msg from mnode, reset status and ready for data processing", pTask->id.idStr);
|
||||||
|
|
||||||
taosThreadMutexLock(&pTask->lock);
|
taosThreadMutexLock(&pTask->lock);
|
||||||
|
streamTaskClearCheckInfo(pTask, true);
|
||||||
|
|
||||||
// clear flag set during do checkpoint, and open inputQ for all upstream tasks
|
// clear flag set during do checkpoint, and open inputQ for all upstream tasks
|
||||||
if (streamTaskGetStatus(pTask)->state == TASK_STATUS__CK) {
|
SStreamTaskState *pState = streamTaskGetStatus(pTask);
|
||||||
|
if (pState->state == TASK_STATUS__CK) {
|
||||||
tqDebug("s-task:%s reset task status from checkpoint, current checkpointingId:%" PRId64 ", transId:%d",
|
tqDebug("s-task:%s reset task status from checkpoint, current checkpointingId:%" PRId64 ", transId:%d",
|
||||||
pTask->id.idStr, pTask->chkInfo.checkpointingId, pTask->chkInfo.transId);
|
pTask->id.idStr, pTask->chkInfo.checkpointingId, pTask->chkInfo.transId);
|
||||||
streamTaskClearCheckInfo(pTask, true);
|
|
||||||
streamTaskSetStatusReady(pTask);
|
streamTaskSetStatusReady(pTask);
|
||||||
|
} else if (pState->state == TASK_STATUS__UNINIT) {
|
||||||
|
tqDebug("s-task:%s start task by checking downstream tasks", pTask->id.idStr);
|
||||||
|
ASSERT(pTask->status.downstreamReady == 0);
|
||||||
|
/*int32_t ret = */ streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_INIT);
|
||||||
|
} else {
|
||||||
|
tqDebug("s-task:%s status:%s do nothing after receiving reset-task from mnode", pTask->id.idStr, pState->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pTask->lock);
|
taosThreadMutexUnlock(&pTask->lock);
|
||||||
|
|
|
@ -73,7 +73,9 @@ int32_t tsdbDataFileRAWReadBlockData(SDataFileRAWReader *reader, STsdbDataRAWBlo
|
||||||
pBlock->file.maxVer = reader->config->file.maxVer;
|
pBlock->file.maxVer = reader->config->file.maxVer;
|
||||||
pBlock->file.stt->level = reader->config->file.stt->level;
|
pBlock->file.stt->level = reader->config->file.stt->level;
|
||||||
|
|
||||||
code = tsdbReadFile(reader->fd, pBlock->offset, pBlock->data, pBlock->dataLength, 0);
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(reader->fd, pBlock->offset, pBlock->data, pBlock->dataLength, 0, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -127,8 +129,11 @@ static int32_t tsdbDataFileRAWWriterCloseCommit(SDataFileRAWWriter *writer, TFil
|
||||||
code = TARRAY2_APPEND(opArr, op);
|
code = TARRAY2_APPEND(opArr, op);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
if (writer->fd) {
|
if (writer->fd) {
|
||||||
code = tsdbFsyncFile(writer->fd);
|
code = tsdbFsyncFile(writer->fd, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
tsdbCloseFile(&writer->fd);
|
tsdbCloseFile(&writer->fd);
|
||||||
}
|
}
|
||||||
|
@ -206,11 +211,13 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *pDataBlock) {
|
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *pDataBlock,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbWriteFile(writer->fd, writer->ctx->offset, (const uint8_t *)pDataBlock->data, pDataBlock->dataLength);
|
code = tsdbWriteFile(writer->fd, writer->ctx->offset, (const uint8_t *)pDataBlock->data, pDataBlock->dataLength,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
writer->ctx->offset += pDataBlock->dataLength;
|
writer->ctx->offset += pDataBlock->dataLength;
|
||||||
|
|
|
@ -105,7 +105,8 @@ int32_t tsdbDataFileRAWWriterOpen(const SDataFileRAWWriterConfig *config, SDataF
|
||||||
int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFileOpArray *opArr);
|
int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFileOpArray *opArr);
|
||||||
|
|
||||||
int32_t tsdbDataFileRAWWriterDoOpen(SDataFileRAWWriter *writer);
|
int32_t tsdbDataFileRAWWriterDoOpen(SDataFileRAWWriter *writer);
|
||||||
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr);
|
int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
int32_t tsdbDataFileRAWFlush(SDataFileRAWWriter *writer);
|
int32_t tsdbDataFileRAWFlush(SDataFileRAWWriter *writer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -46,8 +46,10 @@ static int32_t tsdbDataFileReadHeadFooter(SDataFileReader *reader) {
|
||||||
|
|
||||||
int32_t ftype = TSDB_FTYPE_HEAD;
|
int32_t ftype = TSDB_FTYPE_HEAD;
|
||||||
if (reader->fd[ftype]) {
|
if (reader->fd[ftype]) {
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
code = tsdbReadFile(reader->fd[ftype], reader->config->files[ftype].file.size - sizeof(SHeadFooter),
|
code = tsdbReadFile(reader->fd[ftype], reader->config->files[ftype].file.size - sizeof(SHeadFooter),
|
||||||
(uint8_t *)reader->headFooter, sizeof(SHeadFooter), 0);
|
(uint8_t *)reader->headFooter, sizeof(SHeadFooter), 0, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +70,10 @@ static int32_t tsdbDataFileReadTombFooter(SDataFileReader *reader) {
|
||||||
|
|
||||||
int32_t ftype = TSDB_FTYPE_TOMB;
|
int32_t ftype = TSDB_FTYPE_TOMB;
|
||||||
if (reader->fd[ftype]) {
|
if (reader->fd[ftype]) {
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
code = tsdbReadFile(reader->fd[ftype], reader->config->files[ftype].file.size - sizeof(STombFooter),
|
code = tsdbReadFile(reader->fd[ftype], reader->config->files[ftype].file.size - sizeof(STombFooter),
|
||||||
(uint8_t *)reader->tombFooter, sizeof(STombFooter), 0);
|
(uint8_t *)reader->tombFooter, sizeof(STombFooter), 0, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
reader->ctx->tombFooterLoaded = true;
|
reader->ctx->tombFooterLoaded = true;
|
||||||
|
@ -164,8 +168,10 @@ int32_t tsdbDataFileReadBrinBlk(SDataFileReader *reader, const TBrinBlkArray **b
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
code = tsdbReadFile(reader->fd[TSDB_FTYPE_HEAD], reader->headFooter->brinBlkPtr->offset, data,
|
code = tsdbReadFile(reader->fd[TSDB_FTYPE_HEAD], reader->headFooter->brinBlkPtr->offset, data,
|
||||||
reader->headFooter->brinBlkPtr->size, 0);
|
reader->headFooter->brinBlkPtr->size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
@ -195,9 +201,12 @@ int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinB
|
||||||
SBuffer *buffer = reader->buffers + 0;
|
SBuffer *buffer = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load data
|
// load data
|
||||||
tBufferClear(buffer);
|
tBufferClear(buffer);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_HEAD], brinBlk->dp->offset, brinBlk->dp->size, buffer, 0);
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_HEAD], brinBlk->dp->offset, brinBlk->dp->size, buffer, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode brin block
|
// decode brin block
|
||||||
|
@ -279,9 +288,12 @@ int32_t tsdbDataFileReadBlockData(SDataFileReader *reader, const SBrinRecord *re
|
||||||
SBuffer *buffer = reader->buffers + 0;
|
SBuffer *buffer = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load data
|
// load data
|
||||||
tBufferClear(buffer);
|
tBufferClear(buffer);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockSize, buffer, 0);
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockSize, buffer, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decompress
|
// decompress
|
||||||
|
@ -307,9 +319,12 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe
|
||||||
SBuffer *buffer1 = reader->buffers + 1;
|
SBuffer *buffer1 = reader->buffers + 1;
|
||||||
SBuffer *assist = reader->buffers + 2;
|
SBuffer *assist = reader->buffers + 2;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load key part
|
// load key part
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockKeySize, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset, record->blockKeySize, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// SDiskDataHdr
|
// SDiskDataHdr
|
||||||
|
@ -340,11 +355,11 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe
|
||||||
if (extraColIdx < 0) {
|
if (extraColIdx < 0) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load SBlockCol part
|
// load SBlockCol part
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize, hdr.szBlkCol,
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize, hdr.szBlkCol,
|
||||||
buffer0, 0);
|
buffer0, 0, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// calc szHint
|
// calc szHint
|
||||||
|
@ -454,11 +469,14 @@ int32_t tsdbDataFileReadBlockDataByColumn(SDataFileReader *reader, const SBrinRe
|
||||||
code = tBlockDataDecompressColData(&hdr, &none, &br, bData, assist);
|
code = tBlockDataDecompressColData(&hdr, &none, &br, bData, assist);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else if (cid == blockCol.cid) {
|
} else if (cid == blockCol.cid) {
|
||||||
// load from file
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
// load from file
|
||||||
tBufferClear(buffer1);
|
tBufferClear(buffer1);
|
||||||
code = tsdbReadFileToBuffer(
|
code = tsdbReadFileToBuffer(
|
||||||
reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize + hdr.szBlkCol + blockCol.offset,
|
reader->fd[TSDB_FTYPE_DATA], record->blockOffset + record->blockKeySize + hdr.szBlkCol + blockCol.offset,
|
||||||
blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, firstRead ? szHint : 0);
|
blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, firstRead ? szHint : 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
firstRead = false;
|
firstRead = false;
|
||||||
|
@ -486,7 +504,10 @@ int32_t tsdbDataFileReadBlockSma(SDataFileReader *reader, const SBrinRecord *rec
|
||||||
TARRAY2_CLEAR(columnDataAggArray, NULL);
|
TARRAY2_CLEAR(columnDataAggArray, NULL);
|
||||||
if (record->smaSize > 0) {
|
if (record->smaSize > 0) {
|
||||||
tBufferClear(buffer);
|
tBufferClear(buffer);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_SMA], record->smaOffset, record->smaSize, buffer, 0);
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_SMA], record->smaOffset, record->smaSize, buffer, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode sma data
|
// decode sma data
|
||||||
|
@ -525,8 +546,10 @@ int32_t tsdbDataFileReadTombBlk(SDataFileReader *reader, const TTombBlkArray **t
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
code = tsdbReadFile(reader->fd[TSDB_FTYPE_TOMB], reader->tombFooter->tombBlkPtr->offset, data,
|
code = tsdbReadFile(reader->fd[TSDB_FTYPE_TOMB], reader->tombFooter->tombBlkPtr->offset, data,
|
||||||
reader->tombFooter->tombBlkPtr->size, 0);
|
reader->tombFooter->tombBlkPtr->size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
@ -557,7 +580,10 @@ int32_t tsdbDataFileReadTombBlock(SDataFileReader *reader, const STombBlk *tombB
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_TOMB], tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0);
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFileToBuffer(reader->fd[TSDB_FTYPE_TOMB], tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
@ -785,7 +811,8 @@ int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxV
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmprAlg, int64_t *fileSize,
|
int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmprAlg, int64_t *fileSize,
|
||||||
TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range) {
|
TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
if (brinBlock->numOfRecords == 0) return 0;
|
if (brinBlock->numOfRecords == 0) return 0;
|
||||||
|
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
@ -838,7 +865,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist);
|
code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size);
|
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size, encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
brinBlk.size[i] = info.compressedSize;
|
brinBlk.size[i] = info.compressedSize;
|
||||||
brinBlk.dp->size += info.compressedSize;
|
brinBlk.dp->size += info.compressedSize;
|
||||||
|
@ -854,7 +881,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist);
|
code = tCompressDataToBuffer(brinBlock->buffers[i].data, &info, buffer0, assist);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size);
|
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size, encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
brinBlk.size[i] = info.compressedSize;
|
brinBlk.size[i] = info.compressedSize;
|
||||||
brinBlk.dp->size += info.compressedSize;
|
brinBlk.dp->size += info.compressedSize;
|
||||||
|
@ -879,10 +906,10 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
if ((code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size))) return code;
|
if ((code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size, encryptAlgorithm, encryptKey))) return code;
|
||||||
*fileSize += buffer0->size;
|
*fileSize += buffer0->size;
|
||||||
brinBlk.dp->size += buffer0->size;
|
brinBlk.dp->size += buffer0->size;
|
||||||
if ((code = tsdbWriteFile(fd, *fileSize, buffer1->data, buffer1->size))) return code;
|
if ((code = tsdbWriteFile(fd, *fileSize, buffer1->data, buffer1->size, encryptAlgorithm, encryptKey))) return code;
|
||||||
*fileSize += buffer1->size;
|
*fileSize += buffer1->size;
|
||||||
brinBlk.dp->size += buffer1->size;
|
brinBlk.dp->size += buffer1->size;
|
||||||
}
|
}
|
||||||
|
@ -902,9 +929,12 @@ static int32_t tsdbDataFileWriteBrinBlock(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
code = tsdbFileWriteBrinBlock(writer->fd[TSDB_FTYPE_HEAD], writer->brinBlock, writer->config->cmprAlg,
|
code = tsdbFileWriteBrinBlock(writer->fd[TSDB_FTYPE_HEAD], writer->brinBlock, writer->config->cmprAlg,
|
||||||
&writer->files[TSDB_FTYPE_HEAD].size, writer->brinBlkArray, writer->buffers,
|
&writer->files[TSDB_FTYPE_HEAD].size, writer->brinBlkArray, writer->buffers,
|
||||||
&writer->ctx->range);
|
&writer->ctx->range, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -995,9 +1025,11 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData
|
||||||
record->blockKeySize = buffers[0].size + buffers[1].size;
|
record->blockKeySize = buffers[0].size + buffers[1].size;
|
||||||
record->blockSize = record->blockKeySize + buffers[2].size + buffers[3].size;
|
record->blockSize = record->blockKeySize + buffers[2].size + buffers[3].size;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
code = tsdbWriteFile(writer->fd[TSDB_FTYPE_DATA], writer->files[TSDB_FTYPE_DATA].size, buffers[i].data,
|
code = tsdbWriteFile(writer->fd[TSDB_FTYPE_DATA], writer->files[TSDB_FTYPE_DATA].size, buffers[i].data,
|
||||||
buffers[i].size);
|
buffers[i].size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[TSDB_FTYPE_DATA].size += buffers[i].size;
|
writer->files[TSDB_FTYPE_DATA].size += buffers[i].size;
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1049,8 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData
|
||||||
record->smaSize = buffers[0].size;
|
record->smaSize = buffers[0].size;
|
||||||
|
|
||||||
if (record->smaSize > 0) {
|
if (record->smaSize > 0) {
|
||||||
code = tsdbWriteFile(writer->fd[TSDB_FTYPE_SMA], record->smaOffset, buffers[0].data, record->smaSize);
|
code = tsdbWriteFile(writer->fd[TSDB_FTYPE_SMA], record->smaOffset, buffers[0].data, record->smaSize,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[TSDB_FTYPE_SMA].size += record->smaSize;
|
writer->files[TSDB_FTYPE_SMA].size += record->smaSize;
|
||||||
}
|
}
|
||||||
|
@ -1288,15 +1321,17 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFooter *footer) {
|
int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFooter *footer, int32_t encryptAlgorithm,
|
||||||
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer));
|
char* encryptKey) {
|
||||||
|
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer), encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
*fileSize += sizeof(*footer);
|
*fileSize += sizeof(*footer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize,
|
int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize,
|
||||||
TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range) {
|
TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
if (TOMB_BLOCK_SIZE(tombBlock) == 0) return 0;
|
if (TOMB_BLOCK_SIZE(tombBlock) == 0) return 0;
|
||||||
|
@ -1348,7 +1383,7 @@ int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAl
|
||||||
code = tCompressDataToBuffer(tombBlock->buffers[i].data, &cinfo, buffer0, assist);
|
code = tCompressDataToBuffer(tombBlock->buffers[i].data, &cinfo, buffer0, assist);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size);
|
code = tsdbWriteFile(fd, *fileSize, buffer0->data, buffer0->size, encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
tombBlk.size[i] = cinfo.compressedSize;
|
tombBlk.size[i] = cinfo.compressedSize;
|
||||||
|
@ -1367,7 +1402,11 @@ static int32_t tsdbDataFileWriteHeadFooter(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbFileWriteHeadFooter(writer->fd[TSDB_FTYPE_HEAD], &writer->files[TSDB_FTYPE_HEAD].size, writer->headFooter);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbFileWriteHeadFooter(writer->fd[TSDB_FTYPE_HEAD], &writer->files[TSDB_FTYPE_HEAD].size, writer->headFooter,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1383,9 +1422,12 @@ static int32_t tsdbDataFileDoWriteTombBlock(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
code = tsdbFileWriteTombBlock(writer->fd[TSDB_FTYPE_TOMB], writer->tombBlock, writer->config->cmprAlg,
|
code = tsdbFileWriteTombBlock(writer->fd[TSDB_FTYPE_TOMB], writer->tombBlock, writer->config->cmprAlg,
|
||||||
&writer->files[TSDB_FTYPE_TOMB].size, writer->tombBlkArray, writer->buffers,
|
&writer->files[TSDB_FTYPE_TOMB].size, writer->tombBlkArray, writer->buffers,
|
||||||
&writer->ctx->tombRange);
|
&writer->ctx->tombRange, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1395,12 +1437,14 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteTombBlk(STsdbFD *fd, const TTombBlkArray *tombBlkArray, SFDataPtr *ptr, int64_t *fileSize) {
|
int32_t tsdbFileWriteTombBlk(STsdbFD *fd, const TTombBlkArray *tombBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
ptr->size = TARRAY2_DATA_LEN(tombBlkArray);
|
ptr->size = TARRAY2_DATA_LEN(tombBlkArray);
|
||||||
if (ptr->size > 0) {
|
if (ptr->size > 0) {
|
||||||
ptr->offset = *fileSize;
|
ptr->offset = *fileSize;
|
||||||
|
|
||||||
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)TARRAY2_DATA(tombBlkArray), ptr->size);
|
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)TARRAY2_DATA(tombBlkArray), ptr->size,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1416,8 +1460,11 @@ static int32_t tsdbDataFileDoWriteTombBlk(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
code = tsdbFileWriteTombBlk(writer->fd[TSDB_FTYPE_TOMB], writer->tombBlkArray, writer->tombFooter->tombBlkPtr,
|
code = tsdbFileWriteTombBlk(writer->fd[TSDB_FTYPE_TOMB], writer->tombBlkArray, writer->tombFooter->tombBlkPtr,
|
||||||
&writer->files[TSDB_FTYPE_TOMB].size);
|
&writer->files[TSDB_FTYPE_TOMB].size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1427,8 +1474,9 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t *fileSize) {
|
int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm,
|
||||||
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer));
|
char* encryptKey) {
|
||||||
|
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer), encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
*fileSize += sizeof(*footer);
|
*fileSize += sizeof(*footer);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1438,7 +1486,11 @@ static int32_t tsdbDataFileWriteTombFooter(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbFileWriteTombFooter(writer->fd[TSDB_FTYPE_TOMB], writer->tombFooter, &writer->files[TSDB_FTYPE_TOMB].size);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbFileWriteTombFooter(writer->fd[TSDB_FTYPE_TOMB], writer->tombFooter, &writer->files[TSDB_FTYPE_TOMB].size,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1515,12 +1567,14 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteBrinBlk(STsdbFD *fd, TBrinBlkArray *brinBlkArray, SFDataPtr *ptr, int64_t *fileSize) {
|
int32_t tsdbFileWriteBrinBlk(STsdbFD *fd, TBrinBlkArray *brinBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
ASSERT(TARRAY2_SIZE(brinBlkArray) > 0);
|
ASSERT(TARRAY2_SIZE(brinBlkArray) > 0);
|
||||||
ptr->offset = *fileSize;
|
ptr->offset = *fileSize;
|
||||||
ptr->size = TARRAY2_DATA_LEN(brinBlkArray);
|
ptr->size = TARRAY2_DATA_LEN(brinBlkArray);
|
||||||
|
|
||||||
int32_t code = tsdbWriteFile(fd, ptr->offset, (uint8_t *)TARRAY2_DATA(brinBlkArray), ptr->size);
|
int32_t code = tsdbWriteFile(fd, ptr->offset, (uint8_t *)TARRAY2_DATA(brinBlkArray), ptr->size, encryptAlgorithm,
|
||||||
|
encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
*fileSize += ptr->size;
|
*fileSize += ptr->size;
|
||||||
|
@ -1531,8 +1585,11 @@ static int32_t tsdbDataFileWriteBrinBlk(SDataFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
code = tsdbFileWriteBrinBlk(writer->fd[TSDB_FTYPE_HEAD], writer->brinBlkArray, writer->headFooter->brinBlkPtr,
|
code = tsdbFileWriteBrinBlk(writer->fd[TSDB_FTYPE_HEAD], writer->brinBlkArray, writer->headFooter->brinBlkPtr,
|
||||||
&writer->files[TSDB_FTYPE_HEAD].size);
|
&writer->files[TSDB_FTYPE_HEAD].size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -1689,10 +1746,11 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
||||||
code = TARRAY2_APPEND(opArr, op);
|
code = TARRAY2_APPEND(opArr, op);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) {
|
for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) {
|
||||||
if (writer->fd[i]) {
|
if (writer->fd[i]) {
|
||||||
code = tsdbFsyncFile(writer->fd[i]);
|
code = tsdbFsyncFile(writer->fd[i], encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
tsdbCloseFile(&writer->fd[i]);
|
tsdbCloseFile(&writer->fd[i]);
|
||||||
}
|
}
|
||||||
|
@ -1729,7 +1787,10 @@ static int32_t tsdbDataFileWriterOpenDataFD(SDataFileWriter *writer) {
|
||||||
if (writer->files[ftype].size == 0) {
|
if (writer->files[ftype].size == 0) {
|
||||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||||
|
|
||||||
code = tsdbWriteFile(writer->fd[ftype], 0, hdr, TSDB_FHDR_SIZE);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbWriteFile(writer->fd[ftype], 0, hdr, TSDB_FHDR_SIZE, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
writer->files[ftype].size += TSDB_FHDR_SIZE;
|
writer->files[ftype].size += TSDB_FHDR_SIZE;
|
||||||
|
@ -1895,7 +1956,9 @@ static int32_t tsdbDataFileWriterOpenTombFD(SDataFileWriter *writer) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||||
code = tsdbWriteFile(writer->fd[ftype], 0, hdr, TSDB_FHDR_SIZE);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbWriteFile(writer->fd[ftype], 0, hdr, TSDB_FHDR_SIZE, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->files[ftype].size += TSDB_FHDR_SIZE;
|
writer->files[ftype].size += TSDB_FHDR_SIZE;
|
||||||
|
|
||||||
|
|
|
@ -97,16 +97,22 @@ int32_t tsdbDataFileFlush(SDataFileWriter *writer);
|
||||||
|
|
||||||
// head
|
// head
|
||||||
int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmprAlg, int64_t *fileSize,
|
int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmprAlg, int64_t *fileSize,
|
||||||
TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range);
|
TBrinBlkArray *brinBlkArray, SBuffer *buffers, SVersionRange *range,
|
||||||
int32_t tsdbFileWriteBrinBlk(STsdbFD *fd, TBrinBlkArray *brinBlkArray, SFDataPtr *ptr, int64_t *fileSize);
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFooter *footer);
|
int32_t tsdbFileWriteBrinBlk(STsdbFD *fd, TBrinBlkArray *brinBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
int32_t tsdbFileWriteHeadFooter(STsdbFD *fd, int64_t *fileSize, const SHeadFooter *footer,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
|
||||||
// tomb
|
// tomb
|
||||||
int32_t tsdbDataFileWriteTombRecord(SDataFileWriter *writer, const STombRecord *record);
|
int32_t tsdbDataFileWriteTombRecord(SDataFileWriter *writer, const STombRecord *record);
|
||||||
int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize,
|
int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAlg, int64_t *fileSize,
|
||||||
TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range);
|
TTombBlkArray *tombBlkArray, SBuffer *buffers, SVersionRange *range,
|
||||||
int32_t tsdbFileWriteTombBlk(STsdbFD *fd, const TTombBlkArray *tombBlkArray, SFDataPtr *ptr, int64_t *fileSize);
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t *fileSize);
|
int32_t tsdbFileWriteTombBlk(STsdbFD *fd, const TTombBlkArray *tombBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer);
|
int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer);
|
||||||
|
|
|
@ -33,10 +33,14 @@ typedef struct SFDataPtr {
|
||||||
|
|
||||||
extern int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppFD, int32_t lcn);
|
extern int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppFD, int32_t lcn);
|
||||||
extern void tsdbCloseFile(STsdbFD **ppFD);
|
extern void tsdbCloseFile(STsdbFD **ppFD);
|
||||||
extern int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size);
|
|
||||||
extern int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint);
|
extern int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size,
|
||||||
extern int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint);
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
extern int32_t tsdbFsyncFile(STsdbFD *pFD);
|
extern int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
extern int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
extern int32_t tsdbFsyncFile(STsdbFD *pFD, int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
|
||||||
typedef struct SColCompressInfo SColCompressInfo;
|
typedef struct SColCompressInfo SColCompressInfo;
|
||||||
struct SColCompressInfo {
|
struct SColCompressInfo {
|
||||||
|
|
|
@ -152,7 +152,8 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr) {
|
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm,
|
||||||
|
char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
@ -166,7 +167,7 @@ int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeade
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbDataFileRAWWriteBlockData(writer->dataWriter, bHdr);
|
code = tsdbDataFileRAWWriteBlockData(writer->dataWriter, bHdr, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
writer->ctx->offset += bHdr->dataLength;
|
writer->ctx->offset += bHdr->dataLength;
|
||||||
|
|
|
@ -36,7 +36,8 @@ typedef struct SFSetRAWWriter SFSetRAWWriter;
|
||||||
|
|
||||||
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer);
|
int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer);
|
||||||
int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr);
|
int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr);
|
||||||
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr);
|
int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm,
|
||||||
|
char* encryptKey);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -4501,6 +4501,10 @@ int32_t tsdbReaderResume2(STsdbReader* pReader) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// open reader failure may cause the flag still to be READER_STATUS_SUSPEND, which may cause suspend reader failure.
|
||||||
|
// So we need to set it A.S.A.P
|
||||||
|
pReader->flag = READER_STATUS_NORMAL;
|
||||||
|
|
||||||
if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) {
|
if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) {
|
||||||
code = doOpenReaderImpl(pReader);
|
code = doOpenReaderImpl(pReader);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4531,7 +4535,6 @@ int32_t tsdbReaderResume2(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pReader->flag = READER_STATUS_NORMAL;
|
|
||||||
tsdbDebug("reader: %p resumed uid %" PRIu64 ", numOfTable:%" PRId32 ", in this query %s", pReader,
|
tsdbDebug("reader: %p resumed uid %" PRIu64 ", numOfTable:%" PRId32 ", in this query %s", pReader,
|
||||||
pBlockScanInfo ? (*pBlockScanInfo)->uid : 0, numOfTables, pReader->idStr);
|
pBlockScanInfo ? (*pBlockScanInfo)->uid : 0, numOfTables, pReader->idStr);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "cos.h"
|
#include "cos.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
#include "crypt.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
||||||
|
@ -169,7 +170,7 @@ void tsdbCloseFile(STsdbFD **ppFD) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (!pFD->pFD) {
|
if (!pFD->pFD) {
|
||||||
|
@ -197,6 +198,28 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
||||||
|
|
||||||
|
if(encryptAlgorithm == DND_CA_SM4){
|
||||||
|
//if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){
|
||||||
|
unsigned char PacketData[128];
|
||||||
|
int NewLen;
|
||||||
|
int32_t count = 0;
|
||||||
|
while (count < pFD->szPage) {
|
||||||
|
SCryptOpts opts = {0};
|
||||||
|
opts.len = 128;
|
||||||
|
opts.source = pFD->pBuf + count;
|
||||||
|
opts.result = PacketData;
|
||||||
|
opts.unitLen = 128;
|
||||||
|
//strncpy(opts.key, tsEncryptKey, 16);
|
||||||
|
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
|
||||||
|
NewLen = CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
memcpy(pFD->pBuf + count, PacketData, NewLen);
|
||||||
|
count += NewLen;
|
||||||
|
}
|
||||||
|
//tsdbDebug("CBC_Encrypt count:%d %s", count, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
|
@ -214,7 +237,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
// ASSERT(pgno <= pFD->szFile);
|
// ASSERT(pgno <= pFD->szFile);
|
||||||
|
@ -274,6 +297,30 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
if(encryptAlgorithm == DND_CA_SM4){
|
||||||
|
//if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){
|
||||||
|
unsigned char PacketData[128];
|
||||||
|
int NewLen;
|
||||||
|
|
||||||
|
int32_t count = 0;
|
||||||
|
while(count < pFD->szPage)
|
||||||
|
{
|
||||||
|
SCryptOpts opts = {0};
|
||||||
|
opts.len = 128;
|
||||||
|
opts.source = pFD->pBuf + count;
|
||||||
|
opts.result = PacketData;
|
||||||
|
opts.unitLen = 128;
|
||||||
|
//strncpy(opts.key, tsEncryptKey, 16);
|
||||||
|
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
|
||||||
|
NewLen = CBC_Decrypt(&opts);
|
||||||
|
|
||||||
|
memcpy(pFD->pBuf + count, PacketData, NewLen);
|
||||||
|
count += NewLen;
|
||||||
|
}
|
||||||
|
//tsdbDebug("CBC_Decrypt count:%d %s", count, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
|
if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
|
||||||
code = TSDB_CODE_FILE_CORRUPTED;
|
code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
|
@ -286,7 +333,8 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size) {
|
int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm,
|
||||||
|
char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
|
int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
|
||||||
int64_t pgno = OFFSET_PGNO(fOffset, pFD->szPage);
|
int64_t pgno = OFFSET_PGNO(fOffset, pFD->szPage);
|
||||||
|
@ -295,11 +343,11 @@ int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (pFD->pgno != pgno) {
|
if (pFD->pgno != pgno) {
|
||||||
code = tsdbWriteFilePage(pFD);
|
code = tsdbWriteFilePage(pFD, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
|
|
||||||
if (pgno <= pFD->szFile) {
|
if (pgno <= pFD->szFile) {
|
||||||
code = tsdbReadFilePage(pFD, pgno);
|
code = tsdbReadFilePage(pFD, pgno, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
} else {
|
} else {
|
||||||
pFD->pgno = pgno;
|
pFD->pgno = pgno;
|
||||||
|
@ -318,7 +366,8 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbReadFileImp(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size) {
|
static int32_t tsdbReadFileImp(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm,
|
||||||
|
char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t n = 0;
|
int64_t n = 0;
|
||||||
int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
|
int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
|
||||||
|
@ -331,7 +380,7 @@ static int32_t tsdbReadFileImp(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int6
|
||||||
|
|
||||||
while (n < size) {
|
while (n < size) {
|
||||||
if (pFD->pgno != pgno) {
|
if (pFD->pgno != pgno) {
|
||||||
code = tsdbReadFilePage(pFD, pgno);
|
code = tsdbReadFilePage(pFD, pgno, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +572,8 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint) {
|
int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (!pFD->pFD) {
|
if (!pFD->pFD) {
|
||||||
code = tsdbOpenFileImpl(pFD);
|
code = tsdbOpenFileImpl(pFD);
|
||||||
|
@ -535,26 +585,28 @@ int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size,
|
||||||
if (pFD->lcn > 1 /*pFD->s3File && tsS3BlockSize < 0*/) {
|
if (pFD->lcn > 1 /*pFD->s3File && tsS3BlockSize < 0*/) {
|
||||||
return tsdbReadFileS3(pFD, offset, pBuf, size, szHint);
|
return tsdbReadFileS3(pFD, offset, pBuf, size, szHint);
|
||||||
} else {
|
} else {
|
||||||
return tsdbReadFileImp(pFD, offset, pBuf, size);
|
return tsdbReadFileImp(pFD, offset, pBuf, size, encryptAlgorithm, encryptKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint) {
|
int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
code = tBufferEnsureCapacity(buffer, buffer->size + size);
|
code = tBufferEnsureCapacity(buffer, buffer->size + size);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
code = tsdbReadFile(pFD, offset, (uint8_t *)tBufferGetDataEnd(buffer), size, szHint);
|
code = tsdbReadFile(pFD, offset, (uint8_t *)tBufferGetDataEnd(buffer), size, szHint,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
buffer->size += size;
|
buffer->size += size;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFsyncFile(STsdbFD *pFD) {
|
int32_t tsdbFsyncFile(STsdbFD *pFD, int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
/*
|
/*
|
||||||
if (pFD->s3File) {
|
if (pFD->s3File) {
|
||||||
|
@ -562,7 +614,7 @@ int32_t tsdbFsyncFile(STsdbFD *pFD) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
code = tsdbWriteFilePage(pFD);
|
code = tsdbWriteFilePage(pFD, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
|
|
||||||
if (taosFsyncFile(pFD->pFD) < 0) {
|
if (taosFsyncFile(pFD->pFD) < 0) {
|
||||||
|
@ -673,7 +725,9 @@ int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0);
|
int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
|
@ -710,7 +764,9 @@ int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
code = tsdbReadFile(pReader->aSttFD[iStt], offset, pReader->aBuf[0], size, 0);
|
int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(pReader->aSttFD[iStt], offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
|
@ -743,7 +799,9 @@ int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *m
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0);
|
int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
|
@ -836,7 +894,9 @@ int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelDa
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0);
|
int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// // decode
|
// // decode
|
||||||
|
@ -876,7 +936,9 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// read
|
// read
|
||||||
code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0);
|
int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
|
|
|
@ -545,7 +545,10 @@ static int32_t tsdbSnapRAWWriteTimeSeriesData(STsdbSnapRAWWriter* writer, STsdbD
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbFSetRAWWriteBlockData(writer->ctx->fsetWriter, bHdr);
|
int32_t encryptAlgorithm = writer->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbFSetRAWWriteBlockData(writer->ctx->fsetWriter, bHdr, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
|
|
@ -63,7 +63,10 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
|
||||||
int64_t offset = config->file->size - sizeof(SSttFooter);
|
int64_t offset = config->file->size - sizeof(SSttFooter);
|
||||||
ASSERT(offset >= TSDB_FHDR_SIZE);
|
ASSERT(offset >= TSDB_FHDR_SIZE);
|
||||||
|
|
||||||
code = tsdbReadFile(reader[0]->fd, offset, (uint8_t *)(reader[0]->footer), sizeof(SSttFooter), 0);
|
int32_t encryptAlgoirthm = config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbReadFile(reader[0]->fd, offset, (uint8_t *)(reader[0]->footer), sizeof(SSttFooter), 0, encryptAlgoirthm,
|
||||||
|
encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -99,8 +102,11 @@ int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray *
|
||||||
void *data = taosMemoryMalloc(reader->footer->statisBlkPtr->size);
|
void *data = taosMemoryMalloc(reader->footer->statisBlkPtr->size);
|
||||||
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
tsdbReadFile(reader->fd, reader->footer->statisBlkPtr->offset, data, reader->footer->statisBlkPtr->size, 0);
|
tsdbReadFile(reader->fd, reader->footer->statisBlkPtr->offset, data, reader->footer->statisBlkPtr->size, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
return code;
|
return code;
|
||||||
|
@ -127,8 +133,11 @@ int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tom
|
||||||
void *data = taosMemoryMalloc(reader->footer->tombBlkPtr->size);
|
void *data = taosMemoryMalloc(reader->footer->tombBlkPtr->size);
|
||||||
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
tsdbReadFile(reader->fd, reader->footer->tombBlkPtr->offset, data, reader->footer->tombBlkPtr->size, 0);
|
tsdbReadFile(reader->fd, reader->footer->tombBlkPtr->offset, data, reader->footer->tombBlkPtr->size, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
return code;
|
return code;
|
||||||
|
@ -155,8 +164,11 @@ int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBl
|
||||||
void *data = taosMemoryMalloc(reader->footer->sttBlkPtr->size);
|
void *data = taosMemoryMalloc(reader->footer->sttBlkPtr->size);
|
||||||
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
if (!data) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
tsdbReadFile(reader->fd, reader->footer->sttBlkPtr->offset, data, reader->footer->sttBlkPtr->size, 0);
|
tsdbReadFile(reader->fd, reader->footer->sttBlkPtr->offset, data, reader->footer->sttBlkPtr->size, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
return code;
|
return code;
|
||||||
|
@ -181,9 +193,12 @@ int32_t tsdbSttFileReadBlockData(SSttFileReader *reader, const SSttBlk *sttBlk,
|
||||||
SBuffer *buffer0 = reader->buffers + 0;
|
SBuffer *buffer0 = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load data
|
// load data
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szBlock, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szBlock, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
|
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
|
||||||
|
@ -207,9 +222,12 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
|
||||||
SBuffer *buffer1 = reader->buffers + 1;
|
SBuffer *buffer1 = reader->buffers + 1;
|
||||||
SBuffer *assist = reader->buffers + 2;
|
SBuffer *assist = reader->buffers + 2;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load key part
|
// load key part
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szKey, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset, sttBlk->bInfo.szKey, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode header
|
// decode header
|
||||||
|
@ -244,7 +262,8 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
|
||||||
|
|
||||||
// load SBlockCol part
|
// load SBlockCol part
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey, hdr.szBlkCol, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey, hdr.szBlkCol, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// load each column
|
// load each column
|
||||||
|
@ -290,7 +309,8 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
|
||||||
tBufferClear(buffer1);
|
tBufferClear(buffer1);
|
||||||
code =
|
code =
|
||||||
tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey + hdr.szBlkCol + blockCol.offset,
|
tsdbReadFileToBuffer(reader->fd, sttBlk->bInfo.offset + sttBlk->bInfo.szKey + hdr.szBlkCol + blockCol.offset,
|
||||||
blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, 0);
|
blockCol.szBitmap + blockCol.szOffset + blockCol.szValue, buffer1, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode the buffer
|
// decode the buffer
|
||||||
|
@ -314,9 +334,12 @@ int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *tombBlk
|
||||||
SBuffer *buffer0 = reader->buffers + 0;
|
SBuffer *buffer0 = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load
|
// load
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd, tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd, tombBlk->dp->offset, tombBlk->dp->size, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
|
@ -351,9 +374,12 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta
|
||||||
SBuffer *buffer0 = reader->buffers + 0;
|
SBuffer *buffer0 = reader->buffers + 0;
|
||||||
SBuffer *assist = reader->buffers + 1;
|
SBuffer *assist = reader->buffers + 1;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
// load data
|
// load data
|
||||||
tBufferClear(buffer0);
|
tBufferClear(buffer0);
|
||||||
code = tsdbReadFileToBuffer(reader->fd, statisBlk->dp->offset, statisBlk->dp->size, buffer0, 0);
|
code = tsdbReadFileToBuffer(reader->fd, statisBlk->dp->offset, statisBlk->dp->size, buffer0, 0,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// decode data
|
// decode data
|
||||||
|
@ -442,7 +468,7 @@ struct SSttFileWriter {
|
||||||
|
|
||||||
static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, SColCompressInfo *info,
|
static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, SColCompressInfo *info,
|
||||||
int64_t *fileSize, TSttBlkArray *sttBlkArray, SBuffer *buffers,
|
int64_t *fileSize, TSttBlkArray *sttBlkArray, SBuffer *buffers,
|
||||||
SVersionRange *range) {
|
SVersionRange *range, int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
if (blockData->nRow == 0) return 0;
|
if (blockData->nRow == 0) return 0;
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -474,7 +500,7 @@ static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, S
|
||||||
sttBlk->bInfo.szBlock = buffers[2].size + buffers[3].size + sttBlk->bInfo.szKey;
|
sttBlk->bInfo.szBlock = buffers[2].size + buffers[3].size + sttBlk->bInfo.szKey;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (buffers[i].size) {
|
if (buffers[i].size) {
|
||||||
code = tsdbWriteFile(fd, *fileSize, buffers[i].data, buffers[i].size);
|
code = tsdbWriteFile(fd, *fileSize, buffers[i].data, buffers[i].size, encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
*fileSize += buffers[i].size;
|
*fileSize += buffers[i].size;
|
||||||
}
|
}
|
||||||
|
@ -498,8 +524,11 @@ static int32_t tsdbSttFileDoWriteBlockData(SSttFileWriter *writer) {
|
||||||
SColCompressInfo info = {.defaultCmprAlg = writer->config->cmprAlg, .pColCmpr = NULL};
|
SColCompressInfo info = {.defaultCmprAlg = writer->config->cmprAlg, .pColCmpr = NULL};
|
||||||
code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, uid, &(info.pColCmpr));
|
code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, uid, &(info.pColCmpr));
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
code = tsdbFileDoWriteSttBlockData(writer->fd, writer->blockData, &info, &writer->file->size, writer->sttBlkArray,
|
code = tsdbFileDoWriteSttBlockData(writer->fd, writer->blockData, &info, &writer->file->size, writer->sttBlkArray,
|
||||||
writer->buffers, &writer->ctx->range);
|
writer->buffers, &writer->ctx->range,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -538,6 +567,9 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
|
||||||
statisBlk.maxTbid.suid = record.suid;
|
statisBlk.maxTbid.suid = record.suid;
|
||||||
statisBlk.maxTbid.uid = record.uid;
|
statisBlk.maxTbid.uid = record.uid;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
// compress each column
|
// compress each column
|
||||||
for (int32_t i = 0; i < ARRAY_SIZE(statisBlk.size); i++) {
|
for (int32_t i = 0; i < ARRAY_SIZE(statisBlk.size); i++) {
|
||||||
SCompressInfo info = {
|
SCompressInfo info = {
|
||||||
|
@ -550,7 +582,8 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
|
||||||
code = tCompressDataToBuffer(statisBlock->buffers[i].data, &info, buffer0, assist);
|
code = tCompressDataToBuffer(statisBlock->buffers[i].data, &info, buffer0, assist);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, info.compressedSize);
|
code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, info.compressedSize,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
statisBlk.size[i] = info.compressedSize;
|
statisBlk.size[i] = info.compressedSize;
|
||||||
|
@ -579,12 +612,12 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, buffer0->size);
|
code = tsdbWriteFile(writer->fd, writer->file->size, buffer0->data, buffer0->size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->file->size += buffer0->size;
|
writer->file->size += buffer0->size;
|
||||||
statisBlk.dp->size += buffer0->size;
|
statisBlk.dp->size += buffer0->size;
|
||||||
|
|
||||||
code = tsdbWriteFile(writer->fd, writer->file->size, buffer1->data, buffer1->size);
|
code = tsdbWriteFile(writer->fd, writer->file->size, buffer1->data, buffer1->size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->file->size += buffer1->size;
|
writer->file->size += buffer1->size;
|
||||||
statisBlk.dp->size += buffer1->size;
|
statisBlk.dp->size += buffer1->size;
|
||||||
|
@ -608,8 +641,12 @@ static int32_t tsdbSttFileDoWriteTombBlock(SSttFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
code = tsdbFileWriteTombBlock(writer->fd, writer->tombBlock, writer->config->cmprAlg, &writer->file->size,
|
code = tsdbFileWriteTombBlock(writer->fd, writer->tombBlock, writer->config->cmprAlg, &writer->file->size,
|
||||||
writer->tombBlkArray, writer->buffers, &writer->ctx->range);
|
writer->tombBlkArray, writer->buffers, &writer->ctx->range,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -619,12 +656,14 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize) {
|
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
|
int32_t encryptAlgorithm, char* encryptKey) {
|
||||||
ptr->size = TARRAY2_DATA_LEN(sttBlkArray);
|
ptr->size = TARRAY2_DATA_LEN(sttBlkArray);
|
||||||
if (ptr->size > 0) {
|
if (ptr->size > 0) {
|
||||||
ptr->offset = *fileSize;
|
ptr->offset = *fileSize;
|
||||||
|
|
||||||
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)TARRAY2_DATA(sttBlkArray), ptr->size);
|
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)TARRAY2_DATA(sttBlkArray), ptr->size, encryptAlgorithm,
|
||||||
|
encryptKey);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +677,11 @@ static int32_t tsdbSttFileDoWriteSttBlk(SSttFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
||||||
code = tsdbFileWriteSttBlk(writer->fd, writer->sttBlkArray, writer->footer->sttBlkPtr, &writer->file->size);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbFileWriteSttBlk(writer->fd, writer->sttBlkArray, writer->footer->sttBlkPtr, &writer->file->size,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -651,12 +694,14 @@ _exit:
|
||||||
static int32_t tsdbSttFileDoWriteStatisBlk(SSttFileWriter *writer) {
|
static int32_t tsdbSttFileDoWriteStatisBlk(SSttFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
writer->footer->statisBlkPtr->size = TARRAY2_DATA_LEN(writer->statisBlkArray);
|
writer->footer->statisBlkPtr->size = TARRAY2_DATA_LEN(writer->statisBlkArray);
|
||||||
if (writer->footer->statisBlkPtr->size) {
|
if (writer->footer->statisBlkPtr->size) {
|
||||||
writer->footer->statisBlkPtr->offset = writer->file->size;
|
writer->footer->statisBlkPtr->offset = writer->file->size;
|
||||||
code = tsdbWriteFile(writer->fd, writer->file->size, (const uint8_t *)TARRAY2_DATA(writer->statisBlkArray),
|
code = tsdbWriteFile(writer->fd, writer->file->size, (const uint8_t *)TARRAY2_DATA(writer->statisBlkArray),
|
||||||
writer->footer->statisBlkPtr->size);
|
writer->footer->statisBlkPtr->size, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->file->size += writer->footer->statisBlkPtr->size;
|
writer->file->size += writer->footer->statisBlkPtr->size;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +717,11 @@ static int32_t tsdbSttFileDoWriteTombBlk(SSttFileWriter *writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbFileWriteTombBlk(writer->fd, writer->tombBlkArray, writer->footer->tombBlkPtr, &writer->file->size);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbFileWriteTombBlk(writer->fd, writer->tombBlkArray, writer->footer->tombBlkPtr, &writer->file->size,
|
||||||
|
encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -682,15 +731,19 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize) {
|
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm,
|
||||||
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer));
|
char* encryptKey) {
|
||||||
|
int32_t code = tsdbWriteFile(fd, *fileSize, (const uint8_t *)footer, sizeof(*footer), encryptAlgorithm, encryptKey);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
*fileSize += sizeof(*footer);
|
*fileSize += sizeof(*footer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbSttFileDoWriteFooter(SSttFileWriter *writer) {
|
static int32_t tsdbSttFileDoWriteFooter(SSttFileWriter *writer) {
|
||||||
return tsdbFileWriteSttFooter(writer->fd, writer->footer, &writer->file->size);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
return tsdbFileWriteSttFooter(writer->fd, writer->footer, &writer->file->size, encryptAlgorithm, encryptKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
||||||
|
@ -728,7 +781,10 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||||
code = tsdbWriteFile(writer->fd, 0, hdr, sizeof(hdr));
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbWriteFile(writer->fd, 0, hdr, sizeof(hdr), encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
writer->file->size += sizeof(hdr);
|
writer->file->size += sizeof(hdr);
|
||||||
|
|
||||||
|
@ -793,7 +849,9 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o
|
||||||
code = tsdbSttFileDoUpdateHeader(writer);
|
code = tsdbSttFileDoUpdateHeader(writer);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbFsyncFile(writer->fd);
|
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = writer->config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
code = tsdbFsyncFile(writer->fd, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
tsdbCloseFile(&writer->fd);
|
tsdbCloseFile(&writer->fd);
|
||||||
|
|
|
@ -71,8 +71,10 @@ int32_t tsdbSttFileWriteBlockData(SSttFileWriter *writer, SBlockData *pBlockData
|
||||||
int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *record);
|
int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *record);
|
||||||
bool tsdbSttFileWriterIsOpened(SSttFileWriter *writer);
|
bool tsdbSttFileWriterIsOpened(SSttFileWriter *writer);
|
||||||
|
|
||||||
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize);
|
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||||
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize);
|
int32_t encryptAlgorithm, char* encryptKey);
|
||||||
|
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm,
|
||||||
|
char* encryptKey);
|
||||||
|
|
||||||
struct SSttFileWriterConfig {
|
struct SSttFileWriterConfig {
|
||||||
STsdb *tsdb;
|
STsdb *tsdb;
|
||||||
|
|
|
@ -37,6 +37,8 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
||||||
int8_t cmprAlg;
|
int8_t cmprAlg;
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
SBuffer buffers[10];
|
SBuffer buffers[10];
|
||||||
|
int32_t encryptAlgorithm;
|
||||||
|
char* encryptKey;
|
||||||
// reader
|
// reader
|
||||||
SArray *aBlockIdx;
|
SArray *aBlockIdx;
|
||||||
SMapData mDataBlk[1];
|
SMapData mDataBlk[1];
|
||||||
|
@ -50,6 +52,8 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
||||||
.maxRow = tsdb->pVnode->config.tsdbCfg.maxRows,
|
.maxRow = tsdb->pVnode->config.tsdbCfg.maxRows,
|
||||||
.cmprAlg = tsdb->pVnode->config.tsdbCfg.compression,
|
.cmprAlg = tsdb->pVnode->config.tsdbCfg.compression,
|
||||||
.szPage = tsdb->pVnode->config.tsdbPageSize,
|
.szPage = tsdb->pVnode->config.tsdbPageSize,
|
||||||
|
.encryptAlgorithm = tsdb->pVnode->config.tsdbCfg.encryptAlgorithm,
|
||||||
|
.encryptKey = tsdb->pVnode->config.tsdbCfg.encryptKey,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// read SBlockIdx array
|
// read SBlockIdx array
|
||||||
|
@ -136,7 +140,7 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
||||||
if (ctx->brinBlock->numOfRecords >= ctx->maxRow) {
|
if (ctx->brinBlock->numOfRecords >= ctx->maxRow) {
|
||||||
SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
||||||
code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size,
|
code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size,
|
||||||
ctx->brinBlkArray, ctx->buffers, &range);
|
ctx->brinBlkArray, ctx->buffers, &range, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,18 +149,19 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
||||||
if (ctx->brinBlock->numOfRecords > 0) {
|
if (ctx->brinBlock->numOfRecords > 0) {
|
||||||
SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
SVersionRange range = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
||||||
code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size,
|
code = tsdbFileWriteBrinBlock(ctx->fd, ctx->brinBlock, ctx->cmprAlg, &fset->farr[TSDB_FTYPE_HEAD]->f->size,
|
||||||
ctx->brinBlkArray, ctx->buffers, &range);
|
ctx->brinBlkArray, ctx->buffers, &range, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbFileWriteBrinBlk(ctx->fd, ctx->brinBlkArray, ctx->footer->brinBlkPtr,
|
code = tsdbFileWriteBrinBlk(ctx->fd, ctx->brinBlkArray, ctx->footer->brinBlkPtr,
|
||||||
&fset->farr[TSDB_FTYPE_HEAD]->f->size);
|
&fset->farr[TSDB_FTYPE_HEAD]->f->size, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbFileWriteHeadFooter(ctx->fd, &fset->farr[TSDB_FTYPE_HEAD]->f->size, ctx->footer);
|
code = tsdbFileWriteHeadFooter(ctx->fd, &fset->farr[TSDB_FTYPE_HEAD]->f->size, ctx->footer, ctx->encryptAlgorithm,
|
||||||
|
ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbFsyncFile(ctx->fd);
|
code = tsdbFsyncFile(ctx->fd, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
tsdbCloseFile(&ctx->fd);
|
tsdbCloseFile(&ctx->fd);
|
||||||
|
@ -252,12 +257,16 @@ static int32_t tsdbUpgradeSttFile(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReade
|
||||||
STFileObj *fobj;
|
STFileObj *fobj;
|
||||||
struct {
|
struct {
|
||||||
int32_t szPage;
|
int32_t szPage;
|
||||||
|
int32_t encryptAlgorithm;
|
||||||
|
char* encryptKey;
|
||||||
// writer
|
// writer
|
||||||
STsdbFD *fd;
|
STsdbFD *fd;
|
||||||
TSttBlkArray sttBlkArray[1];
|
TSttBlkArray sttBlkArray[1];
|
||||||
SSttFooter footer[1];
|
SSttFooter footer[1];
|
||||||
} ctx[1] = {{
|
} ctx[1] = {{
|
||||||
.szPage = tsdb->pVnode->config.tsdbPageSize,
|
.szPage = tsdb->pVnode->config.tsdbPageSize,
|
||||||
|
.encryptAlgorithm = tsdb->pVnode->config.tsdbCfg.encryptAlgorithm,
|
||||||
|
.encryptKey = tsdb->pVnode->config.tsdbCfg.encryptKey,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
STFile file = {
|
STFile file = {
|
||||||
|
@ -280,13 +289,14 @@ static int32_t tsdbUpgradeSttFile(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReade
|
||||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbFileWriteSttBlk(ctx->fd, ctx->sttBlkArray, ctx->footer->sttBlkPtr, &fobj->f->size);
|
code = tsdbFileWriteSttBlk(ctx->fd, ctx->sttBlkArray, ctx->footer->sttBlkPtr, &fobj->f->size, ctx->encryptAlgorithm,
|
||||||
|
ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||||
|
|
||||||
code = tsdbFileWriteSttFooter(ctx->fd, ctx->footer, &fobj->f->size);
|
code = tsdbFileWriteSttFooter(ctx->fd, ctx->footer, &fobj->f->size, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||||
|
|
||||||
code = tsdbFsyncFile(ctx->fd);
|
code = tsdbFsyncFile(ctx->fd, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit1);
|
TSDB_CHECK_CODE(code, lino, _exit1);
|
||||||
|
|
||||||
tsdbCloseFile(&ctx->fd);
|
tsdbCloseFile(&ctx->fd);
|
||||||
|
@ -431,7 +441,10 @@ static int32_t tsdbUpgradeOpenTombFile(STsdb *tsdb, STFileSet *fset, STsdbFD **f
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||||
code = tsdbWriteFile(fd[0], 0, hdr, TSDB_FHDR_SIZE);
|
int32_t encryptAlgorithm = tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||||
|
char* encryptKey = tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||||
|
|
||||||
|
code = tsdbWriteFile(fd[0], 0, hdr, TSDB_FHDR_SIZE, encryptAlgorithm, encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
fobj[0]->f->size += TSDB_FHDR_SIZE;
|
fobj[0]->f->size += TSDB_FHDR_SIZE;
|
||||||
|
|
||||||
|
@ -454,6 +467,8 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray *
|
||||||
int64_t minKey;
|
int64_t minKey;
|
||||||
int64_t maxKey;
|
int64_t maxKey;
|
||||||
SBuffer buffers[10];
|
SBuffer buffers[10];
|
||||||
|
int32_t encryptAlgorithm;
|
||||||
|
char* encryptKey;
|
||||||
// reader
|
// reader
|
||||||
SArray *aDelData;
|
SArray *aDelData;
|
||||||
// writer
|
// writer
|
||||||
|
@ -466,6 +481,8 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray *
|
||||||
} ctx[1] = {{
|
} ctx[1] = {{
|
||||||
.maxRow = tsdb->pVnode->config.tsdbCfg.maxRows,
|
.maxRow = tsdb->pVnode->config.tsdbCfg.maxRows,
|
||||||
.cmprAlg = tsdb->pVnode->config.tsdbCfg.compression,
|
.cmprAlg = tsdb->pVnode->config.tsdbCfg.compression,
|
||||||
|
.encryptAlgorithm = tsdb->pVnode->config.tsdbCfg.encryptAlgorithm,
|
||||||
|
.encryptKey = tsdb->pVnode->config.tsdbCfg.encryptKey,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
tsdbFidKeyRange(fset->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &ctx->minKey, &ctx->maxKey);
|
tsdbFidKeyRange(fset->fid, tsdb->keepCfg.days, tsdb->keepCfg.precision, &ctx->minKey, &ctx->maxKey);
|
||||||
|
@ -502,7 +519,7 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray *
|
||||||
}
|
}
|
||||||
SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
||||||
code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray,
|
code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray,
|
||||||
ctx->buffers, &tombRange);
|
ctx->buffers, &tombRange, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,26 +532,30 @@ static int32_t tsdbDumpTombDataToFSet(STsdb *tsdb, SDelFReader *reader, SArray *
|
||||||
}
|
}
|
||||||
SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
SVersionRange tombRange = {.minVer = VERSION_MAX, .maxVer = VERSION_MIN};
|
||||||
code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray,
|
code = tsdbFileWriteTombBlock(ctx->fd, ctx->tombBlock, ctx->cmprAlg, &ctx->fobj->f->size, ctx->tombBlkArray,
|
||||||
ctx->buffers, &tombRange);
|
ctx->buffers, &tombRange, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->fd != NULL) {
|
if (ctx->fd != NULL) {
|
||||||
if (ctx->toStt) {
|
if (ctx->toStt) {
|
||||||
code = tsdbFileWriteTombBlk(ctx->fd, ctx->tombBlkArray, ctx->sttFooter->tombBlkPtr, &ctx->fobj->f->size);
|
code = tsdbFileWriteTombBlk(ctx->fd, ctx->tombBlkArray, ctx->sttFooter->tombBlkPtr, &ctx->fobj->f->size,
|
||||||
|
ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbFileWriteSttFooter(ctx->fd, ctx->sttFooter, &ctx->fobj->f->size);
|
code = tsdbFileWriteSttFooter(ctx->fd, ctx->sttFooter, &ctx->fobj->f->size, ctx->encryptAlgorithm,
|
||||||
|
ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {
|
||||||
code = tsdbFileWriteTombBlk(ctx->fd, ctx->tombBlkArray, ctx->tombFooter->tombBlkPtr, &ctx->fobj->f->size);
|
code = tsdbFileWriteTombBlk(ctx->fd, ctx->tombBlkArray, ctx->tombFooter->tombBlkPtr, &ctx->fobj->f->size,
|
||||||
|
ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbFileWriteTombFooter(ctx->fd, ctx->tombFooter, &ctx->fobj->f->size);
|
code = tsdbFileWriteTombFooter(ctx->fd, ctx->tombFooter, &ctx->fobj->f->size, ctx->encryptAlgorithm,
|
||||||
|
ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbFsyncFile(ctx->fd);
|
code = tsdbFsyncFile(ctx->fd, ctx->encryptAlgorithm, ctx->encryptKey);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
tsdbCloseFile(&ctx->fd);
|
tsdbCloseFile(&ctx->fd);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
|
||||||
.dbname = "",
|
.dbname = "",
|
||||||
|
@ -133,6 +134,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
tjsonAddItemToArray(pNodeRetentions, pNodeRetention);
|
tjsonAddItemToArray(pNodeRetentions, pNodeRetention);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
||||||
|
@ -140,6 +142,8 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "sstTrigger", pCfg->sttTrigger) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "sstTrigger", pCfg->sttTrigger) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
|
||||||
|
@ -242,6 +246,19 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
tjsonGetNumberValue(pNodeRetention, "keep", (pCfg->tsdbCfg.retentions)[i].keep, code);
|
tjsonGetNumberValue(pNodeRetention, "keep", (pCfg->tsdbCfg.retentions)[i].keep, code);
|
||||||
tjsonGetNumberValue(pNodeRetention, "keepUnit", (pCfg->tsdbCfg.retentions)[i].keepUnit, code);
|
tjsonGetNumberValue(pNodeRetention, "keepUnit", (pCfg->tsdbCfg.retentions)[i].keepUnit, code);
|
||||||
}
|
}
|
||||||
|
tjsonGetNumberValue(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
|
||||||
|
if(tsEncryptKey[0] == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code);
|
tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod, code);
|
tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod, code);
|
||||||
|
@ -256,6 +273,32 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level, code);
|
tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level, code);
|
||||||
if (code < 0) return -1;
|
if (code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
|
||||||
|
if(tsEncryptKey[0] == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
tjsonGetNumberValue(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm, code);
|
||||||
|
if (code < 0) return -1;
|
||||||
|
#if defined(TD_ENTERPRISE)
|
||||||
|
if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
|
||||||
|
if(tsEncryptKey[0] == 0){
|
||||||
|
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code);
|
tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code);
|
||||||
if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER;
|
if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER;
|
||||||
tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin, code);
|
tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin, code);
|
||||||
|
|
|
@ -579,12 +579,12 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
|
||||||
vInfo("vgId:%d sync restore finished, start to launch stream task(s)", pVnode->config.vgId);
|
vInfo("vgId:%d sync restore finished, start to launch stream task(s)", pVnode->config.vgId);
|
||||||
int32_t numOfTasks = tqStreamTasksGetTotalNum(pMeta);
|
int32_t numOfTasks = tqStreamTasksGetTotalNum(pMeta);
|
||||||
if (numOfTasks > 0) {
|
if (numOfTasks > 0) {
|
||||||
if (pMeta->startInfo.taskStarting == 1) {
|
if (pMeta->startInfo.startAllTasks == 1) {
|
||||||
pMeta->startInfo.restartCount += 1;
|
pMeta->startInfo.restartCount += 1;
|
||||||
tqDebug("vgId:%d in start tasks procedure, inc restartCounter by 1, remaining restart:%d", vgId,
|
tqDebug("vgId:%d in start tasks procedure, inc restartCounter by 1, remaining restart:%d", vgId,
|
||||||
pMeta->startInfo.restartCount);
|
pMeta->startInfo.restartCount);
|
||||||
} else {
|
} else {
|
||||||
pMeta->startInfo.taskStarting = 1;
|
pMeta->startInfo.startAllTasks = 1;
|
||||||
|
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
tqStreamTaskStartAsync(pMeta, &pVnode->msgCb, false);
|
tqStreamTaskStartAsync(pMeta, &pVnode->msgCb, false);
|
||||||
|
|
|
@ -9,6 +9,8 @@ add_subdirectory(nodes)
|
||||||
add_subdirectory(catalog)
|
add_subdirectory(catalog)
|
||||||
add_subdirectory(audit)
|
add_subdirectory(audit)
|
||||||
add_subdirectory(monitorfw)
|
add_subdirectory(monitorfw)
|
||||||
|
add_subdirectory(sm4)
|
||||||
|
add_subdirectory(crypt)
|
||||||
|
|
||||||
add_subdirectory(scalar)
|
add_subdirectory(scalar)
|
||||||
add_subdirectory(function)
|
add_subdirectory(function)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "osMemory.h"
|
#include "osMemory.h"
|
||||||
|
|
||||||
SAudit tsAudit = {0};
|
SAudit tsAudit = {0};
|
||||||
char* tsAuditUri = "/audit";
|
char* tsAuditUri = "/audit_v2";
|
||||||
char* tsAuditBatchUri = "/audit-batch";
|
char* tsAuditBatchUri = "/audit-batch";
|
||||||
|
|
||||||
int32_t auditInit(const SAuditCfg *pCfg) {
|
int32_t auditInit(const SAuditCfg *pCfg) {
|
||||||
|
|
|
@ -315,6 +315,18 @@ static const char* cacheModelStr(int8_t cacheModel) {
|
||||||
return TSDB_CACHE_MODEL_NONE_STR;
|
return TSDB_CACHE_MODEL_NONE_STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* encryptAlgorithmStr(int8_t encryptAlgorithm) {
|
||||||
|
switch (encryptAlgorithm) {
|
||||||
|
case TSDB_ENCRYPT_ALGO_NONE:
|
||||||
|
return TSDB_ENCRYPT_ALGO_NONE_STR;
|
||||||
|
case TSDB_ENCRYPT_ALGO_SM4:
|
||||||
|
return TSDB_ENCRYPT_ALGO_SM4_STR;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TSDB_CACHE_MODEL_NONE_STR;
|
||||||
|
}
|
||||||
|
|
||||||
static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, char* dbFName, SDbCfgInfo* pCfg) {
|
static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, char* dbFName, SDbCfgInfo* pCfg) {
|
||||||
blockDataEnsureCapacity(pBlock, 1);
|
blockDataEnsureCapacity(pBlock, 1);
|
||||||
pBlock->info.rows = 1;
|
pBlock->info.rows = 1;
|
||||||
|
@ -360,12 +372,12 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch
|
||||||
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm "
|
||||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
|
||||||
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
|
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
|
||||||
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 " KEEP_TIME_OFFSET %d S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d",
|
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d",
|
||||||
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
|
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile,
|
||||||
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2,
|
||||||
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
|
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
|
||||||
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize,
|
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize,
|
||||||
pCfg->keepTimeOffset, pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact);
|
pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact);
|
||||||
|
|
||||||
if (retentions) {
|
if (retentions) {
|
||||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
aux_source_directory(src CRYPT_SRC)
|
||||||
|
|
||||||
|
IF (TD_ENTERPRISE)
|
||||||
|
LIST(APPEND CRYPT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/crypt/cryptImpl.c)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
add_library(crypt STATIC ${CRYPT_SRC})
|
||||||
|
target_include_directories(
|
||||||
|
crypt
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/crypt"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(crypt common sm4)
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "crypt.h"
|
||||||
|
|
||||||
|
extern int32_t CBC_DecryptImpl(SCryptOpts *opts);
|
||||||
|
extern int32_t CBC_EncryptImpl(SCryptOpts *opts);
|
||||||
|
|
||||||
|
int32_t CBC_Encrypt(SCryptOpts *opts) {
|
||||||
|
return CBC_EncryptImpl(opts);
|
||||||
|
}
|
||||||
|
int32_t CBC_Decrypt(SCryptOpts *opts) {
|
||||||
|
return CBC_DecryptImpl(opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef TD_ENTERPRISE
|
||||||
|
int32_t CBC_EncryptImpl(SCryptOpts *opts) {
|
||||||
|
memcpy(opts->result, opts->source, opts->len);
|
||||||
|
return opts->len;
|
||||||
|
}
|
||||||
|
int32_t CBC_DecryptImpl(SCryptOpts *opts) {
|
||||||
|
memcpy(opts->result, opts->source, opts->len);
|
||||||
|
return opts->len;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -87,8 +87,11 @@ static void setColIdForCacheReadBlock(SSDataBlock* pBlock, SLastRowScanPhysiNode
|
||||||
SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle,
|
SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle,
|
||||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) {
|
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t numOfCols = 0;
|
||||||
|
SNodeList* pScanCols = pScanNode->scan.pScanCols;
|
||||||
SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo));
|
SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
tableListDestroy(pTableListInfo);
|
tableListDestroy(pTableListInfo);
|
||||||
|
@ -101,21 +104,32 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
code = extractColMatchInfo(pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
code =
|
|
||||||
extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
// todo: the pk information should comes from the physical plan
|
||||||
SColMatchItem* pItem = taosArrayGet(pInfo->matchInfo.pList, i);
|
// pk info may not in pScanCols, so extract primary key from pInfo->matchInfo may failed
|
||||||
if (pItem->isPk) {
|
SSchemaInfo* pSchemaInfo = taosArrayGet(pTaskInfo->schemaInfos, 0);
|
||||||
pInfo->numOfPks += 1;
|
if (pSchemaInfo != NULL) {
|
||||||
pInfo->pkCol.type = pItem->dataType.type; // only record one primary key
|
if (pSchemaInfo->sw->pSchema[1].flags & COL_IS_KEY) { // is primary key
|
||||||
pInfo->pkCol.bytes = pItem->dataType.bytes; // only record one primary key
|
SSchema* pColSchema = &pSchemaInfo->sw->pSchema[1];
|
||||||
|
pInfo->numOfPks = 1;
|
||||||
|
pInfo->pkCol.type = pColSchema->type;
|
||||||
|
pInfo->pkCol.bytes = pColSchema->bytes;
|
||||||
pInfo->pkCol.pk = 1;
|
pInfo->pkCol.pk = 1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
||||||
|
SColMatchItem* pItem = taosArrayGet(pInfo->matchInfo.pList, i);
|
||||||
|
if (pItem->isPk) {
|
||||||
|
pInfo->numOfPks += 1;
|
||||||
|
pInfo->pkCol.type = pItem->dataType.type; // only record one primary key
|
||||||
|
pInfo->pkCol.bytes = pItem->dataType.bytes; // only record one primary key
|
||||||
|
pInfo->pkCol.pk = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pCidList = taosArrayInit(numOfCols, sizeof(int16_t));
|
SArray* pCidList = taosArrayInit(numOfCols, sizeof(int16_t));
|
||||||
|
@ -223,8 +237,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
blockDataCleanup(pInfo->pBufferedRes);
|
blockDataCleanup(pInfo->pBufferedRes);
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
int32_t code = pInfo->readHandle.api.cacheFn.retrieveRows(pInfo->pLastrowReader, pInfo->pBufferedRes, pInfo->pSlotIds,
|
int32_t code = pInfo->readHandle.api.cacheFn.retrieveRows(pInfo->pLastrowReader, pInfo->pBufferedRes,
|
||||||
pInfo->pDstSlotIds, pInfo->pUidList);
|
pInfo->pSlotIds, pInfo->pDstSlotIds, pInfo->pUidList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -293,9 +307,11 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pInfo->pLastrowReader) {
|
if (NULL == pInfo->pLastrowReader) {
|
||||||
code = pInfo->readHandle.api.cacheFn.openReader(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
code = pInfo->readHandle.api.cacheFn.openReader(
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), pInfo->pCidList, pInfo->pSlotIds, suid, &pInfo->pLastrowReader,
|
pInfo->readHandle.vnode, pInfo->retrieveType, pList, num, taosArrayGetSize(pInfo->matchInfo.pList),
|
||||||
pTaskInfo->id.str, pInfo->pFuncTypeList, &pInfo->pkCol, pInfo->numOfPks);
|
pInfo->pCidList, pInfo->pSlotIds, suid, &pInfo->pLastrowReader, pTaskInfo->id.str, pInfo->pFuncTypeList,
|
||||||
|
&pInfo->pkCol, pInfo->numOfPks);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pInfo->currentGroupIndex += 1;
|
pInfo->currentGroupIndex += 1;
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
|
@ -1640,7 +1640,7 @@ static void getPreVersionDataBlock(uint64_t uid, TSKEY startTs, TSKEY endTs, int
|
||||||
printDataBlock(pBlock, "new delete", taskIdStr);
|
printDataBlock(pBlock, "new delete", taskIdStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType mode) {
|
||||||
if (pSrcBlock->info.rows == 0) {
|
if (pSrcBlock->info.rows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1659,7 +1659,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
|
||||||
}
|
}
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) {
|
if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) {
|
||||||
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
startData = (TSKEY*)pStartTsCol->pData;
|
startData = (TSKEY*)pStartTsCol->pData;
|
||||||
endData = (TSKEY*)pEndTsCol->pData;
|
endData = (TSKEY*)pEndTsCol->pData;
|
||||||
|
@ -1736,7 +1736,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
}
|
}
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) {
|
if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) {
|
||||||
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
startData = (TSKEY*)pStartTsCol->pData;
|
startData = (TSKEY*)pStartTsCol->pData;
|
||||||
endData = (TSKEY*)pEndTsCol->pData;
|
endData = (TSKEY*)pEndTsCol->pData;
|
||||||
|
@ -1779,7 +1779,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
|
static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType mode) {
|
||||||
blockDataCleanup(pDestBlock);
|
blockDataCleanup(pDestBlock);
|
||||||
if (pSrcBlock->info.rows == 0) {
|
if (pSrcBlock->info.rows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1800,7 +1800,7 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
int64_t ver = pSrcBlock->info.version - 1;
|
int64_t ver = pSrcBlock->info.version - 1;
|
||||||
|
|
||||||
if (pInfo->partitionSup.needCalc && (srcStartTsCol[0] != srcEndTsCol[0] || hasPrimaryKey(pInfo))) {
|
if (pInfo->partitionSup.needCalc && ( srcStartTsCol[0] != srcEndTsCol[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) {
|
||||||
getPreVersionDataBlock(srcUidData[0], srcStartTsCol[0], srcEndTsCol[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
getPreVersionDataBlock(srcUidData[0], srcStartTsCol[0], srcEndTsCol[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock);
|
||||||
srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||||
srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||||
|
@ -1959,9 +1959,9 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS
|
||||||
static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) {
|
static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (isIntervalWindow(pInfo)) {
|
if (isIntervalWindow(pInfo)) {
|
||||||
code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock);
|
code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock, type);
|
||||||
} else if (isSessionWindow(pInfo) || isStateWindow(pInfo)) {
|
} else if (isSessionWindow(pInfo) || isStateWindow(pInfo)) {
|
||||||
code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock);
|
code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock, type);
|
||||||
} else if (isCountWindow(pInfo)) {
|
} else if (isCountWindow(pInfo)) {
|
||||||
code = generateCountScanRange(pInfo, pSrcBlock, pDestBlock, type);
|
code = generateCountScanRange(pInfo, pSrcBlock, pDestBlock, type);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2660,7 +2660,7 @@ FETCH_NEXT_BLOCK:
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case STREAM_SCAN_FROM_DELETE_DATA: {
|
case STREAM_SCAN_FROM_DELETE_DATA: {
|
||||||
generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_DELETE_DATA);
|
generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_PARTITION_DELETE_DATA);
|
||||||
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
|
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
|
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
|
||||||
copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
|
copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
|
||||||
|
|
|
@ -185,7 +185,7 @@ void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, ESt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pDelRange->win = tmpKey.win;
|
pDelRange->win = tmpKey.win;
|
||||||
while (mode == STREAM_DELETE_DATA) {
|
while (mode == STREAM_DELETE_DATA || mode == STREAM_PARTITION_DELETE_DATA) {
|
||||||
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur);
|
pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur);
|
||||||
code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0);
|
code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -281,6 +281,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "ShowGrantsLogsStmt";
|
return "ShowGrantsLogsStmt";
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return "ShowClusterMachinesStmt";
|
return "ShowClusterMachinesStmt";
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
|
return "ShowEncryptionsStmt";
|
||||||
case QUERY_NODE_DELETE_STMT:
|
case QUERY_NODE_DELETE_STMT:
|
||||||
return "DeleteStmt";
|
return "DeleteStmt";
|
||||||
case QUERY_NODE_INSERT_STMT:
|
case QUERY_NODE_INSERT_STMT:
|
||||||
|
@ -7047,10 +7049,14 @@ static int32_t showGrantsLogsStmtToJson(const void* pObj, SJson* pJson) { return
|
||||||
|
|
||||||
static int32_t showClusterMachinesStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
static int32_t showClusterMachinesStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
|
||||||
|
static int32_t showEncryptionsStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||||
|
|
||||||
static int32_t jsonToShowGrantsLogsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
static int32_t jsonToShowGrantsLogsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
static int32_t jsonToShowClusterMachinesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
static int32_t jsonToShowClusterMachinesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
|
static int32_t jsonToShowEncryptionsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||||
|
|
||||||
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
|
||||||
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
|
||||||
|
|
||||||
|
@ -7651,6 +7657,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return showGrantsLogsStmtToJson(pObj, pJson);
|
return showGrantsLogsStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return showClusterMachinesStmtToJson(pObj, pJson);
|
return showClusterMachinesStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
|
return showEncryptionsStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return showDnodeVariablesStmtToJson(pObj, pJson);
|
return showDnodeVariablesStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
@ -7996,6 +8004,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToShowGrantsLogsStmt(pJson, pObj);
|
return jsonToShowGrantsLogsStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return jsonToShowClusterMachinesStmt(pJson, pObj);
|
return jsonToShowClusterMachinesStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
|
return jsonToShowEncryptionsStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||||
return jsonToShowDnodeVariablesStmt(pJson, pObj);
|
return jsonToShowDnodeVariablesStmt(pJson, pObj);
|
||||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||||
|
|
|
@ -521,6 +521,7 @@ SNode* nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT:
|
case QUERY_NODE_SHOW_TSMAS_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||||
|
@ -1210,6 +1211,7 @@ void nodesDestroyNode(SNode* pNode) {
|
||||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||||
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_TSMAS_STMT: {
|
case QUERY_NODE_SHOW_TSMAS_STMT: {
|
||||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||||
nodesDestroyNode(pStmt->pDbName);
|
nodesDestroyNode(pStmt->pDbName);
|
||||||
|
|
|
@ -67,7 +67,8 @@ typedef enum EDatabaseOptionType {
|
||||||
DB_OPTION_S3_CHUNKSIZE,
|
DB_OPTION_S3_CHUNKSIZE,
|
||||||
DB_OPTION_S3_KEEPLOCAL,
|
DB_OPTION_S3_KEEPLOCAL,
|
||||||
DB_OPTION_S3_COMPACT,
|
DB_OPTION_S3_COMPACT,
|
||||||
DB_OPTION_KEEP_TIME_OFFSET
|
DB_OPTION_KEEP_TIME_OFFSET,
|
||||||
|
DB_OPTION_ENCRYPT_ALGORITHM,
|
||||||
} EDatabaseOptionType;
|
} EDatabaseOptionType;
|
||||||
|
|
||||||
typedef enum ETableOptionType {
|
typedef enum ETableOptionType {
|
||||||
|
@ -232,6 +233,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force, bool unsafe);
|
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force, bool unsafe);
|
||||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||||
|
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue);
|
||||||
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName);
|
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName);
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
||||||
SNode* pRealTable, SNodeList* pCols, SNode* pOptions);
|
SNode* pRealTable, SNodeList* pCols, SNode* pOptions);
|
||||||
|
|
|
@ -144,6 +144,9 @@ priv_level(A) ::= topic_name(B).
|
||||||
with_opt(A) ::= . { A = NULL; }
|
with_opt(A) ::= . { A = NULL; }
|
||||||
with_opt(A) ::= WITH search_condition(B). { A = B; }
|
with_opt(A) ::= WITH search_condition(B). { A = B; }
|
||||||
|
|
||||||
|
/************************************************ create encrypt_key *********************************************/
|
||||||
|
cmd ::= CREATE ENCRYPT_KEY NK_STRING(A). { pCxt->pRootNode = createEncryptKeyStmt(pCxt, &A); }
|
||||||
|
|
||||||
/************************************************ create/drop/alter/restore dnode *********************************************/
|
/************************************************ create/drop/alter/restore dnode *********************************************/
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||||
|
@ -266,6 +269,7 @@ db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_INTEGER(C).
|
||||||
db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_KEEPLOCAL, &C); }
|
db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_KEEPLOCAL, &C); }
|
||||||
db_options(A) ::= db_options(B) S3_COMPACT NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_COMPACT, &C); }
|
db_options(A) ::= db_options(B) S3_COMPACT NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_COMPACT, &C); }
|
||||||
db_options(A) ::= db_options(B) KEEP_TIME_OFFSET NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP_TIME_OFFSET, &C); }
|
db_options(A) ::= db_options(B) KEEP_TIME_OFFSET NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP_TIME_OFFSET, &C); }
|
||||||
|
db_options(A) ::= db_options(B) ENCRYPT_ALGORITHM NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_ENCRYPT_ALGORITHM, &C); }
|
||||||
|
|
||||||
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
|
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
|
||||||
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
|
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
|
||||||
|
@ -300,6 +304,7 @@ alter_db_option(A) ::= S3_KEEPLOCAL NK_INTEGER(B).
|
||||||
alter_db_option(A) ::= S3_KEEPLOCAL NK_VARIABLE(B). { A.type = DB_OPTION_S3_KEEPLOCAL; A.val = B; }
|
alter_db_option(A) ::= S3_KEEPLOCAL NK_VARIABLE(B). { A.type = DB_OPTION_S3_KEEPLOCAL; A.val = B; }
|
||||||
alter_db_option(A) ::= S3_COMPACT NK_INTEGER(B). { A.type = DB_OPTION_S3_COMPACT, A.val = B; }
|
alter_db_option(A) ::= S3_COMPACT NK_INTEGER(B). { A.type = DB_OPTION_S3_COMPACT, A.val = B; }
|
||||||
alter_db_option(A) ::= KEEP_TIME_OFFSET NK_INTEGER(B). { A.type = DB_OPTION_KEEP_TIME_OFFSET; A.val = B; }
|
alter_db_option(A) ::= KEEP_TIME_OFFSET NK_INTEGER(B). { A.type = DB_OPTION_KEEP_TIME_OFFSET; A.val = B; }
|
||||||
|
alter_db_option(A) ::= ENCRYPT_ALGORITHM NK_STRING(B). { A.type = DB_OPTION_ENCRYPT_ALGORITHM; A.val = B; }
|
||||||
|
|
||||||
%type integer_list { SNodeList* }
|
%type integer_list { SNodeList* }
|
||||||
%destructor integer_list { nodesDestroyList($$); }
|
%destructor integer_list { nodesDestroyList($$); }
|
||||||
|
@ -516,7 +521,9 @@ cmd ::= SHOW GRANTS LOGS.
|
||||||
cmd ::= SHOW CLUSTER MACHINES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); }
|
cmd ::= SHOW CLUSTER MACHINES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); }
|
||||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||||
|
A); }
|
||||||
|
cmd ::= SHOW ENCRYPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ENCRYPTIONS_STMT); }
|
||||||
cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
|
cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
|
||||||
cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
|
cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
|
||||||
cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
|
cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
|
||||||
|
|
|
@ -1375,6 +1375,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||||
pOptions->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
pOptions->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
pOptions->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
pOptions->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||||
|
pOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1414,6 +1415,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
||||||
pOptions->s3KeepLocal = -1;
|
pOptions->s3KeepLocal = -1;
|
||||||
pOptions->s3Compact = -1;
|
pOptions->s3Compact = -1;
|
||||||
pOptions->withArbitrator = -1;
|
pOptions->withArbitrator = -1;
|
||||||
|
pOptions->encryptAlgorithm = -1;
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1547,6 +1549,10 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
|
||||||
case DB_OPTION_KEEP_TIME_OFFSET: {
|
case DB_OPTION_KEEP_TIME_OFFSET: {
|
||||||
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
|
||||||
break;
|
break;
|
||||||
|
case DB_OPTION_ENCRYPT_ALGORITHM:
|
||||||
|
COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal);
|
||||||
|
pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2334,6 +2340,14 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue) {
|
||||||
|
SToken config;
|
||||||
|
config.type = TK_NK_STRING;
|
||||||
|
config.z = "\"encrypt_key\"";
|
||||||
|
config.n = strlen(config.z);
|
||||||
|
return createAlterDnodeStmt(pCxt, NULL, &config, pValue);
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName) {
|
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName) {
|
||||||
if (!checkIndexName(pCxt, pIndexName)) {
|
if (!checkIndexName(pCxt, pIndexName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -644,6 +644,11 @@ static int32_t collectMetaKeyFromShowClusterMachines(SCollectMetaKeyCxt* pCxt, S
|
||||||
pCxt->pMetaCache);
|
pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectMetaKeyFromShowEncryptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||||
|
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ENCRYPTIONS,
|
||||||
|
pCxt->pMetaCache);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
@ -916,6 +921,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
||||||
return collectMetaKeyFromShowGrantsLogs(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowGrantsLogs(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
return collectMetaKeyFromShowClusterMachines(pCxt, (SShowStmt*)pStmt);
|
return collectMetaKeyFromShowClusterMachines(pCxt, (SShowStmt*)pStmt);
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
|
return collectMetaKeyFromShowEncryptions(pCxt, (SShowStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
||||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
|
|
@ -356,6 +356,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
||||||
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
|
||||||
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
|
||||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
|
||||||
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
||||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||||
|
|
|
@ -670,11 +670,13 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema,
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
int32_t output = 0;
|
int32_t output = 0;
|
||||||
void* p = taosMemoryCalloc(1, pSchema->bytes - VARSTR_HEADER_SIZE);
|
int64_t realLen = pToken->n << 2;
|
||||||
|
if (realLen > pSchema->bytes - VARSTR_HEADER_SIZE) realLen = pSchema->bytes - VARSTR_HEADER_SIZE;
|
||||||
|
void* p = taosMemoryMalloc(realLen);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)(p), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) {
|
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)(p), realLen, &output)) {
|
||||||
if (errno == E2BIG) {
|
if (errno == E2BIG) {
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||||
|
|
|
@ -641,7 +641,7 @@ static bool findFileds(SSchema* pSchema, TAOS_FIELD* fields, int numFields) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD* tFields,
|
int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD* tFields,
|
||||||
int numFields, bool needChangeLength) {
|
int numFields, bool needChangeLength, char* errstr, int32_t errstrLen) {
|
||||||
void* tmp =
|
void* tmp =
|
||||||
taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid));
|
taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid));
|
||||||
STableDataCxt* pTableCxt = NULL;
|
STableDataCxt* pTableCxt = NULL;
|
||||||
|
@ -662,8 +662,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
}
|
}
|
||||||
|
|
||||||
char* p = (char*)data;
|
char* p = (char*)data;
|
||||||
// | version | total length | total rows | blankFill | total columns | flag seg| block group id | column schema | each
|
// | version | total length | total rows | blankFill | total columns | flag seg| block group id | column schema | each column length |
|
||||||
// column length |
|
|
||||||
int32_t version = *(int32_t*)data;
|
int32_t version = *(int32_t*)data;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
@ -689,12 +688,12 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
SBoundColInfo* boundInfo = &pTableCxt->boundColsInfo;
|
SBoundColInfo* boundInfo = &pTableCxt->boundColsInfo;
|
||||||
|
|
||||||
if (tFields != NULL && numFields != numOfCols) {
|
if (tFields != NULL && numFields != numOfCols) {
|
||||||
uError("numFields:%d != numOfCols:%d", numFields, numOfCols);
|
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d != raw numOfCols:%d", numFields, numOfCols);
|
||||||
ret = TSDB_CODE_INVALID_PARA;
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (tFields != NULL && numFields > boundInfo->numOfBound) {
|
if (tFields != NULL && numFields > boundInfo->numOfBound) {
|
||||||
uError("numFields:%d > boundInfo->numOfBound:%d", numFields, boundInfo->numOfBound);
|
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d > boundInfo->numOfBound:%d", numFields, boundInfo->numOfBound);
|
||||||
ret = TSDB_CODE_INVALID_PARA;
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -703,7 +702,8 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
SSchema* pColSchema = &pSchema[j];
|
SSchema* pColSchema = &pSchema[j];
|
||||||
SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j);
|
SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j);
|
||||||
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
|
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
|
||||||
uError("type or bytes not equal");
|
if (errstr != NULL) snprintf(errstr, errstrLen, "type or bytes not equal, id:%d, type:%d, raw type:%d. bytes:%d, raw bytes:%d",
|
||||||
|
pColSchema->colId, pColSchema->type, *fields, pColSchema->bytes, *(int32_t*)(fields + sizeof(int8_t)));
|
||||||
ret = TSDB_CODE_INVALID_PARA;
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -732,7 +732,8 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
SSchema* pColSchema = &pSchema[j];
|
SSchema* pColSchema = &pSchema[j];
|
||||||
if (strcmp(pColSchema->name, tFields[i].name) == 0) {
|
if (strcmp(pColSchema->name, tFields[i].name) == 0) {
|
||||||
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
|
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
|
||||||
uError("type or bytes not equal");
|
if (errstr != NULL) snprintf(errstr, errstrLen, "type or bytes not equal, id:%d, type:%d, raw type:%d. bytes:%d, raw bytes:%d",
|
||||||
|
pColSchema->colId, pColSchema->type, *fields, pColSchema->bytes, *(int32_t*)(fields + sizeof(int8_t)));
|
||||||
ret = TSDB_CODE_INVALID_PARA;
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,9 @@ static SKeyword keywordTable[] = {
|
||||||
{"DURATION", TK_DURATION},
|
{"DURATION", TK_DURATION},
|
||||||
{"ELSE", TK_ELSE},
|
{"ELSE", TK_ELSE},
|
||||||
{"ENABLE", TK_ENABLE},
|
{"ENABLE", TK_ENABLE},
|
||||||
|
{"ENCRYPTIONS", TK_ENCRYPTIONS},
|
||||||
|
{"ENCRYPT_ALGORITHM", TK_ENCRYPT_ALGORITHM},
|
||||||
|
{"ENCRYPT_KEY", TK_ENCRYPT_KEY},
|
||||||
{"END", TK_END},
|
{"END", TK_END},
|
||||||
{"EXISTS", TK_EXISTS},
|
{"EXISTS", TK_EXISTS},
|
||||||
{"EXPIRED", TK_EXPIRED},
|
{"EXPIRED", TK_EXPIRED},
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue