Merge branch '3.0' into merge/mainto3.0
This commit is contained in:
commit
1a6becbd2b
|
@ -9,7 +9,7 @@ option(
|
|||
)
|
||||
|
||||
IF(${TD_WINDOWS})
|
||||
|
||||
IF(NOT TD_ASTRA)
|
||||
MESSAGE("build pthread Win32")
|
||||
option(
|
||||
BUILD_PTHREAD
|
||||
|
@ -63,7 +63,7 @@ IF(${TD_WINDOWS})
|
|||
"If build crashdump on Windows"
|
||||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
ELSEIF (TD_DARWIN_64)
|
||||
IF(${BUILD_TEST})
|
||||
add_definitions(-DCOMPILER_SUPPORTS_CXX13)
|
||||
|
@ -71,58 +71,102 @@ ELSEIF (TD_DARWIN_64)
|
|||
ENDIF ()
|
||||
|
||||
option(
|
||||
BUILD_WITH_LEMON
|
||||
"If build with lemon"
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
BUILD_WITH_UDF
|
||||
"If build with UDF"
|
||||
ON
|
||||
)
|
||||
|
||||
IF(NOT TD_ASTRA)
|
||||
option(
|
||||
BUILD_GEOS
|
||||
"If build with geos"
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_SHARED_LIBS
|
||||
""
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
RUST_BINDINGS
|
||||
"If build with rust-bindings"
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_PCRE2
|
||||
"If build with pcre2"
|
||||
ON
|
||||
)
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
JEMALLOC_ENABLED
|
||||
"If build with jemalloc"
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_SANITIZER
|
||||
"If build sanitizer"
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_ADDR2LINE
|
||||
"If build addr2line"
|
||||
OFF
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_WITH_LEVELDB
|
||||
"If build with leveldb"
|
||||
OFF
|
||||
)
|
||||
)
|
||||
|
||||
option(
|
||||
option(
|
||||
BUILD_WITH_ROCKSDB
|
||||
"If build with rocksdb"
|
||||
ON
|
||||
)
|
||||
)
|
||||
|
||||
option(
|
||||
BUILD_WITH_LZ4
|
||||
"If build with lz4"
|
||||
ON
|
||||
)
|
||||
ELSE ()
|
||||
|
||||
option(
|
||||
BUILD_WITH_LZMA2
|
||||
"If build with lzma2"
|
||||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
|
||||
ADD_DEFINITIONS(-DUSE_AUDIT)
|
||||
ADD_DEFINITIONS(-DUSE_GEOS)
|
||||
ADD_DEFINITIONS(-DUSE_UDF)
|
||||
ADD_DEFINITIONS(-DUSE_STREAM)
|
||||
ADD_DEFINITIONS(-DUSE_PRCE2)
|
||||
ADD_DEFINITIONS(-DUSE_RSMA)
|
||||
ADD_DEFINITIONS(-DUSE_TSMA)
|
||||
ADD_DEFINITIONS(-DUSE_TQ)
|
||||
ADD_DEFINITIONS(-DUSE_TOPIC)
|
||||
ADD_DEFINITIONS(-DUSE_MONITOR)
|
||||
ADD_DEFINITIONS(-DUSE_REPORT)
|
||||
|
||||
IF(${TD_ASTRA_RPC})
|
||||
ADD_DEFINITIONS(-DTD_ASTRA_RPC)
|
||||
ENDIF()
|
||||
|
||||
IF(${TD_LINUX})
|
||||
|
||||
|
@ -150,6 +194,12 @@ option(
|
|||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
BUILD_WITH_LZMA2
|
||||
"If build with lzma2"
|
||||
ON
|
||||
)
|
||||
|
||||
ENDIF ()
|
||||
|
||||
IF(NOT TD_ENTERPRISE)
|
||||
|
@ -191,6 +241,14 @@ option(BUILD_WITH_COS "If build with cos" OFF)
|
|||
|
||||
ENDIF ()
|
||||
|
||||
IF(${TAOSD_INTEGRATED})
|
||||
add_definitions(-DTAOSD_INTEGRATED)
|
||||
ENDIF()
|
||||
|
||||
IF(${TD_AS_LIB})
|
||||
add_definitions(-DTD_AS_LIB)
|
||||
ENDIF()
|
||||
|
||||
option(
|
||||
BUILD_WITH_SQLITE
|
||||
"If build with sqlite"
|
||||
|
@ -209,6 +267,14 @@ option(
|
|||
off
|
||||
)
|
||||
|
||||
option(
|
||||
BUILD_WITH_NURAFT
|
||||
"If build with NuRaft"
|
||||
OFF
|
||||
)
|
||||
|
||||
IF(NOT TD_ASTRA)
|
||||
|
||||
option(
|
||||
BUILD_WITH_UV
|
||||
"If build with libuv"
|
||||
|
@ -242,6 +308,7 @@ option(
|
|||
"If use invertedIndex"
|
||||
ON
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
option(
|
||||
BUILD_RELEASE
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
# xz
|
||||
|
||||
if (${TD_LINUX})
|
||||
if (${BUILD_WITH_LZMA2})
|
||||
ExternalProject_Add(lzma2
|
||||
GIT_REPOSITORY https://github.com/conor42/fast-lzma2.git
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/lzma2"
|
||||
|
|
|
@ -92,7 +92,9 @@ if(${BUILD_TEST})
|
|||
endif(${BUILD_TEST})
|
||||
|
||||
# lz4
|
||||
cat("${TD_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
if(${BUILD_WITH_LZ4})
|
||||
cat("${TD_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif(${BUILD_WITH_LZ4})
|
||||
|
||||
# zlib
|
||||
cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
|
@ -186,16 +188,22 @@ if(${BUILD_PCRE2})
|
|||
cat("${TD_SUPPORT_DIR}/pcre2_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
find_program(C_COMPILER_LEMON NAMES gcc)
|
||||
if(C_COMPILER_LEMON)
|
||||
# lemon
|
||||
if(${BUILD_WITH_LEMON})
|
||||
if(${TD_ACORE})
|
||||
set(C_COMPILER_LEMON ${CMAKE_C_COMPILER})
|
||||
else()
|
||||
find_program(C_COMPILER_LEMON NAMES gcc)
|
||||
endif()
|
||||
if(C_COMPILER_LEMON)
|
||||
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
|
||||
else()
|
||||
else()
|
||||
set(C_COMPILER_LEMON ${CMAKE_C_COMPILER})
|
||||
message(STATUS "LEMON C compiler: ${C_COMPILER_LEMON}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# lemon
|
||||
cat("${TD_SUPPORT_DIR}/lemon_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
cat("${TD_SUPPORT_DIR}/lemon_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||
endif()
|
||||
|
||||
# Force specify CC=cc on MacOS. Because the default CC setting in the generated Makefile has issues finding standard library headers
|
||||
IF(${TD_DARWIN})
|
||||
|
@ -273,11 +281,13 @@ unset(CMAKE_PROJECT_INCLUDE_BEFORE)
|
|||
# endif()
|
||||
|
||||
# lz4
|
||||
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
|
||||
target_include_directories(
|
||||
if(${BUILD_WITH_LZ4})
|
||||
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
|
||||
target_include_directories(
|
||||
lz4_static
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lz4/lib
|
||||
)
|
||||
)
|
||||
endif(${BUILD_WITH_LZ4})
|
||||
|
||||
# zlib
|
||||
set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in")
|
||||
|
|
|
@ -108,6 +108,13 @@ Under normal circumstances, stream computation tasks will not process data that
|
|||
|
||||
By enabling the fill_history option, the created stream computation task will be capable of processing data written before, during, and after the creation of the stream. This means that data written either before or after the creation of the stream will be included in the scope of stream computation, thus ensuring data integrity and consistency. This setting provides users with greater flexibility, allowing them to flexibly handle historical and new data according to actual needs.
|
||||
|
||||
Tips:
|
||||
- When enabling fill_ristory, creating a stream requires finding the boundary point of historical data. If there is a lot of historical data, it may cause the task of creating a stream to take a long time. In this case, the parameter streamRunHistorySync (supported since version 3.3.6.0) can be configured to 1 (default is 0), and the task of creating a stream can be processed in the background. The statement of creating a stream can be returned immediately without blocking subsequent operations.
|
||||
|
||||
- Show streams can be used to view the progress of background stream creation (ready status indicates success, init status indicates stream creation in progress, failed status indicates that the stream creation has failed, and the message column can be used to view the reason for the failure. In the case of failed stream creation, the stream can be deleted and rebuilt).
|
||||
|
||||
- Besides, do not create multiple streams asynchronously at the same time, as transaction conflicts may cause subsequent streams to fail.
|
||||
|
||||
For example, create a stream to count the number of data entries generated by all smart meters every 10s, and also calculate historical data. SQL as follows:
|
||||
|
||||
```sql
|
||||
|
|
|
@ -72,6 +72,12 @@ The TDengine client driver provides all the APIs needed for application programm
|
|||
| tempDir | |Supported, effective immediately | Specifies the directory for generating temporary files during operation, default on Linux platform is /tmp |
|
||||
| minimalTmpDirGB | |Supported, effective immediately | Minimum space required to be reserved in the directory specified by tempDir, in GB, default value: 1 |
|
||||
|
||||
### Stream Related
|
||||
|
||||
| Parameter Name |Supported Version|Dynamic Modification| Description |
|
||||
|-----------------------|----------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| streamRunHistoryAsync | 3.3.6.0 |Supported, effective immediately | When creating a stream with the fill_history parameter, should the stream statement be executed asynchronously. Boolean value, async if true, sync if false. default is false |
|
||||
|
||||
### Log Related
|
||||
|
||||
|Parameter Name|Supported Version|Dynamic Modification|Description|
|
||||
|
|
|
@ -101,6 +101,13 @@ PARTITION 子句中,为 tbname 定义了一个别名 tname, 在 PARTITION
|
|||
|
||||
通过启用 fill_history 选项,创建的流计算任务将具备处理创建前、创建过程中以及创建后写入的数据的能力。这意味着,无论数据是在流创建之前还是之后写入的,都将纳入流计算的范围,从而确保数据的完整性和一致性。这一设置为用户提供了更大的灵活性,使其能够根据实际需求灵活处理历史数据和新数据。
|
||||
|
||||
注意:
|
||||
- 开启 fill_history 时,创建流需要找到历史数据的分界点,如果历史数据很多,可能会导致创建流任务耗时较长,此时可以配置参数 streamRunHistoryAsync(3.3.6.0版本开始支持) 为 1 (默认为0),将创建流的任务放在后台处理,创建流的语句可立即返回,不阻塞后面的操作。
|
||||
|
||||
- 通过 show streams 可查看后台建流的进度(ready 状态表示成功,init 状态表示正在建流,failed 状态表示建流失败,失败时 message 列可以查看原因。对于建流失败的情况可以删除流重新建立)。
|
||||
|
||||
- 另外,不要同时异步创建多个流,可能由于事务冲突导致后面创建的流失败。
|
||||
|
||||
比如,创建一个流,统计所有智能电表每 10s 产生的数据条数,并且计算历史数据。SQL 如下:
|
||||
```sql
|
||||
create stream if not exists count_history_s fill_history 1 into count_history as select count(*) from power.meters interval(10s)
|
||||
|
|
|
@ -37,6 +37,14 @@ TDengine 可以通过 MQTT 连接器从 MQTT 代理订阅数据并将其写入 T
|
|||
|
||||
在 **MQTT 端口** 中填写 MQTT 代理的端口,例如:`1883`
|
||||
|
||||
在 **TLS 校验** 中选择 TLS 证书的校验方式
|
||||
|
||||
1. 不开启:表示不进行 TLS 证书认证。在连接 MQTT 时,会先进行 TCP 连接,如果连接失败,会进行无证书认证模式的 TLS 连接。
|
||||
|
||||
2. 单向认证:开启 TLS 连接,并验证服务端证书,此时需要上传 CA 证书。
|
||||
|
||||
3. 双向认证:开启 TLS 连接,并与服务端进行双向认证,此时需要上传 CA 证书,客户端证书以及客户端密钥。
|
||||
|
||||
在 **用户** 中填写 MQTT 代理的用户名。
|
||||
|
||||
在 **密码** 中填写 MQTT 代理的密码。
|
||||
|
@ -44,13 +52,7 @@ TDengine 可以通过 MQTT 连接器从 MQTT 代理订阅数据并将其写入 T
|
|||
|
||||

|
||||
|
||||
### 4. 配置 SSL 证书
|
||||
|
||||
如果 MQTT 代理使用了 SSL 证书,需要在 **SSL证书** 中上传证书文件。
|
||||
|
||||

|
||||
|
||||
### 5. 配置采集信息
|
||||
### 4. 配置采集信息
|
||||
|
||||
在 **采集配置** 区域填写采集任务相关的配置参数。
|
||||
|
||||
|
@ -75,13 +77,13 @@ TDengine 可以通过 MQTT 连接器从 MQTT 代理订阅数据并将其写入 T
|
|||
|
||||

|
||||
|
||||
### 6. 配置 MQTT Payload 解析
|
||||
### 5. 配置 MQTT Payload 解析
|
||||
|
||||
在 **MQTT Payload 解析** 区域填写 Payload 解析相关的配置参数。
|
||||
|
||||
taosX 可以使用 JSON 提取器解析数据,并允许用户在数据库中指定数据模型,包括,指定表名称和超级表名,设置普通列和标签列等。
|
||||
|
||||
#### 6.1 解析
|
||||
#### 5.1 解析
|
||||
|
||||
有三种获取示例数据的方法:
|
||||
|
||||
|
@ -112,7 +114,7 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
#### 6.2 字段拆分
|
||||
#### 5.2 字段拆分
|
||||
|
||||
在 **从列中提取或拆分** 中填写从消息体中提取或拆分的字段,例如:将 message 字段拆分成 `message_0` 和 `message_1` 这2 个字段,选择 split 提取器,seperator 填写 -, number 填写 2。
|
||||
|
||||
|
@ -126,7 +128,7 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
#### 6.3 数据过滤
|
||||
#### 5.3 数据过滤
|
||||
|
||||
在 **过滤** 中,填写过滤条件,例如:填写`id != 1`,则只有 id 不为 1 的数据才会被写入 TDengine。
|
||||
|
||||
|
@ -138,7 +140,7 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
#### 6.4 表映射
|
||||
#### 5.4 表映射
|
||||
|
||||
在 **目标超级表** 的下拉列表中选择一个目标超级表,也可以先点击右侧的 **创建超级表** 按钮创建新的超级表。
|
||||
|
||||
|
@ -164,7 +166,7 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
### 7. 高级选项
|
||||
### 6. 高级选项
|
||||
|
||||
在 **消息等待队列大小** 中填写接收 MQTT 消息的缓存队列大小,当队列满时,新到达的数据会直接丢弃。可设置为 0,即不缓存。
|
||||
|
||||
|
@ -182,12 +184,12 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
### 8. 异常处理策略
|
||||
### 7. 异常处理策略
|
||||
|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
<Contributing />
|
||||
|
||||
### 9. 创建完成
|
||||
### 8. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 MQTT 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 37 KiB |
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
|
@ -305,6 +305,15 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在
|
|||
- 动态修改:不支持
|
||||
- 支持版本:从 v3.1.0.0 版本开始引入
|
||||
|
||||
### 流相关
|
||||
|
||||
#### streamRunHistoryAsync
|
||||
- 说明:创建流有 fill_history 参数时,是否异步执行建流语句
|
||||
- 类型:布尔;false:同步;true:异步
|
||||
- 默认值:false
|
||||
- 动态修改:支持通过 SQL 修改,立即生效
|
||||
- 支持版本:从 v3.3.6.0 版本开始引入
|
||||
|
||||
### 日志相关
|
||||
|
||||
#### logDir
|
||||
|
|
|
@ -204,8 +204,8 @@ typedef struct SPkInfo {
|
|||
typedef struct SDataBlockInfo {
|
||||
STimeWindow window;
|
||||
int32_t rowSize;
|
||||
int64_t rows; // todo hide this attribute
|
||||
uint32_t capacity;
|
||||
int64_t rows; // todo hide this attribute
|
||||
SBlockID id;
|
||||
int16_t hasVarCol;
|
||||
int16_t dataLoad; // denote if the data is loaded or not
|
||||
|
|
|
@ -174,17 +174,17 @@ static FORCE_INLINE void colDataSetInt32(SColumnInfoData* pColumnInfoData, uint3
|
|||
static FORCE_INLINE void colDataSetInt64(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, int64_t* v) {
|
||||
int32_t type = pColumnInfoData->info.type;
|
||||
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
|
||||
*(int64_t*)p = *(int64_t*)v;
|
||||
taosSetPInt64Aligned((int64_t*)p, v);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void colDataSetFloat(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, float* v) {
|
||||
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
|
||||
*(float*)p = *(float*)v;
|
||||
taosSetPFloatAligned((float*)p, v);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void colDataSetDouble(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, double* v) {
|
||||
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * rowIndex;
|
||||
*(double*)p = *(double*)v;
|
||||
taosSetPDoubleAligned((double*)p, v);
|
||||
}
|
||||
|
||||
int32_t getJsonValueLen(const char* data);
|
||||
|
|
|
@ -97,7 +97,7 @@ const static uint8_t BIT2_MAP[4] = {0b11111100, 0b11110011, 0b11001111, 0b001111
|
|||
|
||||
#define tRowGetKey(_pRow, _pKey) \
|
||||
do { \
|
||||
(_pKey)->ts = (_pRow)->ts; \
|
||||
(_pKey)->ts = taosGetInt64Aligned(&((_pRow)->ts)); \
|
||||
(_pKey)->numOfPKs = 0; \
|
||||
if ((_pRow)->numOfPKs > 0) { \
|
||||
tRowGetPrimaryKey((_pRow), (_pKey)); \
|
||||
|
|
|
@ -291,11 +291,13 @@ extern int32_t tsUptimeInterval;
|
|||
extern bool tsUpdateCacheBatch;
|
||||
extern bool tsDisableStream;
|
||||
extern int64_t tsStreamBufferSize;
|
||||
extern int64_t tsStreamFailedTimeout;
|
||||
extern int tsStreamAggCnt;
|
||||
extern bool tsFilterScalarMode;
|
||||
extern int32_t tsMaxStreamBackendCache;
|
||||
extern int32_t tsPQSortMemThreshold;
|
||||
extern bool tsStreamCoverage;
|
||||
extern bool tsStreamRunHistoryAsync;
|
||||
extern int8_t tsS3EpNum;
|
||||
extern int32_t tsStreamNotifyMessageSize;
|
||||
extern int32_t tsStreamNotifyFrameSize;
|
||||
|
|
|
@ -527,7 +527,6 @@ typedef struct SRetention {
|
|||
#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0))
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
|
||||
typedef struct SEp {
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
|
|
|
@ -130,6 +130,8 @@
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_UPDATE_ANODE, "update-anode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_ANODE, "drop-anode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_ANAL_ALGO, "retrieve-anal-algo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_FAILED_STREAM, "create-stream-failed", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CHECK_STREAM_TIMER, "check-stream-status", NULL, NULL)
|
||||
TD_CLOSE_MSG_SEG(TDMT_DND_MSG)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8
|
||||
|
|
|
@ -119,8 +119,8 @@ typedef struct SInputColumnInfoData {
|
|||
int32_t startRowIndex; // handle started row index
|
||||
int64_t numOfRows; // the number of rows needs to be handled
|
||||
bool blankFill; // fill blank data to block for empty table
|
||||
int32_t numOfInputCols; // PTS is not included
|
||||
bool colDataSMAIsSet; // if agg is set or not
|
||||
int32_t numOfInputCols; // PTS is not included
|
||||
SColumnInfoData *pPTS; // primary timestamp column
|
||||
SColumnInfoData *pPrimaryKey; // primary key column
|
||||
SColumnInfoData **pData;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef USE_GEOS
|
||||
#include "function.h"
|
||||
|
||||
int32_t makePointFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
@ -33,6 +34,7 @@ int32_t touchesFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO
|
|||
int32_t coversFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t containsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t containsProperlyFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include <stdint.h>
|
||||
#include "os.h"
|
||||
|
||||
#ifdef USE_GEOS
|
||||
#include "tgeosctx.h"
|
||||
|
||||
void geosFreeBuffer(void *buffer);
|
||||
|
@ -55,6 +56,13 @@ int32_t readGeometry(const unsigned char *input, GEOSGeometry **outputGeom,
|
|||
const GEOSPreparedGeometry **outputPreparedGeom);
|
||||
void destroyGeometry(GEOSGeometry **geom, const GEOSPreparedGeometry **preparedGeom);
|
||||
|
||||
#else
|
||||
int32_t initCtxAsText();
|
||||
int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT);
|
||||
int32_t checkWKB(const unsigned char *wkb, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -440,6 +440,7 @@ typedef struct SRangeAroundNode {
|
|||
typedef struct SSelectStmt {
|
||||
ENodeType type; // QUERY_NODE_SELECT_STMT
|
||||
bool isDistinct;
|
||||
STimeWindow timeRange;
|
||||
SNodeList* pProjectionList;
|
||||
SNodeList* pProjectionBindList;
|
||||
SNode* pFromTable;
|
||||
|
@ -457,7 +458,6 @@ typedef struct SSelectStmt {
|
|||
SNodeList* pOrderByList; // SOrderByExprNode
|
||||
SLimitNode* pLimit;
|
||||
SLimitNode* pSlimit;
|
||||
STimeWindow timeRange;
|
||||
SNodeList* pHint;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
uint8_t precision;
|
||||
|
@ -638,23 +638,23 @@ typedef struct SQuery {
|
|||
ENodeType type;
|
||||
EQueryExecStage execStage;
|
||||
EQueryExecMode execMode;
|
||||
int32_t msgType;
|
||||
int32_t numOfResCols;
|
||||
int32_t placeholderNum;
|
||||
int8_t precision;
|
||||
bool haveResultSet;
|
||||
bool showRewrite;
|
||||
bool stableQuery;
|
||||
SNode* pPrevRoot;
|
||||
SNode* pRoot;
|
||||
SNode* pPostRoot;
|
||||
int32_t numOfResCols;
|
||||
SSchema* pResSchema;
|
||||
int8_t precision;
|
||||
SCmdMsgInfo* pCmdMsg;
|
||||
int32_t msgType;
|
||||
SArray* pTargetTableList;
|
||||
SArray* pTableList;
|
||||
SArray* pDbList;
|
||||
bool showRewrite;
|
||||
int32_t placeholderNum;
|
||||
SArray* pPlaceholderValues;
|
||||
SNode* pPrepareRoot;
|
||||
bool stableQuery;
|
||||
} SQuery;
|
||||
|
||||
void nodesWalkSelectStmtImpl(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
||||
|
|
|
@ -103,6 +103,7 @@ typedef struct SParseContext {
|
|||
setQueryFn setQueryFp;
|
||||
timezone_t timezone;
|
||||
void *charsetCxt;
|
||||
bool streamRunHistory;
|
||||
} SParseContext;
|
||||
|
||||
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
|
||||
|
@ -127,7 +128,7 @@ int32_t qInitKeywordsTable();
|
|||
void qCleanupKeywordsTable();
|
||||
|
||||
int32_t qAppendStmtTableOutput(SQuery* pQuery, SHashObj* pAllVgHash, STableColsData* pTbData, STableDataCxt* pTbCtx,
|
||||
SStbInterlaceInfo* pBuildInfo);
|
||||
SStbInterlaceInfo* pBuildInfo, SVCreateTbReq* ctbReq);
|
||||
int32_t qBuildStmtFinOutput(SQuery* pQuery, SHashObj* pAllVgHash, SArray* pVgDataBlocks);
|
||||
// int32_t qBuildStmtOutputFromTbList(SQuery* pQuery, SHashObj* pVgHash, SArray* pBlockList, STableDataCxt* pTbCtx,
|
||||
// int32_t tbNum);
|
||||
|
@ -165,7 +166,8 @@ int32_t qBindStmtSingleColValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* b
|
|||
int32_t qBindStmt2RowValue(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
STSchema** pTSchema, SBindInfo2* pBindInfos, void* charsetCxt);
|
||||
int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName,
|
||||
TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen, void* charsetCxt);
|
||||
TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen, void* charsetCxt,
|
||||
SVCreateTbReq* pCreateTbReq);
|
||||
|
||||
void destroyBoundColumnInfo(void* pBoundInfo);
|
||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||
|
@ -195,7 +197,7 @@ int32_t serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap, SArray** pOut);
|
|||
void destoryCatalogReq(SCatalogReq* pCatalogReq);
|
||||
bool isPrimaryKeyImpl(SNode* pExpr);
|
||||
int32_t insAppendStmtTableDataCxt(SHashObj* pAllVgHash, STableColsData* pTbData, STableDataCxt* pTbCtx,
|
||||
SStbInterlaceInfo* pBuildInfo);
|
||||
SStbInterlaceInfo* pBuildInfo, SVCreateTbReq* ctbReq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
#include "tdatablock.h"
|
||||
|
||||
#ifdef USE_ROCKSDB
|
||||
#include "rocksdb/c.h"
|
||||
#endif
|
||||
#include "tdbInt.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tstreamFileState.h"
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
#ifndef _TD_UTIL_HTTP_H_
|
||||
#define _TD_UTIL_HTTP_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tdef.h"
|
||||
#include "tref.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef TD_ASTRA_RPC
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "taosdef.h"
|
||||
|
@ -190,6 +191,198 @@ int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);
|
|||
int32_t rpcUtilSWhiteListToStr(SIpWhiteList *pWhiteList, char **ppBuf);
|
||||
int32_t rpcCvtErrCode(int32_t code);
|
||||
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "taosdef.h"
|
||||
#include "tmsg.h"
|
||||
#include "ttrace.h"
|
||||
|
||||
#define TAOS_CONN_SERVER 0
|
||||
#define TAOS_CONN_CLIENT 1
|
||||
#define IsReq(pMsg) (pMsg->msgType & 1U)
|
||||
|
||||
extern int32_t tsRpcHeadSize;
|
||||
|
||||
typedef struct {
|
||||
uint32_t clientIp;
|
||||
uint16_t clientPort;
|
||||
int64_t applyIndex;
|
||||
uint64_t applyTerm;
|
||||
char user[TSDB_USER_LEN];
|
||||
} SRpcConnInfo;
|
||||
|
||||
typedef enum {
|
||||
TD_ASTRA_CLIENT = 1,
|
||||
TD_ASTRA_DSVR_CLIENT = 2,
|
||||
TD_ASTRA_DSVR_STA_CLIENT = 4,
|
||||
TD_ASTRA_DSVR_SYNC_CLIENT = 8,
|
||||
TD_ASTRA_DSVR = 16
|
||||
} RPC_TYPE;
|
||||
|
||||
typedef struct SRpcHandleInfo {
|
||||
// rpc info
|
||||
void *handle; // rpc handle returned to app
|
||||
int64_t refId; // refid, used by server
|
||||
int8_t noResp; // has response or not(default 0, 0: resp, 1: no resp)
|
||||
int8_t persistHandle; // persist handle or not
|
||||
int8_t hasEpSet;
|
||||
int32_t cliVer;
|
||||
|
||||
// app info
|
||||
void *ahandle; // app handle set by client
|
||||
void *wrapper; // wrapper handle
|
||||
void *node; // node mgmt handle
|
||||
#ifdef TD_ASTRA_32
|
||||
void *ahandleEx; // app handle set by client
|
||||
#endif
|
||||
|
||||
// resp info
|
||||
void *rsp;
|
||||
int32_t rspLen;
|
||||
|
||||
STraceId traceId;
|
||||
|
||||
SRpcConnInfo conn;
|
||||
int8_t forbiddenIp;
|
||||
int8_t notFreeAhandle;
|
||||
int8_t compressed;
|
||||
int16_t connType;
|
||||
int64_t seq;
|
||||
int64_t qId;
|
||||
int32_t msgType;
|
||||
void *reqWithSem;
|
||||
int32_t refIdMgt;
|
||||
} SRpcHandleInfo;
|
||||
|
||||
typedef struct SRpcMsg {
|
||||
tmsg_t msgType;
|
||||
void *pCont;
|
||||
int32_t contLen;
|
||||
int32_t code;
|
||||
int32_t type;
|
||||
void *parent;
|
||||
SRpcHandleInfo info;
|
||||
|
||||
} SRpcMsg;
|
||||
|
||||
typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *epset);
|
||||
typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType);
|
||||
typedef bool (*RpcTfp)(int32_t code, tmsg_t msgType);
|
||||
typedef bool (*RpcFFfp)(tmsg_t msgType);
|
||||
typedef bool (*RpcNoDelayfp)(tmsg_t msgType);
|
||||
typedef void (*RpcDfp)(void *ahandle);
|
||||
|
||||
typedef struct SRpcInit {
|
||||
char localFqdn[TSDB_FQDN_LEN];
|
||||
uint16_t localPort; // local port
|
||||
char *label; // for debug purpose
|
||||
int32_t numOfThreads; // number of threads to handle connections
|
||||
int32_t sessions; // number of sessions allowed
|
||||
int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS
|
||||
int32_t idleTime; // milliseconds, 0 means idle timer is disabled
|
||||
int32_t compatibilityVer;
|
||||
|
||||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
int32_t retryMaxInterval; // retry max interval
|
||||
int64_t retryMaxTimeout;
|
||||
|
||||
int32_t failFastThreshold;
|
||||
int32_t failFastInterval;
|
||||
|
||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||
int8_t encryption; // encrypt or not
|
||||
|
||||
// the following is for client app ecurity only
|
||||
char *user; // user name
|
||||
|
||||
// call back to process incoming msg
|
||||
RpcCfp cfp;
|
||||
|
||||
// retry not not for particular msg
|
||||
RpcRfp rfp;
|
||||
|
||||
// set up timeout for particular msg
|
||||
RpcTfp tfp;
|
||||
|
||||
// destroy client ahandle;
|
||||
RpcDfp dfp;
|
||||
// fail fast fp
|
||||
RpcFFfp ffp;
|
||||
|
||||
RpcNoDelayfp noDelayFp;
|
||||
|
||||
int32_t connLimitNum;
|
||||
int32_t connLimitLock;
|
||||
int32_t timeToGetConn;
|
||||
int8_t supportBatch; // 0: no batch, 1. batch
|
||||
int32_t batchSize;
|
||||
int8_t notWaitAvaliableConn; // 1: wait to get, 0: no wait
|
||||
int32_t shareConnLimit;
|
||||
int8_t shareConn; // 0: no share, 1. share
|
||||
int8_t startReadTimer;
|
||||
int64_t readTimeout; // s
|
||||
void *parent;
|
||||
|
||||
} SRpcInit;
|
||||
|
||||
typedef struct {
|
||||
void *val;
|
||||
int32_t (*clone)(void *src, void **dst);
|
||||
} SRpcCtxVal;
|
||||
|
||||
typedef struct {
|
||||
int32_t msgType;
|
||||
void *val;
|
||||
int32_t (*clone)(void *src, void **dst);
|
||||
} SRpcBrokenlinkVal;
|
||||
|
||||
typedef struct {
|
||||
SHashObj *args;
|
||||
SRpcBrokenlinkVal brokenVal;
|
||||
void (*freeFunc)(const void *arg);
|
||||
int64_t st;
|
||||
} SRpcCtx;
|
||||
|
||||
int32_t rpcInit();
|
||||
void rpcCleanup();
|
||||
|
||||
void *rpcOpen(const SRpcInit *pRpc);
|
||||
void rpcClose(void *);
|
||||
void rpcCloseImpl(void *);
|
||||
void *rpcMallocCont(int64_t contLen);
|
||||
void rpcFreeCont(void *pCont);
|
||||
void *rpcReallocCont(void *ptr, int64_t contLen);
|
||||
|
||||
// Because taosd supports multi-process mode
|
||||
// These functions should not be used on the server side
|
||||
// Please use tmsg<xx> functions, which are defined in tmsgcb.h
|
||||
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||
int32_t rpcSendResponse(SRpcMsg *pMsg);
|
||||
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||
int32_t rpcReleaseHandle(void *handle, int8_t type,
|
||||
int32_t status); // just release conn to rpc instance, no close sock
|
||||
|
||||
// These functions will not be called in the child process
|
||||
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
int32_t rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||
int32_t rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated,
|
||||
int32_t timeoutMs);
|
||||
|
||||
int32_t rpcFreeConnById(void *shandle, int64_t connId);
|
||||
|
||||
int32_t rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||
int32_t rpcAllocHandle(int64_t *refId);
|
||||
int32_t rpcSetIpWhite(void *thandl, void *arg);
|
||||
|
||||
int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);
|
||||
|
||||
int32_t rpcUtilSWhiteListToStr(SIpWhiteList *pWhiteList, char **ppBuf);
|
||||
int32_t rpcCvtErrCode(int32_t code);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -28,29 +28,34 @@ extern "C" {
|
|||
#if !defined(WINDOWS)
|
||||
#include <dirent.h>
|
||||
|
||||
#if !defined(_ALPINE)
|
||||
#if !defined(_ALPINE) && !defined(TD_ASTRA)
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#if !defined(TD_ASTRA)
|
||||
#include <libgen.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <termios.h>
|
||||
#else
|
||||
#include <astra.h>
|
||||
#endif
|
||||
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
#include <termios.h>
|
||||
|
||||
#if defined(DARWIN)
|
||||
#else
|
||||
#if !defined(TD_ASTRA)
|
||||
#include <argp.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
@ -58,6 +63,7 @@ extern "C" {
|
|||
#include <cpuid.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
|
||||
#ifndef __func__
|
||||
|
|
|
@ -108,6 +108,9 @@ void wordfree(wordexp_t *pwordexp);
|
|||
#define LOG_ERR 0
|
||||
#define LOG_INFO 1
|
||||
void syslog(int unused, const char *format, ...);
|
||||
#elif defined(TD_ASTRA)
|
||||
char *stpncpy(char *dest, const char *src, int n);
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
#endif // WINDOWS
|
||||
|
||||
#ifndef WINDOWS
|
||||
|
@ -216,6 +219,9 @@ void syslog(int unused, const char *format, ...);
|
|||
// pthread_setname_np not defined
|
||||
#define setThreadName(name)
|
||||
#endif
|
||||
#elif defined(TD_ASTRA)
|
||||
#define setThreadName(name)
|
||||
#define getThreadName(name)
|
||||
#else
|
||||
// Linux, length of name must <= 16 (the last '\0' included)
|
||||
#define setThreadName(name) \
|
||||
|
@ -237,12 +243,24 @@ void syslog(int unused, const char *format, ...);
|
|||
|
||||
#if defined(_WIN32)
|
||||
#define TD_DIRSEP "\\"
|
||||
#elif defined(TD_ASTRA)
|
||||
#ifdef TD_ASTRA_TARGET
|
||||
#define TD_DIRSEP "/"
|
||||
#else
|
||||
#define TD_DIRSEP "\\"
|
||||
#endif
|
||||
#else
|
||||
#define TD_DIRSEP "/"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define TD_DIRSEP_CHAR '\\'
|
||||
#elif defined(TD_ASTRA)
|
||||
#ifdef TD_ASTRA_TARGET
|
||||
#define TD_DIRSEP_CHAR '/'
|
||||
#else
|
||||
#define TD_DIRSEP_CHAR '\\'
|
||||
#endif
|
||||
#else
|
||||
#define TD_DIRSEP_CHAR '/'
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,20 @@ extern "C" {
|
|||
#define TD_LOG_DIR_PATH "/var/log/taos/"
|
||||
#endif // CUS_PROMPT
|
||||
|
||||
#elif defined(TD_ASTRA)
|
||||
|
||||
#ifdef CUS_NAME
|
||||
#define TD_TMP_DIR_PATH "C:\\" CUS_NAME "\\Temp\\"
|
||||
#define TD_CFG_DIR_PATH "C:\\" CUS_NAME "\\cfg\\"
|
||||
#define TD_DATA_DIR_PATH "C:\\" CUS_NAME "\\data\\"
|
||||
#define TD_LOG_DIR_PATH "C:\\" CUS_NAME "\\log\\"
|
||||
#else
|
||||
#define TD_TMP_DIR_PATH "C:\\TDengine\\Temp\\"
|
||||
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
|
||||
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
|
||||
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
|
||||
#endif // CUS_NAME
|
||||
|
||||
#else
|
||||
|
||||
#define TD_TMP_DIR_PATH "/tmp/"
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef TD_ASTRA
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
typedef enum { TD_LITTLE_ENDIAN = 0, TD_BIG_ENDIAN } td_endian_t;
|
||||
|
||||
static const int32_t endian_test_var = 1;
|
||||
|
|
|
@ -72,6 +72,7 @@ TdFilePtr taosCreateFile(const char *path, int32_t tdFileOptions);
|
|||
#define TD_FILE_ACCESS_EXIST_OK 0x1
|
||||
#define TD_FILE_ACCESS_READ_OK 0x2
|
||||
#define TD_FILE_ACCESS_WRITE_OK 0x4
|
||||
#define TD_FILE_ACCESS_EXEC_OK 0x8
|
||||
|
||||
#define TD_TMP_FILE_PREFIX "tdengine-"
|
||||
|
||||
|
|
|
@ -29,13 +29,23 @@ extern "C" {
|
|||
#define TPOW2(x) ((x) * (x))
|
||||
#define TABS(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
#ifndef TD_ASTRA
|
||||
#define TSWAP(a, b) \
|
||||
do { \
|
||||
char *__tmp = (char*)alloca(sizeof(a)); \
|
||||
char *__tmp = (char *)alloca(sizeof(a)); \
|
||||
(void)memcpy(__tmp, &(a), sizeof(a)); \
|
||||
(void)memcpy(&(a), &(b), sizeof(a)); \
|
||||
(void)memcpy(&(b), __tmp, sizeof(a)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TSWAP(a, b) \
|
||||
do { \
|
||||
char __tmp[sizeof(a)]; \
|
||||
(void)memcpy(__tmp, &(a), sizeof(a)); \
|
||||
(void)memcpy(&(a), &(b), sizeof(a)); \
|
||||
(void)memcpy(&(b), __tmp, sizeof(a)); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
|
|
|
@ -149,8 +149,9 @@ int32_t taosMemoryPoolInit(mpReserveFailFp, mpReserveReachFp);
|
|||
} while (0)
|
||||
|
||||
|
||||
#ifndef BUILD_TEST
|
||||
extern void* gMemPoolHandle;
|
||||
|
||||
#if !defined(BUILD_TEST) && !defined(TD_ASTRA)
|
||||
extern threadlocal void* threadPoolSession;
|
||||
extern threadlocal bool threadPoolEnabled;
|
||||
extern int8_t tsMemPoolFullFunc;
|
||||
|
@ -173,10 +174,10 @@ extern int8_t tsMemPoolFullFunc;
|
|||
#define taosMemoryTrim(_size, _trimed) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolTrim(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__, _trimed)) : (taosMemTrim(_size, _trimed)))
|
||||
#define taosMemoryMallocAlign(_alignment, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMallocAlign(gMemPoolHandle, threadPoolSession, _alignment, _size, (char*)__FILE__, __LINE__)) : (taosMemMallocAlign(_alignment, _size)))
|
||||
#else
|
||||
#define taosEnableMemoryPoolUsage(_pool, _session)
|
||||
#define taosDisableMemoryPoolUsage()
|
||||
#define taosSaveDisableMemoryPoolUsage()
|
||||
#define taosRestoreEnableMemoryPoolUsage()
|
||||
#define taosEnableMemPoolUsage(_session)
|
||||
#define taosDisableMemPoolUsage()
|
||||
#define taosSaveDisableMemPoolUsage(_enable, _randErr)
|
||||
#define taosRestoreEnableMemPoolUsage(_enable, _randErr)
|
||||
|
||||
#define taosMemoryMalloc(_size) taosMemMalloc(_size)
|
||||
#define taosMemoryCalloc(_num, _size) taosMemCalloc(_num, _size)
|
||||
|
|
|
@ -25,9 +25,21 @@ extern "C" {
|
|||
#if !defined(WINDOWS)
|
||||
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
#ifdef malloc
|
||||
#undef malloc
|
||||
#endif
|
||||
#define malloc MALLOC_FUNC_TAOS_FORBID
|
||||
#ifdef calloc
|
||||
#undef calloc
|
||||
#endif
|
||||
#define calloc CALLOC_FUNC_TAOS_FORBID
|
||||
#ifdef realloc
|
||||
#undef realloc
|
||||
#endif
|
||||
#define realloc REALLOC_FUNC_TAOS_FORBID
|
||||
#ifdef free
|
||||
#undef free
|
||||
#endif
|
||||
#define free FREE_FUNC_TAOS_FORBID
|
||||
#ifdef strdup
|
||||
#undef strdup
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef TD_ASTRA
|
||||
#define DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
#endif
|
||||
|
||||
typedef wchar_t TdWchar;
|
||||
typedef int32_t TdUcs4;
|
||||
#if !defined(DISALLOW_NCHAR_WITHOUT_ICONV)// && defined(DARWIN)
|
||||
|
@ -101,8 +105,8 @@ void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type, void* charsetC
|
|||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, void* charsetCxt);
|
||||
int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
|
||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len, void* charsetCxt);
|
||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
int32_t taosUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
int32_t taosUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
bool taosValidateEncodec(const char *encodec);
|
||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len, int32_t bufSize);
|
||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
||||
|
@ -131,6 +135,13 @@ int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
|||
bool isHex(const char *z, uint32_t n);
|
||||
bool isValidateHex(const char *z, uint32_t n);
|
||||
|
||||
#ifdef TD_ASTRA
|
||||
static FORCE_INLINE size_t strnlen(const char *s, size_t maxlen) {
|
||||
const char *end = (const char *)memchr(s, '\0', maxlen);
|
||||
return end ? (size_t)(end - s) : maxlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -60,7 +60,7 @@ int32_t taosGetSystemUUIDLen(char *uid, int32_t uidlen);
|
|||
char *taosGetCmdlineByPID(int32_t pid);
|
||||
void taosSetCoreDump(bool enable);
|
||||
|
||||
#if !defined(LINUX)
|
||||
#if !defined(LINUX) || defined(TD_ASTRA)
|
||||
|
||||
#define _UTSNAME_LENGTH 65
|
||||
#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
// #endif
|
||||
#endif
|
||||
|
||||
#if !defined(WINDOWS) && !defined(_ALPINE)
|
||||
#if !defined(WINDOWS) && !defined(_ALPINE) && !defined(TD_ASTRA)
|
||||
#ifndef __USE_XOPEN2K
|
||||
#define TD_USE_SPINLOCK_AS_MUTEX
|
||||
typedef pthread_mutex_t pthread_spinlock_t;
|
||||
|
@ -70,12 +70,19 @@ typedef pthread_cond_t TdThreadCond;
|
|||
typedef pthread_condattr_t TdThreadCondAttr;
|
||||
typedef pthread_key_t TdThreadKey;
|
||||
#endif
|
||||
|
||||
#ifdef TD_ASTRA
|
||||
#define STACK_SIZE_DEFAULT (1048576 << 1)
|
||||
#define STACK_SIZE_SMALL (1048576)
|
||||
#else
|
||||
#define STACK_SIZE_DEFAULT (10485760)
|
||||
#endif
|
||||
#define taosThreadCleanupPush pthread_cleanup_push
|
||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||
#if !defined(WINDOWS)
|
||||
#if defined(_TD_DARWIN_64) // MACOS
|
||||
#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0)
|
||||
#elif defined(TD_ASTRA)
|
||||
#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0)
|
||||
#else // LINUX
|
||||
#if _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L
|
||||
#define taosThreadRwlockAttrSetKindNP(A, B) pthread_rwlockattr_setkind_np(A, B)
|
||||
|
@ -94,7 +101,7 @@ typedef pthread_key_t TdThreadKey;
|
|||
#else
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
|
@ -200,6 +207,7 @@ typedef pthread_key_t TdThreadKey;
|
|||
#define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID
|
||||
#define sigwait SIGWAIT_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg);
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr *attr);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// support OEM
|
||||
//
|
||||
#ifndef TD_PRODUCT_NAME
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA)
|
||||
#define TD_PRODUCT_NAME "TDengine Enterprise Edition"
|
||||
#else
|
||||
#define TD_PRODUCT_NAME "TDengine Community Edition"
|
||||
|
|
|
@ -58,6 +58,11 @@ int32_t taosGetErrSize();
|
|||
#define SET_ERROR_MSG(MSG, ...) \
|
||||
(void)snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
|
||||
|
||||
#ifndef TD_ASTRA_RTP
|
||||
#define SET_ERRNO(_code) (errno = (_code))
|
||||
#define ERRNO errno
|
||||
#endif
|
||||
|
||||
#define TSDB_CODE_SUCCESS 0
|
||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ void taosConvDestroy();
|
|||
//int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, void* charsetCxt);
|
||||
//int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
|
||||
//bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len, void* charsetCxt);
|
||||
//int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
//int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
//int32_t taosUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
//int32_t taosUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -25,6 +25,20 @@ extern "C" {
|
|||
|
||||
#define TSDB__packed
|
||||
|
||||
#if defined(TD_ASTRA_32)
|
||||
#define PACK_PUSH_MIN _Pragma("pack(push, 4)")
|
||||
#elif defined(WINDOWS)
|
||||
#define PACK_PUSH_MIN __pragma(pack(push, 1))
|
||||
#else
|
||||
#define PACK_PUSH_MIN _Pragma("pack(push, 1)")
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#define PACK_POP __pragma(pack(pop))
|
||||
#else
|
||||
#define PACK_POP _Pragma("pack(pop)")
|
||||
#endif
|
||||
|
||||
#define TSKEY int64_t
|
||||
#define TSKEY_MIN INT64_MIN
|
||||
#define TSKEY_MAX INT64_MAX
|
||||
|
@ -339,6 +353,8 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DNODE_CONFIG_LEN 128
|
||||
#define TSDB_DNODE_VALUE_LEN 256
|
||||
|
||||
#define TSDB_RESERVE_VALUE_LEN 256
|
||||
|
||||
#define TSDB_CLUSTER_VALUE_LEN 1000
|
||||
#define TSDB_GRANT_LOG_COL_LEN 15600
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef USE_GEOS
|
||||
#include <geos_c.h>
|
||||
#include <tpcre2.h>
|
||||
|
||||
|
@ -41,6 +42,7 @@ typedef struct SGeosContext {
|
|||
SGeosContext *acquireThreadLocalGeosCtx();
|
||||
int32_t getThreadLocalGeosCtx(SGeosContext **ppCtx);
|
||||
const char *getGeosErrMsg(int32_t code);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,6 +34,11 @@ typedef enum {
|
|||
DEBUG_FILE = 128
|
||||
} ELogLevel;
|
||||
|
||||
typedef enum {
|
||||
LOG_MODE_TAOSC = 1,
|
||||
LOG_MODE_TAOSD = 2
|
||||
} ELogMode;
|
||||
|
||||
typedef void (*LogFp)(int64_t ts, ELogLevel level, const char *content);
|
||||
|
||||
extern bool tsLogEmbedded;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef _TD_ULIT_PCRE2_H_
|
||||
#define _TD_ULIT_PCRE2_H_
|
||||
|
||||
#ifdef USE_PRCE2
|
||||
#define PCRE2_CODE_UNIT_WIDTH 8
|
||||
#include "pcre2.h"
|
||||
|
||||
|
@ -31,4 +32,5 @@ void destroyRegexes(pcre2_code* pWktRegex, pcre2_match_data* pWktMatchData);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // USE_PRCE2
|
||||
#endif // _TD_UTIL_PAGEDBUF_H_
|
||||
|
|
|
@ -54,6 +54,136 @@ int32_t parseCfgReal(const char *str, float *out);
|
|||
bool tIsValidFileName(const char *fileName, const char *pattern);
|
||||
bool tIsValidFilePath(const char *filePath, const char *pattern);
|
||||
|
||||
#ifdef TD_ASTRA
|
||||
static FORCE_INLINE int32_t taosStrcasecmp(const char *s1, const char *s2) {
|
||||
if (s1[0] == 0 && s2[0] == 0) return 0;
|
||||
return strcasecmp(s1, s2);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosStrncasecmp(const char *s1, const char *s2, size_t n) {
|
||||
if (s1[0] == 0 && s2[0] == 0) return 0;
|
||||
return strncasecmp(s1, s2, n);
|
||||
}
|
||||
#else
|
||||
#define taosStrcasecmp strcasecmp
|
||||
#define taosStrncasecmp strncasecmp
|
||||
#endif
|
||||
|
||||
#ifdef NO_UNALIGNED_ACCESS
|
||||
#define CHECK_ALIGNMENT
|
||||
static FORCE_INLINE int64_t taosGetInt64Aligned(int64_t *pVal) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
|
||||
#endif
|
||||
int64_t val;
|
||||
memcpy(&val, pVal, sizeof(int64_t));
|
||||
return val;
|
||||
}
|
||||
|
||||
static FORCE_INLINE uint64_t taosGetUInt64Aligned(uint64_t *pVal) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
|
||||
#endif
|
||||
uint64_t val;
|
||||
memcpy(&val, pVal, sizeof(uint64_t));
|
||||
return val;
|
||||
}
|
||||
|
||||
static FORCE_INLINE float taosGetFloatAligned(float *pVal) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
|
||||
#endif
|
||||
float val;
|
||||
memcpy(&val, pVal, sizeof(float));
|
||||
return val;
|
||||
}
|
||||
|
||||
static FORCE_INLINE double taosGetDoubleAligned(double *pVal) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)pVal) & 7) == 0) return *pVal;
|
||||
#endif
|
||||
double val;
|
||||
memcpy(&val, pVal, sizeof(double));
|
||||
return val;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetInt64Aligned(int64_t *p, int64_t val) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)p) & 7) == 0) {
|
||||
*p = val;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(p, &val, sizeof(int64_t));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetUInt64Aligned(uint64_t *p, uint64_t val) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)p) & 7) == 0) {
|
||||
*p = val;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(p, &val, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetPInt64Aligned(int64_t *to, int64_t *from) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
|
||||
*to = *from;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(to, from, sizeof(int64_t));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetPFloatAligned(float *to, float *from) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
|
||||
*to = *from;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(to, from, sizeof(float));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetPDoubleAligned(double *to, double *from) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
|
||||
*to = *from;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(to, from, sizeof(double));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosSetPUInt64Aligned(uint64_t *to, uint64_t *from) {
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
if ((((uintptr_t)from) & 7) == 0 && ((uintptr_t)to & 7) == 0) {
|
||||
*to = *from;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
memcpy(to, from, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
#define TAOS_SET_OBJ_ALIGNED(pTo, vFrom) memcpy((pTo), &(vFrom), sizeof(*(pTo)))
|
||||
#define TAOS_SET_POBJ_ALIGNED(pTo, pFrom) memcpy((pTo), (pFrom), sizeof(*(pTo)))
|
||||
#else
|
||||
static FORCE_INLINE int64_t taosGetInt64Aligned(int64_t *pVal) { return *pVal; }
|
||||
static FORCE_INLINE uint64_t taosGetUInt64Aligned(uint64_t *pVal) { return *pVal; }
|
||||
static FORCE_INLINE float taosGetFloatAligned(float *pVal) { return *pVal; }
|
||||
static FORCE_INLINE double taosGetDoubleAligned(double *pVal) { return *pVal; }
|
||||
static FORCE_INLINE void taosSetInt64Aligned(int64_t *p, int64_t val) { *p = val; }
|
||||
static FORCE_INLINE void taosSetUInt64Aligned(uint64_t *p, uint64_t val) { *p = val; }
|
||||
static FORCE_INLINE void taosSetPInt64Aligned(int64_t *to, int64_t *from) { *to = *from; }
|
||||
static FORCE_INLINE void taosSetPFloatAligned(float *to, float *from) { *to = *from; }
|
||||
static FORCE_INLINE void taosSetPDoubleAligned(double *to, double *from) { *to = *from; }
|
||||
static FORCE_INLINE void taosSetPUInt64Aligned(uint64_t *to, uint64_t *from) { *to = *from; }
|
||||
#define TAOS_SET_OBJ_ALIGNED(pTo, vFrom) *(pTo) = (vFrom)
|
||||
#define TAOS_SET_POBJ_ALIGNED(pTo, pFrom) *(pTo) = *(pFrom)
|
||||
#endif
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
tMD5Init(&context);
|
||||
|
@ -148,18 +278,18 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
|
||||
#define QUERY_CHECK_CODE TSDB_CHECK_CODE
|
||||
|
||||
#define TSDB_CHECK_CONDITION(condition, CODE, LINO, LABEL, ERRNO) \
|
||||
#define TSDB_CHECK_CONDITION(condition, CODE, LINO, LABEL, _ERRNO) \
|
||||
if (UNLIKELY(!(condition))) { \
|
||||
(CODE) = (ERRNO); \
|
||||
(CODE) = (_ERRNO); \
|
||||
(LINO) = __LINE__; \
|
||||
goto LABEL; \
|
||||
}
|
||||
|
||||
#define QUERY_CHECK_CONDITION TSDB_CHECK_CONDITION
|
||||
|
||||
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \
|
||||
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, _ERRNO) \
|
||||
if (UNLIKELY((ptr) == NULL)) { \
|
||||
(CODE) = (ERRNO); \
|
||||
(CODE) = (_ERRNO); \
|
||||
(LINO) = __LINE__; \
|
||||
goto LABEL; \
|
||||
}
|
||||
|
@ -170,7 +300,7 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
|
||||
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
|
||||
|
||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
|
||||
|
||||
#define TAOS_GET_TERRNO(code) (terrno == 0 ? code : terrno)
|
||||
|
||||
|
@ -187,11 +317,11 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN_SET_CODE(CMD, CODE, ERRNO) \
|
||||
#define TAOS_CHECK_RETURN_SET_CODE(CMD, CODE, _ERRNO) \
|
||||
do { \
|
||||
int32_t __c = (CMD); \
|
||||
if (__c != TSDB_CODE_SUCCESS) { \
|
||||
(CODE) = (ERRNO); \
|
||||
(CODE) = (_ERRNO); \
|
||||
TAOS_RETURN(__c); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -234,11 +364,11 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_EXIT_SET_CODE(CMD, CODE, ERRNO) \
|
||||
#define TAOS_CHECK_EXIT_SET_CODE(CMD, CODE, _ERRNO) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
if (code < TSDB_CODE_SUCCESS) { \
|
||||
(CODE) = (ERRNO); \
|
||||
(CODE) = (_ERRNO); \
|
||||
lino = __LINE__; \
|
||||
goto _exit; \
|
||||
} \
|
||||
|
|
|
@ -21,10 +21,14 @@ target_include_directories(
|
|||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
set(TAOSD_MODULE "")
|
||||
if(${TAOSD_INTEGRATED})
|
||||
set(TAOSD_MODULE "taosd")
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${TAOS_LIB}
|
||||
INTERFACE api
|
||||
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry
|
||||
PRIVATE os util common transport monitor nodes parser command planner catalog scheduler function qcom geometry ${TAOSD_MODULE}
|
||||
)
|
||||
|
||||
if(TD_WINDOWS)
|
||||
|
|
|
@ -119,17 +119,17 @@ typedef struct {
|
|||
} SAppInstServerCFG;
|
||||
struct SAppInstInfo {
|
||||
int64_t numOfConns;
|
||||
SCorEpSet mgmtEp;
|
||||
int32_t totalDnodes;
|
||||
int32_t onlineDnodes;
|
||||
TdThreadMutex qnodeMutex;
|
||||
SArray* pQnodeList;
|
||||
SAppClusterSummary summary;
|
||||
SList* pConnList; // STscObj linked list
|
||||
int64_t clusterId;
|
||||
SAppClusterSummary summary;
|
||||
SArray* pQnodeList;
|
||||
SList* pConnList; // STscObj linked list
|
||||
void* pTransporter;
|
||||
SAppHbMgr* pAppHbMgr;
|
||||
char* instKey;
|
||||
TdThreadMutex qnodeMutex;
|
||||
SCorEpSet mgmtEp;
|
||||
SAppInstServerCFG serverCfg;
|
||||
};
|
||||
|
||||
|
@ -265,8 +265,9 @@ typedef struct SReqRelInfo {
|
|||
|
||||
typedef struct SRequestObj {
|
||||
int8_t resType; // query or tmq
|
||||
uint64_t requestId;
|
||||
int32_t type; // request type
|
||||
uint64_t requestId;
|
||||
SQuery* pQuery;
|
||||
STscObj* pTscObj;
|
||||
char* pDb; // current database string
|
||||
char* sqlstr; // sql string
|
||||
|
@ -294,13 +295,13 @@ typedef struct SRequestObj {
|
|||
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
|
||||
uint32_t retry;
|
||||
int64_t allocatorRefId;
|
||||
SQuery* pQuery;
|
||||
void* pPostPlan;
|
||||
SReqRelInfo relation;
|
||||
void* pWrapper;
|
||||
SMetaData parseMeta;
|
||||
char* effectiveUser;
|
||||
int8_t source;
|
||||
bool streamRunHistory;
|
||||
} SRequestObj;
|
||||
|
||||
typedef struct SSyncQueryParam {
|
||||
|
|
|
@ -123,6 +123,7 @@ typedef struct SStmtStatInfo {
|
|||
typedef struct SStmtQNode {
|
||||
bool restoreTbCols;
|
||||
STableColsData tblData;
|
||||
SVCreateTbReq *pCreateTbReq;
|
||||
struct SStmtQNode* next;
|
||||
} SStmtQNode;
|
||||
|
||||
|
|
|
@ -102,6 +102,8 @@ typedef struct {
|
|||
SHashObj *pVgHash;
|
||||
SBindInfo2 *pBindInfo;
|
||||
bool bindRowFormat;
|
||||
bool fixValueTags;
|
||||
SVCreateTbReq *fixValueTbReq;
|
||||
|
||||
SStbInterlaceInfo siInfo;
|
||||
} SStmtSQLInfo2;
|
||||
|
@ -234,8 +236,9 @@ int stmtClose2(TAOS_STMT2 *stmt);
|
|||
int stmtExec2(TAOS_STMT2 *stmt, int *affected_rows);
|
||||
int stmtPrepare2(TAOS_STMT2 *stmt, const char *sql, unsigned long length);
|
||||
int stmtSetTbName2(TAOS_STMT2 *stmt, const char *tbName);
|
||||
int stmtSetTbTags2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *tags);
|
||||
int stmtBindBatch2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, int32_t colIdx);
|
||||
int stmtSetTbTags2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *tags, SVCreateTbReq **pCreateTbReq);
|
||||
int stmtCheckTags2(TAOS_STMT2 *stmt, SVCreateTbReq **pCreateTbReq);
|
||||
int stmtBindBatch2(TAOS_STMT2 *stmt, TAOS_STMT2_BIND *bind, int32_t colIdx, SVCreateTbReq *pCreateTbReq);
|
||||
int stmtGetStbColFields2(TAOS_STMT2 *stmt, int *nums, TAOS_FIELD_ALL **fields);
|
||||
int stmtGetParamNum2(TAOS_STMT2 *stmt, int *nums);
|
||||
int stmtIsInsert2(TAOS_STMT2 *stmt, int *insert);
|
||||
|
|
|
@ -54,9 +54,9 @@
|
|||
|
||||
#define ENV_ERR_RET(c, info) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
int32_t _code = (c); \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
errno = _code; \
|
||||
terrno = _code; \
|
||||
tscInitRes = _code; \
|
||||
tscError(info); \
|
||||
return; \
|
||||
|
@ -128,7 +128,7 @@ static void concatStrings(SArray *list, char *buf, int size) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_REPORT
|
||||
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration) {
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -217,7 +217,7 @@ _end:
|
|||
cJSON_Delete(json);
|
||||
return code;
|
||||
}
|
||||
|
||||
#endif
|
||||
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char *exceptDb) {
|
||||
if (pRequest->pDb != NULL) {
|
||||
return strcmp(pRequest->pDb, exceptDb) != 0;
|
||||
|
@ -283,6 +283,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_REPORT
|
||||
if (pTscObj->pAppInfo->serverCfg.monitorParas.tsEnableMonitor) {
|
||||
if (QUERY_NODE_VNODE_MODIFY_STMT == pRequest->stmtType || QUERY_NODE_INSERT_STMT == pRequest->stmtType) {
|
||||
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPEINSERT);
|
||||
|
@ -308,6 +309,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
releaseTscObj(pTscObj->id);
|
||||
}
|
||||
|
@ -789,7 +791,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_REPORT
|
||||
void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop, -1); }
|
||||
|
||||
static void *tscCrashReportThreadFp(void *param) {
|
||||
|
@ -888,15 +890,15 @@ int32_t tscCrashReportInit() {
|
|||
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
|
||||
TdThread crashReportThread;
|
||||
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
|
||||
tscError("failed to create crashReport thread since %s", strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
TSC_ERR_RET(errno);
|
||||
tscError("failed to create crashReport thread since %s", strerror(ERRNO));
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
_return:
|
||||
if (code) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -921,6 +923,113 @@ void tscStopCrashReport() {
|
|||
void tscWriteCrashInfo(int signum, void *sigInfo, void *context) {
|
||||
writeCrashLogToFile(signum, sigInfo, CUS_PROMPT, lastClusterId, appInfo.startTime);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
typedef struct {
|
||||
TdThread pid;
|
||||
int32_t stat; // < 0: start failed, 0: init(not start), 1: start successfully
|
||||
} SDaemonObj;
|
||||
|
||||
extern int dmStartDaemon(int argc, char const *argv[]);
|
||||
extern void dmStopDaemon();
|
||||
|
||||
SDaemonObj daemonObj = {0};
|
||||
|
||||
typedef struct {
|
||||
int32_t argc;
|
||||
char **argv;
|
||||
} SExecArgs;
|
||||
|
||||
static void *dmStartDaemonFunc(void *param) {
|
||||
int32_t code = 0;
|
||||
SExecArgs *pArgs = (SExecArgs *)param;
|
||||
int32_t argc = pArgs->argc;
|
||||
char **argv = pArgs->argv;
|
||||
|
||||
code = dmStartDaemon(argc, (const char **)argv);
|
||||
if (code != 0) {
|
||||
printf("failed to start taosd since %s\r\n", tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (code != 0) {
|
||||
atomic_store_32(&daemonObj.stat, code);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t shellStartDaemon(int argc, char *argv[]) {
|
||||
int32_t code = 0, lino = 0;
|
||||
SExecArgs *pArgs = NULL;
|
||||
int64_t startMs = taosGetTimestampMs(), endMs = startMs;
|
||||
|
||||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
pArgs = (SExecArgs *)taosMemoryCalloc(1, sizeof(SExecArgs));
|
||||
if (pArgs == NULL) {
|
||||
code = terrno;
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
pArgs->argc = argc;
|
||||
pArgs->argv = argv;
|
||||
|
||||
#ifndef TD_AS_LIB
|
||||
tsLogEmbedded = 1;
|
||||
#endif
|
||||
|
||||
TAOS_CHECK_EXIT(taosThreadCreate(&daemonObj.pid, &thAttr, dmStartDaemonFunc, pArgs));
|
||||
|
||||
while (true) {
|
||||
if (atomic_load_64(&tsDndStart)) {
|
||||
atomic_store_32(&daemonObj.stat, 1);
|
||||
break;
|
||||
}
|
||||
int32_t daemonstat = atomic_load_32(&daemonObj.stat);
|
||||
if (daemonstat < 0) {
|
||||
code = daemonstat;
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
|
||||
if (daemonstat > 1) {
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
_exit:
|
||||
endMs = taosGetTimestampMs();
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
taosMemoryFreeClear(pArgs);
|
||||
if (code) {
|
||||
printf("\r\n The daemon start failed at line %d since %s, cost %" PRIi64 " ms\r\n", lino, tstrerror(code),
|
||||
endMs - startMs);
|
||||
} else {
|
||||
printf("\r\n The daemon started successfully, cost %" PRIi64 " ms\r\n", endMs - startMs);
|
||||
}
|
||||
#ifndef TD_AS_LIB
|
||||
tsLogEmbedded = 0;
|
||||
#endif
|
||||
return code;
|
||||
}
|
||||
|
||||
void shellStopDaemon() {
|
||||
#ifndef TD_AS_LIB
|
||||
tsLogEmbedded = 1;
|
||||
#endif
|
||||
dmStopDaemon();
|
||||
if (taosCheckPthreadValid(daemonObj.pid)) {
|
||||
(void)taosThreadJoin(daemonObj.pid, NULL);
|
||||
taosThreadClear(&daemonObj.pid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void taos_init_imp(void) {
|
||||
#if defined(LINUX)
|
||||
|
@ -938,7 +1047,8 @@ void taos_init_imp(void) {
|
|||
// In the APIs of other program language, taos_cleanup is not available yet.
|
||||
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
|
||||
(void)atexit(taos_cleanup);
|
||||
errno = TSDB_CODE_SUCCESS;
|
||||
SET_ERRNO(TSDB_CODE_SUCCESS);
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
|
||||
appInfo.pid = taosGetPId();
|
||||
|
@ -956,20 +1066,26 @@ void taos_init_imp(void) {
|
|||
const char *logName = CUS_PROMPT "log";
|
||||
ENV_ERR_RET(taosInitLogOutput(&logName), "failed to init log output");
|
||||
if (taosCreateLog(logName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logName, strerror(errno), configDir);
|
||||
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logName, strerror(ERRNO), configDir);
|
||||
tscInitRes = terrno;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0), "failed to init cfg");
|
||||
#else
|
||||
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1), "failed to init cfg");
|
||||
#endif
|
||||
|
||||
initQueryModuleMsgHandle();
|
||||
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
|
||||
tscInitRes = terrno;
|
||||
tscError("failed to init conv");
|
||||
return;
|
||||
}
|
||||
#ifndef WINDOWS
|
||||
#endif
|
||||
#if !defined(WINDOWS) && !defined(TD_ASTRA)
|
||||
ENV_ERR_RET(tzInit(), "failed to init timezone");
|
||||
#endif
|
||||
ENV_ERR_RET(monitorInit(), "failed to init monitor");
|
||||
|
@ -997,9 +1113,13 @@ void taos_init_imp(void) {
|
|||
|
||||
ENV_ERR_RET(taosGetAppName(appInfo.appName, NULL), "failed to get app name");
|
||||
ENV_ERR_RET(taosThreadMutexInit(&appInfo.mutex, NULL), "failed to init thread mutex");
|
||||
#ifdef USE_REPORT
|
||||
ENV_ERR_RET(tscCrashReportInit(), "failed to init crash report");
|
||||
#endif
|
||||
ENV_ERR_RET(qInitKeywordsTable(), "failed to init parser keywords table");
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
ENV_ERR_RET(shellStartDaemon(0, NULL), "failed to start taosd daemon");
|
||||
#endif
|
||||
tscInfo("TAOS driver is initialized successfully");
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
|
|||
for (int32_t j = 0; j < rsp->vgNum; ++j) {
|
||||
SVgroupInfo *pInfo = taosArrayGet(rsp->pVgroupInfos, j);
|
||||
if (taosHashPut(vgInfo->vgHash, &pInfo->vgId, sizeof(int32_t), pInfo, sizeof(SVgroupInfo)) != 0) {
|
||||
tscError("hash push failed, errno:%d", errno);
|
||||
tscError("hash push failed, terrno:%d", terrno);
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
@ -1401,16 +1401,19 @@ static int32_t hbCreateThread() {
|
|||
TdThreadAttr thAttr;
|
||||
TSC_ERR_JRET(taosThreadAttrInit(&thAttr));
|
||||
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
|
||||
#ifdef TD_COMPACT_OS
|
||||
TSC_ERR_JRET(taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL));
|
||||
#endif
|
||||
|
||||
if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
_return:
|
||||
|
||||
if (code) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -1431,12 +1434,12 @@ static void hbStopThread() {
|
|||
if (clientHbMgr.quitByKill) {
|
||||
code = taosThreadKill(clientHbMgr.thread, 0);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("taosThreadKill failed since %s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
tscError("taosThreadKill failed since %s", tstrerror(code));
|
||||
}
|
||||
} else {
|
||||
code = taosThreadJoin(clientHbMgr.thread, NULL);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("taosThreadJoin failed since %s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
tscError("taosThreadJoin failed since %s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1126,13 +1126,13 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
|
|||
}
|
||||
}
|
||||
|
||||
tscDebug("lastKey:%" PRId64 " vgId:%d, vgVer:%" PRId64, ts, *(int32_t*)pRow[1], *(int64_t*)pRow[2]);
|
||||
tscInfo("[create stream with histroy] lastKey:%" PRId64 " vgId:%d, vgVer:%" PRId64, ts, *(int32_t*)pRow[1], *(int64_t*)pRow[2]);
|
||||
}
|
||||
|
||||
(*pBlock)->info.window.ekey = lastTs;
|
||||
(*pBlock)->info.rows = numOfRows;
|
||||
|
||||
tscDebug("lastKey:%" PRId64 " numOfRows:%d from all vgroups", lastTs, numOfRows);
|
||||
tscInfo("[create stream with histroy] lastKey:%" PRId64 " numOfRows:%d from all vgroups", lastTs, numOfRows);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2413,7 +2413,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, bool convertUcs4) {
|
|||
int32_t hasColumnSeg = *(int32_t*)p;
|
||||
p += sizeof(int32_t);
|
||||
|
||||
uint64_t groupId = *(uint64_t*)p;
|
||||
uint64_t groupId = taosGetUInt64Aligned((uint64_t*)p);
|
||||
p += sizeof(uint64_t);
|
||||
|
||||
// check fields
|
||||
|
@ -2469,10 +2469,11 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, bool convertUcs4) {
|
|||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
if (convertUcs4) {
|
||||
code = doConvertUCS4(pResultInfo, colLength);
|
||||
}
|
||||
|
||||
#endif
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3115,7 +3116,9 @@ void doRequestCallback(SRequestObj* pRequest, int32_t code) {
|
|||
code = TSDB_CODE_SUCCESS;
|
||||
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
||||
}
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(((SSyncQueryParam*)pRequest->body.interParam)->userParam, pRequest, code);
|
||||
}
|
||||
SRequestObj* pReq = acquireRequest(this);
|
||||
if (pReq != NULL) {
|
||||
pReq->inCallback = false;
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
extern void shellStopDaemon();
|
||||
#endif
|
||||
|
||||
static int32_t sentinel = TSC_VAR_NOT_RELEASE;
|
||||
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SSqlCallbackWrapper *pWrapper);
|
||||
|
||||
|
@ -55,7 +59,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
#if !defined(WINDOWS) && !defined(TD_ASTRA)
|
||||
static void freeTz(void *p) {
|
||||
timezone_t tz = *(timezone_t *)p;
|
||||
tzfree(tz);
|
||||
|
@ -95,7 +99,7 @@ static timezone_t setConnnectionTz(const char *val) {
|
|||
tz = tzalloc("UTC");
|
||||
if (tz == NULL) {
|
||||
tscError("%s set timezone UTC error", __func__);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto END;
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +157,7 @@ static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, co
|
|||
val = NULL;
|
||||
}
|
||||
|
||||
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
if (option == TSDB_OPTION_CONNECTION_CHARSET || option == TSDB_OPTION_CONNECTION_CLEAR) {
|
||||
if (val != NULL) {
|
||||
if (!taosValidateEncodec(val)) {
|
||||
|
@ -169,9 +174,9 @@ static int32_t setConnectionOption(TAOS *taos, TSDB_OPTION_CONNECTION option, co
|
|||
pObj->optionInfo.charsetCxt = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (option == TSDB_OPTION_CONNECTION_TIMEZONE || option == TSDB_OPTION_CONNECTION_CLEAR) {
|
||||
#ifndef WINDOWS
|
||||
#if !defined(WINDOWS) && !defined(TD_ASTRA)
|
||||
if (val != NULL) {
|
||||
if (val[0] == 0) {
|
||||
val = "UTC";
|
||||
|
@ -239,7 +244,7 @@ void taos_cleanup(void) {
|
|||
tscWarn("failed to cleanup task queue");
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
#if !defined(WINDOWS) && !defined(TD_ASTRA)
|
||||
tzCleanup();
|
||||
#endif
|
||||
tmqMgmtClose();
|
||||
|
@ -259,10 +264,14 @@ void taos_cleanup(void) {
|
|||
|
||||
taosConvDestroy();
|
||||
DestroyRegexCache();
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
shellStopDaemon();
|
||||
#endif
|
||||
tscInfo("all local resources released");
|
||||
taosCleanupCfg();
|
||||
#ifndef TAOSD_INTEGRATED
|
||||
taosCloseLog();
|
||||
#endif
|
||||
}
|
||||
|
||||
static setConfRet taos_set_config_imp(const char *config) {
|
||||
|
@ -1418,7 +1427,8 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SS
|
|||
.parseSqlParam = pWrapper,
|
||||
.setQueryFp = setQueryRequest,
|
||||
.timezone = pTscObj->optionInfo.timezone,
|
||||
.charsetCxt = pTscObj->optionInfo.charsetCxt};
|
||||
.charsetCxt = pTscObj->optionInfo.charsetCxt,
|
||||
.streamRunHistory = pRequest->streamRunHistory};
|
||||
int8_t biMode = atomic_load_8(&((STscObj *)pTscObj)->biMode);
|
||||
(*pCxt)->biMode = biMode;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2170,7 +2180,7 @@ int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col
|
|||
}
|
||||
|
||||
STscStmt2 *pStmt = (STscStmt2 *)stmt;
|
||||
if( atomic_load_8((int8_t*)&pStmt->asyncBindParam.asyncBindNum)>1) {
|
||||
if (atomic_load_8((int8_t *)&pStmt->asyncBindParam.asyncBindNum) > 1) {
|
||||
tscError("async bind param is still working, please try again later");
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
}
|
||||
|
@ -2210,17 +2220,18 @@ int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col
|
|||
}
|
||||
}
|
||||
|
||||
SVCreateTbReq *pCreateTbReq = NULL;
|
||||
if (bindv->tags && bindv->tags[i]) {
|
||||
code = stmtSetTbTags2(stmt, bindv->tags[i]);
|
||||
code = stmtSetTbTags2(stmt, bindv->tags[i], &pCreateTbReq);
|
||||
} else if (pStmt->sql.autoCreateTbl || pStmt->bInfo.needParse) {
|
||||
code = stmtCheckTags2(stmt, &pCreateTbReq);
|
||||
} else {
|
||||
pStmt->sql.autoCreateTbl = false;
|
||||
}
|
||||
|
||||
if (code) {
|
||||
goto out;
|
||||
}
|
||||
} else if (pStmt->bInfo.tbType == TSDB_CHILD_TABLE && pStmt->sql.autoCreateTbl) {
|
||||
code = stmtSetTbTags2(stmt, NULL);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
if (bindv->bind_cols && bindv->bind_cols[i]) {
|
||||
TAOS_STMT2_BIND *bind = bindv->bind_cols[i];
|
||||
|
@ -2239,7 +2250,7 @@ int taos_stmt2_bind_param(TAOS_STMT2 *stmt, TAOS_STMT2_BINDV *bindv, int32_t col
|
|||
goto out;
|
||||
}
|
||||
|
||||
code = stmtBindBatch2(stmt, bind, col_idx);
|
||||
code = stmtBindBatch2(stmt, bind, col_idx, pCreateTbReq);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -669,8 +669,8 @@ static void monitorSendAllSlowLog() {
|
|||
int64_t size = getFileSize(pClient->path);
|
||||
if (size <= 0) {
|
||||
if (size < 0) {
|
||||
tscError("monitor failed to get file size:%s, err:%d", pClient->path, errno);
|
||||
if (errno == ENOENT) {
|
||||
tscError("monitor failed to get file size:%s, err:%d", pClient->path, ERRNO);
|
||||
if (ERRNO == ENOENT) {
|
||||
processFileRemoved(pClient);
|
||||
}
|
||||
}
|
||||
|
@ -810,16 +810,16 @@ static void* monitorThreadFunc(void* param) {
|
|||
static int32_t tscMonitortInit() {
|
||||
TdThreadAttr thAttr;
|
||||
if (taosThreadAttrInit(&thAttr) != 0) {
|
||||
tscError("failed to init thread attr since %s", strerror(errno));
|
||||
tscError("failed to init thread attr since %s", strerror(ERRNO));
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) {
|
||||
tscError("failed to set thread attr since %s", strerror(errno));
|
||||
tscError("failed to set thread attr since %s", strerror(ERRNO));
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) {
|
||||
tscError("failed to create monitor thread since %s", strerror(errno));
|
||||
tscError("failed to create monitor thread since %s", strerror(ERRNO));
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ int32_t monitorInit() {
|
|||
|
||||
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
||||
tscError("sem init error since %s", terrstr());
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return TAOS_SYSTEM_ERROR(ERRNO);
|
||||
}
|
||||
|
||||
code = taosOpenQueue(&monitorQueue);
|
||||
|
|
|
@ -151,12 +151,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
POINTER_BYTES) != 0) {
|
||||
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
|
||||
} else {
|
||||
#ifdef USE_MONITOR
|
||||
MonitorSlowLogData data = {0};
|
||||
data.clusterId = pTscObj->pAppInfo->clusterId;
|
||||
data.type = SLOW_LOG_READ_BEGINNIG;
|
||||
(void)monitorPutData2MonitorQueue(data); // ignore
|
||||
monitorClientSlowQueryInit(connectRsp.clusterId);
|
||||
monitorClientSQLReqInit(connectRsp.clusterId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -856,6 +858,119 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t setCreateStreamFailedRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (pMsg) {
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pMsg->pData);
|
||||
}
|
||||
if (code != 0){
|
||||
tscError("setCreateStreamFailedRsp since %s", tstrerror(code));
|
||||
} else{
|
||||
tscInfo("setCreateStreamFailedRsp success");
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void sendCreateStreamFailedMsg(SRequestObj* pRequest, char* streamName){
|
||||
int32_t code = 0;
|
||||
tscInfo("send failed stream name to mgmt: %s", streamName);
|
||||
int32_t size = INT_BYTES + strlen(streamName);
|
||||
void *buf = taosMemoryMalloc(size);
|
||||
if (buf == NULL) {
|
||||
tscError("failed to strdup stream name: %s", terrstr());
|
||||
return;
|
||||
}
|
||||
*(int32_t*)buf = pRequest->code;
|
||||
memcpy(POINTER_SHIFT(buf, INT_BYTES), streamName, strlen(streamName));
|
||||
|
||||
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) {
|
||||
taosMemoryFree(buf);
|
||||
tscError("failed to calloc msgSendInfo: %s", terrstr());
|
||||
return;
|
||||
}
|
||||
sendInfo->msgInfo = (SDataBuf){.pData = buf, .len = size, .handle = NULL};
|
||||
sendInfo->requestId = generateRequestId();
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->msgType = TDMT_MND_FAILED_STREAM;
|
||||
sendInfo->fp = setCreateStreamFailedRsp;
|
||||
|
||||
SEpSet epSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
|
||||
code = asyncSendMsgToServer(pRequest->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo);
|
||||
if (code != 0) {
|
||||
tscError("failed to send failed stream name to mgmt since %s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
static void processCreateStreamSecondPhaseRsp(void* param, void* res, int32_t code) {
|
||||
SRequestObj* pRequest = res;
|
||||
if (code != 0 && param != NULL){
|
||||
sendCreateStreamFailedMsg(pRequest, param);
|
||||
}
|
||||
taosMemoryFree(param);
|
||||
destroyRequest(pRequest);
|
||||
}
|
||||
|
||||
static char* getStreamName(SRequestObj* pRequest){
|
||||
SCreateStreamStmt* pStmt = (SCreateStreamStmt*)(pRequest->pQuery->pRoot);
|
||||
SName name;
|
||||
int32_t code = tNameSetDbName(&name, pRequest->pTscObj->acctId, pStmt->streamName, strlen(pStmt->streamName));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to set db name for stream since %s", tstrerror(code));
|
||||
return NULL;
|
||||
} else{
|
||||
char *streamName = taosMemoryCalloc(1, TSDB_STREAM_FNAME_LEN);
|
||||
(void)tNameGetFullDbName(&name, streamName);
|
||||
return streamName;
|
||||
}
|
||||
}
|
||||
|
||||
void processCreateStreamSecondPhase(SRequestObj* pRequest){
|
||||
tscInfo("[create stream with histroy] create in second phase");
|
||||
char *streamName = getStreamName(pRequest);
|
||||
size_t sqlLen = strlen(pRequest->sqlstr);
|
||||
SRequestObj* pRequestNew = NULL;
|
||||
int32_t code = buildRequest(pRequest->pTscObj->id, pRequest->sqlstr, sqlLen, streamName, false, &pRequestNew, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tscError("[create stream with histroy] create in second phase, build request failed since %s", tstrerror(code));
|
||||
return;
|
||||
}
|
||||
pRequestNew->source = pRequest->source;
|
||||
pRequestNew->body.queryFp = processCreateStreamSecondPhaseRsp;
|
||||
pRequestNew->streamRunHistory = true;
|
||||
doAsyncQuery(pRequestNew, false);
|
||||
}
|
||||
|
||||
int32_t processCreateStreamFirstPhaseRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SRequestObj* pRequest = param;
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
setErrno(pRequest, code);
|
||||
}
|
||||
|
||||
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
|
||||
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0) {
|
||||
tscError("failed to remove meta data for table");
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
|
||||
if (code == 0 && !pRequest->streamRunHistory && tsStreamRunHistoryAsync){
|
||||
processCreateStreamSecondPhase(pRequest);
|
||||
}
|
||||
|
||||
if (pRequest->body.queryFp != NULL) {
|
||||
pRequest->body.queryFp(((SSyncQueryParam*)pRequest->body.interParam)->userParam, pRequest, code);
|
||||
} else {
|
||||
if (tsem_post(&pRequest->body.rspSem) != 0) {
|
||||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
__async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
||||
switch (msgType) {
|
||||
case TDMT_MND_CONNECT:
|
||||
|
@ -872,9 +987,12 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
|||
return processAlterStbRsp;
|
||||
case TDMT_MND_SHOW_VARIABLES:
|
||||
return processShowVariablesRsp;
|
||||
case TDMT_MND_CREATE_STREAM:
|
||||
return processCreateStreamFirstPhaseRsp;
|
||||
case TDMT_MND_COMPACT_DB:
|
||||
return processCompactDbRsp;
|
||||
default:
|
||||
return genericRspCallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
kvVal->f = (float)result;
|
||||
|
||||
#define SET_BIGINT \
|
||||
errno = 0; \
|
||||
SET_ERRNO(0); \
|
||||
int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \
|
||||
if (errno == ERANGE) { \
|
||||
if (ERRNO == ERANGE) { \
|
||||
smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \
|
||||
return false; \
|
||||
} \
|
||||
|
@ -63,9 +63,9 @@
|
|||
kvVal->i = result;
|
||||
|
||||
#define SET_UBIGINT \
|
||||
errno = 0; \
|
||||
SET_ERRNO(0); \
|
||||
uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \
|
||||
if (errno == ERANGE || result < 0) { \
|
||||
if (ERRNO == ERANGE || result < 0) { \
|
||||
smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \
|
||||
return false; \
|
||||
} \
|
||||
|
@ -1247,7 +1247,9 @@ void freeSSmlKv(void *data) {
|
|||
SSmlKv *kv = (SSmlKv *)data;
|
||||
if (kv->keyEscaped) taosMemoryFreeClear(kv->key);
|
||||
if (kv->valueEscaped) taosMemoryFreeClear(kv->value);
|
||||
#ifdef USE_GEOS
|
||||
if (kv->type == TSDB_DATA_TYPE_GEOMETRY) geosFreeBuffer((void *)(kv->value));
|
||||
#endif
|
||||
if (kv->type == TSDB_DATA_TYPE_VARBINARY) taosMemoryFreeClear(kv->value);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,13 +97,14 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
}
|
||||
|
||||
if (pVal->value[0] == 'g' || pVal->value[0] == 'G') { // geometry
|
||||
#ifdef USE_GEOS
|
||||
if (pVal->length >= NCHAR_ADD_LEN && pVal->value[1] == '"' && pVal->value[pVal->length - 1] == '"') {
|
||||
int32_t code = initCtxGeomFromText();
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
char* tmp = taosMemoryCalloc(pVal->length, 1);
|
||||
if (tmp == NULL){
|
||||
char *tmp = taosMemoryCalloc(pVal->length, 1);
|
||||
if (tmp == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(tmp, pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN);
|
||||
|
@ -115,12 +116,15 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
|
||||
pVal->type = TSDB_DATA_TYPE_GEOMETRY;
|
||||
if (pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
||||
geosFreeBuffer((void*)(pVal->value));
|
||||
geosFreeBuffer((void *)(pVal->value));
|
||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
#else
|
||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pVal->value[0] == 'b' || pVal->value[0] == 'B') { // varbinary
|
||||
|
|
|
@ -762,7 +762,7 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) {
|
|||
atomic_store_8((int8_t*)&pStmt->sql.siInfo.tableColsReady, true);
|
||||
} else {
|
||||
STMT_ERR_RET(qAppendStmtTableOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, &pParam->tblData, pStmt->exec.pCurrBlock,
|
||||
&pStmt->sql.siInfo));
|
||||
&pStmt->sql.siInfo, NULL));
|
||||
|
||||
// taosMemoryFree(pParam->pTbData);
|
||||
|
||||
|
@ -809,7 +809,7 @@ int32_t stmtStartBindThread(STscStmt* pStmt) {
|
|||
}
|
||||
|
||||
if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ static int32_t stmtGetTbName(TAOS_STMT2* stmt, char** tbName) {
|
|||
pStmt->sql.type = STMT_TYPE_MULTI_INSERT;
|
||||
|
||||
if ('\0' == pStmt->bInfo.tbName[0]) {
|
||||
tscError("no table name set");
|
||||
tscWarn("no table name set, OK if it is a stmt get fields");
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_TBNAME_ERROR);
|
||||
}
|
||||
|
||||
|
@ -240,9 +240,6 @@ static int32_t stmtUpdateInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void* ta
|
|||
STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash));
|
||||
|
||||
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
||||
if (pStmt->sql.autoCreateTbl) {
|
||||
pStmt->sql.stbInterlaceMode = false;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -294,18 +291,18 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
|
|||
}
|
||||
|
||||
STableDataCxt* pTableCtx = *pSrc;
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int16_t lastIdx = -1;
|
||||
// if (pStmt->sql.stbInterlaceMode) {
|
||||
// int16_t lastIdx = -1;
|
||||
|
||||
for (int32_t i = 0; i < pTableCtx->boundColsInfo.numOfBound; ++i) {
|
||||
if (pTableCtx->boundColsInfo.pColIndex[i] < lastIdx) {
|
||||
pStmt->sql.stbInterlaceMode = false;
|
||||
break;
|
||||
}
|
||||
// for (int32_t i = 0; i < pTableCtx->boundColsInfo.numOfBound; ++i) {
|
||||
// if (pTableCtx->boundColsInfo.pColIndex[i] < lastIdx) {
|
||||
// pStmt->sql.stbInterlaceMode = false;
|
||||
// break;
|
||||
// }
|
||||
|
||||
lastIdx = pTableCtx->boundColsInfo.pColIndex[i];
|
||||
}
|
||||
}
|
||||
// lastIdx = pTableCtx->boundColsInfo.pColIndex[i];
|
||||
// }
|
||||
// }
|
||||
|
||||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
|
||||
|
@ -319,7 +316,6 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
|
|||
|
||||
static int32_t stmtCleanBindInfo(STscStmt2* pStmt) {
|
||||
pStmt->bInfo.tbUid = 0;
|
||||
pStmt->bInfo.tbSuid = 0;
|
||||
pStmt->bInfo.tbVgId = -1;
|
||||
pStmt->bInfo.tbType = 0;
|
||||
pStmt->bInfo.needParse = true;
|
||||
|
@ -331,7 +327,10 @@ static int32_t stmtCleanBindInfo(STscStmt2* pStmt) {
|
|||
qDestroyBoundColInfo(pStmt->bInfo.boundTags);
|
||||
taosMemoryFreeClear(pStmt->bInfo.boundTags);
|
||||
}
|
||||
if (!pStmt->sql.autoCreateTbl) {
|
||||
pStmt->bInfo.stbFName[0] = 0;
|
||||
pStmt->bInfo.tbSuid = 0;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -439,6 +438,9 @@ static int32_t stmtCleanSQLInfo(STscStmt2* pStmt) {
|
|||
taosArrayDestroy(pStmt->sql.nodeList);
|
||||
taosHashCleanup(pStmt->sql.pVgHash);
|
||||
pStmt->sql.pVgHash = NULL;
|
||||
if (pStmt->sql.fixValueTags) {
|
||||
tdDestroySVCreateTbReq(pStmt->sql.fixValueTbReq);
|
||||
}
|
||||
|
||||
void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
|
||||
while (pIter) {
|
||||
|
@ -691,12 +693,11 @@ static int32_t stmtAsyncOutput(STscStmt2* pStmt, void* param) {
|
|||
|
||||
atomic_store_8((int8_t*)&pStmt->sql.siInfo.tableColsReady, true);
|
||||
} else {
|
||||
STMT_ERR_RET(qAppendStmtTableOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, &pParam->tblData, pStmt->exec.pCurrBlock,
|
||||
&pStmt->sql.siInfo));
|
||||
|
||||
int code = qAppendStmtTableOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, &pParam->tblData, pStmt->exec.pCurrBlock,
|
||||
&pStmt->sql.siInfo, pParam->pCreateTbReq);
|
||||
// taosMemoryFree(pParam->pTbData);
|
||||
|
||||
(void)atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||
STMT_ERR_RET(code);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -738,7 +739,7 @@ static int32_t stmtStartBindThread(STscStmt2* pStmt) {
|
|||
}
|
||||
|
||||
if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -852,7 +853,7 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
|
|||
pStmt->sql.siInfo.tableColsReady = true;
|
||||
if (pStmt->options.asyncExecFn) {
|
||||
if (tsem_init(&pStmt->asyncExecSem, 0, 1) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
(void)stmtClose2(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1019,7 +1020,7 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
||||
int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags, SVCreateTbReq** pCreateTbReq) {
|
||||
STscStmt2* pStmt = (STscStmt2*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to set tbTags");
|
||||
|
@ -1048,22 +1049,125 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
|||
// tscWarn("no tags or cols bound in sql, will not bound tags");
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
if (pStmt->sql.autoCreateTbl && pStmt->sql.stbInterlaceMode) {
|
||||
STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, pStmt->bInfo.tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb,
|
||||
pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
||||
STMT_ERR_RET(tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName));
|
||||
}
|
||||
|
||||
STableDataCxt** pDataBlock =
|
||||
STableDataCxt** pDataBlock = NULL;
|
||||
if (pStmt->exec.pCurrBlock) {
|
||||
pDataBlock = &pStmt->exec.pCurrBlock;
|
||||
} else {
|
||||
pDataBlock =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_CACHE_ERROR);
|
||||
}
|
||||
// pStmt->exec.pCurrBlock = *pDataBlock;
|
||||
// if (pStmt->sql.stbInterlaceMode) {
|
||||
// taosArrayDestroy(pStmt->exec.pCurrBlock->pData->aCol);
|
||||
// (*pDataBlock)->pData->aCol = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
if (pStmt->bInfo.inExecCache && !pStmt->sql.autoCreateTbl) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
tscDebug("start to bind stmt tag values");
|
||||
STMT_ERR_RET(qBindStmtTagsValue2(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName,
|
||||
|
||||
void* boundTags = NULL;
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
boundTags = pStmt->sql.siInfo.boundTags;
|
||||
*pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||
if (NULL == pCreateTbReq) {
|
||||
return terrno;
|
||||
}
|
||||
int32_t vgId = -1;
|
||||
STMT_ERR_RET(stmtTryAddTableVgroupInfo(pStmt, &vgId));
|
||||
(*pCreateTbReq)->uid = vgId;
|
||||
} else {
|
||||
boundTags = pStmt->bInfo.boundTags;
|
||||
}
|
||||
|
||||
STMT_ERR_RET(qBindStmtTagsValue2(*pDataBlock, boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName,
|
||||
pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt));
|
||||
pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt, *pCreateTbReq));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int stmtCheckTags2(TAOS_STMT2* stmt, SVCreateTbReq** pCreateTbReq) {
|
||||
STscStmt2* pStmt = (STscStmt2*)stmt;
|
||||
|
||||
STMT_DLOG_E("start to set tbTags");
|
||||
|
||||
if (pStmt->errCode != TSDB_CODE_SUCCESS) {
|
||||
return pStmt->errCode;
|
||||
}
|
||||
|
||||
if (!pStmt->sql.stbInterlaceMode) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
||||
|
||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
||||
pStmt->bInfo.needParse = false;
|
||||
}
|
||||
STMT_ERR_RET(stmtCreateRequest(pStmt));
|
||||
|
||||
if (pStmt->bInfo.needParse) {
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
if (!pStmt->sql.autoCreateTbl) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||
STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||
}
|
||||
|
||||
STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, pStmt->bInfo.tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb,
|
||||
pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
||||
STMT_ERR_RET(tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName));
|
||||
|
||||
STableDataCxt** pDataBlock = NULL;
|
||||
if (pStmt->exec.pCurrBlock) {
|
||||
pDataBlock = &pStmt->exec.pCurrBlock;
|
||||
} else {
|
||||
pDataBlock =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_CACHE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!((*pDataBlock)->pData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (pStmt->sql.fixValueTags) {
|
||||
STMT_ERR_RET(cloneSVreateTbReq(pStmt->sql.fixValueTbReq, pCreateTbReq));
|
||||
if ((*pCreateTbReq)->name) {
|
||||
taosMemoryFree((*pCreateTbReq)->name);
|
||||
}
|
||||
(*pCreateTbReq)->name = taosStrdup(pStmt->bInfo.tbName);
|
||||
int32_t vgId = -1;
|
||||
STMT_ERR_RET(stmtTryAddTableVgroupInfo(pStmt, &vgId));
|
||||
(*pCreateTbReq)->uid = vgId;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if ((*pDataBlock)->pData->pCreateTbReq) {
|
||||
pStmt->sql.fixValueTags = true;
|
||||
STMT_ERR_RET(cloneSVreateTbReq((*pDataBlock)->pData->pCreateTbReq, &pStmt->sql.fixValueTbReq));
|
||||
STMT_ERR_RET(cloneSVreateTbReq(pStmt->sql.fixValueTbReq, pCreateTbReq));
|
||||
(*pCreateTbReq)->uid = (*pDataBlock)->pMeta->vgId;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1110,22 +1214,27 @@ static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIEL
|
|||
}
|
||||
|
||||
STableDataCxt** pDataBlock = NULL;
|
||||
bool cleanStb = false;
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
if (pStmt->sql.stbInterlaceMode && pStmt->sql.siInfo.pDataCtx != NULL) {
|
||||
pDataBlock = &pStmt->sql.siInfo.pDataCtx;
|
||||
} else {
|
||||
cleanStb = true;
|
||||
pDataBlock =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
}
|
||||
|
||||
if (NULL == pDataBlock || NULL == *pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERRI_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
STMT_ERRI_JRET(qBuildStmtStbColFields(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.preCtbname, fieldNum, fields));
|
||||
if (pStmt->bInfo.tbType == TSDB_SUPER_TABLE) {
|
||||
STMT_ERRI_JRET(
|
||||
qBuildStmtStbColFields(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.preCtbname, fieldNum, fields));
|
||||
if (pStmt->bInfo.tbType == TSDB_SUPER_TABLE && cleanStb) {
|
||||
pStmt->bInfo.needParse = true;
|
||||
qDestroyStmtDataBlock(*pDataBlock);
|
||||
*pDataBlock = NULL;
|
||||
if (taosHashRemove(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)) != 0) {
|
||||
tscError("get fileds %s remove exec blockHash fail", pStmt->bInfo.tbFName);
|
||||
STMT_ERRI_JRET(TSDB_CODE_APP_ERROR);
|
||||
|
@ -1281,6 +1390,10 @@ static int stmtAddBatch2(TAOS_STMT2* stmt) {
|
|||
param->restoreTbCols = true;
|
||||
param->next = NULL;
|
||||
|
||||
if (pStmt->sql.autoCreateTbl) {
|
||||
pStmt->bInfo.tagsCached = true;
|
||||
}
|
||||
|
||||
stmtEnqueue(pStmt, param);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1334,7 +1447,7 @@ static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
*/
|
||||
int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
||||
int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx, SVCreateTbReq* pCreateTbReq) {
|
||||
STscStmt2* pStmt = (STscStmt2*)stmt;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -1443,6 +1556,8 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
|
||||
param->restoreTbCols = false;
|
||||
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
|
||||
param->pCreateTbReq = pCreateTbReq;
|
||||
}
|
||||
|
||||
int64_t startUs3 = taosGetTimestampUs();
|
||||
|
@ -1452,7 +1567,8 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
|
||||
if (colIdx < 0) {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
(*pDataBlock)->pData->flags = 0;
|
||||
// (*pDataBlock)->pData->flags = 0;
|
||||
(*pDataBlock)->pData->flags &= ~SUBMIT_REQ_COLUMN_DATA_FORMAT;
|
||||
code = qBindStmtStbColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen, &pStmt->sql.siInfo.pTSchema, pStmt->sql.pBindInfo,
|
||||
pStmt->taos->optionInfo.charsetCxt);
|
||||
|
|
|
@ -1346,13 +1346,13 @@ static void doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
|||
static int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
||||
if (pParam == NULL) {
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId);
|
||||
if (tmq == NULL) {
|
||||
code = TSDB_CODE_TMQ_CONSUMER_CLOSED;
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1408,7 +1408,7 @@ static int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
}
|
||||
|
||||
FAIL:
|
||||
_ERR:
|
||||
if (pParam && pParam->sync) {
|
||||
SAskEpInfo* pInfo = pParam->pParam;
|
||||
if (pInfo) {
|
||||
|
@ -1760,7 +1760,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
// init semaphore
|
||||
if (tsem2_init(&pTmq->rspSem, 0, 0) != 0) {
|
||||
tqErrorC("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId,
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)), pTmq->groupId);
|
||||
tstrerror(TAOS_SYSTEM_ERROR(ERRNO)), pTmq->groupId);
|
||||
SET_ERROR_MSG_TMQ("init t_sem failed")
|
||||
goto _failed;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ void checkError(TAOS_STMT2* stmt, int code) {
|
|||
if (pStmt == nullptr || pStmt->sql.sqlStr == nullptr || pStmt->exec.pRequest == nullptr) {
|
||||
printf("stmt api error\n stats : %d\n errstr : %s\n", pStmt->sql.status, taos_stmt_errstr(stmt));
|
||||
} else {
|
||||
printf("stmt api error\n sql : %s\n stats : %d\n errstr : %s\n", pStmt->sql.sqlStr, pStmt->sql.status,
|
||||
taos_stmt_errstr(stmt));
|
||||
printf("stmt api error\n sql : %s\n stats : %d\n", pStmt->sql.sqlStr, pStmt->sql.status);
|
||||
}
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -133,9 +132,9 @@ void do_query(TAOS* taos, const char* sql) {
|
|||
taos_free_result(result);
|
||||
}
|
||||
|
||||
void do_stmt(TAOS* taos, TAOS_STMT2_OPTION* option, const char* sql, int CTB_NUMS, int ROW_NUMS, int CYC_NUMS,
|
||||
bool hastags, bool createTable) {
|
||||
printf("test sql : %s\n", sql);
|
||||
void do_stmt(const char* msg, TAOS* taos, TAOS_STMT2_OPTION* option, const char* sql, int CTB_NUMS, int ROW_NUMS,
|
||||
int CYC_NUMS, bool hastags, bool createTable) {
|
||||
printf("stmt2 [%s] : %s\n", msg, sql);
|
||||
do_query(taos, "drop database if exists stmt2_testdb_1");
|
||||
do_query(taos, "create database IF NOT EXISTS stmt2_testdb_1");
|
||||
do_query(taos, "create stable stmt2_testdb_1.stb (ts timestamp, b binary(10)) tags(t1 int, t2 binary(10))");
|
||||
|
@ -903,14 +902,14 @@ TEST(stmt2Case, stmt2_stb_insert) {
|
|||
TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
||||
ASSERT_NE(taos, nullptr);
|
||||
// normal
|
||||
TAOS_STMT2_OPTION option = {0, true, true, NULL, NULL};
|
||||
TAOS_STMT2_OPTION option = {0, false, true, NULL, NULL};
|
||||
{
|
||||
do_stmt(taos, &option, "insert into `stmt2_testdb_1`.`stb` (tbname,ts,b,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true,
|
||||
true);
|
||||
do_stmt("no-interlcace", taos, &option, "insert into `stmt2_testdb_1`.`stb` (tbname,ts,b,t1,t2) values(?,?,?,?,?)",
|
||||
3, 3, 3, true, true);
|
||||
}
|
||||
{
|
||||
do_stmt(taos, &option, "insert into `stmt2_testdb_1`.? using `stmt2_testdb_1`.`stb` tags(?,?) values(?,?)", 3, 3, 3,
|
||||
true, true);
|
||||
do_stmt("no-interlcace", taos, &option,
|
||||
"insert into `stmt2_testdb_1`.? using `stmt2_testdb_1`.`stb` tags(?,?) values(?,?)", 3, 3, 3, true, true);
|
||||
}
|
||||
|
||||
// async
|
||||
|
@ -918,28 +917,61 @@ TEST(stmt2Case, stmt2_stb_insert) {
|
|||
aa->async_affected_rows = 0;
|
||||
ASSERT_EQ(tsem_init(&aa->sem, 0, 0), TSDB_CODE_SUCCESS);
|
||||
void* param = aa;
|
||||
option = {0, true, true, stmtAsyncQueryCb, param};
|
||||
option = {0, false, true, stmtAsyncQueryCb, param};
|
||||
{
|
||||
do_stmt(taos, &option, "insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, true);
|
||||
do_stmt("no-interlcace & aync exec", taos, &option,
|
||||
"insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, true);
|
||||
}
|
||||
{
|
||||
do_stmt(taos, &option, "insert into stmt2_testdb_1.? using stmt2_testdb_1.stb (t1,t2)tags(?,?) (ts,b)values(?,?)",
|
||||
3, 3, 3, true, true);
|
||||
do_stmt("no-interlcace & aync exec", taos, &option,
|
||||
"insert into stmt2_testdb_1.? using stmt2_testdb_1.stb (t1,t2)tags(?,?) (ts,b)values(?,?)", 3, 3, 3, true,
|
||||
true);
|
||||
}
|
||||
// { do_stmt(taos, &option, "insert into db.? values(?,?)", 3, 3, 3, false, true); }
|
||||
|
||||
// interlace = 0 & use db]
|
||||
do_query(taos, "use stmt2_testdb_1");
|
||||
option = {0, false, false, NULL, NULL};
|
||||
{ do_stmt(taos, &option, "insert into stb (tbname,ts,b) values(?,?,?)", 3, 3, 3, false, true); }
|
||||
{ do_stmt(taos, &option, "insert into ? using stb (t1,t2)tags(?,?) (ts,b)values(?,?)", 3, 3, 3, true, true); }
|
||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
{
|
||||
do_stmt("no-interlcace & no-db", taos, &option, "insert into stb (tbname,ts,b) values(?,?,?)", 3, 3, 3, false,
|
||||
true);
|
||||
}
|
||||
{
|
||||
do_stmt("no-interlcace & no-db", taos, &option, "insert into ? using stb (t1,t2)tags(?,?) (ts,b)values(?,?)", 3, 3,
|
||||
3, true, true);
|
||||
}
|
||||
{ do_stmt("no-interlcace & no-db", taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
|
||||
// interlace = 1
|
||||
option = {0, true, true, stmtAsyncQueryCb, param};
|
||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
{ do_stmt("interlcace & preCreateTB", taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
option = {0, true, true, NULL, NULL};
|
||||
{ do_stmt(taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
{ do_stmt("interlcace & preCreateTB", taos, &option, "insert into ? values(?,?)", 3, 3, 3, false, true); }
|
||||
|
||||
// auto create table
|
||||
// interlace = 1
|
||||
option = {0, true, true, NULL, NULL};
|
||||
{
|
||||
do_stmt("interlcace & no-preCreateTB", taos, &option, "insert into ? using stb (t1,t2)tags(?,?) (ts,b)values(?,?)",
|
||||
3, 3, 3, true, false);
|
||||
}
|
||||
{
|
||||
do_stmt("interlcace & no-preCreateTB", taos, &option,
|
||||
"insert into stmt2_testdb_1.? using stb (t1,t2)tags(1,'abc') (ts,b)values(?,?)", 3, 3, 3, false, false);
|
||||
}
|
||||
{
|
||||
do_stmt("interlcace & no-preCreateTB", taos, &option,
|
||||
"insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, false);
|
||||
}
|
||||
// interlace = 0
|
||||
option = {0, false, false, NULL, NULL};
|
||||
{
|
||||
do_stmt("no-interlcace & no-preCreateTB", taos, &option,
|
||||
"insert into ? using stb (t1,t2)tags(?,?) (ts,b)values(?,?)", 3, 3, 3, true, false);
|
||||
}
|
||||
{
|
||||
do_stmt("no-interlcace & no-preCreateTB", taos, &option,
|
||||
"insert into stmt2_testdb_1.stb (ts,b,tbname,t1,t2) values(?,?,?,?,?)", 3, 3, 3, true, false);
|
||||
}
|
||||
|
||||
do_query(taos, "drop database if exists stmt2_testdb_1");
|
||||
(void)tsem_destroy(&aa->sem);
|
||||
|
@ -967,6 +999,7 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||
ASSERT_NE(stmt, nullptr);
|
||||
const char* sql = "INSERT INTO stmt2_testdb_6.? using stmt2_testdb_6.stb1 (int_tag)tags(1) (ts) VALUES (?)";
|
||||
printf("stmt2 [%s] : %s\n", "less params", sql);
|
||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
checkError(stmt, code);
|
||||
int total_affect_rows = 0;
|
||||
|
@ -987,7 +1020,7 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
TAOS_STMT2_BIND* tagv[2] = {&tags1, &tags2};
|
||||
TAOS_STMT2_BIND* paramv[2] = {¶ms1, ¶ms2};
|
||||
char* tbname[2] = {"tb1", "tb2"};
|
||||
TAOS_STMT2_BINDV bindv = {2, &tbname[0], NULL, ¶mv[0]};
|
||||
TAOS_STMT2_BINDV bindv = {2, &tbname[0], tagv, ¶mv[0]};
|
||||
code = taos_stmt2_bind_param(stmt, &bindv, -1);
|
||||
checkError(stmt, code);
|
||||
|
||||
|
@ -1005,8 +1038,10 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
// less cols and tags
|
||||
{
|
||||
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||
TAOS_STMT2_OPTION option = {0, false, false, NULL, NULL};
|
||||
ASSERT_NE(stmt, nullptr);
|
||||
const char* sql = "INSERT INTO stmt2_testdb_6.stb1 (ts,int_tag,tbname) VALUES (?,?,?)";
|
||||
printf("stmt2 [%s] : %s\n", "less params", sql);
|
||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
checkError(stmt, code);
|
||||
int total_affect_rows = 0;
|
||||
|
@ -1026,7 +1061,7 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
|
||||
TAOS_STMT2_BIND* tagv[2] = {&tags1, &tags2};
|
||||
TAOS_STMT2_BIND* paramv[2] = {¶ms1, ¶ms2};
|
||||
char* tbname[2] = {"tb3", "tb4"};
|
||||
char* tbname[2] = {"tb1", "tb2"};
|
||||
TAOS_STMT2_BINDV bindv = {2, &tbname[0], &tagv[0], ¶mv[0]};
|
||||
code = taos_stmt2_bind_param(stmt, &bindv, -1);
|
||||
checkError(stmt, code);
|
||||
|
@ -1044,9 +1079,14 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
|
||||
// disorder cols and tags
|
||||
{
|
||||
TAOS_STMT2_OPTION option = {0, false, false, NULL, NULL};
|
||||
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||
ASSERT_NE(stmt, nullptr);
|
||||
do_query(taos,
|
||||
"INSERT INTO stmt2_testdb_6.stb1 (ts, int_tag, tbname) VALUES (1591060627000, 5, 'tb5')(1591060627000, "
|
||||
"6,'tb6')");
|
||||
const char* sql = "INSERT INTO stmt2_testdb_6.stb1 (binary_tag,int_col,tbname,ts,int_tag) VALUES (?,?,?,?,?)";
|
||||
printf("stmt2 [%s] : %s\n", "disorder params", sql);
|
||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
checkError(stmt, code);
|
||||
|
||||
|
@ -1096,6 +1136,7 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
ASSERT_NE(stmt, nullptr);
|
||||
const char* sql =
|
||||
"INSERT INTO stmt2_testdb_6.? using stmt2_testdb_6.stb1 (int_tag)tags(1) (int_col,ts)VALUES (?,?)";
|
||||
printf("stmt2 [%s] : %s\n", "PK error", sql);
|
||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
checkError(stmt, code);
|
||||
|
||||
|
@ -1131,11 +1172,10 @@ TEST(stmt2Case, stmt2_insert_db) {
|
|||
ASSERT_NE(taos, nullptr);
|
||||
do_query(taos, "drop database if exists stmt2_testdb_12");
|
||||
do_query(taos, "create database IF NOT EXISTS stmt2_testdb_12");
|
||||
do_query(taos, "create stable `stmt2_testdb_12`.`stb1`(ts timestamp, int_col int) tags(int_tag int)");
|
||||
do_query(taos,
|
||||
"create stable `stmt2_testdb_12`.`stb1` (ts timestamp, int_col int,long_col bigint,double_col "
|
||||
"double,bool_col bool,binary_col binary(20),nchar_col nchar(20),varbinary_col varbinary(20),geometry_col "
|
||||
"geometry(200)) tags(int_tag int,long_tag bigint,double_tag double,bool_tag bool,binary_tag "
|
||||
"binary(20),nchar_tag nchar(20),varbinary_tag varbinary(20),geometry_tag geometry(200));");
|
||||
"INSERT INTO `stmt2_testdb_12`.`stb1` (ts,int_tag,tbname) VALUES "
|
||||
"(1591060627000,1,'tb1')(1591060627000,2,'tb2')");
|
||||
|
||||
TAOS_STMT2_OPTION option = {0, false, false, NULL, NULL};
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ static int32_t cos_cp_save_json(cJSON const* json, SCheckpoint* checkpoint) {
|
|||
}
|
||||
|
||||
if (taosFsyncFile(fp) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(ERRNO), &lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
|
|
@ -11866,6 +11866,7 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm
|
|||
// auto create table
|
||||
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||
if (!(pSubmitTbData->pCreateTbReq)) {
|
||||
uError("auto create table but request is NULL");
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
TAOS_CHECK_EXIT(tEncodeSVCreateTbReq(pCoder, pSubmitTbData->pCreateTbReq));
|
||||
|
@ -12005,7 +12006,7 @@ int32_t tEncodeSubmitReq(SEncoder *pCoder, const SSubmitReq2 *pReq) {
|
|||
for (uint64_t i = 0; i < taosArrayGetSize(pReq->aSubmitTbData); i++) {
|
||||
SSubmitTbData *pSubmitTbData = taosArrayGet(pReq->aSubmitTbData, i);
|
||||
if ((pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) && pSubmitTbData->pCreateTbReq == NULL) {
|
||||
pSubmitTbData->flags = 0;
|
||||
pSubmitTbData->flags &= ~SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||
}
|
||||
TAOS_CHECK_EXIT(tEncodeSSubmitTbData(pCoder, pSubmitTbData));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "tglobal.h"
|
||||
|
||||
#define ERRNO_ERR_FORMAT "errno:%d,msg:%s"
|
||||
#define ERRNO_ERR_DATA errno, strerror(errno)
|
||||
#define ERRNO_ERR_DATA ERRNO, strerror(ERRNO)
|
||||
|
||||
// deleteRsync function produce empty directories, traverse base directory to remove them
|
||||
static void removeEmptyDir() {
|
||||
|
@ -150,7 +150,7 @@ int32_t startRsync() {
|
|||
if (taosMulMkDir(tsCheckpointBackupDir) != 0) {
|
||||
uError("[rsync] build checkpoint backup dir failed, path:%s," ERRNO_ERR_FORMAT, tsCheckpointBackupDir,
|
||||
ERRNO_ERR_DATA);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -170,10 +170,10 @@ int32_t startRsync() {
|
|||
code = system(cmd);
|
||||
if (code != 0) {
|
||||
uError("[rsync] cmd:%s start server failed, code:%d," ERRNO_ERR_FORMAT, cmd, code, ERRNO_ERR_DATA);
|
||||
if (errno == 0) {
|
||||
if (ERRNO == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
}
|
||||
} else {
|
||||
uInfo("[rsync] cmd:%s start server successful", cmd);
|
||||
|
@ -223,7 +223,7 @@ int32_t uploadByRsync(const char* id, const char* path, int64_t checkpointId) {
|
|||
if (code != 0) {
|
||||
uError("[rsync] s-task:%s prepare checkpoint dir in %s to %s failed, code:%d," ERRNO_ERR_FORMAT, id, path,
|
||||
tsSnodeAddress, code, ERRNO_ERR_DATA);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
} else {
|
||||
int64_t el = (taosGetTimestampMs() - st);
|
||||
uDebug("[rsync] s-task:%s prepare checkpoint dir in:%s to %s successfully, elapsed time:%" PRId64 "ms", id, path,
|
||||
|
@ -267,7 +267,7 @@ int32_t uploadByRsync(const char* id, const char* path, int64_t checkpointId) {
|
|||
if (code != 0) {
|
||||
uError("[rsync] s-task:%s upload checkpoint data in %s to %s failed, code:%d," ERRNO_ERR_FORMAT, id, path,
|
||||
tsSnodeAddress, code, ERRNO_ERR_DATA);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
} else {
|
||||
int64_t el = (taosGetTimestampMs() - st);
|
||||
uDebug("[rsync] s-task:%s upload checkpoint data in:%s to %s successfully, elapsed time:%" PRId64 "ms", id, path,
|
||||
|
@ -355,7 +355,7 @@ int32_t deleteRsync(const char* id) {
|
|||
int32_t code = taosMkDir(tmp);
|
||||
if (code != 0) {
|
||||
uError("[rsync] make tmp dir failed. code:%d," ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return TAOS_SYSTEM_ERROR(ERRNO);
|
||||
}
|
||||
|
||||
char command[PATH_MAX] = {0};
|
||||
|
@ -367,7 +367,7 @@ int32_t deleteRsync(const char* id) {
|
|||
taosRemoveDir(tmp);
|
||||
if (code != 0) {
|
||||
uError("[rsync] get failed code:%d," ERRNO_ERR_FORMAT, code, ERRNO_ERR_DATA);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return TAOS_SYSTEM_ERROR(ERRNO);
|
||||
}
|
||||
|
||||
uDebug("[rsync] delete data:%s successful", id);
|
||||
|
|
|
@ -182,6 +182,7 @@ static const SSysDbTableSchema streamSchema[] = {
|
|||
{.name = "checkpoint_interval", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "checkpoint_backup", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "history_scan_idle", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "message", .bytes = TSDB_RESERVE_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema streamTaskSchema[] = {
|
||||
|
|
|
@ -1472,7 +1472,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
|||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, 0);
|
||||
SBlockOrderInfo* pOrder = taosArrayGet(pOrderInfo, 0);
|
||||
if (pColInfoData == NULL || pOrder == NULL) {
|
||||
return errno;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int64_t p0 = taosGetTimestampUs();
|
||||
|
@ -1861,14 +1861,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
|
|||
// window start ts
|
||||
void* px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// window end ts
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1878,14 +1878,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
|
|||
// uid
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// group id
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1895,14 +1895,14 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
|
|||
// calculate start ts
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// calculate end ts
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1911,7 +1911,7 @@ int32_t createSpecialDataBlock(EStreamType type, SSDataBlock** pBlock) {
|
|||
infoData.info.bytes = VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN;
|
||||
px = taosArrayPush(p->pDataBlock, &infoData);
|
||||
if (px == NULL) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -3260,7 +3260,11 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, size_t dataBuflen, in
|
|||
data += sizeof(bool);
|
||||
|
||||
*actualLen = dataLen;
|
||||
#ifndef NO_UNALIGNED_ACCESS
|
||||
*groupId = pBlock->info.id.groupId;
|
||||
#else
|
||||
taosSetPUInt64Aligned(groupId, &pBlock->info.id.groupId);
|
||||
#endif
|
||||
if (dataLen > dataBuflen) goto _exit;
|
||||
|
||||
return dataLen;
|
||||
|
@ -3300,7 +3304,11 @@ int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos
|
|||
pStart += sizeof(int32_t);
|
||||
|
||||
// group id sizeof(uint64_t)
|
||||
#ifndef NO_UNALIGNED_ACCESS
|
||||
pBlock->info.id.groupId = *(uint64_t*)pStart;
|
||||
#else
|
||||
taosSetPUInt64Aligned(&pBlock->info.id.groupId, (uint64_t*)pStart);
|
||||
#endif
|
||||
pStart += sizeof(uint64_t);
|
||||
|
||||
if (pBlock->pDataBlock == NULL) {
|
||||
|
|
|
@ -1372,7 +1372,7 @@ int32_t tValueCompare(const SValue *tv1, const SValue *tv2) {
|
|||
return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0));
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
int32_t ret = tasoUcs4Compare((TdUcs4 *)tv1->pData, (TdUcs4 *)tv2->pData,
|
||||
int32_t ret = taosUcs4Compare((TdUcs4 *)tv1->pData, (TdUcs4 *)tv2->pData,
|
||||
tv1->nData < tv2->nData ? tv1->nData : tv2->nData);
|
||||
return ret ? ret : (tv1->nData < tv2->nData ? -1 : (tv1->nData > tv2->nData ? 1 : 0));
|
||||
}
|
||||
|
|
|
@ -62,7 +62,11 @@ int32_t tsShellActivityTimer = 3; // second
|
|||
|
||||
// memory pool
|
||||
int8_t tsMemPoolFullFunc = 0;
|
||||
#ifndef TD_ASTRA
|
||||
int8_t tsQueryUseMemoryPool = 1;
|
||||
#else
|
||||
int8_t tsQueryUseMemoryPool = 0;
|
||||
#endif
|
||||
int32_t tsQueryBufferPoolSize = 0; // MB
|
||||
int32_t tsSingleQueryMaxMemorySize = 0; // MB
|
||||
int32_t tsMinReservedMemorySize = 0; // MB
|
||||
|
@ -133,23 +137,38 @@ int8_t tsGrant = 1;
|
|||
bool tsCompareAsStrInGreatest = true;
|
||||
|
||||
// monitor
|
||||
#ifdef USE_MONITOR
|
||||
bool tsEnableMonitor = true;
|
||||
#else
|
||||
bool tsEnableMonitor = false;
|
||||
#endif
|
||||
int32_t tsMonitorInterval = 30;
|
||||
char tsMonitorFqdn[TSDB_FQDN_LEN] = {0};
|
||||
uint16_t tsMonitorPort = 6043;
|
||||
int32_t tsMonitorMaxLogs = 100;
|
||||
bool tsMonitorComp = false;
|
||||
bool tsMonitorLogProtocol = false;
|
||||
#ifdef USE_MONITOR
|
||||
bool tsMonitorForceV2 = true;
|
||||
#else
|
||||
bool tsMonitorForceV2 = false;
|
||||
#endif
|
||||
|
||||
// audit
|
||||
#ifdef USE_AUDIT
|
||||
bool tsEnableAudit = true;
|
||||
bool tsEnableAuditCreateTable = true;
|
||||
bool tsEnableAuditDelete = true;
|
||||
int32_t tsAuditInterval = 5000;
|
||||
#else
|
||||
bool tsEnableAudit = false;
|
||||
bool tsEnableAuditCreateTable = false;
|
||||
bool tsEnableAuditDelete = false;
|
||||
int32_t tsAuditInterval = 200000;
|
||||
#endif
|
||||
|
||||
// telem
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || !defined(USE_REPORT)
|
||||
bool tsEnableTelem = false;
|
||||
#else
|
||||
bool tsEnableTelem = true;
|
||||
|
@ -159,7 +178,7 @@ char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.tdengine.com";
|
|||
uint16_t tsTelemPort = 80;
|
||||
char *tsTelemUri = "/report";
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || !defined(USE_REPORT)
|
||||
bool tsEnableCrashReport = false;
|
||||
#else
|
||||
bool tsEnableCrashReport = true;
|
||||
|
@ -288,7 +307,7 @@ bool tsIfAdtFse = false; // ADT-FSE algorithom or origina
|
|||
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
||||
|
||||
// udf
|
||||
#ifdef WINDOWS
|
||||
#if defined(WINDOWS) || !defined(USE_UDF)
|
||||
bool tsStartUdfd = false;
|
||||
#else
|
||||
bool tsStartUdfd = true;
|
||||
|
@ -322,11 +341,17 @@ int32_t tsGrantHBInterval = 60;
|
|||
int32_t tsUptimeInterval = 300; // seconds
|
||||
char tsUdfdResFuncs[512] = ""; // taosudf resident funcs that teardown when taosudf exits
|
||||
char tsUdfdLdLibPath[512] = "";
|
||||
#ifdef USE_STREAM
|
||||
bool tsDisableStream = false;
|
||||
#else
|
||||
bool tsDisableStream = true;
|
||||
#endif
|
||||
int64_t tsStreamBufferSize = 128 * 1024 * 1024;
|
||||
int64_t tsStreamFailedTimeout = 30 * 60 * 1000;
|
||||
bool tsFilterScalarMode = false;
|
||||
int tsStreamAggCnt = 100000;
|
||||
bool tsStreamCoverage = false;
|
||||
bool tsStreamRunHistoryAsync = false;
|
||||
|
||||
bool tsUpdateCacheBatch = true;
|
||||
|
||||
|
@ -382,7 +407,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
|||
tsDiskCfg[0].disable = 0;
|
||||
tstrncpy(tsDataDir, pItem->str, PATH_MAX);
|
||||
if (taosMulMkDir(tsDataDir) != 0) {
|
||||
int32_t code = TAOS_SYSTEM_ERROR(errno);
|
||||
int32_t code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
uError("failed to create dataDir:%s, since:%s", tsDataDir, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -751,6 +776,9 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "compareAsStrInGreatest", tsCompareAsStrInGreatest, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT,CFG_CATEGORY_LOCAL));
|
||||
|
||||
TAOS_CHECK_RETURN(
|
||||
cfgAddBool(pCfg, "streamRunHistoryAsync", tsStreamRunHistoryAsync, CFG_DYN_CLIENT, CFG_DYN_CLIENT, CFG_CATEGORY_LOCAL));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -941,6 +969,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "disableStream", tsDisableStream, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "streamBufferSize", tsStreamBufferSize, 0, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "streamFailedTimeout", tsStreamFailedTimeout, 0, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_GLOBAL));
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "streamAggCnt", tsStreamAggCnt, 2, INT32_MAX, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL));
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "checkpointInterval", tsStreamCheckpointInterval, 60, 1800, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_GLOBAL));
|
||||
|
@ -1358,7 +1387,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minimalTmpDirGB");
|
||||
tsTempSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024);
|
||||
if (taosMulMkDir(tsTempDir) != 0) {
|
||||
int32_t code = TAOS_SYSTEM_ERROR(errno);
|
||||
int32_t code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
uError("failed to create tempDir:%s since %s", tsTempDir, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -1484,6 +1513,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamCoverage");
|
||||
tsStreamCoverage = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamRunHistoryAsync");
|
||||
tsStreamRunHistoryAsync = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "compareAsStrInGreatest");
|
||||
tsCompareAsStrInGreatest = pItem->bval;
|
||||
|
||||
|
@ -1615,6 +1647,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_RETURN(taosSetSlowLogScope(pItem->str, &scope));
|
||||
tsSlowLogScope = scope;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRspPolicy");
|
||||
tsQueryRspPolicy = pItem->i32;
|
||||
#ifdef USE_MONITOR
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitor");
|
||||
tsEnableMonitor = pItem->bval;
|
||||
|
||||
|
@ -1634,15 +1669,13 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorComp");
|
||||
tsMonitorComp = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRspPolicy");
|
||||
tsQueryRspPolicy = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorLogProtocol");
|
||||
tsMonitorLogProtocol = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorForceV2");
|
||||
tsMonitorForceV2 = pItem->i32;
|
||||
|
||||
#endif
|
||||
#ifdef USE_AUDIT
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "audit");
|
||||
tsEnableAudit = pItem->bval;
|
||||
|
||||
|
@ -1654,29 +1687,31 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "auditInterval");
|
||||
tsAuditInterval = pItem->i32;
|
||||
|
||||
#endif
|
||||
#ifdef USE_REPORT
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryReporting");
|
||||
tsEnableTelem = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "crashReporting");
|
||||
tsEnableCrashReport = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryInterval");
|
||||
tsTelemInterval = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryServer");
|
||||
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
|
||||
tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN);
|
||||
#endif
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlChangeOnWrite");
|
||||
tsTtlChangeOnWrite = pItem->bval;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlFlushThreshold");
|
||||
tsTtlFlushThreshold = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryInterval");
|
||||
tsTelemInterval = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rsyncPort");
|
||||
tsRsyncPort = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryServer");
|
||||
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
|
||||
tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN);
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "snodeAddress");
|
||||
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
|
||||
tstrncpy(tsSnodeAddress, pItem->str, TSDB_FQDN_LEN);
|
||||
|
@ -1768,7 +1803,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableWhiteList");
|
||||
tsEnableWhiteList = pItem->bval;
|
||||
|
||||
#ifdef USE_UDF
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udf");
|
||||
tsStartUdfd = pItem->bval;
|
||||
|
||||
|
@ -1782,7 +1817,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
if (tsQueryBufferSize >= 0) {
|
||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||
}
|
||||
|
||||
#endif
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "cacheLazyLoadThreshold");
|
||||
tsCacheLazyLoadThreshold = pItem->i32;
|
||||
|
||||
|
@ -1811,6 +1846,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamBufferSize");
|
||||
tsStreamBufferSize = pItem->i64;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamFailedTimeout");
|
||||
tsStreamFailedTimeout = pItem->i64;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamAggCnt");
|
||||
tsStreamAggCnt = pItem->i32;
|
||||
|
||||
|
@ -1834,7 +1872,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minDiskFreeSize");
|
||||
tsMinDiskFreeSize = pItem->i64;
|
||||
|
||||
#ifdef USE_S3
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3MigrateIntervalSec");
|
||||
tsS3MigrateIntervalSec = pItem->i32;
|
||||
|
||||
|
@ -1846,7 +1884,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3UploadDelaySec");
|
||||
tsS3UploadDelaySec = pItem->i32;
|
||||
|
||||
#endif
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental");
|
||||
tsExperimental = pItem->bval;
|
||||
|
||||
|
@ -1883,24 +1921,31 @@ int32_t taosSetReleaseCfg(SConfig *pCfg);
|
|||
|
||||
static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag);
|
||||
|
||||
static int8_t tsLogCreated = 0;
|
||||
|
||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
int32_t mode = tsc ? LOG_MODE_TAOSC : LOG_MODE_TAOSD;
|
||||
SConfig *pCfg = NULL;
|
||||
|
||||
if (atomic_val_compare_exchange_8(&tsLogCreated, 0, 1) != 0) return 0;
|
||||
|
||||
if (tsCfg == NULL) {
|
||||
TAOS_CHECK_GOTO(osDefaultInit(), &lino, _exit);
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(cfgInit(&pCfg), &lino, _exit);
|
||||
|
||||
if (tsc) {
|
||||
tsLogEmbedded = 0;
|
||||
TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit);
|
||||
} else {
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
mode |= LOG_MODE_TAOSD;
|
||||
tsLogEmbedded = 1;
|
||||
#else
|
||||
tsLogEmbedded = (mode & LOG_MODE_TAOSC) ? 0 : 1;
|
||||
#endif
|
||||
TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit);
|
||||
if (mode & LOG_MODE_TAOSD) {
|
||||
TAOS_CHECK_GOTO(taosAddServerLogCfg(pCfg), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -1914,10 +1959,8 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
if (tsc) {
|
||||
TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit);
|
||||
} else {
|
||||
TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit);
|
||||
if (mode & LOG_MODE_TAOSD) {
|
||||
TAOS_CHECK_GOTO(taosSetServerLogCfg(pCfg), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -1930,7 +1973,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
if ((code = taosInitLog(logname, logFileNum, tsc)) != 0) {
|
||||
if ((code = taosInitLog(logname, logFileNum, mode)) != 0) {
|
||||
(void)printf("failed to init log file since %s\n", tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -2163,6 +2206,10 @@ int32_t readCfgFile(const char *path, bool isGlobal) {
|
|||
uError("failed to stat file:%s , since %s", filename, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (fileSize == 0) {
|
||||
uInfo("config file:%s is empty", filename);
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
TdFilePtr pFile = taosOpenFile(filename, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = terrno;
|
||||
|
@ -2309,7 +2356,7 @@ static int32_t taosCfgSetOption(OptionNameAndVar *pOptions, int32_t optionSize,
|
|||
char *name = pItem->name;
|
||||
for (int32_t d = 0; d < optionSize; ++d) {
|
||||
const char *optName = pOptions[d].optionName;
|
||||
if (strcasecmp(name, optName) != 0) continue;
|
||||
if (taosStrcasecmp(name, optName) != 0) continue;
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
switch (pItem->dtype) {
|
||||
case CFG_DTYPE_BOOL: {
|
||||
|
@ -2742,7 +2789,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
|||
tstrncpy(tsTempDir, pItem->str, PATH_MAX);
|
||||
TAOS_CHECK_GOTO(taosExpandDir(tsTempDir, tsTempDir, PATH_MAX), &lino, _out);
|
||||
if (taosMulMkDir(tsTempDir) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
uError("failed to create tempDir:%s since %s", tsTempDir, tstrerror(code));
|
||||
goto _out;
|
||||
}
|
||||
|
@ -2790,6 +2837,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) {
|
|||
{"numOfRpcSessions", &tsNumOfRpcSessions},
|
||||
{"bypassFlag", &tsBypassFlag},
|
||||
{"safetyCheckLevel", &tsSafetyCheckLevel},
|
||||
{"streamRunHistoryAsync", &tsStreamRunHistoryAsync},
|
||||
{"streamCoverage", &tsStreamCoverage},
|
||||
{"compareAsStrInGreatest", &tsCompareAsStrInGreatest}};
|
||||
|
||||
|
@ -2828,7 +2876,7 @@ int32_t taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVa
|
|||
static int taosLogVarComp(void const *lp, void const *rp) {
|
||||
SLogVar *lpVar = (SLogVar *)lp;
|
||||
SLogVar *rpVar = (SLogVar *)rp;
|
||||
return strcasecmp(lpVar->name, rpVar->name);
|
||||
return taosStrcasecmp(lpVar->name, rpVar->name);
|
||||
}
|
||||
|
||||
static void taosCheckAndSetDebugFlag(int32_t *pFlagPtr, char *name, int32_t flag, SArray *noNeedToSetVars) {
|
||||
|
@ -3063,7 +3111,7 @@ int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version
|
|||
taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
|
||||
if (pConfigFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
uError("failed to open file:%s since %s", filename, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -3072,7 +3120,7 @@ int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version
|
|||
|
||||
if (taosWriteFile(pConfigFile, serialized, strlen(serialized)) < 0) {
|
||||
lino = __LINE__;
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
uError("failed to write file:%s since %s", filename, tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ static int compareKv(const void* p1, const void* p2) {
|
|||
SSmlKv* kv2 = (SSmlKv*)p2;
|
||||
int32_t kvLen1 = kv1->keyLen;
|
||||
int32_t kvLen2 = kv2->keyLen;
|
||||
int32_t res = strncasecmp(kv1->key, kv2->key, TMIN(kvLen1, kvLen2));
|
||||
int32_t res = taosStrncasecmp(kv1->key, kv2->key, TMIN(kvLen1, kvLen2));
|
||||
if (res != 0) {
|
||||
return res;
|
||||
} else {
|
||||
|
|
|
@ -234,13 +234,13 @@ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, ch
|
|||
}
|
||||
|
||||
/* mktime will be affected by TZ, set by using taos_options */
|
||||
#ifdef WINDOWS
|
||||
#if defined(WINDOWS) || defined(TD_ASTRA)
|
||||
int64_t seconds = user_mktime64(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
|
||||
// int64_t seconds = gmtime(&tm);
|
||||
#else
|
||||
int64_t seconds = taosTimeGm(&tm);
|
||||
if (seconds == -1){
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -591,13 +591,13 @@ int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecisi
|
|||
*/
|
||||
int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* duration, char* unit,
|
||||
int32_t timePrecision) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char* endPtr = NULL;
|
||||
|
||||
/* get the basic numeric value */
|
||||
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||
if ((timestamp == 0 && token[0] != '0') || errno != 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
if ((timestamp == 0 && token[0] != '0') || ERRNO != 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
|
||||
}
|
||||
|
||||
/* natual month/year are not allowed in absolute duration */
|
||||
|
@ -611,12 +611,12 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
|
|||
|
||||
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit, int32_t timePrecision,
|
||||
bool negativeAllow) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
|
||||
/* get the basic numeric value */
|
||||
*duration = taosStr2Int64(token, NULL, 10);
|
||||
if ((*duration < 0 && !negativeAllow) || errno != 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
if ((*duration < 0 && !negativeAllow) || ERRNO != 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
|
||||
}
|
||||
|
||||
*unit = token[tokenLen - 1];
|
||||
|
@ -648,7 +648,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision, t
|
|||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
if(taosLocalTime(&tt, &tm, NULL, 0, tz) == NULL) {
|
||||
uError("failed to convert time to gm time, code:%d", errno);
|
||||
uError("failed to convert time to gm time, code:%d", ERRNO);
|
||||
return t;
|
||||
}
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||
|
@ -664,7 +664,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision, t
|
|||
|
||||
tt = taosMktime(&tm, tz);
|
||||
if (tt == -1){
|
||||
uError("failed to convert gm time to time, code:%d", errno);
|
||||
uError("failed to convert gm time to time, code:%d", ERRNO);
|
||||
return t;
|
||||
}
|
||||
return (int64_t)(tt * TSDB_TICK_PER_SECOND(precision) + fraction);
|
||||
|
@ -718,14 +718,14 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
|
|||
struct tm tm;
|
||||
time_t t = (time_t)skey;
|
||||
if (taosLocalTime(&t, &tm, NULL, 0, NULL) == NULL) {
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
|
||||
return ret;
|
||||
}
|
||||
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
||||
t = (time_t)ekey;
|
||||
if (taosLocalTime(&t, &tm, NULL, 0, NULL) == NULL) {
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
|
||||
return ret;
|
||||
}
|
||||
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
@ -752,7 +752,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
struct tm tm;
|
||||
time_t tt = (time_t)start;
|
||||
if (taosLocalTime(&tt, &tm, NULL, 0, pInterval->timezone) == NULL){
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to convert time to local time, code:%d", __FUNCTION__, ERRNO);
|
||||
return ts;
|
||||
}
|
||||
tm.tm_sec = 0;
|
||||
|
@ -772,7 +772,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
|
||||
tt = taosMktime(&tm, pInterval->timezone);
|
||||
if (tt == -1){
|
||||
uError("%s failed to convert local time to time, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to convert local time to time, code:%d", __FUNCTION__, ERRNO);
|
||||
return ts;
|
||||
}
|
||||
start = (int64_t)(tt * TSDB_TICK_PER_SECOND(precision));
|
||||
|
@ -990,7 +990,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
|
|||
}
|
||||
|
||||
if (NULL == taosLocalTime(", &ptm, buf, bufLen, NULL)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
|
||||
}
|
||||
int32_t length = (int32_t)taosStrfTime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
||||
length += tsnprintf(ts + length, fractionLen, format, mod);
|
||||
|
@ -1032,7 +1032,7 @@ int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm, timezone_t tz)
|
|||
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
|
||||
time_t t = ts / TICK_PER_SECOND[precision];
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0, tz)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(ERRNO));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1508,6 +1508,8 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int
|
|||
case TSFKW_TZH:{
|
||||
#ifdef WINDOWS
|
||||
int32_t gmtoff = -_timezone;
|
||||
#elif defined(TD_ASTRA)
|
||||
int32_t gmtoff = -timezone;
|
||||
#else
|
||||
int32_t gmtoff = tm->tm.tm_gmtoff;
|
||||
#endif
|
||||
|
@ -1594,7 +1596,7 @@ static const char* tsFormatStr2Int32(int32_t* dest, const char* str, int32_t len
|
|||
// no integers found
|
||||
return NULL;
|
||||
}
|
||||
if (errno == ERANGE || res > INT32_MAX || res < INT32_MIN) {
|
||||
if (ERRNO == ERANGE || res > INT32_MAX || res < INT32_MIN) {
|
||||
// out of range
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1937,6 +1939,8 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec
|
|||
if (tzHour != 0) {
|
||||
#ifdef WINDOWS
|
||||
int32_t gmtoff = -_timezone;
|
||||
#elif defined(TD_ASTRA)
|
||||
int32_t gmtoff = -timezone;
|
||||
#else
|
||||
int32_t gmtoff = tm.tm.tm_gmtoff;
|
||||
#endif
|
||||
|
@ -2136,7 +2140,7 @@ int64_t taosGetTimestampToday(int32_t precision, timezone_t tz) {
|
|||
}
|
||||
struct tm tm;
|
||||
if (taosLocalTime(&t, &tm, NULL, 0, tz) == NULL){
|
||||
uError("%s failed to get local time, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to get local time, code:%d", __FUNCTION__, ERRNO);
|
||||
return t;
|
||||
}
|
||||
tm.tm_hour = 0;
|
||||
|
@ -2145,7 +2149,7 @@ int64_t taosGetTimestampToday(int32_t precision, timezone_t tz) {
|
|||
|
||||
time_t tmp = taosMktime(&tm, tz);
|
||||
if (tmp == (time_t)-1) {
|
||||
uError("%s failed to get timestamp of today, code:%d", __FUNCTION__, errno);
|
||||
uError("%s failed to get timestamp of today, code:%d", __FUNCTION__, ERRNO);
|
||||
return t;
|
||||
}
|
||||
return (int64_t)tmp * factor;
|
||||
|
|
|
@ -64,7 +64,7 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
|
|||
n--;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
if (z[0] == '0' && n > 2) {
|
||||
if (z[1] == 'b' || z[1] == 'B') {
|
||||
|
@ -75,7 +75,7 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
|
|||
if (z[1] == 'x' || z[1] == 'X') {
|
||||
// parsing as hex
|
||||
*value = taosStr2UInt64(z, &endPtr, 16);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -85,11 +85,11 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
|
|||
if (parseFloat) {
|
||||
// parsing as double
|
||||
double val = taosStr2Double(z, &endPtr);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (val > (double)UINT64_MAX) {
|
||||
errno = ERANGE;
|
||||
SET_ERRNO(ERANGE);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
*value = round(val);
|
||||
|
@ -101,14 +101,14 @@ static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint
|
|||
|
||||
int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) {
|
||||
if (n == 0) {
|
||||
errno = EINVAL;
|
||||
SET_ERRNO(EINVAL);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
*value = taosStr2Double(z, &endPtr); // 0x already converted here
|
||||
if (errno == ERANGE || errno == EINVAL) return TSDB_CODE_FAILED;
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL) return TSDB_CODE_FAILED;
|
||||
if (endPtr - z == n) return TSDB_CODE_SUCCESS;
|
||||
|
||||
if (type == TK_NK_BIN || type == TK_NK_STRING) {
|
||||
|
@ -124,12 +124,12 @@ int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) {
|
|||
}
|
||||
|
||||
int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
|
||||
char *endPtr = NULL;
|
||||
*value = taosStr2Int64(z, &endPtr, base);
|
||||
if (endPtr - z == n) {
|
||||
if (errno == ERANGE || errno == EINVAL) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -159,12 +159,12 @@ int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) {
|
|||
}
|
||||
|
||||
int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
switch (type) {
|
||||
case TK_NK_INTEGER: {
|
||||
*value = taosStr2Int64(z, &endPtr, 10);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -174,7 +174,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
|
|||
if (val < (double)INT64_MIN || val > (double)INT64_MAX) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
*value = val;
|
||||
|
@ -185,18 +185,18 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
|
|||
}
|
||||
|
||||
if (n == 0) {
|
||||
errno = EINVAL;
|
||||
SET_ERRNO(EINVAL);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// 1. try to parse as integer
|
||||
*value = taosStr2Int64(z, &endPtr, 10);
|
||||
if (endPtr - z == n) {
|
||||
if (errno == ERANGE || errno == EINVAL) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (errno == 0 && *endPtr == '.') {
|
||||
} else if (ERRNO == 0 && *endPtr == '.') {
|
||||
// pure decimal part
|
||||
const char *s = endPtr + 1;
|
||||
const char *end = z + n;
|
||||
|
@ -254,7 +254,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
|
|||
}
|
||||
|
||||
int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
const char *p = z;
|
||||
switch (type) {
|
||||
|
@ -263,7 +263,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
|||
if (*p == '-' && *value) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -273,7 +273,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
|||
if (val < 0 || val > (double)UINT64_MAX) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
*value = val;
|
||||
|
@ -284,7 +284,7 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
|||
}
|
||||
|
||||
if (n == 0) {
|
||||
errno = EINVAL;
|
||||
SET_ERRNO(EINVAL);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -292,11 +292,11 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
|||
*value = taosStr2UInt64(p, &endPtr, 10);
|
||||
|
||||
if (endPtr - z == n) {
|
||||
if (errno == ERANGE || errno == EINVAL || (*p == '-' && *value)) {
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || (*p == '-' && *value)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (errno == 0 && *endPtr == '.') {
|
||||
} else if (ERRNO == 0 && *endPtr == '.') {
|
||||
const char *s = endPtr + 1;
|
||||
const char *end = z + n;
|
||||
bool pure = true;
|
||||
|
@ -331,12 +331,12 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
|
|||
}
|
||||
|
||||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
|
||||
*value = taosStr2Int64(z, &endPtr, base);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
errno = 0;
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
SET_ERRNO(0);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
|||
}
|
||||
|
||||
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
||||
errno = 0;
|
||||
SET_ERRNO(0);
|
||||
char *endPtr = NULL;
|
||||
|
||||
const char *p = z;
|
||||
|
@ -354,8 +354,8 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
|||
}
|
||||
|
||||
*value = taosStr2UInt64(z, &endPtr, base);
|
||||
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||
errno = 0;
|
||||
if (ERRNO == ERANGE || ERRNO == EINVAL || endPtr - z != n) {
|
||||
SET_ERRNO(0);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -8,7 +8,11 @@ add_subdirectory(mgmt_dnode)
|
|||
add_subdirectory(test)
|
||||
|
||||
aux_source_directory(exe EXEC_SRC)
|
||||
add_executable(taosd ${EXEC_SRC})
|
||||
if(${TAOSD_INTEGRATED})
|
||||
add_library(taosd ${EXEC_SRC})
|
||||
else()
|
||||
add_executable(taosd ${EXEC_SRC})
|
||||
endif()
|
||||
target_include_directories(
|
||||
taosd
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc"
|
||||
|
|
|
@ -75,6 +75,7 @@ static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert
|
|||
static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
||||
// taosIgnSignal(SIGUSR1);
|
||||
// taosIgnSignal(SIGUSR2);
|
||||
#ifndef TD_ASTRA
|
||||
if (taosIgnSignal(SIGTERM) != 0) {
|
||||
dWarn("failed to ignore signal SIGTERM");
|
||||
}
|
||||
|
@ -90,16 +91,20 @@ static void dmStopDnode(int signum, void *sigInfo, void *context) {
|
|||
if (taosIgnSignal(SIGBREAK) != 0) {
|
||||
dWarn("failed to ignore signal SIGBREAK");
|
||||
}
|
||||
|
||||
#endif
|
||||
dInfo("shut down signal is %d", signum);
|
||||
#ifndef WINDOWS
|
||||
#if !defined(WINDOWS) && !defined(TD_ASTRA)
|
||||
if (sigInfo != NULL) {
|
||||
dInfo("sender PID:%d cmdline:%s", ((siginfo_t *)sigInfo)->si_pid,
|
||||
taosGetCmdlineByPID(((siginfo_t *)sigInfo)->si_pid));
|
||||
}
|
||||
#endif
|
||||
|
||||
dmStop();
|
||||
}
|
||||
|
||||
void dmStopDaemon() { dmStopDnode(SIGTERM, NULL, NULL); }
|
||||
|
||||
void dmLogCrash(int signum, void *sigInfo, void *context) {
|
||||
// taosIgnSignal(SIGTERM);
|
||||
// taosIgnSignal(SIGHUP);
|
||||
|
@ -120,8 +125,9 @@ void dmLogCrash(int signum, void *sigInfo, void *context) {
|
|||
if (taosIgnSignal(SIGSEGV) != 0) {
|
||||
dWarn("failed to ignore signal SIGABRT");
|
||||
}
|
||||
#ifdef USE_REPORT
|
||||
writeCrashLogToFile(signum, sigInfo, CUS_PROMPT "d", dmGetClusterId(), global.startTime);
|
||||
|
||||
#endif
|
||||
#ifdef _TD_DARWIN_64
|
||||
exit(signum);
|
||||
#elif defined(WINDOWS)
|
||||
|
@ -298,10 +304,12 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
|||
taosGetCwd(path, sizeof(path));
|
||||
|
||||
char args[1024] = {0};
|
||||
if (argc > 0) {
|
||||
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
|
||||
for (int32_t i = 1; i < argc; ++i) {
|
||||
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
dInfo("startup path:%s args:%s", path, args);
|
||||
}
|
||||
|
@ -366,7 +374,11 @@ static void taosCleanupArgs() {
|
|||
if (global.envCmd != NULL) taosMemoryFreeClear(global.envCmd);
|
||||
}
|
||||
|
||||
#ifdef TAOSD_INTEGRATED
|
||||
int dmStartDaemon(int argc, char const *argv[]) {
|
||||
#else
|
||||
int main(int argc, char const *argv[]) {
|
||||
#endif
|
||||
int32_t code = 0;
|
||||
#ifdef TD_JEMALLOC_ENABLED
|
||||
bool jeBackgroundThread = true;
|
||||
|
@ -469,13 +481,14 @@ int mainWindows(int argc, char **argv) {
|
|||
return code;
|
||||
}
|
||||
|
||||
#ifndef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
|
||||
dError("failed to init conv");
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
return code;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (global.checkS3) {
|
||||
code = dmCheckS3();
|
||||
taosCleanupCfg();
|
||||
|
@ -546,8 +559,6 @@ int mainWindows(int argc, char **argv) {
|
|||
|
||||
dInfo("start to init service");
|
||||
dmSetSignalHandle();
|
||||
tsDndStart = taosGetTimestampMs();
|
||||
tsDndStartOsUptime = taosGetOsUptime();
|
||||
|
||||
code = dmRun();
|
||||
dInfo("shutting down the service");
|
||||
|
|
|
@ -95,6 +95,7 @@ static void *dmStatusInfoThreadFp(void *param) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
||||
#define TIMESERIES_STASH_NUM 5
|
||||
static void *dmNotifyThreadFp(void *param) {
|
||||
|
@ -196,7 +197,9 @@ static void *dmNotifyThreadFp(void *param) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_MONITOR
|
||||
static void *dmMonitorThreadFp(void *param) {
|
||||
SDnodeMgmt *pMgmt = param;
|
||||
int64_t lastTime = taosGetTimestampMs();
|
||||
|
@ -231,7 +234,8 @@ static void *dmMonitorThreadFp(void *param) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_AUDIT
|
||||
static void *dmAuditThreadFp(void *param) {
|
||||
SDnodeMgmt *pMgmt = param;
|
||||
int64_t lastTime = taosGetTimestampMs();
|
||||
|
@ -252,7 +256,8 @@ static void *dmAuditThreadFp(void *param) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_REPORT
|
||||
static void *dmCrashReportThreadFp(void *param) {
|
||||
int32_t code = 0;
|
||||
SDnodeMgmt *pMgmt = param;
|
||||
|
@ -330,14 +335,18 @@ static void *dmCrashReportThreadFp(void *param) {
|
|||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
|
||||
int32_t code = 0;
|
||||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pMgmt->statusThread, &thAttr, dmStatusThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create status thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -352,8 +361,11 @@ int32_t dmStartConfigThread(SDnodeMgmt *pMgmt) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pMgmt->configThread, &thAttr, dmConfigThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create config thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -368,8 +380,11 @@ int32_t dmStartStatusInfoThread(SDnodeMgmt *pMgmt) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pMgmt->statusInfoThread, &thAttr, dmStatusInfoThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create status Info thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -399,14 +414,14 @@ void dmStopStatusInfoThread(SDnodeMgmt *pMgmt) {
|
|||
taosThreadClear(&pMgmt->statusInfoThread);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt) {
|
||||
int32_t code = 0;
|
||||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pMgmt->notifyThread, &thAttr, dmNotifyThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create notify thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -429,55 +444,64 @@ void dmStopNotifyThread(SDnodeMgmt *pMgmt) {
|
|||
dError("failed to destroy notify sem");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) {
|
||||
int32_t code = 0;
|
||||
#ifdef USE_MONITOR
|
||||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pMgmt->monitorThread, &thAttr, dmMonitorThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create monitor thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
tmsgReportStartup("dnode-monitor", "initialized");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t dmStartAuditThread(SDnodeMgmt *pMgmt) {
|
||||
int32_t code = 0;
|
||||
#ifdef USE_AUDIT
|
||||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pMgmt->auditThread, &thAttr, dmAuditThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create audit thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
tmsgReportStartup("dnode-audit", "initialized");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dmStopMonitorThread(SDnodeMgmt *pMgmt) {
|
||||
#ifdef USE_MONITOR
|
||||
if (taosCheckPthreadValid(pMgmt->monitorThread)) {
|
||||
(void)taosThreadJoin(pMgmt->monitorThread, NULL);
|
||||
taosThreadClear(&pMgmt->monitorThread);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void dmStopAuditThread(SDnodeMgmt *pMgmt) {
|
||||
#ifdef USE_AUDIT
|
||||
if (taosCheckPthreadValid(pMgmt->auditThread)) {
|
||||
(void)taosThreadJoin(pMgmt->auditThread, NULL);
|
||||
taosThreadClear(&pMgmt->auditThread);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) {
|
||||
int32_t code = 0;
|
||||
#ifdef USE_REPORT
|
||||
if (!tsEnableCrashReport) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -486,17 +510,19 @@ int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) {
|
|||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pMgmt->crashReportThread, &thAttr, dmCrashReportThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create crashReport thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
tmsgReportStartup("dnode-crashReport", "initialized");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
|
||||
#ifdef USE_REPORT
|
||||
if (!tsEnableCrashReport) {
|
||||
return;
|
||||
}
|
||||
|
@ -505,6 +531,7 @@ void dmStopCrashReportThread(SDnodeMgmt *pMgmt) {
|
|||
(void)taosThreadJoin(pMgmt->crashReportThread, NULL);
|
||||
taosThreadClear(&pMgmt->crashReportThread);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
|
|
|
@ -212,7 +212,7 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
|||
}
|
||||
|
||||
if (taosCloseFile(&pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
|
|
@ -174,6 +174,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_FAILED_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_PAUSE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RESUME_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "libs/function/function.h"
|
||||
#include "libs/function/tudf.h"
|
||||
|
||||
#ifdef USE_STREAM
|
||||
|
||||
static int32_t smRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||
return dmReadFile(pInput->path, pInput->name, required);
|
||||
}
|
||||
|
@ -98,3 +100,4 @@ SMgmtFunc smGetMgmtFunc() {
|
|||
|
||||
return mgmtFunc;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -350,14 +350,14 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
|||
goto _OVER1;
|
||||
}
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
lino = __LINE__;
|
||||
goto _OVER1;
|
||||
}
|
||||
|
||||
code = taosCloseFile(&pFile);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
lino = __LINE__;
|
||||
goto _OVER1;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1;
|
||||
}
|
||||
}
|
||||
#if defined(TD_ENTERPRISE)
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
@ -199,7 +199,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
pCfg->walCfg.retentionSize = pCreate->walRetentionSize;
|
||||
pCfg->walCfg.segSize = pCreate->walSegmentSize;
|
||||
pCfg->walCfg.level = pCreate->walLevel;
|
||||
#if defined(TD_ENTERPRISE)
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->walCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
@ -208,7 +208,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
pCfg->walCfg.encryptAlgorithm = 0;
|
||||
#endif
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
|
|
|
@ -584,9 +584,10 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
|
||||
SWrapperCfg *pCfgs = NULL;
|
||||
int32_t numOfVnodes = 0;
|
||||
if (vmGetVnodeListFromFile(pMgmt, &pCfgs, &numOfVnodes) != 0) {
|
||||
dInfo("failed to get vnode list from disk since %s", terrstr());
|
||||
return -1;
|
||||
int32_t code = 0;
|
||||
if ((code = vmGetVnodeListFromFile(pMgmt, &pCfgs, &numOfVnodes)) != 0) {
|
||||
dInfo("failed to get vnode list from disk since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pMgmt->state.totalVnodes = numOfVnodes;
|
||||
|
@ -623,8 +624,11 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pThread->thread, &thAttr, vmOpenVnodeInThread, pThread) != 0) {
|
||||
dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(errno));
|
||||
dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(ERRNO));
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
|
@ -646,13 +650,12 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
|
||||
if ((pMgmt->state.openVnodes + pMgmt->state.dropVnodes) != pMgmt->state.totalVnodes) {
|
||||
dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes);
|
||||
terrno = TSDB_CODE_VND_INIT_FAILED;
|
||||
return -1;
|
||||
return terrno = TSDB_CODE_VND_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (updateVnodesList && vmWriteVnodeListToFile(pMgmt) != 0) {
|
||||
dError("failed to write vnode list since %s", terrstr());
|
||||
return -1;
|
||||
if (updateVnodesList && (code = vmWriteVnodeListToFile(pMgmt)) != 0) {
|
||||
dError("failed to write vnode list since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
dInfo("successfully opened %d vnodes", pMgmt->state.totalVnodes);
|
||||
|
@ -741,9 +744,11 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pThread->thread, &thAttr, vmCloseVnodeInThread, pThread) != 0) {
|
||||
dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(errno));
|
||||
dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(ERRNO));
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
|
@ -852,8 +857,11 @@ static int32_t vmInitTimer(SVnodeMgmt *pMgmt) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if (taosThreadCreate(&pMgmt->thread, &thAttr, vmThreadFp, pMgmt) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
dError("failed to create vnode timer thread since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -889,19 +897,19 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
|
||||
code = taosThreadRwlockInit(&pMgmt->hashLock, NULL);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = taosThreadMutexInit(&pMgmt->mutex, NULL);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = taosThreadMutexInit(&pMgmt->fileLock, NULL);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1057,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
|
|||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pThread->thread, &thAttr, vmRestoreVnodeInThread, pThread) != 0) {
|
||||
dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(errno));
|
||||
dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(ERRNO));
|
||||
}
|
||||
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
|
|
|
@ -120,6 +120,7 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
#ifdef USE_STREAM
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
|
||||
|
@ -135,9 +136,11 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vmProcessStreamCtrlQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_t numOfItems) {
|
||||
#ifdef USE_STREAM
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
void *pItem = NULL;
|
||||
int32_t code = 0;
|
||||
|
@ -163,6 +166,7 @@ static void vmProcessStreamCtrlQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_
|
|||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vmProcessStreamChkptQueue(SQueueInfo *pInfo, STaosQall* pQall, int32_t numOfItems) {
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
#define _TD_DND_MGMT_H_
|
||||
|
||||
// tobe deleted
|
||||
#ifdef USE_UDF
|
||||
#include "uv.h"
|
||||
#endif
|
||||
|
||||
#include "dmInt.h"
|
||||
#include "tfs.h"
|
||||
|
@ -58,6 +60,7 @@ typedef struct {
|
|||
char desc[TSDB_STEP_DESC_LEN];
|
||||
} SStartupInfo;
|
||||
|
||||
#ifdef USE_UDF
|
||||
typedef struct SUdfdData {
|
||||
bool startCalled;
|
||||
bool needCleanUp;
|
||||
|
@ -71,6 +74,7 @@ typedef struct SUdfdData {
|
|||
int32_t stopCalled;
|
||||
int32_t dnodeId;
|
||||
} SUdfdData;
|
||||
#endif
|
||||
|
||||
typedef struct SDnode {
|
||||
int8_t once;
|
||||
|
@ -78,7 +82,9 @@ typedef struct SDnode {
|
|||
EDndRunStatus status;
|
||||
SStartupInfo startup;
|
||||
SDnodeData data;
|
||||
#ifdef USE_UDF
|
||||
SUdfdData udfdData;
|
||||
#endif
|
||||
TdThreadMutex mutex;
|
||||
TdFilePtr lockfile;
|
||||
STfs *pTfs;
|
||||
|
|
|
@ -101,8 +101,8 @@ static int32_t dmCheckDiskSpace() {
|
|||
int32_t code = 0;
|
||||
code = osUpdate();
|
||||
if (code != 0) {
|
||||
code = 0; // ignore the error, just log it
|
||||
dError("failed to update os info since %s", tstrerror(code));
|
||||
code = 0; // ignore the error, just log it
|
||||
}
|
||||
if (!dmDataSpaceAvailable()) {
|
||||
code = TSDB_CODE_NO_DISKSPACE;
|
||||
|
|
|
@ -169,7 +169,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
tsiEncryptAlgorithm = pData->encryptAlgorigthm;
|
||||
tsiEncryptScope = pData->encryptScope;
|
||||
/*
|
||||
|
|
|
@ -154,6 +154,9 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
|||
dmCloseNodes(pDnode);
|
||||
return code;
|
||||
}
|
||||
tsDndStart = taosGetTimestampMs();
|
||||
if (tsDndStart == 0) ++tsDndStart; // avoid 0
|
||||
tsDndStartOsUptime = taosGetOsUptime();
|
||||
|
||||
while (1) {
|
||||
if (pDnode->stop) {
|
||||
|
|
|
@ -64,7 +64,7 @@ static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
if (code < 0) return -1;
|
||||
tjsonGetInt32ValueFromDouble(pJson, "dropped", pData->dropped, code);
|
||||
if (code < 0) return -1;
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
tjsonGetInt32ValueFromDouble(pJson, "encryptAlgor", pData->encryptAlgorigthm, code);
|
||||
if (code < 0) return -1;
|
||||
tjsonGetInt32ValueFromDouble(pJson, "encryptScope", pData->encryptScope, code);
|
||||
|
@ -131,7 +131,7 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||
dInfo("dnode file:%s not exist", file);
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
if (strlen(tsEncryptAlgorithm) > 0) {
|
||||
if (strcmp(tsEncryptAlgorithm, "sm4") == 0) {
|
||||
pData->encryptAlgorigthm = DND_CA_SM4;
|
||||
|
@ -289,7 +289,7 @@ static int32_t dmEncodeEps(SJson *pJson, SDnodeData *pData) {
|
|||
if (tjsonAddIntegerToObject(pJson, "engineVer", pData->engineVer) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "clusterId", pData->clusterId) < 0) return -1;
|
||||
if (tjsonAddDoubleToObject(pJson, "dropped", pData->dropped) < 0) return -1;
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
if (tjsonAddDoubleToObject(pJson, "encryptAlgor", pData->encryptAlgorigthm) < 0) return -1;
|
||||
if (tjsonAddDoubleToObject(pJson, "encryptScope", pData->encryptScope) < 0) return -1;
|
||||
#endif
|
||||
|
@ -657,7 +657,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
pData->oldDnodeEps = taosArrayInit(1, sizeof(SDnodeEpPair));
|
||||
if (pData->oldDnodeEps == NULL) {
|
||||
code = terrno;
|
||||
dError("failed to calloc dnodeEp array since %s", strerror(errno));
|
||||
dError("failed to calloc dnodeEp array since %s", strerror(ERRNO));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
|||
}
|
||||
|
||||
if (taosCloseFile(&pFile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
@ -206,7 +206,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) {
|
|||
} while (retryTimes < 12);
|
||||
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
(void)taosCloseFile(pFile);
|
||||
*pFile = NULL;
|
||||
return code;
|
||||
|
@ -249,12 +249,12 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
|||
}
|
||||
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosCloseFile(&pFile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ static int32_t dmWriteEncryptCodeFile(char *file, char *realfile, char *encryptC
|
|||
}
|
||||
|
||||
if (taosCloseFile(&pFile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,7 @@ _OVER:
|
|||
}
|
||||
|
||||
int32_t dmUpdateEncryptKey(char *key, bool toLogFile) {
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
int32_t code = -1;
|
||||
int32_t lino = 0;
|
||||
char *machineId = NULL;
|
||||
|
@ -499,7 +499,7 @@ _OVER:
|
|||
}
|
||||
|
||||
int32_t dmGetEncryptKey() {
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
int32_t code = -1;
|
||||
char encryptFile[PATH_MAX] = {0};
|
||||
char checkFile[PATH_MAX] = {0};
|
||||
|
|
|
@ -833,7 +833,7 @@ typedef struct {
|
|||
|
||||
int32_t indexForMultiAggBalance;
|
||||
int8_t subTableWithoutMd5;
|
||||
char reserve[256];
|
||||
char reserve[TSDB_RESERVE_VALUE_LEN];
|
||||
|
||||
} SStreamObj;
|
||||
|
||||
|
|
|
@ -925,7 +925,7 @@ static int32_t mndCheckDbEncryptKey(SMnode *pMnode, SCreateDbReq *pReq) {
|
|||
SDnodeObj *pDnode = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
if (pReq->encryptAlgorithm == TSDB_ENCRYPT_ALGO_NONE) goto _exit;
|
||||
TAOS_CHECK_GOTO(grantCheck(TSDB_GRANT_DB_ENCRYPTION), NULL, _exit);
|
||||
if (tsEncryptionKeyStat != ENCRYPT_KEY_STAT_LOADED) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "taoserror.h"
|
||||
#include "tunit.h"
|
||||
|
||||
#ifdef USE_STREAM
|
||||
static void *freeStreamTasks(SArray *pTaskLevel);
|
||||
|
||||
int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
||||
|
@ -198,6 +199,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
|
|||
}
|
||||
|
||||
void *freeStreamTasks(SArray *pTaskLevel) {
|
||||
if (pTaskLevel == NULL) return NULL;
|
||||
int32_t numOfLevel = taosArrayGetSize(pTaskLevel);
|
||||
|
||||
for (int32_t i = 0; i < numOfLevel; i++) {
|
||||
|
@ -233,6 +235,7 @@ void tFreeStreamObj(SStreamObj *pStream) {
|
|||
taosMemoryFree(pStream->tagSchema.pSchema);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
|
||||
SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
|
|
|
@ -294,7 +294,7 @@ static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode) {
|
|||
static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew) {
|
||||
mTrace("dnode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew);
|
||||
pOld->updateTime = pNew->updateTime;
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
tstrncpy(pOld->machineId, pNew->machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -350,7 +350,7 @@ static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) {
|
|||
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
if (taosStrncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
return pDnode;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ static SDnodeObj *mndAcquireDnodeAllStatusByEp(SMnode *pMnode, char *pEpStr) {
|
|||
pIter = sdbFetchAll(pSdb, SDB_DNODE, pIter, (void **)&pDnode, &objStatus, true);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
if (taosStrncasecmp(pEpStr, pDnode->ep, TSDB_EP_LEN) == 0) {
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
return pDnode;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
|||
CHECK_MONITOR_PARA(tsSlowLogMaxLen, DND_REASON_STATUS_MONITOR_SLOW_LOG_SQL_MAX_LEN_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
||||
|
||||
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||
if (0 != taosStrcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id,
|
||||
pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
|
||||
|
@ -492,20 +492,20 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
|||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||
}
|
||||
|
||||
if ((0 != strcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||
if ((0 != taosStrcasecmp(pCfg->timezone, tsTimezoneStr)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||
mError("dnode:%d, timezone:%s checkTime:%" PRId64 " inconsistent with cluster %s %" PRId64, pDnode->id,
|
||||
pCfg->timezone, pCfg->checkTime, tsTimezoneStr, pMnode->checkTime);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_TIMEZONE;
|
||||
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
||||
if (0 != taosStrcasecmp(pCfg->locale, tsLocale)) {
|
||||
mError("dnode:%d, locale:%s inconsistent with cluster:%s", pDnode->id, pCfg->locale, tsLocale);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_LOCALE;
|
||||
return DND_REASON_LOCALE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
||||
if (0 != taosStrcasecmp(pCfg->charset, tsCharset)) {
|
||||
mError("dnode:%d, charset:%s inconsistent with cluster:%s", pDnode->id, pCfg->charset, tsCharset);
|
||||
terrno = TSDB_CODE_DNODE_INVALID_CHARSET;
|
||||
return DND_REASON_CHARSET_NOT_MATCH;
|
||||
|
@ -1424,7 +1424,7 @@ _exit:
|
|||
static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pReq) {
|
||||
int32_t code = 0;
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SMCfgDnodeReq cfgReq = {0};
|
||||
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
|
||||
|
|
|
@ -81,7 +81,7 @@ int32_t mndInitIdx(SMnode *pMnode) {
|
|||
|
||||
static int32_t mndFindSuperTableTagId(const SStbObj *pStb, const char *tagName, int8_t *hasIdx) {
|
||||
for (int32_t tag = 0; tag < pStb->numOfTags; tag++) {
|
||||
if (strcasecmp(pStb->pTags[tag].name, tagName) == 0) {
|
||||
if (taosStrcasecmp(pStb->pTags[tag].name, tagName) == 0) {
|
||||
if (IS_IDX_ON(&pStb->pTags[tag])) {
|
||||
*hasIdx = 1;
|
||||
}
|
||||
|
@ -936,7 +936,7 @@ int32_t mndGetIdxsByTagName(SMnode *pMnode, SStbObj *pStb, char *tagName, SIdxOb
|
|||
pIter = sdbFetch(pSdb, SDB_IDX, pIter, (void **)&pIdx);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (pIdx->stbUid == pStb->uid && strcasecmp(pIdx->colName, tagName) == 0) {
|
||||
if (pIdx->stbUid == pStb->uid && taosStrcasecmp(pIdx->colName, tagName) == 0) {
|
||||
memcpy((char *)idx, (char *)pIdx, sizeof(SIdxObj));
|
||||
sdbRelease(pSdb, pIdx);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
|
|
|
@ -204,6 +204,18 @@ static void mndStreamCheckNode(SMnode *pMnode) {
|
|||
}
|
||||
}
|
||||
|
||||
static void mndStreamCheckStatus(SMnode *pMnode) {
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_CHECK_STREAM_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mndStreamConsensusChkpt(SMnode *pMnode) {
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
|
@ -375,6 +387,7 @@ static int32_t minCronTime() {
|
|||
}
|
||||
void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
||||
int32_t code = 0;
|
||||
#ifndef TD_ASTRA
|
||||
if (sec % tsTtlPushIntervalSec == 0) {
|
||||
mndPullupTtl(pMnode);
|
||||
}
|
||||
|
@ -382,11 +395,12 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
|||
if (sec % tsTrimVDbIntervalSec == 0) {
|
||||
mndPullupTrimDb(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_S3
|
||||
if (tsS3MigrateEnabled && sec % tsS3MigrateIntervalSec == 0) {
|
||||
mndPullupS3MigrateDb(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
if (sec % tsTransPullupInterval == 0) {
|
||||
mndPullupTrans(pMnode);
|
||||
}
|
||||
|
@ -394,11 +408,12 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
|||
if (sec % tsCompactPullupInterval == 0) {
|
||||
mndPullupCompacts(pMnode);
|
||||
}
|
||||
|
||||
#ifdef USE_TOPIC
|
||||
if (sec % tsMqRebalanceInterval == 0) {
|
||||
mndCalMqRebalance(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_STREAM
|
||||
if (sec % 30 == 0) { // send the checkpoint info every 30 sec
|
||||
mndStreamCheckpointTimer(pMnode);
|
||||
}
|
||||
|
@ -407,22 +422,28 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
|||
mndStreamCheckNode(pMnode);
|
||||
}
|
||||
|
||||
if (sec % (tsStreamFailedTimeout/1000) == 0) {
|
||||
mndStreamCheckStatus(pMnode);
|
||||
}
|
||||
|
||||
if (sec % 5 == 0) {
|
||||
mndStreamConsensusChkpt(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_REPORT
|
||||
if (sec % tsTelemInterval == (TMIN(86400, (tsTelemInterval - 1)))) {
|
||||
mndPullupTelem(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef TD_ASTRA
|
||||
if (sec % tsGrantHBInterval == 0) {
|
||||
mndPullupGrant(pMnode);
|
||||
}
|
||||
|
||||
#endif
|
||||
if (sec % tsUptimeInterval == 0) {
|
||||
mndIncreaseUpTime(pMnode);
|
||||
}
|
||||
|
||||
#ifndef TD_ASTRA
|
||||
if (sec % (tsArbHeartBeatIntervalSec) == 0) {
|
||||
if ((code = mndPullupArbHeartbeat(pMnode)) != 0) {
|
||||
mError("failed to pullup arb heartbeat, since:%s", tstrerror(code));
|
||||
|
@ -434,6 +455,7 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
|||
mError("failed to pullup arb check sync, since:%s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void mndDoTimerCheckTask(SMnode *pMnode, int64_t sec) {
|
||||
if (sec % (tsStatusInterval * 5) == 0) {
|
||||
|
@ -476,6 +498,9 @@ static int32_t mndInitTimer(SMnode *pMnode) {
|
|||
TdThreadAttr thAttr;
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
#ifdef TD_COMPACT_OS
|
||||
(void)taosThreadAttrSetStackSize(&thAttr, STACK_SIZE_SMALL);
|
||||
#endif
|
||||
if ((code = taosThreadCreate(&pMnode->thread, &thAttr, mndThreadFp, pMnode)) != 0) {
|
||||
mError("failed to create timer thread since %s", tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
|
@ -524,7 +549,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
.encryptAlgorithm = 0,
|
||||
.encryptKey = {0}};
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
#if defined(TD_ENTERPRISE) || defined(TD_ASTRA_TODO)
|
||||
if (tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL) {
|
||||
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL) ? tsiEncryptAlgorithm : 0;
|
||||
if (tsEncryptKey[0] == '\0') {
|
||||
|
@ -897,7 +922,7 @@ _OVER:
|
|||
pMsg->msgType == TDMT_MND_COMPACT_TIMER || pMsg->msgType == TDMT_MND_NODECHECK_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_GRANT_HB_TIMER || pMsg->msgType == TDMT_MND_STREAM_REQ_CHKPT ||
|
||||
pMsg->msgType == TDMT_MND_S3MIGRATE_DB_TIMER || pMsg->msgType == TDMT_MND_ARB_HEARTBEAT_TIMER ||
|
||||
pMsg->msgType == TDMT_MND_ARB_CHECK_SYNC_TIMER) {
|
||||
pMsg->msgType == TDMT_MND_ARB_CHECK_SYNC_TIMER || pMsg->msgType == TDMT_MND_CHECK_STREAM_TIMER) {
|
||||
mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored,
|
||||
pMnode->stopped, state.restored, syncStr(state.state));
|
||||
TAOS_RETURN(code);
|
||||
|
|
|
@ -103,7 +103,7 @@ END:
|
|||
if (pPlan) nodesDestroyNode((SNode*)pPlan);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
#ifdef USE_STREAM
|
||||
int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) {
|
||||
STaskOutputInfo* pInfo = &pTask->outputInfo;
|
||||
|
||||
|
@ -814,7 +814,9 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t skey, SAr
|
|||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_TOPIC
|
||||
int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub) {
|
||||
int32_t code = 0;
|
||||
SSdb* pSdb = pMnode->pSdb;
|
||||
|
@ -911,3 +913,4 @@ END:
|
|||
qDestroyQueryPlan(pPlan);
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -846,7 +846,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
|||
static SSchema *mndFindStbColumns(const SStbObj *pStb, const char *colName) {
|
||||
for (int32_t col = 0; col < pStb->numOfColumns; ++col) {
|
||||
SSchema *pSchema = &pStb->pColumns[col];
|
||||
if (strncasecmp(pSchema->name, colName, TSDB_COL_NAME_LEN) == 0) {
|
||||
if (taosStrncasecmp(pSchema->name, colName, TSDB_COL_NAME_LEN) == 0) {
|
||||
return pSchema;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
|
|||
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
||||
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream);
|
||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessFailedStreamReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessCheckStreamStatusReq(SRpcMsg *pReq);
|
||||
static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);
|
||||
|
||||
static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq);
|
||||
|
@ -95,6 +97,8 @@ int32_t mndInitStream(SMnode *pMnode) {
|
|||
};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_FAILED_STREAM, mndProcessFailedStreamReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CHECK_STREAM_TIMER, mndProcessCheckStreamStatusReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_NODECHECK_TIMER, mndProcessNodeCheck);
|
||||
|
||||
|
@ -229,7 +233,7 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream) {
|
|||
}
|
||||
|
||||
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream) {
|
||||
mTrace("stream:%s, perform delete action", pStream->name);
|
||||
mInfo("stream:%s, perform delete action", pStream->name);
|
||||
taosWLockLatch(&pStream->lock);
|
||||
tFreeStreamObj(pStream);
|
||||
taosWUnLockLatch(&pStream->lock);
|
||||
|
@ -246,7 +250,14 @@ static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStream
|
|||
pOldStream->updateTime = pNewStream->updateTime;
|
||||
pOldStream->checkpointId = pNewStream->checkpointId;
|
||||
pOldStream->checkpointFreq = pNewStream->checkpointFreq;
|
||||
|
||||
if (pOldStream->tasks == NULL){
|
||||
pOldStream->tasks = pNewStream->tasks;
|
||||
pNewStream->tasks = NULL;
|
||||
}
|
||||
if (pOldStream->pHTasksList == NULL){
|
||||
pOldStream->pHTasksList = pNewStream->pHTasksList;
|
||||
pNewStream->pHTasksList = NULL;
|
||||
}
|
||||
taosWUnLockLatch(&pOldStream->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -346,7 +357,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
snprintf(p, tListLen(p), "%s_%s", pObj->name, "fillhistory");
|
||||
|
||||
pObj->hTaskUid = mndGenerateUid(pObj->name, strlen(pObj->name));
|
||||
pObj->status = 0;
|
||||
pObj->status = STREAM_STATUS__NORMAL;
|
||||
|
||||
pObj->conf.igExpired = pCreate->igExpired;
|
||||
pObj->conf.trigger = pCreate->triggerType;
|
||||
|
@ -362,7 +373,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
code = terrno;
|
||||
mInfo("stream:%s failed to create, source db %s not exist since %s", pCreate->name, pObj->sourceDb,
|
||||
tstrerror(code));
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
pObj->sourceDbUid = pSourceDb->uid;
|
||||
|
@ -375,7 +386,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
code = terrno;
|
||||
mError("stream:%s failed to create, target db %s not exist since %s", pCreate->name, pObj->targetDb,
|
||||
tstrerror(code));
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
tstrncpy(pObj->targetDb, pTargetDb->name, TSDB_DB_FNAME_LEN);
|
||||
|
@ -396,12 +407,12 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
|
||||
// deserialize ast
|
||||
if ((code = nodesStringToNode(pObj->ast, &pAst)) < 0) {
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
// create output schema
|
||||
if ((code = createSchemaByFields(pCreate->pCols, &pObj->outputSchema)) != TSDB_CODE_SUCCESS) {
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
int32_t numOfNULL = taosArrayGetSize(pCreate->fillNullCols);
|
||||
|
@ -410,7 +421,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
SSchema *pFullSchema = taosMemoryCalloc(pObj->outputSchema.nCols, sizeof(SSchema));
|
||||
if (!pFullSchema) {
|
||||
code = terrno;
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
int32_t nullIndex = 0;
|
||||
|
@ -471,12 +482,12 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
|
||||
// using ast and param to build physical plan
|
||||
if ((code = qCreateQueryPlan(&cxt, &pPlan, NULL)) < 0) {
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
// save physcial plan
|
||||
if ((code = nodesNodeToString((SNode *)pPlan, false, &pObj->physicalPlan, NULL)) != 0) {
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
pObj->tagSchema.nCols = pCreate->numOfTags;
|
||||
|
@ -484,7 +495,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
pObj->tagSchema.pSchema = taosMemoryCalloc(pCreate->numOfTags, sizeof(SSchema));
|
||||
if (pObj->tagSchema.pSchema == NULL) {
|
||||
code = terrno;
|
||||
goto FAIL;
|
||||
goto _ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,7 +513,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
memcpy(pObj->tagSchema.pSchema[i].name, pField->name, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
|
||||
FAIL:
|
||||
_ERR:
|
||||
if (pAst != NULL) nodesDestroyNode(pAst);
|
||||
if (pPlan != NULL) qDestroyQueryPlan(pPlan);
|
||||
return code;
|
||||
|
@ -732,11 +743,11 @@ static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
|||
++numOfStream;
|
||||
}
|
||||
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
|
||||
if (numOfStream > 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);
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
return TSDB_CODE_MND_TOO_MANY_STREAMS;
|
||||
}
|
||||
|
@ -744,9 +755,11 @@ static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
|||
if (pStream->targetStbUid == pStreamObj->targetStbUid) {
|
||||
mError("Cannot write the same stable as other stream:%s, failed to create stream:%s", pStream->name,
|
||||
pStreamObj->name);
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
return TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
||||
}
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -823,6 +836,58 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCheckStreamStatusReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SStreamObj *pStream = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
while ((pIter = sdbFetch(pMnode->pSdb, SDB_STREAM, pIter, (void **)&pStream)) != NULL) {
|
||||
taosWLockLatch(&pStream->lock);
|
||||
if (pStream->status == STREAM_STATUS__INIT && (taosGetTimestampMs() - pStream->createTime > tsStreamFailedTimeout ||
|
||||
taosGetTimestampMs() - pStream->createTime < 0)){
|
||||
pStream->status = STREAM_STATUS__FAILED;
|
||||
tstrncpy(pStream->reserve, "timeout", sizeof(pStream->reserve));
|
||||
mInfo("stream:%s, set status to failed success because of timeout", pStream->name);
|
||||
}
|
||||
taosWUnLockLatch(&pStream->lock);
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessFailedStreamReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SStreamObj *pStream = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t errCode = *(int32_t*)pReq->pCont;
|
||||
char streamName[TSDB_STREAM_FNAME_LEN] = {0};
|
||||
memcpy(streamName, POINTER_SHIFT(pReq->pCont,INT_BYTES), TMIN(pReq->contLen - INT_BYTES, TSDB_STREAM_FNAME_LEN - 1));
|
||||
|
||||
#ifdef WINDOWS
|
||||
code = TSDB_CODE_MND_INVALID_PLATFORM;
|
||||
return code;
|
||||
#endif
|
||||
|
||||
mInfo("stream:%s, start to set stream failed", streamName);
|
||||
|
||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||
if (pStream == NULL) {
|
||||
mError("stream:%s, failed to get stream when failed stream since %s", streamName, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
taosWLockLatch(&pStream->lock);
|
||||
pStream->status = STREAM_STATUS__FAILED;
|
||||
tstrncpy(pStream->reserve, tstrerror(errCode), sizeof(pStream->reserve));
|
||||
taosWUnLockLatch(&pStream->lock);
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
|
||||
mInfo("stream:%s, end to set stream failed success", streamName);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SStreamObj *pStream = NULL;
|
||||
|
@ -851,6 +916,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
code = mndAcquireStream(pMnode, createReq.name, &pStream);
|
||||
if (pStream != NULL && code == 0) {
|
||||
if (pStream->tasks != NULL){
|
||||
if (createReq.igExists) {
|
||||
mInfo("stream:%s, already exist, ignore exist is set", createReq.name);
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
|
@ -860,6 +926,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
code = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
} else if (code != TSDB_CODE_MND_STREAM_NOT_EXIST) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -900,56 +967,34 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
code = doStreamCheck(pMnode, &streamObj);
|
||||
TSDB_CHECK_CODE(code, lino, _OVER);
|
||||
|
||||
code = doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, pMsg, &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// create stb for stream
|
||||
if (createReq.createStb == STREAM_CREATE_STABLE_TRUE) {
|
||||
if ((code = mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user)) < 0) {
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
} else {
|
||||
mDebug("stream:%s no need create stable", createReq.name);
|
||||
}
|
||||
|
||||
// schedule stream task for stream obj
|
||||
code = mndScheduleStream(pMnode, &streamObj, createReq.lastTs, createReq.pVgroupVerList);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to schedule since %s", createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// add notify info into all stream tasks
|
||||
code = addStreamNotifyInfo(&createReq, &streamObj);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("stream:%s failed to add stream notify info since %s", createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// add stream to trans
|
||||
code = mndPersistStream(pTrans, &streamObj);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to persist since %s", createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
bool buildEmptyStream = false;
|
||||
if (createReq.lastTs == 0 && createReq.fillHistory != STREAM_FILL_HISTORY_OFF){
|
||||
streamObj.status = STREAM_STATUS__INIT;
|
||||
buildEmptyStream = true;
|
||||
}
|
||||
|
||||
if ((code = mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_READ_DB, streamObj.sourceDb)) != 0) {
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((code = mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, streamObj.targetDb)) != 0) {
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = doStreamCheck(pMnode, &streamObj);
|
||||
TSDB_CHECK_CODE(code, lino, _OVER);
|
||||
|
||||
// schedule stream task for stream obj
|
||||
if (!buildEmptyStream) {
|
||||
code = mndScheduleStream(pMnode, &streamObj, createReq.lastTs, createReq.pVgroupVerList);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to schedule since %s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
// add notify info into all stream tasks
|
||||
code = addStreamNotifyInfo(&createReq, &streamObj);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("stream:%s failed to add stream notify info since %s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -959,29 +1004,45 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
mDebug("stream stream:%s start to register tasks into task nodeList and set initial checkpointId", createReq.name);
|
||||
saveTaskAndNodeInfoIntoBuf(&streamObj, &execInfo);
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
}
|
||||
|
||||
code = doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, pMsg, &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// create stb for stream
|
||||
if (createReq.createStb == STREAM_CREATE_STABLE_TRUE && !buildEmptyStream) {
|
||||
if ((code = mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user)) < 0) {
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
} else {
|
||||
mDebug("stream:%s no need create stable", createReq.name);
|
||||
}
|
||||
|
||||
// add stream to trans
|
||||
code = mndPersistStream(pTrans, &streamObj);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to persist since %s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// execute creation
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
|
||||
SName dbname = {0};
|
||||
code = tNameFromString(&dbname, createReq.sourceDB, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (code) {
|
||||
if (tNameFromString(&dbname, createReq.sourceDB, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE) != 0) {
|
||||
mError("invalid source dbname:%s in create stream, code:%s", createReq.sourceDB, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SName name = {0};
|
||||
code = tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_TABLE);
|
||||
if (code) {
|
||||
if (tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_TABLE) != 0) {
|
||||
mError("invalid stream name:%s in create strem, code:%s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
// reuse this function for stream
|
||||
|
@ -1001,6 +1062,7 @@ _OVER:
|
|||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
tFreeSCMCreateStreamReq(&createReq);
|
||||
tFreeStreamObj(&streamObj);
|
||||
|
@ -2352,6 +2414,23 @@ static int32_t mndProcessNodeCheck(SRpcMsg *pReq) {
|
|||
return tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
||||
static int32_t mndProcessStatusCheck(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
if (sdbGetSize(pSdb, SDB_STREAM) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t size = sizeof(SMStreamNodeCheckMsg);
|
||||
SMStreamNodeCheckMsg *pMsg = rpcMallocCont(size);
|
||||
if (pMsg == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_NODECHANGE_CHECK, .pCont = pMsg, .contLen = size};
|
||||
return tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
||||
void saveTaskAndNodeInfoIntoBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) {
|
||||
SStreamTaskIter *pIter = NULL;
|
||||
int32_t code = createStreamTaskIter(pStream, &pIter);
|
||||
|
|
|
@ -995,6 +995,8 @@ static void mndShowStreamStatus(char *dst, int8_t status) {
|
|||
tstrncpy(dst, "recover", MND_STREAM_TRIGGER_NAME_SIZE);
|
||||
} else if (status == STREAM_STATUS__PAUSE) {
|
||||
tstrncpy(dst, "paused", MND_STREAM_TRIGGER_NAME_SIZE);
|
||||
} else if (status == STREAM_STATUS__INIT) {
|
||||
tstrncpy(dst, "init", MND_STREAM_TRIGGER_NAME_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1110,7 @@ int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_
|
|||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
|
||||
int8_t streamStatus = atomic_load_8(&pStream->status);
|
||||
if (isPaused) {
|
||||
if (isPaused && pStream->tasks != NULL) {
|
||||
streamStatus = STREAM_STATUS__PAUSE;
|
||||
}
|
||||
mndShowStreamStatus(status2, streamStatus);
|
||||
|
@ -1207,6 +1209,17 @@ int32_t setStreamAttrInResBlock(SStreamObj *pStream, SSDataBlock *pBlock, int32_
|
|||
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)dstStr, false);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
TSDB_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||
char msg[TSDB_RESERVE_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (streamStatus == STREAM_STATUS__FAILED){
|
||||
STR_TO_VARSTR(msg, pStream->reserve)
|
||||
} else {
|
||||
STR_TO_VARSTR(msg, " ")
|
||||
}
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)msg, false);
|
||||
|
||||
_end:
|
||||
if (code) {
|
||||
|
|
|
@ -795,7 +795,7 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c
|
|||
if (pIter == NULL) break;
|
||||
|
||||
if (pTrans->oper == oper) {
|
||||
if (strcasecmp(dbname, pTrans->dbname) == 0) {
|
||||
if (taosStrcasecmp(dbname, pTrans->dbname) == 0) {
|
||||
mInfo("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper);
|
||||
taosWLockLatch(&pTrans->lockRpcArray);
|
||||
if (pTrans->pRpcArray == NULL) {
|
||||
|
@ -874,13 +874,13 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
|||
|
||||
static bool mndCheckDbConflict(const char *conflict, STrans *pTrans) {
|
||||
if (conflict[0] == 0) return false;
|
||||
if (strcasecmp(conflict, pTrans->dbname) == 0) return true;
|
||||
if (taosStrcasecmp(conflict, pTrans->dbname) == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool mndCheckStbConflict(const char *conflict, STrans *pTrans) {
|
||||
if (conflict[0] == 0) return false;
|
||||
if (strcasecmp(conflict, pTrans->stbname) == 0) return true;
|
||||
if (taosStrcasecmp(conflict, pTrans->stbname) == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -996,7 +996,7 @@ int32_t mndTransCheckConflictWithCompact(SMnode *pMnode, STrans *pTrans) {
|
|||
thisConflict = true;
|
||||
}
|
||||
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
||||
if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
|
||||
if (taosStrcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
|
||||
}
|
||||
|
||||
if (thisConflict) {
|
||||
|
@ -1292,10 +1292,14 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||
int32_t code = 0;
|
||||
SMnode *pMnode = pRsp->info.node;
|
||||
#ifndef TD_ASTRA_32
|
||||
int64_t signature = (int64_t)(pRsp->info.ahandle);
|
||||
int32_t transId = (int32_t)(signature >> 32);
|
||||
int32_t action = (int32_t)((signature << 32) >> 32);
|
||||
|
||||
#else
|
||||
int32_t transId = (int32_t)(pRsp->info.ahandle);
|
||||
int32_t action = (int32_t)(pRsp->info.ahandleEx);
|
||||
#endif
|
||||
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
||||
if (pTrans == NULL) {
|
||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||
|
@ -1418,11 +1422,18 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
|||
TAOS_RETURN(TSDB_CODE_MND_TRANS_CTX_SWITCH);
|
||||
}
|
||||
|
||||
#ifndef TD_ASTRA_32
|
||||
int64_t signature = pTrans->id;
|
||||
signature = (signature << 32);
|
||||
signature += pAction->id;
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = pAction->msgType, .contLen = pAction->contLen, .info.ahandle = (void *)signature};
|
||||
#else
|
||||
SRpcMsg rpcMsg = {.msgType = pAction->msgType,
|
||||
.contLen = pAction->contLen,
|
||||
.info.ahandle = (void *)pTrans->id,
|
||||
.info.ahandleEx = (void *)pAction->id};
|
||||
#endif
|
||||
rpcMsg.pCont = rpcMallocCont(pAction->contLen);
|
||||
if (rpcMsg.pCont == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
// clang-format off
|
||||
#ifndef TD_ASTRA
|
||||
#include <uv.h>
|
||||
#endif
|
||||
#include "mndUser.h"
|
||||
#include "audit.h"
|
||||
#include "mndDb.h"
|
||||
|
@ -688,11 +690,12 @@ void mndCleanupUser(SMnode *pMnode) { ipWhiteMgtCleanup(); }
|
|||
static void ipRangeToStr(SIpV4Range *range, char *buf) {
|
||||
struct in_addr addr;
|
||||
addr.s_addr = range->ip;
|
||||
|
||||
#ifndef TD_ASTRA
|
||||
(void)uv_inet_ntop(AF_INET, &addr, buf, 32);
|
||||
if (range->mask != 32) {
|
||||
(void)tsnprintf(buf + strlen(buf), 36 - strlen(buf), "/%d", range->mask);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static bool isDefaultRange(SIpV4Range *pRange) {
|
||||
|
@ -839,12 +842,13 @@ static int32_t createDefaultIpWhiteList(SIpWhiteList **ppWhiteList) {
|
|||
}
|
||||
(*ppWhiteList)->num = 1;
|
||||
SIpV4Range *range = &((*ppWhiteList)->pIpRange[0]);
|
||||
|
||||
#ifndef TD_ASTRA
|
||||
struct in_addr addr;
|
||||
if (uv_inet_pton(AF_INET, "127.0.0.1", &addr) == 0) {
|
||||
range->ip = addr.s_addr;
|
||||
range->mask = 32;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2330,6 +2334,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
|||
TAOS_CHECK_GOTO(mndRemoveTablePriviledge(pMnode, pAlterTbs, pNewUser->useDbs, pAlterReq, pSdb), &lino, _OVER);
|
||||
}
|
||||
|
||||
#ifdef USE_TOPIC
|
||||
if (ALTER_USER_ADD_SUBSCRIBE_TOPIC_PRIV(pAlterReq->alterType, pAlterReq->privileges)) {
|
||||
int32_t len = strlen(pAlterReq->objname) + 1;
|
||||
SMqTopicObj *pTopic = NULL;
|
||||
|
@ -2357,7 +2362,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
|||
}
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
}
|
||||
|
||||
#endif
|
||||
_OVER:
|
||||
if (code < 0) {
|
||||
mError("user:%s, failed to alter user privileges at line %d since %s", pAlterReq->user, lino, tstrerror(code));
|
||||
|
|
|
@ -154,13 +154,13 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
|
|||
static int32_t sdbCreateDir(SSdb *pSdb) {
|
||||
int32_t code = 0;
|
||||
if (taosMulMkDir(pSdb->currDir) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
mError("failed to create dir:%s since %s", pSdb->currDir, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if (taosMkDir(pSdb->tmpDir) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
mError("failed to create dir:%s since %s", pSdb->tmpDir, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
int64_t maxId = 0;
|
||||
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
|
@ -196,7 +196,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
int64_t ver = 0;
|
||||
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
|
@ -556,7 +556,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
|
||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||
code = errno;
|
||||
code = terrno;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
|
@ -576,7 +576,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
if (code == 0) {
|
||||
code = taosFsyncFile(pFile);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
mError("failed to sync sdb file:%s since %s", tmpfile, tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
@ -822,13 +822,13 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i
|
|||
}
|
||||
|
||||
if (taosFsyncFile(pIter->file) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
mError("sdbiter:%p, failed to fasync file %s since %s", pIter, pIter->name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosCloseFile(&pIter->file) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(ERRNO);
|
||||
goto _OVER;
|
||||
}
|
||||
pIter->file = NULL;
|
||||
|
|
|
@ -136,7 +136,7 @@ int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
*(int64_t *)(pRaw->pData + dataPos) = val;
|
||||
taosSetInt64Aligned((int64_t *)(pRaw->pData + dataPos), val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
*val = *(int64_t *)(pRaw->pData + dataPos);
|
||||
taosSetPInt64Aligned(val, (int64_t *)(pRaw->pData + dataPos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue