Merge branch 'main' of https://github.com/taosdata/TDengine into test/TD-24996
This commit is contained in:
commit
ef494fd45e
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.6.1.alpha")
|
||||
SET(TD_VER_NUMBER "3.0.7.1.alpha")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -201,7 +201,7 @@ You can use the TDengine CLI to monitor your TDengine deployment and execute ad
|
|||
|
||||
<TabItem label="Windows" value="windows">
|
||||
|
||||
After the installation is complete, please run `sc start taosd` or run `C:\TDengine\taosd.exe` with administrator privilege to start TDengine Server.
|
||||
After the installation is complete, please run `sc start taosd` or run `C:\TDengine\taosd.exe` with administrator privilege to start TDengine Server. Please run `sc start taosadapter` or run `C:\TDengine\taosadapter.exe` with administrator privilege to start taosAdapter to provide http/REST service.
|
||||
|
||||
## Command Line Interface (CLI)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ The following characters cannot occur in a password: single quotation marks ('),
|
|||
- Maximum numbers of databases, STables, tables are dependent only on the system resources.
|
||||
- The number of replicas can only be 1 or 3.
|
||||
- The maximum length of a username is 23 bytes.
|
||||
- The maximum length of a password is 128 bytes.
|
||||
- The maximum length of a password is 31 bytes.
|
||||
- The maximum number of rows depends on system resources.
|
||||
- The maximum number of vnodes in a database is 1024.
|
||||
|
||||
|
|
|
@ -283,6 +283,8 @@ Provides dnode configuration information.
|
|||
| 2 | consumer_group | BINARY(193) | Subscribed consumer group |
|
||||
| 3 | vgroup_id | INT | Vgroup ID for the consumer |
|
||||
| 4 | consumer_id | BIGINT | Consumer ID |
|
||||
| 5 | offset | BINARY(64) | Consumption progress |
|
||||
| 6 | rows | BIGINT | Number of consumption items |
|
||||
|
||||
## INS_STREAMS
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ This statement creates a user account.
|
|||
|
||||
The maximum length of user_name is 23 bytes.
|
||||
|
||||
The maximum length of password is 128 bytes. The password can include leters, digits, and special characters excluding single quotation marks, double quotation marks, backticks, backslashes, and spaces. The password cannot be empty.
|
||||
The maximum length of password is 31 bytes. The password can include leters, digits, and special characters excluding single quotation marks, double quotation marks, backticks, backslashes, and spaces. The password cannot be empty.
|
||||
|
||||
`SYSINFO` indicates whether the user is allowed to view system information. `1` means allowed, `0` means not allowed. System information includes server configuration, dnode, vnode, storage. The default value is `1`.
|
||||
|
||||
|
|
|
@ -28,6 +28,24 @@ Performs pre-aggregation on the specified column over the time window defined by
|
|||
- WATERMARK: Enter a value between 0ms and 900000ms. The most precise unit supported is milliseconds. The default value is 5 seconds. This option can be used only on supertables.
|
||||
- MAX_DELAY: Enter a value between 1ms and 900000ms. The most precise unit supported is milliseconds. The default value is the value of interval provided that it does not exceed 900000ms. This option can be used only on supertables. Note: Retain the default value if possible. Configuring a small MAX_DELAY may cause results to be frequently pushed, affecting storage and query performance.
|
||||
|
||||
```sql
|
||||
DROP DATABASE IF EXISTS d0;
|
||||
CREATE DATABASE d0;
|
||||
USE d0;
|
||||
CREATE TABLE IF NOT EXISTS st1 (ts timestamp, c1 int, c2 float, c3 double) TAGS (t1 int unsigned);
|
||||
CREATE TABLE ct1 USING st1 TAGS(1000);
|
||||
CREATE TABLE ct2 USING st1 TAGS(2000);
|
||||
INSERT INTO ct1 VALUES(now+0s, 10, 2.0, 3.0);
|
||||
INSERT INTO ct1 VALUES(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3);
|
||||
CREATE SMA INDEX sma_index_name1 ON st1 FUNCTION(max(c1),max(c2),min(c1)) INTERVAL(5m,10s) SLIDING(5m) WATERMARK 5s MAX_DELAY 1m;
|
||||
-- query from SMA Index
|
||||
ALTER LOCAL 'querySmaOptimize' '1';
|
||||
SELECT max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m);
|
||||
SELECT _wstart,_wend,_wduration,max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m);
|
||||
-- query from raw data
|
||||
ALTER LOCAL 'querySmaOptimize' '0';
|
||||
```
|
||||
|
||||
### FULLTEXT Indexing
|
||||
|
||||
Creates a text index for the specified column. FULLTEXT indexing improves performance for queries with text filtering. The index_option syntax is not supported for FULLTEXT indexing. FULLTEXT indexing is supported for JSON tag columns only. Multiple columns cannot be indexed together. However, separate indices can be created for each column.
|
||||
|
@ -41,7 +59,6 @@ DROP INDEX index_name;
|
|||
## View Indices
|
||||
|
||||
````sql
|
||||
```sql
|
||||
SHOW INDEXES FROM tbl_name [FROM db_name];
|
||||
````
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ REST connection supports all platforms that can run Java.
|
|||
|
||||
| taos-jdbcdriver version | major changes | TDengine version |
|
||||
| :---------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------: |
|
||||
| 3.2.4 | Subscription add the enable.auto.commit parameter and the unsubscribe() method in the WebSocket connection | 3.0.5.0 or later |
|
||||
| 3.2.3 | Fixed resultSet data parsing failure in some cases | 3.0.5.0 or later |
|
||||
| 3.2.4 | Subscription add the enable.auto.commit parameter and the unsubscribe() method in the WebSocket connection | - |
|
||||
| 3.2.3 | Fixed resultSet data parsing failure in some cases | - |
|
||||
| 3.2.2 | Subscription add seek function | 3.0.5.0 or later |
|
||||
| 3.2.1 | JDBC REST connection supports schemaless/prepareStatement over WebSocket | 3.0.3.0 or later |
|
||||
| 3.2.0 | This version has been deprecated | - |
|
||||
|
@ -1019,11 +1019,13 @@ while(true) {
|
|||
#### Assignment subscription Offset
|
||||
|
||||
```java
|
||||
// get offset
|
||||
long position(TopicPartition partition) throws SQLException;
|
||||
Map<TopicPartition, Long> position(String topic) throws SQLException;
|
||||
Map<TopicPartition, Long> beginningOffsets(String topic) throws SQLException;
|
||||
Map<TopicPartition, Long> endOffsets(String topic) throws SQLException;
|
||||
|
||||
// Overrides the fetch offsets that the consumer will use on the next poll(timeout).
|
||||
void seek(TopicPartition partition, long offset) throws SQLException;
|
||||
```
|
||||
|
||||
|
|
|
@ -87,9 +87,9 @@ TDengine currently supports timestamp, number, character, Boolean type, and the
|
|||
|NCHAR|str|
|
||||
|JSON|str|
|
||||
|
||||
## Installation
|
||||
## Installation Steps
|
||||
|
||||
### Preparation
|
||||
### Pre-installation preparation
|
||||
|
||||
1. Install Python. The recent taospy package requires Python 3.6.2+. The earlier versions of taospy require Python 3.7+. The taos-ws-py package requires Python 3.7+. If Python is not available on your system, refer to the [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) to install it.
|
||||
2. Install [pip](https://pypi.org/project/pip/). In most cases, the Python installer comes with the pip utility. If not, please refer to [pip documentation](https://pip.pypa.io/en/stable/installation/) to install it.
|
||||
|
@ -275,7 +275,7 @@ Transfer-Encoding: chunked
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Using connectors to establish connections
|
||||
### Specify the Host and Properties to get the connection
|
||||
|
||||
The following example code assumes that TDengine is installed locally and that the default configuration is used for both FQDN and serverPort.
|
||||
|
||||
|
@ -331,7 +331,69 @@ The parameter of `connect()` is the url of TDengine, and the protocol is `taosws
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Example program
|
||||
### Priority of configuration parameters
|
||||
|
||||
If the configuration parameters are duplicated in the parameters or client configuration file, the priority of the parameters, from highest to lowest, are as follows:
|
||||
|
||||
1. Parameters in `connect` function.
|
||||
2. the configuration file taos.cfg of the TDengine client driver when using a native connection.
|
||||
|
||||
## Usage examples
|
||||
|
||||
### Create database and tables
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
```python
|
||||
conn = taos.connect()
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
# change database. same as execute "USE db"
|
||||
conn.select_db("test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="REST connection">
|
||||
|
||||
```python
|
||||
conn = taosrest.connect(url="http://localhost:6041")
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
conn.execute("USE test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
```python
|
||||
conn = taosws.connect(url="ws://localhost:6041")
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
conn.execute("USE test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Insert data
|
||||
|
||||
```python
|
||||
conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m, 24.4)")
|
||||
```
|
||||
|
||||
:::
|
||||
now is an internal function. The default is the current time of the client's computer. now + 1s represents the current time of the client plus 1 second, followed by the number representing the unit of time: a (milliseconds), s (seconds), m (minutes), h (hours), d (days), w (weeks), n (months), y (years).
|
||||
:::
|
||||
|
||||
|
||||
### Basic Usage
|
||||
|
||||
|
@ -453,7 +515,7 @@ The `query` method of the `TaosConnection` class can be used to query data and r
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage with req_id
|
||||
### Execute SQL with reqId
|
||||
|
||||
By using the optional req_id parameter, you can specify a request ID that can be used for tracing.
|
||||
|
||||
|
@ -553,221 +615,7 @@ As the way to connect introduced above but add `req_id` argument.
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Subscription
|
||||
|
||||
Connector support data subscription. For more information about subscroption, please refer to [Data Subscription](../../../develop/tmq/).
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
The `consumer` in the connector contains the subscription api.
|
||||
|
||||
##### Create Consumer
|
||||
|
||||
The syntax for creating a consumer is `consumer = Consumer(configs)`. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/).
|
||||
|
||||
```python
|
||||
from taos.tmq import Consumer
|
||||
|
||||
consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
|
||||
```
|
||||
|
||||
##### Subscribe topics
|
||||
|
||||
The `subscribe` function is used to subscribe to a list of topics.
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
##### Consume
|
||||
|
||||
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(1)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
val = res.value()
|
||||
|
||||
for block in val:
|
||||
print(block.fetchall())
|
||||
```
|
||||
|
||||
##### assignment
|
||||
|
||||
The `assignment` function is used to get the assignment of the topic.
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
##### Seek
|
||||
|
||||
The `seek` function is used to reset the assignment of the topic.
|
||||
|
||||
```python
|
||||
tp = TopicPartition(topic='topic1', partition=0, offset=0)
|
||||
consumer.seek(tp)
|
||||
```
|
||||
|
||||
##### After consuming data
|
||||
|
||||
You should unsubscribe to the topics and close the consumer after consuming.
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
##### Tmq subscription example
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_example.py}}
|
||||
```
|
||||
|
||||
##### assignment and seek example
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_assignment_example.py:taos_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
In addition to native connections, the connector also supports subscriptions via websockets.
|
||||
|
||||
##### Create Consumer
|
||||
|
||||
The syntax for creating a consumer is "consumer = consumer = Consumer(conf=configs)". You need to specify that the `td.connect.websocket.scheme` parameter is set to "ws" in the configuration. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/#create-a-consumer).
|
||||
|
||||
```python
|
||||
import taosws
|
||||
|
||||
consumer = taosws.(conf={"group.id": "local", "td.connect.websocket.scheme": "ws"})
|
||||
```
|
||||
|
||||
##### subscribe topics
|
||||
|
||||
The `subscribe` function is used to subscribe to a list of topics.
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
##### Consume
|
||||
|
||||
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(timeout=1.0)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
for block in message:
|
||||
for row in block:
|
||||
print(row)
|
||||
```
|
||||
|
||||
##### assignment
|
||||
|
||||
The `assignment` function is used to get the assignment of the topic.
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
##### Seek
|
||||
|
||||
The `seek` function is used to reset the assignment of the topic.
|
||||
|
||||
```python
|
||||
consumer.seek(topic='topic1', partition=0, offset=0)
|
||||
```
|
||||
|
||||
##### After consuming data
|
||||
|
||||
You should unsubscribe to the topics and close the consumer after consuming.
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
##### Subscription example
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_example.py}}
|
||||
```
|
||||
|
||||
##### Assignment and seek example
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_assgnment_example.py:taosws_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Schemaless Insert
|
||||
|
||||
Connector support schemaless insert.
|
||||
|
||||
<Tabs defaultValue="list">
|
||||
<TabItem value="list" label="List Insert">
|
||||
|
||||
##### Simple insert
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert.py}}
|
||||
```
|
||||
|
||||
##### Insert with ttl argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_ttl.py}}
|
||||
```
|
||||
|
||||
##### Insert with req_id argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="raw" label="Raw Insert">
|
||||
|
||||
##### Simple insert
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw.py}}
|
||||
```
|
||||
|
||||
##### Insert with ttl argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_ttl.py}}
|
||||
```
|
||||
|
||||
##### Insert with req_id argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Parameter Binding
|
||||
### Writing data via parameter binding
|
||||
|
||||
The Python connector provides a parameter binding api for inserting data. Similar to most databases, TDengine currently only supports the question mark `?` to indicate the parameters to be bound.
|
||||
|
||||
|
@ -898,6 +746,264 @@ stmt.close()
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Schemaless Writing
|
||||
|
||||
Connector support schemaless insert.
|
||||
|
||||
<Tabs defaultValue="list">
|
||||
<TabItem value="list" label="List Insert">
|
||||
|
||||
##### Simple insert
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert.py}}
|
||||
```
|
||||
|
||||
##### Insert with ttl argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_ttl.py}}
|
||||
```
|
||||
|
||||
##### Insert with req_id argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="raw" label="Raw Insert">
|
||||
|
||||
##### Simple insert
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw.py}}
|
||||
```
|
||||
|
||||
##### Insert with ttl argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_ttl.py}}
|
||||
```
|
||||
|
||||
##### Insert with req_id argument
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Schemaless with reqId
|
||||
|
||||
There is a optional parameter called `req_id` in `schemaless_insert` and `schemaless_insert_raw` method. This reqId can be used to request link tracing.
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
### Data Subscription
|
||||
|
||||
Connector support data subscription. For more information about subscroption, please refer to [Data Subscription](../../../develop/tmq/).
|
||||
|
||||
#### Create a Topic
|
||||
|
||||
To create topic, please refer to [Data Subscription](../../../develop/tmq/#create-a-topic).
|
||||
|
||||
#### Create a Consumer
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
The consumer in the connector contains the subscription api. The syntax for creating a consumer is consumer = Consumer(configs). For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/#create-a-consumer).
|
||||
|
||||
```python
|
||||
from taos.tmq import Consumer
|
||||
|
||||
consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
In addition to native connections, the connector also supports subscriptions via websockets.
|
||||
|
||||
The syntax for creating a consumer is "consumer = consumer = Consumer(conf=configs)". You need to specify that the `td.connect.websocket.scheme` parameter is set to "ws" in the configuration. For more subscription api parameters, please refer to [Data Subscription](../../../develop/tmq/#create-a-consumer).
|
||||
|
||||
```python
|
||||
import taosws
|
||||
|
||||
consumer = taosws.(conf={"group.id": "local", "td.connect.websocket.scheme": "ws"})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Subscribe to a Topic
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
The `subscribe` function is used to subscribe to a list of topics.
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
The `subscribe` function is used to subscribe to a list of topics.
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Consume messages
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(1)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
val = res.value()
|
||||
|
||||
for block in val:
|
||||
print(block.fetchall())
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
The `poll` function is used to consume data in tmq. The parameter of the `poll` function is a value of type float representing the timeout in seconds. It returns a `Message` before timing out, or `None` on timing out. You have to handle error messages in response data.
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(timeout=1.0)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
for block in message:
|
||||
for row in block:
|
||||
print(row)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Assignment subscription Offset
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
The `assignment` function is used to get the assignment of the topic.
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
The `seek` function is used to reset the assignment of the topic.
|
||||
|
||||
```python
|
||||
tp = TopicPartition(topic='topic1', partition=0, offset=0)
|
||||
consumer.seek(tp)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
The `assignment` function is used to get the assignment of the topic.
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
The `seek` function is used to reset the assignment of the topic.
|
||||
|
||||
```python
|
||||
consumer.seek(topic='topic1', partition=0, offset=0)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Close subscriptions
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
You should unsubscribe to the topics and close the consumer after consuming.
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
You should unsubscribe to the topics and close the consumer after consuming.
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Full Sample Code
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="native connection">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_example.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_assignment_example.py:taos_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket connection">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_example.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_assgnment_example.py:taosws_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Other sample programs
|
||||
|
||||
| Example program links | Example program content |
|
||||
|
|
|
@ -470,3 +470,26 @@ The configuration parameters for subscribing to a super table are set in `super_
|
|||
- **sql**: The SQL command to be executed. For the query SQL of super table, keep "xxxx" in the SQL command. The program will automatically replace it with all the sub-table names of the super table.
|
||||
Replace it with all the sub-table names in the super table.
|
||||
- **result**: The file to save the query result. If not specified, taosBenchmark will not save result.
|
||||
|
||||
#### data type on taosBenchmark
|
||||
|
||||
| # | **TDengine** | **taosBenchmark**
|
||||
| --- | :----------------: | :---------------:
|
||||
| 1 | TIMESTAMP | timestamp
|
||||
| 2 | INT | int
|
||||
| 3 | INT UNSIGNED | uint
|
||||
| 4 | BIGINT | bigint
|
||||
| 5 | BIGINT UNSIGNED | ubigint
|
||||
| 6 | FLOAT | float
|
||||
| 7 | DOUBLE | double
|
||||
| 8 | BINARY | binary
|
||||
| 9 | SMALLINT | smallint
|
||||
| 10 | SMALLINT UNSIGNED | usmallint
|
||||
| 11 | TINYINT | tinyint
|
||||
| 12 | TINYINT UNSIGNED | utinyint
|
||||
| 13 | BOOL | bool
|
||||
| 14 | NCHAR | nchar
|
||||
| 15 | VARCHAR | varchar
|
||||
| 15 | JSON | json
|
||||
|
||||
note:Lowercase characters must be used on taosBenchmark datatype
|
||||
|
|
|
@ -102,7 +102,7 @@ Ensure that your firewall rules do not block TCP port 6042 on any host in the c
|
|||
| Value Range | 10-50000000 |
|
||||
| Default Value | 5000 |
|
||||
|
||||
### numOfRpcSessions
|
||||
### numOfRpcSessions
|
||||
|
||||
| Attribute | Description |
|
||||
| ------------- | ------------------------------------------ |
|
||||
|
@ -202,7 +202,7 @@ Please note the `taoskeeper` needs to be installed and running to create the `lo
|
|||
| Default Value | 0 |
|
||||
| Notes | 0: Disable SMA indexing and perform all queries on non-indexed data; 1: Enable SMA indexing and perform queries from suitable statements on precomputation results. |
|
||||
|
||||
### countAlwaysReturnValue
|
||||
### countAlwaysReturnValue
|
||||
|
||||
| Attribute | Description |
|
||||
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
|
@ -713,6 +713,14 @@ The charset that takes effect is UTF-8.
|
|||
| Value Range | 0: disable UDF; 1: enabled UDF |
|
||||
| Default Value | 1 |
|
||||
|
||||
### ttlChangeOnWrite
|
||||
|
||||
| Attribute | Description |
|
||||
| ------------- | ----------------------------------------------------------------------------- |
|
||||
| Applicable | Server Only |
|
||||
| Meaning | Whether the ttl expiration time changes with the table modification operation |
|
||||
| Value Range | 0: not change; 1: change by modification |
|
||||
| Default Value | 0 |
|
||||
|
||||
## 3.0 Parameters
|
||||
|
||||
|
@ -770,3 +778,4 @@ The charset that takes effect is UTF-8.
|
|||
| 52 | charset | Yes | Yes | |
|
||||
| 53 | udf | Yes | Yes | |
|
||||
| 54 | enableCoreFile | Yes | Yes | |
|
||||
| 55 | ttlChangeOnWrite | No | Yes | |
|
||||
|
|
|
@ -363,7 +363,10 @@ The following configuration items apply to TDengine Sink Connector and TDengine
|
|||
7. `out.format`: Result output format. `line` indicates that the output format is InfluxDB line protocol format, `json` indicates that the output format is json. The default is line.
|
||||
8. `topic.per.stable`: If it's set to true, it means one super table in TDengine corresponds to a topic in Kafka, the topic naming rule is `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`; if it's set to false, it means the whole DB corresponds to a topic in Kafka, the topic naming rule is `<topic.prefix><topic.delimiter><connection.database>`.
|
||||
9. `topic.ignore.db`: Whether the topic naming rule contains the database name: true indicates that the rule is `<topic.prefix><topic.delimiter><stable.name>`, false indicates that the rule is `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`, and the default is false. Does not take effect when `topic.per.stable` is set to false.
|
||||
10. `topic.delimiter`: topic name delimiter,default is `-`。
|
||||
10. `topic.delimiter`: topic name delimiter,default is `-`.
|
||||
11. `read.method`: read method for query TDengine data, query or subscription. default is subscription.
|
||||
12. `subscription.group.id`: subscription group id for subscription data from TDengine, this field is required when `read.method` is subscription.
|
||||
13. `subscription.from`: subscription from latest or earliest. default is latest。
|
||||
|
||||
## Other notes
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.7.0
|
||||
|
||||
<Release type="tdengine" version="3.0.7.0" />
|
||||
|
||||
## 3.0.6.0
|
||||
|
||||
<Release type="tdengine" version="3.0.6.0" />
|
||||
|
|
|
@ -201,7 +201,7 @@ Active: inactive (dead)
|
|||
|
||||
<TabItem label="Windows 系统" value="windows">
|
||||
|
||||
安装后,可以在拥有管理员权限的 cmd 窗口执行 `sc start taosd` 或在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。
|
||||
安装后,可以在拥有管理员权限的 cmd 窗口执行 `sc start taosd` 或在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。如需使用 http/REST 服务,请执行 `sc start taosadapter` 或运行 `taosadapter.exe` 来启动 taosAdapter 服务进程。
|
||||
|
||||
**TDengine 命令行(CLI)**
|
||||
|
||||
|
|
|
@ -1022,11 +1022,13 @@ while(true) {
|
|||
#### 指定订阅 Offset
|
||||
|
||||
```java
|
||||
// 获取 offset
|
||||
long position(TopicPartition partition) throws SQLException;
|
||||
Map<TopicPartition, Long> position(String topic) throws SQLException;
|
||||
Map<TopicPartition, Long> beginningOffsets(String topic) throws SQLException;
|
||||
Map<TopicPartition, Long> endOffsets(String topic) throws SQLException;
|
||||
|
||||
// 指定下一次 poll 中使用的 offset
|
||||
void seek(TopicPartition partition, long offset) throws SQLException;
|
||||
```
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ Python Connector 的所有数据库操作如果出现异常,都会直接抛出
|
|||
{{#include docs/examples/python/handle_exception.py}}
|
||||
```
|
||||
|
||||
TDengine DataType 和 Python DataType
|
||||
## TDengine DataType 和 Python DataType
|
||||
|
||||
TDengine 目前支持时间戳、数字、字符、布尔类型,与 Python 对应类型转换如下:
|
||||
|
||||
|
@ -277,7 +277,7 @@ Transfer-Encoding: chunked
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 使用连接器建立连接
|
||||
### 指定 Host 和 Properties 获取连接
|
||||
|
||||
以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。
|
||||
|
||||
|
@ -333,8 +333,69 @@ Transfer-Encoding: chunked
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 配置参数的优先级
|
||||
|
||||
如果配置参数在参数和客户端配置文件中有重复,则参数的优先级由高到低分别如下:
|
||||
|
||||
1. 连接参数
|
||||
2. 使用原生连接时,TDengine 客户端驱动的配置文件 taos.cfg
|
||||
|
||||
## 使用示例
|
||||
|
||||
### 创建数据库和表
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
```python
|
||||
conn = taos.connect()
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
# change database. same as execute "USE db"
|
||||
conn.select_db("test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="rest" label="REST 连接">
|
||||
|
||||
```python
|
||||
conn = taosrest.connect(url="http://localhost:6041")
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
conn.execute("USE test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
```python
|
||||
conn = taosws.connect(url="ws://localhost:6041")
|
||||
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
|
||||
conn.execute("DROP DATABASE IF EXISTS test")
|
||||
conn.execute("CREATE DATABASE test")
|
||||
conn.execute("USE test")
|
||||
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 插入数据
|
||||
|
||||
```python
|
||||
conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m, 24.4)")
|
||||
```
|
||||
|
||||
:::
|
||||
now 为系统内部函数,默认为客户端所在计算机当前时间。 now + 1s 代表客户端当前时间往后加 1 秒,数字后面代表时间单位:a(毫秒),s(秒),m(分),h(小时),d(天),w(周),n(月),y(年)。
|
||||
:::
|
||||
|
||||
### 基本使用
|
||||
|
||||
<Tabs defaultValue="rest">
|
||||
|
@ -373,7 +434,6 @@ Transfer-Encoding: chunked
|
|||
|
||||
:::note
|
||||
TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
|
@ -456,7 +516,7 @@ RestClient 类是对于 REST API 的直接封装。它只包含一个 sql() 方
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 与 req_id 一起使用
|
||||
### 执行带有 reqId 的 SQL
|
||||
|
||||
使用可选的 req_id 参数,指定请求 id,可以用于 tracing
|
||||
|
||||
|
@ -557,224 +617,6 @@ RestClient 类是对于 REST API 的直接封装。它只包含一个 sql() 方
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 数据订阅
|
||||
|
||||
连接器支持数据订阅功能,数据订阅功能请参考 [数据订阅文档](../../develop/tmq/)。
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
`Consumer` 提供了 Python 连接器订阅 TMQ 数据的 API。
|
||||
|
||||
##### 创建 Consumer
|
||||
|
||||
创建 Consumer 语法为 `consumer = Consumer(configs)`,参数定义请参考 [数据订阅文档](../../develop/tmq/#%E5%88%9B%E5%BB%BA%E6%B6%88%E8%B4%B9%E8%80%85-consumer)。
|
||||
|
||||
```python
|
||||
from taos.tmq import Consumer
|
||||
|
||||
consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
|
||||
```
|
||||
|
||||
##### 订阅 topics
|
||||
|
||||
Consumer API 的 `subscribe` 方法用于订阅 topics,consumer 支持同时订阅多个 topic。
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
##### 消费数据
|
||||
|
||||
Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。消费者必须通过 Message 的 `error()` 方法校验返回数据的 error 信息。
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(1)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
val = res.value()
|
||||
|
||||
for block in val:
|
||||
print(block.fetchall())
|
||||
```
|
||||
|
||||
##### 获取消费进度
|
||||
|
||||
Consumer API 的 `assignment` 方法用于获取 Consumer 订阅的所有 topic 的消费进度,返回结果类型为 TopicPartition 列表。
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
##### 指定订阅 Offset
|
||||
|
||||
Consumer API 的 `seek` 方法用于重置 Consumer 的消费进度到指定位置,方法参数类型为 TopicPartition。
|
||||
|
||||
```python
|
||||
tp = TopicPartition(topic='topic1', partition=0, offset=0)
|
||||
consumer.seek(tp)
|
||||
```
|
||||
|
||||
##### 关闭订阅
|
||||
|
||||
消费结束后,应当取消订阅,并关闭 Consumer。
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
##### 完整示例
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_example.py}}
|
||||
```
|
||||
|
||||
##### 获取和重置消费进度示例代码
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_assignment_example.py:taos_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
除了原生的连接方式,Python 连接器还支持通过 websocket 订阅 TMQ 数据,使用 websocket 方式订阅 TMQ 数据需要安装 `taos-ws-py`。
|
||||
|
||||
taosws `Consumer` API 提供了基于 Websocket 订阅 TMQ 数据的 API。
|
||||
|
||||
##### 创建 Consumer
|
||||
|
||||
创建 Consumer 语法为 `consumer = Consumer(conf=configs)`,使用时需要指定 `td.connect.websocket.scheme` 参数值为 "ws",参数定义请参考 [数据订阅文档](../../develop/tmq/#%E5%88%9B%E5%BB%BA%E6%B6%88%E8%B4%B9%E8%80%85-consumer)。
|
||||
|
||||
```python
|
||||
import taosws
|
||||
|
||||
consumer = taosws.(conf={"group.id": "local", "td.connect.websocket.scheme": "ws"})
|
||||
```
|
||||
|
||||
##### 订阅 topics
|
||||
|
||||
Consumer API 的 `subscribe` 方法用于订阅 topics,consumer 支持同时订阅多个 topic。
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
##### 消费数据
|
||||
|
||||
Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。消费者必须通过 Message 的 `error()` 方法校验返回数据的 error 信息。
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(timeout=1.0)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
for block in message:
|
||||
for row in block:
|
||||
print(row)
|
||||
```
|
||||
|
||||
##### 获取消费进度
|
||||
|
||||
Consumer API 的 `assignment` 方法用于获取 Consumer 订阅的所有 topic 的消费进度,返回结果类型为 TopicPartition 列表。
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
##### 重置消费进度
|
||||
|
||||
Consumer API 的 `seek` 方法用于重置 Consumer 的消费进度到指定位置。
|
||||
|
||||
```python
|
||||
consumer.seek(topic='topic1', partition=0, offset=0)
|
||||
```
|
||||
|
||||
##### 结束消费
|
||||
|
||||
消费结束后,应当取消订阅,并关闭 Consumer。
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
##### tmq 订阅示例代码
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_example.py}}
|
||||
```
|
||||
|
||||
连接器提供了 `assignment` 接口,用于获取 topic assignment 的功能,可以查询订阅的 topic 的消费进度,并提供 `seek` 接口,用于重置 topic 的消费进度。
|
||||
|
||||
##### 获取和重置消费进度示例代码
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_assgnment_example.py:taosws_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 无模式写入
|
||||
|
||||
连接器支持无模式写入功能。
|
||||
|
||||
<Tabs defaultValue="list">
|
||||
<TabItem value="list" label="List 写入">
|
||||
|
||||
##### 简单写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert.py}}
|
||||
```
|
||||
|
||||
##### 带有 ttl 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_ttl.py}}
|
||||
```
|
||||
|
||||
##### 带有 req_id 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="raw" label="Raw 写入">
|
||||
|
||||
##### 简单写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw.py}}
|
||||
```
|
||||
|
||||
##### 带有 ttl 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_ttl.py}}
|
||||
```
|
||||
|
||||
##### 带有 req_id 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 通过参数绑定写入数据
|
||||
|
||||
TDengine 的 Python 连接器支持参数绑定风格的 Prepare API 方式写入数据,和大多数数据库类似,目前仅支持用 `?` 来代表待绑定的参数。
|
||||
|
@ -910,6 +752,264 @@ stmt.close()
|
|||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 无模式写入
|
||||
|
||||
连接器支持无模式写入功能。
|
||||
|
||||
<Tabs defaultValue="list">
|
||||
<TabItem value="list" label="List 写入">
|
||||
|
||||
##### 简单写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert.py}}
|
||||
```
|
||||
|
||||
##### 带有 ttl 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_ttl.py}}
|
||||
```
|
||||
|
||||
##### 带有 req_id 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="raw" label="Raw 写入">
|
||||
|
||||
##### 简单写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw.py}}
|
||||
```
|
||||
|
||||
##### 带有 ttl 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_ttl.py}}
|
||||
```
|
||||
|
||||
##### 带有 req_id 参数的写入
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 执行带有 reqId 的无模式写入
|
||||
|
||||
连接器的 `schemaless_insert` 和 `schemaless_insert_raw` 方法支持 `req_id` 可选参数,此 `req_Id` 可用于请求链路追踪。
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_req_id.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/schemaless_insert_raw_req_id.py}}
|
||||
```
|
||||
|
||||
### 数据订阅
|
||||
|
||||
连接器支持数据订阅功能,数据订阅功能请参考 [数据订阅文档](../../develop/tmq/)。
|
||||
|
||||
#### 创建 Topic
|
||||
|
||||
创建 Topic 相关请参考 [数据订阅文档](../../develop/tmq/#创建-topic)。
|
||||
|
||||
#### 创建 Consumer
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
`Consumer` 提供了 Python 连接器订阅 TMQ 数据的 API。创建 Consumer 语法为 `consumer = Consumer(configs)`,参数定义请参考 [数据订阅文档](../../develop/tmq/#创建消费者-consumer)。
|
||||
|
||||
```python
|
||||
from taos.tmq import Consumer
|
||||
|
||||
consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
除了原生的连接方式,Python 连接器还支持通过 websocket 订阅 TMQ 数据,使用 websocket 方式订阅 TMQ 数据需要安装 `taos-ws-py`。
|
||||
|
||||
taosws `Consumer` API 提供了基于 Websocket 订阅 TMQ 数据的 API。创建 Consumer 语法为 `consumer = Consumer(conf=configs)`,使用时需要指定 `td.connect.websocket.scheme` 参数值为 "ws",参数定义请参考 [数据订阅文档](../../develop/tmq/#%E5%88%9B%E5%BB%BA%E6%B6%88%E8%B4%B9%E8%80%85-consumer)。
|
||||
|
||||
```python
|
||||
import taosws
|
||||
|
||||
consumer = taosws.(conf={"group.id": "local", "td.connect.websocket.scheme": "ws"})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### 订阅 topics
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
Consumer API 的 `subscribe` 方法用于订阅 topics,consumer 支持同时订阅多个 topic。
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
Consumer API 的 `subscribe` 方法用于订阅 topics,consumer 支持同时订阅多个 topic。
|
||||
|
||||
```python
|
||||
consumer.subscribe(['topic1', 'topic2'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### 消费数据
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。消费者必须通过 Message 的 `error()` 方法校验返回数据的 error 信息。
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(1)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
val = res.value()
|
||||
|
||||
for block in val:
|
||||
print(block.fetchall())
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
Consumer API 的 `poll` 方法用于消费数据,`poll` 方法接收一个 float 类型的超时时间,超时时间单位为秒(s),`poll` 方法在超时之前返回一条 Message 类型的数据或超时返回 `None`。消费者必须通过 Message 的 `error()` 方法校验返回数据的 error 信息。
|
||||
|
||||
```python
|
||||
while True:
|
||||
res = consumer.poll(timeout=1.0)
|
||||
if not res:
|
||||
continue
|
||||
err = res.error()
|
||||
if err is not None:
|
||||
raise err
|
||||
for block in message:
|
||||
for row in block:
|
||||
print(row)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### 获取消费进度
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
Consumer API 的 `assignment` 方法用于获取 Consumer 订阅的所有 topic 的消费进度,返回结果类型为 TopicPartition 列表。
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
Consumer API 的 `seek` 方法用于重置 Consumer 的消费进度到指定位置,方法参数类型为 TopicPartition。
|
||||
|
||||
```python
|
||||
tp = TopicPartition(topic='topic1', partition=0, offset=0)
|
||||
consumer.seek(tp)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
Consumer API 的 `assignment` 方法用于获取 Consumer 订阅的所有 topic 的消费进度,返回结果类型为 TopicPartition 列表。
|
||||
|
||||
```python
|
||||
assignments = consumer.assignment()
|
||||
```
|
||||
|
||||
Consumer API 的 `seek` 方法用于重置 Consumer 的消费进度到指定位置。
|
||||
|
||||
```python
|
||||
consumer.seek(topic='topic1', partition=0, offset=0)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### 关闭订阅
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
消费结束后,应当取消订阅,并关闭 Consumer。
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
消费结束后,应当取消订阅,并关闭 Consumer。
|
||||
|
||||
```python
|
||||
consumer.unsubscribe()
|
||||
consumer.close()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### 完整示例
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
|
||||
<TabItem value="native" label="原生连接">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_example.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_assignment_example.py:taos_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="websocket" label="WebSocket 连接">
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_example.py}}
|
||||
```
|
||||
|
||||
```python
|
||||
{{#include docs/examples/python/tmq_websocket_assgnment_example.py:taosws_get_assignment_and_seek_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 更多示例程序
|
||||
|
||||
| 示例程序链接 | 示例程序内容 |
|
||||
|
|
|
@ -36,7 +36,7 @@ description: 合法字符集和命名中的限制规则
|
|||
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
|
||||
- 数据库的副本数只能设置为 1 或 3
|
||||
- 用户名的最大长度是 23 字节
|
||||
- 用户密码的最大长度是 128 字节
|
||||
- 用户密码的最大长度是 31 字节
|
||||
- 总数据行数取决于可用资源
|
||||
- 单个数据库的虚拟结点数上限为 1024
|
||||
|
||||
|
|
|
@ -284,6 +284,8 @@ TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数
|
|||
| 2 | consumer_group | BINARY(193) | 订阅者的消费者组 |
|
||||
| 3 | vgroup_id | INT | 消费者被分配的 vgroup id |
|
||||
| 4 | consumer_id | BIGINT | 消费者的唯一 id |
|
||||
| 5 | offset | BINARY(64) | 消费者的消费进度 |
|
||||
| 6 | rows | BIGINT | 消费者的消费的数据条数 |
|
||||
|
||||
## INS_STREAMS
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ CREATE USER use_name PASS 'password' [SYSINFO {1|0}];
|
|||
|
||||
use_name 最长为 23 字节。
|
||||
|
||||
password 最长为 128 字节,合法字符包括"a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/",不可以出现单双引号、撇号、反斜杠和空格,且不可以为空。
|
||||
password 最长为 31 字节,合法字符包括"a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/",不可以出现单双引号、撇号、反斜杠和空格,且不可以为空。
|
||||
|
||||
SYSINFO 表示用户是否可以查看系统信息。1 表示可以查看,0 表示不可以查看。系统信息包括服务端配置信息、服务端各种节点信息(如 DNODE、QNODE等)、存储相关的信息等。默认为可以查看系统信息。
|
||||
|
||||
|
|
|
@ -28,6 +28,24 @@ functions:
|
|||
- WATERMARK: 最小单位毫秒,取值范围 [0ms, 900000ms],默认值为 5 秒,只可用于超级表。
|
||||
- MAX_DELAY: 最小单位毫秒,取值范围 [1ms, 900000ms],默认值为 interval 的值(但不能超过最大值),只可用于超级表。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。
|
||||
|
||||
```sql
|
||||
DROP DATABASE IF EXISTS d0;
|
||||
CREATE DATABASE d0;
|
||||
USE d0;
|
||||
CREATE TABLE IF NOT EXISTS st1 (ts timestamp, c1 int, c2 float, c3 double) TAGS (t1 int unsigned);
|
||||
CREATE TABLE ct1 USING st1 TAGS(1000);
|
||||
CREATE TABLE ct2 USING st1 TAGS(2000);
|
||||
INSERT INTO ct1 VALUES(now+0s, 10, 2.0, 3.0);
|
||||
INSERT INTO ct1 VALUES(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3);
|
||||
CREATE SMA INDEX sma_index_name1 ON st1 FUNCTION(max(c1),max(c2),min(c1)) INTERVAL(5m,10s) SLIDING(5m) WATERMARK 5s MAX_DELAY 1m;
|
||||
-- 从 SMA 索引查询
|
||||
ALTER LOCAL 'querySmaOptimize' '1';
|
||||
SELECT max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m);
|
||||
SELECT _wstart,_wend,_wduration,max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m);
|
||||
-- 从原始数据查询
|
||||
ALTER LOCAL 'querySmaOptimize' '0';
|
||||
```
|
||||
|
||||
### FULLTEXT 索引
|
||||
|
||||
对指定列建立文本索引,可以提升含有文本过滤的查询的性能。FULLTEXT 索引不支持 index_option 语法。现阶段只支持对 JSON 类型的标签列创建 FULLTEXT 索引。不支持多列联合索引,但可以为每个列分布创建 FULLTEXT 索引。
|
||||
|
@ -41,7 +59,6 @@ DROP INDEX index_name;
|
|||
## 查看索引
|
||||
|
||||
````sql
|
||||
```sql
|
||||
SHOW INDEXES FROM tbl_name [FROM db_name];
|
||||
````
|
||||
|
||||
|
|
|
@ -437,3 +437,29 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
|
|||
|
||||
- **sqls** :
|
||||
- **sql** : 执行的 SQL 命令,必填。
|
||||
|
||||
#### 配置文件中数据类型书写对照表
|
||||
|
||||
| # | **引擎** | **taosBenchmark**
|
||||
| --- | :----------------: | :---------------:
|
||||
| 1 | TIMESTAMP | timestamp
|
||||
| 2 | INT | int
|
||||
| 3 | INT UNSIGNED | uint
|
||||
| 4 | BIGINT | bigint
|
||||
| 5 | BIGINT UNSIGNED | ubigint
|
||||
| 6 | FLOAT | float
|
||||
| 7 | DOUBLE | double
|
||||
| 8 | BINARY | binary
|
||||
| 9 | SMALLINT | smallint
|
||||
| 10 | SMALLINT UNSIGNED | usmallint
|
||||
| 11 | TINYINT | tinyint
|
||||
| 12 | TINYINT UNSIGNED | utinyint
|
||||
| 13 | BOOL | bool
|
||||
| 14 | NCHAR | nchar
|
||||
| 15 | VARCHAR | varchar
|
||||
| 15 | JSON | json
|
||||
|
||||
注意:taosBenchmark 配置文件中数据类型必须小写方可识别
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ taos -C
|
|||
| 取值范围 | 10-50000000 |
|
||||
| 缺省值 | 5000 |
|
||||
|
||||
### numOfRpcSessions
|
||||
### numOfRpcSessions
|
||||
|
||||
| 属性 | 说明 |
|
||||
| --------| ---------------------- |
|
||||
|
@ -120,7 +120,7 @@ taos -C
|
|||
| 缺省值 | 500000 |
|
||||
|
||||
|
||||
### numOfRpcSessions
|
||||
### numOfRpcSessions
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ---------------------------- |
|
||||
|
@ -717,6 +717,15 @@ charset 的有效值是 UTF-8。
|
|||
| 取值范围 | 0: 不启动;1:启动 |
|
||||
| 缺省值 | 1 |
|
||||
|
||||
### ttlChangeOnWrite
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------ |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | ttl 到期时间是否伴随表的修改操作改变 |
|
||||
| 取值范围 | 0: 不改变;1:改变 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
## 压缩参数
|
||||
|
||||
### compressMsgSize
|
||||
|
@ -784,6 +793,7 @@ charset 的有效值是 UTF-8。
|
|||
| 52 | charset | 是 | 是 | |
|
||||
| 53 | udf | 是 | 是 | |
|
||||
| 54 | enableCoreFile | 是 | 是 | |
|
||||
| 55 | ttlChangeOnWrite | 否 | 是 | |
|
||||
|
||||
## 2.x->3.0 的废弃参数
|
||||
|
||||
|
|
|
@ -369,6 +369,9 @@ curl -X DELETE http://localhost:8083/connectors/TDengineSourceConnector
|
|||
8. `topic.per.stable`: 如果设置为 true,表示一个超级表对应一个 Kafka topic,topic的命名规则 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`;如果设置为 false,则指定的 DB 中的所有数据进入一个 Kafka topic,topic 的命名规则为 `<topic.prefix><topic.delimiter><connection.database>`
|
||||
9. `topic.ignore.db`: topic 命名规则是否包含 database 名称,true 表示规则为 `<topic.prefix><topic.delimiter><stable.name>`,false 表示规则为 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`,默认 false。此配置项在 `topic.per.stable` 设置为 false 时不生效。
|
||||
10. `topic.delimiter`: topic 名称分割符,默认为 `-`。
|
||||
11. `read.method`: 从 TDengine 读取数据方式,query 或是 subscription。默认为 subscription。
|
||||
12. `subscription.group.id`: 指定 TDengine 数据订阅的组 id,当 `read.method` 为 subscription 时,此项为必填项。
|
||||
13. `subscription.from`: 指定 TDengine 数据订阅起始位置,latest 或是 earliest。默认为 latest。
|
||||
|
||||
## 其他说明
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.7.0
|
||||
|
||||
<Release type="tdengine" version="3.0.7.0" />
|
||||
|
||||
## 3.0.6.0
|
||||
|
||||
<Release type="tdengine" version="3.0.6.0" />
|
||||
|
|
|
@ -36,7 +36,11 @@ dotnet build -c Release
|
|||
## Usage
|
||||
|
||||
```
|
||||
Usage: mono taosdemo.exe [OPTION...]
|
||||
Usage with mono:
|
||||
$ mono taosdemo.exe [OPTION...]
|
||||
|
||||
Usage with dotnet:
|
||||
Usage: .\bin\Release\net5.0\taosdemo.exe [OPTION...]
|
||||
|
||||
--help Show usage.
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace TDengineDriver
|
|||
{
|
||||
if ("--help" == argv[i])
|
||||
{
|
||||
Console.WriteLine("Usage: mono taosdemo.exe [OPTION...]");
|
||||
Console.WriteLine("Usage: taosdemo.exe [OPTION...]");
|
||||
Console.WriteLine("");
|
||||
HelpPrint("--help", "Show usage.");
|
||||
Console.WriteLine("");
|
||||
|
@ -305,7 +305,7 @@ namespace TDengineDriver
|
|||
this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
|
||||
if (this.conn == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("Connect to TDengine failed");
|
||||
Console.WriteLine("Connect to TDengine failed. Reason: {0}\n", TDengine.Error(0));
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3371,6 +3371,12 @@ typedef struct {
|
|||
int8_t reserved;
|
||||
} SMqHbRsp;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
int64_t consumerId;
|
||||
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
} SMqSeekReq;
|
||||
|
||||
#define TD_AUTO_CREATE_TABLE 0x1
|
||||
typedef struct {
|
||||
int64_t suid;
|
||||
|
@ -3500,6 +3506,8 @@ int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
|||
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
|
||||
int32_t tDeatroySMqHbReq(SMqHbReq* pReq);
|
||||
|
||||
int32_t tSerializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq);
|
||||
int32_t tDeserializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq);
|
||||
|
||||
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
|
||||
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
||||
|
|
|
@ -306,7 +306,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SUBSCRIBE, "vnode-tmq-subscribe", SMqRebVgReq, SMqRebVgRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_DELETE_SUB, "vnode-tmq-delete-sub", SMqVDeleteReq, SMqVDeleteRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_COMMIT_OFFSET, "vnode-tmq-commit-offset", STqOffset, STqOffset)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SEEK_TO_OFFSET, "vnode-tmq-seekto-offset", STqOffset, STqOffset)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SEEK, "vnode-tmq-seek", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_ADD_CHECKINFO, "vnode-tmq-add-checkinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_DEL_CHECKINFO, "vnode-del-checkinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_CONSUME, "vnode-tmq-consume", SMqPollReq, SMqDataBlkRsp)
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct SParseContext {
|
|||
bool isSuperUser;
|
||||
bool enableSysInfo;
|
||||
bool async;
|
||||
bool hasInvisibleCol;
|
||||
const char* svrVer;
|
||||
bool nodeOffline;
|
||||
SArray* pTableMetaPos; // sql table pos => catalog data pos
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct SFilterColumnParam {
|
|||
} SFilterColumnParam;
|
||||
|
||||
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
|
||||
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis,
|
||||
extern int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis,
|
||||
int16_t numOfCols, int32_t *pFilterResStatus);
|
||||
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
|
||||
|
|
|
@ -764,6 +764,9 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
||||
#define TSDB_CODE_INDEX_INVALID_FILE TAOS_DEF_ERROR_CODE(0, 0x3201)
|
||||
|
||||
//scalar
|
||||
#define TSDB_CODE_SCALAR_CONVERT_ERROR TAOS_DEF_ERROR_CODE(0, 0x3250)
|
||||
|
||||
//tmq
|
||||
#define TSDB_CODE_TMQ_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x4000)
|
||||
#define TSDB_CODE_TMQ_CONSUMER_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x4001)
|
||||
|
@ -771,6 +774,10 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TMQ_CONSUMER_ERROR TAOS_DEF_ERROR_CODE(0, 0x4003)
|
||||
#define TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x4004)
|
||||
#define TSDB_CODE_TMQ_GROUP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x4005)
|
||||
#define TSDB_CODE_TMQ_SNAPSHOT_ERROR TAOS_DEF_ERROR_CODE(0, 0x4006)
|
||||
#define TSDB_CODE_TMQ_VERSION_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x4007)
|
||||
#define TSDB_CODE_TMQ_INVALID_VGID TAOS_DEF_ERROR_CODE(0, 0x4008)
|
||||
#define TSDB_CODE_TMQ_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x4009)
|
||||
|
||||
// stream
|
||||
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
|
||||
|
|
|
@ -87,7 +87,7 @@ os.system("rm -rf /tmp/dumpdata/*")
|
|||
# dump data out
|
||||
print("taosdump dump out data")
|
||||
|
||||
os.system("taosdump -o /tmp/dumpdata -D test -y -h %s "%serverHost)
|
||||
os.system("taosdump -o /tmp/dumpdata -D test -h %s "%serverHost)
|
||||
|
||||
# drop database of test
|
||||
print("drop database test")
|
||||
|
@ -95,7 +95,7 @@ os.system(" taos -s ' drop database test ;' -h %s "%serverHost)
|
|||
|
||||
# dump data in
|
||||
print("taosdump dump data in")
|
||||
os.system("taosdump -i /tmp/dumpdata -y -h %s "%serverHost)
|
||||
os.system("taosdump -i /tmp/dumpdata -h %s "%serverHost)
|
||||
|
||||
result = conn.query("SELECT count(*) from test.meters")
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ function wgetFile {
|
|||
file=$1
|
||||
versionPath=$2
|
||||
sourceP=$3
|
||||
nasServerIP="192.168.1.131"
|
||||
nasServerIP="192.168.1.213"
|
||||
packagePath="/nas/TDengine/v${versionPath}/${verMode}"
|
||||
if [ -f ${file} ];then
|
||||
echoColor YD "${file} already exists ,it will delete it and download it again "
|
||||
|
|
|
@ -137,7 +137,6 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
|
|||
vgInfo->hashSuffix = rsp->hashSuffix;
|
||||
vgInfo->vgHash = taosHashInit(rsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == vgInfo->vgHash) {
|
||||
taosMemoryFree(vgInfo);
|
||||
tscError("hash init[%d] failed", rsp->vgNum);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
|
@ -147,8 +146,6 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
|
|||
SVgroupInfo *pInfo = taosArrayGet(rsp->pVgroupInfos, j);
|
||||
if (taosHashPut(vgInfo->vgHash, &pInfo->vgId, sizeof(int32_t), pInfo, sizeof(SVgroupInfo)) != 0) {
|
||||
tscError("hash push failed, errno:%d", errno);
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
taosMemoryFree(vgInfo);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
|
@ -486,7 +483,6 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
|||
if (code) {
|
||||
taosArrayDestroy(desc.subDesc);
|
||||
desc.subDesc = NULL;
|
||||
desc.subPlanNum = 0;
|
||||
}
|
||||
desc.subPlanNum = taosArrayGetSize(desc.subDesc);
|
||||
} else {
|
||||
|
@ -592,7 +588,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
strncpy(user->user, pTscObj->user, TSDB_USER_LEN);
|
||||
tstrncpy(user->user, pTscObj->user, TSDB_USER_LEN);
|
||||
user->version = htonl(-1); // force get userAuthInfo
|
||||
kv.valueLen = sizeof(SUserAuthVersion);
|
||||
kv.value = user;
|
||||
|
|
|
@ -1286,6 +1286,10 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
taosArrayPush(pArray, &pVgData);
|
||||
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == pQuery) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_ALTER_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
|
|
|
@ -456,7 +456,7 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
static inline int32_t smlParseMetricFromJSON(SSmlHandle *info, cJSON *metric, SSmlLineInfo *elements) {
|
||||
elements->measureLen = strlen(metric->valuestring);
|
||||
if (IS_INVALID_TABLE_LEN(elements->measureLen)) {
|
||||
uError("OTD:0x%" PRIx64 " Metric lenght is 0 or large than 192", info->id);
|
||||
uError("OTD:0x%" PRIx64 " Metric length is 0 or large than 192", info->id);
|
||||
return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ enum {
|
|||
typedef struct SVgOffsetInfo {
|
||||
STqOffsetVal committedOffset;
|
||||
STqOffsetVal currentOffset;
|
||||
STqOffsetVal seekOffset; // the first version in block for seek operation
|
||||
int64_t walVerBegin;
|
||||
int64_t walVerEnd;
|
||||
} SVgOffsetInfo;
|
||||
|
@ -151,7 +152,7 @@ typedef struct {
|
|||
int32_t vgId;
|
||||
int32_t vgStatus;
|
||||
int32_t vgSkipCnt; // here used to mark the slow vgroups
|
||||
bool receivedInfoFromVnode; // has already received info from vnode
|
||||
// bool receivedInfoFromVnode; // has already received info from vnode
|
||||
int64_t emptyBlockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data
|
||||
bool seekUpdated; // offset is updated by seek operator, therefore, not update by vnode rsp.
|
||||
SEpSet epSet;
|
||||
|
@ -214,6 +215,11 @@ typedef struct SMqVgCommon {
|
|||
int32_t code;
|
||||
} SMqVgCommon;
|
||||
|
||||
typedef struct SMqSeekParam {
|
||||
tsem_t sem;
|
||||
int32_t code;
|
||||
} SMqSeekParam;
|
||||
|
||||
typedef struct SMqVgWalInfoParam {
|
||||
int32_t vgId;
|
||||
int32_t epoch;
|
||||
|
@ -678,6 +684,8 @@ static void asyncCommitOffset(tmq_t* tmq, const TAOS_RES* pRes, int32_t type, tm
|
|||
taosMemoryFree(pParamSet);
|
||||
pCommitFp(tmq, code, userParam);
|
||||
}
|
||||
// update the offset value.
|
||||
pVg->offsetInfo.committedOffset = pVg->offsetInfo.currentOffset;
|
||||
} else { // do not perform commit, callback user function directly.
|
||||
taosMemoryFree(pParamSet);
|
||||
pCommitFp(tmq, code, userParam);
|
||||
|
@ -819,7 +827,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1);
|
||||
offRows->vgId = pVg->vgId;
|
||||
offRows->rows = pVg->numOfRows;
|
||||
offRows->offset = pVg->offsetInfo.currentOffset;
|
||||
offRows->offset = pVg->offsetInfo.seekOffset;
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset);
|
||||
tscInfo("consumer:0x%" PRIx64 ",report offset: vgId:%d, offset:%s, rows:%"PRId64, tmq->consumerId, offRows->vgId, buf, offRows->rows);
|
||||
|
@ -1424,7 +1432,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tDecoderClear(&decoder);
|
||||
memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead));
|
||||
|
||||
char buf[TSDB_OFFSET_LEN];
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pRspWrapper->dataRsp.rspOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64,
|
||||
tmq->consumerId, vgId, pRspWrapper->dataRsp.reqOffset.version, buf, rspType, requestId);
|
||||
|
@ -1477,6 +1485,7 @@ CREATE_MSG_FAIL:
|
|||
typedef struct SVgroupSaveInfo {
|
||||
STqOffsetVal currentOffset;
|
||||
STqOffsetVal commitOffset;
|
||||
STqOffsetVal seekOffset;
|
||||
int64_t numOfRows;
|
||||
} SVgroupSaveInfo;
|
||||
|
||||
|
@ -1516,10 +1525,11 @@ static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopic
|
|||
|
||||
clientVg.offsetInfo.currentOffset = pInfo ? pInfo->currentOffset : offsetNew;
|
||||
clientVg.offsetInfo.committedOffset = pInfo ? pInfo->commitOffset : offsetNew;
|
||||
clientVg.offsetInfo.seekOffset = pInfo ? pInfo->seekOffset : offsetNew;
|
||||
clientVg.offsetInfo.walVerBegin = -1;
|
||||
clientVg.offsetInfo.walVerEnd = -1;
|
||||
clientVg.seekUpdated = false;
|
||||
clientVg.receivedInfoFromVnode = false;
|
||||
// clientVg.receivedInfoFromVnode = false;
|
||||
|
||||
taosArrayPush(pTopic->vgs, &clientVg);
|
||||
}
|
||||
|
@ -1570,12 +1580,12 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp)
|
|||
SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j);
|
||||
makeTopicVgroupKey(vgKey, pTopicCur->topicName, pVgCur->vgId);
|
||||
|
||||
char buf[TSDB_OFFSET_LEN];
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVgCur->offsetInfo.currentOffset);
|
||||
tscInfo("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, pVgCur->vgId,
|
||||
vgKey, buf);
|
||||
|
||||
SVgroupSaveInfo info = {.currentOffset = pVgCur->offsetInfo.currentOffset, .commitOffset = pVgCur->offsetInfo.committedOffset, .numOfRows = pVgCur->numOfRows};
|
||||
SVgroupSaveInfo info = {.currentOffset = pVgCur->offsetInfo.currentOffset, .seekOffset = pVgCur->offsetInfo.seekOffset, .commitOffset = pVgCur->offsetInfo.committedOffset, .numOfRows = pVgCur->numOfRows};
|
||||
taosHashPut(pVgOffsetHashMap, vgKey, strlen(vgKey), &info, sizeof(SVgroupSaveInfo));
|
||||
}
|
||||
}
|
||||
|
@ -1798,7 +1808,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
sendInfo->msgType = TDMT_VND_TMQ_CONSUME;
|
||||
|
||||
int64_t transporterId = 0;
|
||||
char offsetFormatBuf[TSDB_OFFSET_LEN];
|
||||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.currentOffset);
|
||||
|
||||
tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64, pTmq->consumerId,
|
||||
|
@ -1877,6 +1887,24 @@ static int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* p
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void updateVgInfo(SMqClientVg* pVg, STqOffsetVal* reqOffset, STqOffsetVal* rspOffset, int64_t sver, int64_t ever, int64_t consumerId){
|
||||
if (!pVg->seekUpdated) {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is update, since seekupdate not set", consumerId);
|
||||
pVg->offsetInfo.seekOffset = *reqOffset;
|
||||
pVg->offsetInfo.currentOffset = *rspOffset;
|
||||
} else {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is NOT update, since seekupdate is set", consumerId);
|
||||
}
|
||||
|
||||
// update the status
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
|
||||
// update the valid wal version range
|
||||
pVg->offsetInfo.walVerBegin = sver;
|
||||
pVg->offsetInfo.walVerEnd = ever;
|
||||
// pVg->receivedInfoFromVnode = true;
|
||||
}
|
||||
|
||||
static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||
tscDebug("consumer:0x%" PRIx64 " start to handle the rsp, total:%d", tmq->consumerId, tmq->qall->numOfItems);
|
||||
|
||||
|
@ -1925,24 +1953,9 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
pVg->epSet = *pollRspWrapper->pEpset;
|
||||
}
|
||||
|
||||
// update the local offset value only for the returned values, only when the local offset is NOT updated
|
||||
// by tmq_offset_seek function
|
||||
if (!pVg->seekUpdated) {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is update, since seekupdate not set", tmq->consumerId);
|
||||
pVg->offsetInfo.currentOffset = pDataRsp->rspOffset;
|
||||
} else {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is NOT update, since seekupdate is set", tmq->consumerId);
|
||||
}
|
||||
updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset, pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId);
|
||||
|
||||
// update the status
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
|
||||
// update the valid wal version range
|
||||
pVg->offsetInfo.walVerBegin = pDataRsp->head.walsver;
|
||||
pVg->offsetInfo.walVerEnd = pDataRsp->head.walever;
|
||||
pVg->receivedInfoFromVnode = true;
|
||||
|
||||
char buf[TSDB_OFFSET_LEN];
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset);
|
||||
if (pDataRsp->blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64
|
||||
|
@ -1990,11 +2003,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(pollRspWrapper->metaRsp.rspOffset.type != 0){ // if offset is validate
|
||||
pVg->offsetInfo.currentOffset = pollRspWrapper->metaRsp.rspOffset;
|
||||
}
|
||||
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
updateVgInfo(pVg, &pollRspWrapper->metaRsp.rspOffset, &pollRspWrapper->metaRsp.rspOffset, pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId);
|
||||
// build rsp
|
||||
SMqMetaRspObj* pRsp = tmqBuildMetaRspFromWrapper(pollRspWrapper);
|
||||
taosFreeQitem(pollRspWrapper);
|
||||
|
@ -2022,18 +2031,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// update the local offset value only for the returned values, only when the local offset is NOT updated
|
||||
// by tmq_offset_seek function
|
||||
if (!pVg->seekUpdated) {
|
||||
if(pollRspWrapper->taosxRsp.rspOffset.type != 0) { // if offset is validate
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is update, since seekupdate not set", tmq->consumerId);
|
||||
pVg->offsetInfo.currentOffset = pollRspWrapper->taosxRsp.rspOffset;
|
||||
}
|
||||
} else {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is NOT update, since seekupdate is set", tmq->consumerId);
|
||||
}
|
||||
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset, pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId);
|
||||
|
||||
if (pollRspWrapper->taosxRsp.blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
|
@ -2054,7 +2052,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
|
||||
tmq->totalRows += numOfRows;
|
||||
|
||||
char buf[TSDB_OFFSET_LEN];
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.currentOffset);
|
||||
tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64
|
||||
", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
|
@ -2270,9 +2268,11 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
|
|||
int64_t tmq_get_vgroup_offset(TAOS_RES* res) {
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*) res;
|
||||
STqOffsetVal* pOffset = &pRspObj->rsp.rspOffset;
|
||||
STqOffsetVal* pOffset = &pRspObj->rsp.reqOffset;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->rsp.rspOffset.version;
|
||||
return pRspObj->rsp.reqOffset.version;
|
||||
}else{
|
||||
tscError("invalid offset type:%d", pOffset->type);
|
||||
}
|
||||
} else if (TD_RES_TMQ_META(res)) {
|
||||
SMqMetaRspObj* pRspObj = (SMqMetaRspObj*)res;
|
||||
|
@ -2281,9 +2281,11 @@ int64_t tmq_get_vgroup_offset(TAOS_RES* res) {
|
|||
}
|
||||
} else if (TD_RES_TMQ_METADATA(res)) {
|
||||
SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*) res;
|
||||
if (pRspObj->rsp.rspOffset.type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->rsp.rspOffset.version;
|
||||
if (pRspObj->rsp.reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
return pRspObj->rsp.reqOffset.version;
|
||||
}
|
||||
} else{
|
||||
tscError("invalid tmq type:%d", *(int8_t*)res);
|
||||
}
|
||||
|
||||
// data from tsdb, no valid offset info
|
||||
|
@ -2552,6 +2554,8 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tsem_post(&pCommon->rsp);
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pParam);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2567,6 +2571,13 @@ static void destroyCommonInfo(SMqVgCommon* pCommon) {
|
|||
taosMemoryFree(pCommon);
|
||||
}
|
||||
|
||||
static bool isInSnapshotMode(int8_t type, bool useSnapshot){
|
||||
if ((type < TMQ_OFFSET__LOG && useSnapshot) || type > TMQ_OFFSET__LOG) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_assignment** assignment,
|
||||
int32_t* numOfAssignment) {
|
||||
*numOfAssignment = 0;
|
||||
|
@ -2587,6 +2598,15 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
// in case of snapshot is opened, no valid offset will return
|
||||
*numOfAssignment = taosArrayGetSize(pTopic->vgs);
|
||||
for (int32_t j = 0; j < (*numOfAssignment); ++j) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j);
|
||||
int32_t type = pClientVg->offsetInfo.currentOffset.type;
|
||||
if (isInSnapshotMode(type, tmq->useSnapshot)) {
|
||||
tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, assignment not allowed", tmq->consumerId, type);
|
||||
code = TSDB_CODE_TMQ_SNAPSHOT_ERROR;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
*assignment = taosMemoryCalloc(*numOfAssignment, sizeof(tmq_topic_assignment));
|
||||
if (*assignment == NULL) {
|
||||
|
@ -2600,21 +2620,18 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
for (int32_t j = 0; j < (*numOfAssignment); ++j) {
|
||||
SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j);
|
||||
if (!pClientVg->receivedInfoFromVnode) {
|
||||
if (pClientVg->offsetInfo.currentOffset.type != TMQ_OFFSET__LOG) {
|
||||
needFetch = true;
|
||||
break;
|
||||
}
|
||||
|
||||
tmq_topic_assignment* pAssignment = &(*assignment)[j];
|
||||
if (pClientVg->offsetInfo.currentOffset.type == TMQ_OFFSET__LOG) {
|
||||
pAssignment->currentOffset = pClientVg->offsetInfo.currentOffset.version;
|
||||
} else {
|
||||
pAssignment->currentOffset = 0;
|
||||
}
|
||||
|
||||
pAssignment->currentOffset = pClientVg->offsetInfo.seekOffset.version;
|
||||
pAssignment->begin = pClientVg->offsetInfo.walVerBegin;
|
||||
pAssignment->end = pClientVg->offsetInfo.walVerEnd;
|
||||
pAssignment->vgId = pClientVg->vgId;
|
||||
tscInfo("consumer:0x%" PRIx64 " get assignment from local:%d->%" PRId64, tmq->consumerId,
|
||||
pAssignment->vgId, pAssignment->currentOffset);
|
||||
}
|
||||
|
||||
if (needFetch) {
|
||||
|
@ -2648,6 +2665,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
SMqPollReq req = {0};
|
||||
tmqBuildConsumeReqImpl(&req, tmq, 10, pTopic, pClientVg);
|
||||
req.reqOffset = pClientVg->offsetInfo.seekOffset;
|
||||
|
||||
int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req);
|
||||
if (msgSize < 0) {
|
||||
|
@ -2686,11 +2704,11 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
sendInfo->msgType = TDMT_VND_TMQ_VG_WALINFO;
|
||||
|
||||
int64_t transporterId = 0;
|
||||
char offsetFormatBuf[TSDB_OFFSET_LEN];
|
||||
char offsetFormatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pClientVg->offsetInfo.currentOffset);
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64,
|
||||
tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||
tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pClientVg->epSet, &transporterId, sendInfo);
|
||||
}
|
||||
|
||||
|
@ -2717,18 +2735,10 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
}
|
||||
|
||||
SVgOffsetInfo* pOffsetInfo = &pClientVg->offsetInfo;
|
||||
|
||||
pOffsetInfo->currentOffset.type = TMQ_OFFSET__LOG;
|
||||
|
||||
char offsetBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(offsetBuf, tListLen(offsetBuf), &pOffsetInfo->currentOffset);
|
||||
|
||||
tscInfo("vgId:%d offset is update to:%s", p->vgId, offsetBuf);
|
||||
tscInfo("vgId:%d offset is update to:%"PRId64, p->vgId, p->currentOffset);
|
||||
|
||||
pOffsetInfo->walVerBegin = p->begin;
|
||||
pOffsetInfo->walVerEnd = p->end;
|
||||
pOffsetInfo->currentOffset.version = p->currentOffset;
|
||||
pOffsetInfo->committedOffset.version = p->currentOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2752,6 +2762,17 @@ void tmq_free_assignment(tmq_topic_assignment* pAssignment) {
|
|||
taosMemoryFree(pAssignment);
|
||||
}
|
||||
|
||||
static int32_t tmqSeekCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (pMsg) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
}
|
||||
SMqSeekParam* pParam = param;
|
||||
pParam->code = code;
|
||||
tsem_post(&pParam->sem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_t offset) {
|
||||
if (tmq == NULL) {
|
||||
tscError("invalid tmq handle, null");
|
||||
|
@ -2767,7 +2788,7 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
if (pTopic == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " invalid topic name:%s", tmq->consumerId, pTopicName);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_TMQ_INVALID_TOPIC;
|
||||
}
|
||||
|
||||
SMqClientVg* pVg = NULL;
|
||||
|
@ -2783,58 +2804,92 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
if (pVg == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " invalid vgroup id:%d", tmq->consumerId, vgId);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_TMQ_INVALID_VGID;
|
||||
}
|
||||
|
||||
SVgOffsetInfo* pOffsetInfo = &pVg->offsetInfo;
|
||||
|
||||
int32_t type = pOffsetInfo->currentOffset.type;
|
||||
if (type != TMQ_OFFSET__LOG && !OFFSET_IS_RESET_OFFSET(type)) {
|
||||
if (isInSnapshotMode(type, tmq->useSnapshot)) {
|
||||
tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, seek not allowed", tmq->consumerId, type);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_TMQ_SNAPSHOT_ERROR;
|
||||
}
|
||||
|
||||
if (type == TMQ_OFFSET__LOG && (offset < pOffsetInfo->walVerBegin || offset > pOffsetInfo->walVerEnd)) {
|
||||
tscError("consumer:0x%" PRIx64 " invalid seek params, offset:%" PRId64 ", valid range:[%" PRId64 ", %" PRId64 "]",
|
||||
tmq->consumerId, offset, pOffsetInfo->walVerBegin, pOffsetInfo->walVerEnd);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_TMQ_VERSION_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
// update the offset, and then commit to vnode
|
||||
if (pOffsetInfo->currentOffset.type == TMQ_OFFSET__LOG) {
|
||||
pOffsetInfo->currentOffset.version = offset;
|
||||
pOffsetInfo->committedOffset.version = INT64_MIN;
|
||||
pVg->seekUpdated = true;
|
||||
pOffsetInfo->currentOffset.type = TMQ_OFFSET__LOG;
|
||||
pOffsetInfo->currentOffset.version = offset >= 1 ? offset - 1 : 0;
|
||||
pOffsetInfo->seekOffset = pOffsetInfo->currentOffset;
|
||||
// pOffsetInfo->committedOffset.version = INT64_MIN;
|
||||
pVg->seekUpdated = true;
|
||||
tscInfo("consumer:0x%" PRIx64 " seek to %" PRId64 " on vgId:%d", tmq->consumerId, offset, vgId);
|
||||
|
||||
SMqSeekReq req = {0};
|
||||
snprintf(req.subKey, TSDB_SUBSCRIBE_KEY_LEN, "%s:%s", tmq->groupId, pTopic->topicName);
|
||||
req.head.vgId = pVg->vgId;
|
||||
req.consumerId = tmq->consumerId;
|
||||
|
||||
int32_t msgSize = tSerializeSMqSeekReq(NULL, 0, &req);
|
||||
if (msgSize < 0) {
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
SMqRspObj rspObj = {.resType = RES_TYPE__TMQ, .vgId = pVg->vgId};
|
||||
tstrncpy(rspObj.topic, tname, tListLen(rspObj.topic));
|
||||
|
||||
tscInfo("consumer:0x%" PRIx64 " seek to %" PRId64 " on vgId:%d", tmq->consumerId, offset, pVg->vgId);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
|
||||
SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo));
|
||||
if (pInfo == NULL) {
|
||||
tscError("consumer:0x%"PRIx64" failed to prepare seek operation", tmq->consumerId);
|
||||
char* msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tsem_init(&pInfo->sem, 0, 0);
|
||||
pInfo->code = 0;
|
||||
if (tSerializeSMqSeekReq(msg, msgSize, &req) < 0) {
|
||||
taosMemoryFree(msg);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
asyncCommitOffset(tmq, &rspObj, TDMT_VND_TMQ_SEEK_TO_OFFSET, commitCallBackFn, pInfo);
|
||||
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) {
|
||||
taosMemoryFree(msg);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tsem_wait(&pInfo->sem);
|
||||
int32_t code = pInfo->code;
|
||||
SMqSeekParam* pParam = taosMemoryMalloc(sizeof(SMqSeekParam));
|
||||
if (pParam == NULL) {
|
||||
taosMemoryFree(msg);
|
||||
taosMemoryFree(sendInfo);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tsem_init(&pParam->sem, 0, 0);
|
||||
|
||||
tsem_destroy(&pInfo->sem);
|
||||
taosMemoryFree(pInfo);
|
||||
sendInfo->msgInfo = (SDataBuf){.pData = msg, .len = msgSize, .handle = NULL};
|
||||
sendInfo->requestId = generateRequestId();
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqSeekCb;
|
||||
sendInfo->msgType = TDMT_VND_TMQ_SEEK;
|
||||
|
||||
int64_t transporterId = 0;
|
||||
tscInfo("consumer:0x%" PRIx64 " %s send seek info vgId:%d, epoch %d" PRIx64,
|
||||
tmq->consumerId, pTopic->topicName, vgId, tmq->epoch);
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||
taosWUnLockLatch(&tmq->lock);
|
||||
|
||||
tsem_wait(&pParam->sem);
|
||||
int32_t code = pParam->code;
|
||||
tsem_destroy(&pParam->sem);
|
||||
taosMemoryFree(pParam);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tscError("consumer:0x%" PRIx64 " failed to send seek to vgId:%d, code:%s", tmq->consumerId, pVg->vgId,
|
||||
tstrerror(code));
|
||||
tscError("consumer:0x%" PRIx64 " failed to send seek to vgId:%d, code:%s", tmq->consumerId, vgId, tstrerror(code));
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace {
|
|||
void printSubResults(void* pRes, int32_t* totalRows) {
|
||||
char buf[1024];
|
||||
|
||||
int32_t vgId = tmq_get_vgroup_id(pRes);
|
||||
int64_t offset = tmq_get_vgroup_offset(pRes);
|
||||
while (1) {
|
||||
TAOS_ROW row = taos_fetch_row(pRes);
|
||||
if (row == NULL) {
|
||||
|
@ -45,7 +47,7 @@ void printSubResults(void* pRes, int32_t* totalRows) {
|
|||
int32_t precision = taos_result_precision(pRes);
|
||||
taos_print_row(buf, row, fields, numOfFields);
|
||||
*totalRows += 1;
|
||||
printf("precision: %d, row content: %s\n", precision, buf);
|
||||
printf("vgId: %d, offset: %lld, precision: %d, row content: %s\n", vgId, offset, precision, buf);
|
||||
}
|
||||
|
||||
// taos_free_result(pRes);
|
||||
|
@ -1073,6 +1075,162 @@ TEST(clientCase, sub_db_test) {
|
|||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
}
|
||||
|
||||
TEST(clientCase, td_25129) {
|
||||
// taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg");
|
||||
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
tmq_conf_t* conf = tmq_conf_new();
|
||||
|
||||
tmq_conf_set(conf, "enable.auto.commit", "false");
|
||||
tmq_conf_set(conf, "auto.commit.interval.ms", "2000");
|
||||
tmq_conf_set(conf, "group.id", "group_id_2");
|
||||
tmq_conf_set(conf, "td.connect.user", "root");
|
||||
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||
tmq_conf_set(conf, "auto.offset.reset", "earliest");
|
||||
tmq_conf_set(conf, "msg.with.table.name", "true");
|
||||
|
||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||
tmq_conf_destroy(conf);
|
||||
|
||||
// 创建订阅 topics 列表
|
||||
tmq_list_t* topicList = tmq_list_new();
|
||||
tmq_list_append(topicList, "tp");
|
||||
|
||||
// 启动订阅
|
||||
tmq_subscribe(tmq, topicList);
|
||||
tmq_list_destroy(topicList);
|
||||
|
||||
TAOS_FIELD* fields = NULL;
|
||||
int32_t numOfFields = 0;
|
||||
int32_t precision = 0;
|
||||
int32_t totalRows = 0;
|
||||
int32_t msgCnt = 0;
|
||||
int32_t timeout = 2000;
|
||||
|
||||
int32_t count = 0;
|
||||
|
||||
tmq_topic_assignment* pAssign = NULL;
|
||||
int32_t numOfAssign = 0;
|
||||
|
||||
int32_t code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign);
|
||||
if (code != 0) {
|
||||
printf("error occurs:%s\n", tmq_err2str(code));
|
||||
tmq_free_assignment(pAssign);
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numOfAssign; i++){
|
||||
printf("assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end);
|
||||
}
|
||||
|
||||
// tmq_offset_seek(tmq, "tp", pAssign[0].vgId, 4);
|
||||
tmq_free_assignment(pAssign);
|
||||
|
||||
code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign);
|
||||
if (code != 0) {
|
||||
printf("error occurs:%s\n", tmq_err2str(code));
|
||||
tmq_free_assignment(pAssign);
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numOfAssign; i++){
|
||||
printf("assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end);
|
||||
}
|
||||
|
||||
tmq_free_assignment(pAssign);
|
||||
|
||||
code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign);
|
||||
if (code != 0) {
|
||||
printf("error occurs:%s\n", tmq_err2str(code));
|
||||
tmq_free_assignment(pAssign);
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numOfAssign; i++){
|
||||
printf("assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
printf("start to poll\n");
|
||||
TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout);
|
||||
if (pRes) {
|
||||
char buf[128];
|
||||
|
||||
const char* topicName = tmq_get_topic_name(pRes);
|
||||
// const char* dbName = tmq_get_db_name(pRes);
|
||||
// int32_t vgroupId = tmq_get_vgroup_id(pRes);
|
||||
//
|
||||
// printf("topic: %s\n", topicName);
|
||||
// printf("db: %s\n", dbName);
|
||||
// printf("vgroup id: %d\n", vgroupId);
|
||||
|
||||
printSubResults(pRes, &totalRows);
|
||||
|
||||
code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign);
|
||||
if (code != 0) {
|
||||
printf("error occurs:%s\n", tmq_err2str(code));
|
||||
tmq_free_assignment(pAssign);
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numOfAssign; i++){
|
||||
printf("assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end);
|
||||
}
|
||||
} else {
|
||||
tmq_offset_seek(tmq, "tp", pAssign[0].vgId, pAssign[0].currentOffset);
|
||||
tmq_offset_seek(tmq, "tp", pAssign[1].vgId, pAssign[1].currentOffset);
|
||||
tmq_commit_sync(tmq, pRes);
|
||||
continue;
|
||||
}
|
||||
|
||||
// tmq_commit_sync(tmq, pRes);
|
||||
if (pRes != NULL) {
|
||||
taos_free_result(pRes);
|
||||
// if ((++count) > 1) {
|
||||
// break;
|
||||
// }
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
// tmq_offset_seek(tmq, "tp", pAssign[0].vgId, pAssign[0].begin);
|
||||
}
|
||||
|
||||
tmq_free_assignment(pAssign);
|
||||
|
||||
code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign);
|
||||
if (code != 0) {
|
||||
printf("error occurs:%s\n", tmq_err2str(code));
|
||||
tmq_free_assignment(pAssign);
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numOfAssign; i++){
|
||||
printf("assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld\n", i, pAssign[i].vgId, pAssign[i].currentOffset, pAssign[i].begin, pAssign[i].end);
|
||||
}
|
||||
|
||||
tmq_consumer_close(tmq);
|
||||
taos_close(pConn);
|
||||
fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
}
|
||||
|
||||
TEST(clientCase, sub_tb_test) {
|
||||
taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg");
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema), true},
|
||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema), true},
|
||||
{TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)},
|
||||
{TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema), true},
|
||||
{TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema), true},
|
||||
{TSDB_INS_TABLE_DATABASES, userDBSchema, tListLen(userDBSchema), false},
|
||||
{TSDB_INS_TABLE_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema), false},
|
||||
|
|
|
@ -5382,6 +5382,48 @@ int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->subKey) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->head.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
tDecodeCStrTo(&decoder, pReq->subKey);
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
@ -7351,27 +7393,8 @@ void tDeleteMqDataRsp(SMqDataRsp *pRsp) {
|
|||
}
|
||||
|
||||
int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) {
|
||||
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->reqOffset) < 0) return -1;
|
||||
if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->blockNum) < 0) return -1;
|
||||
if (pRsp->blockNum != 0) {
|
||||
if (tEncodeI8(pEncoder, pRsp->withTbName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->withSchema) < 0) return -1;
|
||||
if (tEncodeMqDataRsp(pEncoder, (const SMqDataRsp *)pRsp) < 0) return -1;
|
||||
|
||||
for (int32_t i = 0; i < pRsp->blockNum; i++) {
|
||||
int32_t bLen = *(int32_t *)taosArrayGet(pRsp->blockDataLen, i);
|
||||
void *data = taosArrayGetP(pRsp->blockData, i);
|
||||
if (tEncodeBinary(pEncoder, (const uint8_t *)data, bLen) < 0) return -1;
|
||||
if (pRsp->withSchema) {
|
||||
SSchemaWrapper *pSW = (SSchemaWrapper *)taosArrayGetP(pRsp->blockSchema, i);
|
||||
if (tEncodeSSchemaWrapper(pEncoder, pSW) < 0) return -1;
|
||||
}
|
||||
if (pRsp->withTbName) {
|
||||
char *tbName = (char *)taosArrayGetP(pRsp->blockTbName, i);
|
||||
if (tEncodeCStr(pEncoder, tbName) < 0) return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tEncodeI32(pEncoder, pRsp->createTableNum) < 0) return -1;
|
||||
if (pRsp->createTableNum) {
|
||||
for (int32_t i = 0; i < pRsp->createTableNum; i++) {
|
||||
|
@ -7384,46 +7407,8 @@ int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) {
|
|||
}
|
||||
|
||||
int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp) {
|
||||
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset) < 0) return -1;
|
||||
if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->blockNum) < 0) return -1;
|
||||
if (pRsp->blockNum != 0) {
|
||||
pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *));
|
||||
pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t));
|
||||
if (tDecodeI8(pDecoder, &pRsp->withTbName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->withSchema) < 0) return -1;
|
||||
if (pRsp->withTbName) {
|
||||
pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void *));
|
||||
}
|
||||
if (pRsp->withSchema) {
|
||||
pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void *));
|
||||
}
|
||||
if (tDecodeMqDataRsp(pDecoder, (SMqDataRsp*)pRsp) < 0) return -1;
|
||||
|
||||
for (int32_t i = 0; i < pRsp->blockNum; i++) {
|
||||
void *data;
|
||||
uint64_t bLen;
|
||||
if (tDecodeBinaryAlloc(pDecoder, &data, &bLen) < 0) return -1;
|
||||
taosArrayPush(pRsp->blockData, &data);
|
||||
int32_t len = bLen;
|
||||
taosArrayPush(pRsp->blockDataLen, &len);
|
||||
|
||||
if (pRsp->withSchema) {
|
||||
SSchemaWrapper *pSW = (SSchemaWrapper *)taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
||||
if (pSW == NULL) return -1;
|
||||
if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) {
|
||||
taosMemoryFree(pSW);
|
||||
return -1;
|
||||
}
|
||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
||||
}
|
||||
|
||||
if (pRsp->withTbName) {
|
||||
char *tbName;
|
||||
if (tDecodeCStrAlloc(pDecoder, &tbName) < 0) return -1;
|
||||
taosArrayPush(pRsp->blockTbName, &tbName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tDecodeI32(pDecoder, &pRsp->createTableNum) < 0) return -1;
|
||||
if (pRsp->createTableNum) {
|
||||
pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t));
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include "tconfig.h"
|
||||
#include "tglobal.h"
|
||||
#include "version.h"
|
||||
#ifdef TD_JEMALLOC_ENABLED
|
||||
#include "jemalloc/jemalloc.h"
|
||||
#endif
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -255,6 +258,10 @@ static void taosCleanupArgs() {
|
|||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
#ifdef TD_JEMALLOC_ENABLED
|
||||
bool jeBackgroundThread = true;
|
||||
mallctl("background_thread", NULL, NULL, &jeBackgroundThread, sizeof(bool));
|
||||
#endif
|
||||
if (!taosCheckSystemIsLittleEnd()) {
|
||||
printf("failed to start since on non-little-end machines\n");
|
||||
return -1;
|
||||
|
|
|
@ -726,7 +726,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SUBSCRIBE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DELETE_SUB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SEEK_TO_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SEEK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_ADD_CHECKINFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_DEL_CHECKINFO, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_CONSUME, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -41,7 +41,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) {
|
|||
pWrapper->pMgmt = output.pMgmt;
|
||||
}
|
||||
|
||||
dmReportStartup(pWrapper->name, "openned");
|
||||
dmReportStartup(pWrapper->name, "opened");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
|||
} else {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,12 +137,11 @@ typedef enum {
|
|||
} EDndReason;
|
||||
|
||||
typedef enum {
|
||||
CONSUMER_UPDATE_REB_MODIFY_NOTOPIC = 1, // topic do not need modified after rebalance
|
||||
CONSUMER_UPDATE_REB_MODIFY_TOPIC, // topic need modified after rebalance
|
||||
CONSUMER_UPDATE_REB_MODIFY_REMOVE, // topic need removed after rebalance
|
||||
// CONSUMER_UPDATE_TIMER_LOST,
|
||||
CONSUMER_UPDATE_RECOVER,
|
||||
CONSUMER_UPDATE_SUB_MODIFY, // modify after subscribe req
|
||||
CONSUMER_UPDATE_REB = 1, // update after rebalance
|
||||
CONSUMER_ADD_REB, // add after rebalance
|
||||
CONSUMER_REMOVE_REB, // remove after rebalance
|
||||
CONSUMER_UPDATE_REC, // update after recover
|
||||
CONSUMER_UPDATE_SUB, // update after subscribe req
|
||||
} ECsmUpdateType;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -184,7 +184,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup);
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_RECOVER;
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_REC;
|
||||
|
||||
mndReleaseConsumer(pMnode, pConsumer);
|
||||
|
||||
|
@ -419,6 +419,9 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
mDebug("heartbeat report offset rows.%s:%s", pConsumer->cgroup, data->topicName);
|
||||
|
||||
SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, data->topicName);
|
||||
if(pSub == NULL){
|
||||
continue;
|
||||
}
|
||||
taosWLockLatch(&pSub->lock);
|
||||
SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t));
|
||||
if(pConsumerEp){
|
||||
|
@ -698,7 +701,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
pConsumerNew->autoCommitInterval = subscribe.autoCommitInterval;
|
||||
pConsumerNew->resetOffsetCfg = subscribe.resetOffsetCfg;
|
||||
|
||||
// pConsumerNew->updateType = CONSUMER_UPDATE_SUB_MODIFY; // use insert logic
|
||||
// pConsumerNew->updateType = CONSUMER_UPDATE_SUB; // use insert logic
|
||||
taosArrayDestroy(pConsumerNew->assignedTopics);
|
||||
pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup);
|
||||
|
||||
|
@ -728,7 +731,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
// set the update type
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_SUB_MODIFY;
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_SUB;
|
||||
taosArrayDestroy(pConsumerNew->assignedTopics);
|
||||
pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup);
|
||||
|
||||
|
@ -981,7 +984,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
|
||||
taosWLockLatch(&pOldConsumer->lock);
|
||||
|
||||
if (pNewConsumer->updateType == CONSUMER_UPDATE_SUB_MODIFY) {
|
||||
if (pNewConsumer->updateType == CONSUMER_UPDATE_SUB) {
|
||||
TSWAP(pOldConsumer->rebNewTopics, pNewConsumer->rebNewTopics);
|
||||
TSWAP(pOldConsumer->rebRemovedTopics, pNewConsumer->rebRemovedTopics);
|
||||
TSWAP(pOldConsumer->assignedTopics, pNewConsumer->assignedTopics);
|
||||
|
@ -1001,7 +1004,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
// mInfo("consumer:0x%" PRIx64 " timer update, timer lost. state %s -> %s, reb-time:%" PRId64 ", reb-removed-topics:%d",
|
||||
// pOldConsumer->consumerId, mndConsumerStatusName(prevStatus), mndConsumerStatusName(pOldConsumer->status),
|
||||
// pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics));
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_RECOVER) {
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_REC) {
|
||||
int32_t sz = taosArrayGetSize(pOldConsumer->assignedTopics);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
char *topic = taosStrdup(taosArrayGetP(pOldConsumer->assignedTopics, i));
|
||||
|
@ -1010,12 +1013,12 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
|
||||
pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE;
|
||||
mInfo("consumer:0x%" PRIx64 " timer update, timer recover",pOldConsumer->consumerId);
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB_MODIFY_NOTOPIC) {
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB) {
|
||||
atomic_add_fetch_32(&pOldConsumer->epoch, 1);
|
||||
|
||||
pOldConsumer->rebalanceTime = taosGetTimestampMs();
|
||||
mInfo("consumer:0x%" PRIx64 " reb update, only rebalance time", pOldConsumer->consumerId);
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB_MODIFY_TOPIC) {
|
||||
} else if (pNewConsumer->updateType == CONSUMER_ADD_REB) {
|
||||
char *pNewTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0));
|
||||
|
||||
// check if exist in current topic
|
||||
|
@ -1046,7 +1049,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
|
|||
(int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics),
|
||||
(int)taosArrayGetSize(pOldConsumer->rebRemovedTopics));
|
||||
|
||||
} else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB_MODIFY_REMOVE) {
|
||||
} else if (pNewConsumer->updateType == CONSUMER_REMOVE_REB) {
|
||||
char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0);
|
||||
|
||||
// remove from removed topic
|
||||
|
|
|
@ -504,6 +504,11 @@ static void mndDestroySmaObj(SSmaObj *pSmaObj) {
|
|||
|
||||
static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb,
|
||||
const char *streamName) {
|
||||
if (pDb->cfg.replications > 1) {
|
||||
terrno = TSDB_CODE_MND_INVALID_SMA_OPTION;
|
||||
mError("sma:%s, failed to create since not support multiple replicas", pCreate->name);
|
||||
return -1;
|
||||
}
|
||||
SSmaObj smaObj = {0};
|
||||
memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||
memcpy(smaObj.stb, pStb->name, TSDB_TABLE_FNAME_LEN);
|
||||
|
|
|
@ -275,7 +275,7 @@ static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pI
|
|||
|
||||
taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp));
|
||||
taosArrayPush(pOutput->newConsumers, &consumerId);
|
||||
mInfo("sub:%s mq rebalance add new consumer:%" PRIx64, pSubKey, consumerId);
|
||||
mInfo("sub:%s mq rebalance add new consumer:0x%" PRIx64, pSubKey, consumerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu
|
|||
for (int32_t i = 0; i < consumerNum; i++) {
|
||||
int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->modifyConsumers, i);
|
||||
SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_REB_MODIFY_NOTOPIC;
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_REB;
|
||||
if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) {
|
||||
tDeleteSMqConsumerObj(pConsumerNew, true);
|
||||
|
||||
|
@ -613,7 +613,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu
|
|||
for (int32_t i = 0; i < consumerNum; i++) {
|
||||
int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->newConsumers, i);
|
||||
SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_REB_MODIFY_TOPIC;
|
||||
pConsumerNew->updateType = CONSUMER_ADD_REB;
|
||||
|
||||
char* topicTmp = taosStrdup(topic);
|
||||
taosArrayPush(pConsumerNew->rebNewTopics, &topicTmp);
|
||||
|
@ -633,7 +633,7 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu
|
|||
int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->removedConsumers, i);
|
||||
|
||||
SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup);
|
||||
pConsumerNew->updateType = CONSUMER_UPDATE_REB_MODIFY_REMOVE;
|
||||
pConsumerNew->updateType = CONSUMER_REMOVE_REB;
|
||||
|
||||
char* topicTmp = taosStrdup(topic);
|
||||
taosArrayPush(pConsumerNew->rebRemovedTopics, &topicTmp);
|
||||
|
|
|
@ -802,7 +802,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (TSDB_ALTER_USER_PASSWD == alterReq.alterType &&
|
||||
(alterReq.pass[0] == 0 || strlen(alterReq.pass) > TSDB_PASSWORD_LEN)) {
|
||||
(alterReq.pass[0] == 0 || strlen(alterReq.pass) >= TSDB_PASSWORD_LEN)) {
|
||||
terrno = TSDB_CODE_MND_INVALID_PASS_FORMAT;
|
||||
goto _OVER;
|
||||
}
|
||||
|
|
|
@ -79,16 +79,18 @@ typedef struct {
|
|||
TXN* pTxn;
|
||||
} STtlDelTtlCtx;
|
||||
|
||||
int ttlMgrOpen(STtlManger** ppTtlMgr, TDB* pEnv, int8_t rollback);
|
||||
int ttlMgrClose(STtlManger* pTtlMgr);
|
||||
int ttlMgrBegin(STtlManger* pTtlMgr, void* pMeta);
|
||||
int ttlMgrOpen(STtlManger** ppTtlMgr, TDB* pEnv, int8_t rollback);
|
||||
void ttlMgrClose(STtlManger* pTtlMgr);
|
||||
int ttlMgrPostOpen(STtlManger* pTtlMgr, void* pMeta);
|
||||
|
||||
int ttlMgrConvert(TTB* pOldTtlIdx, TTB* pNewTtlIdx, void* pMeta);
|
||||
int ttlMgrFlush(STtlManger* pTtlMgr, TXN* pTxn);
|
||||
bool ttlMgrNeedUpgrade(TDB* pEnv);
|
||||
int ttlMgrUpgrade(STtlManger* pTtlMgr, void* pMeta);
|
||||
|
||||
int ttlMgrInsertTtl(STtlManger* pTtlMgr, const STtlUpdTtlCtx* pUpdCtx);
|
||||
int ttlMgrDeleteTtl(STtlManger* pTtlMgr, const STtlDelTtlCtx* pDelCtx);
|
||||
int ttlMgrUpdateChangeTime(STtlManger* pTtlMgr, const STtlUpdCtimeCtx* pUpdCtimeCtx);
|
||||
|
||||
int ttlMgrFlush(STtlManger* pTtlMgr, TXN* pTxn);
|
||||
int ttlMgrFindExpired(STtlManger* pTtlMgr, int64_t timePointMs, SArray* pTbUids);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -151,7 +151,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
|
|||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision);
|
||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
||||
int32_t type, int32_t vgId);
|
||||
int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
//int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId);
|
||||
|
||||
// tqMeta
|
||||
int32_t tqMetaOpen(STQ* pTq);
|
||||
|
|
|
@ -136,6 +136,7 @@ typedef struct STbUidStore STbUidStore;
|
|||
#define META_BEGIN_HEAP_NIL 2
|
||||
|
||||
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
||||
int metaUpgrade(SVnode* pVnode, SMeta** ppMeta);
|
||||
int metaClose(SMeta** pMeta);
|
||||
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||
TXN* metaGetTxn(SMeta* pMeta);
|
||||
|
@ -227,7 +228,7 @@ int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t version, char* msg, int32_t m
|
|||
int32_t tqProcessSubscribeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessSeekReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessSeekReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessPollPush(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
|
|
|
@ -40,10 +40,6 @@ int metaBegin(SMeta *pMeta, int8_t heap) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (ttlMgrBegin(pMeta->pTtlMgr, pMeta) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -29,6 +29,8 @@ static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen
|
|||
static int32_t metaInitLock(SMeta *pMeta) { return taosThreadRwlockInit(&pMeta->lock, NULL); }
|
||||
static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); }
|
||||
|
||||
static void metaCleanup(SMeta **ppMeta);
|
||||
|
||||
int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||
SMeta *pMeta = NULL;
|
||||
int ret;
|
||||
|
@ -180,51 +182,43 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
return 0;
|
||||
|
||||
_err:
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
taosMemoryFree(pMeta);
|
||||
metaCleanup(&pMeta);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int metaClose(SMeta **ppMeta) {
|
||||
int metaUpgrade(SVnode *pVnode, SMeta **ppMeta) {
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
SMeta *pMeta = *ppMeta;
|
||||
if (pMeta) {
|
||||
if (pMeta->pEnv) metaAbort(pMeta);
|
||||
if (pMeta->pCache) metaCacheClose(pMeta);
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
|
||||
taosMemoryFreeClear(*ppMeta);
|
||||
if (ttlMgrNeedUpgrade(pMeta->pEnv)) {
|
||||
code = metaBegin(pMeta, META_BEGIN_HEAP_OS);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta, meta begin failed since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = ttlMgrUpgrade(pMeta->pTtlMgr, pMeta);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta ttl since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = metaCommit(pMeta, pMeta->txn);
|
||||
if (code < 0) {
|
||||
metaError("vgId:%d, failed to upgrade meta ttl, meta commit failed since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_err:
|
||||
metaCleanup(ppMeta);
|
||||
return code;
|
||||
}
|
||||
|
||||
int metaClose(SMeta **ppMeta) {
|
||||
metaCleanup(ppMeta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,6 +264,32 @@ int32_t metaULock(SMeta *pMeta) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void metaCleanup(SMeta **ppMeta) {
|
||||
SMeta *pMeta = *ppMeta;
|
||||
if (pMeta) {
|
||||
if (pMeta->pEnv) metaAbort(pMeta);
|
||||
if (pMeta->pCache) metaCacheClose(pMeta);
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
|
||||
taosMemoryFreeClear(*ppMeta);
|
||||
}
|
||||
}
|
||||
|
||||
static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
|
||||
STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1;
|
||||
STbDbKey *pTbDbKey2 = (STbDbKey *)pKey2;
|
||||
|
|
|
@ -21,6 +21,10 @@ typedef struct {
|
|||
SMeta *pMeta;
|
||||
} SConvertData;
|
||||
|
||||
static void ttlMgrCleanup(STtlManger *pTtlMgr);
|
||||
|
||||
static int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta);
|
||||
|
||||
static void ttlMgrBuildKey(STtlIdxKeyV1 *pTtlKey, int64_t ttlDays, int64_t changeTimeMs, tb_uid_t uid);
|
||||
static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
||||
static int ttlIdxKeyV1Cmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
||||
|
@ -36,27 +40,17 @@ const char *ttlTbname = "ttl.idx";
|
|||
const char *ttlV1Tbname = "ttlv1.idx";
|
||||
|
||||
int ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback) {
|
||||
int ret;
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int64_t startNs = taosGetTimestampNs();
|
||||
|
||||
*ppTtlMgr = NULL;
|
||||
|
||||
STtlManger *pTtlMgr = (STtlManger *)tdbOsCalloc(1, sizeof(*pTtlMgr));
|
||||
if (pTtlMgr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbTbExist(ttlTbname, pEnv)) {
|
||||
ret = tdbTbOpen(ttlTbname, sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, pEnv, &pTtlMgr->pOldTtlIdx, rollback);
|
||||
if (ret < 0) {
|
||||
metaError("failed to open %s index since %s", ttlTbname, tstrerror(terrno));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (pTtlMgr == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
ret = tdbTbOpen(ttlV1Tbname, TDB_VARIANT_LEN, TDB_VARIANT_LEN, ttlIdxKeyV1Cmpr, pEnv, &pTtlMgr->pTtlIdx, rollback);
|
||||
if (ret < 0) {
|
||||
metaError("failed to open %s since %s", ttlV1Tbname, tstrerror(terrno));
|
||||
|
||||
tdbOsFree(pTtlMgr);
|
||||
return ret;
|
||||
}
|
||||
|
@ -66,42 +60,57 @@ int ttlMgrOpen(STtlManger **ppTtlMgr, TDB *pEnv, int8_t rollback) {
|
|||
|
||||
taosThreadRwlockInit(&pTtlMgr->lock, NULL);
|
||||
|
||||
ret = ttlMgrFillCache(pTtlMgr);
|
||||
if (ret < 0) {
|
||||
metaError("failed to fill hash since %s", tstrerror(terrno));
|
||||
ttlMgrCleanup(pTtlMgr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t endNs = taosGetTimestampNs();
|
||||
metaInfo("ttl mgr open end, hash size: %d, time consumed: %" PRId64 " ns", taosHashGetSize(pTtlMgr->pTtlCache),
|
||||
endNs - startNs);
|
||||
|
||||
*ppTtlMgr = pTtlMgr;
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int ttlMgrClose(STtlManger *pTtlMgr) {
|
||||
taosHashCleanup(pTtlMgr->pTtlCache);
|
||||
taosHashCleanup(pTtlMgr->pDirtyUids);
|
||||
tdbTbClose(pTtlMgr->pTtlIdx);
|
||||
taosThreadRwlockDestroy(&pTtlMgr->lock);
|
||||
tdbOsFree(pTtlMgr);
|
||||
return 0;
|
||||
void ttlMgrClose(STtlManger *pTtlMgr) { ttlMgrCleanup(pTtlMgr); }
|
||||
|
||||
bool ttlMgrNeedUpgrade(TDB *pEnv) {
|
||||
bool needUpgrade = tdbTbExist(ttlTbname, pEnv);
|
||||
if (needUpgrade) {
|
||||
metaInfo("find ttl idx in old version , will convert");
|
||||
}
|
||||
return needUpgrade;
|
||||
}
|
||||
|
||||
int ttlMgrBegin(STtlManger *pTtlMgr, void *pMeta) {
|
||||
metaInfo("ttl mgr start open");
|
||||
int ret;
|
||||
int ttlMgrUpgrade(STtlManger *pTtlMgr, void *pMeta) {
|
||||
SMeta *meta = (SMeta *)pMeta;
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (!tdbTbExist(ttlTbname, meta->pEnv)) return TSDB_CODE_SUCCESS;
|
||||
|
||||
metaInfo("ttl mgr start upgrade");
|
||||
|
||||
int64_t startNs = taosGetTimestampNs();
|
||||
|
||||
SMeta *meta = (SMeta *)pMeta;
|
||||
ret = tdbTbOpen(ttlTbname, sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, meta->pEnv, &pTtlMgr->pOldTtlIdx, 0);
|
||||
if (ret < 0) {
|
||||
metaError("failed to open %s index since %s", ttlTbname, tstrerror(terrno));
|
||||
goto _out;
|
||||
}
|
||||
|
||||
if (pTtlMgr->pOldTtlIdx) {
|
||||
ret = ttlMgrConvert(pTtlMgr->pOldTtlIdx, pTtlMgr->pTtlIdx, pMeta);
|
||||
if (ret < 0) {
|
||||
metaError("failed to convert ttl index since %s", tstrerror(terrno));
|
||||
goto _out;
|
||||
}
|
||||
ret = ttlMgrConvert(pTtlMgr->pOldTtlIdx, pTtlMgr->pTtlIdx, pMeta);
|
||||
if (ret < 0) {
|
||||
metaError("failed to convert ttl index since %s", tstrerror(terrno));
|
||||
goto _out;
|
||||
}
|
||||
|
||||
ret = tdbTbDropByName(ttlTbname, meta->pEnv, meta->txn);
|
||||
if (ret < 0) {
|
||||
metaError("failed to drop old ttl index since %s", tstrerror(terrno));
|
||||
goto _out;
|
||||
}
|
||||
|
||||
tdbTbClose(pTtlMgr->pOldTtlIdx);
|
||||
pTtlMgr->pOldTtlIdx = NULL;
|
||||
ret = tdbTbDropByName(ttlTbname, meta->pEnv, meta->txn);
|
||||
if (ret < 0) {
|
||||
metaError("failed to drop old ttl index since %s", tstrerror(terrno));
|
||||
goto _out;
|
||||
}
|
||||
|
||||
ret = ttlMgrFillCache(pTtlMgr);
|
||||
|
@ -111,13 +120,23 @@ int ttlMgrBegin(STtlManger *pTtlMgr, void *pMeta) {
|
|||
}
|
||||
|
||||
int64_t endNs = taosGetTimestampNs();
|
||||
|
||||
metaInfo("ttl mgr open end, hash size: %d, time consumed: %" PRId64 " ns", taosHashGetSize(pTtlMgr->pTtlCache),
|
||||
metaInfo("ttl mgr upgrade end, hash size: %d, time consumed: %" PRId64 " ns", taosHashGetSize(pTtlMgr->pTtlCache),
|
||||
endNs - startNs);
|
||||
_out:
|
||||
tdbTbClose(pTtlMgr->pOldTtlIdx);
|
||||
pTtlMgr->pOldTtlIdx = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ttlMgrCleanup(STtlManger *pTtlMgr) {
|
||||
taosHashCleanup(pTtlMgr->pTtlCache);
|
||||
taosHashCleanup(pTtlMgr->pDirtyUids);
|
||||
tdbTbClose(pTtlMgr->pTtlIdx);
|
||||
taosThreadRwlockDestroy(&pTtlMgr->lock);
|
||||
tdbOsFree(pTtlMgr);
|
||||
}
|
||||
|
||||
static void ttlMgrBuildKey(STtlIdxKeyV1 *pTtlKey, int64_t ttlDays, int64_t changeTimeMs, tb_uid_t uid) {
|
||||
if (ttlDays <= 0) return;
|
||||
|
||||
|
@ -205,7 +224,7 @@ _out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta) {
|
||||
static int ttlMgrConvert(TTB *pOldTtlIdx, TTB *pNewTtlIdx, void *pMeta) {
|
||||
SMeta *meta = pMeta;
|
||||
|
||||
metaInfo("ttlMgr convert ttl start.");
|
||||
|
|
|
@ -232,26 +232,43 @@ static int32_t doSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqData
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||
int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||
SMqPollReq req = {0};
|
||||
if (tDeserializeSMqPollReq(pHandle->msg->pCont, pHandle->msg->contLen, &req) < 0) {
|
||||
tqError("tDeserializeSMqPollReq %d failed", pHandle->msg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
dataRsp.head.consumerId = pHandle->consumerId;
|
||||
dataRsp.head.epoch = pHandle->epoch;
|
||||
dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
|
||||
|
||||
int64_t sver = 0, ever = 0;
|
||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
tqDoSendDataRsp(&pHandle->msg->info, &dataRsp, pHandle->epoch, pHandle->consumerId, TMQ_MSG_TYPE__POLL_RSP, sver,
|
||||
ever);
|
||||
|
||||
char buf1[TSDB_OFFSET_LEN] = {0};
|
||||
char buf2[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf1, tListLen(buf1), &dataRsp.reqOffset);
|
||||
tFormatOffset(buf2, tListLen(buf2), &dataRsp.rspOffset);
|
||||
tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s", vgId,
|
||||
dataRsp.head.consumerId, dataRsp.head.epoch, dataRsp.blockNum, buf1, buf2);
|
||||
tqInitDataRsp(&dataRsp, &req);
|
||||
dataRsp.blockNum = 0;
|
||||
dataRsp.rspOffset = dataRsp.reqOffset;
|
||||
tqSendDataRsp(pHandle, pHandle->msg, &req, &dataRsp, TMQ_MSG_TYPE__POLL_RSP, vgId);
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//int32_t tqPushDataRsp(STqHandle* pHandle, int32_t vgId) {
|
||||
// SMqDataRsp dataRsp = {0};
|
||||
// dataRsp.head.consumerId = pHandle->consumerId;
|
||||
// dataRsp.head.epoch = pHandle->epoch;
|
||||
// dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
|
||||
//
|
||||
// int64_t sver = 0, ever = 0;
|
||||
// walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
// tqDoSendDataRsp(&pHandle->msg->info, &dataRsp, pHandle->epoch, pHandle->consumerId, TMQ_MSG_TYPE__POLL_RSP, sver,
|
||||
// ever);
|
||||
//
|
||||
// char buf1[TSDB_OFFSET_LEN] = {0};
|
||||
// char buf2[TSDB_OFFSET_LEN] = {0};
|
||||
// tFormatOffset(buf1, tListLen(buf1), &dataRsp.reqOffset);
|
||||
// tFormatOffset(buf2, tListLen(buf2), &dataRsp.rspOffset);
|
||||
// tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s", vgId,
|
||||
// dataRsp.head.consumerId, dataRsp.head.epoch, dataRsp.blockNum, buf1, buf2);
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp,
|
||||
int32_t type, int32_t vgId) {
|
||||
int64_t sver = 0, ever = 0;
|
||||
|
@ -313,86 +330,124 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessSeekReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||
SMqVgOffset vgOffset = {0};
|
||||
int32_t tqProcessSeekReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SMqSeekReq req = {0};
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
SRpcMsg rsp = {.info = pMsg->info};
|
||||
int code = 0;
|
||||
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
if (tDecodeMqVgOffset(&decoder, &vgOffset) < 0) {
|
||||
tqError("vgId:%d failed to decode seek msg", vgId);
|
||||
return -1;
|
||||
tqDebug("tmq seek: consumer:0x%" PRIx64 " vgId:%d, subkey %s", req.consumerId, vgId, req.subKey);
|
||||
if (tDeserializeSMqSeekReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
tqDebug("topic:%s, vgId:%d process offset seek by consumer:0x%" PRIx64 ", req offset:%" PRId64,
|
||||
vgOffset.offset.subKey, vgId, vgOffset.consumerId, vgOffset.offset.val.version);
|
||||
|
||||
STqOffset* pOffset = &vgOffset.offset;
|
||||
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
tqError("vgId:%d, subKey:%s invalid seek offset type:%d", vgId, pOffset->subKey, pOffset->val.type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, pOffset->subKey, strlen(pOffset->subKey));
|
||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
|
||||
if (pHandle == NULL) {
|
||||
tqError("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", vgOffset.consumerId, vgId, pOffset->subKey);
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
tqWarn("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", req.consumerId, vgId, req.subKey);
|
||||
code = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// 2. check consumer-vg assignment status
|
||||
taosRLockLatch(&pTq->lock);
|
||||
if (pHandle->consumerId != vgOffset.consumerId) {
|
||||
tqDebug("ERROR tmq seek: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||
vgOffset.consumerId, vgId, pOffset->subKey, pHandle->consumerId);
|
||||
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
if (pHandle->consumerId != req.consumerId) {
|
||||
tqError("ERROR tmq seek: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||
req.consumerId, vgId, req.subKey, pHandle->consumerId);
|
||||
taosRUnLockLatch(&pTq->lock);
|
||||
return -1;
|
||||
code = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
goto end;
|
||||
}
|
||||
|
||||
//if consumer register to push manager, push empty to consumer to change vg status from TMQ_VG_STATUS__WAIT to TMQ_VG_STATUS__IDLE,
|
||||
//otherwise poll data failed after seek.
|
||||
tqUnregisterPushHandle(pTq, pHandle);
|
||||
taosRUnLockLatch(&pTq->lock);
|
||||
|
||||
// 3. check the offset info
|
||||
STqOffset* pSavedOffset = tqOffsetRead(pTq->pOffsetStore, pOffset->subKey);
|
||||
if (pSavedOffset != NULL) {
|
||||
if (pSavedOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
tqError("invalid saved offset type, vgId:%d sub:%s", vgId, pOffset->subKey);
|
||||
return 0; // no need to update the offset value
|
||||
}
|
||||
|
||||
if (pSavedOffset->val.version == pOffset->val.version) {
|
||||
tqDebug("vgId:%d subKey:%s no need to seek to %" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey,
|
||||
pOffset->val.version, pSavedOffset->val.version);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t sver = 0, ever = 0;
|
||||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
if (pOffset->val.version < sver) {
|
||||
pOffset->val.version = sver;
|
||||
} else if (pOffset->val.version > ever) {
|
||||
pOffset->val.version = ever;
|
||||
}
|
||||
|
||||
// save the new offset value
|
||||
if (pSavedOffset != NULL) {
|
||||
tqDebug("vgId:%d sub:%s seek to:%" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey, pOffset->val.version,
|
||||
pSavedOffset->val.version);
|
||||
} else {
|
||||
tqDebug("vgId:%d sub:%s seek to:%" PRId64 " not saved yet", vgId, pOffset->subKey, pOffset->val.version);
|
||||
}
|
||||
|
||||
if (tqOffsetWrite(pTq->pOffsetStore, pOffset) < 0) {
|
||||
tqError("failed to save offset, vgId:%d sub:%s seek to %" PRId64, vgId, pOffset->subKey, pOffset->val.version);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tqDebug("topic:%s, vgId:%d consumer:0x%" PRIx64 " offset is update to:%" PRId64, vgOffset.offset.subKey, vgId,
|
||||
vgOffset.consumerId, vgOffset.offset.val.version);
|
||||
|
||||
end:
|
||||
rsp.code = code;
|
||||
tmsgSendRsp(&rsp);
|
||||
return 0;
|
||||
|
||||
// SMqVgOffset vgOffset = {0};
|
||||
// int32_t vgId = TD_VID(pTq->pVnode);
|
||||
//
|
||||
// SDecoder decoder;
|
||||
// tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
// if (tDecodeMqVgOffset(&decoder, &vgOffset) < 0) {
|
||||
// tqError("vgId:%d failed to decode seek msg", vgId);
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// tDecoderClear(&decoder);
|
||||
//
|
||||
// tqDebug("topic:%s, vgId:%d process offset seek by consumer:0x%" PRIx64 ", req offset:%" PRId64,
|
||||
// vgOffset.offset.subKey, vgId, vgOffset.consumerId, vgOffset.offset.val.version);
|
||||
//
|
||||
// STqOffset* pOffset = &vgOffset.offset;
|
||||
// if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
// tqError("vgId:%d, subKey:%s invalid seek offset type:%d", vgId, pOffset->subKey, pOffset->val.type);
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// STqHandle* pHandle = taosHashGet(pTq->pHandle, pOffset->subKey, strlen(pOffset->subKey));
|
||||
// if (pHandle == NULL) {
|
||||
// tqError("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", vgOffset.consumerId, vgId, pOffset->subKey);
|
||||
// terrno = TSDB_CODE_INVALID_MSG;
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// // 2. check consumer-vg assignment status
|
||||
// taosRLockLatch(&pTq->lock);
|
||||
// if (pHandle->consumerId != vgOffset.consumerId) {
|
||||
// tqDebug("ERROR tmq seek: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64,
|
||||
// vgOffset.consumerId, vgId, pOffset->subKey, pHandle->consumerId);
|
||||
// terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
// taosRUnLockLatch(&pTq->lock);
|
||||
// return -1;
|
||||
// }
|
||||
// taosRUnLockLatch(&pTq->lock);
|
||||
//
|
||||
// // 3. check the offset info
|
||||
// STqOffset* pSavedOffset = tqOffsetRead(pTq->pOffsetStore, pOffset->subKey);
|
||||
// if (pSavedOffset != NULL) {
|
||||
// if (pSavedOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
// tqError("invalid saved offset type, vgId:%d sub:%s", vgId, pOffset->subKey);
|
||||
// return 0; // no need to update the offset value
|
||||
// }
|
||||
//
|
||||
// if (pSavedOffset->val.version == pOffset->val.version) {
|
||||
// tqDebug("vgId:%d subKey:%s no need to seek to %" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey,
|
||||
// pOffset->val.version, pSavedOffset->val.version);
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int64_t sver = 0, ever = 0;
|
||||
// walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
// if (pOffset->val.version < sver) {
|
||||
// pOffset->val.version = sver;
|
||||
// } else if (pOffset->val.version > ever) {
|
||||
// pOffset->val.version = ever;
|
||||
// }
|
||||
//
|
||||
// // save the new offset value
|
||||
// if (pSavedOffset != NULL) {
|
||||
// tqDebug("vgId:%d sub:%s seek to:%" PRId64 " prev offset:%" PRId64, vgId, pOffset->subKey, pOffset->val.version,
|
||||
// pSavedOffset->val.version);
|
||||
// } else {
|
||||
// tqDebug("vgId:%d sub:%s seek to:%" PRId64 " not saved yet", vgId, pOffset->subKey, pOffset->val.version);
|
||||
// }
|
||||
//
|
||||
// if (tqOffsetWrite(pTq->pOffsetStore, pOffset) < 0) {
|
||||
// tqError("failed to save offset, vgId:%d sub:%s seek to %" PRId64, vgId, pOffset->subKey, pOffset->val.version);
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// tqDebug("topic:%s, vgId:%d consumer:0x%" PRIx64 " offset is update to:%" PRId64, vgOffset.offset.subKey, vgId,
|
||||
// vgOffset.consumerId, vgOffset.offset.val.version);
|
||||
//
|
||||
// return 0;
|
||||
}
|
||||
|
||||
int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId) {
|
||||
|
@ -490,7 +545,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
if (!exec) {
|
||||
tqSetHandleExec(pHandle);
|
||||
// qSetTaskCode(pHandle->execHandle.task, TDB_CODE_SUCCESS);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, set handle exec, pHandle:%p", consumerId, vgId,
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " vgId:%d, topic:%s, set handle exec, pHandle:%p", consumerId, vgId,
|
||||
req.subKey, pHandle);
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
break;
|
||||
|
@ -510,7 +565,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
pHandle->epoch = reqEpoch;
|
||||
}
|
||||
|
||||
char buf[TSDB_OFFSET_LEN];
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &reqOffset);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, reqId:0x%" PRIx64,
|
||||
consumerId, req.epoch, pHandle->subKey, vgId, buf, req.reqId);
|
||||
|
@ -518,7 +573,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
code = tqExtractDataForMq(pTq, pHandle, &req, pMsg);
|
||||
tqSetHandleIdle(pHandle);
|
||||
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 "vgId:%d, topic:%s, , set handle idle, pHandle:%p", consumerId, vgId,
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " vgId:%d, topic:%s, set handle idle, pHandle:%p", consumerId, vgId,
|
||||
req.subKey, pHandle);
|
||||
return code;
|
||||
}
|
||||
|
@ -560,48 +615,47 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, &req);
|
||||
|
||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey);
|
||||
if (pOffset != NULL) {
|
||||
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s use snapshot, no valid wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
}
|
||||
if (req.useSnapshot == true) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dataRsp.rspOffset.type = TMQ_OFFSET__LOG;
|
||||
dataRsp.rspOffset.version = pOffset->val.version;
|
||||
} else {
|
||||
if (req.useSnapshot == true) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
}
|
||||
dataRsp.rspOffset.type = TMQ_OFFSET__LOG;
|
||||
|
||||
dataRsp.rspOffset.type = TMQ_OFFSET__LOG;
|
||||
|
||||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
int64_t currentVer = walReaderGetCurrentVer(pHandle->execHandle.pTqReader->pWalReader);
|
||||
if (currentVer == -1) { // not start to read data from wal yet, return req offset directly
|
||||
dataRsp.rspOffset.version = reqOffset.version;
|
||||
} else {
|
||||
dataRsp.rspOffset.version = currentVer; // return current consume offset value
|
||||
if (reqOffset.type == TMQ_OFFSET__LOG) {
|
||||
dataRsp.rspOffset.version = reqOffset.version;
|
||||
} else if(reqOffset.type < 0){
|
||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey);
|
||||
if (pOffset != NULL) {
|
||||
if (pOffset->val.type != TMQ_OFFSET__LOG) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s, no valid wal info", consumerId, vgId, req.subKey);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
}
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
dataRsp.rspOffset.version = sver; // not consume yet, set the earliest position
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
dataRsp.rspOffset.version = ever;
|
||||
} else {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||
reqOffset.type);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
|
||||
dataRsp.rspOffset.version = pOffset->val.version;
|
||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from store:%"PRId64, consumerId, vgId, req.subKey, dataRsp.rspOffset.version);
|
||||
}else{
|
||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
dataRsp.rspOffset.version = sver; // not consume yet, set the earliest position
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
dataRsp.rspOffset.version = ever;
|
||||
}
|
||||
tqInfo("consumer:0x%" PRIx64 " vgId:%d subkey:%s get assignment from init:%"PRId64, consumerId, vgId, req.subKey, dataRsp.rspOffset.version);
|
||||
}
|
||||
} else {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s invalid offset type:%d", consumerId, vgId, req.subKey,
|
||||
reqOffset.type);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tqDoSendDataRsp(&pMsg->info, &dataRsp, req.epoch, req.consumerId, TMQ_MSG_TYPE__WALINFO_RSP, sver, ever);
|
||||
tDeleteMqDataRsp(&dataRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,9 @@ int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
|
|||
memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||
pHandle->msg->pCont = rpcMallocCont(pMsg->contLen);
|
||||
} else {
|
||||
tqPushDataRsp(pHandle, vgId);
|
||||
// tqPushDataRsp(pHandle, vgId);
|
||||
tqPushEmptyDataRsp(pHandle, vgId);
|
||||
|
||||
void* tmp = pHandle->msg->pCont;
|
||||
memcpy(pHandle->msg, pMsg, sizeof(SRpcMsg));
|
||||
pHandle->msg->pCont = tmp;
|
||||
|
@ -89,7 +91,8 @@ int32_t tqUnregisterPushHandle(STQ* pTq, void *handle) {
|
|||
tqDebug("vgId:%d remove pHandle:%p,ret:%d consumer Id:0x%" PRIx64, vgId, pHandle, ret, pHandle->consumerId);
|
||||
|
||||
if(pHandle->msg != NULL) {
|
||||
tqPushDataRsp(pHandle, vgId);
|
||||
// tqPushDataRsp(pHandle, vgId);
|
||||
tqPushEmptyDataRsp(pHandle, vgId);
|
||||
|
||||
rpcFreeCont(pHandle->msg->pCont);
|
||||
taosMemoryFree(pHandle->msg);
|
||||
|
|
|
@ -99,7 +99,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
if (pOffset != NULL) {
|
||||
*pOffsetVal = pOffset->val;
|
||||
|
||||
char formatBuf[TSDB_OFFSET_LEN];
|
||||
char formatBuf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(formatBuf, TSDB_OFFSET_LEN, pOffsetVal);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64
|
||||
", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue. reqId:0x%" PRIx64,
|
||||
|
@ -157,17 +157,24 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void setRequestVersion(STqOffsetVal* offset, int64_t ver){
|
||||
if(offset->type == TMQ_OFFSET__LOG){
|
||||
offset->version = ver + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||
SRpcMsg* pMsg, STqOffsetVal* pOffset) {
|
||||
uint64_t consumerId = pRequest->consumerId;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
int code = 0;
|
||||
terrno = 0;
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, pRequest);
|
||||
dataRsp.reqOffset.type = pOffset->type; // stroe origin type for getting offset in tmq_get_vgroup_offset
|
||||
|
||||
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||
code = tqScanData(pTq, pHandle, &dataRsp, pOffset);
|
||||
int code = tqScanData(pTq, pHandle, &dataRsp, pOffset);
|
||||
if (code != 0 && terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
|
||||
goto end;
|
||||
}
|
||||
|
@ -182,11 +189,10 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
goto end;
|
||||
} else {
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
}
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
}
|
||||
|
||||
setRequestVersion(&dataRsp.reqOffset, pOffset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_RSP, vgId);
|
||||
|
||||
end : {
|
||||
|
@ -208,6 +214,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
SMqMetaRsp metaRsp = {0};
|
||||
STaosxRsp taosxRsp = {0};
|
||||
tqInitTaosxRsp(&taosxRsp, pRequest);
|
||||
taosxRsp.reqOffset.type = offset->type; // store origin type for getting offset in tmq_get_vgroup_offset
|
||||
|
||||
if (offset->type != TMQ_OFFSET__LOG) {
|
||||
if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, offset) < 0) {
|
||||
|
@ -260,6 +267,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
|
||||
if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead, pRequest->reqId) < 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP, vgId);
|
||||
goto end;
|
||||
}
|
||||
|
@ -272,6 +280,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
||||
if (totalRows > 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer - 1);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP, vgId);
|
||||
goto end;
|
||||
}
|
||||
|
@ -301,6 +310,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
|
||||
if (totalRows >= 4096 || taosxRsp.createTableNum > 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP, vgId);
|
||||
goto end;
|
||||
} else {
|
||||
|
|
|
@ -289,6 +289,10 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC
|
|||
static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) {
|
||||
int32_t i = 0, j = 0;
|
||||
|
||||
if (j < pSupInfo->numOfCols && PRIMARYKEY_TIMESTAMP_COL_ID == pSupInfo->colId[j]) {
|
||||
j += 1;
|
||||
}
|
||||
|
||||
while (i < pSchema->numOfCols && j < pSupInfo->numOfCols) {
|
||||
STColumn* pTCol = &pSchema->columns[i];
|
||||
if (pTCol->colId == pSupInfo->colId[j]) {
|
||||
|
|
|
@ -76,7 +76,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, STfs *p
|
|||
}
|
||||
|
||||
SSyncCfg *pCfg = &info.config.syncCfg;
|
||||
|
||||
|
||||
pCfg->replicaNum = 0;
|
||||
pCfg->totalReplicaNum = 0;
|
||||
memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo));
|
||||
|
@ -109,7 +109,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, STfs *p
|
|||
pCfg->myIndex = pReq->replica + pReq->learnerSelfIndex;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, save config while alter, replicas:%d totalReplicas:%d selfIndex:%d",
|
||||
vInfo("vgId:%d, save config while alter, replicas:%d totalReplicas:%d selfIndex:%d",
|
||||
pReq->vgId, pCfg->replicaNum, pCfg->totalReplicaNum, pCfg->myIndex);
|
||||
|
||||
info.config.syncCfg = *pCfg;
|
||||
|
@ -371,6 +371,10 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (metaUpgrade(pVnode, &pVnode->pMeta) < 0) {
|
||||
vError("vgId:%d, failed to upgrade meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
}
|
||||
|
||||
// open tsdb
|
||||
if (!VND_IS_RSMA(pVnode) && tsdbOpen(pVnode, &VND_TSDB(pVnode), VNODE_TSDB_DIR, NULL, rollback) < 0) {
|
||||
vError("vgId:%d, failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
|
|
|
@ -466,11 +466,6 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
|||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_TMQ_SEEK_TO_OFFSET:
|
||||
if (tqProcessSeekReq(pVnode->pTq, ver, pReq, pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
break;
|
||||
case TDMT_VND_TMQ_ADD_CHECKINFO:
|
||||
if (tqProcessAddCheckInfoReq(pVnode->pTq, ver, pReq, len) < 0) {
|
||||
goto _err;
|
||||
|
@ -643,6 +638,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
// return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_TMQ_VG_WALINFO:
|
||||
return tqProcessVgWalInfoReq(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_TMQ_SEEK:
|
||||
return tqProcessSeekReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_RUN:
|
||||
return tqProcessTaskRunReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_DISPATCH:
|
||||
|
|
|
@ -341,13 +341,10 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, SUserAuthInfo *pReq,
|
|||
SCtgAuthReq req = {0};
|
||||
req.pRawReq = pReq;
|
||||
req.pConn = pConn;
|
||||
req.onlyCache = exists ? true : false;
|
||||
req.onlyCache = false;
|
||||
CTG_ERR_RET(ctgGetUserDbAuthFromMnode(pCtg, pConn, pReq->user, &req.authInfo, NULL));
|
||||
|
||||
CTG_ERR_JRET(ctgChkSetAuthRes(pCtg, &req, &rsp));
|
||||
if (rsp.metaNotExists && exists) {
|
||||
*exists = false;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
||||
|
|
|
@ -1721,9 +1721,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
|
|||
ctgDebug("stb 0x%" PRIx64 " updated to cache, dbFName:%s, tbName:%s, tbType:%d", meta->suid, dbFName, tbName,
|
||||
meta->tableType);
|
||||
|
||||
if (pCache) {
|
||||
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateRentStbVersion(pCtg, dbFName, tbName, dbId, meta->suid, pCache));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -926,7 +926,6 @@ int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList) {
|
|||
}
|
||||
|
||||
pIter = taosHashIterate(vgHash, pIter);
|
||||
vgInfo = NULL;
|
||||
}
|
||||
|
||||
*pList = vgList;
|
||||
|
|
|
@ -613,7 +613,7 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* de
|
|||
|
||||
extern void doDestroyExchangeOperatorInfo(void* param);
|
||||
|
||||
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
||||
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo);
|
||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache);
|
||||
|
||||
|
|
|
@ -77,8 +77,7 @@ static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock*
|
|||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
|
||||
|
||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep,
|
||||
int32_t status);
|
||||
static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
|
||||
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||
bool createDummyCol);
|
||||
static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
|
||||
|
@ -501,20 +500,26 @@ void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
|||
}
|
||||
}
|
||||
|
||||
void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo) {
|
||||
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo) {
|
||||
if (pFilterInfo == NULL || pBlock->info.rows == 0) {
|
||||
return;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
|
||||
int32_t code = filterSetDataFromSlotId(pFilterInfo, ¶m1);
|
||||
SColumnInfoData* p = NULL;
|
||||
|
||||
SColumnInfoData* p = NULL;
|
||||
int32_t status = 0;
|
||||
int32_t code = filterSetDataFromSlotId(pFilterInfo, ¶m1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// todo the keep seems never to be True??
|
||||
bool keep = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, keep, status);
|
||||
int32_t status = 0;
|
||||
code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
|
||||
if (pColMatchInfo != NULL) {
|
||||
size_t size = taosArrayGetSize(pColMatchInfo->pList);
|
||||
|
@ -529,16 +534,15 @@ void doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pCol
|
|||
}
|
||||
}
|
||||
}
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
|
||||
_err:
|
||||
colDataDestroy(p);
|
||||
taosMemoryFree(p);
|
||||
return code;
|
||||
}
|
||||
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status) {
|
||||
if (keep) {
|
||||
return;
|
||||
}
|
||||
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
|
||||
int8_t* pIndicator = (int8_t*)p->pData;
|
||||
int32_t totalRows = pBlock->info.rows;
|
||||
|
||||
|
@ -546,7 +550,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
|
|||
// here nothing needs to be done
|
||||
} else if (status == FILTER_RESULT_NONE_QUALIFIED) {
|
||||
pBlock->info.rows = 0;
|
||||
} else {
|
||||
} else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
|
||||
int32_t bmLen = BitmapLen(totalRows);
|
||||
char* pBitmap = NULL;
|
||||
int32_t maxRows = 0;
|
||||
|
@ -674,6 +678,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
|
|||
if (pBitmap != NULL) {
|
||||
taosMemoryFree(pBitmap);
|
||||
}
|
||||
} else {
|
||||
qError("unknown filter result type: %d", status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +721,7 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR
|
|||
pCtx[j].resultInfo->numOfRes = pRow->numOfRows;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
blockDataEnsureCapacity(pBlock, pBlock->info.rows + pCtx[j].resultInfo->numOfRes);
|
||||
int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
||||
if (TAOS_FAILED(code)) {
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct SIndefOperatorInfo {
|
|||
SSDataBlock* pNextGroupRes;
|
||||
} SIndefOperatorInfo;
|
||||
|
||||
static SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator);
|
||||
static int32_t doGenerateSourceData(SOperatorInfo* pOperator);
|
||||
static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator);
|
||||
static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator);
|
||||
static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols);
|
||||
|
@ -200,7 +200,7 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S
|
|||
if (newGroup) {
|
||||
resetLimitInfoForNextGroup(pLimitInfo);
|
||||
}
|
||||
|
||||
|
||||
return PROJECT_RETRIEVE_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,12 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
|
|||
SLimitInfo* pLimitInfo = &pProjectInfo->limitInfo;
|
||||
|
||||
if (downstream == NULL) {
|
||||
return doGenerateSourceData(pOperator);
|
||||
code = doGenerateSourceData(pOperator);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -601,7 +606,7 @@ SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) {
|
|||
return pList;
|
||||
}
|
||||
|
||||
SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) {
|
||||
int32_t doGenerateSourceData(SOperatorInfo* pOperator) {
|
||||
SProjectOperatorInfo* pProjectInfo = pOperator->info;
|
||||
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
@ -615,14 +620,45 @@ SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) {
|
|||
for (int32_t k = 0; k < pSup->numOfExprs; ++k) {
|
||||
int32_t outputSlotId = pExpr[k].base.resSchema.slotId;
|
||||
|
||||
ASSERT(pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE);
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pRes->pDataBlock, outputSlotId);
|
||||
if (pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pRes->pDataBlock, outputSlotId);
|
||||
|
||||
int32_t type = pExpr[k].base.pParam[0].param.nType;
|
||||
if (TSDB_DATA_TYPE_NULL == type) {
|
||||
colDataSetNNULL(pColInfoData, 0, 1);
|
||||
int32_t type = pExpr[k].base.pParam[0].param.nType;
|
||||
if (TSDB_DATA_TYPE_NULL == type) {
|
||||
colDataSetNNULL(pColInfoData, 0, 1);
|
||||
} else {
|
||||
colDataSetVal(pColInfoData, 0, taosVariantGet(&pExpr[k].base.pParam[0].param, type), false);
|
||||
}
|
||||
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
||||
SqlFunctionCtx* pfCtx = &pSup->pCtx[k];
|
||||
|
||||
// UDF scalar functions will be calculated here, for example, select foo(n) from (select 1 n).
|
||||
// UDF aggregate functions will be handled in agg operator.
|
||||
if (fmIsScalarFunc(pfCtx->functionId)) {
|
||||
SArray* pBlockList = taosArrayInit(4, POINTER_BYTES);
|
||||
taosArrayPush(pBlockList, &pRes);
|
||||
|
||||
SColumnInfoData* pResColData = taosArrayGet(pRes->pDataBlock, outputSlotId);
|
||||
SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
|
||||
|
||||
SScalarParam dest = {.columnData = &idata};
|
||||
int32_t code = scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pBlockList);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t startOffset = pRes->info.rows;
|
||||
ASSERT(pRes->info.capacity > 0);
|
||||
colDataAssign(pResColData, &idata, dest.numOfRows, &pRes->info);
|
||||
colDataDestroy(&idata);
|
||||
|
||||
taosArrayDestroy(pBlockList);
|
||||
} else {
|
||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
}
|
||||
} else {
|
||||
colDataSetVal(pColInfoData, 0, taosVariantGet(&pExpr[k].base.pParam[0].param, type), false);
|
||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,7 +674,7 @@ SSDataBlock* doGenerateSourceData(SOperatorInfo* pOperator) {
|
|||
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
|
||||
}
|
||||
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, SArray* pPseudoList) {
|
||||
|
|
|
@ -400,9 +400,10 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
pCost->totalRows -= pBlock->info.rows;
|
||||
|
||||
if (pOperator->exprSupp.pFilterInfo != NULL) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
doFilter(pBlock, pOperator->exprSupp.pFilterInfo, &pTableScanInfo->matchInfo);
|
||||
int32_t code = doFilter(pBlock, pOperator->exprSupp.pFilterInfo, &pTableScanInfo->matchInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) return code;
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
pTableScanInfo->readRecorder.filterTime += el;
|
||||
|
||||
|
@ -2797,7 +2798,7 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
|||
} else if (kWay <= 2) {
|
||||
kWay = 2;
|
||||
} else {
|
||||
int i = 2;
|
||||
int i = 2;
|
||||
while (i * 2 <= kWay) i = i * 2;
|
||||
kWay = i;
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||
float v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, float, pVar->nType, &pVar->i);
|
||||
GET_TYPED_DATA(v, float, pVar->nType, &pVar->f);
|
||||
} else {
|
||||
v = taosStr2Float(varDataVal(pVar->pz), NULL);
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
} else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
double v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, double, pVar->nType, &pVar->i);
|
||||
GET_TYPED_DATA(v, double, pVar->nType, &pVar->d);
|
||||
} else {
|
||||
v = taosStr2Double(varDataVal(pVar->pz), NULL);
|
||||
}
|
||||
|
@ -333,7 +333,15 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i);
|
||||
} else {
|
||||
v = taosStr2int64(varDataVal(pVar->pz));
|
||||
v = taosStr2Int64(varDataVal(pVar->pz), NULL, 10);
|
||||
}
|
||||
colDataSetVal(pDst, rows, (char*)&v, false);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pDst->info.type)) {
|
||||
uint64_t v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, uint64_t, pVar->nType, &pVar->u);
|
||||
} else {
|
||||
v = taosStr2UInt64(varDataVal(pVar->pz), NULL, 10);
|
||||
}
|
||||
colDataSetVal(pDst, rows, (char*)&v, false);
|
||||
} else if (IS_BOOLEAN_TYPE(pDst->info.type)) {
|
||||
|
|
|
@ -127,7 +127,7 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem
|
|||
|
||||
if(kv->keyLen != strlen(pTagSchema->name) || memcmp(kv->key, pTagSchema->name, kv->keyLen) != 0 || kv->type != pTagSchema->type){
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
uError("SML smlBuildCol error col not same %s", pTagSchema->name);
|
||||
uError("SML smlBuildTagRow error col not same %s", pTagSchema->name);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32
|
|||
SSmlKv* kv = (SSmlKv*)data;
|
||||
if(kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0 || kv->type != pColSchema->type){
|
||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
||||
uError("SML smlBuildCol error col not same %s", pColSchema->name);
|
||||
uInfo("SML smlBuildCol error col not same %s", pColSchema->name);
|
||||
goto end;
|
||||
}
|
||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
|
|
@ -878,6 +878,7 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
|
|||
(igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0));
|
||||
for (int32_t i = 0; i < nums; ++i) {
|
||||
if (invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
pCxt->pParseCxt->hasInvisibleCol = true;
|
||||
continue;
|
||||
}
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
|
@ -3203,7 +3204,11 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
code = translateFillValues(pCxt, pSelect);
|
||||
}
|
||||
if (NULL == pSelect->pProjectionList || 0 >= pSelect->pProjectionList->length) {
|
||||
code = TSDB_CODE_PAR_INVALID_SELECTED_EXPR;
|
||||
if (pCxt->pParseCxt->hasInvisibleCol) {
|
||||
code = TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
} else {
|
||||
code = TSDB_CODE_PAR_INVALID_SELECTED_EXPR;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -6044,6 +6049,9 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
|
|||
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
|
||||
SSchema* column = &pMeta->schema[0];
|
||||
SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == col) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(col->colName, column->name);
|
||||
strcpy(col->node.aliasName, col->colName);
|
||||
strcpy(col->node.userAlias, col->colName);
|
||||
|
@ -6154,7 +6162,7 @@ static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pSt
|
|||
char* p = strchr(pStmt->config, ' ');
|
||||
if (NULL != p) {
|
||||
*p = 0;
|
||||
strcpy(pStmt->value, p + 1);
|
||||
tstrncpy(pStmt->value, p + 1, sizeof(pStmt->value));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1979,7 +1979,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
|||
int32_t code = sclConvertValueToSclParam(var, &out, NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("convert value to type[%d] failed", type);
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
return code;
|
||||
}
|
||||
|
||||
size_t bufBytes = IS_VAR_DATA_TYPE(type) ? varDataTLen(out.columnData->pData)
|
||||
|
@ -4644,11 +4644,11 @@ _return:
|
|||
FLT_RET(code);
|
||||
}
|
||||
|
||||
bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis, int16_t numOfCols,
|
||||
int32_t *pResultStatus) {
|
||||
int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis,
|
||||
int16_t numOfCols, int32_t *pResultStatus) {
|
||||
if (NULL == info) {
|
||||
*pResultStatus = FILTER_RESULT_ALL_QUALIFIED;
|
||||
return false;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SScalarParam output = {0};
|
||||
|
@ -4656,7 +4656,7 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC
|
|||
|
||||
int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return false;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (info->scalarMode) {
|
||||
|
@ -4666,7 +4666,7 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC
|
|||
code = scalarCalculate(info->sclCtx.node, pList, &output);
|
||||
taosArrayDestroy(pList);
|
||||
|
||||
FLT_ERR_RET(code); // TODO: current errcode returns as true
|
||||
FLT_ERR_RET(code);
|
||||
|
||||
*p = output.columnData;
|
||||
|
||||
|
@ -4677,18 +4677,23 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC
|
|||
} else {
|
||||
*pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED;
|
||||
}
|
||||
return false;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT(false == info->scalarMode);
|
||||
*p = output.columnData;
|
||||
output.numOfRows = pSrc->info.rows;
|
||||
|
||||
if (*p == NULL) {
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
bool keepAll = (*info->func)(info, pSrc->info.rows, *p, statis, numOfCols, &output.numOfQualified);
|
||||
|
||||
// todo this should be return during filter procedure
|
||||
if (keepAll) {
|
||||
*pResultStatus = FILTER_RESULT_ALL_QUALIFIED;
|
||||
} else {
|
||||
*p = output.columnData;
|
||||
output.numOfRows = pSrc->info.rows;
|
||||
|
||||
if (*p == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool keep = (*info->func)(info, pSrc->info.rows, *p, statis, numOfCols, &output.numOfQualified);
|
||||
|
||||
// todo this should be return during filter procedure
|
||||
int32_t num = 0;
|
||||
for (int32_t i = 0; i < output.numOfRows; ++i) {
|
||||
if (((int8_t *)((*p)->pData))[i] == 1) {
|
||||
|
@ -4703,9 +4708,9 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC
|
|||
} else {
|
||||
*pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED;
|
||||
}
|
||||
|
||||
return keep;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
typedef struct SClassifyConditionCxt {
|
||||
|
|
|
@ -1694,7 +1694,8 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
SCL_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (1 == res->numOfRows) {
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
if (1 == res->numOfRows && pb->info.rows > 0) {
|
||||
SCL_ERR_JRET(sclExtendResRows(pDst, res, pBlockList));
|
||||
} else {
|
||||
colInfoDataEnsureCapacity(pDst->columnData, res->numOfRows, true);
|
||||
|
|
|
@ -240,15 +240,20 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
int64_t value = 0;
|
||||
if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||
value = 0;
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
|
||||
colDataSetInt64(pOut->columnData, rowIndex, &value);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void varToSigned(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (overflow) {
|
||||
int64_t minValue = tDataTypes[pOut->columnData->info.type].minValue;
|
||||
int64_t maxValue = tDataTypes[pOut->columnData->info.type].maxValue;
|
||||
|
@ -290,6 +295,8 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam *pOut, int32_t rowI
|
|||
}
|
||||
|
||||
static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (overflow) {
|
||||
uint64_t minValue = (uint64_t)tDataTypes[pOut->columnData->info.type].minValue;
|
||||
uint64_t maxValue = (uint64_t)tDataTypes[pOut->columnData->info.type].maxValue;
|
||||
|
@ -330,6 +337,8 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam *pOut, int32_t ro
|
|||
}
|
||||
|
||||
static FORCE_INLINE void varToFloat(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (TSDB_DATA_TYPE_FLOAT == pOut->columnData->info.type) {
|
||||
float value = taosStr2Float(buf, NULL);
|
||||
colDataSetFloat(pOut->columnData, rowIndex, &value);
|
||||
|
@ -341,6 +350,8 @@ static FORCE_INLINE void varToFloat(char *buf, SScalarParam *pOut, int32_t rowIn
|
|||
}
|
||||
|
||||
static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
int64_t value = taosStr2Int64(buf, NULL, 10);
|
||||
bool v = (value != 0) ? true : false;
|
||||
colDataSetInt8(pOut->columnData, rowIndex, (int8_t *)&v);
|
||||
|
@ -348,6 +359,8 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowInd
|
|||
|
||||
// todo remove this malloc
|
||||
static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
int32_t len = 0;
|
||||
int32_t inputLen = varDataLen(buf);
|
||||
int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
|
||||
|
@ -357,6 +370,7 @@ static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIn
|
|||
taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len);
|
||||
if (!ret) {
|
||||
sclError("failed to convert to NCHAR");
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
varDataSetLen(t, len);
|
||||
|
||||
|
@ -365,11 +379,14 @@ static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIn
|
|||
}
|
||||
|
||||
static FORCE_INLINE void ncharToVar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
int32_t inputLen = varDataLen(buf);
|
||||
|
||||
char *t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE);
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t));
|
||||
if (len < 0) {
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
taosMemoryFree(t);
|
||||
return;
|
||||
}
|
||||
|
@ -379,22 +396,26 @@ static FORCE_INLINE void ncharToVar(char *buf, SScalarParam *pOut, int32_t rowIn
|
|||
taosMemoryFree(t);
|
||||
}
|
||||
|
||||
// todo remove this malloc
|
||||
static FORCE_INLINE void varToGeometry(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) {
|
||||
//[ToDo] support to parse WKB as well as WKT
|
||||
unsigned char *t = NULL;
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
size_t len = 0;
|
||||
unsigned char *t = NULL;
|
||||
char *output = NULL;
|
||||
|
||||
if (initCtxGeomFromText()) {
|
||||
sclError("failed to init geometry ctx");
|
||||
return;
|
||||
sclError("failed to init geometry ctx, %s", getThreadLocalGeosCtx()->errMsg);
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
if (doGeomFromText(buf, &t, &len)) {
|
||||
sclDebug("failed to convert text to geometry");
|
||||
return;
|
||||
sclInfo("failed to convert text to geometry, %s", getThreadLocalGeosCtx()->errMsg);
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
char *output = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||
output = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||
memcpy(output + VARSTR_HEADER_SIZE, t, len);
|
||||
varDataSetLen(output, len);
|
||||
|
||||
|
@ -402,10 +423,19 @@ static FORCE_INLINE void varToGeometry(char *buf, SScalarParam *pOut, int32_t ro
|
|||
|
||||
taosMemoryFree(output);
|
||||
geosFreeBuffer(t);
|
||||
|
||||
return;
|
||||
|
||||
_err:
|
||||
ASSERT(t == NULL && len == 0);
|
||||
VarDataLenT dummyHeader = 0;
|
||||
colDataSetVal(pOut->columnData, rowIndex, (const char *)&dummyHeader, false);
|
||||
}
|
||||
|
||||
// TODO opt performance, tmp is not needed.
|
||||
int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
bool vton = false;
|
||||
|
||||
_bufConverteFunc func = NULL;
|
||||
|
@ -431,7 +461,8 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
|||
func = varToGeometry;
|
||||
} else {
|
||||
sclError("invalid convert outType:%d, inType:%d", pCtx->outType, pCtx->inType);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCtx->pOut->numOfRows = pCtx->pIn->numOfRows;
|
||||
|
@ -451,7 +482,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
|||
convertType = TSDB_DATA_TYPE_NCHAR;
|
||||
} else if (tTagIsJson(data) || *data == TSDB_DATA_TYPE_NULL) {
|
||||
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
|
||||
return terrno;
|
||||
goto _err;
|
||||
} else {
|
||||
convertNumberToNumber(data + CHAR_BYTES, colDataGetNumData(pCtx->pOut->columnData, i), *data, pCtx->outType);
|
||||
continue;
|
||||
|
@ -463,7 +494,8 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
|||
tmp = taosMemoryMalloc(bufSize);
|
||||
if (tmp == NULL) {
|
||||
sclError("out of memory in vectorConvertFromVarData");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,15 +509,15 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
|||
// we need to convert it to native char string, and then perform the string to numeric data
|
||||
if (varDataLen(data) > bufSize) {
|
||||
sclError("castConvert convert buffer size too small");
|
||||
taosMemoryFreeClear(tmp);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp);
|
||||
if (len < 0) {
|
||||
sclError("castConvert taosUcs4ToMbs error 1");
|
||||
taosMemoryFreeClear(tmp);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tmp[len] = 0;
|
||||
|
@ -493,12 +525,16 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
|
|||
}
|
||||
|
||||
(*func)(tmp, pCtx->pOut, i, overflow);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
_err:
|
||||
if (tmp != NULL) {
|
||||
taosMemoryFreeClear(tmp);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
double getVectorDoubleValue_JSON(void *src, int32_t index) {
|
||||
|
@ -911,25 +947,25 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut,
|
|||
int8_t gConvertTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = {
|
||||
/* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/
|
||||
/*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*BOOL*/ 0, 0, 2, 3, 4, 5, 6, 7, 5, 9, 7, 11, 12, 13, 14, 0, 7, 0, 0, 0, 0,
|
||||
/*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 5, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 5, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 5, 9, 7, 4, 4, 5, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 5, 9, 7, 5, 5, 5, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 0, 7, 0, 0, 0, 0,
|
||||
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*BOOL*/ 0, 0, 2, 3, 4, 5, 6, 7, 5, 9, 7, 11, 12, 13, 14, 0, 7, 0, 0, 0, -1,
|
||||
/*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 5, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 5, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 5, 9, 7, 4, 4, 5, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 5, 9, 7, 5, 5, 5, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 0, 7, 0, 0, 0, -1,
|
||||
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 7, 7, 7, 7, 0, 0, 0, 0, 0, 20,
|
||||
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 7, 0, 7, 0, 0, 0, 0,
|
||||
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0,
|
||||
/*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 0, 7, 0, 0, 0, 0,
|
||||
/*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 7, 0, 0, 0, 0,
|
||||
/*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 7, 0, 0, 0, 0,
|
||||
/*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0,
|
||||
/*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*MEDB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 7, 0, 7, 0, 0, 0, -1,
|
||||
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, 0, -1,
|
||||
/*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 0, 7, 0, 0, 0, -1,
|
||||
/*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 7, 0, 0, 0, -1,
|
||||
/*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 7, 0, 0, 0, -1,
|
||||
/*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, -1,
|
||||
/*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
|
||||
/*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
|
||||
/*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
|
||||
/*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
|
||||
/*MEDB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
|
||||
/*GEOM*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2) {
|
||||
|
@ -1010,6 +1046,11 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara
|
|||
if (0 == type) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (-1 == type) {
|
||||
sclError("invalid convert type1:%d, type2:%d", GET_PARAM_TYPE(param1), GET_PARAM_TYPE(param2));
|
||||
terrno = TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
return TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != GET_PARAM_TYPE(param1)) {
|
||||
|
@ -1753,7 +1794,9 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *
|
|||
param1 = pLeft;
|
||||
param2 = pRight;
|
||||
} else {
|
||||
vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows);
|
||||
if (vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows)) {
|
||||
return;
|
||||
}
|
||||
param1 = (pLeftOut.columnData != NULL) ? &pLeftOut : pLeft;
|
||||
param2 = (pRightOut.columnData != NULL) ? &pRightOut : pRight;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) {
|
|||
break;
|
||||
case JOB_TASK_STATUS_DROP:
|
||||
SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED);
|
||||
break;
|
||||
|
||||
default:
|
||||
SCH_JOB_ELOG("invalid job status:%s", jobTaskStatusStr(oriStatus));
|
||||
|
|
|
@ -392,6 +392,7 @@ int32_t schProcessResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SD
|
|||
// NEVER REACH HERE
|
||||
SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:0x%" PRIx64, pJob->refId);
|
||||
SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
break;
|
||||
}
|
||||
case TDMT_SCH_LINK_BROKEN:
|
||||
SCH_TASK_ELOG("link broken received, error:%x - %s", rspCode, tstrerror(rspCode));
|
||||
|
|
|
@ -961,7 +961,6 @@ int32_t schHandleExplainRes(SArray *pExplainRes) {
|
|||
localRsp->rsp.numOfPlans = 0;
|
||||
localRsp->rsp.subplanInfo = NULL;
|
||||
pTask = NULL;
|
||||
pJob = NULL;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
|
|
@ -35,7 +35,7 @@ int32_t schedulerInit() {
|
|||
schMgmt.cfg.schPolicy = SCHEDULE_DEFAULT_POLICY;
|
||||
schMgmt.cfg.enableReSchedule = true;
|
||||
|
||||
qDebug("schedule init, policy: %d, maxNodeTableNum: %" PRId64", reSchedule:%d",
|
||||
qDebug("schedule init, policy: %d, maxNodeTableNum: %" PRId64", reSchedule:%d",
|
||||
schMgmt.cfg.schPolicy, schMgmt.cfg.maxNodeTableNum, schMgmt.cfg.enableReSchedule);
|
||||
|
||||
schMgmt.jobRef = taosOpenRef(schMgmt.cfg.maxJobNum, schFreeJobImpl);
|
||||
|
@ -57,11 +57,11 @@ int32_t schedulerInit() {
|
|||
}
|
||||
|
||||
if (taosGetSystemUUID((char *)&schMgmt.sId, sizeof(schMgmt.sId))) {
|
||||
qError("generate schdulerId failed, errno:%d", errno);
|
||||
qError("generate schedulerId failed, errno:%d", errno);
|
||||
SCH_ERR_RET(TSDB_CODE_QRY_SYS_ERROR);
|
||||
}
|
||||
|
||||
qInfo("scheduler 0x%" PRIx64 " initizlized, maxJob:%u", schMgmt.sId, schMgmt.cfg.maxJobNum);
|
||||
qInfo("scheduler 0x%" PRIx64 " initialized, maxJob:%u", schMgmt.sId, schMgmt.cfg.maxJobNum);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -403,7 +403,16 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
|||
// wait for the task to be ready to go
|
||||
while (pTask->taskLevel == TASK_LEVEL__SOURCE) {
|
||||
int8_t status = atomic_load_8(&pTask->status.taskStatus);
|
||||
if (status != TASK_STATUS__NORMAL && status != TASK_STATUS__PAUSE) {
|
||||
if (status == TASK_STATUS__DROPPING) {
|
||||
if (pInput != NULL) {
|
||||
streamFreeQitem(pInput);
|
||||
}
|
||||
|
||||
qError("s-task:%s task is dropped, abort exec", id);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (status != TASK_STATUS__NORMAL && status != TASK_STATUS__PAUSE && status != TASK_STATUS__STOP) {
|
||||
qError("stream task wait for the end of fill history, s-task:%s, status:%d", id, status);
|
||||
taosMsleep(100);
|
||||
} else {
|
||||
|
|
|
@ -82,6 +82,11 @@ int32_t walNextValidMsg(SWalReader *pReader) {
|
|||
", applied index:%" PRId64", end index:%" PRId64,
|
||||
pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer, endVer);
|
||||
|
||||
if (fetchVer > endVer){
|
||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fetchVer <= endVer) {
|
||||
if (walFetchHeadNew(pReader, fetchVer) < 0) {
|
||||
return -1;
|
||||
|
|
|
@ -626,8 +626,15 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FS_UPDATE, "Rsma fs update erro
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_INVALID_FILE, "Index file is invalid")
|
||||
|
||||
//scalar
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_SCALAR_CONVERT_ERROR, "Cannot convert to specific type")
|
||||
|
||||
//tmq
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_MSG, "Invalid message")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_SNAPSHOT_ERROR, "Can not operate in snapshot mode")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_VERSION_OUT_OF_RANGE, "Offset out of range")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_VGID, "VgId does not belong to this consumer")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_TOPIC, "Topic does not belong to this consumer")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_MISMATCH, "Consumer mismatch")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_CLOSED, "Consumer closed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_ERROR, "Consumer error, to see log")
|
||||
|
@ -675,7 +682,7 @@ const char* tstrerror(int32_t err) {
|
|||
if ((err & 0x00ff0000) == 0x00ff0000) {
|
||||
int32_t code = err & 0x0000ffff;
|
||||
// strerror can handle any invalid code
|
||||
// invalid code return Unknown error
|
||||
// invalid code return Unknown error
|
||||
return strerror(code);
|
||||
}
|
||||
int32_t s = 0;
|
||||
|
|
|
@ -755,6 +755,8 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py
|
||||
,,n,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/insertMix.py -N 3
|
||||
,,n,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/stt.py -N 3
|
||||
|
||||
#tsim test
|
||||
,,y,script,./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim
|
||||
|
|
|
@ -151,10 +151,10 @@ class TDTestCase:
|
|||
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database db4096 '")
|
||||
os.system("LD_LIBRARY_PATH=/usr/lib taos -f 0-others/TS-3131.tsql")
|
||||
|
||||
# cmd = f" LD_LIBRARY_PATH={bPath}/build/lib {bPath}/build/bin/taos -h localhost ;"
|
||||
# tdLog.info(f"new client version connect to old version taosd, commad return value:{cmd}")
|
||||
# if os.system(cmd) == 0:
|
||||
# raise Exception("failed to execute system command. cmd: %s" % cmd)
|
||||
cmd = f" LD_LIBRARY_PATH={bPath}/build/lib {bPath}/build/bin/taos -h localhost ;"
|
||||
tdLog.info(f"new client version connect to old version taosd, commad return value:{cmd}")
|
||||
if os.system(cmd) == 0:
|
||||
raise Exception("failed to execute system command. cmd: %s" % cmd)
|
||||
|
||||
os.system("pkill taosd") # make sure all the data are saved in disk.
|
||||
self.checkProcessPid("taosd")
|
||||
|
|
|
@ -234,6 +234,11 @@ class TDTestCase:
|
|||
tdSql.checkData(20,6,88)
|
||||
tdSql.checkData(20,7,1)
|
||||
|
||||
tdSql.query("select udf1(1) from (select 1)")
|
||||
tdSql.checkData(0,0,1)
|
||||
|
||||
tdSql.query("select udf1(n) from (select 1 n)")
|
||||
tdSql.checkData(0,0,1)
|
||||
|
||||
# aggregate functions
|
||||
tdSql.query("select udf2(num1) ,udf2(num2), udf2(num3) from tb")
|
||||
|
|
|
@ -0,0 +1,409 @@
|
|||
from itertools import product
|
||||
import taos
|
||||
import time
|
||||
from taos.tmq import *
|
||||
from util.cases import *
|
||||
from util.common import *
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.sqlset import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
"""This test case is used to veirfy the user privilege for insert and select operation on
|
||||
stable、child table and table
|
||||
"""
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
# init the tdsql
|
||||
tdSql.init(conn.cursor())
|
||||
self.setsql = TDSetSql()
|
||||
# user info
|
||||
self.username = 'test'
|
||||
self.password = 'test'
|
||||
# db info
|
||||
self.dbname = "user_privilege_all_db"
|
||||
self.stbname = 'stb'
|
||||
self.common_tbname = "tb"
|
||||
self.ctbname_list = ["ct1", "ct2"]
|
||||
self.common_table_dict = {
|
||||
'ts':'timestamp',
|
||||
'col1':'float',
|
||||
'col2':'int'
|
||||
}
|
||||
self.stable_column_dict = {
|
||||
'ts': 'timestamp',
|
||||
'col1': 'float',
|
||||
'col2': 'int',
|
||||
}
|
||||
self.tag_dict = {
|
||||
'ctbname': 'binary(10)'
|
||||
}
|
||||
|
||||
# case list
|
||||
self.cases = {
|
||||
"test_db_table_both_no_permission": {
|
||||
"db_privilege": "none",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct1 using stb tags('ct1') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, False, False, False, False, False]
|
||||
},
|
||||
"test_db_no_permission_table_read": {
|
||||
"db_privilege": "none",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "read",
|
||||
"sql": ["insert into ct1 using stb tags('ct1') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, False, False, False, False, True]
|
||||
},
|
||||
"test_db_no_permission_childtable_read": {
|
||||
"db_privilege": "none",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "read",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct1 using stb tags('ct1') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, False, False, False]
|
||||
},
|
||||
"test_db_no_permission_table_write": {
|
||||
"db_privilege": "none",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "write",
|
||||
"sql": ["insert into ct1 using stb tags('ct1') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, False, False, False, True, False]
|
||||
},
|
||||
"test_db_no_permission_childtable_write": {
|
||||
"db_privilege": "none",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "write",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [True, False, False, False, False, False]
|
||||
},
|
||||
"test_db_read_table_no_permission": {
|
||||
"db_privilege": "read",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, True, False, True]
|
||||
},
|
||||
"test_db_read_table_read": {
|
||||
"db_privilege": "read",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "read",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, True, False, True]
|
||||
},
|
||||
"test_db_read_childtable_read": {
|
||||
"db_privilege": "read",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "read",
|
||||
"child_table_ct2_privilege": "read",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 3.3, 3);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, True, False, True]
|
||||
},
|
||||
"test_db_read_table_write": {
|
||||
"db_privilege": "read",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "write",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 4.4, 4);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, True, True, True]
|
||||
},
|
||||
"test_db_read_childtable_write": {
|
||||
"db_privilege": "read",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "write",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 1.1, 1)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 5.5, 5)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 4.4, 4);",
|
||||
"select * from tb;"],
|
||||
"res": [False, True, True, True, True, False, True]
|
||||
},
|
||||
"test_db_write_table_no_permission": {
|
||||
"db_privilege": "write",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 6.6, 6)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 7.7, 7)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 8.8, 8);",
|
||||
"select * from tb;"],
|
||||
"res": [True, True, False, False, False, True, False]
|
||||
},
|
||||
"test_db_write_table_write": {
|
||||
"db_privilege": "write",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 9.9, 9)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 10.0, 10)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 11.1, 11);",
|
||||
"select * from tb;"],
|
||||
"res": [True, True, False, False, False, True, False]
|
||||
},
|
||||
"test_db_write_childtable_write": {
|
||||
"db_privilege": "write",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 12.2, 12)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 13.3, 13)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 14.4, 14);",
|
||||
"select * from tb;"],
|
||||
"res": [True, True, False, False, False, True, False]
|
||||
},
|
||||
"test_db_write_table_read": {
|
||||
"db_privilege": "write",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "none",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "read",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 15.5, 15)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 16.6, 16)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 17.7, 17);",
|
||||
"select * from tb;"],
|
||||
"res": [True, True, False, False, False, True, True]
|
||||
},
|
||||
"test_db_write_childtable_read": {
|
||||
"db_privilege": "write",
|
||||
"stable_priviege": "none",
|
||||
"child_table_ct1_privilege": "read",
|
||||
"child_table_ct2_privilege": "none",
|
||||
"table_tb_privilege": "none",
|
||||
"sql": ["insert into ct2 using stb tags('ct2') values(now, 18.8, 18)",
|
||||
"insert into ct1 using stb tags('ct1') values(now, 19.9, 19)",
|
||||
"select * from stb;",
|
||||
"select * from ct1;",
|
||||
"select * from ct2;",
|
||||
"insert into tb values(now, 20.0, 20);",
|
||||
"select * from tb;"],
|
||||
"res": [True, True, True, True, False, True, False]
|
||||
}
|
||||
}
|
||||
|
||||
def prepare_data(self):
|
||||
"""Create the db and data for test
|
||||
"""
|
||||
tdLog.debug("Start to prepare the data for test")
|
||||
# create datebase
|
||||
tdSql.execute(f"create database {self.dbname}")
|
||||
tdSql.execute(f"use {self.dbname}")
|
||||
|
||||
# create stable
|
||||
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname, self.stable_column_dict, self.tag_dict))
|
||||
tdLog.debug("Create stable {} successfully".format(self.stbname))
|
||||
|
||||
# insert data into child table
|
||||
for ctname in self.ctbname_list:
|
||||
tdSql.execute(f"insert into {ctname} using {self.stbname} tags('{ctname}') values(now, 1.1, 1)")
|
||||
tdSql.execute(f"insert into {ctname} using {self.stbname} tags('{ctname}') values(now, 2.1, 2)")
|
||||
|
||||
# create common table
|
||||
tdSql.execute(self.setsql.set_create_normaltable_sql(self.common_tbname, self.common_table_dict))
|
||||
tdLog.debug("Create common table {} successfully".format(self.common_tbname))
|
||||
|
||||
# insert data into common table
|
||||
tdSql.execute(f"insert into {self.common_tbname} values(now, 1.1, 1)")
|
||||
tdSql.execute(f"insert into {self.common_tbname} values(now, 2.2, 2)")
|
||||
tdLog.debug("Finish to prepare the data")
|
||||
|
||||
def create_user(self):
|
||||
"""Create the user for test
|
||||
"""
|
||||
tdSql.execute(f'create user {self.username} pass "{self.password}"')
|
||||
tdLog.debug("sql:" + f'create user {self.username} pass "{self.password}" successfully')
|
||||
|
||||
def grant_privilege(self, username, privilege, table, tag_condition=None):
|
||||
"""Add the privilege for the user
|
||||
"""
|
||||
try:
|
||||
if tag_condition:
|
||||
tdSql.execute(f'grant {privilege} on {self.dbname}.{table} with {tag_condition} to {username}')
|
||||
else:
|
||||
tdSql.execute(f'grant {privilege} on {self.dbname}.{table} to {username}')
|
||||
time.sleep(2)
|
||||
tdLog.debug("Grant {} privilege on {}.{} with condition {} to {} successfully".format(privilege, self.dbname, table, tag_condition, username))
|
||||
except Exception as ex:
|
||||
tdLog.exit(ex)
|
||||
|
||||
def remove_privilege(self, username, privilege, table, tag_condition=None):
|
||||
"""Remove the privilege for the user
|
||||
"""
|
||||
try:
|
||||
if tag_condition:
|
||||
tdSql.execute(f'revoke {privilege} on {self.dbname}.{table} with {tag_condition} from {username}')
|
||||
else:
|
||||
tdSql.execute(f'revoke {privilege} on {self.dbname}.{table} from {username}')
|
||||
tdLog.debug("Revoke {} privilege on {}.{} with condition {} from {} successfully".format(privilege, self.dbname, table, tag_condition, username))
|
||||
except Exception as ex:
|
||||
tdLog.exit(ex)
|
||||
|
||||
def run(self):
|
||||
self.create_user()
|
||||
# prepare the test data
|
||||
self.prepare_data()
|
||||
|
||||
for case_name in self.cases.keys():
|
||||
tdLog.debug("Execute the case {} with params {}".format(case_name, str(self.cases[case_name])))
|
||||
# grant privilege for user test if case need
|
||||
if self.cases[case_name]["db_privilege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["db_privilege"], "*")
|
||||
if self.cases[case_name]["stable_priviege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["stable_priviege"], self.stbname)
|
||||
if self.cases[case_name]["child_table_ct1_privilege"] != "none" and self.cases[case_name]["child_table_ct2_privilege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["child_table_ct1_privilege"], self.stbname, "ctbname='ct1' or ctbname='ct2'")
|
||||
elif self.cases[case_name]["child_table_ct1_privilege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["child_table_ct1_privilege"], self.stbname, "ctbname='ct1'")
|
||||
elif self.cases[case_name]["child_table_ct2_privilege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["child_table_ct2_privilege"], self.stbname, "ctbname='ct2'")
|
||||
if self.cases[case_name]["table_tb_privilege"] != "none":
|
||||
self.grant_privilege(self.username, self.cases[case_name]["table_tb_privilege"], self.common_tbname)
|
||||
# connect db with user test
|
||||
testconn = taos.connect(user=self.username, password=self.password)
|
||||
if case_name != "test_db_table_both_no_permission":
|
||||
testconn.execute("use %s;" % self.dbname)
|
||||
# check privilege of user test from ins_user_privileges table
|
||||
res = testconn.query("select * from information_schema.ins_user_privileges;")
|
||||
tdLog.debug("Current information_schema.ins_user_privileges values: {}".format(res.fetch_all()))
|
||||
# check privilege of user test by executing sql query
|
||||
for index in range(len(self.cases[case_name]["sql"])):
|
||||
tdLog.debug("Execute sql: {}".format(self.cases[case_name]["sql"][index]))
|
||||
try:
|
||||
# for write privilege
|
||||
if "insert " in self.cases[case_name]["sql"][index]:
|
||||
testconn.execute(self.cases[case_name]["sql"][index])
|
||||
# check the expected result
|
||||
if self.cases[case_name]["res"][index]:
|
||||
tdLog.debug("Write data with sql {} successfully".format(self.cases[case_name]["sql"][index]))
|
||||
# for read privilege
|
||||
elif "select " in self.cases[case_name]["sql"][index]:
|
||||
res = testconn.query(self.cases[case_name]["sql"][index])
|
||||
data = res.fetch_all()
|
||||
tdLog.debug("query result: {}".format(data))
|
||||
# check query results by cases
|
||||
if case_name in ["test_db_no_permission_childtable_read", "test_db_write_childtable_read"] and self.cases[case_name]["sql"][index] == "select * from ct2;":
|
||||
if not self.cases[case_name]["res"][index]:
|
||||
if 0 == len(data):
|
||||
tdLog.debug("Query with sql {} successfully as expected with empty result".format(self.cases[case_name]["sql"][index]))
|
||||
continue
|
||||
else:
|
||||
tdLog.exit("Query with sql {} failed with result {}".format(self.cases[case_name]["sql"][index], data))
|
||||
# check the expected result
|
||||
if self.cases[case_name]["res"][index]:
|
||||
if len(data) > 0:
|
||||
tdLog.debug("Query with sql {} successfully".format(self.cases[case_name]["sql"][index]))
|
||||
else:
|
||||
tdLog.exit("Query with sql {} failed with result {}".format(self.cases[case_name]["sql"][index], data))
|
||||
else:
|
||||
tdLog.exit("Execute query sql {} successfully, but expected failed".format(self.cases[case_name]["sql"][index]))
|
||||
except BaseException as ex:
|
||||
# check the expect false result
|
||||
if not self.cases[case_name]["res"][index]:
|
||||
tdLog.debug("Execute sql {} failed with {} as expected".format(self.cases[case_name]["sql"][index], str(ex)))
|
||||
continue
|
||||
# unexpected exception
|
||||
else:
|
||||
tdLog.exit(ex)
|
||||
# remove the privilege
|
||||
if self.cases[case_name]["db_privilege"] != "none":
|
||||
self.remove_privilege(self.username, self.cases[case_name]["db_privilege"], "*")
|
||||
if self.cases[case_name]["stable_priviege"] != "none":
|
||||
self.remove_privilege(self.username, self.cases[case_name]["stable_priviege"], self.stbname)
|
||||
if self.cases[case_name]["child_table_ct1_privilege"] != "none":
|
||||
self.remove_privilege(self.username, self.cases[case_name]["child_table_ct1_privilege"], self.stbname, "ctbname='ct1'")
|
||||
if self.cases[case_name]["child_table_ct2_privilege"] != "none":
|
||||
self.remove_privilege(self.username, self.cases[case_name]["child_table_ct2_privilege"], self.stbname, "ctbname='ct2'")
|
||||
if self.cases[case_name]["table_tb_privilege"] != "none":
|
||||
self.remove_privilege(self.username, self.cases[case_name]["table_tb_privilege"], self.common_tbname)
|
||||
# close the connection of user test
|
||||
testconn.close()
|
||||
|
||||
def stop(self):
|
||||
# remove the user
|
||||
tdSql.execute(f'drop user {self.username}')
|
||||
# close the connection
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -44,7 +44,7 @@ class TDTestCase:
|
|||
|
||||
tdSql.execute(
|
||||
f'''create table if not exists {dbname}.{tbname}
|
||||
(ts timestamp, c0 tinyint, c1 smallint, c2 int, c3 bigint, c4 double, c5 float, c6 bool, c7 varchar(10), c8 nchar(10))
|
||||
(ts timestamp, c0 tinyint, c1 smallint, c2 int, c3 bigint, c4 double, c5 float, c6 bool, c7 varchar(10), c8 nchar(10), c9 tinyint unsigned, c10 smallint unsigned, c11 int unsigned, c12 bigint unsigned)
|
||||
'''
|
||||
)
|
||||
|
||||
|
@ -52,9 +52,9 @@ class TDTestCase:
|
|||
|
||||
tdSql.execute(f"use db")
|
||||
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar')")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:10', 10, 10, 10, 10, 10.0, 10.0, true, 'varchar', 'nchar')")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:15', 15, 15, 15, 15, 15.0, 15.0, true, 'varchar', 'nchar')")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar', 5, 5, 5, 5)")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:10', 10, 10, 10, 10, 10.0, 10.0, true, 'varchar', 'nchar', 10, 10, 10, 10)")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:15', 15, 15, 15, 15, 15.0, 15.0, true, 'varchar', 'nchar', 15, 15, 15, 15)")
|
||||
|
||||
tdLog.printNoPrefix("==========step3:fill null")
|
||||
|
||||
|
@ -129,21 +129,71 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step4:fill value")
|
||||
|
||||
## {. . .}
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)")
|
||||
col_list = {'c0', 'c1', 'c2', 'c3', 'c9', 'c10', 'c11', 'c12'}
|
||||
for col in col_list:
|
||||
tdSql.query(f"select interp({col}) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 5)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
tdSql.checkData(4, 0, 1)
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(6, 0, 10)
|
||||
tdSql.checkData(7, 0, 1)
|
||||
tdSql.checkData(8, 0, 1)
|
||||
tdSql.checkData(9, 0, 1)
|
||||
tdSql.checkData(10, 0, 1)
|
||||
tdSql.checkData(11, 0, 15)
|
||||
tdSql.checkData(12, 0, 1)
|
||||
|
||||
tdSql.query(f"select interp(c4) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.checkData(1, 0, 5)
|
||||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
tdSql.checkData(4, 0, 1)
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(6, 0, 10)
|
||||
tdSql.checkData(7, 0, 1)
|
||||
tdSql.checkData(8, 0, 1)
|
||||
tdSql.checkData(9, 0, 1)
|
||||
tdSql.checkData(10, 0, 1)
|
||||
tdSql.checkData(11, 0, 15)
|
||||
tdSql.checkData(12, 0, 1)
|
||||
tdSql.checkData(0, 0, 1.0)
|
||||
tdSql.checkData(1, 0, 5.0)
|
||||
tdSql.checkData(2, 0, 1.0)
|
||||
tdSql.checkData(3, 0, 1.0)
|
||||
tdSql.checkData(4, 0, 1.0)
|
||||
tdSql.checkData(5, 0, 1.0)
|
||||
tdSql.checkData(6, 0, 10.0)
|
||||
tdSql.checkData(7, 0, 1.0)
|
||||
tdSql.checkData(8, 0, 1.0)
|
||||
tdSql.checkData(9, 0, 1.0)
|
||||
tdSql.checkData(10, 0, 1.0)
|
||||
tdSql.checkData(11, 0, 15.0)
|
||||
tdSql.checkData(12, 0, 1.0)
|
||||
|
||||
tdSql.query(f"select interp(c5) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, 1.0)
|
||||
tdSql.checkData(1, 0, 5.0)
|
||||
tdSql.checkData(2, 0, 1.0)
|
||||
tdSql.checkData(3, 0, 1.0)
|
||||
tdSql.checkData(4, 0, 1.0)
|
||||
tdSql.checkData(5, 0, 1.0)
|
||||
tdSql.checkData(6, 0, 10.0)
|
||||
tdSql.checkData(7, 0, 1.0)
|
||||
tdSql.checkData(8, 0, 1.0)
|
||||
tdSql.checkData(9, 0, 1.0)
|
||||
tdSql.checkData(10, 0, 1.0)
|
||||
tdSql.checkData(11, 0, 15.0)
|
||||
tdSql.checkData(12, 0, 1.0)
|
||||
|
||||
tdSql.query(f"select interp(c6) from {dbname}.{tbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(value, 1)")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, True)
|
||||
tdSql.checkData(1, 0, True)
|
||||
tdSql.checkData(2, 0, True)
|
||||
tdSql.checkData(3, 0, True)
|
||||
tdSql.checkData(4, 0, True)
|
||||
tdSql.checkData(5, 0, True)
|
||||
tdSql.checkData(6, 0, True)
|
||||
tdSql.checkData(7, 0, True)
|
||||
tdSql.checkData(8, 0, True)
|
||||
tdSql.checkData(9, 0, True)
|
||||
tdSql.checkData(10, 0, True)
|
||||
tdSql.checkData(11, 0, True)
|
||||
tdSql.checkData(12, 0, True)
|
||||
|
||||
## {} ...
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:01', '2020-02-01 00:00:04') every(1s) fill(value, 1)")
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def caseDescription(self):
|
||||
"""
|
||||
[TD-13823] taosBenchmark test cases
|
||||
"""
|
||||
return
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
# comment off by Shuduo for CI self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def getPath(self, tool="taosBenchmark"):
|
||||
if (platform.system().lower() == 'windows'):
|
||||
tool = tool + ".exe"
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
if "community" in selfPath:
|
||||
projPath = selfPath[: selfPath.find("community")]
|
||||
else:
|
||||
projPath = selfPath[: selfPath.find("tests")]
|
||||
|
||||
paths = []
|
||||
for root, dirs, files in os.walk(projPath):
|
||||
if (tool) in files:
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if "packaging" not in rootRealPath:
|
||||
paths.append(os.path.join(root, tool))
|
||||
break
|
||||
if len(paths) == 0:
|
||||
tdLog.exit("taosBenchmark not found!")
|
||||
return
|
||||
else:
|
||||
tdLog.info("taosBenchmark found in %s" % paths[0])
|
||||
return paths[0]
|
||||
|
||||
def checkDataCorrect(self):
|
||||
sql = "select count(*) from meters"
|
||||
tdSql.query(sql)
|
||||
allCnt = tdSql.getData(0, 0)
|
||||
if allCnt < 2000000:
|
||||
tdLog.exit(f"taosbenchmark insert row small. row count={allCnt} sql={sql}")
|
||||
return
|
||||
|
||||
# group by 10 child table
|
||||
rowCnt = tdSql.query("select count(*),tbname from meters group by tbname")
|
||||
tdSql.checkRows(10)
|
||||
|
||||
# interval
|
||||
sql = "select count(*),max(ic),min(dc),last(*) from meters interval(1s)"
|
||||
rowCnt = tdSql.query(sql)
|
||||
if rowCnt < 10:
|
||||
tdLog.exit(f"taosbenchmark interval(1s) count small. row cout={rowCnt} sql={sql}")
|
||||
return
|
||||
|
||||
# nest query
|
||||
tdSql.query("select count(*) from (select * from meters order by ts desc)")
|
||||
tdSql.checkData(0, 0, allCnt)
|
||||
|
||||
|
||||
def run(self):
|
||||
binPath = self.getPath()
|
||||
cmd = "%s -f ./5-taos-tools/taosbenchmark/json/insertMix.json" % binPath
|
||||
tdLog.info("%s" % cmd)
|
||||
errcode = os.system("%s" % cmd)
|
||||
if errcode != 0:
|
||||
tdLog.exit(f"execute taosBenchmark ret error code={errcode}")
|
||||
return
|
||||
|
||||
tdSql.execute("use mixdb")
|
||||
self.checkDataCorrect()
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"filetype": "insert",
|
||||
"cfgdir": "/etc/taos",
|
||||
"host": "127.0.0.1",
|
||||
"port": 6030,
|
||||
"user": "root",
|
||||
"password": "taosdata",
|
||||
"connection_pool_size": 8,
|
||||
"num_of_records_per_req": 3000,
|
||||
"thread_count": 10,
|
||||
"create_table_thread_count": 2,
|
||||
"result_file": "./insert_res_mix.txt",
|
||||
"confirm_parameter_prompt": "no",
|
||||
"insert_interval": 0,
|
||||
"check_sql": "yes",
|
||||
"continue_if_fail": "no",
|
||||
"databases": [
|
||||
{
|
||||
"dbinfo": {
|
||||
"name": "mixdb",
|
||||
"drop": "yes",
|
||||
"vgroups": 6,
|
||||
"replica": 3,
|
||||
"precision": "ms",
|
||||
"keep": 3650,
|
||||
"minRows": 100,
|
||||
"maxRows": 4096
|
||||
},
|
||||
"super_tables": [
|
||||
{
|
||||
"name": "meters",
|
||||
"child_table_exists": "no",
|
||||
"childtable_count": 10,
|
||||
"insert_rows": 300000,
|
||||
"childtable_prefix": "d",
|
||||
"insert_mode": "taosc",
|
||||
"insert_interval": 0,
|
||||
"timestamp_step": 100,
|
||||
"start_timestamp":1500000000000,
|
||||
"disorder_ratio": 10,
|
||||
"update_ratio": 5,
|
||||
"delete_ratio": 1,
|
||||
"disorder_fill_interval": 300,
|
||||
"update_fill_interval": 25,
|
||||
"generate_row_rule": 2,
|
||||
"columns": [
|
||||
{ "type": "bool", "name": "bc"},
|
||||
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
|
||||
{ "type": "double", "name": "dc", "max": 1, "min": 0 },
|
||||
{ "type": "tinyint", "name": "ti", "max": 100, "min": 0 },
|
||||
{ "type": "smallint", "name": "si", "max": 100, "min": 0 },
|
||||
{ "type": "int", "name": "ic", "max": 100, "min": 0 },
|
||||
{ "type": "bigint", "name": "bi", "max": 100, "min": 0 },
|
||||
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
|
||||
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
|
||||
{ "type": "uint", "name": "ui", "max": 100, "min": 0 },
|
||||
{ "type": "ubigint", "name": "ubi", "max": 100, "min": 0 },
|
||||
{ "type": "binary", "name": "bin", "len": 32},
|
||||
{ "type": "nchar", "name": "nch", "len": 64}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"type": "tinyint",
|
||||
"name": "groupid",
|
||||
"max": 10,
|
||||
"min": 1
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"type": "binary",
|
||||
"len": 16,
|
||||
"values": ["San Francisco", "Los Angles", "San Diego",
|
||||
"San Jose", "Palo Alto", "Campbell", "Mountain View",
|
||||
"Sunnyvale", "Santa Clara", "Cupertino"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"filetype": "insert",
|
||||
"cfgdir": "/etc/taos",
|
||||
"host": "127.0.0.1",
|
||||
"port": 6030,
|
||||
"user": "root",
|
||||
"password": "taosdata",
|
||||
"connection_pool_size": 8,
|
||||
"num_of_records_per_req": 3000,
|
||||
"thread_count": 20,
|
||||
"create_table_thread_count": 5,
|
||||
"result_file": "./insert_res_wal.txt",
|
||||
"confirm_parameter_prompt": "no",
|
||||
"insert_interval": 0,
|
||||
"databases": [
|
||||
{
|
||||
"dbinfo": {
|
||||
"name": "db",
|
||||
"drop": "yes",
|
||||
"flush_each_batch": "yes",
|
||||
"vgroups": 2,
|
||||
"replica": 1,
|
||||
"precision": "ms",
|
||||
"keep": 3650,
|
||||
"minRows": 100,
|
||||
"maxRows": 4096
|
||||
},
|
||||
"super_tables": [
|
||||
{
|
||||
"name": "meters",
|
||||
"child_table_exists": "no",
|
||||
"childtable_count": 1000,
|
||||
"insert_rows": 2850,
|
||||
"childtable_prefix": "d",
|
||||
"insert_mode": "taosc",
|
||||
"insert_interval": 0,
|
||||
"timestamp_step": 10,
|
||||
"disorder_ratio": 10,
|
||||
"update_ratio": 5,
|
||||
"delete_ratio": 1,
|
||||
"disorder_fill_interval": 30,
|
||||
"update_fill_interval": 25,
|
||||
"generate_row_rule": 2,
|
||||
"start_timestamp":"2022-01-01 10:00:00",
|
||||
"columns": [
|
||||
{ "type": "bool", "name": "bc"},
|
||||
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
|
||||
{ "type": "double", "name": "dc", "max": 1, "min": 0 },
|
||||
{ "type": "tinyint", "name": "ti", "max": 100, "min": 0 },
|
||||
{ "type": "smallint", "name": "si", "max": 100, "min": 0 },
|
||||
{ "type": "int", "name": "ic", "max": 100, "min": 0 },
|
||||
{ "type": "bigint", "name": "bi", "max": 100, "min": 0 },
|
||||
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
|
||||
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
|
||||
{ "type": "uint", "name": "ui", "max": 100, "min": 0 },
|
||||
{ "type": "ubigint", "name": "ubi", "max": 100, "min": 0 },
|
||||
{ "type": "binary", "name": "bin", "len": 32},
|
||||
{ "type": "nchar", "name": "nch", "len": 64}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"type": "tinyint",
|
||||
"name": "groupid",
|
||||
"max": 10,
|
||||
"min": 1
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"type": "binary",
|
||||
"len": 16,
|
||||
"values": ["San Francisco", "Los Angles", "San Diego",
|
||||
"San Jose", "Palo Alto", "Campbell", "Mountain View",
|
||||
"Sunnyvale", "Santa Clara", "Cupertino"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def caseDescription(self):
|
||||
"""
|
||||
[TD-13823] taosBenchmark test cases
|
||||
"""
|
||||
return
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
# comment off by Shuduo for CI self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def getPath(self, tool="taosBenchmark"):
|
||||
if (platform.system().lower() == 'windows'):
|
||||
tool = tool + ".exe"
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
if "community" in selfPath:
|
||||
projPath = selfPath[: selfPath.find("community")]
|
||||
else:
|
||||
projPath = selfPath[: selfPath.find("tests")]
|
||||
|
||||
paths = []
|
||||
for root, dirs, files in os.walk(projPath):
|
||||
if (tool) in files:
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if "packaging" not in rootRealPath:
|
||||
paths.append(os.path.join(root, tool))
|
||||
break
|
||||
if len(paths) == 0:
|
||||
tdLog.exit("taosBenchmark not found!")
|
||||
return
|
||||
else:
|
||||
tdLog.info("taosBenchmark found in %s" % paths[0])
|
||||
return paths[0]
|
||||
|
||||
def checkDataCorrect(self):
|
||||
sql = "select count(*) from meters"
|
||||
tdSql.query(sql)
|
||||
allCnt = tdSql.getData(0, 0)
|
||||
if allCnt < 2000000:
|
||||
tdLog.exit(f"taosbenchmark insert row small. row count={allCnt} sql={sql}")
|
||||
return
|
||||
|
||||
# group by 10 child table
|
||||
rowCnt = tdSql.query("select count(*),tbname from meters group by tbname")
|
||||
tdSql.checkRows(1000)
|
||||
|
||||
# interval
|
||||
sql = "select count(*),max(ic),min(dc),last(*) from meters interval(1s)"
|
||||
rowCnt = tdSql.query(sql)
|
||||
if rowCnt < 10:
|
||||
tdLog.exit(f"taosbenchmark interval(1s) count small. row cout={rowCnt} sql={sql}")
|
||||
return
|
||||
|
||||
# nest query
|
||||
tdSql.query("select count(*) from (select * from meters order by ts desc)")
|
||||
tdSql.checkData(0, 0, allCnt)
|
||||
|
||||
|
||||
def run(self):
|
||||
binPath = self.getPath()
|
||||
cmd = "%s -f ./5-taos-tools/taosbenchmark/json/stt.json" % binPath
|
||||
tdLog.info("%s" % cmd)
|
||||
errcode = os.system("%s" % cmd)
|
||||
if errcode != 0:
|
||||
tdLog.exit(f"execute taosBenchmark ret error code={errcode}")
|
||||
return
|
||||
|
||||
tdSql.execute("use db")
|
||||
self.checkDataCorrect()
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -546,7 +546,7 @@ class TDTestCase:
|
|||
keyList = 'group.id:cgrp1,\
|
||||
enable.auto.commit:false,\
|
||||
auto.commit.interval.ms:6000,\
|
||||
auto.offset.reset:none'
|
||||
auto.offset.reset:earliest'
|
||||
self.insertConsumerInfo(consumerId, expectrowcnt/2,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||
|
||||
tdLog.info("again start consume processor")
|
||||
|
@ -569,7 +569,7 @@ class TDTestCase:
|
|||
keyList = 'group.id:cgrp1,\
|
||||
enable.auto.commit:false,\
|
||||
auto.commit.interval.ms:6000,\
|
||||
auto.offset.reset:none'
|
||||
auto.offset.reset:earliest'
|
||||
self.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||
|
||||
tdLog.info("again start consume processor")
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
|
@ -22,12 +21,12 @@ class TDTestCase:
|
|||
self.commit_value_list = ["true", "false"]
|
||||
self.offset_value_list = ["", "earliest", "latest", "none"]
|
||||
self.tbname_value_list = ["true", "false"]
|
||||
self.snapshot_value_list = ["true", "false"]
|
||||
self.snapshot_value_list = ["false"]
|
||||
|
||||
# self.commit_value_list = ["true"]
|
||||
# self.offset_value_list = ["none"]
|
||||
# self.offset_value_list = [""]
|
||||
# self.tbname_value_list = ["true"]
|
||||
# self.snapshot_value_list = ["true"]
|
||||
# self.snapshot_value_list = ["false"]
|
||||
|
||||
def tmqParamsTest(self):
|
||||
paraDict = {'dbName': 'db1',
|
||||
|
@ -128,11 +127,12 @@ class TDTestCase:
|
|||
start_group_id += 1
|
||||
tdSql.query('show subscriptions;')
|
||||
subscription_info = tdSql.queryResult
|
||||
tdLog.info(f"---------- subscription_info: {subscription_info}")
|
||||
if snapshot_value == "true":
|
||||
if offset_value != "earliest" and offset_value != "":
|
||||
if offset_value == "latest":
|
||||
offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace("earliest", "0")), subscription_info))
|
||||
tdSql.checkEqual(sum(offset_value_list) > 0, True)
|
||||
offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace(offset_value, "0")), subscription_info))
|
||||
tdSql.checkEqual(sum(offset_value_list) >= 0, True)
|
||||
rows_value_list = list(map(lambda x: int(x[-1]), subscription_info))
|
||||
tdSql.checkEqual(sum(rows_value_list), expected_res)
|
||||
elif offset_value == "none":
|
||||
|
@ -143,9 +143,10 @@ class TDTestCase:
|
|||
else:
|
||||
if offset_value != "none":
|
||||
offset_value_str = ",".join(list(map(lambda x: x[-2], subscription_info)))
|
||||
tdSql.checkEqual("tsdb" in offset_value_str, True)
|
||||
rows_value_list = list(map(lambda x: int(x[-1]), subscription_info))
|
||||
tdSql.checkEqual(sum(rows_value_list), expected_res)
|
||||
tdLog.info("checking tsdb in offset_value_str")
|
||||
# tdSql.checkEqual("tsdb" in offset_value_str, True)
|
||||
# rows_value_list = list(map(lambda x: int(x[-1]), subscription_info))
|
||||
# tdSql.checkEqual(sum(rows_value_list), expected_res)
|
||||
else:
|
||||
offset_value_list = list(map(lambda x: x[-2], subscription_info))
|
||||
tdSql.checkEqual(offset_value_list, [None]*len(subscription_info))
|
||||
|
@ -153,8 +154,8 @@ class TDTestCase:
|
|||
tdSql.checkEqual(rows_value_list, [None]*len(subscription_info))
|
||||
else:
|
||||
if offset_value != "none":
|
||||
offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace("earliest", "0")), subscription_info))
|
||||
tdSql.checkEqual(sum(offset_value_list) > 0, True)
|
||||
offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace(offset_value, "0")), subscription_info))
|
||||
tdSql.checkEqual(sum(offset_value_list) >= 0, True)
|
||||
rows_value_list = list(map(lambda x: int(x[-1]), subscription_info))
|
||||
tdSql.checkEqual(sum(rows_value_list), expected_res)
|
||||
else:
|
||||
|
@ -175,4 +176,4 @@ class TDTestCase:
|
|||
event = threading.Event()
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
Loading…
Reference in New Issue