other:merge 3.0

This commit is contained in:
Haojun Liao 2022-09-30 13:47:21 +08:00
commit f8a84a1d19
159 changed files with 5228 additions and 4246 deletions

View File

@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER) IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER}) SET(TD_VER_NUMBER ${VERNUMBER})
ELSE () ELSE ()
SET(TD_VER_NUMBER "3.0.1.3") SET(TD_VER_NUMBER "3.0.1.4")
ENDIF () ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)

View File

@ -64,10 +64,10 @@ taos> use test;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | meters.current |
meters.voltage | 2022-03-30 17:04:10.882 | 2 | 2 | 2 | meters.voltage |
Query OK, 2 row(s) in set (0.002544s) Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`; taos> select tbname, * from `meters.current`;

View File

@ -81,10 +81,10 @@ taos> use test;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | meters.current |
meters.voltage | 2022-03-29 16:05:25.200 | 2 | 2 | 1 | meters.voltage |
Query OK, 2 row(s) in set (0.001954s) Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`; taos> select * from `meters.current`;

View File

@ -181,6 +181,14 @@ In TDengine, the first column of all tables must be a timestamp. This column is
select _rowts, max(current) from meters; select _rowts, max(current) from meters;
``` ```
**\_IROWTS**
The \_IROWTS pseudocolumn can only be used with INTERP function. This pseudocolumn can be used to retrieve the corresponding timestamp column associated with the interpolation results.
```sql
select _irowts, interp(current) from meters range('2020-01-01 10:00:00', '2020-01-01 10:30:00') every(1s) fill(linear);
```
## Query Objects ## Query Objects
`FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query. `FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query.

View File

@ -343,6 +343,7 @@ The following list shows all reserved keywords:
### \_ ### \_
- \_C0 - \_C0
- \_IROWTS
- \_QDURATION - \_QDURATION
- \_QEND - \_QEND
- \_QSTART - \_QSTART

View File

@ -11,12 +11,13 @@ description: "This document explains how TDengine SQL has changed in version 3.0
| 1 | VARCHAR | Added | Alias of BINARY. | 1 | VARCHAR | Added | Alias of BINARY.
| 2 | TIMESTAMP literal | Added | TIMESTAMP 'timestamp format' syntax now supported. | 2 | TIMESTAMP literal | Added | TIMESTAMP 'timestamp format' syntax now supported.
| 3 | _ROWTS pseudocolumn | Added | Indicates the primary key. Alias of _C0. | 3 | _ROWTS pseudocolumn | Added | Indicates the primary key. Alias of _C0.
| 4 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions | 4 | _IROWTS pseudocolumn | Added | Used to retrieve timestamps with INTERP function.
| 5 | PERFORMANCE_SCHEMA | Added | Database for system performance information. | 5 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions
| 6 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated. | 6 | PERFORMANCE_SCHEMA | Added | Database for system performance information.
| 7 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses. | 7 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated.
| 8 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns. | 8 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses.
| 9 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline. | 9 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns.
| 10 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline.
## SQL Syntax ## SQL Syntax

View File

@ -109,7 +109,7 @@ TDengine's JDBC URL specification format is:
For establishing connections, native connections differ slightly from REST connections. For establishing connections, native connections differ slightly from REST connections.
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
```java ```java

View File

@ -113,7 +113,7 @@ username:password@protocol(address)/dbname?param=value
``` ```
### Connecting via connector ### Connecting via connector
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
_taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver. _taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver.

View File

@ -55,16 +55,6 @@ taos = "*"
</TabItem> </TabItem>
<TabItem value="native" label="native connection only">
In `cargo.toml`, add [taos][taos] and enable the native feature:
```toml
[dependencies]
taos = { version = "*", default-features = false, features = ["native"] }
```
</TabItem>
<TabItem value="rest" label="Websocket only"> <TabItem value="rest" label="Websocket only">
In `cargo.toml`, add [taos][taos] and enable the ws feature: In `cargo.toml`, add [taos][taos] and enable the ws feature:
@ -75,6 +65,18 @@ taos = { version = "*", default-features = false, features = ["ws"] }
``` ```
</TabItem> </TabItem>
<TabItem value="native" label="native connection only">
In `cargo.toml`, add [taos][taos] and enable the native feature:
```toml
[dependencies]
taos = { version = "*", default-features = false, features = ["native"] }
```
</TabItem>
</Tabs> </Tabs>
## Establishing a connection ## Establishing a connection

View File

@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git
### Verify ### Verify
<Tabs groupId="connect" default="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
For native connection, you need to verify that both the client driver and the Python connector itself are installed correctly. The client driver and Python connector have been installed properly if you can successfully import the `taos` module. In the Python Interactive Shell, you can type. For native connection, you need to verify that both the client driver and the Python connector itself are installed correctly. The client driver and Python connector have been installed properly if you can successfully import the `taos` module. In the Python Interactive Shell, you can type.
@ -118,7 +118,7 @@ Requirement already satisfied: taospy in c:\users\username\appdata\local\program
Before establishing a connection with the connector, we recommend testing the connectivity of the local TDengine CLI to the TDengine cluster. Before establishing a connection with the connector, we recommend testing the connectivity of the local TDengine CLI to the TDengine cluster.
<Tabs> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
Ensure that the TDengine instance is up and that the FQDN of the machines in the cluster (the FQDN defaults to hostname if you are starting a standalone version) can be resolved locally, by testing with the `ping` command. Ensure that the TDengine instance is up and that the FQDN of the machines in the cluster (the FQDN defaults to hostname if you are starting a standalone version) can be resolved locally, by testing with the `ping` command.
@ -173,7 +173,7 @@ If the test is successful, it will output the server version information, e.g.
The following example code assumes that TDengine is installed locally and that the default configuration is used for both FQDN and serverPort. The following example code assumes that TDengine is installed locally and that the default configuration is used for both FQDN and serverPort.
<Tabs> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection" groupId="connect"> <TabItem value="native" label="native connection" groupId="connect">
```python ```python
@ -219,7 +219,7 @@ All arguments to the `connect()` function are optional keyword arguments. The fo
### Basic Usage ### Basic Usage
<Tabs default="native" groupId="connect"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
##### TaosConnection class ##### TaosConnection class
@ -289,7 +289,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
### Used with pandas ### Used with pandas
<Tabs default="native" groupId="connect"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
```python ```python

View File

@ -85,7 +85,7 @@ If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and
### Install via npm ### Install via npm
<Tabs defaultValue="install_native"> <Tabs defaultValue="install_rest">
<TabItem value="install_native" label="Install native connector"> <TabItem value="install_native" label="Install native connector">
```bash ```bash
@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost
Please choose to use one of the connectors. Please choose to use one of the connectors.
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="native connection"> <TabItem value="native" label="native connection">
Install and import the `@tdengine/client` package. Install and import the `@tdengine/client` package.

View File

@ -97,7 +97,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj
## Establish a Connection ## Establish a Connection
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="Native Connection"> <TabItem value="native" label="Native Connection">
@ -173,7 +173,7 @@ ws://localhost:6041/test
#### SQL Write #### SQL Write
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="Native Connection"> <TabItem value="native" label="Native Connection">
@ -204,7 +204,7 @@ ws://localhost:6041/test
#### Parameter Binding #### Parameter Binding
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="Native Connection"> <TabItem value="native" label="Native Connection">
@ -227,7 +227,7 @@ ws://localhost:6041/test
#### Synchronous Query #### Synchronous Query
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="Native Connection"> <TabItem value="native" label="Native Connection">

View File

@ -4,11 +4,11 @@ Execute TDengine CLI program `taos` directly from the Linux shell to connect to
$ taos $ taos
taos> show databases; taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | name |
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= =================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | information_schema |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | performance_schema |
db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 | db |
Query OK, 3 rows in database (0.019154s) Query OK, 3 rows in database (0.019154s)
taos> taos>

View File

@ -2,12 +2,11 @@ Go to the `C:\TDengine` directory from `cmd` and execute TDengine CLI program `t
```text ```text
taos> show databases; taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | name |
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= =================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | information_schema |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | performance_schema |
test | 2022-08-04 16:46:40.506 | 2 | 0 | 1 | off | 14400m | 5256000m,5256000m,5256000m | 96 | 4 | 256 | test |
100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 |
Query OK, 3 rows in database (0.123000s) Query OK, 3 rows in database (0.123000s)
taos> taos>

View File

@ -25,10 +25,11 @@ The TDengine client taos can be executed in this container to access TDengine us
$ docker exec -it tdengine taos $ docker exec -it tdengine taos
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready | information_schema |
Query OK, 1 row(s) in set (0.002843s) performance_schema |
Query OK, 2 row(s) in set (0.002843s)
``` ```
The TDengine server running in the container uses the container's hostname to establish a connection. Using TDengine CLI or various connectors (such as JDBC-JNI) to access the TDengine inside the container from outside the container is more complicated. So the above is the simplest way to access the TDengine service in the container and is suitable for some simple scenarios. Please refer to the next section if you want to access the TDengine service in the container from outside the container using TDengine CLI or various connectors for complex scenarios. The TDengine server running in the container uses the container's hostname to establish a connection. Using TDengine CLI or various connectors (such as JDBC-JNI) to access the TDengine inside the container from outside the container is more complicated. So the above is the simplest way to access the TDengine service in the container and is suitable for some simple scenarios. Please refer to the next section if you want to access the TDengine service in the container from outside the container using TDengine CLI or various connectors for complex scenarios.

View File

@ -51,5 +51,6 @@ port: 8125
Start StatsD after adding the following (assuming the config file is modified to config.js) Start StatsD after adding the following (assuming the config file is modified to config.js)
``` ```
npm install
node stats.js config.js & node stats.js config.js &
``` ```

View File

@ -22,5 +22,4 @@ An example is as follows.
username = "root" username = "root"
password = "taosdata" password = "taosdata"
data_format = "influx" data_format = "influx"
influx_max_line_bytes = 250
``` ```

View File

@ -30,21 +30,20 @@ After restarting Prometheus, you can refer to the following example to verify th
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
test | 2022-04-12 08:07:58.756 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 2 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
prometheus_data | 2022-04-20 07:21:09.202 | 158 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | prometheus_data |
db | 2022-04-15 06:37:08.512 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | Query OK, 3 row(s) in set (0.000585s)
Query OK, 4 row(s) in set (0.000585s)
taos> use prometheus_data; taos> use prometheus_data;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
metrics | 2022-04-20 07:21:09.209 | 2 | 1 | 1389 | metrics |
Query OK, 1 row(s) in set (0.000487s) Query OK, 1 row(s) in set (0.000487s)
taos> select * from metrics limit 10; taos> select * from metrics limit 10;
@ -89,3 +88,7 @@ VALUE TIMESTAMP
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -15,6 +15,7 @@ To write Telegraf data to TDengine requires the following preparations.
- The TDengine cluster is deployed and functioning properly - The TDengine cluster is deployed and functioning properly
- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details. - taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details.
- Telegraf has been installed. Please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.22/install/) for Telegraf installation. - Telegraf has been installed. Please refer to the [official documentation](https://docs.influxdata.com/telegraf/v1.22/install/) for Telegraf installation.
- Telegraf collects the running status measurements of current system. You can enable [input plugins](https://docs.influxdata.com/telegraf/v1.22/plugins/) to insert [other formats](https://docs.influxdata.com/telegraf/v1.24/data_formats/input/) data to Telegraf then forward to TDengine.
## Configuration steps ## Configuration steps
<Telegraf /> <Telegraf />
@ -31,26 +32,27 @@ Use TDengine CLI to verify Telegraf correctly writing data to TDengine and read
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.002401s) telegraf |
Query OK, 3 rows in database (0.010568s)
taos> use telegraf; taos> use telegraf;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | swap |
cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | cpu |
system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | system |
diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | diskio |
kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | kernel |
mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | mem |
processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | processes |
disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | disk |
Query OK, 8 row(s) in set (0.000521s) Query OK, 8 row(s) in set (0.000521s)
taos> select * from telegraf.system limit 10; taos> select * from telegraf.system limit 10;
@ -65,3 +67,11 @@ taos> select * from telegraf.system limit 10;
| |
Query OK, 3 row(s) in set (0.013269s) Query OK, 3 row(s) in set (0.013269s)
``` ```
:::note
- TDengine take influxdb format data and create unique ID for table names by the rule.
The user can configure `smlChildTableName` parameter to generate specified table names if he/she needs. And he/she also need to insert data with specified data format.
For example, Add `smlChildTableName=tname` in the taos.cfg file. Insert data `st,tname=cpu1,t1=4 c1=3 1626006833639000000` then the table name will be cpu1. If there are multiple lines has same tname but different tag_set, the first line's tag_set will be used to automatically creating table and ignore other lines. Please refer to [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol)
:::

View File

@ -32,28 +32,29 @@ Use the TDengine CLI to verify that collectd's data is written to TDengine and c
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
collectd | 2022-04-20 09:27:45.460 | 95 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.003266s) collectd |
Query OK, 3 row(s) in set (0.003266s)
taos> use collectd; taos> use collectd;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
load_1 | 2022-04-20 09:27:45.492 | 2 | 2 | 1 | load_1 |
memory_value | 2022-04-20 09:27:45.463 | 2 | 3 | 6 | memory_value |
df_value | 2022-04-20 09:27:45.463 | 2 | 4 | 25 | df_value |
load_2 | 2022-04-20 09:27:45.501 | 2 | 2 | 1 | load_2 |
load_0 | 2022-04-20 09:27:45.485 | 2 | 2 | 1 | load_0 |
interface_1 | 2022-04-20 09:27:45.488 | 2 | 3 | 12 | interface_1 |
irq_value | 2022-04-20 09:27:45.476 | 2 | 3 | 31 | irq_value |
interface_0 | 2022-04-20 09:27:45.480 | 2 | 3 | 12 | interface_0 |
entropy_value | 2022-04-20 09:27:45.473 | 2 | 2 | 1 | entropy_value |
swap_value | 2022-04-20 09:27:45.477 | 2 | 3 | 5 | swap_value |
Query OK, 10 row(s) in set (0.002236s) Query OK, 10 row(s) in set (0.002236s)
taos> select * from collectd.memory_value limit 10; taos> select * from collectd.memory_value limit 10;
@ -72,3 +73,7 @@ taos> select * from collectd.memory_value limit 10;
Query OK, 10 row(s) in set (0.010348s) Query OK, 10 row(s) in set (0.010348s)
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -26,7 +26,7 @@ Start StatsD:
``` ```
$ node stats.js config.js & $ node stats.js config.js &
[1] 8546 [1] 8546
$ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js $ 20 Apr 09:54:41 - [8546] reading config file: config.js
20 Apr 09:54:41 - server is up INFO 20 Apr 09:54:41 - server is up INFO
``` ```
@ -40,19 +40,20 @@ Use the TDengine CLI to verify that StatsD data is written to TDengine and can r
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
statsd | 2022-04-20 09:54:51.220 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | performance_schema |
Query OK, 2 row(s) in set (0.003142s) statsd |
Query OK, 3 row(s) in set (0.003142s)
taos> use statsd; taos> use statsd;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
foo | 2022-04-20 09:54:51.234 | 2 | 1 | 1 | foo |
Query OK, 1 row(s) in set (0.002161s) Query OK, 1 row(s) in set (0.002161s)
taos> select * from foo; taos> select * from foo;
@ -63,3 +64,8 @@ Query OK, 1 row(s) in set (0.004179s)
taos> taos>
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -36,39 +36,45 @@ After waiting about 10 seconds, use the TDengine CLI to query TDengine to verify
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
icinga2 | 2022-04-20 12:11:39.697 | 13 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | performance_schema |
Query OK, 2 row(s) in set (0.001867s) icinga2 |
Query OK, 3 row(s) in set (0.001867s)
taos> use icinga2; taos> use icinga2;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
icinga.service.users.state_... | 2022-04-20 12:11:39.726 | 2 | 1 | 1 | icinga.service.users.state_... |
icinga.service.users.acknow... | 2022-04-20 12:11:39.756 | 2 | 1 | 1 | icinga.service.users.acknow... |
icinga.service.procs.downti... | 2022-04-20 12:11:44.541 | 2 | 1 | 1 | icinga.service.procs.downti... |
icinga.service.users.users | 2022-04-20 12:11:39.770 | 2 | 1 | 1 | icinga.service.users.users |
icinga.service.procs.procs_min | 2022-04-20 12:11:44.599 | 2 | 1 | 1 | icinga.service.procs.procs_min |
icinga.service.users.users_min | 2022-04-20 12:11:39.809 | 2 | 1 | 1 | icinga.service.users.users_min |
icinga.check.max_check_atte... | 2022-04-20 12:11:39.847 | 2 | 3 | 2 | icinga.check.max_check_atte... |
icinga.service.procs.state_... | 2022-04-20 12:11:44.522 | 2 | 1 | 1 | icinga.service.procs.state_... |
icinga.service.procs.procs_... | 2022-04-20 12:11:44.576 | 2 | 1 | 1 | icinga.service.procs.procs_... |
icinga.service.users.users_... | 2022-04-20 12:11:39.796 | 2 | 1 | 1 | icinga.service.users.users_... |
icinga.check.latency | 2022-04-20 12:11:39.869 | 2 | 3 | 2 | icinga.check.latency |
icinga.service.procs.procs_... | 2022-04-20 12:11:44.588 | 2 | 1 | 1 | icinga.service.procs.procs_... |
icinga.service.users.downti... | 2022-04-20 12:11:39.746 | 2 | 1 | 1 | icinga.service.users.downti... |
icinga.service.users.users_... | 2022-04-20 12:11:39.783 | 2 | 1 | 1 | icinga.service.users.users_... |
icinga.service.users.reachable | 2022-04-20 12:11:39.736 | 2 | 1 | 1 | icinga.service.users.reachable |
icinga.service.procs.procs | 2022-04-20 12:11:44.565 | 2 | 1 | 1 | icinga.service.procs.procs |
icinga.service.procs.acknow... | 2022-04-20 12:11:44.554 | 2 | 1 | 1 | icinga.service.procs.acknow... |
icinga.service.procs.state | 2022-04-20 12:11:44.509 | 2 | 1 | 1 | icinga.service.procs.state |
icinga.service.procs.reachable | 2022-04-20 12:11:44.532 | 2 | 1 | 1 | icinga.service.procs.reachable |
icinga.check.current_attempt | 2022-04-20 12:11:39.825 | 2 | 3 | 2 | icinga.check.current_attempt |
icinga.check.execution_time | 2022-04-20 12:11:39.898 | 2 | 3 | 2 | icinga.check.execution_time |
icinga.service.users.state | 2022-04-20 12:11:39.704 | 2 | 1 | 1 | icinga.service.users.state |
Query OK, 22 row(s) in set (0.002317s) Query OK, 22 row(s) in set (0.002317s)
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -33,35 +33,41 @@ Wait for a few seconds and then use the TDengine CLI to query whether the corres
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
tcollector | 2022-04-20 12:44:49.604 | 88 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.002679s) tcollector |
Query OK, 3 rows in database (0.001647s)
taos> use tcollector; taos> use tcollector;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
proc.meminfo.hugepages_rsvd | 2022-04-20 12:44:53.945 | 2 | 1 | 1 | proc.meminfo.hugepages_rsvd |
proc.meminfo.directmap1g | 2022-04-20 12:44:54.110 | 2 | 1 | 1 | proc.meminfo.directmap1g |
proc.meminfo.vmallocchunk | 2022-04-20 12:44:53.724 | 2 | 1 | 1 | proc.meminfo.vmallocchunk |
proc.meminfo.hugepagesize | 2022-04-20 12:44:54.004 | 2 | 1 | 1 | proc.meminfo.hugepagesize |
tcollector.reader.lines_dro... | 2022-04-20 12:44:49.675 | 2 | 1 | 1 | tcollector.reader.lines_dro... |
proc.meminfo.sunreclaim | 2022-04-20 12:44:53.437 | 2 | 1 | 1 | proc.meminfo.sunreclaim |
proc.stat.ctxt | 2022-04-20 12:44:55.363 | 2 | 1 | 1 | proc.stat.ctxt |
proc.meminfo.swaptotal | 2022-04-20 12:44:53.158 | 2 | 1 | 1 | proc.meminfo.swaptotal |
proc.uptime.total | 2022-04-20 12:44:52.813 | 2 | 1 | 1 | proc.uptime.total |
tcollector.collector.lines_... | 2022-04-20 12:44:49.895 | 2 | 2 | 51 | tcollector.collector.lines_... |
proc.meminfo.vmallocused | 2022-04-20 12:44:53.704 | 2 | 1 | 1 | proc.meminfo.vmallocused |
proc.meminfo.memavailable | 2022-04-20 12:44:52.939 | 2 | 1 | 1 | proc.meminfo.memavailable |
sys.numa.foreign_allocs | 2022-04-20 12:44:57.929 | 2 | 2 | 1 | sys.numa.foreign_allocs |
proc.meminfo.committed_as | 2022-04-20 12:44:53.639 | 2 | 1 | 1 | proc.meminfo.committed_as |
proc.vmstat.pswpin | 2022-04-20 12:44:54.177 | 2 | 1 | 1 | proc.vmstat.pswpin |
proc.meminfo.cmafree | 2022-04-20 12:44:53.865 | 2 | 1 | 1 | proc.meminfo.cmafree |
proc.meminfo.mapped | 2022-04-20 12:44:53.349 | 2 | 1 | 1 | proc.meminfo.mapped |
proc.vmstat.pgmajfault | 2022-04-20 12:44:54.251 | 2 | 1 | 1 | proc.vmstat.pgmajfault |
... ...
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -60,7 +60,6 @@ For the configuration method, add the following text to `/etc/telegraf/telegraf.
username = "<TDengine's username>" username = "<TDengine's username>"
password = "<TDengine's password>" password = "<TDengine's password>"
data_format = "influx" data_format = "influx"
influx_max_line_bytes = 250
``` ```
Then restart telegraf: Then restart telegraf:

View File

@ -6,6 +6,10 @@ description: TDengine release history, Release Notes and download links.
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 3.0.1.4
<Release type="tdengine" version="3.0.1.4" />
## 3.0.1.3 ## 3.0.1.3
<Release type="tdengine" version="3.0.1.3" /> <Release type="tdengine" version="3.0.1.3" />

View File

@ -6,6 +6,10 @@ description: taosTools release history, Release Notes, download links.
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 2.2.4
<Release type="tools" version="2.2.4" />
## 2.2.3 ## 2.2.3
<Release type="tools" version="2.2.3" /> <Release type="tools" version="2.2.3" />

View File

@ -66,10 +66,10 @@ taos> use test;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | meters.current |
meters.voltage | 2022-03-30 17:04:10.882 | 2 | 2 | 2 | meters.voltage |
Query OK, 2 row(s) in set (0.002544s) Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`; taos> select tbname, * from `meters.current`;

View File

@ -82,10 +82,10 @@ taos> use test;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | meters.current |
meters.voltage | 2022-03-29 16:05:25.200 | 2 | 2 | 1 | meters.voltage |
Query OK, 2 row(s) in set (0.001954s) Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`; taos> select * from `meters.current`;

View File

@ -109,7 +109,7 @@ TDengine 的 JDBC URL 规范格式为:
对于建立连接,原生连接与 REST 连接有细微不同。 对于建立连接,原生连接与 REST 连接有细微不同。
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
```java ```java

View File

@ -114,7 +114,7 @@ username:password@protocol(address)/dbname?param=value
``` ```
### 使用连接器进行连接 ### 使用连接器进行连接
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
_taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。 _taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。

View File

@ -55,16 +55,6 @@ taos = "*"
</TabItem> </TabItem>
<TabItem value="native" label="仅原生连接">
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性:
```toml
[dependencies]
taos = { version = "*", default-features = false, features = ["native"] }
```
</TabItem>
<TabItem value="rest" label="仅 Websocket"> <TabItem value="rest" label="仅 Websocket">
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `ws` 特性。 在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `ws` 特性。
@ -74,6 +64,17 @@ taos = { version = "*", default-features = false, features = ["native"] }
taos = { version = "*", default-features = false, features = ["ws"] } taos = { version = "*", default-features = false, features = ["ws"] }
``` ```
</TabItem>
<TabItem value="native" label="仅原生连接">
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性:
```toml
[dependencies]
taos = { version = "*", default-features = false, features = ["native"] }
```
</TabItem> </TabItem>
</Tabs> </Tabs>

View File

@ -80,7 +80,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git
### 安装验证 ### 安装验证
<Tabs groupId="connect" default="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入: 对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入:
@ -118,7 +118,7 @@ Requirement already satisfied: taospy in c:\users\username\appdata\local\program
在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。 在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。
<Tabs> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
请确保 TDengine 集群已经启动, 且集群中机器的 FQDN 如果启动的是单机版FQDN 默认为 hostname在本机能够解析, 可用 `ping` 命令进行测试: 请确保 TDengine 集群已经启动, 且集群中机器的 FQDN 如果启动的是单机版FQDN 默认为 hostname在本机能够解析, 可用 `ping` 命令进行测试:
@ -173,7 +173,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。 以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。
<Tabs> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接" groupId="connect"> <TabItem value="native" label="原生连接" groupId="connect">
```python ```python
@ -219,7 +219,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
### 基本使用 ### 基本使用
<Tabs default="native" groupId="connect"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
##### TaosConnection 类的使用 ##### TaosConnection 类的使用
@ -289,7 +289,7 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线
### 与 pandas 一起使用 ### 与 pandas 一起使用
<Tabs default="native" groupId="connect"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
```python ```python

View File

@ -85,7 +85,7 @@ REST 连接器支持所有能运行 Node.js 的平台。
### 使用 npm 安装 ### 使用 npm 安装
<Tabs defaultValue="install_native"> <Tabs defaultValue="install_rest">
<TabItem value="install_native" label="安装原生连接器"> <TabItem value="install_native" label="安装原生连接器">
```bash ```bash
@ -124,7 +124,7 @@ node nodejsChecker.js host=localhost
请选择使用一种连接器。 请选择使用一种连接器。
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
安装并引用 `@tdengine/client` 包。 安装并引用 `@tdengine/client` 包。

View File

@ -35,7 +35,7 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx"
## 支持的功能特性 ## 支持的功能特性
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
@ -96,7 +96,7 @@ dotnet add exmaple.csproj reference src/TDengine.csproj
## 建立连接 ## 建立连接
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
@ -171,7 +171,7 @@ namespace TDengineExample
#### SQL 写入 #### SQL 写入
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
@ -203,7 +203,7 @@ namespace TDengineExample
#### 参数绑定 #### 参数绑定
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">
@ -227,7 +227,7 @@ namespace TDengineExample
#### 同步查询 #### 同步查询
<Tabs defaultValue="native"> <Tabs defaultValue="rest">
<TabItem value="native" label="原生连接"> <TabItem value="native" label="原生连接">

View File

@ -4,11 +4,11 @@
$ taos $ taos
taos> show databases; taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size | name |
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================= =================================
information_schema | NULL | NULL | 14 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | information_schema |
performance_schema | NULL | NULL | 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | ready | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | performance_schema |
db | 2022-08-04 14:14:49.385 | 2 | 4 | 1 | off | 14400m | 5254560m,5254560m,5254560m | 96 | 4 | 256 | 100 | 4096 | 2 | ms | ready | NULL | false | none | 1 | 1 | 3000 | 0 | 0 | 0 | 0 | db |
Query OK, 3 rows in database (0.019154s) Query OK, 3 rows in database (0.019154s)
taos> taos>

View File

@ -182,6 +182,14 @@ TDengine 中,所有表的第一列都必须是时间戳类型,且为其主
select _rowts, max(current) from meters; select _rowts, max(current) from meters;
``` ```
**\_IROWTS**
\_irowts 伪列只能与 interp 函数一起使用,用于返回 interp 函数插值结果对应的时间戳列。
```sql
select _irowts, interp(current) from meters range('2020-01-01 10:00:00', '2020-01-01 10:30:00') every(1s) fill(linear);
```
## 查询对象 ## 查询对象
FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。 FROM 关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。

View File

@ -344,6 +344,7 @@ description: TDengine 保留关键字的详细列表
### \_ ### \_
- \_C0 - \_C0
- \_IROWTS
- \_QDURATION - \_QDURATION
- \_QEND - \_QEND
- \_QSTART - \_QSTART

View File

@ -11,12 +11,13 @@ description: "TDengine 3.0 版本的语法变更说明"
| 1 | VARCHAR | 新增 | BINARY类型的别名。 | 1 | VARCHAR | 新增 | BINARY类型的别名。
| 2 | TIMESTAMP字面量 | 新增 | 新增支持 TIMESTAMP 'timestamp format' 语法。 | 2 | TIMESTAMP字面量 | 新增 | 新增支持 TIMESTAMP 'timestamp format' 语法。
| 3 | _ROWTS伪列 | 新增 | 表示时间戳主键。是_C0伪列的别名。 | 3 | _ROWTS伪列 | 新增 | 表示时间戳主键。是_C0伪列的别名。
| 4 | INFORMATION_SCHEMA | 新增 | 包含各种SCHEMA定义的系统数据库。 | 4 | _IROWTS伪列 | 新增 | 用于返回 interp 函数插值结果对应的时间戳列。
| 5 | PERFORMANCE_SCHEMA | 新增 | 包含运行信息的系统数据库。 | 5 | INFORMATION_SCHEMA | 新增 | 包含各种SCHEMA定义的系统数据库。
| 6 | 连续查询 | 废除 | 不再支持连续查询。相关的各种语法和接口废除。 | 6 | PERFORMANCE_SCHEMA | 新增 | 包含运行信息的系统数据库。
| 7 | 混合运算 | 增强 | 查询中的混合运算标量运算和矢量运算混合全面增强SELECT的各个子句均全面支持符合语法语义的混合运算。 | 7 | 连续查询 | 废除 | 不再支持连续查询。相关的各种语法和接口废除。
| 8 | 标签运算 | 新增 |在查询中,标签列可以像普通列一样参与各种运算,用于各种子句。 | 8 | 混合运算 | 增强 | 查询中的混合运算标量运算和矢量运算混合全面增强SELECT的各个子句均全面支持符合语法语义的混合运算。
| 9 | 时间线子句和时间函数用于超级表查询 | 增强 |没有PARTITION BY时超级表的数据会被合并成一条时间线。 | 9 | 标签运算 | 新增 |在查询中,标签列可以像普通列一样参与各种运算,用于各种子句。
| 10 | 时间线子句和时间函数用于超级表查询 | 增强 |没有PARTITION BY时超级表的数据会被合并成一条时间线。
## SQL 语句变更 ## SQL 语句变更

View File

@ -51,5 +51,6 @@ port: 8125
增加如下内容后启动 StatsD假设配置文件修改为 config.js 增加如下内容后启动 StatsD假设配置文件修改为 config.js
``` ```
npm install
node stats.js config.js & node stats.js config.js &
``` ```

View File

@ -22,6 +22,5 @@
username = "root" username = "root"
password = "taosdata" password = "taosdata"
data_format = "influx" data_format = "influx"
influx_max_line_bytes = 250
``` ```

View File

@ -29,21 +29,20 @@ Prometheus 提供了 `remote_write` 和 `remote_read` 接口来利用其它数
### 使用 TDengine CLI 查询写入数据 ### 使用 TDengine CLI 查询写入数据
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
test | 2022-04-12 08:07:58.756 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 2 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
prometheus_data | 2022-04-20 07:21:09.202 | 158 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | prometheus_data |
db | 2022-04-15 06:37:08.512 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | Query OK, 3 row(s) in set (0.000585s)
Query OK, 4 row(s) in set (0.000585s)
taos> use prometheus_data; taos> use prometheus_data;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
metrics | 2022-04-20 07:21:09.209 | 2 | 1 | 1389 | metrics |
Query OK, 1 row(s) in set (0.000487s) Query OK, 1 row(s) in set (0.000487s)
taos> select * from metrics limit 10; taos> select * from metrics limit 10;
@ -88,3 +87,7 @@ VALUE TIMESTAMP
``` ```
:::note
- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。
:::

View File

@ -16,6 +16,7 @@ Telegraf 是一款十分流行的指标采集开源软件。在数据采集和
- TDengine 集群已经部署并正常运行 - TDengine 集群已经部署并正常运行
- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) - taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter)
- Telegraf 已经安装。安装 Telegraf 请参考[官方文档](https://docs.influxdata.com/telegraf/v1.22/install/) - Telegraf 已经安装。安装 Telegraf 请参考[官方文档](https://docs.influxdata.com/telegraf/v1.22/install/)
- Telegraf 默认采集系统运行状态数据。通过使能[输入插件](https://docs.influxdata.com/telegraf/v1.22/plugins/)方式可以输出[其他格式](https://docs.influxdata.com/telegraf/v1.24/data_formats/input/)的数据到 Telegraf 再写入到 TDengine中。
## 配置步骤 ## 配置步骤
<Telegraf /> <Telegraf />
@ -32,26 +33,27 @@ sudo systemctl restart telegraf
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.002401s) telegraf |
Query OK, 3 rows in database (0.010568s)
taos> use telegraf; taos> use telegraf;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | swap |
cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | cpu |
system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | system |
diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | diskio |
kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | kernel |
mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | mem |
processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | processes |
disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | disk |
Query OK, 8 row(s) in set (0.000521s) Query OK, 8 row(s) in set (0.000521s)
taos> select * from telegraf.system limit 10; taos> select * from telegraf.system limit 10;
@ -66,3 +68,11 @@ taos> select * from telegraf.system limit 10;
| |
Query OK, 3 row(s) in set (0.013269s) Query OK, 3 row(s) in set (0.013269s)
``` ```
:::note
- TDengine 接收 influxdb 格式数据默认生成的子表名是根据规则生成的唯一 ID 值。
用户如需指定生成的表名,可以通过在 taos.cfg 里配置 smlChildTableName 参数来指定。如果通过控制输入数据格式,即可利用 TDengine 这个功能指定生成的表名。
举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1。如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set其他的行会忽略。[TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议)
:::

View File

@ -32,28 +32,29 @@ sudo systemctl restart collectd
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
collectd | 2022-04-20 09:27:45.460 | 95 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.003266s) collectd |
Query OK, 3 row(s) in set (0.003266s)
taos> use collectd; taos> use collectd;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
load_1 | 2022-04-20 09:27:45.492 | 2 | 2 | 1 | load_1 |
memory_value | 2022-04-20 09:27:45.463 | 2 | 3 | 6 | memory_value |
df_value | 2022-04-20 09:27:45.463 | 2 | 4 | 25 | df_value |
load_2 | 2022-04-20 09:27:45.501 | 2 | 2 | 1 | load_2 |
load_0 | 2022-04-20 09:27:45.485 | 2 | 2 | 1 | load_0 |
interface_1 | 2022-04-20 09:27:45.488 | 2 | 3 | 12 | interface_1 |
irq_value | 2022-04-20 09:27:45.476 | 2 | 3 | 31 | irq_value |
interface_0 | 2022-04-20 09:27:45.480 | 2 | 3 | 12 | interface_0 |
entropy_value | 2022-04-20 09:27:45.473 | 2 | 2 | 1 | entropy_value |
swap_value | 2022-04-20 09:27:45.477 | 2 | 3 | 5 | swap_value |
Query OK, 10 row(s) in set (0.002236s) Query OK, 10 row(s) in set (0.002236s)
taos> select * from collectd.memory_value limit 10; taos> select * from collectd.memory_value limit 10;
@ -72,3 +73,7 @@ taos> select * from collectd.memory_value limit 10;
Query OK, 10 row(s) in set (0.010348s) Query OK, 10 row(s) in set (0.010348s)
``` ```
:::note
- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。
:::

View File

@ -27,7 +27,7 @@ StatsD 是汇总和总结应用指标的一个简单的守护进程,近些年
``` ```
$ node stats.js config.js & $ node stats.js config.js &
[1] 8546 [1] 8546
$ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js $ 20 Apr 09:54:41 - [8546] reading config file: config.js
20 Apr 09:54:41 - server is up INFO 20 Apr 09:54:41 - server is up INFO
``` ```
@ -41,19 +41,20 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
statsd | 2022-04-20 09:54:51.220 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | performance_schema |
Query OK, 2 row(s) in set (0.003142s) statsd |
Query OK, 3 row(s) in set (0.003142s)
taos> use statsd; taos> use statsd;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
foo | 2022-04-20 09:54:51.234 | 2 | 1 | 1 | foo |
Query OK, 1 row(s) in set (0.002161s) Query OK, 1 row(s) in set (0.002161s)
taos> select * from foo; taos> select * from foo;
@ -64,3 +65,8 @@ Query OK, 1 row(s) in set (0.004179s)
taos> taos>
``` ```
:::note
- TDengine will automatically create unique IDs for sub-table names by the rule.
:::

View File

@ -37,39 +37,46 @@ sudo systemctl restart icinga2
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | information_schema |
icinga2 | 2022-04-20 12:11:39.697 | 13 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | performance_schema |
Query OK, 2 row(s) in set (0.001867s) icinga2 |
Query OK, 3 row(s) in set (0.001867s)
taos> use icinga2; taos> use icinga2;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
icinga.service.users.state_... | 2022-04-20 12:11:39.726 | 2 | 1 | 1 | icinga.service.users.state_... |
icinga.service.users.acknow... | 2022-04-20 12:11:39.756 | 2 | 1 | 1 | icinga.service.users.acknow... |
icinga.service.procs.downti... | 2022-04-20 12:11:44.541 | 2 | 1 | 1 | icinga.service.procs.downti... |
icinga.service.users.users | 2022-04-20 12:11:39.770 | 2 | 1 | 1 | icinga.service.users.users |
icinga.service.procs.procs_min | 2022-04-20 12:11:44.599 | 2 | 1 | 1 | icinga.service.procs.procs_min |
icinga.service.users.users_min | 2022-04-20 12:11:39.809 | 2 | 1 | 1 | icinga.service.users.users_min |
icinga.check.max_check_atte... | 2022-04-20 12:11:39.847 | 2 | 3 | 2 | icinga.check.max_check_atte... |
icinga.service.procs.state_... | 2022-04-20 12:11:44.522 | 2 | 1 | 1 | icinga.service.procs.state_... |
icinga.service.procs.procs_... | 2022-04-20 12:11:44.576 | 2 | 1 | 1 | icinga.service.procs.procs_... |
icinga.service.users.users_... | 2022-04-20 12:11:39.796 | 2 | 1 | 1 | icinga.service.users.users_... |
icinga.check.latency | 2022-04-20 12:11:39.869 | 2 | 3 | 2 | icinga.check.latency |
icinga.service.procs.procs_... | 2022-04-20 12:11:44.588 | 2 | 1 | 1 | icinga.service.procs.procs_... |
icinga.service.users.downti... | 2022-04-20 12:11:39.746 | 2 | 1 | 1 | icinga.service.users.downti... |
icinga.service.users.users_... | 2022-04-20 12:11:39.783 | 2 | 1 | 1 | icinga.service.users.users_... |
icinga.service.users.reachable | 2022-04-20 12:11:39.736 | 2 | 1 | 1 | icinga.service.users.reachable |
icinga.service.procs.procs | 2022-04-20 12:11:44.565 | 2 | 1 | 1 | icinga.service.procs.procs |
icinga.service.procs.acknow... | 2022-04-20 12:11:44.554 | 2 | 1 | 1 | icinga.service.procs.acknow... |
icinga.service.procs.state | 2022-04-20 12:11:44.509 | 2 | 1 | 1 | icinga.service.procs.state |
icinga.service.procs.reachable | 2022-04-20 12:11:44.532 | 2 | 1 | 1 | icinga.service.procs.reachable |
icinga.check.current_attempt | 2022-04-20 12:11:39.825 | 2 | 3 | 2 | icinga.check.current_attempt |
icinga.check.execution_time | 2022-04-20 12:11:39.898 | 2 | 3 | 2 | icinga.check.execution_time |
icinga.service.users.state | 2022-04-20 12:11:39.704 | 2 | 1 | 1 | icinga.service.users.state |
Query OK, 22 row(s) in set (0.002317s) Query OK, 22 row(s) in set (0.002317s)
``` ```
:::note
- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。
:::

View File

@ -34,35 +34,42 @@ sudo systemctl restart taosadapter
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name |
==================================================================================================================================================================================================================================================================================== =================================
tcollector | 2022-04-20 12:44:49.604 | 88 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | information_schema |
log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | performance_schema |
Query OK, 2 row(s) in set (0.002679s) tcollector |
Query OK, 3 rows in database (0.001647s)
taos> use tcollector; taos> use tcollector;
Database changed. Database changed.
taos> show stables; taos> show stables;
name | created_time | columns | tags | tables | name |
============================================================================================ =================================
proc.meminfo.hugepages_rsvd | 2022-04-20 12:44:53.945 | 2 | 1 | 1 | proc.meminfo.hugepages_rsvd |
proc.meminfo.directmap1g | 2022-04-20 12:44:54.110 | 2 | 1 | 1 | proc.meminfo.directmap1g |
proc.meminfo.vmallocchunk | 2022-04-20 12:44:53.724 | 2 | 1 | 1 | proc.meminfo.vmallocchunk |
proc.meminfo.hugepagesize | 2022-04-20 12:44:54.004 | 2 | 1 | 1 | proc.meminfo.hugepagesize |
tcollector.reader.lines_dro... | 2022-04-20 12:44:49.675 | 2 | 1 | 1 | tcollector.reader.lines_dro... |
proc.meminfo.sunreclaim | 2022-04-20 12:44:53.437 | 2 | 1 | 1 | proc.meminfo.sunreclaim |
proc.stat.ctxt | 2022-04-20 12:44:55.363 | 2 | 1 | 1 | proc.stat.ctxt |
proc.meminfo.swaptotal | 2022-04-20 12:44:53.158 | 2 | 1 | 1 | proc.meminfo.swaptotal |
proc.uptime.total | 2022-04-20 12:44:52.813 | 2 | 1 | 1 | proc.uptime.total |
tcollector.collector.lines_... | 2022-04-20 12:44:49.895 | 2 | 2 | 51 | tcollector.collector.lines_... |
proc.meminfo.vmallocused | 2022-04-20 12:44:53.704 | 2 | 1 | 1 | proc.meminfo.vmallocused |
proc.meminfo.memavailable | 2022-04-20 12:44:52.939 | 2 | 1 | 1 | proc.meminfo.memavailable |
sys.numa.foreign_allocs | 2022-04-20 12:44:57.929 | 2 | 2 | 1 | sys.numa.foreign_allocs |
proc.meminfo.committed_as | 2022-04-20 12:44:53.639 | 2 | 1 | 1 | proc.meminfo.committed_as |
proc.vmstat.pswpin | 2022-04-20 12:44:54.177 | 2 | 1 | 1 | proc.vmstat.pswpin |
proc.meminfo.cmafree | 2022-04-20 12:44:53.865 | 2 | 1 | 1 | proc.meminfo.cmafree |
proc.meminfo.mapped | 2022-04-20 12:44:53.349 | 2 | 1 | 1 | proc.meminfo.mapped |
proc.vmstat.pgmajfault | 2022-04-20 12:44:54.251 | 2 | 1 | 1 | proc.vmstat.pgmajfault |
... ...
``` ```
:::note
- TDengine 默认生成的子表名是根据规则生成的唯一 ID 值。
:::

View File

@ -61,7 +61,6 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如
username = "<TDengine's username>" username = "<TDengine's username>"
password = "<TDengine's password>" password = "<TDengine's password>"
data_format = "influx" data_format = "influx"
influx_max_line_bytes = 250
``` ```
然后重启 Telegraf 然后重启 Telegraf

View File

@ -6,6 +6,10 @@ description: TDengine 发布历史、Release Notes 及下载链接
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 3.0.1.4
<Release type="tdengine" version="3.0.1.4" />
## 3.0.1.3 ## 3.0.1.3
<Release type="tdengine" version="3.0.1.3" /> <Release type="tdengine" version="3.0.1.3" />

View File

@ -6,6 +6,10 @@ description: taosTools 的发布历史、Release Notes 和下载链接
import Release from "/components/ReleaseV3"; import Release from "/components/ReleaseV3";
## 2.2.4
<Release type="tools" version="2.2.4" />
## 2.2.3 ## 2.2.3
<Release type="tools" version="2.2.3" /> <Release type="tools" version="2.2.3" />

View File

@ -1,6 +1,12 @@
# TDengine driver connector for Lua # TDengine driver connector for Lua
It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 . It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 .
As TDengine is built with lua-enable with default configure, the built-in lua lib conflicts with external lua lib. The following commands require TDengine built with lua-disable.
To disable built-in lua:
```
mkdir debug && cd debug
cmake .. -DBUILD_LUA=false && cmake --build .
```
## Lua Dependencies ## Lua Dependencies
- Lua: - Lua:

View File

@ -60,6 +60,7 @@ static int l_connect(lua_State *L){
lua_settop(L, 0); lua_settop(L, 0);
taos_init();
lua_newtable(L); lua_newtable(L);
int table_index = lua_gettop(L); int table_index = lua_gettop(L);
@ -136,15 +137,19 @@ static int l_query(lua_State *L){
lua_pushstring(L,fields[i].name); lua_pushstring(L,fields[i].name);
int32_t* length = taos_fetch_lengths(result); int32_t* length = taos_fetch_lengths(result);
switch (fields[i].type) { switch (fields[i].type) {
case TSDB_DATA_TYPE_UTINYINT:
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
lua_pushinteger(L,*((char *)row[i])); lua_pushinteger(L,*((char *)row[i]));
break; break;
case TSDB_DATA_TYPE_USMALLINT:
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
lua_pushinteger(L,*((short *)row[i])); lua_pushinteger(L,*((short *)row[i]));
break; break;
case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
lua_pushinteger(L,*((int *)row[i])); lua_pushinteger(L,*((int *)row[i]));
break; break;
case TSDB_DATA_TYPE_UBIGINT:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
lua_pushinteger(L,*((int64_t *)row[i])); lua_pushinteger(L,*((int64_t *)row[i]));
break; break;
@ -154,6 +159,7 @@ static int l_query(lua_State *L){
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
lua_pushnumber(L,*((double *)row[i])); lua_pushnumber(L,*((double *)row[i]));
break; break;
case TSDB_DATA_TYPE_JSON:
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
//printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
@ -197,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){
printf("failed, reason:%s\n", taos_errstr(result)); printf("failed, reason:%s\n", taos_errstr(result));
lua_pushinteger(L, -1); lua_pushinteger(L, -1);
lua_setfield(L, table_index, "code"); lua_setfield(L, table_index, "code");
lua_pushstring(L,"something is wrong");// taos_errstr(taos)); lua_pushstring(L, taos_errstr(result));
lua_setfield(L, table_index, "error"); lua_setfield(L, table_index, "error");
}else{ }else{
//printf("success to async query.\n"); //printf("success to async query.\n");

View File

@ -203,7 +203,7 @@ void async_query_callback(void *param, TAOS_RES *result, int code){
printf("failed, reason:%s\n", taos_errstr(result)); printf("failed, reason:%s\n", taos_errstr(result));
lua_pushinteger(L, -1); lua_pushinteger(L, -1);
lua_setfield(L, table_index, "code"); lua_setfield(L, table_index, "code");
lua_pushstring(L,"something is wrong");// taos_errstr(taos)); lua_pushstring(L, taos_errstr(result));
lua_setfield(L, table_index, "error"); lua_setfield(L, table_index, "error");
}else{ }else{
//printf("success to async query.\n"); //printf("success to async query.\n");

View File

@ -176,8 +176,14 @@ end
driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback)
res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)") res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)")
if res.code ~=0 then
print("create stream--- failed:"..res.error)
return
else
print("create stream--- pass")
end
print("From now on we start continous insert in an definite loop, pls wait for about 10 seconds and check stream table for result.") print("From now on we start continous insertion in an definite loop, please wait for about 10 seconds and check stream table avg_degree for result.")
local loop_index = 0 local loop_index = 0
while loop_index < 10 do while loop_index < 10 do
local t = os.time()*1000 local t = os.time()*1000
@ -193,5 +199,5 @@ while loop_index < 10 do
os.execute("sleep " .. 1) os.execute("sleep " .. 1)
loop_index = loop_index + 1 loop_index = loop_index + 1
end end
driver.query(conn,"DROP STREAM IF EXISTS avg_therm_s") driver.query(conn,"DROP STREAM IF EXISTS stream_avg_degree")
driver.close(conn) driver.close(conn)

View File

@ -177,6 +177,7 @@ typedef struct SSDataBlock {
enum { enum {
FETCH_TYPE__DATA = 1, FETCH_TYPE__DATA = 1,
FETCH_TYPE__META, FETCH_TYPE__META,
FETCH_TYPE__SEP,
FETCH_TYPE__NONE, FETCH_TYPE__NONE,
}; };

View File

@ -227,110 +227,111 @@
#define TK_WEND 209 #define TK_WEND 209
#define TK_WDURATION 210 #define TK_WDURATION 210
#define TK_IROWTS 211 #define TK_IROWTS 211
#define TK_CAST 212 #define TK_QTAGS 212
#define TK_NOW 213 #define TK_CAST 213
#define TK_TODAY 214 #define TK_NOW 214
#define TK_TIMEZONE 215 #define TK_TODAY 215
#define TK_CLIENT_VERSION 216 #define TK_TIMEZONE 216
#define TK_SERVER_VERSION 217 #define TK_CLIENT_VERSION 217
#define TK_SERVER_STATUS 218 #define TK_SERVER_VERSION 218
#define TK_CURRENT_USER 219 #define TK_SERVER_STATUS 219
#define TK_COUNT 220 #define TK_CURRENT_USER 220
#define TK_LAST_ROW 221 #define TK_COUNT 221
#define TK_CASE 222 #define TK_LAST_ROW 222
#define TK_END 223 #define TK_CASE 223
#define TK_WHEN 224 #define TK_END 224
#define TK_THEN 225 #define TK_WHEN 225
#define TK_ELSE 226 #define TK_THEN 226
#define TK_BETWEEN 227 #define TK_ELSE 227
#define TK_IS 228 #define TK_BETWEEN 228
#define TK_NK_LT 229 #define TK_IS 229
#define TK_NK_GT 230 #define TK_NK_LT 230
#define TK_NK_LE 231 #define TK_NK_GT 231
#define TK_NK_GE 232 #define TK_NK_LE 232
#define TK_NK_NE 233 #define TK_NK_GE 233
#define TK_MATCH 234 #define TK_NK_NE 234
#define TK_NMATCH 235 #define TK_MATCH 235
#define TK_CONTAINS 236 #define TK_NMATCH 236
#define TK_IN 237 #define TK_CONTAINS 237
#define TK_JOIN 238 #define TK_IN 238
#define TK_INNER 239 #define TK_JOIN 239
#define TK_SELECT 240 #define TK_INNER 240
#define TK_DISTINCT 241 #define TK_SELECT 241
#define TK_WHERE 242 #define TK_DISTINCT 242
#define TK_PARTITION 243 #define TK_WHERE 243
#define TK_BY 244 #define TK_PARTITION 244
#define TK_SESSION 245 #define TK_BY 245
#define TK_STATE_WINDOW 246 #define TK_SESSION 246
#define TK_SLIDING 247 #define TK_STATE_WINDOW 247
#define TK_FILL 248 #define TK_SLIDING 248
#define TK_VALUE 249 #define TK_FILL 249
#define TK_NONE 250 #define TK_VALUE 250
#define TK_PREV 251 #define TK_NONE 251
#define TK_LINEAR 252 #define TK_PREV 252
#define TK_NEXT 253 #define TK_LINEAR 253
#define TK_HAVING 254 #define TK_NEXT 254
#define TK_RANGE 255 #define TK_HAVING 255
#define TK_EVERY 256 #define TK_RANGE 256
#define TK_ORDER 257 #define TK_EVERY 257
#define TK_SLIMIT 258 #define TK_ORDER 258
#define TK_SOFFSET 259 #define TK_SLIMIT 259
#define TK_LIMIT 260 #define TK_SOFFSET 260
#define TK_OFFSET 261 #define TK_LIMIT 261
#define TK_ASC 262 #define TK_OFFSET 262
#define TK_NULLS 263 #define TK_ASC 263
#define TK_ABORT 264 #define TK_NULLS 264
#define TK_AFTER 265 #define TK_ABORT 265
#define TK_ATTACH 266 #define TK_AFTER 266
#define TK_BEFORE 267 #define TK_ATTACH 267
#define TK_BEGIN 268 #define TK_BEFORE 268
#define TK_BITAND 269 #define TK_BEGIN 269
#define TK_BITNOT 270 #define TK_BITAND 270
#define TK_BITOR 271 #define TK_BITNOT 271
#define TK_BLOCKS 272 #define TK_BITOR 272
#define TK_CHANGE 273 #define TK_BLOCKS 273
#define TK_COMMA 274 #define TK_CHANGE 274
#define TK_COMPACT 275 #define TK_COMMA 275
#define TK_CONCAT 276 #define TK_COMPACT 276
#define TK_CONFLICT 277 #define TK_CONCAT 277
#define TK_COPY 278 #define TK_CONFLICT 278
#define TK_DEFERRED 279 #define TK_COPY 279
#define TK_DELIMITERS 280 #define TK_DEFERRED 280
#define TK_DETACH 281 #define TK_DELIMITERS 281
#define TK_DIVIDE 282 #define TK_DETACH 282
#define TK_DOT 283 #define TK_DIVIDE 283
#define TK_EACH 284 #define TK_DOT 284
#define TK_FAIL 285 #define TK_EACH 285
#define TK_FILE 286 #define TK_FAIL 286
#define TK_FOR 287 #define TK_FILE 287
#define TK_GLOB 288 #define TK_FOR 288
#define TK_ID 289 #define TK_GLOB 289
#define TK_IMMEDIATE 290 #define TK_ID 290
#define TK_IMPORT 291 #define TK_IMMEDIATE 291
#define TK_INITIALLY 292 #define TK_IMPORT 292
#define TK_INSTEAD 293 #define TK_INITIALLY 293
#define TK_ISNULL 294 #define TK_INSTEAD 294
#define TK_KEY 295 #define TK_ISNULL 295
#define TK_NK_BITNOT 296 #define TK_KEY 296
#define TK_NK_SEMI 297 #define TK_NK_BITNOT 297
#define TK_NOTNULL 298 #define TK_NK_SEMI 298
#define TK_OF 299 #define TK_NOTNULL 299
#define TK_PLUS 300 #define TK_OF 300
#define TK_PRIVILEGE 301 #define TK_PLUS 301
#define TK_RAISE 302 #define TK_PRIVILEGE 302
#define TK_REPLACE 303 #define TK_RAISE 303
#define TK_RESTRICT 304 #define TK_REPLACE 304
#define TK_ROW 305 #define TK_RESTRICT 305
#define TK_SEMI 306 #define TK_ROW 306
#define TK_STAR 307 #define TK_SEMI 307
#define TK_STATEMENT 308 #define TK_STAR 308
#define TK_STRING 309 #define TK_STATEMENT 309
#define TK_TIMES 310 #define TK_STRING 310
#define TK_UPDATE 311 #define TK_TIMES 311
#define TK_VALUES 312 #define TK_UPDATE 312
#define TK_VARIABLE 313 #define TK_VALUES 313
#define TK_VIEW 314 #define TK_VARIABLE 314
#define TK_WAL 315 #define TK_VIEW 315
#define TK_WAL 316
#define TK_NK_SPACE 300 #define TK_NK_SPACE 300
#define TK_NK_COMMENT 301 #define TK_NK_COMMENT 301

View File

@ -136,6 +136,7 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
* @param handle * @param handle
* @return * @return
*/ */
int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch *pLocal); int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch *pLocal);
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds); int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds);
@ -195,6 +196,8 @@ int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts);
int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType); int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType);
int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq);
int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo);

View File

@ -120,6 +120,7 @@ typedef enum EFunctionType {
FUNCTION_TYPE_WEND, FUNCTION_TYPE_WEND,
FUNCTION_TYPE_WDURATION, FUNCTION_TYPE_WDURATION,
FUNCTION_TYPE_IROWTS, FUNCTION_TYPE_IROWTS,
FUNCTION_TYPE_TAGS,
// internal function // internal function
FUNCTION_TYPE_SELECT_VALUE = 3750, FUNCTION_TYPE_SELECT_VALUE = 3750,

View File

@ -206,12 +206,6 @@ void indexJsonRebuild(SIndexJson* idx, void* iter);
**/ **/
bool indexJsonIsRebuild(SIndexJson* idx); bool indexJsonIsRebuild(SIndexJson* idx);
/*
* init index env
*
*/
void indexInit();
/* index filter */ /* index filter */
typedef struct SIndexMetaArg { typedef struct SIndexMetaArg {
void* metaEx; void* metaEx;
@ -225,6 +219,12 @@ typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltS
SIdxFltStatus idxGetFltStatus(SNode* pFilterNode); SIdxFltStatus idxGetFltStatus(SNode* pFilterNode);
int32_t doFilterTag(SNode* pFilterNode, SIndexMetaArg* metaArg, SArray* result, SIdxFltStatus* status); int32_t doFilterTag(SNode* pFilterNode, SIndexMetaArg* metaArg, SArray* result, SIdxFltStatus* status);
/*
* init index env
*
*/
void indexInit(int32_t threads);
/* /*
* destory index env * destory index env
* *

View File

@ -29,7 +29,8 @@ extern "C" {
#define FOREACH(node, list) \ #define FOREACH(node, list) \
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL), *pNext; \ for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL), *pNext; \
(NULL != cell ? (node = cell->pNode, pNext = cell->pNext, true) : (node = NULL, pNext = NULL, false)); cell = pNext) (NULL != cell ? (node = cell->pNode, pNext = cell->pNext, true) : (node = NULL, pNext = NULL, false)); \
cell = pNext)
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode) #define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
@ -192,6 +193,7 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
QUERY_NODE_SHOW_SCORES_STMT, QUERY_NODE_SHOW_SCORES_STMT,
QUERY_NODE_SHOW_TABLE_TAGS_STMT,
QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_CONNECTION_STMT,
QUERY_NODE_KILL_QUERY_STMT, QUERY_NODE_KILL_QUERY_STMT,
QUERY_NODE_KILL_TRANSACTION_STMT, QUERY_NODE_KILL_TRANSACTION_STMT,

View File

@ -33,6 +33,7 @@ typedef struct {
TTB* pFuncStateDb; TTB* pFuncStateDb;
TTB* pFillStateDb; // todo refactor TTB* pFillStateDb; // todo refactor
TXN txn; TXN txn;
int32_t number;
} SStreamState; } SStreamState;
SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath); SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath);
@ -43,6 +44,7 @@ int32_t streamStateAbort(SStreamState* pState);
typedef struct { typedef struct {
TBC* pCur; TBC* pCur;
int64_t number;
} SStreamStateCur; } SStreamStateCur;
int32_t streamStateFuncPut(SStreamState* pState, const STupleKey* key, const void* value, int32_t vLen); int32_t streamStateFuncPut(SStreamState* pState, const STupleKey* key, const void* value, int32_t vLen);
@ -52,6 +54,8 @@ int32_t streamStateFuncDel(SStreamState* pState, const STupleKey* key);
int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen); int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen); int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
int32_t streamStateDel(SStreamState* pState, const SWinKey* key); int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
int32_t streamStateClear(SStreamState* pState);
void streamStateSetNumber(SStreamState* pState, int32_t number);
int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen); int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen); int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
@ -63,6 +67,7 @@ void streamFreeVal(void* val);
SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key); SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key);
SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key); SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key);
SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key);
SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key); SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key);
SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key); SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key);
void streamStateFreeCur(SStreamStateCur* pCur); void streamStateFreeCur(SStreamStateCur* pCur);
@ -70,6 +75,7 @@ void streamStateFreeCur(SStreamStateCur* pCur);
int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen); int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen); int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
int32_t streamStateGetFirst(SStreamState* pState, SWinKey* key);
int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur); int32_t streamStateSeekFirst(SStreamState* pState, SStreamStateCur* pCur);
int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur); int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur);

View File

@ -132,7 +132,7 @@ typedef struct SSyncFSM {
void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm); void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm);
void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta); void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta);
void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm); void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm);

View File

@ -565,6 +565,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662) #define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662)
#define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663) #define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663)
#define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664) #define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664)
#define TSDB_CODE_PAR_INVALID_TAGS_PC TAOS_DEF_ERROR_CODE(0, 0x2665)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner //planner

View File

@ -219,12 +219,12 @@ fi
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then
if [ "$verMode" != "cluster" ]; then if [ "$verMode" != "cluster" ]; then
# community-version compile # community-version compile
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
else else
if [[ "$dbName" != "taos" ]]; then if [[ "$dbName" != "taos" ]]; then
replace_enterprise_$dbName replace_enterprise_$dbName
fi fi
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro} cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
fi fi
else else
echo "input cpuType=${cpuType} error!!!" echo "input cpuType=${cpuType} error!!!"

View File

@ -874,8 +874,6 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
STscObj* pTscObj = pRequest->pTscObj; STscObj* pTscObj = pRequest->pTscObj;
pRequest->code = code; pRequest->code = code;
pRequest->metric.resultReady = taosGetTimestampUs();
if (pResult) { if (pResult) {
destroyQueryExecRes(&pRequest->body.resInfo.execRes); destroyQueryExecRes(&pRequest->body.resInfo.execRes);
memcpy(&pRequest->body.resInfo.execRes, pResult, sizeof(*pResult)); memcpy(&pRequest->body.resInfo.execRes, pResult, sizeof(*pResult));

View File

@ -863,6 +863,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
SRequestObj *pRequest = (SRequestObj *)param; SRequestObj *pRequest = (SRequestObj *)param;
SReqResultInfo *pResultInfo = &pRequest->body.resInfo; SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
pRequest->metric.resultReady = taosGetTimestampUs();
tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code,
tstrerror(code), pRequest->requestId); tstrerror(code), pRequest->requestId);

View File

@ -715,7 +715,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
int32_t epoch = tmq->epoch; int32_t epoch = tmq->epoch;
SMqHbReq* pReq = taosMemoryMalloc(sizeof(SMqHbReq)); SMqHbReq* pReq = taosMemoryMalloc(sizeof(SMqHbReq));
if (pReq == NULL) goto OVER; if (pReq == NULL) goto OVER;
pReq->consumerId = consumerId; pReq->consumerId = htobe64(consumerId);
pReq->epoch = epoch; pReq->epoch = epoch;
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
@ -1603,6 +1603,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
return NULL; return NULL;
} else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
tscDebug("consumer %ld actual process poll rsp", tmq->consumerId);
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
int32_t consumerEpoch = atomic_load_32(&tmq->epoch); int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) {
@ -1718,7 +1719,10 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
while (1) { while (1) {
tmqHandleAllDelayedTask(tmq); tmqHandleAllDelayedTask(tmq);
if (tmqPollImpl(tmq, timeout) < 0) return NULL; if (tmqPollImpl(tmq, timeout) < 0) {
tscDebug("return since poll err");
/*return NULL;*/
}
rspObj = tmqHandleAllRsp(tmq, timeout, false); rspObj = tmqHandleAllRsp(tmq, timeout, false);
if (rspObj) { if (rspObj) {

View File

@ -193,6 +193,8 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
goto _OVER; goto _OVER;
} }
indexInit(tsNumOfCommitThreads);
dmReportStartup("dnode-transport", "initialized"); dmReportStartup("dnode-transport", "initialized");
dDebug("dnode is created, ptr:%p", pDnode); dDebug("dnode is created, ptr:%p", pDnode);
code = 0; code = 0;

View File

@ -74,11 +74,14 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
} }
tstrncpy(queue->name, proc->name, sizeof(queue->name)); tstrncpy(queue->name, proc->name, sizeof(queue->name));
taosThreadMutexLock(&queue->mutex);
queue->head = 0; queue->head = 0;
queue->tail = 0; queue->tail = 0;
queue->total = bufSize; queue->total = bufSize;
queue->avail = bufSize; queue->avail = bufSize;
queue->items = 0; queue->items = 0;
taosThreadMutexUnlock(&queue->mutex);
} }
return queue; return queue;

View File

@ -301,7 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) {
SDnodeTrans *pTrans = &pDnode->trans; SDnodeTrans *pTrans = &pDnode->trans;
SRpcInit rpcInit = {0}; SRpcInit rpcInit = {0};
strncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN); tstrncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
rpcInit.localPort = tsServerPort; rpcInit.localPort = tsServerPort;
rpcInit.label = "DND-S"; rpcInit.label = "DND-S";
rpcInit.numOfThreads = tsNumOfRpcThreads; rpcInit.numOfThreads = tsNumOfRpcThreads;

View File

@ -83,6 +83,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-acct"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-acct");
if (pTrans == NULL) { if (pTrans == NULL) {
sdbFreeRaw(pRaw);
mError("acct:%s, failed to create since %s", acctObj.acct, terrstr()); mError("acct:%s, failed to create since %s", acctObj.acct, terrstr());
return -1; return -1;
} }

View File

@ -237,6 +237,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster");
if (pTrans == NULL) { if (pTrans == NULL) {
sdbFreeRaw(pRaw);
mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr()); mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr());
return -1; return -1;
} }
@ -315,7 +316,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
return 0; return 0;
} }
mInfo("update cluster uptime to %" PRId64, clusterObj.upTime); mInfo("update cluster uptime to %d", clusterObj.upTime);
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime");
if (pTrans == NULL) return -1; if (pTrans == NULL) return -1;

View File

@ -272,6 +272,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
if (pConsumer == NULL) { if (pConsumer == NULL) {
mError("consumer %ld not exist", consumerId);
terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;
return -1; return -1;
} }

View File

@ -1594,7 +1594,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
break; break;
} }
char precVstr[10] = {0}; char precVstr[10] = {0};
STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2); STR_WITH_MAXSIZE_TO_VARSTR(precVstr, precStr, 10);
char *statusStr = "ready"; char *statusStr = "ready";
if (objStatus == SDB_STATUS_CREATING) { if (objStatus == SDB_STATUS_CREATING) {
@ -1607,7 +1607,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
} }
} }
char statusVstr[24] = {0}; char statusVstr[24] = {0};
STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr)); STR_WITH_MAXSIZE_TO_VARSTR(statusVstr, statusStr, 24);
if (sysDb || !sysinfo) { if (sysDb || !sysinfo) {
for (int32_t i = 0; i < pShow->numOfColumns; ++i) { for (int32_t i = 0; i < pShow->numOfColumns; ++i) {
@ -1644,7 +1644,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
const char *strictStr = pDb->cfg.strict ? "on" : "off"; const char *strictStr = pDb->cfg.strict ? "on" : "off";
char strictVstr[24] = {0}; char strictVstr[24] = {0};
STR_WITH_SIZE_TO_VARSTR(strictVstr, strictStr, strlen(strictStr)); STR_WITH_MAXSIZE_TO_VARSTR(strictVstr, strictStr, 24);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)strictVstr, false); colDataAppend(pColInfo, rows, (const char *)strictVstr, false);
@ -1704,7 +1704,7 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast); const char *cacheModelStr = getCacheModelStr(pDb->cfg.cacheLast);
char cacheModelVstr[24] = {0}; char cacheModelVstr[24] = {0};
STR_WITH_SIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, strlen(cacheModelStr)); STR_WITH_MAXSIZE_TO_VARSTR(cacheModelVstr, cacheModelStr, 24);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)cacheModelVstr, false); colDataAppend(pColInfo, rows, (const char *)cacheModelVstr, false);

View File

@ -102,7 +102,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.updateTime = dnodeObj.createdTime;
dnodeObj.port = tsServerPort; dnodeObj.port = tsServerPort;
memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode"); pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
if (pTrans == NULL) goto _OVER; if (pTrans == NULL) goto _OVER;
@ -190,7 +190,7 @@ _OVER:
static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) { static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) {
mTrace("dnode:%d, perform insert action, row:%p", pDnode->id, pDnode); mTrace("dnode:%d, perform insert action, row:%p", pDnode->id, pDnode);
pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED; pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED;
snprintf(pDnode->ep, TSDB_EP_LEN, "%s:%u", pDnode->fqdn, pDnode->port); snprintf(pDnode->ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port);
return 0; return 0;
} }
@ -253,7 +253,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) { bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs) {
int64_t interval = TABS(pDnode->lastAccessTime - curMs); int64_t interval = TABS(pDnode->lastAccessTime - curMs);
if (interval > 5000 * tsStatusInterval) { if (interval > 5000 * (int64_t)tsStatusInterval) {
if (pDnode->rebootTime > 0) { if (pDnode->rebootTime > 0) {
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT; pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
} }
@ -486,7 +486,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.updateTime = dnodeObj.createdTime;
dnodeObj.port = pCreate->port; dnodeObj.port = pCreate->port;
memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode"); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
if (pTrans == NULL) goto _OVER; if (pTrans == NULL) goto _OVER;
@ -673,12 +673,14 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id); mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id);
pRaw = mndDnodeActionEncode(pDnode); pRaw = mndDnodeActionEncode(pDnode);
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL) goto _OVER;
if (mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING); sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING);
pRaw = NULL; pRaw = NULL;
pRaw = mndDnodeActionEncode(pDnode); pRaw = mndDnodeActionEncode(pDnode);
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL) goto _OVER;
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
pRaw = NULL; pRaw = NULL;

View File

@ -257,15 +257,18 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
mInfo("trans:%d, used to drop user:%s", pTrans->id, pFunc->name); mInfo("trans:%d, used to drop user:%s", pTrans->id, pFunc->name);
SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc); SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; if (pRedoRaw == NULL) goto _OVER;
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING);
SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc); SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc);
if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; if (pUndoRaw == NULL) goto _OVER;
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER;
sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY);
SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc); SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc);
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; if (pCommitRaw == NULL) goto _OVER;
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;

View File

@ -30,85 +30,85 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
cols = 0; cols = 0;
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
const char *src = "community"; const char *src = "community";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "false"; src = "false";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
cols++; cols++;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
src = "unlimited"; src = "unlimited";
STR_WITH_SIZE_TO_VARSTR(tmp, src, strlen(src)); STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
colDataAppend(pColInfo, numOfRows, tmp, false); colDataAppend(pColInfo, numOfRows, tmp, false);
numOfRows++; numOfRows++;

View File

@ -649,7 +649,7 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
tmsg_t type = TMSG_INDEX(msgType); tmsg_t type = TMSG_INDEX(msgType);
if (type >= 0 && type < TDMT_MAX) { if (type < TDMT_MAX) {
pMnode->msgFp[type] = fp; pMnode->msgFp[type] = fp;
} }
} }

View File

@ -93,6 +93,7 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-mnode"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-mnode");
if (pTrans == NULL) { if (pTrans == NULL) {
sdbFreeRaw(pRaw);
mError("mnode:%d, failed to create since %s", mnodeObj.id, terrstr()); mError("mnode:%d, failed to create since %s", mnodeObj.id, terrstr());
return -1; return -1;
} }
@ -220,8 +221,12 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE); int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
void *pIter = NULL; if (totalMnodes == 0) {
syncGetRetryEpSet(pMnode->syncMgmt.sync, pEpSet);
return;
}
void *pIter = NULL;
while (1) { while (1) {
SMnodeObj *pObj = NULL; SMnodeObj *pObj = NULL;
pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj); pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj);
@ -658,7 +663,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false); colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false);
char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes); STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, TSDB_EP_LEN + VARSTR_HEADER_SIZE);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, b1, false); colDataAppend(pColInfo, numOfRows, b1, false);
@ -667,7 +672,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
if (pObj->id == pMnode->selfDnodeId) { if (pObj->id == pMnode->selfDnodeId) {
roles = syncStr(TAOS_SYNC_STATE_LEADER); roles = syncStr(TAOS_SYNC_STATE_LEADER);
} }
if (pObj->pDnode && mndIsDnodeOnline(pObj->pDnode, curMs)) { if (mndIsDnodeOnline(pObj->pDnode, curMs)) {
roles = syncStr(pObj->state); roles = syncStr(pObj->state);
if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) { if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) {
roles = syncStr(TAOS_SYNC_STATE_ERROR); roles = syncStr(TAOS_SYNC_STATE_ERROR);

View File

@ -26,7 +26,7 @@ int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, S
} }
for (int32_t i = 0; i < colNum; ++i) { for (int32_t i = 0; i < colNum; ++i) {
strcpy(schema[i].name, pSrc[i].name); tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
schema[i].type = pSrc[i].type; schema[i].type = pSrc[i].type;
schema[i].colId = i + 1; schema[i].colId = i + 1;
@ -40,7 +40,7 @@ int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, S
int32_t mndPerfsInitMeta(SHashObj *hash) { int32_t mndPerfsInitMeta(SHashObj *hash) {
STableMetaRsp meta = {0}; STableMetaRsp meta = {0};
strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName));
meta.tableType = TSDB_SYSTEM_TABLE; meta.tableType = TSDB_SYSTEM_TABLE;
meta.sversion = 1; meta.sversion = 1;
meta.tversion = 1; meta.tversion = 1;
@ -50,7 +50,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) {
getPerfDbMeta(&pSysDbTableMeta, &size); getPerfDbMeta(&pSysDbTableMeta, &size);
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
strcpy(meta.tbName, pSysDbTableMeta[i].name); tstrncpy(meta.tbName, pSysDbTableMeta[i].name, sizeof(meta.tbName));
meta.numOfColumns = pSysDbTableMeta[i].colNum; meta.numOfColumns = pSysDbTableMeta[i].colNum;
if (mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas)) { if (mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas)) {

View File

@ -664,7 +664,7 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) { static int32_t mndProcessSvrVerReq(SRpcMsg *pReq) {
int32_t code = -1; int32_t code = -1;
SServerVerRsp rsp = {0}; SServerVerRsp rsp = {0};
strcpy(rsp.ver, version); tstrncpy(rsp.ver, version, sizeof(rsp.ver));
int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp); int32_t contLen = tSerializeSServerVerRsp(NULL, 0, &rsp);
if (contLen < 0) goto _over; if (contLen < 0) goto _over;
@ -702,7 +702,7 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
break; break;
} }
if ((taosGetTimestampMs() - pConn->lastAccessTimeMs) > (keepTime * 1000)) { if ((taosGetTimestampMs() - pConn->lastAccessTimeMs) > ((int64_t)keepTime * 1000)) {
continue; continue;
} }

View File

@ -123,7 +123,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
req.subType = pSub->subType; req.subType = pSub->subType;
req.withMeta = pSub->withMeta; req.withMeta = pSub->withMeta;
req.suid = pSub->stbUid; req.suid = pSub->stbUid;
strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN); tstrncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
int32_t tlen = sizeof(SMsgHead) + tEncodeSMqRebVgReq(NULL, &req); int32_t tlen = sizeof(SMsgHead) + tEncodeSMqRebVgReq(NULL, &req);
void *buf = taosMemoryMalloc(tlen); void *buf = taosMemoryMalloc(tlen);

View File

@ -68,7 +68,7 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
if (pMgmt->errCode != 0) { if (pMgmt->errCode != 0) {
mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode)); mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode));
} else { } else {
mInfo("trans:%d, is proposed and post sem", transId, tstrerror(pMgmt->errCode)); mInfo("trans:%d, is proposed and post sem", transId);
} }
pMgmt->transId = 0; pMgmt->transId = 0;
taosWUnLockLatch(&pMgmt->lock); taosWUnLockLatch(&pMgmt->lock);
@ -113,13 +113,13 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
} }
} }
void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbMeta) { void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta *cbMeta) {
SMnode *pMnode = pFsm->data; SMnode *pMnode = pFsm->data;
SSyncMgmt *pMgmt = &pMnode->syncMgmt; SSyncMgmt *pMgmt = &pMnode->syncMgmt;
pMgmt->errCode = cbMeta.code; pMgmt->errCode = cbMeta->code;
mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64, pMgmt->transId, mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64, pMgmt->transId,
cbMeta.code, cbMeta.index, cbMeta.term); cbMeta->code, cbMeta->index, cbMeta->term);
taosWLockLatch(&pMgmt->lock); taosWLockLatch(&pMgmt->lock);
if (pMgmt->transId == -1) { if (pMgmt->transId == -1) {
@ -127,7 +127,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
mError("trans:-1, failed to propose sync reconfig since %s, post sem", tstrerror(pMgmt->errCode)); mError("trans:-1, failed to propose sync reconfig since %s, post sem", tstrerror(pMgmt->errCode));
} else { } else {
mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64 " post sem", mInfo("trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%" PRId64 " term:%" PRId64 " post sem",
pMgmt->transId, cbMeta.code, cbMeta.index, cbMeta.term); pMgmt->transId, cbMeta->code, cbMeta->index, cbMeta->term);
} }
pMgmt->transId = 0; pMgmt->transId = 0;
tsem_post(&pMgmt->syncSem); tsem_post(&pMgmt->syncSem);
@ -271,6 +271,11 @@ void mndCleanupSync(SMnode *pMnode) {
int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
SSyncMgmt *pMgmt = &pMnode->syncMgmt; SSyncMgmt *pMgmt = &pMnode->syncMgmt;
SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)}; SRpcMsg req = {.msgType = TDMT_MND_APPLY_MSG, .contLen = sdbGetRawTotalSize(pRaw)};
if (req.contLen <= 0) {
terrno = TSDB_CODE_APP_ERROR;
return -1;
}
req.pCont = rpcMallocCont(req.contLen); req.pCont = rpcMallocCont(req.contLen);
if (req.pCont == NULL) return -1; if (req.pCont == NULL) return -1;
memcpy(req.pCont, pRaw, req.contLen); memcpy(req.pCont, pRaw, req.contLen);
@ -278,7 +283,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
pMgmt->errCode = 0; pMgmt->errCode = 0;
taosWLockLatch(&pMgmt->lock); taosWLockLatch(&pMgmt->lock);
if (pMgmt->transId != 0) { if (pMgmt->transId != 0) {
mError("trans:%d, can't be proposed since trans:%s alrady waiting for confirm", transId, pMgmt->transId); mError("trans:%d, can't be proposed since trans:%d alrady waiting for confirm", transId, pMgmt->transId);
taosWUnLockLatch(&pMgmt->lock); taosWUnLockLatch(&pMgmt->lock);
terrno = TSDB_CODE_APP_NOT_READY; terrno = TSDB_CODE_APP_NOT_READY;
return -1; return -1;

View File

@ -379,6 +379,8 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
topicObj.ast = strdup(pCreate->ast); topicObj.ast = strdup(pCreate->ast);
topicObj.astLen = strlen(pCreate->ast) + 1; topicObj.astLen = strlen(pCreate->ast) + 1;
qDebugL("ast %s", topicObj.ast);
SNode *pAst = NULL; SNode *pAst = NULL;
if (nodesStringToNode(pCreate->ast, &pAst) != 0) { if (nodesStringToNode(pCreate->ast, &pAst) != 0) {
taosMemoryFree(topicObj.ast); taosMemoryFree(topicObj.ast);
@ -774,7 +776,7 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
SName n; SName n;
int32_t cols = 0; int32_t cols = 0;
char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE + 5] = {0};
strcpy(varDataVal(topicName), mndGetDbStr(pTopic->name)); strcpy(varDataVal(topicName), mndGetDbStr(pTopic->name));
/*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/ /*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/
/*tNameGetDbName(&n, varDataVal(topicName));*/ /*tNameGetDbName(&n, varDataVal(topicName));*/

View File

@ -427,7 +427,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
terrno = 0; terrno = 0;
_OVER: _OVER:
if (terrno != 0) { if (terrno != 0 && pTrans != NULL) {
mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr()); mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
mndTransDropData(pTrans); mndTransDropData(pTrans);
taosMemoryFreeClear(pRow); taosMemoryFreeClear(pRow);
@ -629,6 +629,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
pTrans->pRpcArray == NULL) { pTrans->pRpcArray == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
mError("failed to create transaction since %s", terrstr()); mError("failed to create transaction since %s", terrstr());
mndTransDrop(pTrans);
return NULL; return NULL;
} }
@ -1428,6 +1429,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) {
SSdbRaw *pRaw = mndTransActionEncode(pTrans); SSdbRaw *pRaw = mndTransActionEncode(pTrans);
if (pRaw == NULL) { if (pRaw == NULL) {
mError("trans:%d, failed to encode while finish trans since %s", pTrans->id, terrstr()); mError("trans:%d, failed to encode while finish trans since %s", pTrans->id, terrstr());
return false;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
@ -1617,7 +1619,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
char detail[TSDB_TRANS_ERROR_LEN] = {0}; char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction, int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo)); pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
SEpSet epset = pTrans->lastEpset; SEpSet epset = pTrans->lastEpset;

View File

@ -83,6 +83,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-user"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-user");
if (pTrans == NULL) { if (pTrans == NULL) {
sdbFreeRaw(pRaw);
mError("user:%s, failed to create since %s", userObj.user, terrstr()); mError("user:%s, failed to create since %s", userObj.user, terrstr());
return -1; return -1;
} }

View File

@ -1250,7 +1250,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64,
pVgroup->dbName, pVgroup->vgId, vgMem, pNew1->id, pNew1->memAvail, pNew1->memUsed); pVgroup->dbName, pVgroup->vgId, vgMem, pNew1->id, pNew1->memAvail, pNew1->memUsed);
terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE;
return -1; goto _OVER;
} else { } else {
pNew1->memUsed += vgMem; pNew1->memUsed += vgMem;
} }
@ -1272,7 +1272,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64,
pVgroup->dbName, pVgroup->vgId, vgMem, pNew2->id, pNew2->memAvail, pNew2->memUsed); pVgroup->dbName, pVgroup->vgId, vgMem, pNew2->id, pNew2->memAvail, pNew2->memUsed);
terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE;
return -1; goto _OVER;
} else { } else {
pNew2->memUsed += vgMem; pNew2->memUsed += vgMem;
} }
@ -1293,7 +1293,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64, mError("db:%s, vgId:%d, no enough memory:%" PRId64 " in dnode:%d avail:%" PRId64 " used:%" PRId64,
pVgroup->dbName, pVgroup->vgId, vgMem, pNew3->id, pNew3->memAvail, pNew3->memUsed); pVgroup->dbName, pVgroup->vgId, vgMem, pNew3->id, pNew3->memAvail, pNew3->memUsed);
terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE;
return -1; goto _OVER;
} else { } else {
pNew3->memUsed += vgMem; pNew3->memUsed += vgMem;
} }
@ -1627,7 +1627,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
} else if (newVg1.replica == 3) { } else if (newVg1.replica == 3) {
SVnodeGid del1 = {0}; SVnodeGid del1 = {0};
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER; if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1; if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) goto _OVER;
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER;
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;

View File

@ -62,7 +62,9 @@ void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId); void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId);
int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen); int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen);
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list); int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list);
int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list); int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list);
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg);
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list); int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list);
void *vnodeGetIdx(SVnode *pVnode); void *vnodeGetIdx(SVnode *pVnode);
void *vnodeGetIvtIdx(SVnode *pVnode); void *vnodeGetIvtIdx(SVnode *pVnode);
@ -92,10 +94,14 @@ typedef struct SMetaEntry SMetaEntry;
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags); void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags);
void metaReaderClear(SMetaReader *pReader); void metaReaderClear(SMetaReader *pReader);
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
int metaGetTableEntryByName(SMetaReader *pReader, const char *name);
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags);
int32_t metaGetTableTagsOpt(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags);
int32_t metaReadNext(SMetaReader *pReader); int32_t metaReadNext(SMetaReader *pReader);
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid);
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType);
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
typedef struct SMetaFltParam { typedef struct SMetaFltParam {
@ -153,7 +159,7 @@ uint64_t getReaderMaxVersion(STsdbReader *pReader);
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader); int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, void **pReader);
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids); int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
int32_t tsdbCacherowsReaderClose(void *pReader); void* tsdbCacherowsReaderClose(void *pReader);
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid); int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity); void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
@ -217,7 +223,7 @@ int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
int32_t tqSeekVer(STqReader *pReader, int64_t ver); int32_t tqSeekVer(STqReader *pReader, int64_t ver);
int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret); int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret);
int32_t tqReaderSetDataMsg(STqReader *pReader, SSubmitReq *pMsg, int64_t ver); int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver);
bool tqNextDataBlock(STqReader *pReader); bool tqNextDataBlock(STqReader *pReader);
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids); bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader); int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);

View File

@ -113,10 +113,20 @@ typedef struct {
} STqHandle; } STqHandle;
typedef struct {
SMqDataRsp dataRsp;
SMqRspHead rspHead;
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
SRpcHandleInfo pInfo;
} STqPushEntry;
struct STQ { struct STQ {
SVnode* pVnode; SVnode* pVnode;
char* path; char* path;
SHashObj* pPushMgr; // consumerId -> STqHandle*
SRWLatch pushLock;
SHashObj* pPushMgr; // consumerId -> STqPushEntry
SHashObj* pHandle; // subKey -> STqHandle SHashObj* pHandle; // subKey -> STqHandle
SHashObj* pCheckInfo; // topic -> SAlterCheckInfo SHashObj* pCheckInfo; // topic -> SAlterCheckInfo
@ -146,7 +156,9 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
// tqExec // tqExec
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp); int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp);
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols);
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp);
int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry);
// tqMeta // tqMeta
int32_t tqMetaOpen(STQ* pTq); int32_t tqMetaOpen(STQ* pTq);

View File

@ -99,7 +99,6 @@ void vnodeSyncStart(SVnode* pVnode);
void vnodeSyncClose(SVnode* pVnode); void vnodeSyncClose(SVnode* pVnode);
void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg); void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg);
bool vnodeIsLeader(SVnode* pVnode); bool vnodeIsLeader(SVnode* pVnode);
bool vnodeIsReadyForRead(SVnode* pVnode);
bool vnodeIsRoleLeader(SVnode* pVnode); bool vnodeIsRoleLeader(SVnode* pVnode);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -111,6 +111,7 @@ SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, boo
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver); STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema** ppTSchema); int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sver, STSchema** ppTSchema);
int metaGetTableEntryByName(SMetaReader* pReader, const char* name); int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name); tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
int64_t metaGetTbNum(SMeta* pMeta); int64_t metaGetTbNum(SMeta* pMeta);
int64_t metaGetTimeSeriesNum(SMeta* pMeta); int64_t metaGetTimeSeriesNum(SMeta* pMeta);
@ -184,8 +185,9 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg);
int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg);
int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg);
SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema,
const char* stbFullName, SBatchDeleteReq* pDeleteReq); SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName,
SBatchDeleteReq* pDeleteReq);
// sma // sma
int32_t smaInit(); int32_t smaInit();

View File

@ -200,36 +200,30 @@ int metaClose(SMeta *pMeta) {
int32_t metaRLock(SMeta *pMeta) { int32_t metaRLock(SMeta *pMeta) {
int32_t ret = 0; int32_t ret = 0;
metaTrace("meta rlock %p B", &pMeta->lock); metaTrace("meta rlock %p", &pMeta->lock);
ret = taosThreadRwlockRdlock(&pMeta->lock); ret = taosThreadRwlockRdlock(&pMeta->lock);
metaTrace("meta rlock %p E", &pMeta->lock);
return ret; return ret;
} }
int32_t metaWLock(SMeta *pMeta) { int32_t metaWLock(SMeta *pMeta) {
int32_t ret = 0; int32_t ret = 0;
metaTrace("meta wlock %p B", &pMeta->lock); metaTrace("meta wlock %p", &pMeta->lock);
ret = taosThreadRwlockWrlock(&pMeta->lock); ret = taosThreadRwlockWrlock(&pMeta->lock);
metaTrace("meta wlock %p E", &pMeta->lock);
return ret; return ret;
} }
int32_t metaULock(SMeta *pMeta) { int32_t metaULock(SMeta *pMeta) {
int32_t ret = 0; int32_t ret = 0;
metaTrace("meta ulock %p B", &pMeta->lock); metaTrace("meta ulock %p", &pMeta->lock);
ret = taosThreadRwlockUnlock(&pMeta->lock); ret = taosThreadRwlockUnlock(&pMeta->lock);
metaTrace("meta ulock %p E", &pMeta->lock);
return ret; return ret;
} }

View File

@ -202,6 +202,38 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) {
return 0; return 0;
} }
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) {
int code = 0;
SMetaReader mr = {0};
metaReaderInit(&mr, (SMeta *)meta, 0);
SMeta *pMeta = mr.pMeta;
SMetaReader *pReader = &mr;
// query name.idx
if (tdbTbGet(pMeta->pNameIdx, tbName, strlen(tbName) + 1, &pReader->pBuf, &pReader->szBuf) < 0) {
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
metaReaderClear(&mr);
return -1;
}
*uid = *(tb_uid_t *)pReader->pBuf;
metaReaderClear(&mr);
return 0;
}
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType) {
int code = 0;
SMetaReader mr = {0};
metaReaderInit(&mr, (SMeta *)meta, 0);
if (metaGetTableEntryByName(&mr, tbName) == 0) {
*tbType = mr.me.type;
}
metaReaderClear(&mr);
return 0;
}
int metaReadNext(SMetaReader *pReader) { int metaReadNext(SMetaReader *pReader) {
SMeta *pMeta = pReader->pMeta; SMeta *pMeta = pReader->pMeta;
@ -872,7 +904,7 @@ SArray *metaGetSmaIdsByTable(SMeta *pMeta, tb_uid_t uid) {
pSmaIdxKey = (SSmaIdxKey *)pCur->pKey; pSmaIdxKey = (SSmaIdxKey *)pCur->pKey;
if (taosArrayPush(pUids, &pSmaIdxKey->smaUid) < 0) { if (!taosArrayPush(pUids, &pSmaIdxKey->smaUid)) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
metaCloseSmaCursor(pCur); metaCloseSmaCursor(pCur);
taosArrayDestroy(pUids); taosArrayDestroy(pUids);
@ -915,7 +947,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
} }
} }
if (taosArrayPush(pUids, &uid) < 0) { if (!taosArrayPush(pUids, &uid)) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
metaCloseSmaCursor(pCur); metaCloseSmaCursor(pCur);
taosArrayDestroy(pUids); taosArrayDestroy(pUids);
@ -1102,6 +1134,21 @@ END:
return ret; return ret;
} }
int32_t metaGetTableTagsOpt(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) {
int32_t sz = uidList ? taosArrayGetSize(uidList) : 0;
for (int i = 0; i < sz; i++) {
tb_uid_t *id = taosArrayGet(uidList, i);
SCtbIdxKey ctbIdxKey = {.suid = suid, .uid = *id};
void *val = NULL;
int32_t len = 0;
if (taosHashGet(tags, id, sizeof(tb_uid_t)) == NULL &&
0 == tdbTbGet(pMeta->pCtbIdx, &ctbIdxKey, sizeof(SCtbIdxKey), &val, &len)) {
taosHashPut(tags, id, sizeof(tb_uid_t), val, len);
}
}
return 0;
}
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) { int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) {
SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid); SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid);

View File

@ -213,7 +213,7 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
if (taosCheckExistFile(qTaskInfoFullName)) { if (taosCheckExistFile(qTaskInfoFullName)) {
SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0}; SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0};
if (taosArrayPush(pFS->aQTaskInf, &qFile) < 0) { if (!taosArrayPush(pFS->aQTaskInf, &qFile)) {
taosWUnLockLatch(RSMA_FS_LOCK(pStat)); taosWUnLockLatch(RSMA_FS_LOCK(pStat));
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;

View File

@ -386,7 +386,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
} }
break; break;
default: default:
smaError("vgId:%d, undefined smaType:%", SMA_VID(pSma), smaType); smaError("vgId:%d, undefined smaType:%" PRIi8, SMA_VID(pSma), smaType);
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }

View File

@ -54,7 +54,7 @@ int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) {
if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) { if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) {
goto _end; goto _end;
} }
smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%" PRIi64, TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef); smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%d", TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef);
} }
_end: _end:

View File

@ -196,7 +196,8 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids,
if (!suid || !tbUids) { if (!suid || !tbUids) {
terrno = TSDB_CODE_INVALID_PTR; terrno = TSDB_CODE_INVALID_PTR;
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr()); smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), suid ? *suid : -1,
terrstr());
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
@ -566,6 +567,7 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid)
} }
if (!taosArrayPush(pUidArray, uid)) { if (!taosArrayPush(pUidArray, uid)) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
taosArrayDestroy(pUidArray);
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
if (taosHashPut(pStore->uidHash, &suid, sizeof(suid), &pUidArray, sizeof(pUidArray)) < 0) { if (taosHashPut(pStore->uidHash, &suid, sizeof(suid), &pUidArray, sizeof(pUidArray)) < 0) {
@ -1678,13 +1680,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
SRSmaInfoItem *pItem = NULL; SRSmaInfoItem *pItem = NULL;
if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, &param, POINTER_BYTES))) { if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, &param, POINTER_BYTES))) {
smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%" PRIi64, param, smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%d", param,
*(int64_t *)&param, smaMgmt.refHash, smaMgmt.rsetId); smaMgmt.refHash, smaMgmt.rsetId);
return; return;
} }
if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) { if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) {
smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)", smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")",
smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
taosHashRemove(smaMgmt.refHash, &param, POINTER_BYTES); taosHashRemove(smaMgmt.refHash, &param, POINTER_BYTES);
return; return;
@ -1693,7 +1695,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
pSma = pStat->pSma; pSma = pStat->pSma;
if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) { if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) {
smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
taosHashRemove(smaMgmt.refHash, &param, POINTER_BYTES); taosHashRemove(smaMgmt.refHash, &param, POINTER_BYTES);
@ -1701,7 +1703,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
} }
if (RSMA_INFO_IS_DEL(pRSmaInfo)) { if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
tdReleaseRSmaInfo(pSma, pRSmaInfo); tdReleaseRSmaInfo(pSma, pRSmaInfo);
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
@ -1717,7 +1719,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
case TASK_TRIGGER_STAT_PAUSED: case TASK_TRIGGER_STAT_PAUSED:
case TASK_TRIGGER_STAT_CANCELLED: { case TASK_TRIGGER_STAT_CANCELLED: {
smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8 smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8
", rsetId rsetId:%" PRIi64 " refId:%d", ", rsetId:%d refId:%" PRIi64,
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId); SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId);
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
@ -1845,7 +1847,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
void *msg = NULL; void *msg = NULL;
taosGetQitem(qall, (void **)&msg); taosGetQitem(qall, (void **)&msg);
if (msg) { if (msg) {
if (taosArrayPush(pSubmitArr, &msg) < 0) { if (!taosArrayPush(pSubmitArr, &msg)) {
tdFreeRSmaSubmitItems(pSubmitArr); tdFreeRSmaSubmitItems(pSubmitArr);
goto _err; goto _err;
} }

View File

@ -70,6 +70,8 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapRead
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
_err: _err:
if (pReader) rsmaSnapReaderClose(&pReader);
*ppReader = NULL;
smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code)); smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code));
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
@ -101,8 +103,8 @@ static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t vers
if (!taosCheckExistFile(qTaskInfoFullName)) { if (!taosCheckExistFile(qTaskInfoFullName)) {
tdRSmaFSUnRef(pSma, pStat, version); tdRSmaFSUnRef(pSma, pStat, version);
smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exists", smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exist",
TD_VID(pVnode), qTaskInfoFullName); TD_VID(pVnode), version, qTaskInfoFullName);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -336,6 +338,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (!qTaskF) { if (!qTaskF) {
taosMemoryFree(qWriter);
code = TAOS_SYSTEM_ERROR(errno); code = TAOS_SYSTEM_ERROR(errno);
smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName, smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName,
tstrerror(code)); tstrerror(code));
@ -356,6 +359,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit
_err: _err:
smaError("vgId:%d, rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code)); smaError("vgId:%d, rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code));
if (pWriter) rsmaSnapWriterClose(&pWriter, 0);
*ppWriter = NULL; *ppWriter = NULL;
return code; return code;
} }
@ -449,11 +453,11 @@ static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData,
code = TAOS_SYSTEM_ERROR(errno); code = TAOS_SYSTEM_ERROR(errno);
goto _err; goto _err;
} }
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname);
} else { } else {
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma)); smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma));
} }
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname);
_exit: _exit:
return code; return code;

View File

@ -290,19 +290,19 @@ int32_t tdRemoveTFile(STFile *pTFile) {
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
void *pResult = taosAcquireRef(rsetId, refId); void *pResult = taosAcquireRef(rsetId, refId);
if (!pResult) { if (!pResult) {
smaWarn("rsma acquire ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr()); smaWarn("rsma acquire ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
} else { } else {
smaDebug("rsma acquire ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId); smaDebug("rsma acquire ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId);
} }
return pResult; return pResult;
} }
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) { int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
if (taosReleaseRef(rsetId, refId) < 0) { if (taosReleaseRef(rsetId, refId) < 0) {
smaWarn("rsma release ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr()); smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId); smaDebug("rsma release ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -65,6 +65,11 @@ static void destroySTqHandle(void* data) {
} }
} }
static void tqPushEntryFree(void* data) {
STqPushEntry* p = *(void**)data;
taosMemoryFree(p);
}
STQ* tqOpen(const char* path, SVnode* pVnode) { STQ* tqOpen(const char* path, SVnode* pVnode) {
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ)); STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
if (pTq == NULL) { if (pTq == NULL) {
@ -78,7 +83,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
taosHashSetFreeFp(pTq->pHandle, destroySTqHandle); taosHashSetFreeFp(pTq->pHandle, destroySTqHandle);
pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); taosInitRWLatch(&pTq->pushLock);
pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
taosHashSetFreeFp(pTq->pPushMgr, tqPushEntryFree);
pTq->pCheckInfo = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK); pTq->pCheckInfo = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK);
@ -153,6 +160,65 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
return 0; return 0;
} }
int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
SMqDataRsp* pRsp = &pPushEntry->dataRsp;
ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum);
ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum);
ASSERT(!pRsp->withSchema);
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
if (pRsp->blockNum > 0) {
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
} else {
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
}
}
int32_t len = 0;
int32_t code = 0;
tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code);
if (code < 0) {
return -1;
}
int32_t tlen = sizeof(SMqRspHead) + len;
void* buf = rpcMallocCont(tlen);
if (buf == NULL) {
return -1;
}
memcpy(buf, &pPushEntry->rspHead, sizeof(SMqRspHead));
void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead));
SEncoder encoder = {0};
tEncoderInit(&encoder, abuf, len);
tEncodeSMqDataRsp(&encoder, pRsp);
tEncoderClear(&encoder);
SRpcMsg rsp = {
.info = pPushEntry->pInfo,
.pCont = buf,
.contLen = tlen,
.code = 0,
};
tmsgSendRsp(&rsp);
char buf1[80] = {0};
char buf2[80] = {0};
tFormatOffset(buf1, 80, &pRsp->reqOffset);
tFormatOffset(buf2, 80, &pRsp->rspOffset);
tqDebug("vgId:%d, from consumer:%" PRId64 ", (epoch %d) push rsp, block num: %d, reqOffset:%s, rspOffset:%s",
TD_VID(pTq->pVnode), pPushEntry->rspHead.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2);
return 0;
}
int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp) { int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp) {
ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum);
ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum);
@ -354,6 +420,8 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
return -1; return -1;
} }
pRsp->withTbName = 0;
#if 0
pRsp->withTbName = pReq->withTbName; pRsp->withTbName = pReq->withTbName;
if (pRsp->withTbName) { if (pRsp->withTbName) {
pRsp->blockTbName = taosArrayInit(0, sizeof(void*)); pRsp->blockTbName = taosArrayInit(0, sizeof(void*));
@ -362,6 +430,7 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
return -1; return -1;
} }
} }
#endif
if (subType == TOPIC_SUB_TYPE__COLUMN) { if (subType == TOPIC_SUB_TYPE__COLUMN) {
pRsp->withSchema = false; pRsp->withSchema = false;
@ -477,11 +546,33 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
SMqDataRsp dataRsp = {0}; SMqDataRsp dataRsp = {0};
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
// lock
taosWLockLatch(&pTq->pushLock);
tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew); tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew);
#if 1 #if 1
if (dataRsp.blockNum == 0 && dataRsp.reqOffset.type == TMQ_OFFSET__LOG &&
dataRsp.reqOffset.version == dataRsp.rspOffset.version) {
STqPushEntry* pPushEntry = taosMemoryCalloc(1, sizeof(STqPushEntry));
if (pPushEntry != NULL) {
pPushEntry->pInfo = pMsg->info;
memcpy(pPushEntry->subKey, pHandle->subKey, TSDB_SUBSCRIBE_KEY_LEN);
dataRsp.withTbName = 0;
memcpy(&pPushEntry->dataRsp, &dataRsp, sizeof(SMqDataRsp));
pPushEntry->rspHead.consumerId = consumerId;
pPushEntry->rspHead.epoch = reqEpoch;
pPushEntry->rspHead.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*));
tqDebug("tmq poll: consumer %ld, subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey,
TD_VID(pTq->pVnode));
// unlock
taosWUnLockLatch(&pTq->pushLock);
return 0;
}
}
taosWUnLockLatch(&pTq->pushLock);
#endif #endif
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
code = -1; code = -1;
} }
@ -614,10 +705,22 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) { int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) {
SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg; SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg;
int32_t code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey)); taosWLockLatch(&pTq->pushLock);
ASSERT(code == 0); int32_t code = taosHashRemove(pTq->pPushMgr, pReq->subKey, strlen(pReq->subKey));
if (code != 0) {
tqDebug("vgId:%d, tq remove push handle %s", pTq->pVnode->config.vgId, pReq->subKey);
}
taosWUnLockLatch(&pTq->pushLock);
tqOffsetDelete(pTq->pOffsetStore, pReq->subKey); code = taosHashRemove(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
if (code != 0) {
tqError("cannot process tq delete req %s, since no such handle", pReq->subKey);
}
code = tqOffsetDelete(pTq->pOffsetStore, pReq->subKey);
if (code != 0) {
tqError("cannot process tq delete req %s, since no such offset", pReq->subKey);
}
if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) { if (tqMetaDeleteHandle(pTq, pReq->subKey) < 0) {
ASSERT(0); ASSERT(0);
@ -756,7 +859,9 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
atomic_add_fetch_32(&pHandle->epoch, 1); atomic_add_fetch_32(&pHandle->epoch, 1);
if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) {
// TODO // TODO
ASSERT(0);
} }
// close handle
} }
return 0; return 0;

View File

@ -15,7 +15,7 @@
#include "tq.h" #include "tq.h"
static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) { int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols) {
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
void* buf = taosMemoryCalloc(1, dataStrLen); void* buf = taosMemoryCalloc(1, dataStrLen);
if (buf == NULL) return -1; if (buf == NULL) return -1;

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