Merge branch 'main' into docs/TD-33141
This commit is contained in:
commit
ad1cf8c7d4
|
@ -162,3 +162,12 @@ geos_c.h
|
||||||
source/libs/parser/src/sql.c
|
source/libs/parser/src/sql.c
|
||||||
include/common/ttokenauto.h
|
include/common/ttokenauto.h
|
||||||
!packaging/smokeTest/pytest_require.txt
|
!packaging/smokeTest/pytest_require.txt
|
||||||
|
tdengine-test-dir/
|
||||||
|
localtime.c
|
||||||
|
private.h
|
||||||
|
strftime.c
|
||||||
|
tzdir.h
|
||||||
|
tzfile.h
|
||||||
|
coverage.info
|
||||||
|
taos
|
||||||
|
taosd
|
|
@ -112,14 +112,14 @@ Fill in the example data from the MQTT message body in **Message Body**.
|
||||||
|
|
||||||
JSON data supports JSONObject or JSONArray, and the json parser can parse the following data:
|
JSON data supports JSONObject or JSONArray, and the json parser can parse the following data:
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{"id": 1, "message": "hello-word"}
|
{"id": 1, "message": "hello-word"}
|
||||||
{"id": 2, "message": "hello-word"}
|
{"id": 2, "message": "hello-word"}
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
[{"id": 1, "message": "hello-word"},{"id": 2, "message": "hello-word"}]
|
[{"id": 1, "message": "hello-word"},{"id": 2, "message": "hello-word"}]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ In addition, the [Kerberos](https://web.mit.edu/kerberos/) authentication servic
|
||||||
|
|
||||||
After configuration, you can use the [kcat](https://github.com/edenhill/kcat) tool to verify Kafka topic consumption:
|
After configuration, you can use the [kcat](https://github.com/edenhill/kcat) tool to verify Kafka topic consumption:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
kcat <topic> \
|
kcat <topic> \
|
||||||
-b <kafka-server:port> \
|
-b <kafka-server:port> \
|
||||||
-G kcat \
|
-G kcat \
|
||||||
|
@ -171,14 +171,14 @@ Enter sample data from the Kafka message body in **Message Body**.
|
||||||
|
|
||||||
JSON data supports JSONObject or JSONArray, and the following data can be parsed using a JSON parser:
|
JSON data supports JSONObject or JSONArray, and the following data can be parsed using a JSON parser:
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{"id": 1, "message": "hello-word"}
|
{"id": 1, "message": "hello-word"}
|
||||||
{"id": 2, "message": "hello-word"}
|
{"id": 2, "message": "hello-word"}
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
[{"id": 1, "message": "hello-word"},{"id": 2, "message": "hello-word"}]
|
[{"id": 1, "message": "hello-word"},{"id": 2, "message": "hello-word"}]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ Parsing is the process of parsing unstructured strings into structured data. The
|
||||||
|
|
||||||
JSON parsing supports JSONObject or JSONArray. The following JSON sample data can automatically parse fields: `groupid`, `voltage`, `current`, `ts`, `inuse`, `location`.
|
JSON parsing supports JSONObject or JSONArray. The following JSON sample data can automatically parse fields: `groupid`, `voltage`, `current`, `ts`, `inuse`, `location`.
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"}
|
||||||
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"}
|
||||||
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}
|
||||||
|
@ -91,7 +91,7 @@ JSON parsing supports JSONObject or JSONArray. The following JSON sample data ca
|
||||||
|
|
||||||
Or
|
Or
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
[{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"},
|
[{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"},
|
||||||
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"},
|
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"},
|
||||||
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}]
|
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}]
|
||||||
|
@ -101,7 +101,7 @@ Subsequent examples will only explain using JSONObject.
|
||||||
|
|
||||||
The following nested JSON data can automatically parse fields `groupid`, `data_voltage`, `data_current`, `ts`, `inuse`, `location_0_province`, `location_0_city`, `location_0_datun`, and you can also choose which fields to parse and set aliases for the parsed fields.
|
The following nested JSON data can automatically parse fields `groupid`, `data_voltage`, `data_current`, `ts`, `inuse`, `location_0_province`, `location_0_city`, `location_0_datun`, and you can also choose which fields to parse and set aliases for the parsed fields.
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{"groupid": 170001, "data": { "voltage": "221V", "current": 12.3 }, "ts": "2023-12-18T22:12:00", "inuse": true, "location": [{"province": "beijing", "city":"chaoyang", "street": "datun"}]}
|
{"groupid": 170001, "data": { "voltage": "221V", "current": 12.3 }, "ts": "2023-12-18T22:12:00", "inuse": true, "location": [{"province": "beijing", "city":"chaoyang", "street": "datun"}]}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ The following nested JSON data can automatically parse fields `groupid`, `data_v
|
||||||
|
|
||||||
You can use **named capture groups** in regular expressions to extract multiple fields from any string (text) field. As shown in the figure, extract fields such as access IP, timestamp, and accessed URL from nginx logs.
|
You can use **named capture groups** in regular expressions to extract multiple fields from any string (text) field. As shown in the figure, extract fields such as access IP, timestamp, and accessed URL from nginx logs.
|
||||||
|
|
||||||
``` re
|
```regex
|
||||||
(?<ip>\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b)\s-\s-\s\[(?<ts>\d{2}/\w{3}/\d{4}:\d{2}:\d{2}:\d{2}\s\+\d{4})\]\s"(?<method>[A-Z]+)\s(?<url>[^\s"]+).*(?<status>\d{3})\s(?<length>\d+)
|
(?<ip>\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b)\s-\s-\s\[(?<ts>\d{2}/\w{3}/\d{4}:\d{2}:\d{2}:\d{2}\s\+\d{4})\]\s"(?<method>[A-Z]+)\s(?<url>[^\s"]+).*(?<status>\d{3})\s(?<length>\d+)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ Custom rhai syntax scripts for parsing input data (refer to `https://rhai.rs/boo
|
||||||
|
|
||||||
For example, for data reporting three-phase voltage values, which are entered into three subtables respectively, such data needs to be parsed
|
For example, for data reporting three-phase voltage values, which are entered into three subtables respectively, such data needs to be parsed
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{
|
{
|
||||||
"ts": "2024-06-27 18:00:00",
|
"ts": "2024-06-27 18:00:00",
|
||||||
"voltage": "220.1,220.3,221.1",
|
"voltage": "220.1,220.3,221.1",
|
||||||
|
@ -164,7 +164,7 @@ The final parsing result is shown below:
|
||||||
|
|
||||||
The parsed data may still not meet the data requirements of the target table. For example, the original data collected by a smart meter is as follows (in json format):
|
The parsed data may still not meet the data requirements of the target table. For example, the original data collected by a smart meter is as follows (in json format):
|
||||||
|
|
||||||
``` json
|
```json
|
||||||
{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "221V", "current": 12.3, "ts": "2023-12-18T22:12:00", "inuse": true, "location": "beijing.chaoyang.datun"}
|
||||||
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "220V", "current": 12.2, "ts": "2023-12-18T22:12:02", "inuse": true, "location": "beijing.chaoyang.datun"}
|
||||||
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}
|
{"groupid": 170001, "voltage": "216V", "current": 12.5, "ts": "2023-12-18T22:12:04", "inuse": false, "location": "beijing.chaoyang.datun"}
|
||||||
|
|
|
@ -83,14 +83,14 @@ Next, create a supertable (STABLE) named `meters`, whose table structure include
|
||||||
|
|
||||||
Create Database
|
Create Database
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
||||||
--data 'CREATE DATABASE IF NOT EXISTS power'
|
--data 'CREATE DATABASE IF NOT EXISTS power'
|
||||||
```
|
```
|
||||||
|
|
||||||
Create Table, specify the database as `power` in the URL
|
Create Table, specify the database as `power` in the URL
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql/power' \
|
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql/power' \
|
||||||
--data 'CREATE STABLE IF NOT EXISTS meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))'
|
--data 'CREATE STABLE IF NOT EXISTS meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))'
|
||||||
```
|
```
|
||||||
|
@ -167,7 +167,7 @@ NOW is an internal system function, defaulting to the current time of the client
|
||||||
|
|
||||||
Write data
|
Write data
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
||||||
--data 'INSERT INTO power.d1001 USING power.meters TAGS(2,'\''California.SanFrancisco'\'') VALUES (NOW + 1a, 10.30000, 219, 0.31000) (NOW + 2a, 12.60000, 218, 0.33000) (NOW + 3a, 12.30000, 221, 0.31000) power.d1002 USING power.meters TAGS(3, '\''California.SanFrancisco'\'') VALUES (NOW + 1a, 10.30000, 218, 0.25000)'
|
--data 'INSERT INTO power.d1001 USING power.meters TAGS(2,'\''California.SanFrancisco'\'') VALUES (NOW + 1a, 10.30000, 219, 0.31000) (NOW + 2a, 12.60000, 218, 0.33000) (NOW + 3a, 12.30000, 221, 0.31000) power.d1002 USING power.meters TAGS(3, '\''California.SanFrancisco'\'') VALUES (NOW + 1a, 10.30000, 218, 0.25000)'
|
||||||
```
|
```
|
||||||
|
@ -247,7 +247,7 @@ Rust connector also supports using **serde** for deserializing to get structured
|
||||||
|
|
||||||
Query Data
|
Query Data
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' \
|
||||||
--data 'SELECT ts, current, location FROM power.meters limit 100'
|
--data 'SELECT ts, current, location FROM power.meters limit 100'
|
||||||
```
|
```
|
||||||
|
@ -329,7 +329,7 @@ Below are code examples of setting reqId to execute SQL in various language conn
|
||||||
|
|
||||||
Query data, specify reqId as 3
|
Query data, specify reqId as 3
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql?req_id=3' \
|
curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql?req_id=3' \
|
||||||
--data 'SELECT ts, current, location FROM power.meters limit 1'
|
--data 'SELECT ts, current, location FROM power.meters limit 1'
|
||||||
```
|
```
|
||||||
|
|
|
@ -273,19 +273,19 @@ To better operate the above data structures, some convenience functions are prov
|
||||||
|
|
||||||
Create table:
|
Create table:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
create table battery(ts timestamp, vol1 float, vol2 float, vol3 float, deviceId varchar(16));
|
create table battery(ts timestamp, vol1 float, vol2 float, vol3 float, deviceId varchar(16));
|
||||||
```
|
```
|
||||||
|
|
||||||
Create custom function:
|
Create custom function:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
create aggregate function max_vol as '/root/udf/libmaxvol.so' outputtype binary(64) bufsize 10240 language 'C';
|
create aggregate function max_vol as '/root/udf/libmaxvol.so' outputtype binary(64) bufsize 10240 language 'C';
|
||||||
```
|
```
|
||||||
|
|
||||||
Use custom function:
|
Use custom function:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
select max_vol(vol1, vol2, vol3, deviceid) from battery;
|
select max_vol(vol1, vol2, vol3, deviceid) from battery;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ When developing UDFs in Python, you need to implement the specified interface fu
|
||||||
|
|
||||||
The interface for scalar functions is as follows.
|
The interface for scalar functions is as follows.
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
def process(input: datablock) -> tuple[output_type]:
|
def process(input: datablock) -> tuple[output_type]:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ The main parameters are as follows:
|
||||||
|
|
||||||
The interface for aggregate functions is as follows.
|
The interface for aggregate functions is as follows.
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
def start() -> bytes:
|
def start() -> bytes:
|
||||||
def reduce(inputs: datablock, buf: bytes) -> bytes
|
def reduce(inputs: datablock, buf: bytes) -> bytes
|
||||||
def finish(buf: bytes) -> output_type:
|
def finish(buf: bytes) -> output_type:
|
||||||
|
@ -365,7 +365,7 @@ Finally, when all row data blocks have been processed, the finish function is ca
|
||||||
|
|
||||||
The interfaces for initialization and destruction are as follows.
|
The interfaces for initialization and destruction are as follows.
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
def init()
|
def init()
|
||||||
def destroy()
|
def destroy()
|
||||||
```
|
```
|
||||||
|
@ -381,7 +381,7 @@ Parameter description:
|
||||||
|
|
||||||
The template for developing scalar functions in Python is as follows.
|
The template for developing scalar functions in Python is as follows.
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
def init():
|
def init():
|
||||||
# initialization
|
# initialization
|
||||||
def destroy():
|
def destroy():
|
||||||
|
@ -393,7 +393,7 @@ def process(input: datablock) -> tuple[output_type]:
|
||||||
|
|
||||||
The template for developing aggregate functions in Python is as follows.
|
The template for developing aggregate functions in Python is as follows.
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
def init():
|
def init():
|
||||||
#initialization
|
#initialization
|
||||||
def destroy():
|
def destroy():
|
||||||
|
@ -828,7 +828,7 @@ Through this example, we learned how to define aggregate functions and print cus
|
||||||
<details>
|
<details>
|
||||||
<summary>pybitand.py</summary>
|
<summary>pybitand.py</summary>
|
||||||
|
|
||||||
```Python
|
```python
|
||||||
{{#include tests/script/sh/pybitand.py}}
|
{{#include tests/script/sh/pybitand.py}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ TDengine is designed for various writing scenarios, and many of these scenarios
|
||||||
|
|
||||||
### Syntax
|
### Syntax
|
||||||
|
|
||||||
```SQL
|
```sql
|
||||||
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY'];
|
||||||
SHOW COMPACTS [compact_id];
|
SHOW COMPACTS [compact_id];
|
||||||
KILL COMPACT compact_id;
|
KILL COMPACT compact_id;
|
||||||
|
@ -41,7 +41,7 @@ KILL COMPACT compact_id;
|
||||||
|
|
||||||
When one or more nodes in a multi-replica cluster restart due to upgrades or other reasons, it may lead to an imbalance in the load among the various dnodes in the cluster. In extreme cases, all vgroup leaders may be located on the same dnode. To solve this problem, you can use the following commands, which were first released in version 3.0.4.0. It is recommended to use the latest version as much as possible.
|
When one or more nodes in a multi-replica cluster restart due to upgrades or other reasons, it may lead to an imbalance in the load among the various dnodes in the cluster. In extreme cases, all vgroup leaders may be located on the same dnode. To solve this problem, you can use the following commands, which were first released in version 3.0.4.0. It is recommended to use the latest version as much as possible.
|
||||||
|
|
||||||
```SQL
|
```sql
|
||||||
balance vgroup leader; # Rebalance all vgroup leaders
|
balance vgroup leader; # Rebalance all vgroup leaders
|
||||||
balance vgroup leader on <vgroup_id>; # Rebalance a vgroup leader
|
balance vgroup leader on <vgroup_id>; # Rebalance a vgroup leader
|
||||||
balance vgroup leader database <database_name>; # Rebalance all vgroup leaders within a database
|
balance vgroup leader database <database_name>; # Rebalance all vgroup leaders within a database
|
||||||
|
|
|
@ -121,7 +121,7 @@ The cost of using object storage services is related to the amount of data store
|
||||||
|
|
||||||
When the TSDB time-series data exceeds the time specified by the `s3_keeplocal` parameter, the related data files will be split into multiple file blocks, each with a default size of 512 MB (`s3_chunkpages * tsdb_pagesize`). Except for the last file block, which is retained on the local file system, the rest of the file blocks are uploaded to the object storage service.
|
When the TSDB time-series data exceeds the time specified by the `s3_keeplocal` parameter, the related data files will be split into multiple file blocks, each with a default size of 512 MB (`s3_chunkpages * tsdb_pagesize`). Except for the last file block, which is retained on the local file system, the rest of the file blocks are uploaded to the object storage service.
|
||||||
|
|
||||||
```math
|
```text
|
||||||
Upload Count = Data File Size / (s3_chunkpages * tsdb_pagesize) - 1
|
Upload Count = Data File Size / (s3_chunkpages * tsdb_pagesize) - 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ During query operations, if data in object storage needs to be accessed, TSDB do
|
||||||
|
|
||||||
Adjacent multiple data pages are downloaded as a single data block from object storage to reduce the number of downloads. The size of each data page is specified by the `tsdb_pagesize` parameter when creating the database, with a default of 4 KB.
|
Adjacent multiple data pages are downloaded as a single data block from object storage to reduce the number of downloads. The size of each data page is specified by the `tsdb_pagesize` parameter when creating the database, with a default of 4 KB.
|
||||||
|
|
||||||
```math
|
```text
|
||||||
Download Count = Number of Data Blocks Needed for Query - Number of Cached Data Blocks
|
Download Count = Number of Data Blocks Needed for Query - Number of Cached Data Blocks
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ For deployment methods, please refer to the [Flexify](https://azuremarketplace.m
|
||||||
|
|
||||||
In the configuration file /etc/taos/taos.cfg, add parameters for S3 access:
|
In the configuration file /etc/taos/taos.cfg, add parameters for S3 access:
|
||||||
|
|
||||||
```cfg
|
```text
|
||||||
s3EndPoint http //20.191.157.23,http://20.191.157.24,http://20.191.157.25
|
s3EndPoint http //20.191.157.23,http://20.191.157.24,http://20.191.157.25
|
||||||
s3AccessKey FLIOMMNL0:uhRNdeZMLD4wo,ABCIOMMN:uhRNdeZMD4wog,DEFOMMNL049ba:uhRNdeZMLD4wogXd
|
s3AccessKey FLIOMMNL0:uhRNdeZMLD4wo,ABCIOMMN:uhRNdeZMD4wog,DEFOMMNL049ba:uhRNdeZMLD4wogXd
|
||||||
s3BucketName td-test
|
s3BucketName td-test
|
||||||
|
|
|
@ -18,7 +18,7 @@ create user user_name pass'password' [sysinfo {1|0}]
|
||||||
The parameters are explained as follows.
|
The parameters are explained as follows.
|
||||||
|
|
||||||
- user_name: Up to 23 B long.
|
- user_name: Up to 23 B long.
|
||||||
- password: Up to 128 B long, valid characters include letters and numbers as well as special characters other than single and double quotes, apostrophes, backslashes, and spaces, and it cannot be empty.
|
- password: The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. Special characters include `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`.
|
||||||
- sysinfo: Whether the user can view system information. 1 means they can view it, 0 means they cannot. System information includes server configuration information, various node information such as dnode, query node (qnode), etc., as well as storage-related information, etc. The default is to view system information.
|
- sysinfo: Whether the user can view system information. 1 means they can view it, 0 means they cannot. System information includes server configuration information, various node information such as dnode, query node (qnode), etc., as well as storage-related information, etc. The default is to view system information.
|
||||||
|
|
||||||
The following SQL can create a user named test with the password 123456 who can view system information.
|
The following SQL can create a user named test with the password 123456 who can view system information.
|
||||||
|
|
|
@ -140,7 +140,7 @@ Finally, click the "Create" button at the bottom left to save the rule.
|
||||||
|
|
||||||
## Write a Mock Test Program
|
## Write a Mock Test Program
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
{{#include docs/examples/other/mock.js}}
|
{{#include docs/examples/other/mock.js}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ curl http://localhost:8083/connectors
|
||||||
|
|
||||||
If all components have started successfully, the following output will be displayed:
|
If all components have started successfully, the following output will be displayed:
|
||||||
|
|
||||||
```txt
|
```text
|
||||||
[]
|
[]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ If the above command is executed successfully, the following output will be disp
|
||||||
|
|
||||||
Prepare a text file with test data, content as follows:
|
Prepare a text file with test data, content as follows:
|
||||||
|
|
||||||
```txt title="test-data.txt"
|
```text title="test-data.txt"
|
||||||
meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249000000
|
meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249000000
|
||||||
meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250000000
|
meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250000000
|
||||||
meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249000000
|
meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249000000
|
||||||
|
@ -303,7 +303,7 @@ kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --t
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
```txt
|
```text
|
||||||
......
|
......
|
||||||
meters,location="California.SanFrancisco",groupid=2i32 current=10.3f32,voltage=219i32,phase=0.31f32 1538548685000000000
|
meters,location="California.SanFrancisco",groupid=2i32 current=10.3f32,voltage=219i32,phase=0.31f32 1538548685000000000
|
||||||
meters,location="California.SanFrancisco",groupid=2i32 current=12.6f32,voltage=218i32,phase=0.33f32 1538548695000000000
|
meters,location="California.SanFrancisco",groupid=2i32 current=12.6f32,voltage=218i32,phase=0.33f32 1538548695000000000
|
||||||
|
|
|
@ -60,7 +60,7 @@ Click `Save & Test` to test, if successful, it will prompt: `TDengine Data sourc
|
||||||
|
|
||||||
For users using Grafana version 7.x or configuring with [Grafana Provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/), you can use the installation script on the Grafana server to automatically install the plugin and add the data source Provisioning configuration file.
|
For users using Grafana version 7.x or configuring with [Grafana Provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/), you can use the installation script on the Grafana server to automatically install the plugin and add the data source Provisioning configuration file.
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
bash -c "$(curl -fsSL \
|
bash -c "$(curl -fsSL \
|
||||||
https://raw.githubusercontent.com/taosdata/grafanaplugin/master/install.sh)" -- \
|
https://raw.githubusercontent.com/taosdata/grafanaplugin/master/install.sh)" -- \
|
||||||
-a http://localhost:6041 \
|
-a http://localhost:6041 \
|
||||||
|
@ -77,7 +77,7 @@ Save the script and execute `./install.sh --help` to view detailed help document
|
||||||
|
|
||||||
Use the [`grafana-cli` command line tool](https://grafana.com/docs/grafana/latest/administration/cli/) to install the plugin [installation](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation).
|
Use the [`grafana-cli` command line tool](https://grafana.com/docs/grafana/latest/administration/cli/) to install the plugin [installation](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation).
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
grafana-cli plugins install tdengine-datasource
|
grafana-cli plugins install tdengine-datasource
|
||||||
# with sudo
|
# with sudo
|
||||||
sudo -u grafana grafana-cli plugins install tdengine-datasource
|
sudo -u grafana grafana-cli plugins install tdengine-datasource
|
||||||
|
@ -85,7 +85,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource
|
||||||
|
|
||||||
Alternatively, download the .zip file from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) to your local machine and unzip it into the Grafana plugins directory. Example command line download is as follows:
|
Alternatively, download the .zip file from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) to your local machine and unzip it into the Grafana plugins directory. Example command line download is as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
GF_VERSION=3.5.1
|
GF_VERSION=3.5.1
|
||||||
# from GitHub
|
# from GitHub
|
||||||
wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip
|
wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip
|
||||||
|
@ -95,13 +95,13 @@ wget -O tdengine-datasource-$GF_VERSION.zip https://grafana.com/api/plugins/tden
|
||||||
|
|
||||||
For CentOS 7.2 operating system, unzip the plugin package into the /var/lib/grafana/plugins directory and restart Grafana.
|
For CentOS 7.2 operating system, unzip the plugin package into the /var/lib/grafana/plugins directory and restart Grafana.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
sudo unzip tdengine-datasource-$GF_VERSION.zip -d /var/lib/grafana/plugins/
|
sudo unzip tdengine-datasource-$GF_VERSION.zip -d /var/lib/grafana/plugins/
|
||||||
```
|
```
|
||||||
|
|
||||||
If Grafana is running in a Docker environment, you can use the following environment variable to set up automatic installation of the TDengine data source plugin:
|
If Grafana is running in a Docker environment, you can use the following environment variable to set up automatic installation of the TDengine data source plugin:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
GF_INSTALL_PLUGINS=tdengine-datasource
|
GF_INSTALL_PLUGINS=tdengine-datasource
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ Click `Save & Test` to test, if successful, it will prompt: `TDengine Data sourc
|
||||||
|
|
||||||
Refer to [Grafana containerized installation instructions](https://grafana.com/docs/grafana/next/setup-grafana/installation/docker/#install-plugins-in-the-docker-container). Use the following command to start a container and automatically install the TDengine plugin:
|
Refer to [Grafana containerized installation instructions](https://grafana.com/docs/grafana/next/setup-grafana/installation/docker/#install-plugins-in-the-docker-container). Use the following command to start a container and automatically install the TDengine plugin:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 3000:3000 \
|
-p 3000:3000 \
|
||||||
--name=grafana \
|
--name=grafana \
|
|
@ -31,7 +31,7 @@ The following parameter descriptions and examples use `<content>` as a placehold
|
||||||
|
|
||||||
In command line mode, taosX uses DSN to represent a data source (source or destination), a typical DSN is as follows:
|
In command line mode, taosX uses DSN to represent a data source (source or destination), a typical DSN is as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
# url-like
|
# url-like
|
||||||
<driver>[+<protocol>]://[[<username>:<password>@]<host>:<port>][/<object>][?<p1>=<v1>[&<p2>=<v2>]]
|
<driver>[+<protocol>]://[[<username>:<password>@]<host>:<port>][/<object>][?<p1>=<v1>[&<p2>=<v2>]]
|
||||||
|------|------------|---|-----------|-----------|------|------|----------|-----------------------|
|
|------|------------|---|-----------|-----------|------|------|----------|-----------------------|
|
||||||
|
@ -390,7 +390,7 @@ You can view the log files or use the `journalctl` command to view the logs of `
|
||||||
|
|
||||||
The command to view logs under Linux using `journalctl` is as follows:
|
The command to view logs under Linux using `journalctl` is as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
journalctl -u taosx [-f]
|
journalctl -u taosx [-f]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ uint32_t len: The binary length of this string (excluding `\0`).
|
||||||
|
|
||||||
**Return Value**:
|
**Return Value**:
|
||||||
|
|
||||||
``` c
|
```c
|
||||||
struct parser_resp_t {
|
struct parser_resp_t {
|
||||||
int e; // 0 if success.
|
int e; // 0 if success.
|
||||||
void* p; // Success if contains.
|
void* p; // Success if contains.
|
||||||
|
@ -589,7 +589,7 @@ When creation is successful, e = 0, p is the parser object.
|
||||||
|
|
||||||
Parse the input payload and return the result in JSON format [u8]. The returned JSON will be fully decoded using the default JSON parser (expanding the root array and all objects).
|
Parse the input payload and return the result in JSON format [u8]. The returned JSON will be fully decoded using the default JSON parser (expanding the root array and all objects).
|
||||||
|
|
||||||
``` c
|
```c
|
||||||
const char* parser_mutate(
|
const char* parser_mutate(
|
||||||
void* parser,
|
void* parser,
|
||||||
const uint8_t* in_ptr, uint32_t in_len,
|
const uint8_t* in_ptr, uint32_t in_len,
|
||||||
|
|
|
@ -26,7 +26,7 @@ The default configuration file for `Agent` is located at `/etc/taos/agent.toml`,
|
||||||
|
|
||||||
As shown below:
|
As shown below:
|
||||||
|
|
||||||
```TOML
|
```toml
|
||||||
# taosX service endpoint
|
# taosX service endpoint
|
||||||
#
|
#
|
||||||
#endpoint = "http://localhost:6055"
|
#endpoint = "http://localhost:6055"
|
||||||
|
@ -83,7 +83,7 @@ You don't need to be confused about how to set up the configuration file. Read a
|
||||||
|
|
||||||
On Linux systems, the `Agent` can be started with the Systemd command:
|
On Linux systems, the `Agent` can be started with the Systemd command:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
systemctl start taosx-agent
|
systemctl start taosx-agent
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -95,6 +95,6 @@ You can view the log files or use the `journalctl` command to view the logs of t
|
||||||
|
|
||||||
The command to view logs with `journalctl` on Linux is as follows:
|
The command to view logs with `journalctl` on Linux is as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
journalctl -u taosx-agent [-f]
|
journalctl -u taosx-agent [-f]
|
||||||
```
|
```
|
||||||
|
|
|
@ -143,13 +143,13 @@ For details on TDengine monitoring configuration, please refer to: [TDengine Mon
|
||||||
|
|
||||||
After installation, please use the `systemctl` command to start the taoskeeper service process.
|
After installation, please use the `systemctl` command to start the taoskeeper service process.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
systemctl start taoskeeper
|
systemctl start taoskeeper
|
||||||
```
|
```
|
||||||
|
|
||||||
Check if the service is working properly:
|
Check if the service is working properly:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
systemctl status taoskeeper
|
systemctl status taoskeeper
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ Query OK, 14 row(s) in set (0.006542s)
|
||||||
|
|
||||||
You can view the most recent report record of a supertable, such as:
|
You can view the most recent report record of a supertable, such as:
|
||||||
|
|
||||||
``` shell
|
```shell
|
||||||
taos> select last_row(*) from taosd_dnodes_info;
|
taos> select last_row(*) from taosd_dnodes_info;
|
||||||
last_row(_ts) | last_row(disk_engine) | last_row(system_net_in) | last_row(vnodes_num) | last_row(system_net_out) | last_row(uptime) | last_row(has_mnode) | last_row(io_read_disk) | last_row(error_log_count) | last_row(io_read) | last_row(cpu_cores) | last_row(has_qnode) | last_row(has_snode) | last_row(disk_total) | last_row(mem_engine) | last_row(info_log_count) | last_row(cpu_engine) | last_row(io_write_disk) | last_row(debug_log_count) | last_row(disk_used) | last_row(mem_total) | last_row(io_write) | last_row(masters) | last_row(cpu_system) | last_row(trace_log_count) | last_row(mem_free) |
|
last_row(_ts) | last_row(disk_engine) | last_row(system_net_in) | last_row(vnodes_num) | last_row(system_net_out) | last_row(uptime) | last_row(has_mnode) | last_row(io_read_disk) | last_row(error_log_count) | last_row(io_read) | last_row(cpu_cores) | last_row(has_qnode) | last_row(has_snode) | last_row(disk_total) | last_row(mem_engine) | last_row(info_log_count) | last_row(cpu_engine) | last_row(io_write_disk) | last_row(debug_log_count) | last_row(disk_used) | last_row(mem_total) | last_row(io_write) | last_row(masters) | last_row(cpu_system) | last_row(trace_log_count) | last_row(mem_free) |
|
||||||
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
|
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
|
||||||
|
|
|
@ -14,7 +14,7 @@ taosExplorer does not require separate installation. Starting from TDengine vers
|
||||||
|
|
||||||
Before starting taosExplorer, please make sure the content in the configuration file is correct.
|
Before starting taosExplorer, please make sure the content in the configuration file is correct.
|
||||||
|
|
||||||
```TOML
|
```toml
|
||||||
# This is an automatically generated configuration file for Explorer in [TOML](https://toml.io/) format.
|
# This is an automatically generated configuration file for Explorer in [TOML](https://toml.io/) format.
|
||||||
#
|
#
|
||||||
# Here is a full list of available options.
|
# Here is a full list of available options.
|
||||||
|
@ -148,7 +148,7 @@ Description:
|
||||||
|
|
||||||
Then start taosExplorer, you can directly execute taos-explorer in the command line or use the systemctl command:
|
Then start taosExplorer, you can directly execute taos-explorer in the command line or use the systemctl command:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
systemctl start taos-explorer # Linux
|
systemctl start taos-explorer # Linux
|
||||||
sc.exe start taos-explorer # Windows
|
sc.exe start taos-explorer # Windows
|
||||||
```
|
```
|
||||||
|
|
|
@ -171,7 +171,37 @@ Metric details:
|
||||||
5. **Writes**: Total number of writes
|
5. **Writes**: Total number of writes
|
||||||
6. **Other**: Total number of other requests
|
6. **Other**: Total number of other requests
|
||||||
|
|
||||||
There are also line charts for the above categories.
|
There are also line charts for the above categories.
|
||||||
|
|
||||||
|
### Automatic import of preconfigured alert rules
|
||||||
|
|
||||||
|
After summarizing user experience, 14 commonly used alert rules are sorted out. These alert rules can monitor key indicators of the TDengine cluster and report alerts, such as abnormal and exceeded indicators.
|
||||||
|
Starting from TDengine-Server 3.3.4.3 (TDengine-datasource 3.6.3), TDengine Datasource supports automatic import of preconfigured alert rules. You can import 14 alert rules to Grafana (version 11 or later) with one click.
|
||||||
|
In the TDengine-datasource setting interface, turn on the "Load Tengine Alert" switch, click the "Save & test" button, the plugin will automatically load the mentioned 14 alert rules. The rules will be placed in the Grafana alerts directory. If not required, turn off the "Load TDengine Alert" switch, and click the button next to "Clear TDengine Alert" to clear all the alert rules imported into this data source.
|
||||||
|
|
||||||
|
After importing, click on "Alert rules" on the left side of the Grafana interface to view all current alert rules. By configuring contact points, users can receive alert notifications.
|
||||||
|
|
||||||
|
The specific configuration of the 14 alert rules is as follows:
|
||||||
|
|
||||||
|
| alert rule| Rule threshold| Behavior when no data | Data scanning interval |Duration | SQL |
|
||||||
|
| ------ | --------- | ---------------- | ----------- |------- |----------------------|
|
||||||
|
|CPU load of dnode node|average > 80%|Trigger alert|5 minutes|5 minutes |`select now(), dnode_id, last(cpu_system) as cup_use from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts < now partition by dnode_id having first(_ts) > 0 `|
|
||||||
|
|Memory of dnode node |average > 60%|Trigger alert|5 minutes|5 minutes|`select now(), dnode_id, last(mem_engine) / last(mem_total) * 100 as taosd from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts <now partition by dnode_id`|
|
||||||
|
|Disk capacity occupancy of dnode nodes | > 80%|Trigger alert|5 minutes|5 minutes|`select now(), dnode_id, data_dir_level, data_dir_name, last(used) / last(total) * 100 as used from log.taosd_dnodes_data_dirs where _ts >= (now - 5m) and _ts < now partition by dnode_id, data_dir_level, data_dir_name`|
|
||||||
|
|Authorization expires |< 60天|Trigger alert|1 day|0 0 seconds|`select now(), cluster_id, last(grants_expire_time) / 86400 as expire_time from log.taosd_cluster_info where _ts >= (now - 24h) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|
||||||
|
|The used measurement points has reached the authorized number|>= 90%|Trigger alert|1 day|0 seconds|`select now(), cluster_id, CASE WHEN max(grants_timeseries_total) > 0.0 THEN max(grants_timeseries_used) /max(grants_timeseries_total) * 100.0 ELSE 0.0 END AS result from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1m) > 0`|
|
||||||
|
|Number of concurrent query requests | > 100|Do not trigger alert|1 minute|0 seconds|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries`|
|
||||||
|
|Maximum time for slow query execution (no time window) |> 300秒|Do not trigger alert|1 minute|0 seconds|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries where exec_usec>300000000`|
|
||||||
|
|dnode offline |total != alive|Trigger alert|30 seconds|0 seconds|`select now(), cluster_id, last(dnodes_total) - last(dnodes_alive) as dnode_offline from log.taosd_cluster_info where _ts >= (now -30s) and _ts < now partition by cluster_id having first(_ts) > 0`|
|
||||||
|
|vnode offline |total != alive|Trigger alert|30 seconds|0 seconds|`select now(), cluster_id, last(vnodes_total) - last(vnodes_alive) as vnode_offline from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|
||||||
|
|Number of data deletion requests |> 0|Do not trigger alert|30 seconds|0 seconds|``select now(), count(`count`) as `delete_count` from log.taos_sql_req where sql_type = 'delete' and _ts >= (now -30s) and _ts < now``|
|
||||||
|
|Adapter RESTful request fail |> 5|Do not trigger alert|30 seconds|0 seconds|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=0 and ts >= (now -30s) and ts < now``|
|
||||||
|
|Adapter WebSocket request fail |> 5|Do not trigger alert|30 seconds|0 seconds|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=1 and ts >= (now -30s) and ts < now``|
|
||||||
|
|Dnode data reporting is missing |< 3|Trigger alert|180 seconds|0 seconds|`select now(), cluster_id, count(*) as dnode_report from log.taosd_cluster_info where _ts >= (now -180s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1h) > 0`|
|
||||||
|
|Restart dnode |max(update_time) > last(update_time)|Trigger alert|90 seconds|0 seconds|`select now(), dnode_id, max(uptime) - last(uptime) as dnode_restart from log.taosd_dnodes_info where _ts >= (now - 90s) and _ts < now partition by dnode_id`|
|
||||||
|
|
||||||
|
TDengine users can modify and improve these alert rules according to their own business needs. In Grafana 7.5 and below versions, the Dashboard and Alert rules functions are combined, while in subsequent new versions, the two functions are separated. To be compatible with Grafana7.5 and below versions, an Alert Used Only panel has been added to the TDinsight panel, which is only required for Grafana7.5 and below versions.
|
||||||
|
|
||||||
|
|
||||||
## Upgrade
|
## Upgrade
|
||||||
|
|
||||||
|
@ -248,13 +278,13 @@ The new version of the plugin uses the Grafana unified alerting feature, the `-E
|
||||||
|
|
||||||
Assuming you start the TDengine database on the host `tdengine` with HTTP API port `6041`, user `root1`, and password `pass5ord`. Execute the script:
|
Assuming you start the TDengine database on the host `tdengine` with HTTP API port `6041`, user `root1`, and password `pass5ord`. Execute the script:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord
|
./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to monitor multiple TDengine clusters, you need to set up multiple TDinsight dashboards. Setting up a non-default TDinsight requires some changes: the `-n` `-i` `-t` options need to be changed to non-default names, and if using the built-in SMS alert feature, `-N` and `-L` should also be changed.
|
If you want to monitor multiple TDengine clusters, you need to set up multiple TDinsight dashboards. Setting up a non-default TDinsight requires some changes: the `-n` `-i` `-t` options need to be changed to non-default names, and if using the built-in SMS alert feature, `-N` and `-L` should also be changed.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1'
|
sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1'
|
||||||
```
|
```
|
||||||
|
|
|
@ -10,7 +10,7 @@ The TDengine command line program (hereinafter referred to as TDengine CLI) is t
|
||||||
|
|
||||||
To enter the TDengine CLI, simply execute `taos` in the terminal.
|
To enter the TDengine CLI, simply execute `taos` in the terminal.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
taos
|
taos
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ There are many other parameters:
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
taos -h h1.taos.com -s "use db; show tables;"
|
taos -h h1.taos.com -s "use db; show tables;"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ taosBenchmark supports comprehensive performance testing for TDengine, and the T
|
||||||
|
|
||||||
Execute the following command to quickly experience taosBenchmark performing a write performance test on TDengine based on the default configuration.
|
Execute the following command to quickly experience taosBenchmark performing a write performance test on TDengine based on the default configuration.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
taosBenchmark
|
taosBenchmark
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ When running without parameters, taosBenchmark by default connects to the TDengi
|
||||||
|
|
||||||
When running taosBenchmark using command line parameters and controlling its behavior, the `-f <json file>` parameter cannot be used. All configuration parameters must be specified through the command line. Below is an example of using command line mode to test the write performance of taosBenchmark.
|
When running taosBenchmark using command line parameters and controlling its behavior, the `-f <json file>` parameter cannot be used. All configuration parameters must be specified through the command line. Below is an example of using command line mode to test the write performance of taosBenchmark.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
taosBenchmark -I stmt -n 200 -t 100
|
taosBenchmark -I stmt -n 200 -t 100
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ The taosBenchmark installation package includes examples of configuration files,
|
||||||
|
|
||||||
Use the following command line to run taosBenchmark and control its behavior through a configuration file.
|
Use the following command line to run taosBenchmark and control its behavior through a configuration file.
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
taosBenchmark -f <json file>
|
taosBenchmark -f <json file>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ ALTER TABLE [db_name.]tb_name alter_table_clause
|
||||||
|
|
||||||
alter_table_clause: {
|
alter_table_clause: {
|
||||||
alter_table_options
|
alter_table_options
|
||||||
| SET tag tag_name = new_tag_value,tag_name2=new_tag2_value...
|
| SET tag tag_name = new_tag_value, tag_name2=new_tag2_value ...
|
||||||
}
|
}
|
||||||
|
|
||||||
alter_table_options:
|
alter_table_options:
|
||||||
|
@ -194,7 +194,7 @@ alter_table_option: {
|
||||||
### Modify Subtable Tag Value
|
### Modify Subtable Tag Value
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
ALTER TABLE tb_name SET TAG tag_name1=new_tag_value1,tag_name2=new_tag_value2...;
|
ALTER TABLE tb_name SET TAG tag_name1=new_tag_value1, tag_name2=new_tag_value2 ...;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Modify Table Lifespan
|
### Modify Table Lifespan
|
||||||
|
|
|
@ -210,19 +210,19 @@ However, renaming individual columns is not supported for `first(*)`, `last(*)`,
|
||||||
|
|
||||||
Retrieve all subtable names and related tag information from a supertable:
|
Retrieve all subtable names and related tag information from a supertable:
|
||||||
|
|
||||||
```mysql
|
```sql
|
||||||
SELECT TAGS TBNAME, location FROM meters;
|
SELECT TAGS TBNAME, location FROM meters;
|
||||||
```
|
```
|
||||||
|
|
||||||
It is recommended that users query the subtable tag information of supertables using the INS_TAGS system table under INFORMATION_SCHEMA, for example, to get all subtable names and tag values of the supertable meters:
|
It is recommended that users query the subtable tag information of supertables using the INS_TAGS system table under INFORMATION_SCHEMA, for example, to get all subtable names and tag values of the supertable meters:
|
||||||
|
|
||||||
```mysql
|
```sql
|
||||||
SELECT table_name, tag_name, tag_type, tag_value FROM information_schema.ins_tags WHERE stable_name='meters';
|
SELECT table_name, tag_name, tag_type, tag_value FROM information_schema.ins_tags WHERE stable_name='meters';
|
||||||
```
|
```
|
||||||
|
|
||||||
Count the number of subtables under a supertable:
|
Count the number of subtables under a supertable:
|
||||||
|
|
||||||
```mysql
|
```sql
|
||||||
SELECT COUNT(*) FROM (SELECT DISTINCT TBNAME FROM meters);
|
SELECT COUNT(*) FROM (SELECT DISTINCT TBNAME FROM meters);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ SELECT CURRENT_USER();
|
||||||
|
|
||||||
### Syntax
|
### Syntax
|
||||||
|
|
||||||
```txt
|
```text
|
||||||
WHERE (column|tbname) match/MATCH/nmatch/NMATCH _regex_
|
WHERE (column|tbname) match/MATCH/nmatch/NMATCH _regex_
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ The length of the regular match string cannot exceed 128 bytes. You can set and
|
||||||
|
|
||||||
### Syntax
|
### Syntax
|
||||||
|
|
||||||
```txt
|
```text
|
||||||
CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END
|
CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END
|
||||||
CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END
|
CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END
|
||||||
```
|
```
|
||||||
|
@ -493,7 +493,7 @@ SELECT ... FROM (SELECT ... FROM ...) ...;
|
||||||
|
|
||||||
## UNION ALL Clause
|
## UNION ALL Clause
|
||||||
|
|
||||||
```txt title=Syntax
|
```text title=Syntax
|
||||||
SELECT ...
|
SELECT ...
|
||||||
UNION ALL SELECT ...
|
UNION ALL SELECT ...
|
||||||
[UNION ALL SELECT ...]
|
[UNION ALL SELECT ...]
|
||||||
|
|
|
@ -417,7 +417,7 @@ MOD(expr1, expr2)
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
``` sql
|
```sql
|
||||||
taos> select mod(10,3);
|
taos> select mod(10,3);
|
||||||
mod(10,3) |
|
mod(10,3) |
|
||||||
============================
|
============================
|
||||||
|
@ -454,7 +454,7 @@ RAND([seed])
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
``` sql
|
```sql
|
||||||
taos> select rand();
|
taos> select rand();
|
||||||
rand() |
|
rand() |
|
||||||
============================
|
============================
|
||||||
|
|
|
@ -13,14 +13,14 @@ CREATE USER user_name PASS 'password' [SYSINFO {1|0}];
|
||||||
|
|
||||||
The username can be up to 23 bytes long.
|
The username can be up to 23 bytes long.
|
||||||
|
|
||||||
The password can be up to 31 bytes long. The password can include letters, numbers, and special characters except for single quotes, double quotes, backticks, backslashes, and spaces, and it cannot be an empty string.
|
The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. Special characters include `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`.
|
||||||
|
|
||||||
`SYSINFO` indicates whether the user can view system information. `1` means they can view, `0` means they have no permission to view. System information includes service configuration, dnode, vnode, storage, etc. The default value is `1`.
|
`SYSINFO` indicates whether the user can view system information. `1` means they can view, `0` means they have no permission to view. System information includes service configuration, dnode, vnode, storage, etc. The default value is `1`.
|
||||||
|
|
||||||
In the example below, we create a user with the password `123456` who can view system information.
|
In the example below, we create a user with the password `abc123!@#` who can view system information.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
taos> create user test pass '123456' sysinfo 1;
|
taos> create user test pass 'abc123!@#' sysinfo 1;
|
||||||
Query OK, 0 of 0 rows affected (0.001254s)
|
Query OK, 0 of 0 rows affected (0.001254s)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,14 @@ In this document, it specifically refers to the internal levels of the second-le
|
||||||
|
|
||||||
- Default compression algorithms list and applicable range for each data type
|
- Default compression algorithms list and applicable range for each data type
|
||||||
|
|
||||||
| Data Type | Available Encoding Algorithms | Default Encoding Algorithm | Available Compression Algorithms|Default Compression Algorithm| Default Compression Level|
|
| Data Type |Available Encoding Algorithms | Default Encoding Algorithm | Available Compression Algorithms | Default Compression Algorithm | Default Compression Level |
|
||||||
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
|:------------------------------------:|:-------------------------:|:-----------:|:--------------------:|:----:|:------:|
|
||||||
| tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
| int/uint | disabled/simple8b | simple8b | lz4/zlib/zstd/xz | lz4 | medium |
|
||||||
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
| tinyint/untinyint/smallint/usmallint | disabled/simple8b | simple8b | lz4/zlib/zstd/xz | zlib | medium |
|
||||||
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|lz4| medium|
|
| bigint/ubigint/timestamp | disabled/simple8b/delta-i | delta-i | lz4/zlib/zstd/xz | lz4 | medium |
|
||||||
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
| float/double | disabled/delta-d | delta-d | lz4/zlib/zstd/xz/tsz | lz4 | medium |
|
||||||
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
| binary/nchar | disabled | disabled | lz4/zlib/zstd/xz | zstd | medium |
|
||||||
|
| bool | disabled/bit-packing | bit-packing | lz4/zlib/zstd/xz | zstd | medium |
|
||||||
|
|
||||||
## SQL Syntax
|
## SQL Syntax
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ For the source code of the example programs, please refer to: [Example Programs]
|
||||||
|
|
||||||
The Data Source Name has a generic format, similar to [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php), but without the type prefix (brackets indicate optional):
|
The Data Source Name has a generic format, similar to [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php), but without the type prefix (brackets indicate optional):
|
||||||
|
|
||||||
``` text
|
```text
|
||||||
[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&...¶mN=valueN]
|
[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&...¶mN=valueN]
|
||||||
```
|
```
|
||||||
|
|
|
@ -21,7 +21,7 @@ Below is an example using the `curl` tool in an Ubuntu environment (please confi
|
||||||
|
|
||||||
The following example lists all databases, please replace `h1.tdengine.com` and 6041 (default value) with the actual running TDengine service FQDN and port number:
|
The following example lists all databases, please replace `h1.tdengine.com` and 6041 (default value) with the actual running TDengine service FQDN and port number:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" \
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" \
|
||||||
-d "select name, ntables, status from information_schema.ins_databases;" \
|
-d "select name, ntables, status from information_schema.ins_databases;" \
|
||||||
h1.tdengine.com:6041/rest/sql
|
h1.tdengine.com:6041/rest/sql
|
||||||
|
@ -100,13 +100,13 @@ The BODY of the HTTP request contains a complete SQL statement. The data table i
|
||||||
|
|
||||||
Use `curl` to initiate an HTTP Request with custom authentication as follows:
|
Use `curl` to initiate an HTTP Request with custom authentication as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl -L -H "Authorization: Basic <TOKEN>" -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timezone[&req_id=req_id][&row_with_meta=true]]
|
curl -L -H "Authorization: Basic <TOKEN>" -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timezone[&req_id=req_id][&row_with_meta=true]]
|
||||||
```
|
```
|
||||||
|
|
||||||
Or,
|
Or,
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timezone[&req_id=req_id][&row_with_meta=true]]
|
curl -L -u username:password -d "<SQL>" <ip>:<PORT>/rest/sql/[db_name][?tz=timezone[&req_id=req_id][&row_with_meta=true]]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ Column types use the following strings:
|
||||||
|
|
||||||
Prepare data
|
Prepare data
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
create database demo
|
create database demo
|
||||||
use demo
|
use demo
|
||||||
create table t(ts timestamp,c1 varbinary(20),c2 geometry(100))
|
create table t(ts timestamp,c1 varbinary(20),c2 geometry(100))
|
||||||
|
@ -288,7 +288,7 @@ insert into t values(now,'\x7f8290','point(100 100)')
|
||||||
|
|
||||||
Execute query
|
Execute query
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl --location 'http://<fqdn>:<port>/rest/sql' \
|
curl --location 'http://<fqdn>:<port>/rest/sql' \
|
||||||
--header 'Content-Type: text/plain' \
|
--header 'Content-Type: text/plain' \
|
||||||
--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \
|
--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \
|
||||||
|
@ -428,7 +428,7 @@ Data Query Return Example
|
||||||
|
|
||||||
HTTP requests need to include an authorization code `<TOKEN>`, used for identity verification. The authorization code is usually provided by the administrator and can be simply obtained by sending an `HTTP GET` request as follows:
|
HTTP requests need to include an authorization code `<TOKEN>`, used for identity verification. The authorization code is usually provided by the administrator and can be simply obtained by sending an `HTTP GET` request as follows:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl http://<fqnd>:<port>/rest/login/<username>/<password>
|
curl http://<fqnd>:<port>/rest/login/<username>/<password>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ Here, `fqdn` is the FQDN or IP address of the TDengine database, `port` is the p
|
||||||
|
|
||||||
Example of obtaining an authorization code:
|
Example of obtaining an authorization code:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl http://192.168.0.1:6041/rest/login/root/taosdata
|
curl http://192.168.0.1:6041/rest/login/root/taosdata
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ Return value:
|
||||||
|
|
||||||
- Query all records of table d1001 in the demo database:
|
- Query all records of table d1001 in the demo database:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||||
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
@ -509,7 +509,7 @@ Return value:
|
||||||
|
|
||||||
- Create database demo:
|
- Create database demo:
|
||||||
|
|
||||||
```bash
|
```shell
|
||||||
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||||
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "create database demo" 192.168.0.1:6041/rest/sql
|
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||||
```
|
```
|
||||||
|
@ -560,7 +560,7 @@ Return value:
|
||||||
|
|
||||||
#### TDengine 2.x response codes and message bodies
|
#### TDengine 2.x response codes and message bodies
|
||||||
|
|
||||||
```JSON
|
```json
|
||||||
{
|
{
|
||||||
"status": "succ",
|
"status": "succ",
|
||||||
"head": [
|
"head": [
|
||||||
|
@ -624,7 +624,7 @@ Return value:
|
||||||
|
|
||||||
#### TDengine 3.0 Response Codes and Message Body
|
#### TDengine 3.0 Response Codes and Message Body
|
||||||
|
|
||||||
```JSON
|
```json
|
||||||
{
|
{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
"column_meta": [
|
"column_meta": [
|
|
@ -119,7 +119,7 @@ This document details the server error codes that may be encountered when using
|
||||||
| 0x80000350 | User already exists | Create user, duplicate creation | Confirm if the operation is correct |
|
| 0x80000350 | User already exists | Create user, duplicate creation | Confirm if the operation is correct |
|
||||||
| 0x80000351 | Invalid user | User does not exist | Confirm if the operation is correct |
|
| 0x80000351 | Invalid user | User does not exist | Confirm if the operation is correct |
|
||||||
| 0x80000352 | Invalid user format | Incorrect format | Confirm if the operation is correct |
|
| 0x80000352 | Invalid user format | Incorrect format | Confirm if the operation is correct |
|
||||||
| 0x80000353 | Invalid password format | Incorrect format | Confirm if the operation is correct |
|
| 0x80000353 | Invalid password format | The password must be between 8 and 16 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. | Confirm the format of the password string |
|
||||||
| 0x80000354 | Can not get user from conn | Internal error | Report issue |
|
| 0x80000354 | Can not get user from conn | Internal error | Report issue |
|
||||||
| 0x80000355 | Too many users | (Enterprise only) Exceeding user limit | Adjust configuration |
|
| 0x80000355 | Too many users | (Enterprise only) Exceeding user limit | Adjust configuration |
|
||||||
| 0x80000357 | Authentication failure | Incorrect password | Confirm if the operation is correct |
|
| 0x80000357 | Authentication failure | Incorrect password | Confirm if the operation is correct |
|
||||||
|
|
|
@ -90,7 +90,7 @@ Batch insertion. Each insert statement can insert multiple records into one tabl
|
||||||
|
|
||||||
When inserting nchar type data containing Chinese characters on Windows, first ensure that the system's regional settings are set to China (this can be set in the Control Panel). At this point, the `taos` client in cmd should already be working properly; if developing a Java application in an IDE, such as Eclipse or IntelliJ, ensure that the file encoding in the IDE is set to GBK (which is the default encoding type for Java), then initialize the client configuration when creating the Connection, as follows:
|
When inserting nchar type data containing Chinese characters on Windows, first ensure that the system's regional settings are set to China (this can be set in the Control Panel). At this point, the `taos` client in cmd should already be working properly; if developing a Java application in an IDE, such as Eclipse or IntelliJ, ensure that the file encoding in the IDE is set to GBK (which is the default encoding type for Java), then initialize the client configuration when creating the Connection, as follows:
|
||||||
|
|
||||||
```JAVA
|
```java
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
|
properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
|
||||||
|
@ -145,7 +145,7 @@ Version 3.0 of TDengine includes a standalone component developed in Go called `
|
||||||
|
|
||||||
The Go language version requirement is 1.14 or higher. If there are Go compilation errors, often due to issues accessing Go mod in China, they can be resolved by setting Go environment variables:
|
The Go language version requirement is 1.14 or higher. If there are Go compilation errors, often due to issues accessing Go mod in China, they can be resolved by setting Go environment variables:
|
||||||
|
|
||||||
```sh
|
```shell
|
||||||
go env -w GO111MODULE=on
|
go env -w GO111MODULE=on
|
||||||
go env -w GOPROXY=https://goproxy.cn,direct
|
go env -w GOPROXY=https://goproxy.cn,direct
|
||||||
```
|
```
|
||||||
|
@ -196,7 +196,7 @@ Here are the solutions:
|
||||||
|
|
||||||
1. Create a file /Library/LaunchDaemons/limit.maxfiles.plist, write the following content (the example changes limit and maxfiles to 100,000, modify as needed):
|
1. Create a file /Library/LaunchDaemons/limit.maxfiles.plist, write the following content (the example changes limit and maxfiles to 100,000, modify as needed):
|
||||||
|
|
||||||
```plist
|
```xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
@ -286,4 +286,14 @@ This connection only reports the most basic information that does not involve an
|
||||||
This feature is an optional configuration item, which is enabled by default in the open-source version. The specific parameter is telemetryReporting, as explained in the [official documentation](../tdengine-reference/components/taosd/).
|
This feature is an optional configuration item, which is enabled by default in the open-source version. The specific parameter is telemetryReporting, as explained in the [official documentation](../tdengine-reference/components/taosd/).
|
||||||
You can disable this parameter at any time by modifying telemetryReporting to 0 in taos.cfg, then restarting the database service.
|
You can disable this parameter at any time by modifying telemetryReporting to 0 in taos.cfg, then restarting the database service.
|
||||||
Code located at: [https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c](https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c).
|
Code located at: [https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c](https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c).
|
||||||
Additionally, for the highly secure enterprise version, TDengine Enterprise, this parameter will not be operational.
|
Additionally, for the highly secure enterprise version, TDengine Enterprise, this parameter will not be operational.
|
||||||
|
|
||||||
|
### 31 What should I do if I encounter 'Sync leader is unreachable' when connecting to the cluster for the first time?
|
||||||
|
|
||||||
|
Reporting this error indicates that the first connection to the cluster was successful, but the IP address accessed for the first time was not the leader of mnode. An error occurred when the client attempted to establish a connection with the leader. The client searches for the leader node through EP, which specifies the fqdn and port number. There are two common reasons for this error:
|
||||||
|
|
||||||
|
- The ports of other dnodes in the cluster are not open
|
||||||
|
- The client's hosts file is not configured correctly
|
||||||
|
|
||||||
|
Therefore, first, check whether all ports on the server and cluster (default 6030 for native connections and 6041 for HTTP connections) are open; Next, check if the client's hosts file has configured the fqdn and IP information for all dnodes in the cluster.
|
||||||
|
If the issue still cannot be resolved, it is necessary to contact Taos technical personnel for support.
|
||||||
|
|
|
@ -4,11 +4,10 @@ sidebar_label: "安装部署"
|
||||||
---
|
---
|
||||||
|
|
||||||
### 环境准备
|
### 环境准备
|
||||||
使用 TDgpt 的高级时序数据分析功能需要在 TDengine 集群中安装部署 AI node(Anode)。Anode 可以运行在 Linux/Windows/MacOS 等平台上,同时需要 3.10 或以上版本的 Python 环境支持。
|
使用 TDgpt 的高级时序数据分析功能需要在 TDengine 集群中安装部署 AI node(Anode)。Anode 运行在 Linux 平台上,并需要 3.10 或以上版本的 Python 环境支持。
|
||||||
> 部署 Anode 需要 TDengine Enterprise 3.3.4.3 及以后版本,请首先确认搭配 Anode 使用的 TDengine 能够支持 Anode。
|
> 部署 Anode 需要 TDengine Enterprise 3.3.4.3 及以后版本,请首先确认搭配 Anode 使用的 TDengine 能够支持 Anode。
|
||||||
|
|
||||||
### 安装及卸载
|
### 安装及卸载
|
||||||
不同操作系统上安装及部署 Anode 有一些差异,主要是卸载操作、安装路径、服务启停等方面。本文以 Linux 系统为例,说明安装部署的流程。
|
|
||||||
使用 Linux 环境下的安装包 TDengine-enterprise-anode-1.x.x.tar.gz 可进行 Anode 的安装部署工作,命令如下:
|
使用 Linux 环境下的安装包 TDengine-enterprise-anode-1.x.x.tar.gz 可进行 Anode 的安装部署工作,命令如下:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -37,7 +36,7 @@ systemctl status taosanoded
|
||||||
|/usr/local/taos/taosanode/bin|可执行文件目录|
|
|/usr/local/taos/taosanode/bin|可执行文件目录|
|
||||||
|/usr/local/taos/taosanode/resource|资源文件目录,链接到文件夹 /var/lib/taos/taosanode/resource/|
|
|/usr/local/taos/taosanode/resource|资源文件目录,链接到文件夹 /var/lib/taos/taosanode/resource/|
|
||||||
|/usr/local/taos/taosanode/lib|库文件目录|
|
|/usr/local/taos/taosanode/lib|库文件目录|
|
||||||
|/var/lib/taos/taosanode/model/|模型文件目录,链接到文件夹 /var/lib/taos/taosanode/model|
|
|/usr/local/taos/taosanode/model/|模型文件目录,链接到文件夹 /var/lib/taos/taosanode/model|
|
||||||
|/var/log/taos/taosanode/|日志文件目录|
|
|/var/log/taos/taosanode/|日志文件目录|
|
||||||
|/etc/taos/taosanode.ini|配置文件|
|
|/etc/taos/taosanode.ini|配置文件|
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ pidfile = /usr/local/taos/taosanode/taosanode.pid
|
||||||
# conflict with systemctl, so do NOT uncomment this
|
# conflict with systemctl, so do NOT uncomment this
|
||||||
# daemonize = /var/log/taos/taosanode/taosanode.log
|
# daemonize = /var/log/taos/taosanode/taosanode.log
|
||||||
|
|
||||||
# log directory
|
# uWSGI log files
|
||||||
logto = /var/log/taos/taosanode/taosanode.log
|
logto = /var/log/taos/taosanode/taosanode.log
|
||||||
|
|
||||||
# wWSGI monitor port
|
# wWSGI monitor port
|
||||||
|
@ -74,7 +73,7 @@ stats = 127.0.0.1:8387
|
||||||
virtualenv = /usr/local/taos/taosanode/venv/
|
virtualenv = /usr/local/taos/taosanode/venv/
|
||||||
|
|
||||||
[taosanode]
|
[taosanode]
|
||||||
# default app log file
|
# default taosanode log file
|
||||||
app-log = /var/log/taos/taosanode/taosanode.app.log
|
app-log = /var/log/taos/taosanode/taosanode.app.log
|
||||||
|
|
||||||
# model storage directory
|
# model storage directory
|
||||||
|
|
|
@ -12,7 +12,7 @@ import wndata from './pic/white-noise-data.png'
|
||||||
<img src={activity} width="560" alt="预处理流程" />
|
<img src={activity} width="560" alt="预处理流程" />
|
||||||
|
|
||||||
TDgpt 首先对输入数据进行白噪声检查(White Noise Data check), 检查通过以后针对预测分析,还要进行输入(历史)数据的重采样和时间戳对齐处理(异常检测跳过数据重采样和时间戳对齐步骤)。
|
TDgpt 首先对输入数据进行白噪声检查(White Noise Data check), 检查通过以后针对预测分析,还要进行输入(历史)数据的重采样和时间戳对齐处理(异常检测跳过数据重采样和时间戳对齐步骤)。
|
||||||
预处理完成以后,再进行预测或异常检测操作。预处理过程部署于预测或异常检测处理逻辑的一部分。
|
预处理完成以后,再进行预测或异常检测操作。预处理过程不属于预测或异常检测处理逻辑的一部分。
|
||||||
|
|
||||||
### 白噪声检查
|
### 白噪声检查
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ description: 预测算法
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
taos> select * from foo;
|
taos> select * from foo;
|
||||||
ts | k |
|
ts | i32 |
|
||||||
========================================
|
========================================
|
||||||
2020-01-01 00:00:12.681 | 13 |
|
2020-01-01 00:00:12.681 | 13 |
|
||||||
2020-01-01 00:00:13.727 | 14 |
|
2020-01-01 00:00:13.727 | 14 |
|
||||||
|
@ -42,7 +42,7 @@ algo=expr1
|
||||||
|
|
||||||
```
|
```
|
||||||
1. `column_expr`:预测的时序数据列。与异常检测相同,只支持数值类型列输入。
|
1. `column_expr`:预测的时序数据列。与异常检测相同,只支持数值类型列输入。
|
||||||
2. `options`:异常检测函数的参数,使用规则与 anomaly_window 相同。预测支持 `conf`, `every`, `rows`, `start`, `rows` 几个控制参数,其含义如下:
|
2. `options`:预测函数的参数。字符串类型,其中使用 K=V 方式调用算法及相关参数。采用逗号分隔的 K=V 字符串表示,其中的字符串不需要使用单引号、双引号、或转义号等符号,不能使用中文及其他宽字符。预测支持 `conf`, `every`, `rows`, `start`, `rows` 几个控制参数,其含义如下:
|
||||||
|
|
||||||
### 参数说明
|
### 参数说明
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ return {
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from service import AbstractForecastService
|
from taosanalytics.service import AbstractForecastService
|
||||||
|
|
||||||
|
|
||||||
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
|
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
|
||||||
class _MyForecastService(AbstractForecastService):
|
class _MyForecastService(AbstractForecastService):
|
||||||
|
@ -51,12 +52,12 @@ class _MyForecastService(AbstractForecastService):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
""" 算法逻辑的核心实现"""
|
""" 算法逻辑的核心实现"""
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
"""这个预测算法固定返回 1 作为预测值,预测值的数量是用户通过 self.fc_rows 指定"""
|
"""这个预测算法固定返回 1 作为预测值,预测值的数量是用户通过 self.fc_rows 指定"""
|
||||||
ts_list = [self.start_ts + i * self.time_step for i in range(self.fc_rows)]
|
ts_list = [self.start_ts + i * self.time_step for i in range(self.fc_rows)]
|
||||||
res.app(ts_list) # 设置预测结果时间戳列
|
res.append(ts_list) # 设置预测结果时间戳列
|
||||||
|
|
||||||
"""生成全部为 1 的预测结果 """
|
"""生成全部为 1 的预测结果 """
|
||||||
res_list = [1] * self.fc_rows
|
res_list = [1] * self.fc_rows
|
||||||
|
@ -64,18 +65,18 @@ class _MyForecastService(AbstractForecastService):
|
||||||
|
|
||||||
"""检查用户输入,是否要求返回预测置信区间上下界"""
|
"""检查用户输入,是否要求返回预测置信区间上下界"""
|
||||||
if self.return_conf:
|
if self.return_conf:
|
||||||
"""对于没有计算预测置信区间上下界的算法,直接返回预测值作为上下界即可"""
|
"""对于没有计算预测置信区间上下界的算法,直接返回预测值作为上下界即可"""
|
||||||
bound_list = [1] * self.fc_rows
|
bound_list = [1] * self.fc_rows
|
||||||
res.append(bound_list) # 预测结果置信区间下界
|
res.append(bound_list) # 预测结果置信区间下界
|
||||||
res.append(bound_list) # 预测结果执行区间上界
|
res.append(bound_list) # 预测结果执行区间上界
|
||||||
|
|
||||||
"""返回结果"""
|
"""返回结果"""
|
||||||
return { "res": res, "mse": 0}
|
return {"res": res, "mse": 0}
|
||||||
|
|
||||||
|
|
||||||
def set_params(self, params):
|
def set_params(self, params):
|
||||||
"""该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑"""
|
"""该算法无需任何输入参数,直接调用父类函数,不处理算法参数设置逻辑"""
|
||||||
pass
|
return super().set_params(params)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
将该文件保存在 `./taosanalytics/algo/fc/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口中执行 `SHOW ANODES FULL` 能够看到新加入的算法。应用就可以通过 SQL 语句调用该预测算法。
|
将该文件保存在 `./taosanalytics/algo/fc/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口中执行 `SHOW ANODES FULL` 能够看到新加入的算法。应用就可以通过 SQL 语句调用该预测算法。
|
||||||
|
|
|
@ -16,7 +16,7 @@ sidebar_label: "异常检测"
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from service import AbstractAnomalyDetectionService
|
from taosanalytics.service import AbstractAnomalyDetectionService
|
||||||
|
|
||||||
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
|
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
|
||||||
class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
|
class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):
|
||||||
|
|
|
@ -19,24 +19,25 @@ Anode的主要目录结构如下图所示
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
.
|
.
|
||||||
|
├── bin
|
||||||
├── cfg
|
├── cfg
|
||||||
├── model
|
├── lib
|
||||||
│ └── ad_autoencoder
|
│ └── taosanalytics
|
||||||
├── release
|
│ ├── algo
|
||||||
├── script
|
│ │ ├── ad
|
||||||
└── taosanalytics
|
│ │ └── fc
|
||||||
├── algo
|
│ ├── misc
|
||||||
│ ├── ad
|
│ └── test
|
||||||
│ └── fc
|
├── log -> /var/log/taos/taosanode
|
||||||
├── misc
|
├── model -> /var/lib/taos/taosanode/model
|
||||||
└── test
|
└── venv -> /var/lib/taos/taosanode/venv
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|目录|说明|
|
|目录|说明|
|
||||||
|---|---|
|
|---|---|
|
||||||
|taosanalytics| 源代码目录,其下包含了算法具体保存目录 algo,放置杂项目录 misc,单元测试和集成测试目录 test。 algo 目录下 ad 保存异常检测算法代码,fc 目录保存预测算法代码|
|
|taosanalytics| 源代码目录,其下包含了算法具体保存目录 algo,放置杂项目录 misc,单元测试和集成测试目录 test。 algo 目录下 ad 保存异常检测算法代码,fc 目录保存预测算法代码|
|
||||||
|script|是安装脚本和发布脚本放置目录|
|
|venv| Python 虚拟环境|
|
||||||
|model|放置针对数据集完成的训练模型|
|
|model|放置针对数据集完成的训练模型|
|
||||||
|cfg|配置文件目录|
|
|cfg|配置文件目录|
|
||||||
|
|
||||||
|
@ -63,7 +64,8 @@ Anode采用算法自动加载模式,因此只识别符合命名约定的 Pytho
|
||||||
|
|
||||||
```SQL
|
```SQL
|
||||||
--- algo 后面的参数 name 即为类属性 `name`
|
--- algo 后面的参数 name 即为类属性 `name`
|
||||||
SELECT COUNT(*) FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
|
SELECT COUNT(*)
|
||||||
|
FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
|
||||||
```
|
```
|
||||||
|
|
||||||
## 添加具有模型的分析算法
|
## 添加具有模型的分析算法
|
||||||
|
@ -76,19 +78,10 @@ SELECT COUNT(*) FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
.
|
.
|
||||||
├── cfg
|
└── model
|
||||||
├── model
|
└── ad_autoencoder
|
||||||
│ └── ad_autoencoder
|
├── ad_autoencoder_foo.dat
|
||||||
│ ├── ad_autoencoder_foo.dat
|
└── ad_autoencoder_foo.info
|
||||||
│ └── ad_autoencoder_foo.info
|
|
||||||
├── release
|
|
||||||
├── script
|
|
||||||
└── taosanalytics
|
|
||||||
├── algo
|
|
||||||
│ ├── ad
|
|
||||||
│ └── fc
|
|
||||||
├── misc
|
|
||||||
└── test
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@ create user user_name pass'password' [sysinfo {1|0}]
|
||||||
```
|
```
|
||||||
|
|
||||||
相关参数说明如下。
|
相关参数说明如下。
|
||||||
- user_name:最长为 23 B。
|
- user_name:用户名最长不超过 23 个字节。
|
||||||
- password:最长为 128 B,合法字符包括字母和数字以及单双引号、撇号、反斜杠和空格以外的特殊字符,且不可以为空。
|
- password:密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类。特殊字符包括 `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`。
|
||||||
- sysinfo :用户是否可以查看系统信息。1 表示可以查看,0 表示不可以查看。系统信息包括服务端配置信息、服务端各种节点信息,如 dnode、查询节点(qnode)等,以及与存储相关的信息等。默认为可以查看系统信息。
|
- sysinfo :用户是否可以查看系统信息。1 表示可以查看,0 表示不可以查看。系统信息包括服务端配置信息、服务端各种节点信息,如 dnode、查询节点(qnode)等,以及与存储相关的信息等。默认为可以查看系统信息。
|
||||||
|
|
||||||
如下 SQL 可以创建密码为 123456 且可以查看系统信息的用户 test。
|
如下 SQL 可以创建密码为 abc123!@# 且可以查看系统信息的用户 test。
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
create user test pass '123456' sysinfo 1
|
create user test pass 'abc123!@#' sysinfo 1
|
||||||
```
|
```
|
||||||
|
|
||||||
### 查看用户
|
### 查看用户
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 212 KiB |
Binary file not shown.
After Width: | Height: | Size: 222 KiB |
Binary file not shown.
After Width: | Height: | Size: 95 KiB |
|
@ -145,6 +145,44 @@ TDinsight 仪表盘旨在提供 TDengine 相关资源的使用情况和状态,
|
||||||
|
|
||||||
还有上述分类的细分维度折线图。
|
还有上述分类的细分维度折线图。
|
||||||
|
|
||||||
|
### 预配置告警规则自动导入
|
||||||
|
|
||||||
|
涛思总结用户使用经验,整理出 14 个常用的告警规则(alert rule),能够对集群关键指标进行监测并及时上报指标异常、超限等告警信息。
|
||||||
|
从 TDengine-server 3.3.4.3 版本(tdengine-datasource 3.6.3)开始,TDengine Datasource 支持预配置告警规则自动导入功能,用户可将 14 个告警规则一键导入 Grafana(11 及以上版本),直接使用。
|
||||||
|
预配置告警规则导入方法如下图所示,在 tdengine-datasource setting 界面,打开 “Load Tengine Alert” 开关,点击 “Save & test” 按钮后,插件会自动加载上述告警规则, 规则会放入以数据源名称 + “-alert” 的 grafana 告警目录中。如不需要,关闭 “Load TDengine Alert” 开关,点击 “Clear TDengine Alert” 旁边的按钮则会清除此数据源已导入的所有告警规则。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
导入后,点击 Grafana 左侧 “Alert rules” ,可查看当前所有告警规则。
|
||||||
|
用户只需配置联络点(Contact points),即可获取告警通知。联络点配置方法见[告警配置](https://docs.taosdata.com/third-party/visual/grafana/#%E5%91%8A%E8%AD%A6%E9%85%8D%E7%BD%AE)。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
14 个告警规则具体配置如下:
|
||||||
|
|
||||||
|
| 规则名称| 规则阈值| 无监控数据时的行为 | 数据扫描间隔 |持续时间 | 执行SQL |
|
||||||
|
| ------ | --------- | ---------------- | ----------- |------- |----------------------|
|
||||||
|
|dnode 节点的CPU负载|均值 > 80%|触发告警|5分钟|5分钟 |`select now(), dnode_id, last(cpu_system) as cup_use from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts < now partition by dnode_id having first(_ts) > 0 `|
|
||||||
|
|dnode 节点的的内存 |均值 > 60%|触发告警|5分钟|5分钟|`select now(), dnode_id, last(mem_engine) / last(mem_total) * 100 as taosd from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts <now partition by dnode_id`|
|
||||||
|
|dnode 节点的磁盘容量占用 | > 80%|触发告警|5分钟|5分钟|`select now(), dnode_id, data_dir_level, data_dir_name, last(used) / last(total) * 100 as used from log.taosd_dnodes_data_dirs where _ts >= (now - 5m) and _ts < now partition by dnode_id, data_dir_level, data_dir_name`|
|
||||||
|
|集群授权到期 |< 60天|触发告警|1天|0秒|`select now(), cluster_id, last(grants_expire_time) / 86400 as expire_time from log.taosd_cluster_info where _ts >= (now - 24h) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|
||||||
|
|测点数达到授权测点数|>= 90%|触发告警|1天|0秒|`select now(), cluster_id, CASE WHEN max(grants_timeseries_total) > 0.0 THEN max(grants_timeseries_used) /max(grants_timeseries_total) * 100.0 ELSE 0.0 END AS result from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1m) > 0`|
|
||||||
|
|查询并发请求数 | > 100|不触发报警|1分钟|0秒|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries`|
|
||||||
|
|慢查询执行最长时间 (无时间窗口) |> 300秒|不触发报警|1分钟|0秒|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries where exec_usec>300000000`|
|
||||||
|
|dnode下线 |total != alive|触发告警|30秒|0秒|`select now(), cluster_id, last(dnodes_total) - last(dnodes_alive) as dnode_offline from log.taosd_cluster_info where _ts >= (now -30s) and _ts < now partition by cluster_id having first(_ts) > 0`|
|
||||||
|
|vnode下线 |total != alive|触发告警|30秒|0秒|`select now(), cluster_id, last(vnodes_total) - last(vnodes_alive) as vnode_offline from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|
||||||
|
|数据删除请求数 |> 0|不触发报警|30秒|0秒|``select now(), count(`count`) as `delete_count` from log.taos_sql_req where sql_type = 'delete' and _ts >= (now -30s) and _ts < now``|
|
||||||
|
|Adapter RESTful 请求失败 |> 5|不触发报警|30秒|0秒|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=0 and ts >= (now -30s) and ts < now``|
|
||||||
|
|Adapter WebSocket 请求失败 |> 5|不触发报警|30秒|0秒|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=1 and ts >= (now -30s) and ts < now``|
|
||||||
|
|dnode 数据上报缺少 |< 3|触发告警|180秒|0秒|`select now(), cluster_id, count(*) as dnode_report from log.taosd_cluster_info where _ts >= (now -180s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1h) > 0`|
|
||||||
|
|dnode 重启 |max(update_time) > last(update_time)|触发告警|90秒|0秒|`select now(), dnode_id, max(uptime) - last(uptime) as dnode_restart from log.taosd_dnodes_info where _ts >= (now - 90s) and _ts < now partition by dnode_id`|
|
||||||
|
|
||||||
|
用户可参考上述告警规则,根据自己业务需求进行修改与完善。
|
||||||
|
Grafana7.5 及以下版本,Dashboards 与 Alert rules 功能合在一起,而之后的新版本两个功能是分开的。为兼容 Grafana7.5 及以下版本,TDinsight 面板中增加了 Alert Used Only 面板,仅 Grafana7.5 及以下版本需要使用。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
## 升级
|
## 升级
|
||||||
下面三种方式都可以进行升级:
|
下面三种方式都可以进行升级:
|
||||||
- 用图形界面,若有新版本,可以在 ”TDengine Datasource“ 插件页面点击 update 升级。
|
- 用图形界面,若有新版本,可以在 ”TDengine Datasource“ 插件页面点击 update 升级。
|
||||||
|
@ -155,10 +193,11 @@ TDinsight 仪表盘旨在提供 TDengine 相关资源的使用情况和状态,
|
||||||
针对不同的安装方式,卸载时:
|
针对不同的安装方式,卸载时:
|
||||||
- 用图形界面,在 ”TDengine Datasource“ 插件页面点击 ”Uninstall“ 卸载。
|
- 用图形界面,在 ”TDengine Datasource“ 插件页面点击 ”Uninstall“ 卸载。
|
||||||
- 通过 `TDinsight.sh` 脚本安装的 TDinsight,可以使用命令行 `TDinsight.sh -R` 清理相关资源。
|
- 通过 `TDinsight.sh` 脚本安装的 TDinsight,可以使用命令行 `TDinsight.sh -R` 清理相关资源。
|
||||||
- 手动安装的 TDinsight,要完全卸载,需要清理以下内容:
|
- 手动安装的 TDinsight,要完全卸载,需要按照顺序清理以下内容:
|
||||||
1. Grafana 中的 TDinsight Dashboard。
|
1. Grafana 中的 TDinsight Dashboard。
|
||||||
2. Grafana 中的 Data Source 数据源。
|
2. Grafana 中的 Alert rules 告警规则。
|
||||||
3. 从插件安装目录删除 `tdengine-datasource` 插件。
|
3. Grafana 中的 Data Source 数据源。
|
||||||
|
4. 从插件安装目录删除 `tdengine-datasource` 插件。
|
||||||
|
|
||||||
## 附录
|
## 附录
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ taos> SET MAX_BINARY_DISPLAY_WIDTH <nn>;
|
||||||
- -h HOST: 要连接的 TDengine 服务端所在服务器的 FQDN, 默认为连接本地服务
|
- -h HOST: 要连接的 TDengine 服务端所在服务器的 FQDN, 默认为连接本地服务
|
||||||
- -P PORT: 指定服务端所用端口号
|
- -P PORT: 指定服务端所用端口号
|
||||||
- -u USER: 连接时使用的用户名
|
- -u USER: 连接时使用的用户名
|
||||||
- -p PASSWORD: 连接服务端时使用的密码
|
- -p PASSWORD: 连接服务端时使用的密码,特殊字符如 `! & ( ) < > ; |` 需使用字符 `\` 进行转义处理
|
||||||
- -?, --help: 打印出所有命令行参数
|
- -?, --help: 打印出所有命令行参数
|
||||||
|
|
||||||
还有更多其他参数:
|
还有更多其他参数:
|
||||||
|
|
|
@ -64,7 +64,7 @@ database_option: {
|
||||||
- DURATION:数据文件存储数据的时间跨度。可以使用加单位的表示形式,如 DURATION 100h、DURATION 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。不加时间单位时默认单位为天,如 DURATION 50 表示 50 天。
|
- DURATION:数据文件存储数据的时间跨度。可以使用加单位的表示形式,如 DURATION 100h、DURATION 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。不加时间单位时默认单位为天,如 DURATION 50 表示 50 天。
|
||||||
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
||||||
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
||||||
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于3倍的 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据从而释放存储空间。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](https://docs.taosdata.com/tdinternal/arch/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 \<= keep 1 \<= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。
|
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于3倍的 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据从而释放存储空间。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。企业版支持[多级存储](../../operation/planning/#%E5%A4%9A%E7%BA%A7%E5%AD%98%E5%82%A8)功能, 因此, 可以设置多个保存时间(多个以英文逗号分隔,最多 3 个,满足 keep 0 \<= keep 1 \<= keep 2,如 KEEP 100h,100d,3650d); 社区版不支持多级存储功能(即使配置了多个保存时间, 也不会生效, KEEP 会取最大的保存时间)。
|
||||||
- KEEP_TIME_OFFSET:自 3.2.0.0 版本生效。删除或迁移保存时间超过 KEEP 值的数据的延迟执行时间,默认值为 0 (小时)。在数据文件保存时间超过 KEEP 后,删除或迁移操作不会立即执行,而会额外等待本参数指定的时间间隔,以实现与业务高峰期错开的目的。
|
- KEEP_TIME_OFFSET:自 3.2.0.0 版本生效。删除或迁移保存时间超过 KEEP 值的数据的延迟执行时间,默认值为 0 (小时)。在数据文件保存时间超过 KEEP 后,删除或迁移操作不会立即执行,而会额外等待本参数指定的时间间隔,以实现与业务高峰期错开的目的。
|
||||||
- STT_TRIGGER:表示落盘文件触发文件合并的个数。开源版本固定为 1,企业版本可设置范围为 1 到 16。对于少表高频写入场景,此参数建议使用默认配置;而对于多表低频写入场景,此参数建议配置较大的值。
|
- STT_TRIGGER:表示落盘文件触发文件合并的个数。开源版本固定为 1,企业版本可设置范围为 1 到 16。对于少表高频写入场景,此参数建议使用默认配置;而对于多表低频写入场景,此参数建议配置较大的值。
|
||||||
- SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。
|
- SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。
|
||||||
|
@ -134,11 +134,11 @@ alter_database_option: {
|
||||||
|
|
||||||
1. 如何查看 cachesize?
|
1. 如何查看 cachesize?
|
||||||
|
|
||||||
通过 select * from information_schema.ins_databases; 可以查看这些 cachesize 的具体值。
|
通过 select * from information_schema.ins_databases; 可以查看这些 cachesize 的具体值(单位为 MB)。。
|
||||||
|
|
||||||
2. 如何查看 cacheload?
|
2. 如何查看 cacheload?
|
||||||
|
|
||||||
通过 show \<db_name>.vgroups; 可以查看 cacheload
|
通过 show \<db_name>.vgroups; 可以查看 cacheload(单位为字节)。
|
||||||
|
|
||||||
3. 判断 cachesize 是否够用
|
3. 判断 cachesize 是否够用
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ ALTER TABLE [db_name.]tb_name alter_table_clause
|
||||||
|
|
||||||
alter_table_clause: {
|
alter_table_clause: {
|
||||||
alter_table_options
|
alter_table_options
|
||||||
| SET TAG tag_name = new_tag_value,tag_name2=new_tag2_value...
|
| SET TAG tag_name = new_tag_value, tag_name2=new_tag2_value ...
|
||||||
}
|
}
|
||||||
|
|
||||||
alter_table_options:
|
alter_table_options:
|
||||||
|
@ -195,7 +195,7 @@ alter_table_option: {
|
||||||
### 修改子表标签值
|
### 修改子表标签值
|
||||||
|
|
||||||
```
|
```
|
||||||
ALTER TABLE tb_name SET TAG tag_name1=new_tag_value1,tag_name2=new_tag_value2...;
|
ALTER TABLE tb_name SET TAG tag_name1=new_tag_value1, tag_name2=new_tag_value2 ...;
|
||||||
```
|
```
|
||||||
|
|
||||||
### 修改表生命周期
|
### 修改表生命周期
|
||||||
|
|
|
@ -6,7 +6,7 @@ title: "删除数据"
|
||||||
|
|
||||||
删除数据是 TDengine 提供的根据指定时间段删除指定表或超级表中数据记录的功能,方便用户清理由于设备故障等原因产生的异常数据。
|
删除数据是 TDengine 提供的根据指定时间段删除指定表或超级表中数据记录的功能,方便用户清理由于设备故障等原因产生的异常数据。
|
||||||
|
|
||||||
**注意**:删除数据并不会立即释放该表所占用的磁盘空间,而是把该表的数据标记为已删除,在查询时这些数据将不会再出现,但释放磁盘空间会延迟到系统自动或用户手动进行数据重整时。
|
**注意**:删除数据并不会立即释放该表所占用的磁盘空间,而是把该表的数据标记为已删除,在查询时这些数据将不会再出现,但释放磁盘空间会延迟到系统自动清理(建库参数 keep 生效)或用户手动进行数据重整时(企业版功能 compact)。
|
||||||
|
|
||||||
**语法:**
|
**语法:**
|
||||||
|
|
||||||
|
|
|
@ -1817,7 +1817,7 @@ ignore_null_values: {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**功能说明**:返回指定时间截面指定列的记录值或插值。ignore_null_values 参数的值可以是 0 或 1,为 1 时表示忽略 NULL 值, 缺省值为0。
|
**功能说明**:返回指定时间截面指定列的记录值或插值。ignore_null_values 参数的值可以是 0 或 1,为 1 时表示忽略 NULL 值, 缺省值为 0。
|
||||||
|
|
||||||
**返回数据类型**:同字段类型。
|
**返回数据类型**:同字段类型。
|
||||||
|
|
||||||
|
@ -1838,9 +1838,9 @@ ignore_null_values: {
|
||||||
- INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.2.0 版本以后支持)。
|
- INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.2.0 版本以后支持)。
|
||||||
- INTERP 可以与伪列 _isfilled 一起使用,显示返回结果是否为原始记录或插值算法产生的数据(3.0.3.0 版本以后支持)。
|
- INTERP 可以与伪列 _isfilled 一起使用,显示返回结果是否为原始记录或插值算法产生的数据(3.0.3.0 版本以后支持)。
|
||||||
- INTERP 对于带复合主键的表的查询,若存在相同时间戳的数据,则只有对应的复合主键最小的数据参与运算。
|
- INTERP 对于带复合主键的表的查询,若存在相同时间戳的数据,则只有对应的复合主键最小的数据参与运算。
|
||||||
- INTERP 查询支持NEAR FILL模式, 即当需要FILL时, 使用距离当前时间点最近的数据进行插值, 当前后时间戳与当前时间断面一样近时, FILL 前一行的值. 此模式在流计算中和窗口查询中不支持。例如: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', '2023-01-01 00:10:00') FILL(NEAR)。(3.3.4.9版本及以后支持)。
|
- INTERP 查询支持 NEAR FILL 模式, 即当需要 FILL 时, 使用距离当前时间点最近的数据进行插值, 当前后时间戳与当前时间断面一样近时, FILL 前一行的值. 此模式在流计算中和窗口查询中不支持。例如: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', '2023-01-01 00:10:00') FILL(NEAR)(3.3.4.9 版本及以后支持)。
|
||||||
- INTERP 只有在使用FILL PREV/NEXT/NEAR 模式时才可以使用伪列 `_irowts_origin`。`_irowts_origin`在3.3.4.9版本及以后支持。
|
- INTERP 只有在使用 FILL PREV/NEXT/NEAR 模式时才可以使用伪列 `_irowts_origin`。`_irowts_origin`在 3.3.4.9 版本及以后支持。
|
||||||
- INTERP `RANEG`子句支持时间范围的扩展(3.3.4.9版本及以后支持), 如`RANGE('2023-01-01 00:00:00', 10s)`表示在时间点'2023-01-01 00:00:00'查找前后10s的数据进行插值, FILL PREV/NEXT/NEAR分别表示从时间点向前/向后/前后查找数据, 若时间点周围没有数据, 则使用FILL指定的值进行插值, 因此此时FILL子句必须指定值。例如: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', 10s) FILL(PREV, 1). 目前仅支持时间点和时间范围的组合, 不支持时间区间和时间范围的组合, 即不支持RANGE('2023-01-01 00:00:00', '2023-02-01 00:00:00', 1h)。所指定的时间范围规则与EVERY类似, 单位不能是年或月, 值不能为0, 不能带引号。使用该扩展时, 不支持除FILL PREV/NEXT/NEAR外的其他FILL模式, 且不能指定EVERY子句。
|
- INTERP `RANGE`子句支持时间范围的扩展(3.3.4.9 版本及以后支持), 如`RANGE('2023-01-01 00:00:00', 10s)`表示在时间点 '2023-01-01 00:00:00' 查找前后 10s 的数据进行插值, FILL PREV/NEXT/NEAR 分别表示从时间点向前/向后/前后查找数据, 若时间点周围没有数据, 则使用 FILL 指定的值进行插值, 因此此时 FILL 子句必须指定值。例如: SELECT INTERP(col) FROM tb RANGE('2023-01-01 00:00:00', 10s) FILL(PREV, 1)。目前仅支持时间点和时间范围的组合, 不支持时间区间和时间范围的组合, 即不支持 RANGE('2023-01-01 00:00:00', '2023-02-01 00:00:00', 1h)。所指定的时间范围规则与 EVERY 类似, 单位不能是年或月, 值不能为 0, 不能带引号。使用该扩展时, 不支持除FILL PREV/NEXT/NEAR外的其他 FILL 模式, 且不能指定 EVERY 子句。
|
||||||
|
|
||||||
### LAST
|
### LAST
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ CREATE USER user_name PASS 'password' [SYSINFO {1|0}];
|
||||||
|
|
||||||
用户名最长不超过 23 个字节。
|
用户名最长不超过 23 个字节。
|
||||||
|
|
||||||
密码最长不超过 31 个字节。密码可以包含字母、数字以及除单引号、双引号、反引号、反斜杠和空格以外的特殊字符,密码不能为空字符串。
|
密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类。特殊字符包括 `! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , .`。
|
||||||
|
|
||||||
`SYSINFO` 表示该用户是否能够查看系统信息。`1` 表示可以查看,`0` 表示无权查看。系统信息包括服务配置、dnode、vnode、存储等信息。缺省值为 `1`。
|
`SYSINFO` 表示该用户是否能够查看系统信息。`1` 表示可以查看,`0` 表示无权查看。系统信息包括服务配置、dnode、vnode、存储等信息。缺省值为 `1`。
|
||||||
|
|
||||||
在下面的示例中,我们创建一个密码为 `123456` 且可以查看系统信息的用户。
|
在下面的示例中,我们创建一个密码为 `abc123!@#` 且可以查看系统信息的用户。
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
taos> create user test pass '123456' sysinfo 1;
|
taos> create user test pass 'abc123!@#' sysinfo 1;
|
||||||
Query OK, 0 of 0 rows affected (0.001254s)
|
Query OK, 0 of 0 rows affected (0.001254s)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,15 @@ description: 可配置压缩算法
|
||||||
|
|
||||||
- 各个数据类型的默认压缩算法列表和适用范围
|
- 各个数据类型的默认压缩算法列表和适用范围
|
||||||
|
|
||||||
| 数据类型 | 可选编码算法 | 编码算法默认值 | 可选压缩算法|压缩算法默认值| 压缩等级默认值|
|
| 数据类型 | 可选编码算法 | 编码算法默认值 | 可选压缩算法 | 压缩算法默认值 |压缩等级默认值|
|
||||||
| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:|
|
|:------------------------------------:|:-------------------------:|:-----------:|:--------------------:|:----:|:------:|
|
||||||
| tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium|
|
| int/uint | disabled/simple8b | simple8b | lz4/zlib/zstd/xz | lz4 | medium |
|
||||||
| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium|
|
| tinyint/untinyint/smallint/usmallint | disabled/simple8b | simple8b | lz4/zlib/zstd/xz | zlib | medium |
|
||||||
|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|lz4| medium|
|
| bigint/ubigint/timestamp | disabled/simple8b/delta-i | delta-i | lz4/zlib/zstd/xz | lz4 | medium |
|
||||||
|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium|
|
| float/double | disabled/delta-d | delta-d | lz4/zlib/zstd/xz/tsz | lz4 | medium |
|
||||||
|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium|
|
| binary/nchar | disabled | disabled | lz4/zlib/zstd/xz | zstd | medium |
|
||||||
|
| bool | disabled/bit-packing | bit-packing | lz4/zlib/zstd/xz | zstd | medium |
|
||||||
|
|
||||||
|
|
||||||
## SQL 语法
|
## SQL 语法
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ WKB规范请参考[Well-Known Binary (WKB)](https://libgeos.org/specifications/w
|
||||||
|
|
||||||
**原因**:程序没有找到依赖的本地函数库 taos。
|
**原因**:程序没有找到依赖的本地函数库 taos。
|
||||||
|
|
||||||
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib`。
|
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib /usr/lib/libtaos.dylib`。
|
||||||
|
|
||||||
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
|
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ description: TDengine 服务端的错误码列表和详细说明
|
||||||
| 0x80000350 | User already exists | Create user, 重复创建 | 确认操作是否正确 |
|
| 0x80000350 | User already exists | Create user, 重复创建 | 确认操作是否正确 |
|
||||||
| 0x80000351 | Invalid user | 用户不存在 | 确认操作是否正确 |
|
| 0x80000351 | Invalid user | 用户不存在 | 确认操作是否正确 |
|
||||||
| 0x80000352 | Invalid user format | 格式不正确 | 确认操作是否正确 |
|
| 0x80000352 | Invalid user format | 格式不正确 | 确认操作是否正确 |
|
||||||
| 0x80000353 | Invalid password format | 格式不正确 | 确认操作是否正确 |
|
| 0x80000353 | Invalid password format | 密码长度必须为 8 到 16 位,并且至少包含大写字母、小写字母、数字、特殊字符中的三类 | 确认密码字符串的格式 |
|
||||||
| 0x80000354 | Can not get user from conn | 内部错误 | 上报issue |
|
| 0x80000354 | Can not get user from conn | 内部错误 | 上报issue |
|
||||||
| 0x80000355 | Too many users | (仅企业版)用户数量超限 | 调整配置 |
|
| 0x80000355 | Too many users | (仅企业版)用户数量超限 | 调整配置 |
|
||||||
| 0x80000357 | Authentication failure | 密码不正确 | 确认操作是否正确 |
|
| 0x80000357 | Authentication failure | 密码不正确 | 确认操作是否正确 |
|
||||||
|
|
|
@ -280,4 +280,21 @@ TDinsight插件中展示的数据是通过taosKeeper和taosAdapter服务收集
|
||||||
https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B8%E5%85%B3
|
https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B8%E5%85%B3
|
||||||
您可以随时关闭该参数,只需要在taos.cfg 中修改telemetryReporting为 0,然后重启数据库服务即可。
|
您可以随时关闭该参数,只需要在taos.cfg 中修改telemetryReporting为 0,然后重启数据库服务即可。
|
||||||
代码位于:https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c
|
代码位于:https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c
|
||||||
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
|
此外,对于安全性要求极高的企业版 TDengine Enterprise 来说,此参数不会工作。
|
||||||
|
### 31 第一次连接集群时遇到“Sync leader is unreachable”怎么办?
|
||||||
|
报这个错,说明第一次向集群的连接是成功的,但第一次访问的IP不是mnode的leader节点,客户端试图与leader建立连接时发生错误。客户端通过EP,也就是指定的fqdn与端口号寻找leader节点,常见的报错原因有两个:
|
||||||
|
|
||||||
|
- 集群中其他节点的端口没有打开
|
||||||
|
- 客户端的hosts未正确配置
|
||||||
|
|
||||||
|
因此用户首先要检查服务端,集群的所有端口(原生连接默认6030,http连接默认6041)有无打开;其次是客户端的hosts文件中是否配置了集群所有节点的fqdn与IP信息。
|
||||||
|
如仍无法解决,则需要联系涛思技术人员支持。
|
||||||
|
|
||||||
|
### 32 同一台服务器,数据库的数据目录 dataDir 不变,为什么原有数据库丢失且集群 ID 发生了变化?
|
||||||
|
背景知识:TDengine 服务端进程(taosd)在启动时,若数据目录(dataDir,该目录在配置文件 taos.cfg 中指定)下不存在有效的数据文件子目录(如 mnode、dnode 和 vnode 等),则会自动创建这些目录。在创建新的 mnode 目录的同时,会分配一个新的集群 ID,从而产生一个新的集群。
|
||||||
|
|
||||||
|
原因分析:taosd 的数据目录 dataDir 可以指向多个不同的挂载点。如果这些挂载点未在 fstab 文件中配置自动挂载,服务器重启后,dataDir 将仅作为一个本地磁盘的普通目录存在,而未能按预期指向挂载的磁盘。此时,若 taosd 服务启动,它将在 dataDir 下新建目录,从而产生一个新的集群。
|
||||||
|
|
||||||
|
问题影响:服务器重启后,原有数据库丢失(注:并非真正丢失,只是原有的数据磁盘未挂载,暂时看不到)且集群 ID 发生变化,导致无法访问原有数据库。对于企业版用户,如果已针对集群 ID 进行授权,还会发现集群服务器的机器码未变,但原有的授权已失效。如果未针对该问题进行监控或者未及时发现并进行处理,则用户不会注意到原有数据库已经丢失,从而造成损失,增加运维成本。
|
||||||
|
|
||||||
|
问题解决:应在 fstab 文件中配置 dataDir 目录的自动挂载,确保 dataDir 始终指向预期的挂载点和目录,此时,再重启服务器,会找回原有的数据库和集群。在后续的版本中,我们将开发一个功能,使 taosd 在检测到启动前后 dataDir 发生变化时,在启动阶段退出,同时提供相应的错误提示。
|
|
@ -25,7 +25,7 @@ typedef int32_t TdUcs4;
|
||||||
#if !defined(DISALLOW_NCHAR_WITHOUT_ICONV) && defined(DARWIN)
|
#if !defined(DISALLOW_NCHAR_WITHOUT_ICONV) && defined(DARWIN)
|
||||||
#include "iconv.h"
|
#include "iconv.h"
|
||||||
#else
|
#else
|
||||||
typedef void *iconv_t;
|
typedef void *iconv_t;
|
||||||
#endif
|
#endif
|
||||||
typedef enum { M2C = 0, C2M } ConvType;
|
typedef enum { M2C = 0, C2M } ConvType;
|
||||||
|
|
||||||
|
@ -55,29 +55,34 @@ typedef enum { M2C = 0, C2M } ConvType;
|
||||||
#ifdef strndup
|
#ifdef strndup
|
||||||
#undef strndup
|
#undef strndup
|
||||||
#endif
|
#endif
|
||||||
#define strndup STR_TO_F_FUNC_TAOS_FORBID
|
#define strndup STR_TO_F_FUNC_TAOS_FORBID
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define tstrncpy(dst, src, size) \
|
#define tstrncpy(dst, src, size) \
|
||||||
do { \
|
do { \
|
||||||
(void)strncpy((dst), (src), (size)); \
|
(void)strncpy((dst), (src), (size)); \
|
||||||
(dst)[(size) - 1] = 0; \
|
(dst)[(size)-1] = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||||
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
|
||||||
|
|
||||||
char *tstrdup(const char *src);
|
char *tstrdup(const char *src);
|
||||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||||
int32_t taosStr2int64(const char *str, int64_t *val);
|
int32_t taosStr2int64(const char *str, int64_t *val);
|
||||||
int32_t taosStr2int16(const char *str, int16_t *val);
|
|
||||||
int32_t taosStr2int32(const char *str, int32_t *val);
|
int32_t taosStr2int32(const char *str, int32_t *val);
|
||||||
|
int32_t taosStr2int16(const char *str, int16_t *val);
|
||||||
int32_t taosStr2int8(const char *str, int8_t *val);
|
int32_t taosStr2int8(const char *str, int8_t *val);
|
||||||
|
|
||||||
|
int32_t taosStr2Uint64(const char *str, uint64_t *val);
|
||||||
|
int32_t taosStr2Uint32(const char *str, uint32_t *val);
|
||||||
|
int32_t taosStr2Uint16(const char *str, uint16_t *val);
|
||||||
|
int32_t taosStr2Uint8(const char *str, uint8_t *val);
|
||||||
|
|
||||||
int32_t taosConvInit(void);
|
int32_t taosConvInit(void);
|
||||||
void taosConvDestroy();
|
void taosConvDestroy();
|
||||||
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
iconv_t taosAcquireConv(int32_t *idx, ConvType type);
|
||||||
|
@ -112,9 +117,9 @@ float taosStr2Float(const char *str, char **pEnd);
|
||||||
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
|
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||||
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
|
||||||
char *taosStrndup(const char *s, int n);
|
char *taosStrndup(const char *s, int n);
|
||||||
//int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
// int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
|
||||||
bool isHex(const char* z, uint32_t n);
|
bool isHex(const char *z, uint32_t n);
|
||||||
bool isValidateHex(const char* z, uint32_t n);
|
bool isValidateHex(const char *z, uint32_t n);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,6 +318,8 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_MAX_JSON_KEY_LEN 256
|
#define TSDB_MAX_JSON_KEY_LEN 256
|
||||||
|
|
||||||
#define TSDB_AUTH_LEN 16
|
#define TSDB_AUTH_LEN 16
|
||||||
|
#define TSDB_PASSWORD_MIN_LEN 8
|
||||||
|
#define TSDB_PASSWORD_MAX_LEN 16
|
||||||
#define TSDB_PASSWORD_LEN 32
|
#define TSDB_PASSWORD_LEN 32
|
||||||
#define TSDB_USET_PASSWORD_LEN 129
|
#define TSDB_USET_PASSWORD_LEN 129
|
||||||
#define TSDB_VERSION_LEN 32
|
#define TSDB_VERSION_LEN 32
|
||||||
|
|
|
@ -230,6 +230,11 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
|
|
||||||
#define TAOS_UNUSED(expr) (void)(expr)
|
#define TAOS_UNUSED(expr) (void)(expr)
|
||||||
|
|
||||||
|
bool taosIsBigChar(char c);
|
||||||
|
bool taosIsSmallChar(char c);
|
||||||
|
bool taosIsNumberChar(char c);
|
||||||
|
bool taosIsSpecialChar(char c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,59 +1,80 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# 执行 git fetch 命令并捕获输出
|
|
||||||
def git_fetch():
|
def git_fetch():
|
||||||
result = subprocess.run(['git', 'fetch'], capture_output=True, text=True)
|
result = subprocess.run(['git', 'fetch'], capture_output=True, text=True)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# 解析分支名称
|
def git_prune():
|
||||||
|
# git remote prune origin
|
||||||
|
print("git remote prune origin")
|
||||||
|
result = subprocess.run(['git', 'remote', 'prune', 'origin'], capture_output=True, text=True)
|
||||||
|
return result
|
||||||
|
|
||||||
def parse_branch_name_type1(error_output):
|
def parse_branch_name_type1(error_output):
|
||||||
# 使用正则表达式匹配 'is at' 前的分支名称
|
# error: cannot lock ref 'refs/remotes/origin/fix/3.0/TD-32817': is at 7af5 but expected eaba
|
||||||
|
# match the branch name before ‘is at’ with a regular expression
|
||||||
match = re.search(r"error: cannot lock ref '(refs/remotes/origin/[^']+)': is at", error_output)
|
match = re.search(r"error: cannot lock ref '(refs/remotes/origin/[^']+)': is at", error_output)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 解析第二种错误中的分支名称
|
|
||||||
def parse_branch_name_type2(error_output):
|
def parse_branch_name_type2(error_output):
|
||||||
# 使用正则表达式匹配 'exists' 前的第一个引号内的分支名称
|
# match the branch name before ‘exists; cannot create’ with a regular expression
|
||||||
match = re.search(r"'(refs/remotes/origin/[^']+)' exists;", error_output)
|
match = re.search(r"'(refs/remotes/origin/[^']+)' exists;", error_output)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 执行 git update-ref -d 命令
|
# parse branch name from error output of git remote prune origin
|
||||||
|
def parse_branch_name_type3(error_output):
|
||||||
|
# match the branch name before the first single quote before 'Unable to' with a regular expression
|
||||||
|
# git error: could not delete references: cannot lock ref 'refs/remotes/origin/test/3.0/TS-4893': Unable to create 'D:/workspace/main/TDinternal/community/.git/refs/remotes/origin/test/3.0/TS-4893.lock': File exists
|
||||||
|
match = re.search(r"references: cannot lock ref '(refs/remotes/origin/[^']+)': Unable to", error_output)
|
||||||
|
if match:
|
||||||
|
return match.group(1)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# execute git update-ref -d <branch_name> to delete the ref
|
||||||
def git_update_ref(branch_name):
|
def git_update_ref(branch_name):
|
||||||
if branch_name:
|
if branch_name:
|
||||||
subprocess.run(['git', 'update-ref', '-d', f'{branch_name}'], check=True)
|
subprocess.run(['git', 'update-ref', '-d', f'{branch_name}'], check=True)
|
||||||
|
|
||||||
# 解析错误类型并执行相应的修复操作
|
# parse error type and execute corresponding repair operation
|
||||||
def handle_error(error_output):
|
def handle_error(error_output):
|
||||||
# 错误类型1:本地引用的提交ID与远程不一致
|
error_types = [
|
||||||
if "is at" in error_output and "but expected" in error_output:
|
("is at", "but expected", parse_branch_name_type1, "type 1"),
|
||||||
branch_name = parse_branch_name_type1(error_output)
|
("exists; cannot create", None, parse_branch_name_type2, "type 2"),
|
||||||
if branch_name:
|
("Unable to create", "File exists", parse_branch_name_type3, "type 3")
|
||||||
print(f"Detected error type 1, attempting to delete ref for branch: {branch_name}")
|
]
|
||||||
git_update_ref(branch_name)
|
|
||||||
else:
|
for error_type in error_types:
|
||||||
print("Error parsing branch name for type 1.")
|
if error_type[0] in error_output and (error_type[1] is None or error_type[1] in error_output):
|
||||||
# 错误类型2:尝试创建新的远程引用时,本地已经存在同名的引用
|
branch_name = error_type[2](error_output)
|
||||||
elif "exists; cannot create" in error_output:
|
if branch_name:
|
||||||
branch_name = parse_branch_name_type2(error_output)
|
print(f"Detected error {error_type[3]}, attempting to delete ref for branch: {branch_name}")
|
||||||
if branch_name:
|
git_update_ref(branch_name)
|
||||||
print(f"Detected error type 2, attempting to delete ref for branch: {branch_name}")
|
else:
|
||||||
git_update_ref(branch_name)
|
print(f"Error parsing branch name for {error_type[3]}.")
|
||||||
else:
|
break
|
||||||
print("Error parsing branch name for type 2.")
|
|
||||||
|
|
||||||
# 主函数
|
|
||||||
def main():
|
def main():
|
||||||
fetch_result = git_fetch()
|
fetch_result = git_fetch()
|
||||||
if fetch_result.returncode != 0: # 如果 git fetch 命令失败
|
if fetch_result.returncode != 0:
|
||||||
error_output = fetch_result.stderr
|
error_output = fetch_result.stderr
|
||||||
handle_error(error_output)
|
handle_error(error_output)
|
||||||
else:
|
else:
|
||||||
print("Git fetch successful.")
|
print("Git fetch successful.")
|
||||||
|
|
||||||
|
prune_result = git_prune()
|
||||||
|
print(prune_result.returncode)
|
||||||
|
if prune_result.returncode != 0:
|
||||||
|
error_output = prune_result.stderr
|
||||||
|
print(error_output)
|
||||||
|
handle_error(error_output)
|
||||||
|
else:
|
||||||
|
print("Git prune successful.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
|
@ -52,6 +52,22 @@
|
||||||
|
|
||||||
#define TMQ_META_VERSION "1.0"
|
#define TMQ_META_VERSION "1.0"
|
||||||
|
|
||||||
|
static bool tmqAddJsonObjectItem(cJSON *object, const char *string, cJSON *item){
|
||||||
|
bool ret = cJSON_AddItemToObject(object, string, item);
|
||||||
|
if (!ret){
|
||||||
|
cJSON_Delete(item);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
static bool tmqAddJsonArrayItem(cJSON *array, cJSON *item){
|
||||||
|
bool ret = cJSON_AddItemToArray(array, item);
|
||||||
|
if (!ret){
|
||||||
|
cJSON_Delete(item);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t tmqWriteBatchMetaDataImpl(TAOS* taos, void* meta, int32_t metaLen);
|
static int32_t tmqWriteBatchMetaDataImpl(TAOS* taos, void* meta, int32_t metaLen);
|
||||||
static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); }
|
static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); }
|
||||||
static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t,
|
static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t,
|
||||||
|
@ -68,41 +84,43 @@ static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sche
|
||||||
cJSON* type = cJSON_CreateString("create");
|
cJSON* type = cJSON_CreateString("create");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
|
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
cJSON* tableType = cJSON_CreateString(t == TSDB_NORMAL_TABLE ? "normal" : "super");
|
cJSON* tableType = cJSON_CreateString(t == TSDB_NORMAL_TABLE ? "normal" : "super");
|
||||||
RAW_NULL_CHECK(tableType);
|
RAW_NULL_CHECK(tableType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableType", tableType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableType", tableType));
|
||||||
cJSON* tableName = cJSON_CreateString(name);
|
cJSON* tableName = cJSON_CreateString(name);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableName", tableName));
|
||||||
|
|
||||||
cJSON* columns = cJSON_CreateArray();
|
cJSON* columns = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(columns);
|
RAW_NULL_CHECK(columns);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "columns", columns));
|
||||||
|
|
||||||
for (int i = 0; i < schemaRow->nCols; i++) {
|
for (int i = 0; i < schemaRow->nCols; i++) {
|
||||||
cJSON* column = cJSON_CreateObject();
|
cJSON* column = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(column);
|
RAW_NULL_CHECK(column);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(columns, column));
|
||||||
SSchema* s = schemaRow->pSchema + i;
|
SSchema* s = schemaRow->pSchema + i;
|
||||||
cJSON* cname = cJSON_CreateString(s->name);
|
cJSON* cname = cJSON_CreateString(s->name);
|
||||||
RAW_NULL_CHECK(cname);
|
RAW_NULL_CHECK(cname);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "name", cname));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "name", cname));
|
||||||
cJSON* ctype = cJSON_CreateNumber(s->type);
|
cJSON* ctype = cJSON_CreateNumber(s->type);
|
||||||
RAW_NULL_CHECK(ctype);
|
RAW_NULL_CHECK(ctype);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "type", ctype));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "type", ctype));
|
||||||
if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY || s->type == TSDB_DATA_TYPE_GEOMETRY) {
|
if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY || s->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = s->bytes - VARSTR_HEADER_SIZE;
|
int32_t length = s->bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "length", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "length", cbytes));
|
||||||
} else if (s->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (s->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (s->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (s->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "length", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "length", cbytes));
|
||||||
}
|
}
|
||||||
cJSON* isPk = cJSON_CreateBool(s->flags & COL_IS_KEY);
|
cJSON* isPk = cJSON_CreateBool(s->flags & COL_IS_KEY);
|
||||||
RAW_NULL_CHECK(isPk);
|
RAW_NULL_CHECK(isPk);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "isPrimarykey", isPk));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "isPrimarykey", isPk));
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(columns, column));
|
|
||||||
|
|
||||||
if (pColCmprRow == NULL) {
|
if (pColCmprRow == NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -124,44 +142,44 @@ static void buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sche
|
||||||
|
|
||||||
cJSON* encodeJson = cJSON_CreateString(encode);
|
cJSON* encodeJson = cJSON_CreateString(encode);
|
||||||
RAW_NULL_CHECK(encodeJson);
|
RAW_NULL_CHECK(encodeJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "encode", encodeJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "encode", encodeJson));
|
||||||
|
|
||||||
cJSON* compressJson = cJSON_CreateString(compress);
|
cJSON* compressJson = cJSON_CreateString(compress);
|
||||||
RAW_NULL_CHECK(compressJson);
|
RAW_NULL_CHECK(compressJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "compress", compressJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "compress", compressJson));
|
||||||
|
|
||||||
cJSON* levelJson = cJSON_CreateString(level);
|
cJSON* levelJson = cJSON_CreateString(level);
|
||||||
RAW_NULL_CHECK(levelJson);
|
RAW_NULL_CHECK(levelJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(column, "level", levelJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(column, "level", levelJson));
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "columns", columns));
|
|
||||||
|
|
||||||
cJSON* tags = cJSON_CreateArray();
|
cJSON* tags = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(tags);
|
RAW_NULL_CHECK(tags);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tags", tags));
|
||||||
|
|
||||||
for (int i = 0; schemaTag && i < schemaTag->nCols; i++) {
|
for (int i = 0; schemaTag && i < schemaTag->nCols; i++) {
|
||||||
cJSON* tag = cJSON_CreateObject();
|
cJSON* tag = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(tag);
|
RAW_NULL_CHECK(tag);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(tags, tag));
|
||||||
SSchema* s = schemaTag->pSchema + i;
|
SSchema* s = schemaTag->pSchema + i;
|
||||||
cJSON* tname = cJSON_CreateString(s->name);
|
cJSON* tname = cJSON_CreateString(s->name);
|
||||||
RAW_NULL_CHECK(tname);
|
RAW_NULL_CHECK(tname);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "name", tname));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "name", tname));
|
||||||
cJSON* ttype = cJSON_CreateNumber(s->type);
|
cJSON* ttype = cJSON_CreateNumber(s->type);
|
||||||
RAW_NULL_CHECK(ttype);
|
RAW_NULL_CHECK(ttype);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "type", ttype));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "type", ttype));
|
||||||
if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY || s->type == TSDB_DATA_TYPE_GEOMETRY) {
|
if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY || s->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = s->bytes - VARSTR_HEADER_SIZE;
|
int32_t length = s->bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "length", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "length", cbytes));
|
||||||
} else if (s->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (s->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (s->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (s->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "length", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "length", cbytes));
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(tags, tag));
|
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
*pJson = json;
|
*pJson = json;
|
||||||
|
@ -175,7 +193,7 @@ static int32_t setCompressOption(cJSON* json, uint32_t para) {
|
||||||
RAW_NULL_CHECK(encodeStr);
|
RAW_NULL_CHECK(encodeStr);
|
||||||
cJSON* encodeJson = cJSON_CreateString(encodeStr);
|
cJSON* encodeJson = cJSON_CreateString(encodeStr);
|
||||||
RAW_NULL_CHECK(encodeJson);
|
RAW_NULL_CHECK(encodeJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "encode", encodeJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "encode", encodeJson));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
uint8_t compress = COMPRESS_L2_TYPE_U32(para);
|
uint8_t compress = COMPRESS_L2_TYPE_U32(para);
|
||||||
|
@ -184,7 +202,7 @@ static int32_t setCompressOption(cJSON* json, uint32_t para) {
|
||||||
RAW_NULL_CHECK(compressStr);
|
RAW_NULL_CHECK(compressStr);
|
||||||
cJSON* compressJson = cJSON_CreateString(compressStr);
|
cJSON* compressJson = cJSON_CreateString(compressStr);
|
||||||
RAW_NULL_CHECK(compressJson);
|
RAW_NULL_CHECK(compressJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "compress", compressJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "compress", compressJson));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
uint8_t level = COMPRESS_L2_TYPE_LEVEL_U32(para);
|
uint8_t level = COMPRESS_L2_TYPE_LEVEL_U32(para);
|
||||||
|
@ -193,7 +211,7 @@ static int32_t setCompressOption(cJSON* json, uint32_t para) {
|
||||||
RAW_NULL_CHECK(levelStr);
|
RAW_NULL_CHECK(levelStr);
|
||||||
cJSON* levelJson = cJSON_CreateString(levelStr);
|
cJSON* levelJson = cJSON_CreateString(levelStr);
|
||||||
RAW_NULL_CHECK(levelJson);
|
RAW_NULL_CHECK(levelJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "level", levelJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "level", levelJson));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,19 +232,19 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("alter");
|
cJSON* type = cJSON_CreateString("alter");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
RAW_RETURN_CHECK(tNameFromString(&name, req.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE));
|
RAW_RETURN_CHECK(tNameFromString(&name, req.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE));
|
||||||
cJSON* tableType = cJSON_CreateString("super");
|
cJSON* tableType = cJSON_CreateString("super");
|
||||||
RAW_NULL_CHECK(tableType);
|
RAW_NULL_CHECK(tableType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableType", tableType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableType", tableType));
|
||||||
cJSON* tableName = cJSON_CreateString(name.tname);
|
cJSON* tableName = cJSON_CreateString(name.tname);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableName", tableName));
|
||||||
|
|
||||||
cJSON* alterType = cJSON_CreateNumber(req.alterType);
|
cJSON* alterType = cJSON_CreateNumber(req.alterType);
|
||||||
RAW_NULL_CHECK(alterType);
|
RAW_NULL_CHECK(alterType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "alterType", alterType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "alterType", alterType));
|
||||||
switch (req.alterType) {
|
switch (req.alterType) {
|
||||||
case TSDB_ALTER_TABLE_ADD_TAG:
|
case TSDB_ALTER_TABLE_ADD_TAG:
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN: {
|
case TSDB_ALTER_TABLE_ADD_COLUMN: {
|
||||||
|
@ -234,22 +252,22 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(field);
|
RAW_NULL_CHECK(field);
|
||||||
cJSON* colName = cJSON_CreateString(field->name);
|
cJSON* colName = cJSON_CreateString(field->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(field->type);
|
cJSON* colType = cJSON_CreateNumber(field->type);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
|
|
||||||
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -258,22 +276,22 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(field);
|
RAW_NULL_CHECK(field);
|
||||||
cJSON* colName = cJSON_CreateString(field->name);
|
cJSON* colName = cJSON_CreateString(field->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(field->type);
|
cJSON* colType = cJSON_CreateNumber(field->type);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
|
|
||||||
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
RAW_RETURN_CHECK(setCompressOption(json, field->compress));
|
RAW_RETURN_CHECK(setCompressOption(json, field->compress));
|
||||||
break;
|
break;
|
||||||
|
@ -284,7 +302,7 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(field);
|
RAW_NULL_CHECK(field);
|
||||||
cJSON* colName = cJSON_CreateString(field->name);
|
cJSON* colName = cJSON_CreateString(field->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
||||||
|
@ -293,21 +311,21 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(field);
|
RAW_NULL_CHECK(field);
|
||||||
cJSON* colName = cJSON_CreateString(field->name);
|
cJSON* colName = cJSON_CreateString(field->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(field->type);
|
cJSON* colType = cJSON_CreateNumber(field->type);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
field->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
int32_t length = field->bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (field->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (field->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -319,10 +337,10 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(newField);
|
RAW_NULL_CHECK(newField);
|
||||||
cJSON* colName = cJSON_CreateString(oldField->name);
|
cJSON* colName = cJSON_CreateString(oldField->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colNewName = cJSON_CreateString(newField->name);
|
cJSON* colNewName = cJSON_CreateString(newField->name);
|
||||||
RAW_NULL_CHECK(colNewName);
|
RAW_NULL_CHECK(colNewName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colNewName", colNewName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colNewName", colNewName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
|
||||||
|
@ -330,7 +348,7 @@ static void buildAlterSTableJson(void* alterData, int32_t alterDataLen, cJSON**
|
||||||
RAW_NULL_CHECK(field);
|
RAW_NULL_CHECK(field);
|
||||||
cJSON* colName = cJSON_CreateString(field->name);
|
cJSON* colName = cJSON_CreateString(field->name);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
RAW_RETURN_CHECK(setCompressOption(json, field->bytes));
|
RAW_RETURN_CHECK(setCompressOption(json, field->bytes));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -391,51 +409,47 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
int64_t id = pCreateReq->uid;
|
int64_t id = pCreateReq->uid;
|
||||||
uint8_t tagNum = pCreateReq->ctb.tagNum;
|
uint8_t tagNum = pCreateReq->ctb.tagNum;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
cJSON* tags = NULL;
|
SArray* pTagVals = NULL;
|
||||||
|
char* pJson = NULL;
|
||||||
|
|
||||||
cJSON* tableName = cJSON_CreateString(name);
|
cJSON* tableName = cJSON_CreateString(name);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableName", tableName));
|
||||||
cJSON* using = cJSON_CreateString(sname);
|
cJSON* using = cJSON_CreateString(sname);
|
||||||
RAW_NULL_CHECK(using);
|
RAW_NULL_CHECK(using);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "using", using));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "using", using));
|
||||||
cJSON* tagNumJson = cJSON_CreateNumber(tagNum);
|
cJSON* tagNumJson = cJSON_CreateNumber(tagNum);
|
||||||
RAW_NULL_CHECK(tagNumJson);
|
RAW_NULL_CHECK(tagNumJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tagNum", tagNumJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tagNum", tagNumJson));
|
||||||
|
|
||||||
tags = cJSON_CreateArray();
|
cJSON* tags = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(tags);
|
RAW_NULL_CHECK(tags);
|
||||||
SArray* pTagVals = NULL;
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tags", tags));
|
||||||
RAW_RETURN_CHECK(tTagToValArray(pTag, &pTagVals));
|
RAW_RETURN_CHECK(tTagToValArray(pTag, &pTagVals));
|
||||||
|
|
||||||
if (tTagIsJson(pTag)) {
|
if (tTagIsJson(pTag)) {
|
||||||
STag* p = (STag*)pTag;
|
STag* p = (STag*)pTag;
|
||||||
if (p->nTag == 0) {
|
if (p->nTag == 0) {
|
||||||
uError("p->nTag == 0");
|
uError("p->nTag == 0");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
char* pJson = NULL;
|
|
||||||
parseTagDatatoJson(pTag, &pJson);
|
parseTagDatatoJson(pTag, &pJson);
|
||||||
if (pJson == NULL) {
|
RAW_NULL_CHECK(pJson);
|
||||||
uError("parseTagDatatoJson failed, pJson == NULL");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
cJSON* tag = cJSON_CreateObject();
|
cJSON* tag = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(tag);
|
RAW_NULL_CHECK(tag);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(tags, tag));
|
||||||
STagVal* pTagVal = taosArrayGet(pTagVals, 0);
|
STagVal* pTagVal = taosArrayGet(pTagVals, 0);
|
||||||
RAW_NULL_CHECK(pTagVal);
|
RAW_NULL_CHECK(pTagVal);
|
||||||
char* ptname = taosArrayGet(tagName, 0);
|
char* ptname = taosArrayGet(tagName, 0);
|
||||||
RAW_NULL_CHECK(ptname);
|
RAW_NULL_CHECK(ptname);
|
||||||
cJSON* tname = cJSON_CreateString(ptname);
|
cJSON* tname = cJSON_CreateString(ptname);
|
||||||
RAW_NULL_CHECK(tname);
|
RAW_NULL_CHECK(tname);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "name", tname));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "name", tname));
|
||||||
cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON);
|
cJSON* ttype = cJSON_CreateNumber(TSDB_DATA_TYPE_JSON);
|
||||||
RAW_NULL_CHECK(ttype);
|
RAW_NULL_CHECK(ttype);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "type", ttype));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "type", ttype));
|
||||||
cJSON* tvalue = cJSON_CreateString(pJson);
|
cJSON* tvalue = cJSON_CreateString(pJson);
|
||||||
RAW_NULL_CHECK(tvalue);
|
RAW_NULL_CHECK(tvalue);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "value", tvalue));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "value", tvalue));
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(tags, tag));
|
|
||||||
taosMemoryFree(pJson);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,36 +458,34 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
RAW_NULL_CHECK(pTagVal);
|
RAW_NULL_CHECK(pTagVal);
|
||||||
cJSON* tag = cJSON_CreateObject();
|
cJSON* tag = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(tag);
|
RAW_NULL_CHECK(tag);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(tags, tag));
|
||||||
char* ptname = taosArrayGet(tagName, i);
|
char* ptname = taosArrayGet(tagName, i);
|
||||||
RAW_NULL_CHECK(ptname);
|
RAW_NULL_CHECK(ptname);
|
||||||
cJSON* tname = cJSON_CreateString(ptname);
|
cJSON* tname = cJSON_CreateString(ptname);
|
||||||
RAW_NULL_CHECK(tname);
|
RAW_NULL_CHECK(tname);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "name", tname));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "name", tname));
|
||||||
cJSON* ttype = cJSON_CreateNumber(pTagVal->type);
|
cJSON* ttype = cJSON_CreateNumber(pTagVal->type);
|
||||||
RAW_NULL_CHECK(ttype);
|
RAW_NULL_CHECK(ttype);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "type", ttype));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "type", ttype));
|
||||||
|
|
||||||
cJSON* tvalue = NULL;
|
cJSON* tvalue = NULL;
|
||||||
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
|
||||||
char* buf = NULL;
|
|
||||||
int64_t bufSize = 0;
|
int64_t bufSize = 0;
|
||||||
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
bufSize = pTagVal->nData * 2 + 2 + 3;
|
bufSize = pTagVal->nData * 2 + 2 + 3;
|
||||||
} else {
|
} else {
|
||||||
bufSize = pTagVal->nData + 3;
|
bufSize = pTagVal->nData + 3;
|
||||||
}
|
}
|
||||||
buf = taosMemoryCalloc(bufSize, 1);
|
char* buf = taosMemoryCalloc(bufSize, 1);
|
||||||
|
|
||||||
RAW_NULL_CHECK(buf);
|
RAW_NULL_CHECK(buf);
|
||||||
if (!buf) goto end;
|
|
||||||
if (dataConverToStr(buf, bufSize, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
if (dataConverToStr(buf, bufSize, pTagVal->type, pTagVal->pData, pTagVal->nData, NULL) != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
tvalue = cJSON_CreateString(buf);
|
tvalue = cJSON_CreateString(buf);
|
||||||
RAW_NULL_CHECK(tvalue);
|
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
|
RAW_NULL_CHECK(tvalue);
|
||||||
} else {
|
} else {
|
||||||
double val = 0;
|
double val = 0;
|
||||||
GET_TYPED_DATA(val, double, pTagVal->type, &pTagVal->i64);
|
GET_TYPED_DATA(val, double, pTagVal->type, &pTagVal->i64);
|
||||||
|
@ -481,12 +493,11 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
||||||
RAW_NULL_CHECK(tvalue);
|
RAW_NULL_CHECK(tvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(tag, "value", tvalue));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(tag, "value", tvalue));
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(tags, tag));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
taosMemoryFree(pJson);
|
||||||
taosArrayDestroy(pTagVals);
|
taosArrayDestroy(pTagVals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,22 +508,23 @@ static void buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs, cJSO
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("create");
|
cJSON* type = cJSON_CreateString("create");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
|
|
||||||
cJSON* tableType = cJSON_CreateString("child");
|
cJSON* tableType = cJSON_CreateString("child");
|
||||||
RAW_NULL_CHECK(tableType);
|
RAW_NULL_CHECK(tableType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableType", tableType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableType", tableType));
|
||||||
|
|
||||||
buildChildElement(json, pCreateReq);
|
buildChildElement(json, pCreateReq);
|
||||||
cJSON* createList = cJSON_CreateArray();
|
cJSON* createList = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(createList);
|
RAW_NULL_CHECK(createList);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "createList", createList));
|
||||||
|
|
||||||
for (int i = 0; nReqs > 1 && i < nReqs; i++) {
|
for (int i = 0; nReqs > 1 && i < nReqs; i++) {
|
||||||
cJSON* create = cJSON_CreateObject();
|
cJSON* create = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(create);
|
RAW_NULL_CHECK(create);
|
||||||
buildChildElement(create, pCreateReq + i);
|
buildChildElement(create, pCreateReq + i);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(createList, create));
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(createList, create));
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "createList", createList));
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
*pJson = json;
|
*pJson = json;
|
||||||
|
@ -619,62 +631,62 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("alter");
|
cJSON* type = cJSON_CreateString("alter");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
cJSON* tableType = cJSON_CreateString(vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_TAG_VAL ||
|
cJSON* tableType = cJSON_CreateString(vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_TAG_VAL ||
|
||||||
vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL
|
vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL
|
||||||
? "child"
|
? "child"
|
||||||
: "normal");
|
: "normal");
|
||||||
RAW_NULL_CHECK(tableType);
|
RAW_NULL_CHECK(tableType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableType", tableType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableType", tableType));
|
||||||
cJSON* tableName = cJSON_CreateString(vAlterTbReq.tbName);
|
cJSON* tableName = cJSON_CreateString(vAlterTbReq.tbName);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableName", tableName));
|
||||||
cJSON* alterType = cJSON_CreateNumber(vAlterTbReq.action);
|
cJSON* alterType = cJSON_CreateNumber(vAlterTbReq.action);
|
||||||
RAW_NULL_CHECK(alterType);
|
RAW_NULL_CHECK(alterType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "alterType", alterType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "alterType", alterType));
|
||||||
|
|
||||||
switch (vAlterTbReq.action) {
|
switch (vAlterTbReq.action) {
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN: {
|
case TSDB_ALTER_TABLE_ADD_COLUMN: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type);
|
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
|
|
||||||
if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY ||
|
if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) {
|
vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE;
|
int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (vAlterTbReq.type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (vAlterTbReq.type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (vAlterTbReq.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (vAlterTbReq.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION: {
|
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type);
|
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
|
|
||||||
if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY ||
|
if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) {
|
vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE;
|
int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (vAlterTbReq.type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (vAlterTbReq.type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (vAlterTbReq.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (vAlterTbReq.bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
RAW_RETURN_CHECK(setCompressOption(json, vAlterTbReq.compress));
|
RAW_RETURN_CHECK(setCompressOption(json, vAlterTbReq.compress));
|
||||||
break;
|
break;
|
||||||
|
@ -682,43 +694,43 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN: {
|
case TSDB_ALTER_TABLE_DROP_COLUMN: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: {
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.colModType);
|
cJSON* colType = cJSON_CreateNumber(vAlterTbReq.colModType);
|
||||||
RAW_NULL_CHECK(colType);
|
RAW_NULL_CHECK(colType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colType", colType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colType", colType));
|
||||||
if (vAlterTbReq.colModType == TSDB_DATA_TYPE_BINARY || vAlterTbReq.colModType == TSDB_DATA_TYPE_VARBINARY ||
|
if (vAlterTbReq.colModType == TSDB_DATA_TYPE_BINARY || vAlterTbReq.colModType == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
vAlterTbReq.colModType == TSDB_DATA_TYPE_GEOMETRY) {
|
vAlterTbReq.colModType == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
int32_t length = vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE;
|
int32_t length = vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
} else if (vAlterTbReq.colModType == TSDB_DATA_TYPE_NCHAR) {
|
} else if (vAlterTbReq.colModType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t length = (vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
int32_t length = (vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
cJSON* cbytes = cJSON_CreateNumber(length);
|
cJSON* cbytes = cJSON_CreateNumber(length);
|
||||||
RAW_NULL_CHECK(cbytes);
|
RAW_NULL_CHECK(cbytes);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colLength", cbytes));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colLength", cbytes));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: {
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
cJSON* colNewName = cJSON_CreateString(vAlterTbReq.colNewName);
|
cJSON* colNewName = cJSON_CreateString(vAlterTbReq.colNewName);
|
||||||
RAW_NULL_CHECK(colNewName);
|
RAW_NULL_CHECK(colNewName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colNewName", colNewName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colNewName", colNewName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL: {
|
case TSDB_ALTER_TABLE_UPDATE_TAG_VAL: {
|
||||||
cJSON* tagName = cJSON_CreateString(vAlterTbReq.tagName);
|
cJSON* tagName = cJSON_CreateString(vAlterTbReq.tagName);
|
||||||
RAW_NULL_CHECK(tagName);
|
RAW_NULL_CHECK(tagName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", tagName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", tagName));
|
||||||
|
|
||||||
bool isNull = vAlterTbReq.isNull;
|
bool isNull = vAlterTbReq.isNull;
|
||||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) {
|
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
@ -757,12 +769,12 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
cJSON* colValue = cJSON_CreateString(buf);
|
cJSON* colValue = cJSON_CreateString(buf);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
RAW_NULL_CHECK(colValue);
|
RAW_NULL_CHECK(colValue);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValue", colValue));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colValue", colValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
||||||
RAW_NULL_CHECK(isNullCJson);
|
RAW_NULL_CHECK(isNullCJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colValueNull", isNullCJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colValueNull", isNullCJson));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL: {
|
case TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL: {
|
||||||
|
@ -774,14 +786,17 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
|
|
||||||
cJSON* tags = cJSON_CreateArray();
|
cJSON* tags = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(tags);
|
RAW_NULL_CHECK(tags);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tags", tags));
|
||||||
|
|
||||||
for (int32_t i = 0; i < nTags; i++) {
|
for (int32_t i = 0; i < nTags; i++) {
|
||||||
cJSON* member = cJSON_CreateObject();
|
cJSON* member = cJSON_CreateObject();
|
||||||
RAW_NULL_CHECK(member);
|
RAW_NULL_CHECK(member);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(tags, member));
|
||||||
|
|
||||||
SMultiTagUpateVal* pTagVal = taosArrayGet(vAlterTbReq.pMultiTag, i);
|
SMultiTagUpateVal* pTagVal = taosArrayGet(vAlterTbReq.pMultiTag, i);
|
||||||
cJSON* tagName = cJSON_CreateString(pTagVal->tagName);
|
cJSON* tagName = cJSON_CreateString(pTagVal->tagName);
|
||||||
RAW_NULL_CHECK(tagName);
|
RAW_NULL_CHECK(tagName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colName", tagName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(member, "colName", tagName));
|
||||||
|
|
||||||
if (pTagVal->tagType == TSDB_DATA_TYPE_JSON) {
|
if (pTagVal->tagType == TSDB_DATA_TYPE_JSON) {
|
||||||
uError("processAlterTable isJson false");
|
uError("processAlterTable isJson false");
|
||||||
|
@ -789,14 +804,13 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
}
|
}
|
||||||
bool isNull = pTagVal->isNull;
|
bool isNull = pTagVal->isNull;
|
||||||
if (!isNull) {
|
if (!isNull) {
|
||||||
char* buf = NULL;
|
|
||||||
int64_t bufSize = 0;
|
int64_t bufSize = 0;
|
||||||
if (pTagVal->tagType == TSDB_DATA_TYPE_VARBINARY) {
|
if (pTagVal->tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
bufSize = pTagVal->nTagVal * 2 + 2 + 3;
|
bufSize = pTagVal->nTagVal * 2 + 2 + 3;
|
||||||
} else {
|
} else {
|
||||||
bufSize = pTagVal->nTagVal + 3;
|
bufSize = pTagVal->nTagVal + 3;
|
||||||
}
|
}
|
||||||
buf = taosMemoryCalloc(bufSize, 1);
|
char* buf = taosMemoryCalloc(bufSize, 1);
|
||||||
RAW_NULL_CHECK(buf);
|
RAW_NULL_CHECK(buf);
|
||||||
if (dataConverToStr(buf, bufSize, pTagVal->tagType, pTagVal->pTagVal, pTagVal->nTagVal, NULL) !=
|
if (dataConverToStr(buf, bufSize, pTagVal->tagType, pTagVal->pTagVal, pTagVal->nTagVal, NULL) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
|
@ -806,21 +820,19 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
cJSON* colValue = cJSON_CreateString(buf);
|
cJSON* colValue = cJSON_CreateString(buf);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
RAW_NULL_CHECK(colValue);
|
RAW_NULL_CHECK(colValue);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colValue", colValue));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(member, "colValue", colValue));
|
||||||
}
|
}
|
||||||
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
cJSON* isNullCJson = cJSON_CreateBool(isNull);
|
||||||
RAW_NULL_CHECK(isNullCJson);
|
RAW_NULL_CHECK(isNullCJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(member, "colValueNull", isNullCJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(member, "colValueNull", isNullCJson));
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(tags, member));
|
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tags", tags));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: {
|
||||||
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
cJSON* colName = cJSON_CreateString(vAlterTbReq.colName);
|
||||||
RAW_NULL_CHECK(colName);
|
RAW_NULL_CHECK(colName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "colName", colName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "colName", colName));
|
||||||
RAW_RETURN_CHECK(setCompressOption(json, vAlterTbReq.compress));
|
RAW_RETURN_CHECK(setCompressOption(json, vAlterTbReq.compress));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -858,13 +870,13 @@ static void processDropSTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("drop");
|
cJSON* type = cJSON_CreateString("drop");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
cJSON* tableType = cJSON_CreateString("super");
|
cJSON* tableType = cJSON_CreateString("super");
|
||||||
RAW_NULL_CHECK(tableType);
|
RAW_NULL_CHECK(tableType);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableType", tableType));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableType", tableType));
|
||||||
cJSON* tableName = cJSON_CreateString(req.name);
|
cJSON* tableName = cJSON_CreateString(req.name);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableName", tableName));
|
||||||
|
|
||||||
end:
|
end:
|
||||||
uDebug("processDropSTable return");
|
uDebug("processDropSTable return");
|
||||||
|
@ -897,10 +909,10 @@ static void processDeleteTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("delete");
|
cJSON* type = cJSON_CreateString("delete");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
cJSON* sqlJson = cJSON_CreateString(sql);
|
cJSON* sqlJson = cJSON_CreateString(sql);
|
||||||
RAW_NULL_CHECK(sqlJson);
|
RAW_NULL_CHECK(sqlJson);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", sqlJson));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "sql", sqlJson));
|
||||||
|
|
||||||
end:
|
end:
|
||||||
uDebug("processDeleteTable return");
|
uDebug("processDeleteTable return");
|
||||||
|
@ -928,16 +940,17 @@ static void processDropTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
||||||
RAW_NULL_CHECK(json);
|
RAW_NULL_CHECK(json);
|
||||||
cJSON* type = cJSON_CreateString("drop");
|
cJSON* type = cJSON_CreateString("drop");
|
||||||
RAW_NULL_CHECK(type);
|
RAW_NULL_CHECK(type);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "type", type));
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "type", type));
|
||||||
cJSON* tableNameList = cJSON_CreateArray();
|
cJSON* tableNameList = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(tableNameList);
|
RAW_NULL_CHECK(tableNameList);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(json, "tableNameList", tableNameList));
|
||||||
|
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
SVDropTbReq* pDropTbReq = req.pReqs + iReq;
|
SVDropTbReq* pDropTbReq = req.pReqs + iReq;
|
||||||
cJSON* tableName = cJSON_CreateString(pDropTbReq->name);
|
cJSON* tableName = cJSON_CreateString(pDropTbReq->name);
|
||||||
RAW_NULL_CHECK(tableName);
|
RAW_NULL_CHECK(tableName);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(tableNameList, tableName));
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(tableNameList, tableName));
|
||||||
}
|
}
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableNameList", tableNameList));
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
uDebug("processDropTable return");
|
uDebug("processDropTable return");
|
||||||
|
@ -2183,6 +2196,8 @@ static void processBatchMetaToJson(SMqBatchMetaRsp* pMsgRsp, char** string) {
|
||||||
RAW_FALSE_CHECK(cJSON_AddStringToObject(pJson, "tmq_meta_version", TMQ_META_VERSION));
|
RAW_FALSE_CHECK(cJSON_AddStringToObject(pJson, "tmq_meta_version", TMQ_META_VERSION));
|
||||||
cJSON* pMetaArr = cJSON_CreateArray();
|
cJSON* pMetaArr = cJSON_CreateArray();
|
||||||
RAW_NULL_CHECK(pMetaArr);
|
RAW_NULL_CHECK(pMetaArr);
|
||||||
|
RAW_FALSE_CHECK(tmqAddJsonObjectItem(pJson, "metas", pMetaArr));
|
||||||
|
|
||||||
int32_t num = taosArrayGetSize(rsp.batchMetaReq);
|
int32_t num = taosArrayGetSize(rsp.batchMetaReq);
|
||||||
for (int32_t i = 0; i < num; i++) {
|
for (int32_t i = 0; i < num; i++) {
|
||||||
int32_t* len = taosArrayGet(rsp.batchMetaLen, i);
|
int32_t* len = taosArrayGet(rsp.batchMetaLen, i);
|
||||||
|
@ -2198,10 +2213,9 @@ static void processBatchMetaToJson(SMqBatchMetaRsp* pMsgRsp, char** string) {
|
||||||
cJSON* pItem = NULL;
|
cJSON* pItem = NULL;
|
||||||
processSimpleMeta(&metaRsp, &pItem);
|
processSimpleMeta(&metaRsp, &pItem);
|
||||||
tDeleteMqMetaRsp(&metaRsp);
|
tDeleteMqMetaRsp(&metaRsp);
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToArray(pMetaArr, pItem));
|
RAW_FALSE_CHECK(tmqAddJsonArrayItem(pMetaArr, pItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
RAW_FALSE_CHECK(cJSON_AddItemToObject(pJson, "metas", pMetaArr));
|
|
||||||
tDeleteMqBatchMetaRsp(&rsp);
|
tDeleteMqBatchMetaRsp(&rsp);
|
||||||
char* fullStr = cJSON_PrintUnformatted(pJson);
|
char* fullStr = cJSON_PrintUnformatted(pJson);
|
||||||
cJSON_Delete(pJson);
|
cJSON_Delete(pJson);
|
||||||
|
|
|
@ -300,7 +300,13 @@ void* doConsumeData(void* param) {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
numOfThreads = atoi(argv[1]);
|
//numOfThreads = atoi(argv[1]);
|
||||||
|
int32_t code = taosStr2int32(argv[1], &numOfThreads);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfThreads = TMAX(numOfThreads, 1);
|
numOfThreads = TMAX(numOfThreads, 1);
|
||||||
|
|
|
@ -261,7 +261,7 @@ static void responseCompleteCallback(S3Status status, const S3ErrorDetails *erro
|
||||||
for (int i = 0; i < error->extraDetailsCount; i++) {
|
for (int i = 0; i < error->extraDetailsCount; i++) {
|
||||||
if (elen - len > 0) {
|
if (elen - len > 0) {
|
||||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
||||||
error->extraDetails[i].value);
|
error->extraDetails[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -742,9 +742,9 @@ upload:
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
||||||
}
|
}
|
||||||
n = tsnprintf(buf, sizeof(buf),
|
n = tsnprintf(buf, sizeof(buf),
|
||||||
"<Part><PartNumber>%d</PartNumber>"
|
"<Part><PartNumber>%d</PartNumber>"
|
||||||
"<ETag>%s</ETag></Part>",
|
"<ETag>%s</ETag></Part>",
|
||||||
i + 1, manager.etags[i]);
|
i + 1, manager.etags[i]);
|
||||||
size += growbuffer_append(&(manager.gb), buf, n);
|
size += growbuffer_append(&(manager.gb), buf, n);
|
||||||
}
|
}
|
||||||
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
||||||
|
@ -908,10 +908,10 @@ upload:
|
||||||
int n;
|
int n;
|
||||||
for (int i = 0; i < cp.part_num; ++i) {
|
for (int i = 0; i < cp.part_num; ++i) {
|
||||||
n = tsnprintf(buf, sizeof(buf),
|
n = tsnprintf(buf, sizeof(buf),
|
||||||
"<Part><PartNumber>%d</PartNumber>"
|
"<Part><PartNumber>%d</PartNumber>"
|
||||||
"<ETag>%s</ETag></Part>",
|
"<ETag>%s</ETag></Part>",
|
||||||
// i + 1, manager.etags[i]);
|
// i + 1, manager.etags[i]);
|
||||||
cp.parts[i].index + 1, cp.parts[i].etag);
|
cp.parts[i].index + 1, cp.parts[i].etag);
|
||||||
size += growbuffer_append(&(manager.gb), buf, n);
|
size += growbuffer_append(&(manager.gb), buf, n);
|
||||||
}
|
}
|
||||||
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
size += growbuffer_append(&(manager.gb), "</CompleteMultipartUpload>", strlen("</CompleteMultipartUpload>"));
|
||||||
|
@ -1916,7 +1916,8 @@ void s3EvictCache(const char *path, long object_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
long s3Size(const char *object_name) {
|
long s3Size(const char *object_name) {
|
||||||
long size = 0;
|
int32_t code = 0;
|
||||||
|
long size = 0;
|
||||||
|
|
||||||
cos_pool_t *p = NULL;
|
cos_pool_t *p = NULL;
|
||||||
int is_cname = 0;
|
int is_cname = 0;
|
||||||
|
@ -1941,7 +1942,10 @@ long s3Size(const char *object_name) {
|
||||||
if (cos_status_is_ok(s)) {
|
if (cos_status_is_ok(s)) {
|
||||||
char *content_length_str = (char *)apr_table_get(resp_headers, COS_CONTENT_LENGTH);
|
char *content_length_str = (char *)apr_table_get(resp_headers, COS_CONTENT_LENGTH);
|
||||||
if (content_length_str != NULL) {
|
if (content_length_str != NULL) {
|
||||||
size = atol(content_length_str);
|
code = taosStr2Int64(content_length_str, &size);
|
||||||
|
if (code != 0) {
|
||||||
|
cos_warn_log("parse content length failed since %s\n", tstrerror(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cos_warn_log("head object succeeded: %ld\n", size);
|
cos_warn_log("head object succeeded: %ld\n", size);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -251,7 +251,7 @@ bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
}
|
}
|
||||||
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(encode)) {
|
if (0 == strlen(encode)) {
|
||||||
strncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
tstrncpy(encode, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkColumnEncode(encode) && validColEncode(type, columnEncodeVal(encode));
|
return checkColumnEncode(encode) && validColEncode(type, columnEncodeVal(encode));
|
||||||
|
@ -268,7 +268,7 @@ bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
}
|
}
|
||||||
bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(compress)) {
|
if (0 == strlen(compress)) {
|
||||||
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
tstrncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
}
|
}
|
||||||
bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(level)) {
|
if (0 == strlen(level)) {
|
||||||
strncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
tstrncpy(level, getDefaultLevelStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkColumnLevel(level) && validColCompressLevel(type, columnLevelVal(level));
|
return checkColumnLevel(level) && validColCompressLevel(type, columnLevelVal(level));
|
||||||
|
@ -314,7 +314,7 @@ void setColLevel(uint32_t* compress, uint8_t level) {
|
||||||
|
|
||||||
int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||||
uint32_t* compress) {
|
uint32_t* compress) {
|
||||||
if(compress == NULL) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (compress == NULL) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
if (check && !validColEncode(type, encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (check && !validColEncode(type, encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
setColEncode(compress, encode);
|
setColEncode(compress, encode);
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,15 @@
|
||||||
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
|
||||||
pEp->port = 0;
|
pEp->port = 0;
|
||||||
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
memset(pEp->fqdn, 0, TSDB_FQDN_LEN);
|
||||||
strncpy(pEp->fqdn, ep, TSDB_FQDN_LEN - 1);
|
tstrncpy(pEp->fqdn, ep, TSDB_FQDN_LEN);
|
||||||
|
|
||||||
char* temp = strchr(pEp->fqdn, ':');
|
char* temp = strchr(pEp->fqdn, ':');
|
||||||
if (temp) {
|
if (temp) {
|
||||||
*temp = 0;
|
*temp = 0;
|
||||||
pEp->port = atoi(temp + 1);
|
pEp->port = taosStr2UInt16(temp + 1, NULL, 10);
|
||||||
|
if (pEp->port < 0) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEp->port == 0) {
|
if (pEp->port == 0) {
|
||||||
|
@ -282,7 +285,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
||||||
locked = 1;
|
locked = 1;
|
||||||
|
|
||||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||||
_start:
|
_start:
|
||||||
col = startCol;
|
col = startCol;
|
||||||
|
|
||||||
// GRANT_CFG_SKIP;
|
// GRANT_CFG_SKIP;
|
||||||
|
@ -297,11 +300,11 @@ _start:
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, name, false), NULL, _exit);
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, name, false), NULL, _exit);
|
||||||
|
|
||||||
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
|
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
int32_t valueLen = 0;
|
int32_t valueLen = 0;
|
||||||
SDiskCfg* pDiskCfg = NULL;
|
SDiskCfg* pDiskCfg = NULL;
|
||||||
if (strcasecmp(pItem->name, "dataDir") == 0 && exSize > 0) {
|
if (strcasecmp(pItem->name, "dataDir") == 0 && exSize > 0) {
|
||||||
char* buf = &value[VARSTR_HEADER_SIZE];
|
char* buf = &value[VARSTR_HEADER_SIZE];
|
||||||
pDiskCfg = taosArrayGet(pItem->array, index);
|
pDiskCfg = taosArrayGet(pItem->array, index);
|
||||||
valueLen = tsnprintf(buf, TSDB_CONFIG_PATH_LEN, "%s", pDiskCfg->dir);
|
valueLen = tsnprintf(buf, TSDB_CONFIG_PATH_LEN, "%s", pDiskCfg->dir);
|
||||||
index++;
|
index++;
|
||||||
|
@ -334,7 +337,7 @@ _start:
|
||||||
if (strcasecmp(pItem->name, "dataDir") == 0 && pDiskCfg) {
|
if (strcasecmp(pItem->name, "dataDir") == 0 && pDiskCfg) {
|
||||||
char* buf = &info[VARSTR_HEADER_SIZE];
|
char* buf = &info[VARSTR_HEADER_SIZE];
|
||||||
valueLen = tsnprintf(buf, TSDB_CONFIG_INFO_LEN, "level %d primary %d disabled %" PRIi8, pDiskCfg->level,
|
valueLen = tsnprintf(buf, TSDB_CONFIG_INFO_LEN, "level %d primary %d disabled %" PRIi8, pDiskCfg->level,
|
||||||
pDiskCfg->primary, pDiskCfg->disable);
|
pDiskCfg->primary, pDiskCfg->disable);
|
||||||
} else {
|
} else {
|
||||||
valueLen = 0;
|
valueLen = 0;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +354,7 @@ _start:
|
||||||
if (index > 0 && index <= exSize) {
|
if (index > 0 && index <= exSize) {
|
||||||
goto _start;
|
goto _start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pBlock->info.rows = numOfRows;
|
pBlock->info.rows = numOfRows;
|
||||||
_exit:
|
_exit:
|
||||||
if (locked) cfgUnLock(pConf);
|
if (locked) cfgUnLock(pConf);
|
||||||
|
|
|
@ -251,7 +251,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
printf("ERROR: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN);
|
printf("ERROR: Encrypt key overflow, it should be at most %d characters\n", ENCRYPT_KEY_LEN);
|
||||||
return TSDB_CODE_INVALID_CFG;
|
return TSDB_CODE_INVALID_CFG;
|
||||||
}
|
}
|
||||||
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN);
|
tstrncpy(global.encryptKey, argv[i], ENCRYPT_KEY_LEN + 1);
|
||||||
} else {
|
} else {
|
||||||
printf("'-y' requires a parameter\n");
|
printf("'-y' requires a parameter\n");
|
||||||
return TSDB_CODE_INVALID_CFG;
|
return TSDB_CODE_INVALID_CFG;
|
||||||
|
|
|
@ -114,7 +114,7 @@ static void dmMayShouldUpdateAnalFunc(SDnodeMgmt *pMgmt, int64_t newVer) {
|
||||||
.pCont = pHead,
|
.pCont = pHead,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.msgType = TDMT_MND_RETRIEVE_ANAL_ALGO,
|
.msgType = TDMT_MND_RETRIEVE_ANAL_ALGO,
|
||||||
.info.ahandle = (void *)0x9527,
|
.info.ahandle = 0,
|
||||||
.info.refId = 0,
|
.info.refId = 0,
|
||||||
.info.noResp = 0,
|
.info.noResp = 0,
|
||||||
.info.handle = 0,
|
.info.handle = 0,
|
||||||
|
|
|
@ -186,7 +186,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
#if defined(TD_ENTERPRISE)
|
#if defined(TD_ENTERPRISE)
|
||||||
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
pCfg->tsdbCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
if (pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4) {
|
if (pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||||
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
pCfg->tsdbCfg.encryptAlgorithm = 0;
|
pCfg->tsdbCfg.encryptAlgorithm = 0;
|
||||||
|
@ -202,7 +202,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
#if defined(TD_ENTERPRISE)
|
#if defined(TD_ENTERPRISE)
|
||||||
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
pCfg->walCfg.encryptAlgorithm = pCreate->encryptAlgorithm;
|
||||||
if (pCfg->walCfg.encryptAlgorithm == DND_CA_SM4) {
|
if (pCfg->walCfg.encryptAlgorithm == DND_CA_SM4) {
|
||||||
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
pCfg->walCfg.encryptAlgorithm = 0;
|
pCfg->walCfg.encryptAlgorithm = 0;
|
||||||
|
@ -898,7 +898,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
size_t size = taosArrayGetSize(arbHbReq.hbMembers);
|
size_t size = taosArrayGetSize(arbHbReq.hbMembers);
|
||||||
|
|
||||||
arbHbRsp.dnodeId = pMgmt->pData->dnodeId;
|
arbHbRsp.dnodeId = pMgmt->pData->dnodeId;
|
||||||
strncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE);
|
tstrncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE);
|
||||||
arbHbRsp.hbMembers = taosArrayInit(size, sizeof(SVArbHbRspMember));
|
arbHbRsp.hbMembers = taosArrayInit(size, sizeof(SVArbHbRspMember));
|
||||||
if (arbHbRsp.hbMembers == NULL) {
|
if (arbHbRsp.hbMembers == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
|
|
@ -179,7 +179,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
||||||
|
|
||||||
//code = taosGetCryptKey(tsAuthCode, pData->machineId, tsCryptKey);
|
//code = taosGetCryptKey(tsAuthCode, pData->machineId, tsCryptKey);
|
||||||
code = 0;
|
code = 0;
|
||||||
strncpy(tsEncryptKey, tsAuthCode, 16);
|
tstrncpy(tsEncryptKey, tsAuthCode, 16);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
if(code == -1){
|
if(code == -1){
|
||||||
|
@ -220,6 +220,7 @@ int32_t dmInitVars(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern SMonVloadInfo tsVinfo;
|
extern SMonVloadInfo tsVinfo;
|
||||||
|
|
||||||
void dmClearVars(SDnode *pDnode) {
|
void dmClearVars(SDnode *pDnode) {
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
|
|
|
@ -230,7 +230,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
SCryptOpts opts;
|
SCryptOpts opts;
|
||||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
|
||||||
opts.len = len;
|
opts.len = len;
|
||||||
opts.source = DM_KEY_INDICATOR;
|
opts.source = DM_KEY_INDICATOR;
|
||||||
opts.result = result;
|
opts.result = result;
|
||||||
|
@ -349,7 +349,7 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCryptOpts opts = {0};
|
SCryptOpts opts = {0};
|
||||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, key, ENCRYPT_KEY_LEN + 1);
|
||||||
opts.len = len;
|
opts.len = len;
|
||||||
opts.source = content;
|
opts.source = content;
|
||||||
opts.result = result;
|
opts.result = result;
|
||||||
|
@ -551,7 +551,7 @@ int32_t dmGetEncryptKey() {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN);
|
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
taosMemoryFreeClear(encryptKey);
|
taosMemoryFreeClear(encryptKey);
|
||||||
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
|
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
|
||||||
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char dbNameInGroup[TSDB_DB_FNAME_LEN];
|
char dbNameInGroup[TSDB_DB_FNAME_LEN];
|
||||||
strncpy(dbNameInGroup, pVgObj->dbName, TSDB_DB_FNAME_LEN);
|
tstrncpy(dbNameInGroup, pVgObj->dbName, TSDB_DB_FNAME_LEN);
|
||||||
sdbRelease(pSdb, pVgObj);
|
sdbRelease(pSdb, pVgObj);
|
||||||
|
|
||||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
|
|
@ -244,7 +244,7 @@ int32_t mndCompactGetDbName(SMnode *pMnode, int32_t compactId, char *dbname, int
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)strncpy(dbname, pCompact->dbname, len);
|
tstrncpy(dbname, pCompact->dbname, len);
|
||||||
mndReleaseCompact(pMnode, pCompact);
|
mndReleaseCompact(pMnode, pCompact);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ int32_t mndRetrieveCompact(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock,
|
||||||
TAOS_CHECK_GOTO(tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB), &lino, _OVER);
|
TAOS_CHECK_GOTO(tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB), &lino, _OVER);
|
||||||
(void)tNameGetDbName(&name, varDataVal(tmpBuf));
|
(void)tNameGetDbName(&name, varDataVal(tmpBuf));
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
tstrncpy(varDataVal(tmpBuf), pCompact->dbname, TSDB_SHOW_SQL_LEN);
|
||||||
}
|
}
|
||||||
varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf)));
|
varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf)));
|
||||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false), pCompact, &lino, _OVER);
|
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false), pCompact, &lino, _OVER);
|
||||||
|
@ -516,11 +516,14 @@ int32_t mndProcessKillCompactReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
char obj[TSDB_INT32_ID_LEN] = {0};
|
char obj[TSDB_INT32_ID_LEN] = {0};
|
||||||
(void)sprintf(obj, "%d", pCompact->compactId);
|
int32_t nBytes = snprintf(obj, sizeof(obj), "%d", pCompact->compactId);
|
||||||
|
if ((uint32_t)nBytes < sizeof(obj)) {
|
||||||
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql, killCompactReq.sqlLen);
|
auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql,
|
||||||
|
killCompactReq.sqlLen);
|
||||||
|
} else {
|
||||||
|
mError("compact:%" PRId32 " failed to audit since %s", pCompact->compactId, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||||
|
}
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
mError("failed to kill compact %" PRId32 " since %s", killCompactReq.compactId, terrstr());
|
mError("failed to kill compact %" PRId32 " since %s", killCompactReq.compactId, terrstr());
|
||||||
|
@ -641,7 +644,7 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
||||||
|
|
||||||
char detail[1024] = {0};
|
char detail[1024] = {0};
|
||||||
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
||||||
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
||||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||||
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
|
#include "command.h"
|
||||||
#include "mndArbGroup.h"
|
#include "mndArbGroup.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
|
@ -34,7 +35,6 @@
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
#include "thttp.h"
|
#include "thttp.h"
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
#include "command.h"
|
|
||||||
|
|
||||||
#define DB_VER_NUMBER 1
|
#define DB_VER_NUMBER 1
|
||||||
#define DB_RESERVE_SIZE 27
|
#define DB_RESERVE_SIZE 27
|
||||||
|
@ -416,7 +416,12 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
|
||||||
return TSDB_CODE_MND_INVALID_DB;
|
return TSDB_CODE_MND_INVALID_DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t acctId = atoi(dbName);
|
int32_t acctId;
|
||||||
|
int32_t code = taosStr2int32(dbName, &acctId);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
if (acctId != pUser->acctId) {
|
if (acctId != pUser->acctId) {
|
||||||
return TSDB_CODE_MND_INVALID_DB_ACCT;
|
return TSDB_CODE_MND_INVALID_DB_ACCT;
|
||||||
}
|
}
|
||||||
|
@ -1560,8 +1565,8 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
|
|
||||||
static int32_t mndSetDropDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
static int32_t mndSetDropDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
|
@ -1941,9 +1946,9 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64
|
mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64
|
||||||
" numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
" numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d",
|
||||||
pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs,
|
pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs,
|
||||||
pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable);
|
pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDbCacheInfo->cfgVersion < pDb->cfgVersion) {
|
if (pDbCacheInfo->cfgVersion < pDb->cfgVersion) {
|
||||||
|
@ -1955,7 +1960,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
||||||
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp));
|
||||||
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES);
|
||||||
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) {
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
int32_t code = mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
int32_t code = mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
@ -2386,7 +2391,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)strictVstr, false), &lino, _OVER);
|
||||||
|
|
||||||
char durationVstr[128] = {0};
|
char durationVstr[128] = {0};
|
||||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE, pDb->cfg.daysPerFile);
|
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], sizeof(durationVstr) - VARSTR_HEADER_SIZE,
|
||||||
|
pDb->cfg.daysPerFile);
|
||||||
|
|
||||||
varDataSetLen(durationVstr, len);
|
varDataSetLen(durationVstr, len);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
@ -2402,9 +2408,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
||||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pDb->cfg.daysToKeep2);
|
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pDb->cfg.daysToKeep2);
|
||||||
|
|
||||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||||
} else {
|
} else {
|
||||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep0Str, keep1Str, keep2Str);
|
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep0Str, keep1Str, keep2Str);
|
||||||
}
|
}
|
||||||
varDataSetLen(keepVstr, len);
|
varDataSetLen(keepVstr, len);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
@ -462,7 +462,7 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
||||||
dInfo.isMnode = 0;
|
dInfo.isMnode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(taosArrayPush(pDnodeInfo, &dInfo) == NULL){
|
if (taosArrayPush(pDnodeInfo, &dInfo) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
break;
|
break;
|
||||||
|
@ -471,12 +471,12 @@ int32_t mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_MONITOR_PARA(para,err) \
|
#define CHECK_MONITOR_PARA(para, err) \
|
||||||
if (pCfg->monitorParas.para != para) { \
|
if (pCfg->monitorParas.para != para) { \
|
||||||
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
||||||
terrno = err; \
|
terrno = err; \
|
||||||
return err;\
|
return err; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
||||||
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
||||||
|
@ -487,7 +487,8 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
||||||
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
||||||
|
|
||||||
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id, 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;
|
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS;
|
||||||
return DND_REASON_STATUS_MONITOR_NOT_MATCH;
|
return DND_REASON_STATUS_MONITOR_NOT_MATCH;
|
||||||
}
|
}
|
||||||
|
@ -583,8 +584,8 @@ static bool mndUpdateMnodeState(SMnodeObj *pObj, SMnodeLoad *pMload) {
|
||||||
return stateChanged;
|
return stateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char* tsMonFwUri;
|
extern char *tsMonFwUri;
|
||||||
extern char* tsMonSlowLogUri;
|
extern char *tsMonSlowLogUri;
|
||||||
static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SStatisReq statisReq = {0};
|
SStatisReq statisReq = {0};
|
||||||
|
@ -596,9 +597,9 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
||||||
mInfo("process statis req,\n %s", statisReq.pCont);
|
mInfo("process statis req,\n %s", statisReq.pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statisReq.type == MONITOR_TYPE_COUNTER){
|
if (statisReq.type == MONITOR_TYPE_COUNTER) {
|
||||||
monSendContent(statisReq.pCont, tsMonFwUri);
|
monSendContent(statisReq.pCont, tsMonFwUri);
|
||||||
}else if(statisReq.type == MONITOR_TYPE_SLOW_LOG){
|
} else if (statisReq.type == MONITOR_TYPE_SLOW_LOG) {
|
||||||
monSendContent(statisReq.pCont, tsMonSlowLogUri);
|
monSendContent(statisReq.pCont, tsMonSlowLogUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,27 +1059,27 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getSlowLogScopeString(int32_t scope, char* result){
|
static void getSlowLogScopeString(int32_t scope, char *result) {
|
||||||
if(scope == SLOW_LOG_TYPE_NULL) {
|
if (scope == SLOW_LOG_TYPE_NULL) {
|
||||||
(void)strcat(result, "NONE");
|
(void)strcat(result, "NONE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while(scope > 0){
|
while (scope > 0) {
|
||||||
if(scope & SLOW_LOG_TYPE_QUERY) {
|
if (scope & SLOW_LOG_TYPE_QUERY) {
|
||||||
(void)strcat(result, "QUERY");
|
(void)strcat(result, "QUERY");
|
||||||
scope &= ~SLOW_LOG_TYPE_QUERY;
|
scope &= ~SLOW_LOG_TYPE_QUERY;
|
||||||
} else if(scope & SLOW_LOG_TYPE_INSERT) {
|
} else if (scope & SLOW_LOG_TYPE_INSERT) {
|
||||||
(void)strcat(result, "INSERT");
|
(void)strcat(result, "INSERT");
|
||||||
scope &= ~SLOW_LOG_TYPE_INSERT;
|
scope &= ~SLOW_LOG_TYPE_INSERT;
|
||||||
} else if(scope & SLOW_LOG_TYPE_OTHERS) {
|
} else if (scope & SLOW_LOG_TYPE_OTHERS) {
|
||||||
(void)strcat(result, "OTHERS");
|
(void)strcat(result, "OTHERS");
|
||||||
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
scope &= ~SLOW_LOG_TYPE_OTHERS;
|
||||||
} else{
|
} else {
|
||||||
(void)printf("invalid slow log scope:%d", scope);
|
(void)printf("invalid slow log scope:%d", scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scope > 0) {
|
if (scope > 0) {
|
||||||
(void)strcat(result, "|");
|
(void)strcat(result, "|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1441,7 @@ _OVER:
|
||||||
|
|
||||||
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char *p = pMCfgReq->config;
|
char *p = pMCfgReq->config;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (*p == ' ') {
|
if (*p == ' ') {
|
||||||
break;
|
break;
|
||||||
|
@ -1449,7 +1450,7 @@ static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t optLen = p - pMCfgReq->config;
|
size_t optLen = p - pMCfgReq->config;
|
||||||
(void)strncpy(pDCfgReq->config, pMCfgReq->config, optLen);
|
tstrncpy(pDCfgReq->config, pMCfgReq->config, optLen + 1);
|
||||||
pDCfgReq->config[optLen] = 0;
|
pDCfgReq->config[optLen] = 0;
|
||||||
|
|
||||||
if (' ' == pMCfgReq->config[optLen]) {
|
if (' ' == pMCfgReq->config[optLen]) {
|
||||||
|
@ -1538,7 +1539,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
||||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
TAOS_CHECK_GOTO (mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
|
||||||
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
|
||||||
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
|
||||||
code = TSDB_CODE_INVALID_CFG;
|
code = TSDB_CODE_INVALID_CFG;
|
||||||
|
@ -1881,11 +1882,19 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
||||||
if (' ' == pMCfgReq->config[optLen]) {
|
if (' ' == pMCfgReq->config[optLen]) {
|
||||||
// 'key value'
|
// 'key value'
|
||||||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||||
*pOutValue = atoi(pMCfgReq->config + optLen + 1);
|
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 'key' 'value'
|
// 'key' 'value'
|
||||||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||||
*pOutValue = atoi(pMCfgReq->value);
|
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndAcct.h"
|
#include "mndAcct.h"
|
||||||
#include "mndArbGroup.h"
|
|
||||||
#include "mndAnode.h"
|
#include "mndAnode.h"
|
||||||
|
#include "mndArbGroup.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndCompact.h"
|
#include "mndCompact.h"
|
||||||
#include "mndCompactDetail.h"
|
#include "mndCompactDetail.h"
|
||||||
|
@ -254,7 +254,7 @@ static void mndIncreaseUpTime(SMnode *pMnode) {
|
||||||
.pCont = pReq,
|
.pCont = pReq,
|
||||||
.contLen = contLen,
|
.contLen = contLen,
|
||||||
.info.notFreeAhandle = 1,
|
.info.notFreeAhandle = 1,
|
||||||
.info.ahandle = (void *)0x9527};
|
.info.ahandle = 0};
|
||||||
// TODO check return value
|
// TODO check return value
|
||||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||||
|
@ -530,7 +530,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
||||||
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
} else {
|
} else {
|
||||||
(void)strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "mndMnode.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "mndCluster.h"
|
#include "mndCluster.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndMnode.h"
|
|
||||||
#include "mndPrivilege.h"
|
#include "mndPrivilege.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndSync.h"
|
#include "mndSync.h"
|
||||||
|
@ -722,10 +722,13 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
|
||||||
code = mndCreateMnode(pMnode, pReq, pDnode, &createReq);
|
code = mndCreateMnode(pMnode, pReq, pDnode, &createReq);
|
||||||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
char obj[40] = {0};
|
char obj[40] = {0};
|
||||||
sprintf(obj, "%d", createReq.dnodeId);
|
int32_t bytes = snprintf(obj, sizeof(obj), "%d", createReq.dnodeId);
|
||||||
|
if ((uint32_t)bytes < sizeof(obj)) {
|
||||||
auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen);
|
auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen);
|
||||||
|
} else {
|
||||||
|
mError("mnode:%d, failed to audit create req since %s", createReq.dnodeId, tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
|
@ -917,7 +920,9 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
|
||||||
|
sdbCancelFetch(pSdb, pShow->pIter);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +932,9 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, b1, false);
|
code = colDataSetVal(pColInfo, numOfRows, b1, false);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
|
||||||
|
sdbCancelFetch(pSdb, pShow->pIter);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,10 +954,8 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
||||||
if (code != 0) {
|
if (code != 0) goto _err;
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
|
||||||
goto _out;
|
|
||||||
}
|
|
||||||
const char *status = "ready";
|
const char *status = "ready";
|
||||||
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||||
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||||
|
@ -959,25 +964,16 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
|
||||||
if (code != 0) {
|
if (code != 0) goto _err;
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
|
||||||
goto _out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
|
||||||
if (code != 0) {
|
if (code != 0) goto _err;
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
|
||||||
goto _out;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t roleTimeMs = (isDnodeOnline) ? pObj->roleTimeMs : 0;
|
int64_t roleTimeMs = (isDnodeOnline) ? pObj->roleTimeMs : 0;
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false);
|
||||||
if (code != 0) {
|
if (code != 0) goto _err;
|
||||||
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
|
|
||||||
goto _out;
|
|
||||||
}
|
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pObj);
|
sdbRelease(pSdb, pObj);
|
||||||
|
@ -988,6 +984,13 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
_out:
|
_out:
|
||||||
sdbRelease(pSdb, pSelfObj);
|
sdbRelease(pSdb, pSelfObj);
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
|
||||||
|
sdbCancelFetch(pSdb, pShow->pIter);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
sdbRelease(pSdb, pSelfObj);
|
||||||
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {
|
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "mndProfile.h"
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
#include "mndPrivilege.h"
|
#include "mndPrivilege.h"
|
||||||
#include "mndProfile.h"
|
|
||||||
#include "mndQnode.h"
|
#include "mndQnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndSma.h"
|
#include "mndSma.h"
|
||||||
|
@ -336,10 +336,13 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
char detail[1000] = {0};
|
char detail[1000] = {0};
|
||||||
(void)sprintf(detail, "app:%s", connReq.app);
|
int32_t nBytes = snprintf(detail, sizeof(detail), "app:%s", connReq.app);
|
||||||
|
if ((uint32_t)nBytes < sizeof(detail)) {
|
||||||
auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail));
|
auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail));
|
||||||
|
} else {
|
||||||
|
mError("failed to audit logic since %s", tstrerror(TSDB_CODE_OUT_OF_RANGE));
|
||||||
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndSma.h"
|
#include "mndSma.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
#include "mndDb.h"
|
#include "mndDb.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndIndex.h"
|
#include "mndIndex.h"
|
||||||
|
@ -31,7 +32,6 @@
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "functionMgt.h"
|
|
||||||
|
|
||||||
#define TSDB_SMA_VER_NUMBER 1
|
#define TSDB_SMA_VER_NUMBER 1
|
||||||
#define TSDB_SMA_RESERVE_SIZE 64
|
#define TSDB_SMA_RESERVE_SIZE 64
|
||||||
|
@ -48,8 +48,8 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndDestroySmaObj(SSmaObj *pSmaObj);
|
static void mndDestroySmaObj(SSmaObj *pSmaObj);
|
||||||
|
|
||||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq);
|
static int32_t mndProcessCreateTSMAReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq);
|
static int32_t mndProcessDropTSMAReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
// sma and tag index comm func
|
// sma and tag index comm func
|
||||||
static int32_t mndProcessDropIdxReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropIdxReq(SRpcMsg *pReq);
|
||||||
|
@ -61,11 +61,11 @@ static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq);
|
static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
typedef struct SCreateTSMACxt {
|
typedef struct SCreateTSMACxt {
|
||||||
SMnode * pMnode;
|
SMnode *pMnode;
|
||||||
const SRpcMsg *pRpcReq;
|
const SRpcMsg *pRpcReq;
|
||||||
union {
|
union {
|
||||||
const SMCreateSmaReq *pCreateSmaReq;
|
const SMCreateSmaReq *pCreateSmaReq;
|
||||||
const SMDropSmaReq * pDropSmaReq;
|
const SMDropSmaReq *pDropSmaReq;
|
||||||
};
|
};
|
||||||
SDbObj *pDb;
|
SDbObj *pDb;
|
||||||
SStbObj *pSrcStb;
|
SStbObj *pSrcStb;
|
||||||
|
@ -298,16 +298,13 @@ void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma) {
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *db) {
|
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *db) { return mndAcquireDb(pMnode, db); }
|
||||||
|
|
||||||
return mndAcquireDb(pMnode, db);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma, int32_t *pContLen) {
|
static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma, int32_t *pContLen) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +365,7 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma,
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -424,9 +421,9 @@ static int32_t mndSetCreateSmaRedoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetCreateSmaUndoLogs(SMnode* pMnode, STrans* pTrans, SSmaObj* pSma) {
|
static int32_t mndSetCreateSmaUndoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *pSma) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSdbRaw * pUndoRaw = mndSmaActionEncode(pSma);
|
SSdbRaw *pUndoRaw = mndSmaActionEncode(pSma);
|
||||||
if (!pUndoRaw) {
|
if (!pUndoRaw) {
|
||||||
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
code = TSDB_CODE_MND_RETURN_VALUE_NULL;
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
|
@ -670,7 +667,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
// check the maxDelay
|
// check the maxDelay
|
||||||
if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {
|
||||||
int64_t msInterval = -1;
|
int64_t msInterval = -1;
|
||||||
int32_t code = convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND, &msInterval);
|
int32_t code =
|
||||||
|
convertTimeFromPrecisionToUnit(pCreate->interval, pDb->cfg.precision, TIME_UNIT_MILLISECOND, &msInterval);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
mError("sma:%s, failed to create since convert time failed: %s", smaObj.name, tstrerror(code));
|
mError("sma:%s, failed to create since convert time failed: %s", smaObj.name, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -792,7 +790,7 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndGetStreamNameFromSmaName(char *streamName, char *smaName) {
|
static int32_t mndGetStreamNameFromSmaName(char *streamName, char *smaName) {
|
||||||
SName n;
|
SName n;
|
||||||
int32_t code = tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
int32_t code = tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -984,10 +982,10 @@ static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SD
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) {
|
static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
SStreamObj *pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||||
|
@ -1023,7 +1021,6 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||||
if (pStream == NULL || pStream->smaId != pSma->uid || code != 0) {
|
if (pStream == NULL || pStream->smaId != pSma->uid || code != 0) {
|
||||||
sdbRelease(pMnode->pSdb, pStream);
|
sdbRelease(pMnode->pSdb, pStream);
|
||||||
|
@ -1124,8 +1121,8 @@ _OVER:
|
||||||
|
|
||||||
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
|
@ -1232,7 +1229,7 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
||||||
FOREACH(node, pList) {
|
FOREACH(node, pList) {
|
||||||
SFunctionNode *pFunc = (SFunctionNode *)node;
|
SFunctionNode *pFunc = (SFunctionNode *)node;
|
||||||
extOffset += tsnprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
extOffset += tsnprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
||||||
(extOffset ? "," : ""), pFunc->functionName);
|
(extOffset ? "," : ""), pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
*exist = true;
|
*exist = true;
|
||||||
|
@ -1439,8 +1436,8 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
|
|
||||||
SName smaName = {0};
|
SName smaName = {0};
|
||||||
SName stbName = {0};
|
SName stbName = {0};
|
||||||
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -1448,7 +1445,7 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
|
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
|
||||||
code = tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
code = tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
}
|
}
|
||||||
SColumnInfoData* pColInfo = NULL;
|
SColumnInfoData *pColInfo = NULL;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName));
|
STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName));
|
||||||
|
|
||||||
|
@ -1540,7 +1537,7 @@ static void mndCancelRetrieveIdx(SMnode *pMnode, void *pIter) {
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initSMAObj(SCreateTSMACxt* pCxt) {
|
static void initSMAObj(SCreateTSMACxt *pCxt) {
|
||||||
memcpy(pCxt->pSma->name, pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
memcpy(pCxt->pSma->name, pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
||||||
memcpy(pCxt->pSma->stb, pCxt->pCreateSmaReq->stb, TSDB_TABLE_FNAME_LEN);
|
memcpy(pCxt->pSma->stb, pCxt->pCreateSmaReq->stb, TSDB_TABLE_FNAME_LEN);
|
||||||
memcpy(pCxt->pSma->db, pCxt->pDb->name, TSDB_DB_FNAME_LEN);
|
memcpy(pCxt->pSma->db, pCxt->pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
@ -1549,7 +1546,7 @@ static void initSMAObj(SCreateTSMACxt* pCxt) {
|
||||||
pCxt->pSma->uid = mndGenerateUid(pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
pCxt->pSma->uid = mndGenerateUid(pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
memcpy(pCxt->pSma->dstTbName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
memcpy(pCxt->pSma->dstTbName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||||
pCxt->pSma->dstTbUid = 0; // not used
|
pCxt->pSma->dstTbUid = 0; // not used
|
||||||
pCxt->pSma->stbUid = pCxt->pSrcStb ? pCxt->pSrcStb->uid : pCxt->pCreateSmaReq->normSourceTbUid;
|
pCxt->pSma->stbUid = pCxt->pSrcStb ? pCxt->pSrcStb->uid : pCxt->pCreateSmaReq->normSourceTbUid;
|
||||||
pCxt->pSma->dbUid = pCxt->pDb->uid;
|
pCxt->pSma->dbUid = pCxt->pDb->uid;
|
||||||
pCxt->pSma->interval = pCxt->pCreateSmaReq->interval;
|
pCxt->pSma->interval = pCxt->pCreateSmaReq->interval;
|
||||||
|
@ -1598,7 +1595,7 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
||||||
if (!pCxt->pCreateStreamReq->pTags) {
|
if (!pCxt->pCreateStreamReq->pTags) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
SField f = {0};
|
SField f = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
if (pCxt->pSrcStb) {
|
if (pCxt->pSrcStb) {
|
||||||
for (int32_t idx = 0; idx < pCxt->pCreateStreamReq->numOfTags - 1; ++idx) {
|
for (int32_t idx = 0; idx < pCxt->pCreateStreamReq->numOfTags - 1; ++idx) {
|
||||||
|
@ -1626,9 +1623,9 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// construct output cols
|
// construct output cols
|
||||||
SNode* pNode;
|
SNode *pNode;
|
||||||
FOREACH(pNode, pCxt->pProjects) {
|
FOREACH(pNode, pCxt->pProjects) {
|
||||||
SExprNode* pExprNode = (SExprNode*)pNode;
|
SExprNode *pExprNode = (SExprNode *)pNode;
|
||||||
f.bytes = pExprNode->resType.bytes;
|
f.bytes = pExprNode->resType.bytes;
|
||||||
f.type = pExprNode->resType.type;
|
f.type = pExprNode->resType.type;
|
||||||
f.flags = COL_SMA_ON;
|
f.flags = COL_SMA_ON;
|
||||||
|
@ -1642,7 +1639,7 @@ static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCreateTSMABuildDropStreamReq(SCreateTSMACxt* pCxt) {
|
static int32_t mndCreateTSMABuildDropStreamReq(SCreateTSMACxt *pCxt) {
|
||||||
tstrncpy(pCxt->pDropStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN);
|
tstrncpy(pCxt->pDropStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN);
|
||||||
pCxt->pDropStreamReq->igNotExists = false;
|
pCxt->pDropStreamReq->igNotExists = false;
|
||||||
pCxt->pDropStreamReq->sql = taosStrdup(pCxt->pDropSmaReq->name);
|
pCxt->pDropStreamReq->sql = taosStrdup(pCxt->pDropSmaReq->name);
|
||||||
|
@ -1685,14 +1682,13 @@ static int32_t mndSetUpdateDbTsmaVersionCommitLogs(SMnode *pMnode, STrans *pTran
|
||||||
TAOS_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
TAOS_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt *pCxt) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STransAction createStreamRedoAction = {0};
|
STransAction createStreamRedoAction = {0};
|
||||||
STransAction createStreamUndoAction = {0};
|
STransAction createStreamUndoAction = {0};
|
||||||
STransAction dropStbUndoAction = {0};
|
STransAction dropStbUndoAction = {0};
|
||||||
SMDropStbReq dropStbReq = {0};
|
SMDropStbReq dropStbReq = {0};
|
||||||
STrans *pTrans =
|
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "create-tsma");
|
||||||
mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "create-tsma");
|
|
||||||
if (!pTrans) {
|
if (!pTrans) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1713,7 +1709,9 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (createStreamRedoAction.contLen != tSerializeSCMCreateStreamReq(createStreamRedoAction.pCont, createStreamRedoAction.contLen, pCxt->pCreateStreamReq)) {
|
if (createStreamRedoAction.contLen != tSerializeSCMCreateStreamReq(createStreamRedoAction.pCont,
|
||||||
|
createStreamRedoAction.contLen,
|
||||||
|
pCxt->pCreateStreamReq)) {
|
||||||
mError("sma: %s, failed to create due to create stream req encode failure", pCxt->pCreateSmaReq->name);
|
mError("sma: %s, failed to create due to create stream req encode failure", pCxt->pCreateSmaReq->name);
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1728,7 +1726,8 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (createStreamUndoAction.contLen != tSerializeSMDropStreamReq(createStreamUndoAction.pCont, createStreamUndoAction.contLen, pCxt->pDropStreamReq)) {
|
if (createStreamUndoAction.contLen !=
|
||||||
|
tSerializeSMDropStreamReq(createStreamUndoAction.pCont, createStreamUndoAction.contLen, pCxt->pDropStreamReq)) {
|
||||||
mError("sma: %s, failed to create due to drop stream req encode failure", pCxt->pCreateSmaReq->name);
|
mError("sma: %s, failed to create due to drop stream req encode failure", pCxt->pCreateSmaReq->name);
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1746,7 +1745,8 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (dropStbUndoAction.contLen != tSerializeSMDropStbReq(dropStbUndoAction.pCont, dropStbUndoAction.contLen, &dropStbReq)) {
|
if (dropStbUndoAction.contLen !=
|
||||||
|
tSerializeSMDropStbReq(dropStbUndoAction.pCont, dropStbUndoAction.contLen, &dropStbReq)) {
|
||||||
mError("sma: %s, failed to create due to drop stb req encode failure", pCxt->pCreateSmaReq->name);
|
mError("sma: %s, failed to create due to drop stb req encode failure", pCxt->pCreateSmaReq->name);
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1781,7 +1781,7 @@ static int32_t mndCreateTSMA(SCreateTSMACxt *pCxt) {
|
||||||
pCxt->pSma = &sma;
|
pCxt->pSma = &sma;
|
||||||
initSMAObj(pCxt);
|
initSMAObj(pCxt);
|
||||||
|
|
||||||
SNodeList* pProjects = NULL;
|
SNodeList *pProjects = NULL;
|
||||||
code = nodesStringToList(pCxt->pCreateSmaReq->expr, &pProjects);
|
code = nodesStringToList(pCxt->pCreateSmaReq->expr, &pProjects);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -1830,8 +1830,8 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTSMAGenerateOutputName(const char* tsmaName, char* streamName, char* targetStbName) {
|
static int32_t mndTSMAGenerateOutputName(const char *tsmaName, char *streamName, char *targetStbName) {
|
||||||
SName smaName;
|
SName smaName;
|
||||||
int32_t code = tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
int32_t code = tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -1841,17 +1841,17 @@ static int32_t mndTSMAGenerateOutputName(const char* tsmaName, char* streamName,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
static int32_t mndProcessCreateTSMAReq(SRpcMsg *pReq) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
TAOS_RETURN(TSDB_CODE_MND_INVALID_PLATFORM);
|
TAOS_RETURN(TSDB_CODE_MND_INVALID_PLATFORM);
|
||||||
#endif
|
#endif
|
||||||
SMnode * pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj * pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SStbObj * pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SSmaObj * pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SSmaObj * pBaseTsma = NULL;
|
SSmaObj *pBaseTsma = NULL;
|
||||||
SStreamObj * pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
int64_t mTraceId = TRACE_GET_ROOTID(&pReq->info.traceId);
|
int64_t mTraceId = TRACE_GET_ROOTID(&pReq->info.traceId);
|
||||||
SMCreateSmaReq createReq = {0};
|
SMCreateSmaReq createReq = {0};
|
||||||
|
|
||||||
|
@ -1941,16 +1941,16 @@ static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateTSMACxt cxt = {
|
SCreateTSMACxt cxt = {
|
||||||
.pMnode = pMnode,
|
.pMnode = pMnode,
|
||||||
.pCreateSmaReq = &createReq,
|
.pCreateSmaReq = &createReq,
|
||||||
.pCreateStreamReq = NULL,
|
.pCreateStreamReq = NULL,
|
||||||
.streamName = streamName,
|
.streamName = streamName,
|
||||||
.targetStbFullName = streamTargetStbFullName,
|
.targetStbFullName = streamTargetStbFullName,
|
||||||
.pDb = pDb,
|
.pDb = pDb,
|
||||||
.pRpcReq = pReq,
|
.pRpcReq = pReq,
|
||||||
.pSma = NULL,
|
.pSma = NULL,
|
||||||
.pBaseSma = pBaseTsma,
|
.pBaseSma = pBaseTsma,
|
||||||
.pSrcStb = pStb,
|
.pSrcStb = pStb,
|
||||||
};
|
};
|
||||||
|
|
||||||
code = mndCreateTSMA(&cxt);
|
code = mndCreateTSMA(&cxt);
|
||||||
|
@ -1971,10 +1971,10 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) {
|
static int32_t mndDropTSMA(SCreateTSMACxt *pCxt) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STransAction dropStreamRedoAction = {0};
|
STransAction dropStreamRedoAction = {0};
|
||||||
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "drop-tsma");
|
STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TSMA, pCxt->pRpcReq, "drop-tsma");
|
||||||
if (!pTrans) {
|
if (!pTrans) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -2021,7 +2021,8 @@ static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (dropStbRedoAction.contLen != tSerializeSMDropStbReq(dropStbRedoAction.pCont, dropStbRedoAction.contLen, &dropStbReq)) {
|
if (dropStbRedoAction.contLen !=
|
||||||
|
tSerializeSMDropStbReq(dropStbRedoAction.pCont, dropStbRedoAction.contLen, &dropStbReq)) {
|
||||||
mError("tsma: %s, failedto drop due to drop stb req encode failure", pCxt->pDropSmaReq->name);
|
mError("tsma: %s, failedto drop due to drop stb req encode failure", pCxt->pDropSmaReq->name);
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
|
@ -2044,9 +2045,9 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasRecursiveTsmasBasedOnMe(SMnode* pMnode, const SSmaObj* pSma) {
|
static bool hasRecursiveTsmasBasedOnMe(SMnode *pMnode, const SSmaObj *pSma) {
|
||||||
SSmaObj *pSmaObj = NULL;
|
SSmaObj *pSmaObj = NULL;
|
||||||
void * pIter = NULL;
|
void *pIter = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSmaObj);
|
pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSmaObj);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
@ -2060,25 +2061,25 @@ static bool hasRecursiveTsmasBasedOnMe(SMnode* pMnode, const SSmaObj* pSma) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
static int32_t mndProcessDropTSMAReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SMDropSmaReq dropReq = {0};
|
SMDropSmaReq dropReq = {0};
|
||||||
SSmaObj * pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SDbObj * pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SMnode * pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
if (tDeserializeSMDropSmaReq(pReq->pCont, pReq->contLen, &dropReq) != TSDB_CODE_SUCCESS) {
|
if (tDeserializeSMDropSmaReq(pReq->pCont, pReq->contLen, &dropReq) != TSDB_CODE_SUCCESS) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
code = mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName);
|
code = mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStbObj* pStb = mndAcquireStb(pMnode, streamTargetStbFullName);
|
SStbObj *pStb = mndAcquireStb(pMnode, streamTargetStbFullName);
|
||||||
|
|
||||||
pSma = mndAcquireSma(pMnode, dropReq.name);
|
pSma = mndAcquireSma(pMnode, dropReq.name);
|
||||||
if (!pSma && dropReq.igNotExists) {
|
if (!pSma && dropReq.igNotExists) {
|
||||||
|
@ -2113,13 +2114,13 @@ static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateTSMACxt cxt = {
|
SCreateTSMACxt cxt = {
|
||||||
.pDb = pDb,
|
.pDb = pDb,
|
||||||
.pMnode = pMnode,
|
.pMnode = pMnode,
|
||||||
.pRpcReq = pReq,
|
.pRpcReq = pReq,
|
||||||
.pSma = pSma,
|
.pSma = pSma,
|
||||||
.streamName = streamName,
|
.streamName = streamName,
|
||||||
.targetStbFullName = streamTargetStbFullName,
|
.targetStbFullName = streamTargetStbFullName,
|
||||||
.pDropSmaReq = &dropReq,
|
.pDropSmaReq = &dropReq,
|
||||||
};
|
};
|
||||||
|
|
||||||
code = mndDropTSMA(&cxt);
|
code = mndDropTSMA(&cxt);
|
||||||
|
@ -2134,10 +2135,10 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SDbObj * pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SSmaObj * pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SMnode * pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SColumnInfoData *pColInfo;
|
SColumnInfoData *pColInfo;
|
||||||
if (pShow->pIter == NULL) {
|
if (pShow->pIter == NULL) {
|
||||||
|
@ -2153,7 +2154,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pIter->pSmaIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter->pSmaIter, (void **)&pSma);
|
pIter->pSmaIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter->pSmaIter, (void **)&pSma);
|
||||||
if (pIter->pSmaIter == NULL) break;
|
if (pIter->pSmaIter == NULL) break;
|
||||||
SDbObj* pSrcDb = mndAcquireDb(pMnode, pSma->db);
|
SDbObj *pSrcDb = mndAcquireDb(pMnode, pSma->db);
|
||||||
|
|
||||||
if ((pDb && pSma->dbUid != pDb->uid) || !pSrcDb) {
|
if ((pDb && pSma->dbUid != pDb->uid) || !pSrcDb) {
|
||||||
sdbRelease(pMnode->pSdb, pSma);
|
sdbRelease(pMnode->pSdb, pSma);
|
||||||
|
@ -2176,7 +2177,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db));
|
STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -2186,12 +2187,12 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n));
|
STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)srcTb, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)srcTb, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -2200,29 +2201,29 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_TO_VARSTR(targetTb, (char*)tNameGetTableName(&n));
|
STR_TO_VARSTR(targetTb, (char *)tNameGetTableName(&n));
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)targetTb, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)targetTb, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// stream name
|
// stream name
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)smaName, false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)smaName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)(&pSma->createdTime), false);
|
code = colDataSetVal(pColInfo, numOfRows, (const char *)(&pSma->createdTime), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// interval
|
// interval
|
||||||
char interval[64 + VARSTR_HEADER_SIZE] = {0};
|
char interval[64 + VARSTR_HEADER_SIZE] = {0};
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||||
} else {
|
} else {
|
||||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||||
}
|
}
|
||||||
|
@ -2243,17 +2244,17 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
||||||
// func list
|
// func list
|
||||||
len = 0;
|
len = 0;
|
||||||
SNode *pNode = NULL, *pFunc = NULL;
|
SNode *pNode = NULL, *pFunc = NULL;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesStringToNode(pSma->ast, &pNode);
|
code = nodesStringToNode(pSma->ast, &pNode);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
char * start = buf + VARSTR_HEADER_SIZE;
|
char *start = buf + VARSTR_HEADER_SIZE;
|
||||||
FOREACH(pFunc, ((SSelectStmt *)pNode)->pProjectionList) {
|
FOREACH(pFunc, ((SSelectStmt *)pNode)->pProjectionList) {
|
||||||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||||
len += tsnprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
len += tsnprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||||
((SExprNode *)pFunc)->userAlias);
|
((SExprNode *)pFunc)->userAlias);
|
||||||
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
||||||
len = TSDB_MAX_SAVED_SQL_LEN;
|
len = TSDB_MAX_SAVED_SQL_LEN;
|
||||||
break;
|
break;
|
||||||
|
@ -2297,7 +2298,8 @@ static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter) {
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STableTSMAInfo* pInfo, const SSmaObj* pBaseTsma) {
|
int32_t dumpTSMAInfoFromSmaObj(const SSmaObj *pSma, const SStbObj *pDestStb, STableTSMAInfo *pInfo,
|
||||||
|
const SSmaObj *pBaseTsma) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
pInfo->interval = pSma->interval;
|
pInfo->interval = pSma->interval;
|
||||||
pInfo->unit = pSma->intervalUnit;
|
pInfo->unit = pSma->intervalUnit;
|
||||||
|
@ -2336,7 +2338,7 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
||||||
SSelectStmt *pSelect = (SSelectStmt *)pNode;
|
SSelectStmt *pSelect = (SSelectStmt *)pNode;
|
||||||
FOREACH(pFunc, pSelect->pProjectionList) {
|
FOREACH(pFunc, pSelect->pProjectionList) {
|
||||||
STableTSMAFuncInfo funcInfo = {0};
|
STableTSMAFuncInfo funcInfo = {0};
|
||||||
SFunctionNode * pFuncNode = (SFunctionNode *)pFunc;
|
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||||
funcInfo.funcId = pFuncNode->funcId;
|
funcInfo.funcId = pFuncNode->funcId;
|
||||||
funcInfo.colId = ((SColumnNode *)pFuncNode->pParameterList->pHead->pNode)->colId;
|
funcInfo.colId = ((SColumnNode *)pFuncNode->pParameterList->pHead->pNode)->colId;
|
||||||
|
@ -2383,9 +2385,9 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
||||||
}
|
}
|
||||||
|
|
||||||
// @note remember to mndReleaseSma(*ppOut)
|
// @note remember to mndReleaseSma(*ppOut)
|
||||||
static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj** ppOut) {
|
static int32_t mndGetDeepestBaseForTsma(SMnode *pMnode, SSmaObj *pSma, SSmaObj **ppOut) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSmaObj* pRecursiveTsma = NULL;
|
SSmaObj *pRecursiveTsma = NULL;
|
||||||
if (pSma->baseSmaName[0]) {
|
if (pSma->baseSmaName[0]) {
|
||||||
pRecursiveTsma = mndAcquireSma(pMnode, pSma->baseSmaName);
|
pRecursiveTsma = mndAcquireSma(pMnode, pSma->baseSmaName);
|
||||||
if (!pRecursiveTsma) {
|
if (!pRecursiveTsma) {
|
||||||
|
@ -2393,7 +2395,7 @@ static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj**
|
||||||
return TSDB_CODE_MND_SMA_NOT_EXIST;
|
return TSDB_CODE_MND_SMA_NOT_EXIST;
|
||||||
}
|
}
|
||||||
while (pRecursiveTsma->baseSmaName[0]) {
|
while (pRecursiveTsma->baseSmaName[0]) {
|
||||||
SSmaObj* pTmpSma = pRecursiveTsma;
|
SSmaObj *pTmpSma = pRecursiveTsma;
|
||||||
pRecursiveTsma = mndAcquireSma(pMnode, pTmpSma->baseSmaName);
|
pRecursiveTsma = mndAcquireSma(pMnode, pTmpSma->baseSmaName);
|
||||||
if (!pRecursiveTsma) {
|
if (!pRecursiveTsma) {
|
||||||
mError("base tsma: %s for tsma: %s not found", pTmpSma->baseSmaName, pTmpSma->name);
|
mError("base tsma: %s for tsma: %s not found", pTmpSma->baseSmaName, pTmpSma->name);
|
||||||
|
@ -2407,7 +2409,6 @@ static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj**
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rsp, bool *exist) {
|
static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rsp, bool *exist) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
|
@ -2450,17 +2451,17 @@ static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rs
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param);
|
typedef bool (*tsmaFilter)(const SSmaObj *pSma, void *param);
|
||||||
|
|
||||||
static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) {
|
static int32_t mndGetSomeTsmas(SMnode *pMnode, STableTSMAInfoRsp *pRsp, tsmaFilter filtered, void *param, bool *exist) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSmaObj * pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SSmaObj * pBaseTsma = NULL;
|
SSmaObj *pBaseTsma = NULL;
|
||||||
SSdb * pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void * pIter = NULL;
|
void *pIter = NULL;
|
||||||
SStreamObj * pStream = NULL;
|
SStreamObj *pStream = NULL;
|
||||||
SStbObj * pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
bool shouldRetry = false;
|
bool shouldRetry = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||||
|
@ -2479,7 +2480,7 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
||||||
}
|
}
|
||||||
|
|
||||||
SName smaName;
|
SName smaName;
|
||||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
|
@ -2541,8 +2542,8 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tsmaTbFilter(const SSmaObj* pSma, void* param) {
|
static bool tsmaTbFilter(const SSmaObj *pSma, void *param) {
|
||||||
const char* tbFName = param;
|
const char *tbFName = param;
|
||||||
return pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName) != 0;
|
return pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2550,7 +2551,7 @@ static int32_t mndGetTableTSMA(SMnode *pMnode, char *tbFName, STableTSMAInfoRsp
|
||||||
return mndGetSomeTsmas(pMnode, pRsp, tsmaTbFilter, tbFName, exist);
|
return mndGetSomeTsmas(pMnode, pRsp, tsmaTbFilter, tbFName, exist);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tsmaDbFilter(const SSmaObj* pSma, void* param) {
|
static bool tsmaDbFilter(const SSmaObj *pSma, void *param) {
|
||||||
uint64_t *dbUid = param;
|
uint64_t *dbUid = param;
|
||||||
return pSma->dbUid != *dbUid;
|
return pSma->dbUid != *dbUid;
|
||||||
}
|
}
|
||||||
|
@ -2564,7 +2565,7 @@ static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STableTSMAInfoReq tsmaReq = {0};
|
STableTSMAInfoReq tsmaReq = {0};
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
SMnode * pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tDeserializeTableTSMAInfoReq(pReq->pCont, pReq->contLen, &tsmaReq), NULL, _OVER);
|
TAOS_CHECK_GOTO(tDeserializeTableTSMAInfoReq(pReq->pCont, pReq->contLen, &tsmaReq), NULL, _OVER);
|
||||||
|
|
||||||
|
@ -2635,12 +2636,12 @@ static int32_t mkNonExistTSMAInfo(const STSMAVersion *pTsmaVer, STableTSMAInfo *
|
||||||
|
|
||||||
int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp,
|
int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp,
|
||||||
int32_t *pRspLen) {
|
int32_t *pRspLen) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STSMAHbRsp hbRsp = {0};
|
STSMAHbRsp hbRsp = {0};
|
||||||
int32_t rspLen = 0;
|
int32_t rspLen = 0;
|
||||||
void * pRsp = NULL;
|
void *pRsp = NULL;
|
||||||
char tsmaFName[TSDB_TABLE_FNAME_LEN] = {0};
|
char tsmaFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
STableTSMAInfo * pTsmaInfo = NULL;
|
STableTSMAInfo *pTsmaInfo = NULL;
|
||||||
|
|
||||||
hbRsp.pTsmas = taosArrayInit(numOfTsmas, POINTER_BYTES);
|
hbRsp.pTsmas = taosArrayInit(numOfTsmas, POINTER_BYTES);
|
||||||
if (!hbRsp.pTsmas) {
|
if (!hbRsp.pTsmas) {
|
||||||
|
@ -2649,13 +2650,13 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTsmas; ++i) {
|
for (int32_t i = 0; i < numOfTsmas; ++i) {
|
||||||
STSMAVersion* pTsmaVer = &pTsmaVersions[i];
|
STSMAVersion *pTsmaVer = &pTsmaVersions[i];
|
||||||
pTsmaVer->dbId = be64toh(pTsmaVer->dbId);
|
pTsmaVer->dbId = be64toh(pTsmaVer->dbId);
|
||||||
pTsmaVer->tsmaId = be64toh(pTsmaVer->tsmaId);
|
pTsmaVer->tsmaId = be64toh(pTsmaVer->tsmaId);
|
||||||
pTsmaVer->version = ntohl(pTsmaVer->version);
|
pTsmaVer->version = ntohl(pTsmaVer->version);
|
||||||
|
|
||||||
snprintf(tsmaFName, sizeof(tsmaFName), "%s.%s", pTsmaVer->dbFName, pTsmaVer->name);
|
snprintf(tsmaFName, sizeof(tsmaFName), "%s.%s", pTsmaVer->dbFName, pTsmaVer->name);
|
||||||
SSmaObj* pSma = mndAcquireSma(pMnode, tsmaFName);
|
SSmaObj *pSma = mndAcquireSma(pMnode, tsmaFName);
|
||||||
if (!pSma) {
|
if (!pSma) {
|
||||||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||||
if (code) goto _OVER;
|
if (code) goto _OVER;
|
||||||
|
@ -2683,7 +2684,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStbObj* pDestStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
SStbObj *pDestStb = mndAcquireStb(pMnode, pSma->dstTbName);
|
||||||
if (!pDestStb) {
|
if (!pDestStb) {
|
||||||
mInfo("tsma: %s.%" PRIx64 " dest stb: %s not found, maybe dropped", tsmaFName, pTsmaVer->tsmaId, pSma->dstTbName);
|
mInfo("tsma: %s.%" PRIx64 " dest stb: %s not found, maybe dropped", tsmaFName, pTsmaVer->tsmaId, pSma->dstTbName);
|
||||||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||||
|
@ -2698,7 +2699,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump smaObj into rsp
|
// dump smaObj into rsp
|
||||||
STableTSMAInfo * pInfo = NULL;
|
STableTSMAInfo *pInfo = NULL;
|
||||||
pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo));
|
pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo));
|
||||||
if (!pInfo) {
|
if (!pInfo) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -2707,7 +2708,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmaObj* pBaseSma = NULL;
|
SSmaObj *pBaseSma = NULL;
|
||||||
code = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseSma);
|
code = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseSma);
|
||||||
if (code == 0) code = dumpTSMAInfoFromSmaObj(pSma, pDestStb, pInfo, pBaseSma);
|
if (code == 0) code = dumpTSMAInfoFromSmaObj(pSma, pDestStb, pInfo, pBaseSma);
|
||||||
|
|
||||||
|
|
|
@ -1931,11 +1931,6 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
return terrno = code;
|
return terrno = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndStreamRegisterTrans(pTrans, MND_STREAM_TASK_UPDATE_NAME, pStream->uid);
|
|
||||||
if (code) {
|
|
||||||
mError("failed to register trans, transId:%d, and continue", pTrans->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeAllNodes) {
|
if (!includeAllNodes) {
|
||||||
|
@ -1951,6 +1946,12 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
||||||
mDebug("stream:0x%" PRIx64 " %s involved node changed, create update trans, transId:%d", pStream->uid,
|
mDebug("stream:0x%" PRIx64 " %s involved node changed, create update trans, transId:%d", pStream->uid,
|
||||||
pStream->name, pTrans->id);
|
pStream->name, pTrans->id);
|
||||||
|
|
||||||
|
// NOTE: for each stream, we register one trans entry for task update
|
||||||
|
code = mndStreamRegisterTrans(pTrans, MND_STREAM_TASK_UPDATE_NAME, pStream->uid);
|
||||||
|
if (code) {
|
||||||
|
mError("failed to register trans, transId:%d, and continue", pTrans->id);
|
||||||
|
}
|
||||||
|
|
||||||
code = mndStreamSetUpdateEpsetAction(pMnode, pStream, pChangeInfo, pTrans);
|
code = mndStreamSetUpdateEpsetAction(pMnode, pStream, pChangeInfo, pTrans);
|
||||||
|
|
||||||
// todo: not continue, drop all and retry again
|
// todo: not continue, drop all and retry again
|
||||||
|
|
|
@ -35,7 +35,11 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
||||||
size_t keyLen = 0;
|
size_t keyLen = 0;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SArray *pList = taosArrayInit(4, sizeof(SKeyInfo));
|
SArray *pList = taosArrayInit(4, sizeof(SKeyInfo));
|
||||||
int32_t num = 0;
|
int32_t numOfChkpt = 0;
|
||||||
|
|
||||||
|
if (pNumOfActiveChkpt != NULL) {
|
||||||
|
*pNumOfActiveChkpt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -50,15 +54,15 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
||||||
void *pKey = taosHashGetKey(pEntry, &keyLen);
|
void *pKey = taosHashGetKey(pEntry, &keyLen);
|
||||||
// key is the name of src/dst db name
|
// key is the name of src/dst db name
|
||||||
SKeyInfo info = {.pKey = pKey, .keyLen = keyLen};
|
SKeyInfo info = {.pKey = pKey, .keyLen = keyLen};
|
||||||
mDebug("transId:%d %s startTs:%" PRId64 " cleared since finished", pEntry->transId, pEntry->name,
|
mDebug("transId:%d stream:0x%" PRIx64 " %s startTs:%" PRId64 " cleared since finished", pEntry->transId,
|
||||||
pEntry->startTime);
|
pEntry->streamId, pEntry->name, pEntry->startTime);
|
||||||
void* p = taosArrayPush(pList, &info);
|
void* p = taosArrayPush(pList, &info);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(pEntry->name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
if (strcmp(pEntry->name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
||||||
num++;
|
numOfChkpt++;
|
||||||
}
|
}
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
}
|
}
|
||||||
|
@ -78,48 +82,34 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("clear %d finished stream-trans, remained:%d, active checkpoint trans:%d", size,
|
mDebug("clear %d finished stream-trans, active trans:%d, active checkpoint trans:%d", size,
|
||||||
taosHashGetSize(execInfo.transMgmt.pDBTrans), num);
|
taosHashGetSize(execInfo.transMgmt.pDBTrans), numOfChkpt);
|
||||||
|
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
|
|
||||||
if (pNumOfActiveChkpt != NULL) {
|
if (pNumOfActiveChkpt != NULL) {
|
||||||
*pNumOfActiveChkpt = num;
|
*pNumOfActiveChkpt = numOfChkpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * Transactions of different streams are not related. Here only check the conflict of transaction for a given stream.
|
static int32_t doStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName) {
|
||||||
// For a given stream:
|
|
||||||
// 1. checkpoint trans is conflict with any other trans except for the drop and reset trans.
|
|
||||||
// 2. create/drop/reset/update trans are conflict with any other trans.
|
|
||||||
int32_t mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock) {
|
|
||||||
if (lock) {
|
|
||||||
streamMutexLock(&execInfo.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t num = taosHashGetSize(execInfo.transMgmt.pDBTrans);
|
int32_t num = taosHashGetSize(execInfo.transMgmt.pDBTrans);
|
||||||
if (num <= 0) {
|
if (num <= 0) {
|
||||||
if (lock) {
|
|
||||||
streamMutexUnlock(&execInfo.lock);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if any task updates exist, any other stream trans are not allowed to be created
|
||||||
int32_t code = mndStreamClearFinishedTrans(pMnode, NULL);
|
int32_t code = mndStreamClearFinishedTrans(pMnode, NULL);
|
||||||
if (code) {
|
if (code) {
|
||||||
mError("failed to clear finish trans, code:%s", tstrerror(code));
|
mError("failed to clear finish trans, code:%s, and continue", tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamId, sizeof(streamId));
|
SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamId, sizeof(streamId));
|
||||||
if (pEntry != NULL) {
|
if (pEntry != NULL) {
|
||||||
SStreamTransInfo tInfo = *pEntry;
|
SStreamTransInfo tInfo = *pEntry;
|
||||||
|
|
||||||
if (lock) {
|
|
||||||
streamMutexUnlock(&execInfo.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
||||||
if ((strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) && (strcmp(pTransName, MND_STREAM_TASK_RESET_NAME) != 0) &&
|
if ((strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) && (strcmp(pTransName, MND_STREAM_TASK_RESET_NAME) != 0) &&
|
||||||
(strcmp(pTransName, MND_STREAM_RESTART_NAME) != 0)) {
|
(strcmp(pTransName, MND_STREAM_RESTART_NAME) != 0)) {
|
||||||
|
@ -141,11 +131,25 @@ int32_t mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char
|
||||||
mDebug("stream:0x%" PRIx64 " no conflict trans existed, continue create trans", streamId);
|
mDebug("stream:0x%" PRIx64 " no conflict trans existed, continue create trans", streamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * Transactions of different streams are not related. Here only check the conflict of transaction for a given stream.
|
||||||
|
// For a given stream:
|
||||||
|
// 1. checkpoint trans is conflict with any other trans except for the drop and reset trans.
|
||||||
|
// 2. create/drop/reset/update trans are conflict with any other trans.
|
||||||
|
int32_t mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock) {
|
||||||
|
if (lock) {
|
||||||
|
streamMutexLock(&execInfo.lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = doStreamTransConflictCheck(pMnode, streamId, pTransName);
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
streamMutexUnlock(&execInfo.lock);
|
streamMutexUnlock(&execInfo.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId) {
|
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId) {
|
||||||
|
|
|
@ -108,30 +108,94 @@ static bool checkStatusForEachReplica(SVgObj *pVgroup) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
static int32_t mndAddSnodeInfo(SMnode *pMnode, SArray *pVgroupList) {
|
||||||
|
SSnodeObj *pObj = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pMnode->pSdb, SDB_SNODE, pIter, (void **)&pObj);
|
||||||
|
if (pIter == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNodeEntry entry = {.nodeId = SNODE_HANDLE};
|
||||||
|
code = addEpIntoEpSet(&entry.epset, pObj->pDnode->fqdn, pObj->pDnode->port);
|
||||||
|
if (code) {
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
|
mError("failed to extract epset for fqdn:%s during task vgroup snapshot", pObj->pDnode->fqdn);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[256] = {0};
|
||||||
|
code = epsetToStr(&entry.epset, buf, tListLen(buf));
|
||||||
|
if (code != 0) { // print error and continue
|
||||||
|
mError("failed to convert epset to str, code:%s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
void *p = taosArrayPush(pVgroupList, &entry);
|
||||||
|
if (p == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
|
mError("failed to put entry in vgroup list, nodeId:%d code:%s", entry.nodeId, tstrerror(code));
|
||||||
|
return code;
|
||||||
|
} else {
|
||||||
|
mDebug("take snode snapshot, nodeId:%d %s", entry.nodeId, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndCheckMnodeStatus(SMnode* pMnode) {
|
||||||
|
int32_t code = 0;
|
||||||
|
ESdbStatus objStatus;
|
||||||
|
void *pIter = NULL;
|
||||||
|
SMnodeObj *pObj = NULL;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetchAll(pMnode->pSdb, SDB_MNODE, pIter, (void **)&pObj, &objStatus, true);
|
||||||
|
if (pIter == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pObj->syncState != TAOS_SYNC_STATE_LEADER && pObj->syncState != TAOS_SYNC_STATE_FOLLOWER) {
|
||||||
|
mDebug("mnode sync state:%d not leader/follower", pObj->syncState);
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objStatus != SDB_STATUS_READY) {
|
||||||
|
mWarn("mnode status:%d not ready", objStatus);
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pMnode->pSdb, pObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndCheckAndAddVgroupsInfo(SMnode *pMnode, SArray *pVgroupList, bool* allReady) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArray *pVgroupList = NULL;
|
|
||||||
SHashObj *pHash = NULL;
|
SHashObj *pHash = NULL;
|
||||||
|
|
||||||
pVgroupList = taosArrayInit(4, sizeof(SNodeEntry));
|
|
||||||
if (pVgroupList == NULL) {
|
|
||||||
mError("failed to prepare arraylist during take vgroup snapshot, code:%s", tstrerror(terrno));
|
|
||||||
code = terrno;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
pHash = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
pHash = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (pHash == NULL) {
|
if (pHash == NULL) {
|
||||||
mError("failed to prepare hashmap during take vgroup snapshot, code:%s", tstrerror(terrno));
|
mError("failed to prepare hashmap during take vgroup snapshot, code:%s", tstrerror(terrno));
|
||||||
code = terrno;
|
return terrno;
|
||||||
goto _err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*allReady = true;
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
|
||||||
if (pIter == NULL) {
|
if (pIter == NULL) {
|
||||||
|
@ -148,7 +212,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
mError("failed to put info into hashmap during task vgroup snapshot, code:%s", tstrerror(code));
|
mError("failed to put info into hashmap during task vgroup snapshot, code:%s", tstrerror(code));
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
goto _err; // take snapshot failed, and not all ready
|
goto _end; // take snapshot failed, and not all ready
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (*pReplica != pVgroup->replica) {
|
if (*pReplica != pVgroup->replica) {
|
||||||
|
@ -158,7 +222,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not all ready till now, no need to check the remaining vgroups.
|
// if not all ready till now, no need to check the remaining vgroups,
|
||||||
// but still we need to put the info of the existed vgroups into the snapshot list
|
// but still we need to put the info of the existed vgroups into the snapshot list
|
||||||
if (*allReady) {
|
if (*allReady) {
|
||||||
*allReady = checkStatusForEachReplica(pVgroup);
|
*allReady = checkStatusForEachReplica(pVgroup);
|
||||||
|
@ -176,7 +240,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
goto _err;
|
goto _end;
|
||||||
} else {
|
} else {
|
||||||
mDebug("take node snapshot, nodeId:%d %s", entry.nodeId, buf);
|
mDebug("take node snapshot, nodeId:%d %s", entry.nodeId, buf);
|
||||||
}
|
}
|
||||||
|
@ -184,51 +248,49 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnodeObj *pObj = NULL;
|
_end:
|
||||||
while (1) {
|
taosHashCleanup(pHash);
|
||||||
pIter = sdbFetch(pSdb, SDB_SNODE, pIter, (void **)&pObj);
|
return code;
|
||||||
if (pIter == NULL) {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SNodeEntry entry = {.nodeId = SNODE_HANDLE};
|
int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
|
||||||
code = addEpIntoEpSet(&entry.epset, pObj->pDnode->fqdn, pObj->pDnode->port);
|
int32_t code = 0;
|
||||||
if (code) {
|
SArray *pVgroupList = NULL;
|
||||||
sdbRelease(pSdb, pObj);
|
|
||||||
sdbCancelFetch(pSdb, pIter);
|
|
||||||
mError("failed to extract epset for fqdn:%s during task vgroup snapshot", pObj->pDnode->fqdn);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buf[256] = {0};
|
*pList = NULL;
|
||||||
code = epsetToStr(&entry.epset, buf, tListLen(buf));
|
*allReady = true;
|
||||||
if (code != 0) { // print error and continue
|
|
||||||
mError("failed to convert epset to str, code:%s", tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void *p = taosArrayPush(pVgroupList, &entry);
|
pVgroupList = taosArrayInit(4, sizeof(SNodeEntry));
|
||||||
if (p == NULL) {
|
if (pVgroupList == NULL) {
|
||||||
code = terrno;
|
mError("failed to prepare arraylist during take vgroup snapshot, code:%s", tstrerror(terrno));
|
||||||
sdbRelease(pSdb, pObj);
|
code = terrno;
|
||||||
sdbCancelFetch(pSdb, pIter);
|
goto _err;
|
||||||
mError("failed to put entry in vgroup list, nodeId:%d code:%s", entry.nodeId, tstrerror(code));
|
}
|
||||||
goto _err;
|
|
||||||
} else {
|
|
||||||
mDebug("take snode snapshot, nodeId:%d %s", entry.nodeId, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
sdbRelease(pSdb, pObj);
|
// 1. check for all vnodes status
|
||||||
|
code = mndCheckAndAddVgroupsInfo(pMnode, pVgroupList, allReady);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. add snode info
|
||||||
|
code = mndAddSnodeInfo(pMnode, pVgroupList);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. check for mnode status
|
||||||
|
code = mndCheckMnodeStatus(pMnode);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
*allReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pList = pVgroupList;
|
*pList = pVgroupList;
|
||||||
taosHashCleanup(pHash);
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
*allReady = false;
|
*allReady = false;
|
||||||
taosArrayDestroy(pVgroupList);
|
taosArrayDestroy(pVgroupList);
|
||||||
taosHashCleanup(pHash);
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,17 @@ static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans, bool t
|
||||||
static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool topHalf);
|
static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool topHalf);
|
||||||
static bool mndTransPerformFinishStage(SMnode *pMnode, STrans *pTrans, bool topHalf);
|
static bool mndTransPerformFinishStage(SMnode *pMnode, STrans *pTrans, bool topHalf);
|
||||||
|
|
||||||
static bool mndCannotExecuteTransAction(SMnode *pMnode, bool topHalf) {
|
static inline bool mndTransIsInSyncContext(bool topHalf) { return !topHalf; }
|
||||||
return (!pMnode->deploy && !mndIsLeader(pMnode)) || !topHalf;
|
|
||||||
|
static bool mndCannotExecuteTrans(SMnode *pMnode, bool topHalf) {
|
||||||
|
bool isLeader = mndIsLeader(pMnode);
|
||||||
|
bool ret = (!pMnode->deploy && !isLeader) || mndTransIsInSyncContext(topHalf);
|
||||||
|
if (ret) mDebug("cannot execute trans action, deploy:%d, isLeader:%d, topHalf:%d", pMnode->deploy, isLeader, topHalf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline char *mndStrExecutionContext(bool topHalf) { return topHalf ? "transContext" : "syncContext"; }
|
||||||
|
|
||||||
static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
|
static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
|
||||||
static int32_t mndProcessTransTimer(SRpcMsg *pReq);
|
static int32_t mndProcessTransTimer(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessTtl(SRpcMsg *pReq);
|
static int32_t mndProcessTtl(SRpcMsg *pReq);
|
||||||
|
@ -1339,7 +1346,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
|
||||||
// execute in trans context
|
// execute in trans context
|
||||||
static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransAction *pAction, bool topHalf) {
|
static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransAction *pAction, bool topHalf) {
|
||||||
if (pAction->msgSent) return 0;
|
if (pAction->msgSent) return 0;
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
if (mndCannotExecuteTrans(pMnode, topHalf)) {
|
||||||
TAOS_RETURN(TSDB_CODE_MND_TRANS_CTX_SWITCH);
|
TAOS_RETURN(TSDB_CODE_MND_TRANS_CTX_SWITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1485,8 +1492,8 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, topHalf(TransContext):%d", pTrans->id,
|
mError("trans:%d, failed to execute redoActions since:%s, code:0x%x, in %s", pTrans->id, terrstr(), terrno,
|
||||||
terrstr(), terrno, topHalf);
|
mndStrExecutionContext(topHalf));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1494,8 +1501,8 @@ static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans, bool t
|
||||||
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute undoActions since %s. topHalf(TransContext):%d", pTrans->id, terrstr(),
|
mError("trans:%d, failed to execute undoActions since %s. in %s", pTrans->id, terrstr(),
|
||||||
topHalf);
|
mndStrExecutionContext(topHalf));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1503,8 +1510,8 @@ static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans, bool t
|
||||||
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->commitActions, topHalf);
|
||||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
||||||
mError("trans:%d, failed to execute commitActions since %s. topHalf(TransContext):%d", pTrans->id, terrstr(),
|
mError("trans:%d, failed to execute commitActions since %s. in %s", pTrans->id, terrstr(),
|
||||||
topHalf);
|
mndStrExecutionContext(topHalf));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1524,7 +1531,7 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
|
||||||
STransAction *pAction = taosArrayGet(pActions, action);
|
STransAction *pAction = taosArrayGet(pActions, action);
|
||||||
|
|
||||||
mInfo("trans:%d, current action:%d, stage:%s, actionType(0:log,1:msg):%d", pTrans->id, pTrans->actionPos,
|
mInfo("trans:%d, current action:%d, stage:%s, actionType(1:msg,2:log):%d", pTrans->id, pTrans->actionPos,
|
||||||
mndTransStr(pAction->stage), pAction->actionType);
|
mndTransStr(pAction->stage), pAction->actionType);
|
||||||
|
|
||||||
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
||||||
|
@ -1555,11 +1562,11 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
||||||
}
|
}
|
||||||
mndSetTransLastAction(pTrans, pAction);
|
mndSetTransLastAction(pTrans, pAction);
|
||||||
|
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
if (mndCannotExecuteTrans(pMnode, topHalf)) {
|
||||||
pTrans->lastErrorNo = code;
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
mInfo("trans:%d, %s:%d, topHalf(TransContext):%d, not execute next action, code:%s", pTrans->id,
|
mInfo("trans:%d, %s:%d, cannot execute next action in %s, code:%s", pTrans->id, mndTransStr(pAction->stage),
|
||||||
mndTransStr(pAction->stage), action, topHalf, tstrerror(code));
|
action, mndStrExecutionContext(topHalf), tstrerror(code));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1660,20 +1667,21 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
code = mndTransExecuteRedoActions(pMnode, pTrans, topHalf);
|
code = mndTransExecuteRedoActions(pMnode, pTrans, topHalf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) {
|
if (code != 0 && code != TSDB_CODE_MND_TRANS_CTX_SWITCH && mndTransIsInSyncContext(topHalf)) {
|
||||||
pTrans->lastErrorNo = code;
|
pTrans->lastErrorNo = code;
|
||||||
pTrans->code = code;
|
pTrans->code = code;
|
||||||
bool continueExec = true;
|
mInfo(
|
||||||
if (code != 0 && code != TSDB_CODE_MND_TRANS_CTX_SWITCH) {
|
"trans:%d, failed to execute, will retry redo action stage in 100 ms , in %s, "
|
||||||
taosMsleep(100);
|
"continueExec:%d, code:%s",
|
||||||
continueExec = true;
|
pTrans->id, mndStrExecutionContext(topHalf), continueExec, tstrerror(code));
|
||||||
} else {
|
taosMsleep(100);
|
||||||
continueExec = false;
|
return true;
|
||||||
|
} else {
|
||||||
|
if (mndCannotExecuteTrans(pMnode, topHalf)) {
|
||||||
|
mInfo("trans:%d, cannot continue to execute redo action stage in %s, continueExec:%d, code:%s", pTrans->id,
|
||||||
|
mndStrExecutionContext(topHalf), continueExec, tstrerror(code));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
mInfo("trans:%d, cannot execute redo action stage, topHalf(TransContext):%d, continueExec:%d, code:%s", pTrans->id,
|
|
||||||
topHalf, continueExec, tstrerror(code));
|
|
||||||
|
|
||||||
return continueExec;
|
|
||||||
}
|
}
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
|
||||||
|
@ -1716,9 +1724,9 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
return continueExec;
|
return continueExec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in trans context
|
// execute in trans context
|
||||||
static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) return false;
|
if (mndCannotExecuteTrans(pMnode, topHalf)) return false;
|
||||||
|
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
int32_t code = mndTransCommit(pMnode, pTrans);
|
int32_t code = mndTransCommit(pMnode, pTrans);
|
||||||
|
@ -1772,7 +1780,7 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
code = mndTransExecuteUndoActions(pMnode, pTrans, topHalf);
|
code = mndTransExecuteUndoActions(pMnode, pTrans, topHalf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) return false;
|
if (mndCannotExecuteTrans(pMnode, topHalf)) return false;
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
|
@ -1793,7 +1801,7 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans, bool
|
||||||
|
|
||||||
// in trans context
|
// in trans context
|
||||||
static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) return false;
|
if (mndCannotExecuteTrans(pMnode, topHalf)) return false;
|
||||||
|
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
int32_t code = mndTransRollback(pMnode, pTrans);
|
int32_t code = mndTransRollback(pMnode, pTrans);
|
||||||
|
@ -1810,8 +1818,9 @@ static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans, bool to
|
||||||
return continueExec;
|
return continueExec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// excute in trans context
|
||||||
static bool mndTransPerformPreFinishStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
static bool mndTransPerformPreFinishStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
if (mndCannotExecuteTransAction(pMnode, topHalf)) return false;
|
if (mndCannotExecuteTrans(pMnode, topHalf)) return false;
|
||||||
|
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
int32_t code = mndTransPreFinish(pMnode, pTrans);
|
int32_t code = mndTransPreFinish(pMnode, pTrans);
|
||||||
|
@ -1854,8 +1863,8 @@ void mndTransExecuteImp(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||||
bool continueExec = true;
|
bool continueExec = true;
|
||||||
|
|
||||||
while (continueExec) {
|
while (continueExec) {
|
||||||
mInfo("trans:%d, continue to execute, stage:%s createTime:%" PRId64 " topHalf(TransContext):%d", pTrans->id,
|
mInfo("trans:%d, continue to execute stage:%s in %s, createTime:%" PRId64 "", pTrans->id,
|
||||||
mndTransStr(pTrans->stage), pTrans->createdTime, topHalf);
|
mndTransStr(pTrans->stage), mndStrExecutionContext(topHalf), pTrans->createdTime);
|
||||||
pTrans->lastExecTime = taosGetTimestampMs();
|
pTrans->lastExecTime = taosGetTimestampMs();
|
||||||
switch (pTrans->stage) {
|
switch (pTrans->stage) {
|
||||||
case TRN_STAGE_PREPARE:
|
case TRN_STAGE_PREPARE:
|
||||||
|
|
|
@ -1706,8 +1706,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
if (pCreate->isImport != 1) {
|
if (pCreate->isImport != 1) {
|
||||||
taosEncryptPass_c((uint8_t *)pCreate->pass, strlen(pCreate->pass), userObj.pass);
|
taosEncryptPass_c((uint8_t *)pCreate->pass, strlen(pCreate->pass), userObj.pass);
|
||||||
} else {
|
} else {
|
||||||
// mInfo("pCreate->pass:%s", pCreate->pass)
|
// mInfo("pCreate->pass:%s", pCreate->eass)
|
||||||
strncpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
memcpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
||||||
}
|
}
|
||||||
tstrncpy(userObj.user, pCreate->user, TSDB_USER_LEN);
|
tstrncpy(userObj.user, pCreate->user, TSDB_USER_LEN);
|
||||||
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
|
@ -1803,6 +1803,43 @@ _OVER:
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndCheckPasswordFmt(const char *pwd) {
|
||||||
|
int32_t len = strlen(pwd);
|
||||||
|
if (len < TSDB_PASSWORD_MIN_LEN || len > TSDB_PASSWORD_MAX_LEN) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(pwd, "taosdata") == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool charTypes[4] = {0};
|
||||||
|
for (int32_t i = 0; i < len; ++i) {
|
||||||
|
if (taosIsBigChar(pwd[i])) {
|
||||||
|
charTypes[0] = true;
|
||||||
|
} else if (taosIsSmallChar(pwd[i])) {
|
||||||
|
charTypes[1] = true;
|
||||||
|
} else if (taosIsNumberChar(pwd[i])) {
|
||||||
|
charTypes[2] = true;
|
||||||
|
} else if (taosIsSpecialChar(pwd[i])) {
|
||||||
|
charTypes[3] = true;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfTypes = 0;
|
||||||
|
for (int32_t i = 0; i < 4; ++i) {
|
||||||
|
numOfTypes += charTypes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numOfTypes < 3) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1836,7 +1873,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createReq.pass[0] == 0) {
|
if (mndCheckPasswordFmt(createReq.pass) != 0) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2325,8 +2362,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_USER_FORMAT, &lino, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType &&
|
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType && mndCheckPasswordFmt(alterReq.pass) != 0) {
|
||||||
(alterReq.pass[0] == 0 || strlen(alterReq.pass) >= TSDB_PASSWORD_LEN)) {
|
|
||||||
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
TAOS_CHECK_GOTO(TSDB_CODE_MND_INVALID_PASS_FORMAT, &lino, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
||||||
opts.source = pRaw->pData;
|
opts.source = pRaw->pData;
|
||||||
opts.result = plantContent;
|
opts.result = plantContent;
|
||||||
opts.unitLen = 16;
|
opts.unitLen = 16;
|
||||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
|
|
||||||
count = CBC_Decrypt(&opts);
|
count = CBC_Decrypt(&opts);
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
opts.source = pRaw->pData;
|
opts.source = pRaw->pData;
|
||||||
opts.result = newData;
|
opts.result = newData;
|
||||||
opts.unitLen = 16;
|
opts.unitLen = 16;
|
||||||
strncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
|
|
||||||
int32_t count = CBC_Encrypt(&opts);
|
int32_t count = CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
|
|
@ -254,11 +254,12 @@ static void tdRSmaTaskInit(SStreamMeta *pMeta, SRSmaInfoItem *pItem, SStreamTask
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tdRSmaTaskRemove(SStreamMeta *pMeta, int64_t streamId, int32_t taskId) {
|
static void tdRSmaTaskRemove(SStreamMeta *pMeta, int64_t streamId, int32_t taskId) {
|
||||||
|
streamMetaWLock(pMeta);
|
||||||
|
|
||||||
int32_t code = streamMetaUnregisterTask(pMeta, streamId, taskId);
|
int32_t code = streamMetaUnregisterTask(pMeta, streamId, taskId);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
smaError("vgId:%d, rsma task:%" PRIi64 ",%d drop failed since %s", pMeta->vgId, streamId, taskId, tstrerror(code));
|
smaError("vgId:%d, rsma task:%" PRIi64 ",%d drop failed since %s", pMeta->vgId, streamId, taskId, tstrerror(code));
|
||||||
}
|
}
|
||||||
streamMetaWLock(pMeta);
|
|
||||||
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
||||||
if (streamMetaCommit(pMeta) < 0) {
|
if (streamMetaCommit(pMeta) < 0) {
|
||||||
// persist to disk
|
// persist to disk
|
||||||
|
|
|
@ -1108,91 +1108,76 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always return success to mnode
|
||||||
|
//todo: handle failure of build and send msg to mnode
|
||||||
|
static void doSendChkptSourceRsp(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, int32_t code,
|
||||||
|
int32_t taskId) {
|
||||||
|
SRpcMsg rsp = {0};
|
||||||
|
int32_t ret = streamTaskBuildCheckpointSourceRsp(pReq, pRpcInfo, &rsp, code);
|
||||||
|
if (ret) { // suppress the error in build checkpoint source rsp
|
||||||
|
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", taskId, tstrerror(ret));
|
||||||
|
}
|
||||||
|
tmsgSendRsp(&rsp); // error occurs
|
||||||
|
}
|
||||||
|
|
||||||
// no matter what kinds of error happened, make sure the mnode will receive the success execution code.
|
// no matter what kinds of error happened, make sure the mnode will receive the success execution code.
|
||||||
int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) {
|
int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
int32_t vgId = TD_VID(pTq->pVnode);
|
||||||
SStreamMeta* pMeta = pTq->pStreamMeta;
|
SStreamMeta* pMeta = pTq->pStreamMeta;
|
||||||
char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
int32_t len = pMsg->contLen - sizeof(SMsgHead);
|
int32_t len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SStreamCheckpointSourceReq req = {0};
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
SStreamTask* pTask = NULL;
|
||||||
|
int64_t checkpointId = 0;
|
||||||
|
|
||||||
// disable auto rsp to mnode
|
// disable auto rsp to mnode
|
||||||
pRsp->info.handle = NULL;
|
pRsp->info.handle = NULL;
|
||||||
|
|
||||||
SStreamCheckpointSourceReq req = {0};
|
|
||||||
SDecoder decoder;
|
|
||||||
tDecoderInit(&decoder, (uint8_t*)msg, len);
|
tDecoderInit(&decoder, (uint8_t*)msg, len);
|
||||||
if (tDecodeStreamCheckpointSourceReq(&decoder, &req) < 0) {
|
if (tDecodeStreamCheckpointSourceReq(&decoder, &req) < 0) {
|
||||||
code = TSDB_CODE_MSG_DECODE_ERROR;
|
code = TSDB_CODE_MSG_DECODE_ERROR;
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
tqError("vgId:%d failed to decode checkpoint-source msg, code:%s", vgId, tstrerror(code));
|
tqError("vgId:%d failed to decode checkpoint-source msg, code:%s", vgId, tstrerror(code));
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
return TSDB_CODE_SUCCESS; // always return success to mnode,
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
if (!vnodeIsRoleLeader(pTq->pVnode)) {
|
if (!vnodeIsRoleLeader(pTq->pVnode)) {
|
||||||
tqDebug("vgId:%d not leader, ignore checkpoint-source msg, s-task:0x%x", vgId, req.taskId);
|
tqDebug("vgId:%d not leader, ignore checkpoint-source msg, s-task:0x%x", vgId, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
return TSDB_CODE_SUCCESS; // always return success to mnode
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pTq->pVnode->restored) {
|
if (!pTq->pVnode->restored) {
|
||||||
tqDebug("vgId:%d checkpoint-source msg received during restoring, checkpointId:%" PRId64
|
tqDebug("vgId:%d checkpoint-source msg received during restoring, checkpointId:%" PRId64
|
||||||
", transId:%d s-task:0x%x ignore it",
|
", transId:%d s-task:0x%x ignore it",
|
||||||
vgId, req.checkpointId, req.transId, req.taskId);
|
vgId, req.checkpointId, req.transId, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
return TSDB_CODE_SUCCESS; // always return success to mnode
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS; // always return success to mnode, , todo: handle failure of build and send msg to mnode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamTask* pTask = NULL;
|
|
||||||
code = streamMetaAcquireTask(pMeta, req.streamId, req.taskId, &pTask);
|
code = streamMetaAcquireTask(pMeta, req.streamId, req.taskId, &pTask);
|
||||||
if (pTask == NULL || code != 0) {
|
if (pTask == NULL || code != 0) {
|
||||||
tqError("vgId:%d failed to find s-task:0x%x, ignore checkpoint msg. checkpointId:%" PRId64
|
tqError("vgId:%d failed to find s-task:0x%x, ignore checkpoint msg. checkpointId:%" PRId64
|
||||||
" transId:%d it may have been destroyed",
|
" transId:%d it may have been destroyed",
|
||||||
vgId, req.taskId, req.checkpointId, req.transId);
|
vgId, req.taskId, req.checkpointId, req.transId);
|
||||||
SRpcMsg rsp = {0};
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
|
||||||
}
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask->status.downstreamReady != 1) {
|
if (pTask->status.downstreamReady != 1) {
|
||||||
streamTaskSetFailedChkptInfo(pTask, req.transId, req.checkpointId); // record the latest failed checkpoint id
|
// record the latest failed checkpoint id
|
||||||
|
streamTaskSetFailedChkptInfo(pTask, req.transId, req.checkpointId);
|
||||||
tqError("s-task:%s not ready for checkpoint, since downstream not ready, ignore this checkpointId:%" PRId64
|
tqError("s-task:%s not ready for checkpoint, since downstream not ready, ignore this checkpointId:%" PRId64
|
||||||
", transId:%d set it failed",
|
", transId:%d set it failed",
|
||||||
pTask->id.idStr, req.checkpointId, req.transId);
|
pTask->id.idStr, req.checkpointId, req.transId);
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS; // todo retry handle error
|
return TSDB_CODE_SUCCESS; // todo retry handle error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,14 +1192,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
streamMutexUnlock(&pTask->lock);
|
streamMutexUnlock(&pTask->lock);
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1226,7 +1204,6 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
// check if the checkpoint msg already sent or not.
|
// check if the checkpoint msg already sent or not.
|
||||||
if (status == TASK_STATUS__CK) {
|
if (status == TASK_STATUS__CK) {
|
||||||
int64_t checkpointId = 0;
|
|
||||||
streamTaskGetActiveCheckpointInfo(pTask, NULL, &checkpointId);
|
streamTaskGetActiveCheckpointInfo(pTask, NULL, &checkpointId);
|
||||||
|
|
||||||
tqWarn("s-task:%s repeatly recv checkpoint-source msg checkpointId:%" PRId64
|
tqWarn("s-task:%s repeatly recv checkpoint-source msg checkpointId:%" PRId64
|
||||||
|
@ -1235,7 +1212,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
streamMutexUnlock(&pTask->lock);
|
streamMutexUnlock(&pTask->lock);
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SYN_PROPOSE_NOT_READY, req.taskId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else { // checkpoint already finished, and not in checkpoint status
|
} else { // checkpoint already finished, and not in checkpoint status
|
||||||
if (req.checkpointId <= pTask->chkInfo.checkpointId) {
|
if (req.checkpointId <= pTask->chkInfo.checkpointId) {
|
||||||
|
@ -1245,15 +1222,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
streamMutexUnlock(&pTask->lock);
|
streamMutexUnlock(&pTask->lock);
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
SRpcMsg rsp = {0};
|
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1264,7 +1233,9 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
if (code) {
|
if (code) {
|
||||||
qError("s-task:%s (vgId:%d) failed to process checkpoint-source req, code:%s", pTask->id.idStr, vgId,
|
qError("s-task:%s (vgId:%d) failed to process checkpoint-source req, code:%s", pTask->id.idStr, vgId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.mndTrigger) {
|
if (req.mndTrigger) {
|
||||||
|
@ -1279,13 +1250,8 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
||||||
|
|
||||||
code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask);
|
code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
SRpcMsg rsp = {0};
|
streamTaskSetCheckpointFailed(pTask); // set the checkpoint failed
|
||||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
doSendChkptSourceRsp(&req, &pMsg->info, TSDB_CODE_SUCCESS, req.taskId);
|
||||||
if (ret) { // suppress the error in build checkpointsource rsp
|
|
||||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
|
||||||
}
|
|
||||||
tmsgSendRsp(&rsp); // error occurs
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaReleaseTask(pMeta, pTask);
|
streamMetaReleaseTask(pMeta, pTask);
|
||||||
|
|
|
@ -13,9 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common/tmsg.h>
|
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tmsg.h"
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
#define IS_NEW_SUBTB_RULE(_t) (((_t)->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER) && ((_t)->subtableWithoutMd5 != 1))
|
#define IS_NEW_SUBTB_RULE(_t) (((_t)->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER) && ((_t)->subtableWithoutMd5 != 1))
|
||||||
|
@ -50,7 +48,7 @@ static int32_t doPutSinkTableInfoIntoCache(SSHashObj* pSinkTableMap, STableSinkI
|
||||||
static bool doGetSinkTableInfoFromCache(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo);
|
static bool doGetSinkTableInfoFromCache(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo);
|
||||||
static int32_t doRemoveSinkTableInfoInCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id);
|
static int32_t doRemoveSinkTableInfoInCache(SSHashObj* pSinkTableMap, uint64_t groupId, const char* id);
|
||||||
static int32_t checkTagSchema(SStreamTask* pTask, SVnode* pVnode);
|
static int32_t checkTagSchema(SStreamTask* pTask, SVnode* pVnode);
|
||||||
static void reubuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs);
|
static void rebuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs);
|
||||||
static int32_t handleResultBlockMsg(SStreamTask* pTask, SSDataBlock* pDataBlock, int32_t index, SVnode* pVnode,
|
static int32_t handleResultBlockMsg(SStreamTask* pTask, SSDataBlock* pDataBlock, int32_t index, SVnode* pVnode,
|
||||||
int64_t earlyTs);
|
int64_t earlyTs);
|
||||||
|
|
||||||
|
@ -1062,7 +1060,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reubuildAndSendMultiResBlock(pTask, pBlocks, pVnode, earlyTs);
|
rebuildAndSendMultiResBlock(pTask, pBlocks, pVnode, earlyTs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,7 +1163,7 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reubuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs) {
|
void rebuildAndSendMultiResBlock(SStreamTask* pTask, const SArray* pBlocks, SVnode* pVnode, int64_t earlyTs) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
const char* id = pTask->id.idStr;
|
const char* id = pTask->id.idStr;
|
||||||
int32_t vgId = pTask->pMeta->vgId;
|
int32_t vgId = pTask->pMeta->vgId;
|
||||||
|
|
|
@ -17,19 +17,20 @@
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
#define MAX_REPEAT_SCAN_THRESHOLD 3
|
#define MAX_REPEAT_SCAN_THRESHOLD 3
|
||||||
#define SCAN_WAL_IDLE_DURATION 100
|
#define SCAN_WAL_IDLE_DURATION 500 // idle for 500ms to do next wal scan
|
||||||
|
|
||||||
typedef struct SBuildScanWalMsgParam {
|
typedef struct SBuildScanWalMsgParam {
|
||||||
int64_t metaId;
|
int64_t metaId;
|
||||||
int32_t numOfTasks;
|
int32_t numOfTasks;
|
||||||
} SBuildScanWalMsgParam;
|
} SBuildScanWalMsgParam;
|
||||||
|
|
||||||
static int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle);
|
static int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta);
|
||||||
static int32_t setWalReaderStartOffset(SStreamTask* pTask, int32_t vgId);
|
static int32_t setWalReaderStartOffset(SStreamTask* pTask, int32_t vgId);
|
||||||
static bool handleFillhistoryScanComplete(SStreamTask* pTask, int64_t ver);
|
static bool handleFillhistoryScanComplete(SStreamTask* pTask, int64_t ver);
|
||||||
static bool taskReadyForDataFromWal(SStreamTask* pTask);
|
static bool taskReadyForDataFromWal(SStreamTask* pTask);
|
||||||
static int32_t doPutDataIntoInputQ(SStreamTask* pTask, int64_t maxVer, int32_t* numOfItems, bool* pSucc);
|
static int32_t doPutDataIntoInputQ(SStreamTask* pTask, int64_t maxVer, int32_t* numOfItems, bool* pSucc);
|
||||||
static int32_t tqScanWalInFuture(STQ* pTq, int32_t numOfTasks, int32_t idleDuration);
|
static int32_t tqScanWalInFuture(STQ* pTq, int32_t numOfTasks, int32_t idleDuration);
|
||||||
|
static int32_t doScanWalAsync(STQ* pTq, bool ckPause);
|
||||||
|
|
||||||
// extract data blocks(submit/delete) from WAL, and add them into the input queue for all the sources tasks.
|
// extract data blocks(submit/delete) from WAL, and add them into the input queue for all the sources tasks.
|
||||||
int32_t tqScanWal(STQ* pTq) {
|
int32_t tqScanWal(STQ* pTq) {
|
||||||
|
@ -37,12 +38,11 @@ int32_t tqScanWal(STQ* pTq) {
|
||||||
int32_t vgId = pMeta->vgId;
|
int32_t vgId = pMeta->vgId;
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
int32_t numOfTasks = 0;
|
int32_t numOfTasks = 0;
|
||||||
bool shouldIdle = true;
|
|
||||||
|
|
||||||
tqDebug("vgId:%d continue to check if data in wal are available, scanCounter:%d", vgId, pMeta->scanInfo.scanCounter);
|
tqDebug("vgId:%d continue to check if data in wal are available, scanCounter:%d", vgId, pMeta->scanInfo.scanCounter);
|
||||||
|
|
||||||
// check all tasks
|
// check all tasks
|
||||||
int32_t code = doScanWalForAllTasks(pMeta, &shouldIdle);
|
int32_t code = doScanWalForAllTasks(pMeta);
|
||||||
if (code) {
|
if (code) {
|
||||||
tqError("vgId:%d failed to start all tasks, try next time, code:%s", vgId, tstrerror(code));
|
tqError("vgId:%d failed to start all tasks, try next time, code:%s", vgId, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -133,10 +133,9 @@ int32_t tqScanWalInFuture(STQ* pTq, int32_t numOfTasks, int32_t idleDuration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqScanWalAsync(STQ* pTq, bool ckPause) {
|
int32_t tqScanWalAsync(STQ* pTq, bool ckPause) {
|
||||||
int32_t vgId = TD_VID(pTq->pVnode);
|
|
||||||
SStreamMeta* pMeta = pTq->pStreamMeta;
|
SStreamMeta* pMeta = pTq->pStreamMeta;
|
||||||
bool alreadyRestored = pTq->pVnode->restored;
|
bool alreadyRestored = pTq->pVnode->restored;
|
||||||
int32_t numOfTasks = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
// do not launch the stream tasks, if it is a follower or not restored vnode.
|
// do not launch the stream tasks, if it is a follower or not restored vnode.
|
||||||
if (!(vnodeIsRoleLeader(pTq->pVnode) && alreadyRestored)) {
|
if (!(vnodeIsRoleLeader(pTq->pVnode) && alreadyRestored)) {
|
||||||
|
@ -144,47 +143,8 @@ int32_t tqScanWalAsync(STQ* pTq, bool ckPause) {
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaWLock(pMeta);
|
streamMetaWLock(pMeta);
|
||||||
|
code = doScanWalAsync(pTq, ckPause);
|
||||||
numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
|
||||||
if (numOfTasks == 0) {
|
|
||||||
tqDebug("vgId:%d no stream tasks existed to run", vgId);
|
|
||||||
streamMetaWUnLock(pMeta);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMeta->startInfo.startAllTasks) {
|
|
||||||
tqTrace("vgId:%d in restart procedure, not scan wal", vgId);
|
|
||||||
streamMetaWUnLock(pMeta);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pMeta->scanInfo.scanCounter += 1;
|
|
||||||
if (pMeta->scanInfo.scanCounter > MAX_REPEAT_SCAN_THRESHOLD) {
|
|
||||||
pMeta->scanInfo.scanCounter = MAX_REPEAT_SCAN_THRESHOLD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMeta->scanInfo.scanCounter > 1) {
|
|
||||||
tqDebug("vgId:%d wal read task has been launched, remain scan times:%d", vgId, pMeta->scanInfo.scanCounter);
|
|
||||||
streamMetaWUnLock(pMeta);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t numOfPauseTasks = pMeta->numOfPausedTasks;
|
|
||||||
if (ckPause && numOfTasks == numOfPauseTasks) {
|
|
||||||
tqDebug("vgId:%d ignore all submit, all streams had been paused, reset the walScanCounter", vgId);
|
|
||||||
|
|
||||||
// reset the counter value, since we do not launch the scan wal operation.
|
|
||||||
pMeta->scanInfo.scanCounter = 0;
|
|
||||||
streamMetaWUnLock(pMeta);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tqDebug("vgId:%d create msg to start wal scan to launch stream tasks, numOfTasks:%d, vnd restored:%d", vgId,
|
|
||||||
numOfTasks, alreadyRestored);
|
|
||||||
|
|
||||||
int32_t code = streamTaskSchedTask(&pTq->pVnode->msgCb, vgId, 0, 0, STREAM_EXEC_T_EXTRACT_WAL_DATA);
|
|
||||||
streamMetaWUnLock(pMeta);
|
streamMetaWUnLock(pMeta);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,11 +328,8 @@ int32_t doPutDataIntoInputQ(SStreamTask* pTask, int64_t maxVer, int32_t* numOfIt
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle) {
|
int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta) {
|
||||||
*pScanIdle = true;
|
|
||||||
bool noDataInWal = true;
|
|
||||||
int32_t vgId = pStreamMeta->vgId;
|
int32_t vgId = pStreamMeta->vgId;
|
||||||
|
|
||||||
int32_t numOfTasks = taosArrayGetSize(pStreamMeta->pTaskList);
|
int32_t numOfTasks = taosArrayGetSize(pStreamMeta->pTaskList);
|
||||||
if (numOfTasks == 0) {
|
if (numOfTasks == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -410,8 +367,6 @@ int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pScanIdle = false;
|
|
||||||
|
|
||||||
// seek the stored version and extract data from WAL
|
// seek the stored version and extract data from WAL
|
||||||
code = setWalReaderStartOffset(pTask, vgId);
|
code = setWalReaderStartOffset(pTask, vgId);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -437,7 +392,6 @@ int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle) {
|
||||||
streamMutexUnlock(&pTask->lock);
|
streamMutexUnlock(&pTask->lock);
|
||||||
|
|
||||||
if ((numOfItems > 0) || hasNewData) {
|
if ((numOfItems > 0) || hasNewData) {
|
||||||
noDataInWal = false;
|
|
||||||
code = streamTrySchedExec(pTask);
|
code = streamTrySchedExec(pTask);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
streamMetaReleaseTask(pStreamMeta, pTask);
|
streamMetaReleaseTask(pStreamMeta, pTask);
|
||||||
|
@ -449,11 +403,47 @@ int32_t doScanWalForAllTasks(SStreamMeta* pStreamMeta, bool* pScanIdle) {
|
||||||
streamMetaReleaseTask(pStreamMeta, pTask);
|
streamMetaReleaseTask(pStreamMeta, pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all wal are checked, and no new data available in wal.
|
|
||||||
if (noDataInWal) {
|
|
||||||
*pScanIdle = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pTaskList);
|
taosArrayDestroy(pTaskList);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t doScanWalAsync(STQ* pTq, bool ckPause) {
|
||||||
|
SStreamMeta* pMeta = pTq->pStreamMeta;
|
||||||
|
bool alreadyRestored = pTq->pVnode->restored;
|
||||||
|
int32_t vgId = pMeta->vgId;
|
||||||
|
int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList);
|
||||||
|
|
||||||
|
if (numOfTasks == 0) {
|
||||||
|
tqDebug("vgId:%d no stream tasks existed to run", vgId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->startInfo.startAllTasks) {
|
||||||
|
tqTrace("vgId:%d in restart procedure, not scan wal", vgId);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMeta->scanInfo.scanCounter += 1;
|
||||||
|
if (pMeta->scanInfo.scanCounter > MAX_REPEAT_SCAN_THRESHOLD) {
|
||||||
|
pMeta->scanInfo.scanCounter = MAX_REPEAT_SCAN_THRESHOLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->scanInfo.scanCounter > 1) {
|
||||||
|
tqDebug("vgId:%d wal read task has been launched, remain scan times:%d", vgId, pMeta->scanInfo.scanCounter);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t numOfPauseTasks = pMeta->numOfPausedTasks;
|
||||||
|
if (ckPause && numOfTasks == numOfPauseTasks) {
|
||||||
|
tqDebug("vgId:%d ignore all submit, all streams had been paused, reset the walScanCounter", vgId);
|
||||||
|
|
||||||
|
// reset the counter value, since we do not launch the scan wal operation.
|
||||||
|
pMeta->scanInfo.scanCounter = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tqDebug("vgId:%d create msg to start wal scan to launch stream tasks, numOfTasks:%d, vnd restored:%d", vgId,
|
||||||
|
numOfTasks, alreadyRestored);
|
||||||
|
|
||||||
|
return streamTaskSchedTask(&pTq->pVnode->msgCb, vgId, 0, 0, STREAM_EXEC_T_EXTRACT_WAL_DATA);
|
||||||
|
}
|
||||||
|
|
|
@ -718,8 +718,6 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMetaWUnLock(pMeta);
|
|
||||||
|
|
||||||
// drop the related fill-history task firstly
|
// drop the related fill-history task firstly
|
||||||
if (hTaskId.taskId != 0 && hTaskId.streamId != 0) {
|
if (hTaskId.taskId != 0 && hTaskId.streamId != 0) {
|
||||||
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x firstly", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
tqDebug("s-task:0x%x vgId:%d drop rel fill-history task:0x%x firstly", pReq->taskId, vgId, (int32_t)hTaskId.taskId);
|
||||||
|
@ -737,7 +735,6 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit the update
|
// commit the update
|
||||||
streamMetaWLock(pMeta);
|
|
||||||
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
||||||
tqDebug("vgId:%d task:0x%x dropped, remain tasks:%d", vgId, pReq->taskId, numOfTasks);
|
tqDebug("vgId:%d task:0x%x dropped, remain tasks:%d", vgId, pReq->taskId, numOfTasks);
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ static int32_t tsdbFSAddEntryToFileObjHash(STFileHash *hash, const char *fname)
|
||||||
STFileHashEntry *entry = taosMemoryMalloc(sizeof(*entry));
|
STFileHashEntry *entry = taosMemoryMalloc(sizeof(*entry));
|
||||||
if (entry == NULL) return terrno;
|
if (entry == NULL) return terrno;
|
||||||
|
|
||||||
strncpy(entry->fname, fname, TSDB_FILENAME_LEN);
|
tstrncpy(entry->fname, fname, TSDB_FILENAME_LEN);
|
||||||
|
|
||||||
uint32_t idx = MurmurHash3_32(fname, strlen(fname)) % hash->numBucket;
|
uint32_t idx = MurmurHash3_32(fname, strlen(fname)) % hash->numBucket;
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
||||||
opts.result = PacketData;
|
opts.result = PacketData;
|
||||||
opts.unitLen = 128;
|
opts.unitLen = 128;
|
||||||
// strncpy(opts.key, tsEncryptKey, 16);
|
// strncpy(opts.key, tsEncryptKey, 16);
|
||||||
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
|
|
||||||
NewLen = CBC_Encrypt(&opts);
|
NewLen = CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
|
||||||
opts.result = PacketData;
|
opts.result = PacketData;
|
||||||
opts.unitLen = 128;
|
opts.unitLen = 128;
|
||||||
// strncpy(opts.key, tsEncryptKey, 16);
|
// strncpy(opts.key, tsEncryptKey, 16);
|
||||||
strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
|
|
||||||
NewLen = CBC_Decrypt(&opts);
|
NewLen = CBC_Decrypt(&opts);
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (tsEncryptKey[0] == 0) {
|
if (tsEncryptKey[0] == 0) {
|
||||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
} else {
|
} else {
|
||||||
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -292,7 +292,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (tsEncryptKey[0] == 0) {
|
if (tsEncryptKey[0] == 0) {
|
||||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
} else {
|
} else {
|
||||||
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,9 +103,11 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
code = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
||||||
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
|
// ignore timeout error and retry
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
if (code == TSDB_CODE_TIMEOUT_ERROR) {
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,14 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
|
||||||
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
|
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
|
||||||
if (tsdbFilePrefixPos == NULL) continue;
|
if (tsdbFilePrefixPos == NULL) continue;
|
||||||
|
|
||||||
int32_t tsdbFileVgId = atoi(tsdbFilePrefixPos + prefixLen);
|
int32_t tsdbFileVgId = 0; // atoi(tsdbFilePrefixPos + prefixLen);
|
||||||
|
ret = taosStr2int32(tsdbFilePrefixPos + prefixLen, &tsdbFileVgId);
|
||||||
|
if (ret != 0) {
|
||||||
|
vError("vgId:%d, failed to get tsdb file vgid since %s", dstVgId, tstrerror(ret));
|
||||||
|
tfsClosedir(tsdbDir);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (tsdbFileVgId == srcVgId) {
|
if (tsdbFileVgId == srcVgId) {
|
||||||
char *tsdbFileSurfixPos = tsdbFilePrefixPos + prefixLen + vnodeVgroupIdLen(srcVgId);
|
char *tsdbFileSurfixPos = tsdbFilePrefixPos + prefixLen + vnodeVgroupIdLen(srcVgId);
|
||||||
|
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode *pVnode, int64_t ver, void
|
||||||
expiredTb.suid = *uid;
|
expiredTb.suid = *uid;
|
||||||
terrno = metaReaderGetTableEntryByUid(&mr, *uid);
|
terrno = metaReaderGetTableEntryByUid(&mr, *uid);
|
||||||
if (terrno < 0) goto _end;
|
if (terrno < 0) goto _end;
|
||||||
strncpy(buf, mr.me.name, TSDB_TABLE_NAME_LEN);
|
tstrncpy(buf, mr.me.name, TSDB_TABLE_NAME_LEN);
|
||||||
void *p = taosArrayPush(pNames, buf);
|
void *p = taosArrayPush(pNames, buf);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
goto _end;
|
goto _end;
|
||||||
|
|
|
@ -2449,13 +2449,21 @@ static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t
|
||||||
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
pInfo->bytes = varDataTLen(pData);
|
if (type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pInfo->bytes = getJsonValueLen(pData);
|
||||||
|
} else {
|
||||||
|
pInfo->bytes = varDataTLen(pData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
|
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
|
||||||
if (pkData != NULL) {
|
if (pkData != NULL) {
|
||||||
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
|
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
|
||||||
pInfo->pkBytes = varDataTLen(pkData);
|
if (pInfo->pkType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pInfo->pkBytes = getJsonValueLen(pkData);
|
||||||
|
} else {
|
||||||
|
pInfo->pkBytes = varDataTLen(pkData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
|
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
|
||||||
pInfo->pkData = pInfo->buf + pInfo->bytes;
|
pInfo->pkData = pInfo->buf + pInfo->bytes;
|
||||||
|
@ -2985,7 +2993,11 @@ static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex
|
||||||
pInfo->isNull = false;
|
pInfo->isNull = false;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pInputCol->info.type)) {
|
if (IS_VAR_DATA_TYPE(pInputCol->info.type)) {
|
||||||
pInfo->bytes = varDataTLen(pData);
|
if (pInputCol->info.type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pInfo->bytes = getJsonValueLen(pData);
|
||||||
|
} else {
|
||||||
|
pInfo->bytes = varDataTLen(pData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
|
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
|
||||||
|
@ -2994,7 +3006,11 @@ static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex
|
||||||
if (pCtx->hasPrimaryKey && !colDataIsNull_s(pkCol, rowIndex)) {
|
if (pCtx->hasPrimaryKey && !colDataIsNull_s(pkCol, rowIndex)) {
|
||||||
char* pkData = colDataGetData(pkCol, rowIndex);
|
char* pkData = colDataGetData(pkCol, rowIndex);
|
||||||
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
|
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
|
||||||
pInfo->pkBytes = varDataTLen(pkData);
|
if (pInfo->pkType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pInfo->pkBytes = getJsonValueLen(pkData);
|
||||||
|
} else {
|
||||||
|
pInfo->pkBytes = varDataTLen(pkData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
|
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
|
||||||
pInfo->pkData = pInfo->buf + pInfo->bytes;
|
pInfo->pkData = pInfo->buf + pInfo->bytes;
|
||||||
|
@ -5872,7 +5888,11 @@ void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
||||||
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
|
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
|
||||||
(void)memcpy(pInfo->buf, data, varDataTLen(data));
|
if (pInfo->colType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
(void)memcpy(pInfo->buf, data, getJsonValueLen(data));
|
||||||
|
} else {
|
||||||
|
(void)memcpy(pInfo->buf, data, varDataTLen(data));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(void)memcpy(pInfo->buf, data, pInfo->colBytes);
|
(void)memcpy(pInfo->buf, data, pInfo->colBytes);
|
||||||
}
|
}
|
||||||
|
@ -5882,7 +5902,16 @@ static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pI
|
||||||
|
|
||||||
static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) {
|
static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
|
int32_t hashKeyBytes;
|
||||||
|
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
|
||||||
|
if (pInfo->colType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
hashKeyBytes = getJsonValueLen(data);
|
||||||
|
} else {
|
||||||
|
hashKeyBytes = varDataTLen(data);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hashKeyBytes = pInfo->colBytes;
|
||||||
|
}
|
||||||
|
|
||||||
SModeItem* pHashItem = (SModeItem *)taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
SModeItem* pHashItem = (SModeItem *)taosHashGet(pInfo->pHash, data, hashKeyBytes);
|
||||||
if (pHashItem == NULL) {
|
if (pHashItem == NULL) {
|
||||||
|
@ -6654,14 +6683,32 @@ static void doSaveRateInfo(SRateInfo* pRateInfo, bool isFirst, int64_t ts, char*
|
||||||
pRateInfo->firstValue = v;
|
pRateInfo->firstValue = v;
|
||||||
pRateInfo->firstKey = ts;
|
pRateInfo->firstKey = ts;
|
||||||
if (pRateInfo->firstPk) {
|
if (pRateInfo->firstPk) {
|
||||||
int32_t pkBytes = IS_VAR_DATA_TYPE(pRateInfo->pkType) ? varDataTLen(pk) : pRateInfo->pkBytes;
|
int32_t pkBytes;
|
||||||
|
if (IS_VAR_DATA_TYPE(pRateInfo->pkType)) {
|
||||||
|
if (pRateInfo->pkType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pkBytes = getJsonValueLen(pk);
|
||||||
|
} else {
|
||||||
|
pkBytes = varDataTLen(pk);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pkBytes = pRateInfo->pkBytes;
|
||||||
|
}
|
||||||
(void)memcpy(pRateInfo->firstPk, pk, pkBytes);
|
(void)memcpy(pRateInfo->firstPk, pk, pkBytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pRateInfo->lastValue = v;
|
pRateInfo->lastValue = v;
|
||||||
pRateInfo->lastKey = ts;
|
pRateInfo->lastKey = ts;
|
||||||
if (pRateInfo->lastPk) {
|
if (pRateInfo->lastPk) {
|
||||||
int32_t pkBytes = IS_VAR_DATA_TYPE(pRateInfo->pkType) ? varDataTLen(pk) : pRateInfo->pkBytes;
|
int32_t pkBytes;
|
||||||
|
if (IS_VAR_DATA_TYPE(pRateInfo->pkType)) {
|
||||||
|
if (pRateInfo->pkType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
pkBytes = getJsonValueLen(pk);
|
||||||
|
} else {
|
||||||
|
pkBytes = varDataTLen(pk);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pkBytes = pRateInfo->pkBytes;
|
||||||
|
}
|
||||||
(void)memcpy(pRateInfo->lastPk, pk, pkBytes);
|
(void)memcpy(pRateInfo->lastPk, pk, pkBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,11 @@ void taos_monitor_split_str_metric(char** arr, taos_metric_t* metric, const char
|
||||||
memset(name, 0, size + 1);
|
memset(name, 0, size + 1);
|
||||||
memcpy(name, metric->name, size);
|
memcpy(name, metric->name, size);
|
||||||
|
|
||||||
char* s = strtok(name, del);
|
char* saveptr;
|
||||||
|
char* s = strtok_r(name, del, &saveptr);
|
||||||
while (s != NULL) {
|
while (s != NULL) {
|
||||||
*arr++ = s;
|
*arr++ = s;
|
||||||
s = strtok(NULL, del);
|
s = strtok_r(NULL, del, &saveptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = name;
|
*buf = name;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue