Merge remote-tracking branch 'origin/3.0' into feat/TD-24700
This commit is contained in:
commit
6ce28e8886
|
@ -175,7 +175,7 @@ cd TDengine
|
|||
```bash
|
||||
mkdir debug
|
||||
cd debug
|
||||
cmake .. -DBUILD_TOOLS=true
|
||||
cmake .. -DBUILD_TOOLS=true -DBUILD_CONTRIB=true
|
||||
make
|
||||
```
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ It equals to execute following commands:
|
|||
```bash
|
||||
mkdir debug
|
||||
cd debug
|
||||
cmake .. -DBUILD_TOOLS=true
|
||||
cmake .. -DBUILD_TOOLS=true -DBUILD_CONTRIB=true
|
||||
make
|
||||
```
|
||||
|
||||
|
|
2
build.sh
2
build.sh
|
@ -4,5 +4,5 @@ if [ ! -d debug ]; then
|
|||
mkdir debug || echo -e "failed to make directory for build"
|
||||
fi
|
||||
|
||||
cd debug && cmake .. -DBUILD_TOOLS=true && make
|
||||
cd debug && cmake .. -DBUILD_TOOLS=true -DBUILD_CONTRIB=true && make
|
||||
|
||||
|
|
|
@ -32,6 +32,20 @@ docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043
|
|||
|
||||
Note that TDengine Server 3.0 uses TCP port 6030. Port 6041 is used by taosAdapter for the REST API service. Ports 6043 through 6049 are used by taosAdapter for other connectors. You can open these ports as needed.
|
||||
|
||||
If you need to persist data to a specific directory on your local machine, please run the following command:
|
||||
```shell
|
||||
docker run -d -v ~/data/taos/dnode/data:/var/lib/taos \
|
||||
-v ~/data/taos/dnode/log:/var/log/taos \
|
||||
-p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
|
||||
```
|
||||
:::note
|
||||
|
||||
- /var/lib/taos: TDengine's default data file directory. The location can be changed via [configuration file]. Also you can modify ~/data/taos/dnode/data to your any local empty data directory
|
||||
- /var/log/taos: TDengine's default log file directory. The location can be changed via [configure file]. you can modify ~/data/taos/dnode/log to your any local empty log directory
|
||||
|
||||
:::
|
||||
|
||||
|
||||
Run the following command to ensure that your container is running:
|
||||
|
||||
```shell
|
||||
|
@ -113,4 +127,4 @@ In the query above you are selecting the first timestamp (ts) in the interval, a
|
|||
|
||||
## Additional Information
|
||||
|
||||
For more information about deploying TDengine in a Docker environment, see [Using TDengine in Docker](../../reference/docker).
|
||||
For more information about deploying TDengine in a Docker environment, see [Deploying TDengine with Docker](../../deployment/docker).
|
||||
|
|
|
@ -62,12 +62,13 @@ serverPort 6030
|
|||
|
||||
For all the dnodes in a TDengine cluster, the below parameters must be configured exactly the same, any node whose configuration is different from dnodes already in the cluster can't join the cluster.
|
||||
|
||||
| **#** | **Parameter** | **Definition** |
|
||||
| ----- | ------------------ | ------------------------------------------- |
|
||||
| 1 | statusInterval | The interval by which dnode reports its status to mnode |
|
||||
| 2 | timezone | Timezone |
|
||||
| 3 | locale | System region and encoding |
|
||||
| 4 | charset | Character set |
|
||||
| **#** | **Parameter** | **Definition** |
|
||||
| ----- | ---------------- | ----------------------------------------------------------------------------- |
|
||||
| 1 | statusInterval | The interval by which dnode reports its status to mnode |
|
||||
| 2 | timezone | Timezone |
|
||||
| 3 | locale | System region and encoding |
|
||||
| 4 | charset | Character set |
|
||||
| 5 | ttlChangeOnWrite | Whether the ttl expiration time changes with the table modification operation |
|
||||
|
||||
## Start Cluster
|
||||
|
||||
|
@ -97,7 +98,7 @@ Then, on the first dnode i.e. h1.tdengine.com in our example, use TDengine CLI `
|
|||
CREATE DNODE "h2.taos.com:6030";
|
||||
````
|
||||
|
||||
This adds the end point of the new dnode (from Step 4) into the end point list of the cluster. In the command "fqdn:port" should be quoted using double quotes. Change `"h2.taos.com:6030"` to the end point of your new dnode.
|
||||
This adds the end point of the new dnode (from Step 4) into the end point list of the cluster. In the command "fqdn:port" should be quoted using double quotes. Change `"h2.taos.com:6030"` to the end point of your new dnode.
|
||||
|
||||
Then on the first dnode h1.tdengine.com, execute `show dnodes` in `taos`
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: Deploying TDengine with Docker
|
||||
sidebar_label: Docker
|
||||
description: This chapter describes how to start and access TDengine in a Docker container.
|
||||
---
|
||||
|
||||
|
@ -10,8 +11,17 @@ This chapter describes how to start the TDengine service in a container and acce
|
|||
The TDengine image starts with the HTTP service activated by default, using the following command:
|
||||
|
||||
```shell
|
||||
docker run -d --name tdengine -p 6041:6041 tdengine/tdengine
|
||||
docker run -d --name tdengine \
|
||||
-v ~/data/taos/dnode/data:/var/lib/taos \
|
||||
-v ~/data/taos/dnode/log:/var/log/taos \
|
||||
-p 6041:6041 tdengine/tdengine
|
||||
```
|
||||
:::note
|
||||
|
||||
* /var/lib/taos: TDengine's default data file directory. The location can be changed via [configuration file]. And also you can modify ~/data/taos/dnode/data to your any other local emtpy data directory
|
||||
* /var/log/taos: TDengine's default log file directory. The location can be changed via [configure file]. And also you can modify ~/data/taos/dnode/log to your any other local empty log directory
|
||||
|
||||
:::
|
||||
|
||||
The above command starts a container named "tdengine" and maps the HTTP service port 6041 to the host port 6041. You can verify that the HTTP service provided in this container is available using the following command.
|
||||
|
||||
|
@ -283,39 +293,38 @@ services:
|
|||
environment:
|
||||
TAOS_FQDN: "td-1"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
ports:
|
||||
- 6041:6041
|
||||
- 6030:6030
|
||||
volumes:
|
||||
- taosdata-td1:/var/lib/taos/
|
||||
- taoslog-td1:/var/log/taos/
|
||||
# /var/lib/taos: TDengine's default data file directory. The location can be changed via [configuration file]. you can modify ~/data/taos/dnode1/data to your own data directory
|
||||
- ~/data/taos/dnode1/data:/var/lib/taos
|
||||
# /var/log/taos: TDengine's default log file directory. The location can be changed via [configure file]. you can modify ~/data/taos/dnode1/log to your own log directory
|
||||
- ~/data/taos/dnode1/log:/var/log/taos
|
||||
td-2:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
environment:
|
||||
TAOS_FQDN: "td-2"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td2:/var/lib/taos/
|
||||
- taoslog-td2:/var/log/taos/
|
||||
- ~/data/taos/dnode2/data:/var/lib/taos
|
||||
- ~/data/taos/dnode2/log:/var/log/taos
|
||||
td-3:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
environment:
|
||||
TAOS_FQDN: "td-3"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td3:/var/lib/taos/
|
||||
- taoslog-td3:/var/log/taos/
|
||||
volumes:
|
||||
taosdata-td1:
|
||||
taoslog-td1:
|
||||
taosdata-td2:
|
||||
taoslog-td2:
|
||||
taosdata-td3:
|
||||
taoslog-td3:
|
||||
- ~/data/taos/dnode3/data:/var/lib/taos
|
||||
- ~/data/taos/dnode3/log:/var/log/taos
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
- The `VERSION` environment variable is used to set the tdengine image tag
|
||||
- `TAOS_FIRST_EP` must be set on the newly created instance so that it can join the TDengine cluster; if there is a high availability requirement, `TAOS_SECOND_EP` needs to be used at the same time
|
||||
:::
|
||||
|
||||
:::
|
||||
|
||||
2. Start the cluster
|
||||
|
||||
|
@ -382,24 +391,22 @@ networks:
|
|||
services:
|
||||
td-1:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
networks:
|
||||
- inter
|
||||
environment:
|
||||
TAOS_FQDN: "td-1"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td1:/var/lib/taos/
|
||||
- taoslog-td1:/var/log/taos/
|
||||
# /var/lib/taos: TDengine's default data file directory. The location can be changed via [configuration file]. you can modify ~/data/taos/dnode1/data to your own data directory
|
||||
- ~/data/taos/dnode1/data:/var/lib/taos
|
||||
# /var/log/taos: TDengine's default log file directory. The location can be changed via [configure file]. you can modify ~/data/taos/dnode1/log to your own log directory
|
||||
- ~/data/taos/dnode1/log:/var/log/taos
|
||||
td-2:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
networks:
|
||||
- inter
|
||||
environment:
|
||||
TAOS_FQDN: "td-2"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td2:/var/lib/taos/
|
||||
- taoslog-td2:/var/log/taos/
|
||||
- ~/data/taos/dnode2/data:/var/lib/taos
|
||||
- ~/data/taos/dnode2/log:/var/log/taos
|
||||
adapter:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
entrypoint: "taosadapter"
|
||||
|
@ -431,11 +438,6 @@ services:
|
|||
>> /etc/nginx/nginx.conf;cat /etc/nginx/nginx.conf;
|
||||
nginx -g 'daemon off;'",
|
||||
]
|
||||
volumes:
|
||||
taosdata-td1:
|
||||
taoslog-td1:
|
||||
taosdata-td2:
|
||||
taoslog-td2:
|
||||
```
|
||||
|
||||
## Deploy with docker swarm
|
|
@ -5,7 +5,7 @@ description: This document describes how to deploy a TDengine cluster on a serve
|
|||
|
||||
TDengine has a native distributed design and provides the ability to scale out. A few nodes can form a TDengine cluster. If you need higher processing power, you just need to add more nodes into the cluster. TDengine uses virtual node technology to virtualize a node into multiple virtual nodes to achieve load balancing. At the same time, TDengine can group virtual nodes on different nodes into virtual node groups, and use the replication mechanism to ensure the high availability of the system. The cluster feature of TDengine is completely open source.
|
||||
|
||||
This document describes how to manually deploy a cluster on a host as well as how to deploy on Kubernetes and by using Helm.
|
||||
This document describes how to manually deploy a cluster on a host directly and deploy a cluster with Docker, Kubernetes or Helm.
|
||||
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
|
|
|
@ -42,7 +42,7 @@ In TDengine, the data types below can be used when specifying a column or tag.
|
|||
| 14 | NCHAR | User Defined | Multi-byte string that can include multi byte characters like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\'`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. |
|
||||
| 15 | JSON | | JSON type can only be used on tags. A tag of json type is excluded with any other tags of any other type. |
|
||||
| 16 | VARCHAR | User-defined | Alias of BINARY |
|
||||
| 16 | GEOMETRY | User-defined | Geometry |
|
||||
| 17 | GEOMETRY | User-defined | Geometry |
|
||||
:::note
|
||||
|
||||
- Each row of the table cannot be longer than 48KB (64KB since version 3.0.5.0) (note that each BINARY/NCHAR/GEOMETRY column takes up an additional 2 bytes of storage space).
|
||||
|
|
|
@ -698,7 +698,7 @@ ELAPSED(ts_primary_key [, time_unit])
|
|||
LEASTSQUARES(expr, start_val, step_val)
|
||||
```
|
||||
|
||||
**Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value.
|
||||
**Description**: The linear regression function of a specified column, `start_val` is the initial value and `step_val` is the step value.
|
||||
|
||||
**Return value type**: A string in the format of "(slope, intercept)"
|
||||
|
||||
|
@ -1274,3 +1274,161 @@ SELECT SERVER_STATUS();
|
|||
```
|
||||
|
||||
**Description**: The server status.
|
||||
|
||||
|
||||
## Geometry Functions
|
||||
|
||||
### Geometry Input Functions
|
||||
|
||||
Geometry input functions create geometry data from WTK.
|
||||
|
||||
#### ST_GeomFromText
|
||||
|
||||
```sql
|
||||
ST_GeomFromText(VARCHAR WKT expr)
|
||||
```
|
||||
|
||||
**Description**: Return a specified GEOMETRY value from Well-Known Text representation (WKT).
|
||||
|
||||
**Return value type**: GEOMETRY
|
||||
|
||||
**Applicable data types**: VARCHAR
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- The input can be one of WTK string, like POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION.
|
||||
- The output is a GEOMETRY data type, internal defined as binary string.
|
||||
|
||||
### Geometry Output Functions
|
||||
|
||||
Geometry output functions convert geometry data into WTK.
|
||||
|
||||
#### ST_AsText
|
||||
|
||||
```sql
|
||||
ST_AsText(GEOMETRY geom)
|
||||
```
|
||||
|
||||
**Description**: Return a specified Well-Known Text representation (WKT) value from GEOMETRY data.
|
||||
|
||||
**Return value type**: VARCHAR
|
||||
|
||||
**Applicable data types**: GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- The output can be one of WTK string, like POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION.
|
||||
|
||||
### Geometry Relationships Functions
|
||||
|
||||
Geometry relationships functions determine spatial relationships between geometries.
|
||||
|
||||
#### ST_Intersects
|
||||
|
||||
```sql
|
||||
ST_Intersects(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Compares two geometries and returns true if they intersect.
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- Geometries intersect if they have any point in common.
|
||||
|
||||
|
||||
#### ST_Equals
|
||||
|
||||
```sql
|
||||
ST_Equals(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Returns TRUE if the given geometries are "spatially equal".
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- 'Spatially equal' means ST_Contains(A,B) = true and ST_Contains(B,A) = true, and the ordering of points can be different but represent the same geometry structure.
|
||||
|
||||
|
||||
#### ST_Touches
|
||||
|
||||
```sql
|
||||
ST_Touches(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Returns TRUE if A and B intersect, but their interiors do not intersect.
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- A and B have at least one point in common, and the common points lie in at least one boundary.
|
||||
- For Point/Point inputs the relationship is always FALSE, since points do not have a boundary.
|
||||
|
||||
|
||||
#### ST_Covers
|
||||
|
||||
```sql
|
||||
ST_Covers(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Returns TRUE if every point in Geometry B lies inside (intersects the interior or boundary of) Geometry A.
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- A covers B means no point of B lies outside (in the exterior of) A.
|
||||
|
||||
|
||||
#### ST_Contains
|
||||
|
||||
```sql
|
||||
ST_Contains(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Returns TRUE if geometry A contains geometry B.
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- A contains B if and only if all points of B lie inside (i.e. in the interior or boundary of) A (or equivalently, no points of B lie in the exterior of A), and the interiors of A and B have at least one point in common.
|
||||
|
||||
|
||||
#### ST_ContainsProperly
|
||||
|
||||
```sql
|
||||
ST_ContainsProperly(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**Description**: Returns TRUE if every point of B lies inside A.
|
||||
|
||||
**Return value type**: BOOL
|
||||
|
||||
**Applicable data types**: GEOMETRY, GEOMETRY
|
||||
|
||||
**Applicable table types**: standard tables and supertables
|
||||
|
||||
**Explanations**:
|
||||
- There is no point of B that lies on the boundary of A or in the exterior of A.
|
||||
|
|
|
@ -54,7 +54,7 @@ LIKE is used together with wildcards to match strings. Its usage is described as
|
|||
MATCH and NMATCH are used together with regular expressions to match strings. Their usage is described as follows:
|
||||
|
||||
- Use POSIX regular expression syntax. For more information, see Regular Expressions.
|
||||
- Regular expression can be used against only table names, i.e. `tbname`, and tags of binary/nchar types, but can't be used against data columns.
|
||||
- Regular expression can be used against only table names, i.e. `tbname`, and tags/columns of binary/nchar types.
|
||||
- The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on the client side, and will take effect after restarting the client.
|
||||
|
||||
## Logical Operators
|
||||
|
|
|
@ -178,6 +178,7 @@ The following list shows all reserved keywords:
|
|||
|
||||
- MATCH
|
||||
- MAX_DELAY
|
||||
- MAX_SPEED
|
||||
- MAXROWS
|
||||
- MERGE
|
||||
- META
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_label: R
|
||||
title: R Language Connector
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Rdemo from "../../07-develop/01-connect/_connect_r.mdx"
|
||||
|
||||
By using the RJDBC library in R, you can enable R programs to access TDengine data. Here are the installation process, configuration steps, and an example code in R.
|
||||
|
||||
## Installation Process
|
||||
|
||||
Before getting started, make sure you have installed the R language environment. Then, follow these steps to install and configure the RJDBC library:
|
||||
|
||||
1. Install Java Development Kit (JDK): RJDBC library requires Java environment. Download the appropriate JDK for your operating system from the official Oracle website and follow the installation guide.
|
||||
|
||||
2. Install the RJDBC library: Execute the following command in the R console to install the RJDBC library.
|
||||
|
||||
```r
|
||||
install.packages("RJDBC", repos='http://cran.us.r-project.org')
|
||||
```
|
||||
|
||||
:::note
|
||||
1. The default R language package version 4.2 which shipped with Ubuntu might lead unresponsive bug. Please install latest version of R language package from the [official website](https://www.r-project.org/).
|
||||
2. On Linux systems, installing the RJDBC package may require installing the necessary components for compilation. For example, on Ubuntu, you can execute the command ``apt install -y libbz2-dev libpcre2-dev libicu-dev`` to install the required components.
|
||||
3. On Windows systems, you need to set the **JAVA_HOME** environment variable.
|
||||
:::
|
||||
|
||||
3. Download the TDengine JDBC driver: Visit the Maven website and download the TDengine JDBC driver (taos-jdbcdriver-X.X.X-dist.jar) to your local machine.
|
||||
|
||||
## Configuration Process
|
||||
|
||||
Once you have completed the installation steps, you need to do some configuration to enable the RJDBC library to connect and access the TDengine time-series database.
|
||||
|
||||
1. Load the RJDBC library and other necessary libraries in your R script:
|
||||
|
||||
```r
|
||||
library(DBI)
|
||||
library(rJava)
|
||||
library(RJDBC)
|
||||
```
|
||||
|
||||
2. Set the JDBC driver and JDBC URL:
|
||||
|
||||
```r
|
||||
# Set the JDBC driver path (specify the location on your local machine)
|
||||
driverPath <- "/path/to/taos-jdbcdriver-X.X.X-dist.jar"
|
||||
|
||||
# Set the JDBC URL (specify the FQDN and credentials of your TDengine cluster)
|
||||
url <- "jdbc:TAOS://localhost:6030/?user=root&password=taosdata"
|
||||
```
|
||||
|
||||
3. Load the JDBC driver:
|
||||
|
||||
```r
|
||||
# Load the JDBC driver
|
||||
drv <- JDBC("com.taosdata.jdbc.TSDBDriver", driverPath)
|
||||
```
|
||||
|
||||
4. Create a TDengine database connection:
|
||||
|
||||
```r
|
||||
# Create a database connection
|
||||
conn <- dbConnect(drv, url)
|
||||
```
|
||||
|
||||
5. Once the connection is established, you can use the ``conn`` object for various database operations such as querying data and inserting data.
|
||||
|
||||
6. Finally, don't forget to close the database connection after you are done:
|
||||
|
||||
```r
|
||||
# Close the database connection
|
||||
dbDisconnect(conn)
|
||||
```
|
||||
|
||||
## Example Code Using RJDBC in R
|
||||
|
||||
Here's an example code that uses the RJDBC library to connect to a TDengine time-series database and perform a query operation:
|
||||
|
||||
<Rdemo/>
|
||||
|
||||
Please modify the JDBC driver, JDBC URL, username, password, and SQL query statement according to your specific TDengine time-series database environment and requirements.
|
||||
|
||||
By following the steps and using the provided example code, you can use the RJDBC library in the R language to access the TDengine time-series database and perform tasks such as data querying and analysis.
|
|
@ -7,10 +7,10 @@ description: This document describes the supported platforms for the TDengine se
|
|||
|
||||
| | **Windows Server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18 or later** | **macOS** |
|
||||
| ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | --------- |
|
||||
| X64 | ● | ● | ● | ● | ● |
|
||||
| X64 | ●/E | ●/E | ● | ● | ● |
|
||||
| ARM64 | | | ● | | ● |
|
||||
|
||||
Note: ● means officially tested and verified, ○ means unofficially tested and verified.
|
||||
Note: 1) ● means officially tested and verified, ○ means unofficially tested and verified, E means only supported by the enterprise edition. 2) The community edition only supports newer versions of mainstream operating systems, including Ubuntu 18+/CentOS 7+/RetHat/Debian/CoreOS/FreeBSD/OpenSUSE/SUSE Linux/Fedora/macOS, etc. If you have requirements for other operating systems and editions, please contact support of the enterprise edition.
|
||||
|
||||
## List of supported platforms for TDengine clients and connectors
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
label: TDengine Docker images
|
|
@ -12,6 +12,11 @@ import Release from "/components/ReleaseV3";
|
|||
|
||||
## 3.1.0.0
|
||||
|
||||
:::note IMPORTANT
|
||||
- Once you upgrade to TDengine 3.1.0.0, you cannot roll back to any previous version of TDengine. Upgrading to 3.1.0.0 will alter your data such that it cannot be read by previous versions.
|
||||
- You must remove all streams before upgrading to TDengine 3.1.0.0. If you upgrade a deployment that contains streams, the upgrade will fail and your deployment will become nonoperational.
|
||||
:::
|
||||
|
||||
<Release type="tdengine" version="3.1.0.0" />
|
||||
|
||||
## 3.0.7.1
|
||||
|
|
|
@ -8,9 +8,13 @@ library("rJava")
|
|||
library("RJDBC")
|
||||
|
||||
args<- commandArgs(trailingOnly = TRUE)
|
||||
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-3.0.0-dist.jar"
|
||||
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-3.2.4-dist.jar"
|
||||
driver = JDBC("com.taosdata.jdbc.TSDBDriver", driver_path)
|
||||
conn = dbConnect(driver, "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata")
|
||||
dbGetQuery(conn, "SELECT server_version()")
|
||||
dbSendUpdate(conn, "create database if not exists rtest")
|
||||
dbSendUpdate(conn, "create table if not exists rtest.test (ts timestamp, current float, voltage int, devname varchar(20))")
|
||||
dbSendUpdate(conn, "insert into rtest.test values (now, 1.2, 220, 'test')")
|
||||
dbGetQuery(conn, "select * from rtest.test")
|
||||
dbDisconnect(conn)
|
||||
# ANCHOR_END: demo
|
||||
|
|
|
@ -2,11 +2,19 @@ if (! "RJDBC" %in% installed.packages()[, "Package"]) {
|
|||
install.packages('RJDBC', repos='http://cran.us.r-project.org')
|
||||
}
|
||||
|
||||
# ANCHOR: demo
|
||||
library("DBI")
|
||||
library("rJava")
|
||||
library("RJDBC")
|
||||
driver_path = "/home/debug/build/lib/taos-jdbcdriver-2.0.38-dist.jar"
|
||||
|
||||
args<- commandArgs(trailingOnly = TRUE)
|
||||
driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-3.2.4-dist.jar"
|
||||
driver = JDBC("com.taosdata.jdbc.rs.RestfulDriver", driver_path)
|
||||
conn = dbConnect(driver, "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata")
|
||||
dbGetQuery(conn, "SELECT server_version()")
|
||||
dbDisconnect(conn)
|
||||
dbSendUpdate(conn, "create database if not exists rtest")
|
||||
dbSendUpdate(conn, "create table if not exists rtest.test (ts timestamp, current float, voltage int, devname varchar(20))")
|
||||
dbSendUpdate(conn, "insert into rtest.test values (now, 1.2, 220, 'test')")
|
||||
dbGetQuery(conn, "select * from rtest.test")
|
||||
dbDisconnect(conn)
|
||||
# ANCHOR_END: demo
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
apt install -y libbz2-dev libpcre2-dev libicu-dev
|
|
@ -28,6 +28,21 @@ docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043
|
|||
|
||||
注意:TDengine 3.0 服务端仅使用 6030 TCP 端口。6041 为 taosAdapter 所使用提供 REST 服务端口。6043-6049 为 taosAdapter 提供第三方应用接入所使用端口,可根据需要选择是否打开。
|
||||
|
||||
如果需要将数据持久化到本机的某一个文件夹,则执行下边的命令:
|
||||
|
||||
```shell
|
||||
docker run -d -v ~/data/taos/dnode/data:/var/lib/taos \
|
||||
-v ~/data/taos/dnode/log:/var/log/taos \
|
||||
-p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
- /var/lib/taos: TDengine 默认数据文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode/data为你自己的数据目录
|
||||
- /var/log/taos: TDengine 默认日志文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode/log为你自己的日志目录
|
||||
|
||||
:::
|
||||
|
||||
确定该容器已经启动并且在正常运行。
|
||||
|
||||
```shell
|
||||
|
@ -108,4 +123,4 @@ SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(
|
|||
|
||||
## 其它
|
||||
|
||||
更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [在 Docker 下使用 TDengine](../../reference/docker)。
|
||||
更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [用 Docker 部署 TDengine](../../deployment/docker)。
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
sidebar_label: R
|
||||
title: R Language Connector
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Rdemo from "../07-develop/01-connect/_connect_r.mdx"
|
||||
|
||||
通过 R 语言中的 RJDBC 库可以使 R 语言程序支持访问 TDengine 数据。以下是安装过程、配置过程以及 R 语言示例代码。
|
||||
|
||||
## 安装过程
|
||||
|
||||
在开始之前,请确保已经安装了R语言环境。然后按照以下步骤安装和配置RJDBC库:
|
||||
|
||||
1. 安装Java Development Kit (JDK):RJDBC库需要依赖Java环境。请从Oracle官方网站下载适合您操作系统的JDK,并按照安装指南进行安装。
|
||||
|
||||
2. 安装RJDBC库:在R控制台中执行以下命令来安装RJDBC库。
|
||||
|
||||
```r
|
||||
install.packages("RJDBC", repos='http://cran.us.r-project.org')
|
||||
```
|
||||
|
||||
:::note
|
||||
1. Ubuntu 系统自带的 R 语言软件版本 4.2 在调用 RJDBC 库会产生无响应 bug,请安装 R 语言[官网](https://www.r-project.org/)的安装包。
|
||||
2. 在 Linux 上安装 RJDBC 包可能需要安装编译需要的组件,以 Ubuntu 为例执行 `apt install -y libbz2-dev libpcre2-dev libicu-dev` 命令安装。
|
||||
3. 在 Windows 系统上需要设置 JAVA_HOME 环境变量。
|
||||
:::
|
||||
|
||||
3. 下载 TDengine JDBC 驱动程序:访问 maven.org 网站,下载 TDengine JDBC 驱动程序(taos-jdbcdriver-X.X.X-dist.jar)。
|
||||
|
||||
4. 将 TDengine JDBC 驱动程序放置在适当的位置:在您的计算机上选择一个合适的位置,将 TDengine JDBC 驱动程序文件(taos-jdbcdriver-X.X.X-dist.jar)保存在此处。
|
||||
|
||||
## 配置过程
|
||||
|
||||
完成了安装步骤后,您需要进行一些配置,以便RJDBC库能够正确连接和访问TDengine时序数据库。
|
||||
|
||||
1. 在 R 脚本中加载 RJDBC 和其他必要的库:
|
||||
|
||||
```r
|
||||
library(DBI)
|
||||
library(rJava)
|
||||
library(RJDBC)
|
||||
```
|
||||
|
||||
2. 设置 JDBC 驱动程序和 JDBC URL:
|
||||
|
||||
```r
|
||||
# 设置JDBC驱动程序路径(根据您实际保存的位置进行修改)
|
||||
driverPath <- "/path/to/taos-jdbcdriver-X.X.X-dist.jar"
|
||||
|
||||
# 设置JDBC URL(根据您的具体环境进行修改)
|
||||
url <- "jdbc:TAOS://localhost:6030/?user=root&password=taosdata"
|
||||
```
|
||||
|
||||
3. 加载 JDBC 驱动程序:
|
||||
|
||||
```r
|
||||
# 加载JDBC驱动程序
|
||||
drv <- JDBC("com.taosdata.jdbc.TSDBDriver", driverPath)
|
||||
```
|
||||
|
||||
4. 创建 TDengine 数据库连接:
|
||||
|
||||
```r
|
||||
# 创建数据库连接
|
||||
conn <- dbConnect(drv, url)
|
||||
```
|
||||
|
||||
5. 连接成功后,您可以使用 conn 对象进行各种数据库操作,如查询数据、插入数据等。
|
||||
|
||||
6. 最后,不要忘记在使用完成后关闭数据库连接:
|
||||
|
||||
```r
|
||||
# 关闭数据库连接
|
||||
dbDisconnect(conn)
|
||||
```
|
||||
|
||||
## 使用 RJDBC 的 R 语言示例代码
|
||||
|
||||
以下是一个使用 RJDBC 库连接 TDengine 时序数据库并执行查询操作的示例代码:
|
||||
|
||||
<Rdemo/>
|
||||
|
||||
请根据您的实际情况修改JDBC驱动程序、JDBC URL、用户名、密码以及SQL查询语句,以适配您的 TDengine 时序数据库环境和要求。
|
||||
|
||||
通过以上步骤和示例代码,您可以在 R 语言环境中使用 RJDBC 库访问 TDengine 时序数据库,进行数据查询和分析等操作。
|
|
@ -62,12 +62,13 @@ serverPort 6030
|
|||
|
||||
加入到集群中的数据节点 dnode,下表中涉及集群相关的参数必须完全相同,否则不能成功加入到集群中。
|
||||
|
||||
| **#** | **配置参数名称** | **含义** |
|
||||
| ----- | ------------------ | ------------------------------------------- |
|
||||
| 1 | statusInterval | dnode 向 mnode 报告状态时长 |
|
||||
| 2 | timezone | 时区 |
|
||||
| 3 | locale | 系统区位信息及编码格式 |
|
||||
| 4 | charset | 字符集编码 |
|
||||
| **#** | **配置参数名称** | **含义** |
|
||||
| ----- | ---------------- | ------------------------------------ |
|
||||
| 1 | statusInterval | dnode 向 mnode 报告状态时长 |
|
||||
| 2 | timezone | 时区 |
|
||||
| 3 | locale | 系统区位信息及编码格式 |
|
||||
| 4 | charset | 字符集编码 |
|
||||
| 5 | ttlChangeOnWrite | ttl 到期时间是否伴随表的修改操作改变 |
|
||||
|
||||
## 启动集群
|
||||
|
||||
|
@ -196,10 +197,10 @@ dnodeID 是集群自动分配的,不得人工指定。它在生成时是递增
|
|||
1、建立集群时使用 CREATE DNODE 增加新节点后,新节点始终显示 offline 状态?
|
||||
```sql
|
||||
1)首先要检查增加的新节点上的 taosd 服务是否已经正常启动
|
||||
|
||||
|
||||
2)如果已经启动,再检查到新节点的网络是否通畅,可以使用 ping fqdn 验证下
|
||||
|
||||
|
||||
3)如果前面两步都没有问题,这一步要检查新节点做为独立集群在运行了,可以使用 taos -h fqdn 连接上后,show dnodes; 命令查看.
|
||||
如果显示的列表与你主节点上显示的不一致,说明此节点自己单独成立了一个集群,解决的方法是停止新节点上的服务,然后清空新节点上
|
||||
如果显示的列表与你主节点上显示的不一致,说明此节点自己单独成立了一个集群,解决的方法是停止新节点上的服务,然后清空新节点上
|
||||
taos.cfg 中配置的 dataDir 目录下的所有文件,重新启动新节点服务即可解决。
|
||||
```
|
||||
```
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: 用 Docker 部署 TDengine
|
||||
sidebar_label: Docker
|
||||
description: '本章主要介绍如何在容器中启动 TDengine 服务并访问它'
|
||||
---
|
||||
|
||||
|
@ -10,8 +11,17 @@ description: '本章主要介绍如何在容器中启动 TDengine 服务并访
|
|||
TDengine 镜像启动时默认激活 HTTP 服务,使用下列命令
|
||||
|
||||
```shell
|
||||
docker run -d --name tdengine -p 6041:6041 tdengine/tdengine
|
||||
docker run -d --name tdengine \
|
||||
-v ~/data/taos/dnode/data:/var/lib/taos \
|
||||
-v ~/data/taos/dnode/log:/var/log/taos \
|
||||
-p 6041:6041 tdengine/tdengine
|
||||
```
|
||||
:::note
|
||||
|
||||
- /var/lib/taos: TDengine 默认数据文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode/data为你自己的数据目录
|
||||
- /var/log/taos: TDengine 默认日志文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode/log为你自己的日志目录
|
||||
|
||||
:::
|
||||
|
||||
以上命令启动了一个名为“tdengine”的容器,并把其中的 HTTP 服务的端 6041 映射到了主机端口 6041。使用如下命令可以验证该容器中提供的 HTTP 服务是否可用:
|
||||
|
||||
|
@ -291,38 +301,37 @@ services:
|
|||
environment:
|
||||
TAOS_FQDN: "td-1"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
ports:
|
||||
- 6041:6041
|
||||
- 6030:6030
|
||||
volumes:
|
||||
- taosdata-td1:/var/lib/taos/
|
||||
- taoslog-td1:/var/log/taos/
|
||||
# /var/lib/taos: TDengine 默认数据文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode1/data为你自己的数据目录
|
||||
- ~/data/taos/dnode1/data:/var/lib/taos
|
||||
# /var/log/taos: TDengine 默认日志文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode1/log为你自己的日志目录
|
||||
- ~/data/taos/dnode1/log:/var/log/taos
|
||||
td-2:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
environment:
|
||||
TAOS_FQDN: "td-2"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td2:/var/lib/taos/
|
||||
- taoslog-td2:/var/log/taos/
|
||||
- ~/data/taos/dnode2/data:/var/lib/taos
|
||||
- ~/data/taos/dnode2/log:/var/log/taos
|
||||
td-3:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
environment:
|
||||
TAOS_FQDN: "td-3"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td3:/var/lib/taos/
|
||||
- taoslog-td3:/var/log/taos/
|
||||
volumes:
|
||||
taosdata-td1:
|
||||
taoslog-td1:
|
||||
taosdata-td2:
|
||||
taoslog-td2:
|
||||
taosdata-td3:
|
||||
taoslog-td3:
|
||||
- ~/data/taos/dnode3/data:/var/lib/taos
|
||||
- ~/data/taos/dnode3/log:/var/log/taos
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
* `VERSION` 环境变量被用来设置 tdengine image tag
|
||||
* 在新创建的实例上必须设置 `TAOS_FIRST_EP` 以使其能够加入 TDengine 集群;如果有高可用需求,则需要同时使用 `TAOS_SECOND_EP`
|
||||
|
||||
:::
|
||||
|
||||
2. 启动集群
|
||||
|
@ -397,24 +406,22 @@ networks:
|
|||
services:
|
||||
td-1:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
networks:
|
||||
- inter
|
||||
environment:
|
||||
TAOS_FQDN: "td-1"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td1:/var/lib/taos/
|
||||
- taoslog-td1:/var/log/taos/
|
||||
# /var/lib/taos: TDengine 默认数据文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode1/data为你自己的数据目录
|
||||
- ~/data/taos/dnode1/data:/var/lib/taos
|
||||
# /var/log/taos: TDengine 默认日志文件目录。可通过[配置文件]修改位置。你可以修改~/data/taos/dnode1/log为你自己的日志目录
|
||||
- ~/data/taos/dnode1/log:/var/log/taos
|
||||
td-2:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
networks:
|
||||
- inter
|
||||
environment:
|
||||
TAOS_FQDN: "td-2"
|
||||
TAOS_FIRST_EP: "td-1"
|
||||
volumes:
|
||||
- taosdata-td2:/var/lib/taos/
|
||||
- taoslog-td2:/var/log/taos/
|
||||
- ~/data/taos/dnode2/data:/var/lib/taos
|
||||
- ~/data/taos/dnode2/log:/var/log/taos
|
||||
adapter:
|
||||
image: tdengine/tdengine:$VERSION
|
||||
entrypoint: "taosadapter"
|
||||
|
@ -446,11 +453,6 @@ services:
|
|||
>> /etc/nginx/nginx.conf;cat /etc/nginx/nginx.conf;
|
||||
nginx -g 'daemon off;'",
|
||||
]
|
||||
volumes:
|
||||
taosdata-td1:
|
||||
taoslog-td1:
|
||||
taosdata-td2:
|
||||
taoslog-td2:
|
||||
```
|
||||
|
||||
## 使用 docker swarm 部署
|
|
@ -6,7 +6,7 @@ description: 部署 TDengine 集群的多种方式
|
|||
|
||||
TDengine 支持集群,提供水平扩展的能力。如果需要获得更高的处理能力,只需要多增加节点即可。TDengine 采用虚拟节点技术,将一个节点虚拟化为多个虚拟节点,以实现负载均衡。同时,TDengine可以将多个节点上的虚拟节点组成虚拟节点组,通过多副本机制,以保证供系统的高可用。TDengine的集群功能完全开源。
|
||||
|
||||
本章节主要介绍如何在主机上人工部署集群,以及如何使用 Kubernetes 和 Helm部署集群。
|
||||
本章节主要介绍如何在主机上人工部署集群,docker部署,以及如何使用 Kubernetes 和 Helm部署集群。
|
||||
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
|
|
|
@ -82,7 +82,7 @@ INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27,
|
|||
|
||||
```sql
|
||||
INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
|
||||
d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
|
||||
d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
|
||||
```
|
||||
|
||||
## 插入记录时自动建表
|
||||
|
|
|
@ -315,7 +315,7 @@ WHERE (column|tbname) match/MATCH/nmatch/NMATCH _regex_
|
|||
|
||||
### 使用限制
|
||||
|
||||
只能针对表名(即 tbname 筛选)、binary/nchar 类型标签值进行正则表达式过滤,不支持普通列的过滤。
|
||||
只能针对表名(即 tbname 筛选)、binary/nchar 类型值进行正则表达式过滤。
|
||||
|
||||
正则匹配字符串长度不能超过 128 字节。可以通过参数 _maxRegexStringLen_ 设置和调整最大允许的正则匹配字符串,该参数是客户端配置参数,需要重启才能生效。
|
||||
|
||||
|
|
|
@ -700,7 +700,7 @@ ELAPSED(ts_primary_key [, time_unit])
|
|||
LEASTSQUARES(expr, start_val, step_val)
|
||||
```
|
||||
|
||||
**功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。
|
||||
**功能说明**:统计表中某列的值的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。
|
||||
|
||||
**返回数据类型**:字符串表达式(斜率, 截距)。
|
||||
|
||||
|
@ -1265,3 +1265,140 @@ SELECT SERVER_STATUS();
|
|||
```
|
||||
|
||||
**说明**:检测服务端是否所有 dnode 都在线,如果是则返回成功,否则返回无法建立连接的错误。
|
||||
|
||||
|
||||
## Geometry 函数
|
||||
|
||||
### Geometry 输入函数:
|
||||
|
||||
#### ST_GeomFromText
|
||||
|
||||
```sql
|
||||
ST_GeomFromText(VARCHAR WKT expr)
|
||||
```
|
||||
|
||||
**功能说明**:根据 Well-Known Text (WKT) 表示从指定的几何值创建几何数据。
|
||||
|
||||
**返回值类型**:GEOMETRY
|
||||
|
||||
**适用数据类型**:VARCHAR
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:输入可以是 WKT 字符串之一,例如点(POINT)、线串(LINESTRING)、多边形(POLYGON)、多点集(MULTIPOINT)、多线串(MULTILINESTRING)、多多边形(MULTIPOLYGON)、几何集合(GEOMETRYCOLLECTION)。输出是以二进制字符串形式定义的 GEOMETRY 数据类型。
|
||||
|
||||
### Geometry 输出函数:
|
||||
|
||||
#### ST_AsText
|
||||
|
||||
```sql
|
||||
ST_AsText(GEOMETRY geom)
|
||||
```
|
||||
|
||||
**功能说明**:从几何数据中返回指定的 Well-Known Text (WKT) 表示。
|
||||
|
||||
**返回值类型**:VARCHAR
|
||||
|
||||
**适用数据类型**:GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:输出可以是 WKT 字符串之一,例如点(POINT)、线串(LINESTRING)、多边形(POLYGON)、多点集(MULTIPOINT)、多线串(MULTILINESTRING)、多多边形(MULTIPOLYGON)、几何集合(GEOMETRYCOLLECTION)。
|
||||
|
||||
### Geometry 关系函数:
|
||||
|
||||
#### ST_Intersects
|
||||
|
||||
```sql
|
||||
ST_Intersects(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
##功能说明**:比较两个几何对象,并在它们相交时返回 true。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:如果两个几何对象有任何一个共享点,则它们相交。
|
||||
|
||||
#### ST_Equals
|
||||
|
||||
```sql
|
||||
ST_Equals(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**功能说明**:如果给定的几何对象是"空间相等"的,则返回 TRUE。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:"空间相等"意味着 ST_Contains(A,B) = true 和 ST_Contains(B,A) = true,并且点的顺序可能不同,但表示相同的几何结构。
|
||||
|
||||
#### ST_Touches
|
||||
|
||||
```sql
|
||||
ST_Touches(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**功能说明**:如果 A 和 B 相交,但它们的内部不相交,则返回 TRUE。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:A 和 B 至少有一个公共点,并且这些公共点位于至少一个边界中。对于点/点输入,关系始终为 FALSE,因为点没有边界。
|
||||
|
||||
#### ST_Covers
|
||||
|
||||
```sql
|
||||
ST_Covers(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**功能说明**:如果 B 中的每个点都位于几何形状 A 内部(与内部或边界相交),则返回 TRUE。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:A 包含 B 意味着 B 中的没有点位于 A 的外部(在外部)。
|
||||
|
||||
#### ST_Contains
|
||||
|
||||
```sql
|
||||
ST_Contains(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**功能说明**:如果 A 包含 B,描述:如果几何形状 A 包含几何形状 B,则返回 TRUE。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:A 包含 B 当且仅当 B 的所有点位于 A 的内部(即位于内部或边界上)(或等效地,B 的没有点位于 A 的外部),并且 A 和 B 的内部至少有一个公共点。
|
||||
|
||||
#### ST_ContainsProperly
|
||||
|
||||
```sql
|
||||
ST_ContainsProperly(GEOMETRY geomA, GEOMETRY geomB)
|
||||
```
|
||||
|
||||
**功能说明**:如果 B 的每个点都位于 A 内部,则返回 TRUE。
|
||||
|
||||
**返回值类型**:BOOL
|
||||
|
||||
**适用数据类型**:GEOMETRY,GEOMETRY
|
||||
|
||||
**适用表类型**:标准表和超表
|
||||
|
||||
**使用说明**:B 的没有点位于 A 的边界或外部。
|
||||
|
|
|
@ -178,6 +178,7 @@ description: TDengine 保留关键字的详细列表
|
|||
|
||||
- MATCH
|
||||
- MAX_DELAY
|
||||
- MAX_SPEED
|
||||
- MAXROWS
|
||||
- MERGE
|
||||
- META
|
||||
|
|
|
@ -7,12 +7,13 @@ description: "TDengine 服务端、客户端和连接器支持的平台列表"
|
|||
|
||||
| | **Windows server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18 以上** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **macOS** |
|
||||
| ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | ------------ | ----------------- | ---------------- | --------- |
|
||||
| X64 | ● | ● | ● | ● | ● | ● | ● | ● |
|
||||
| 树莓派 ARM64 | | | ● | | | | | |
|
||||
| 华为云 ARM64 | | | | ● | | | | |
|
||||
| M1 | | | | | | | | ● |
|
||||
| X64 | ●/E | ●/E | ● | ● | ●/E | ●/E | ●/E | ● |
|
||||
| 树莓派 ARM64 | | | ● | | | | | |
|
||||
| 华为云 ARM64 | | | | ● | | | | |
|
||||
| M1 | | | | | | | | ● |
|
||||
|
||||
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。
|
||||
注:1) ● 表示经过官方测试验证, ○ 表示非官方测试验证,E 表示仅企业版支持。
|
||||
2) 社区版仅支持主流操作系统的较新版本,包括 Ubuntu 18+/CentOS 7+/RetHat/Debian/CoreOS/FreeBSD/OpenSUSE/SUSE Linux/Fedora/macOS 等。如果有其他操作系统及版本的需求,请联系企业版支持。
|
||||
|
||||
## TDengine 客户端和连接器支持的平台列表
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
label: TDengine Docker 镜像
|
|
@ -95,30 +95,11 @@ taos -C
|
|||
### maxShellConns
|
||||
|
||||
| 属性 | 说明 |
|
||||
| --------| ----------------------- |
|
||||
| -------- | ----------------------- |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 一个 dnode 容许的连接数 |
|
||||
| 含义 | 一个 dnode 容许的连接数 |
|
||||
| 取值范围 | 10-50000000 |
|
||||
| 缺省值 | 5000 |
|
||||
|
||||
### numOfRpcSessions
|
||||
|
||||
| 属性 | 说明 |
|
||||
| --------| ---------------------- |
|
||||
| 适用范围 | 客户端和服务端都适用 |
|
||||
| 含义 | 一个客户端能创建的最大连接数|
|
||||
| 取值范围 | 100-100000 |
|
||||
| 缺省值 | 10000 |
|
||||
|
||||
### timeToGetAvailableConn
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | --------------------|
|
||||
| 适用范围 | 客户端和服务端都适用 |
|
||||
| 含义 |获得可用连接的最长等待时间|
|
||||
| 取值范围 | 10-50000000(单位为毫秒)|
|
||||
| 缺省值 | 500000 |
|
||||
|
||||
| 缺省值 | 5000 |
|
||||
|
||||
### numOfRpcSessions
|
||||
|
||||
|
@ -127,7 +108,7 @@ taos -C
|
|||
| 适用范围 | 客户端和服务端都适用 |
|
||||
| 含义 | 一个客户端能创建的最大连接数 |
|
||||
| 取值范围 | 100-100000 |
|
||||
| 缺省值 | 10000 |
|
||||
| 缺省值 | 30000 |
|
||||
|
||||
### timeToGetAvailableConn
|
||||
|
||||
|
@ -392,12 +373,12 @@ charset 的有效值是 UTF-8。
|
|||
|
||||
### metaCacheMaxSize
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ---------------------------------------------- |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | 指定单个客户端元数据缓存大小的最大值 |
|
||||
| 单位 | MB |
|
||||
| 缺省值 | -1 (无限制) |
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------------------------ |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | 指定单个客户端元数据缓存大小的最大值 |
|
||||
| 单位 | MB |
|
||||
| 缺省值 | -1 (无限制) |
|
||||
|
||||
## 集群相关
|
||||
|
||||
|
@ -479,13 +460,13 @@ charset 的有效值是 UTF-8。
|
|||
|
||||
### slowLogScope
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | --------------------------------------------------------------|
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | 指定启动记录哪些类型的慢查询 |
|
||||
| 可选值 | ALL, QUERY, INSERT, OTHERS, NONE |
|
||||
| 缺省值 | ALL |
|
||||
| 补充说明 | 默认记录所有类型的慢查询,可通过配置只记录某一类型的慢查询 |
|
||||
| 属性 | 说明 |
|
||||
| -------- | ---------------------------------------------------------- |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | 指定启动记录哪些类型的慢查询 |
|
||||
| 可选值 | ALL, QUERY, INSERT, OTHERS, NONE |
|
||||
| 缺省值 | ALL |
|
||||
| 补充说明 | 默认记录所有类型的慢查询,可通过配置只记录某一类型的慢查询 |
|
||||
|
||||
### debugFlag
|
||||
|
||||
|
@ -685,16 +666,16 @@ charset 的有效值是 UTF-8。
|
|||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | schemaless 列数据是否顺序一致,从3.0.3.0开始,该配置废弃 |
|
||||
| 值域 | 0:不一致;1: 一致 |
|
||||
| 缺省值 | 0
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### smlTsDefaultName
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------------------------------- |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------------------- |
|
||||
| 适用范围 | 仅客户端适用 |
|
||||
| 含义 | schemaless自动建表的时间列名字通过该配置设置 |
|
||||
| 类型 | 字符串 |
|
||||
| 缺省值 | _ts |
|
||||
| 缺省值 | _ts |
|
||||
|
||||
## 其他
|
||||
|
||||
|
@ -728,31 +709,31 @@ charset 的有效值是 UTF-8。
|
|||
|
||||
### ttlChangeOnWrite
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------ |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | ttl 到期时间是否伴随表的修改操作改变 |
|
||||
| 取值范围 | 0: 不改变;1:改变 |
|
||||
| 缺省值 | 0 |
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------------------------ |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | ttl 到期时间是否伴随表的修改操作改变 |
|
||||
| 取值范围 | 0: 不改变;1:改变 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### keepTimeOffset
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------ |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 迁移操作的延时 |
|
||||
| 单位 | 小时 |
|
||||
| 取值范围 | 0-23 |
|
||||
| 缺省值 | 0 |
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------- |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 迁移操作的延时 |
|
||||
| 单位 | 小时 |
|
||||
| 取值范围 | 0-23 |
|
||||
| 缺省值 | 0 |
|
||||
|
||||
### tmqMaxTopicNum
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | ------------------ |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 订阅最多可建立的 topic 数量 |
|
||||
| 取值范围 | 1-10000|
|
||||
| 缺省值 | 20 |
|
||||
| 属性 | 说明 |
|
||||
| -------- | --------------------------- |
|
||||
| 适用范围 | 仅服务端适用 |
|
||||
| 含义 | 订阅最多可建立的 topic 数量 |
|
||||
| 取值范围 | 1-10000 |
|
||||
| 缺省值 | 20 |
|
||||
|
||||
## 压缩参数
|
||||
|
||||
|
|
|
@ -20,18 +20,12 @@ mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -De
|
|||
```
|
||||
|
||||
## Compile the Demo Code and Run It
|
||||
To compile taos-jdbcdriver, go to the source directory ``TDengine/src/connector/jdbc`` and execute
|
||||
```
|
||||
mvn clean package -Dmaven.test.skip=true
|
||||
```
|
||||
|
||||
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
|
||||
To run JDBCDemo.jar, execute
|
||||
```
|
||||
mvn clean package assembly:single
|
||||
```
|
||||
|
||||
To run JDBCDemo.jar, go to ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
|
||||
```
|
||||
java -Djava.ext.dirs=../../../../src/connector/jdbc/target:$JAVA_HOME/jre/lib/ext -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host [HOSTNAME]
|
||||
java -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host [HOSTNAME]
|
||||
```
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ public class JdbcRestfulDemo {
|
|||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("charset", "UTF-8");
|
||||
properties.setProperty("locale", "en_US.UTF-8");
|
||||
properties.setProperty("timezone", "UTC-8");
|
||||
|
||||
Connection conn = DriverManager.getConnection(url, properties);
|
||||
Statement stmt = conn.createStatement();
|
||||
|
|
|
@ -58,6 +58,7 @@ extern int32_t tsTagFilterResCacheSize;
|
|||
extern int32_t tsNumOfRpcThreads;
|
||||
extern int32_t tsNumOfRpcSessions;
|
||||
extern int32_t tsTimeToGetAvailableConn;
|
||||
extern int32_t tsKeepAliveIdle;
|
||||
extern int32_t tsNumOfCommitThreads;
|
||||
extern int32_t tsNumOfTaskQueueThreads;
|
||||
extern int32_t tsNumOfMnodeQueryThreads;
|
||||
|
|
|
@ -3000,6 +3000,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
SMsgHead head;
|
||||
int64_t leftForVer;
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
} SVDropStreamTaskReq;
|
||||
|
||||
|
@ -3191,6 +3192,7 @@ int32_t tDecodeMqVgOffset(SDecoder* pDecoder, SMqVgOffset* pOffset);
|
|||
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
int64_t streamId;
|
||||
int32_t taskId;
|
||||
} SVPauseStreamTaskReq;
|
||||
|
||||
|
@ -3209,6 +3211,7 @@ int32_t tDeserializeSMPauseStreamReq(void* buf, int32_t bufLen, SMPauseStreamReq
|
|||
typedef struct {
|
||||
SMsgHead head;
|
||||
int32_t taskId;
|
||||
int64_t streamId;
|
||||
int8_t igUntreated;
|
||||
} SVResumeStreamTaskReq;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef enum {
|
|||
* @param vgId
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId);
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId, int32_t taskId);
|
||||
|
||||
/**
|
||||
* Create the exec task for queue mode
|
||||
|
@ -95,8 +95,6 @@ int32_t qGetTableList(int64_t suid, void* pVnode, void* node, SArray **tableList
|
|||
*/
|
||||
void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId);
|
||||
|
||||
//void qSetTaskCode(qTaskInfo_t tinfo, int32_t code);
|
||||
|
||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo);
|
||||
|
||||
// todo refactor
|
||||
|
|
|
@ -30,6 +30,7 @@ extern "C" {
|
|||
|
||||
typedef struct SStreamTask SStreamTask;
|
||||
|
||||
#define SSTREAM_TASK_VER 1
|
||||
enum {
|
||||
STREAM_STATUS__NORMAL = 0,
|
||||
STREAM_STATUS__STOP,
|
||||
|
@ -266,13 +267,13 @@ typedef struct SCheckpointInfo {
|
|||
} SCheckpointInfo;
|
||||
|
||||
typedef struct SStreamStatus {
|
||||
int8_t taskStatus;
|
||||
int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set
|
||||
int8_t schedStatus;
|
||||
int8_t keepTaskStatus;
|
||||
bool transferState;
|
||||
int8_t timerActive; // timer is active
|
||||
int8_t pauseAllowed; // allowed task status to be set to be paused
|
||||
int8_t taskStatus;
|
||||
int8_t downstreamReady; // downstream tasks are all ready now, if this flag is set
|
||||
int8_t schedStatus;
|
||||
int8_t keepTaskStatus;
|
||||
bool transferState;
|
||||
int8_t timerActive; // timer is active
|
||||
int8_t pauseAllowed; // allowed task status to be set to be paused
|
||||
} SStreamStatus;
|
||||
|
||||
typedef struct SHistDataRange {
|
||||
|
@ -309,6 +310,7 @@ typedef struct {
|
|||
} STaskTimestamp;
|
||||
|
||||
struct SStreamTask {
|
||||
int64_t ver;
|
||||
SStreamId id;
|
||||
SSTaskBasicInfo info;
|
||||
STaskOutputInfo outputInfo;
|
||||
|
@ -589,10 +591,10 @@ bool streamTaskShouldPause(const SStreamStatus* pStatus);
|
|||
bool streamTaskIsIdle(const SStreamTask* pTask);
|
||||
int32_t streamTaskEndScanWAL(SStreamTask* pTask);
|
||||
|
||||
SStreamChildEpInfo * streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t taskId);
|
||||
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSize);
|
||||
SStreamChildEpInfo* streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t taskId);
|
||||
int32_t streamScanExec(SStreamTask* pTask, int32_t batchSize);
|
||||
|
||||
char* createStreamTaskIdStr(int64_t streamId, int32_t taskId);
|
||||
char* createStreamTaskIdStr(int64_t streamId, int32_t taskId);
|
||||
|
||||
// recover and fill history
|
||||
void streamTaskCheckDownstreamTasks(SStreamTask* pTask);
|
||||
|
@ -628,7 +630,8 @@ int32_t streamDispatchTransferStateMsg(SStreamTask* pTask);
|
|||
|
||||
// agg level
|
||||
int32_t streamTaskScanHistoryPrepare(SStreamTask* pTask);
|
||||
int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistoryFinishReq *pReq, SRpcHandleInfo* pRpcInfo);
|
||||
int32_t streamProcessScanHistoryFinishReq(SStreamTask* pTask, SStreamScanHistoryFinishReq* pReq,
|
||||
SRpcHandleInfo* pRpcInfo);
|
||||
int32_t streamProcessScanHistoryFinishRsp(SStreamTask* pTask);
|
||||
|
||||
// stream task meta
|
||||
|
@ -641,9 +644,9 @@ void streamMetaClose(SStreamMeta* streamMeta);
|
|||
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
|
||||
int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask, bool* pAdded);
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int32_t taskId);
|
||||
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta); // todo remove it
|
||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int32_t taskId);
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta); // todo remove it
|
||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||
|
||||
int32_t streamMetaBegin(SStreamMeta* pMeta);
|
||||
|
@ -659,7 +662,6 @@ int32_t streamTaskReleaseState(SStreamTask* pTask);
|
|||
int32_t streamTaskReloadState(SStreamTask* pTask);
|
||||
int32_t streamAlignTransferState(SStreamTask* pTask);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -300,6 +300,25 @@ void tfsClosedir(STfsDir *pDir);
|
|||
*/
|
||||
int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo);
|
||||
|
||||
/**
|
||||
* @brief Check if disk space available at level
|
||||
*
|
||||
* @param pTfs The fs object.
|
||||
* #param level the level
|
||||
* @return bool
|
||||
*/
|
||||
bool tfsDiskSpaceAvailable(STfs *pTfs, int32_t level);
|
||||
|
||||
/**
|
||||
* @brief Check if disk space sufficient at disk of level
|
||||
*
|
||||
* @param pTfs The fs object.
|
||||
* @param level the level
|
||||
* @param disk the disk
|
||||
* @return bool
|
||||
*/
|
||||
bool tfsDiskSpaceSufficient(STfs *pTfs, int32_t level, int32_t disk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -89,7 +89,7 @@ typedef struct SRpcInit {
|
|||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
int32_t retryMaxInterval; // retry max interval
|
||||
int64_t retryMaxTimouet;
|
||||
int64_t retryMaxTimeout;
|
||||
|
||||
int32_t failFastThreshold;
|
||||
int32_t failFastInterval;
|
||||
|
|
|
@ -153,7 +153,6 @@ struct SWalReader {
|
|||
int64_t capacity;
|
||||
TdThreadMutex mutex;
|
||||
SWalFilterCond cond;
|
||||
// TODO remove it
|
||||
SWalCkHead *pHead;
|
||||
};
|
||||
|
||||
|
@ -207,10 +206,9 @@ void walReaderValidVersionRange(SWalReader *pReader, int64_t *sver, int64
|
|||
void walReaderVerifyOffset(SWalReader *pWalReader, STqOffsetVal* pOffset);
|
||||
|
||||
// only for tq usage
|
||||
void walSetReaderCapacity(SWalReader *pRead, int32_t capacity);
|
||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead);
|
||||
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead);
|
||||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead);
|
||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver);
|
||||
int32_t walFetchBody(SWalReader *pRead);
|
||||
int32_t walSkipFetchBody(SWalReader *pRead);
|
||||
|
||||
void walRefFirstVer(SWal *, SWalRef *);
|
||||
void walRefLastVer(SWal *, SWalRef *);
|
||||
|
|
|
@ -613,6 +613,11 @@ function install_examples() {
|
|||
fi
|
||||
}
|
||||
|
||||
function install_web() {
|
||||
if [ -d "${script_dir}/share" ]; then
|
||||
${csudo}cp -rf ${script_dir}/share/* ${install_main_dir}/share > /dev/null 2>&1 ||:
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then
|
||||
|
@ -888,6 +893,7 @@ function updateProduct() {
|
|||
fi
|
||||
|
||||
install_examples
|
||||
install_web
|
||||
if [ -z $1 ]; then
|
||||
install_bin
|
||||
install_service
|
||||
|
@ -898,29 +904,29 @@ function updateProduct() {
|
|||
openresty_work=false
|
||||
|
||||
echo
|
||||
echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}"
|
||||
echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t: edit ${cfg_install_dir}/${configFile2}"
|
||||
[ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml"
|
||||
echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml"
|
||||
if ((${service_mod} == 0)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}systemctl start ${serverName2}${NC}"
|
||||
[ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${csudo}systemctl start ${clientName2}adapter ${NC}"
|
||||
elif ((${service_mod} == 1)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}service ${serverName2} start${NC}"
|
||||
[ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${csudo}service ${clientName2}adapter start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ./${serverName2}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ./${serverName2}${NC}"
|
||||
[ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${clientName2}adapter &${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${clientName2}adapter ${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}: sudo systemctl enable ${clientName2}keeper &${NC}"
|
||||
echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t: sudo systemctl enable ${clientName2}keeper ${NC}"
|
||||
|
||||
if [ ${openresty_work} = 'true' ]; then
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}"
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}"
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}"
|
||||
fi
|
||||
|
||||
if ((${prompt_force} == 1)); then
|
||||
|
@ -968,7 +974,7 @@ function installProduct() {
|
|||
install_connector
|
||||
fi
|
||||
install_examples
|
||||
|
||||
install_web
|
||||
if [ -z $1 ]; then # install service and client
|
||||
# For installing new
|
||||
install_bin
|
||||
|
@ -982,24 +988,24 @@ function installProduct() {
|
|||
|
||||
# Ask if to start the service
|
||||
echo
|
||||
echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}"
|
||||
echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t: edit ${cfg_install_dir}/${configFile2}"
|
||||
[ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml"
|
||||
echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml"
|
||||
if ((${service_mod} == 0)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}systemctl start ${serverName2}${NC}"
|
||||
[ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${csudo}systemctl start ${clientName2}adapter ${NC}"
|
||||
elif ((${service_mod} == 1)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${csudo}service ${serverName2} start${NC}"
|
||||
[ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${csudo}service ${clientName2}adapter start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${serverName2}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t: ${serverName2}${NC}"
|
||||
[ -f ${installDir}/bin/${clientName2}adapter ] && \
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}: ${clientName2}adapter &${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t: ${clientName2}adapter ${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}: sudo systemctl enable ${clientName2}keeper &${NC}"
|
||||
echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t: sudo systemctl enable ${clientName2}keeper ${NC}"
|
||||
|
||||
if [ ! -z "$firstEp" ]; then
|
||||
tmpFqdn=${firstEp%%:*}
|
||||
|
@ -1010,14 +1016,14 @@ function installProduct() {
|
|||
tmpPort=""
|
||||
fi
|
||||
if [[ "$tmpPort" != "" ]]; then
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t: ${clientName2} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
|
||||
echo
|
||||
elif [ ! -z "$serverFqdn" ]; then
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}"
|
||||
echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}"
|
||||
echo
|
||||
fi
|
||||
|
||||
|
|
|
@ -319,6 +319,11 @@ if [[ $dbName == "taos" ]]; then
|
|||
mkdir -p ${install_dir}/examples/taosbenchmark-json && cp ${examples_dir}/../tools/taos-tools/example/* ${install_dir}/examples/taosbenchmark-json
|
||||
fi
|
||||
|
||||
if [ "$verMode" == "cluster" ] || [ "$verMode" == "cloud" ]; then
|
||||
mkdir -p ${install_dir}/share/
|
||||
cp -rf ${build_dir}/share/{etc,srv} ${install_dir}/share ||:
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Copy driver
|
||||
|
|
|
@ -123,8 +123,8 @@ function clean_bin() {
|
|||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
||||
${csudo}rm -f ${bin_link_dir}/${keeperName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${xName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${explorerName2} || :
|
||||
# ${csudo}rm -f ${bin_link_dir}/${xName2} || :
|
||||
# ${csudo}rm -f ${bin_link_dir}/${explorerName2} || :
|
||||
|
||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||
${csudo}rm -f ${bin_link_dir}/${clientName2} || :
|
||||
|
@ -194,26 +194,26 @@ function clean_service_on_systemd() {
|
|||
fi
|
||||
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
||||
|
||||
x_service_config="${service_config_dir}/${xName2}.service"
|
||||
if [ -e "$x_service_config" ]; then
|
||||
if systemctl is-active --quiet ${xName2}; then
|
||||
echo "${productName2} ${xName2} is running, stopping it..."
|
||||
${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null
|
||||
${csudo}rm -f ${x_service_config}
|
||||
fi
|
||||
# x_service_config="${service_config_dir}/${xName2}.service"
|
||||
# if [ -e "$x_service_config" ]; then
|
||||
# if systemctl is-active --quiet ${xName2}; then
|
||||
# echo "${productName2} ${xName2} is running, stopping it..."
|
||||
# ${csudo}systemctl stop ${xName2} &>/dev/null || echo &>/dev/null
|
||||
# fi
|
||||
# ${csudo}systemctl disable ${xName2} &>/dev/null || echo &>/dev/null
|
||||
# ${csudo}rm -f ${x_service_config}
|
||||
# fi
|
||||
|
||||
explorer_service_config="${service_config_dir}/${explorerName2}.service"
|
||||
if [ -e "$explorer_service_config" ]; then
|
||||
if systemctl is-active --quiet ${explorerName2}; then
|
||||
echo "${productName2} ${explorerName2} is running, stopping it..."
|
||||
${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||
${csudo}rm -f ${explorer_service_config}
|
||||
${csudo}rm -f /etc/${clientName2}/explorer.toml
|
||||
fi
|
||||
# explorer_service_config="${service_config_dir}/${explorerName2}.service"
|
||||
# if [ -e "$explorer_service_config" ]; then
|
||||
# if systemctl is-active --quiet ${explorerName2}; then
|
||||
# echo "${productName2} ${explorerName2} is running, stopping it..."
|
||||
# ${csudo}systemctl stop ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||
# fi
|
||||
# ${csudo}systemctl disable ${explorerName2} &>/dev/null || echo &>/dev/null
|
||||
# ${csudo}rm -f ${explorer_service_config}
|
||||
# ${csudo}rm -f /etc/${clientName2}/explorer.toml
|
||||
# fi
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
|
|
|
@ -169,7 +169,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||
rpcInit.retryMaxTimeout = tsMaxRetryWaitTime;
|
||||
|
||||
int32_t connLimitNum = tsNumOfRpcSessions / (tsNumOfRpcThreads * 3);
|
||||
connLimitNum = TMAX(connLimitNum, 10);
|
||||
|
|
|
@ -1863,10 +1863,10 @@ 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){
|
||||
static void updateVgInfo(SMqClientVg* pVg, STqOffsetVal* reqOffset, STqOffsetVal* rspOffset, int64_t sver, int64_t ever, int64_t consumerId, bool hasData){
|
||||
if (!pVg->seekUpdated) {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is update, since seekupdate not set", consumerId);
|
||||
pVg->offsetInfo.beginOffset = *reqOffset;
|
||||
if(hasData) pVg->offsetInfo.beginOffset = *reqOffset;
|
||||
pVg->offsetInfo.endOffset = *rspOffset;
|
||||
} else {
|
||||
tscDebug("consumer:0x%" PRIx64" local offset is NOT update, since seekupdate is set", consumerId);
|
||||
|
@ -1929,7 +1929,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
pVg->epSet = *pollRspWrapper->pEpset;
|
||||
}
|
||||
|
||||
updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset, pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId);
|
||||
updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset, pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId, pDataRsp->blockNum != 0);
|
||||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset);
|
||||
|
@ -1979,7 +1979,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
updateVgInfo(pVg, &pollRspWrapper->metaRsp.rspOffset, &pollRspWrapper->metaRsp.rspOffset, pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId);
|
||||
updateVgInfo(pVg, &pollRspWrapper->metaRsp.rspOffset, &pollRspWrapper->metaRsp.rspOffset, pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId, true);
|
||||
// build rsp
|
||||
SMqMetaRspObj* pRsp = tmqBuildMetaRspFromWrapper(pollRspWrapper);
|
||||
taosFreeQitem(pollRspWrapper);
|
||||
|
@ -2007,7 +2007,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset, pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId);
|
||||
updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset, pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId, pollRspWrapper->taosxRsp.blockNum != 0);
|
||||
|
||||
if (pollRspWrapper->taosxRsp.blockNum == 0) {
|
||||
tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64,
|
||||
|
|
|
@ -1442,178 +1442,4 @@ TEST(clientCase, sub_tb_mt_test) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(clientCase, ts_3756) {
|
||||
// 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", "latest");
|
||||
tmq_conf_set(conf, "msg.with.table.name", "false");
|
||||
|
||||
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 = 200;
|
||||
|
||||
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);
|
||||
|
||||
tmq_topic_assignment* pAssignTmp = NULL;
|
||||
int32_t numOfAssignTmp = 0;
|
||||
|
||||
code = tmq_get_topic_assignment(tmq, "tp", &pAssignTmp, &numOfAssignTmp);
|
||||
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, pAssignTmp[i].vgId, pAssignTmp[i].currentOffset, pAssignTmp[i].begin, pAssignTmp[i].end);
|
||||
}
|
||||
if(numOfAssign != 0){
|
||||
int i = 0;
|
||||
for(; i < numOfAssign; i++){
|
||||
if(pAssign[i].currentOffset != pAssignTmp[i].currentOffset){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == numOfAssign){
|
||||
printf("all position is same\n");
|
||||
break;
|
||||
}
|
||||
tmq_free_assignment(pAssign);
|
||||
}
|
||||
numOfAssign = numOfAssignTmp;
|
||||
pAssign = pAssignTmp;
|
||||
|
||||
} 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);
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -616,6 +616,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
|
|||
pDst->info = pBlock->info;
|
||||
pDst->info.rows = 0;
|
||||
pDst->info.capacity = 0;
|
||||
pDst->info.rowSize = 0;
|
||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData colInfo = {0};
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "tglobal.h"
|
||||
#include "os.h"
|
||||
#include "tconfig.h"
|
||||
#include "tgrant.h"
|
||||
#include "tlog.h"
|
||||
|
@ -47,8 +47,10 @@ bool tsPrintAuth = false;
|
|||
|
||||
// queue & threads
|
||||
int32_t tsNumOfRpcThreads = 1;
|
||||
int32_t tsNumOfRpcSessions = 10000;
|
||||
int32_t tsNumOfRpcSessions = 30000;
|
||||
int32_t tsTimeToGetAvailableConn = 500000;
|
||||
int32_t tsKeepAliveIdle = 60;
|
||||
|
||||
int32_t tsNumOfCommitThreads = 2;
|
||||
int32_t tsNumOfTaskQueueThreads = 4;
|
||||
int32_t tsNumOfMnodeQueryThreads = 4;
|
||||
|
@ -63,7 +65,7 @@ int32_t tsNumOfQnodeFetchThreads = 1;
|
|||
int32_t tsNumOfSnodeStreamThreads = 4;
|
||||
int32_t tsNumOfSnodeWriteThreads = 1;
|
||||
int32_t tsMaxStreamBackendCache = 128; // M
|
||||
int32_t tsPQSortMemThreshold = 16; // M
|
||||
int32_t tsPQSortMemThreshold = 16; // M
|
||||
|
||||
// sync raft
|
||||
int32_t tsElectInterval = 25 * 1000;
|
||||
|
@ -121,8 +123,8 @@ int32_t tsQueryPolicy = 1;
|
|||
int32_t tsQueryRspPolicy = 0;
|
||||
int64_t tsQueryMaxConcurrentTables = 200; // unit is TSDB_TABLE_NUM_UNIT
|
||||
bool tsEnableQueryHb = true;
|
||||
bool tsEnableScience = false; // on taos-cli show float and doulbe with scientific notation if true
|
||||
bool tsTtlChangeOnWrite = false; // ttl delete time changes on last write if true
|
||||
bool tsEnableScience = false; // on taos-cli show float and doulbe with scientific notation if true
|
||||
bool tsTtlChangeOnWrite = false; // ttl delete time changes on last write if true
|
||||
int32_t tsQuerySmaOptimize = 0;
|
||||
int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data.
|
||||
bool tsQueryPlannerTrace = false;
|
||||
|
@ -376,7 +378,9 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "useAdapter", tsUseAdapter, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "crashReporting", tsEnableCrashReport, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt64(pCfg, "queryMaxConcurrentTables", tsQueryMaxConcurrentTables, INT64_MIN, INT64_MAX, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt64(pCfg, "queryMaxConcurrentTables", tsQueryMaxConcurrentTables, INT64_MIN, INT64_MAX,
|
||||
CFG_SCOPE_CLIENT) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "metaCacheMaxSize", tsMetaCacheMaxSize, -1, INT32_MAX, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "slowLogThreshold", tsSlowLogThreshold, 0, INT32_MAX, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "slowLogScope", "", CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
|
@ -389,7 +393,11 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "numOfRpcSessions", tsNumOfRpcSessions, 1, 100000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
|
||||
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 10000000);
|
||||
if (cfgAddInt32(pCfg, "timeToGetAvailableConn", tsTimeToGetAvailableConn, 20, 1000000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "timeToGetAvailableConn", tsTimeToGetAvailableConn, 20, 1000000, CFG_SCOPE_BOTH) != 0)
|
||||
return -1;
|
||||
|
||||
tsKeepAliveIdle = TRANGE(tsKeepAliveIdle, 1, 72000);
|
||||
if (cfgAddInt32(pCfg, "keepAliveIdle", tsKeepAliveIdle, 1, 7200000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
|
||||
tsNumOfTaskQueueThreads = tsNumOfCores / 2;
|
||||
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 4);
|
||||
|
@ -449,7 +457,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "minSlidingTime", tsMinSlidingTime, 1, 1000000, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "minIntervalTime", tsMinIntervalTime, 1, 1000000, CFG_SCOPE_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000,
|
||||
CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
@ -465,6 +475,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 1000000);
|
||||
if (cfgAddInt32(pCfg, "timeToGetAvailableConn", tsNumOfRpcSessions, 20, 1000000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
|
||||
tsKeepAliveIdle = TRANGE(tsKeepAliveIdle, 1, 72000);
|
||||
if (cfgAddInt32(pCfg, "keepAliveIdle", tsKeepAliveIdle, 1, 7200000, CFG_SCOPE_BOTH) != 0) return -1;
|
||||
|
||||
tsNumOfCommitThreads = tsNumOfCores / 2;
|
||||
tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
@ -477,7 +490,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
||||
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 100, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddFloat(pCfg, "ratioOfVnodeStreamThreads", tsRatioOfVnodeStreamThreads, 0.01, 100, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
tsNumOfVnodeFetchThreads = tsNumOfCores / 4;
|
||||
tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4);
|
||||
|
@ -497,7 +511,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
|
||||
tsNumOfSnodeStreamThreads = tsNumOfCores / 4;
|
||||
tsNumOfSnodeStreamThreads = TRANGE(tsNumOfSnodeStreamThreads, 2, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
tsNumOfSnodeWriteThreads = tsNumOfCores / 4;
|
||||
tsNumOfSnodeWriteThreads = TRANGE(tsNumOfSnodeWriteThreads, 2, 4);
|
||||
|
@ -505,14 +520,18 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
|
||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_BOTH) != 0)
|
||||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX,
|
||||
CFG_SCOPE_BOTH) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt64(pCfg, "vndCommitMaxInterval", tsVndCommitMaxIntervalMs, 1000, 1000 * 60 * 60, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt64(pCfg, "vndCommitMaxInterval", tsVndCommitMaxIntervalMs, 1000, 1000 * 60 * 60, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt64(pCfg, "mndSdbWriteDelta", tsMndSdbWriteDelta, 20, 10000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt64(pCfg, "mndLogRetention", tsMndLogRetention, 500, 10000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
@ -542,7 +561,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
||||
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX, CFG_SCOPE_SERVER) != 0)
|
||||
if (cfgAddInt64(pCfg, "walFsyncDataSizeLimit", tsWalFsyncDataSizeLimit, 100 * 1024 * 1024, INT64_MAX,
|
||||
CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "udf", tsStartUdfd, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
@ -553,7 +573,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt64(pCfg, "streamBufferSize", tsStreamBufferSize, 0, INT64_MAX, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt64(pCfg, "checkpointInterval", tsCheckpointInterval, 0, INT64_MAX, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, CFG_SCOPE_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "filterScalarMode", tsFilterScalarMode, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "keepTimeOffset", tsKeepTimeOffset, 0, 23, CFG_SCOPE_SERVER) != 0) return -1;
|
||||
|
@ -608,6 +629,13 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
pItem = cfgGetItem(tsCfg, "keepAliveIdle");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsKeepAliveIdle = TRANGE(tsKeepAliveIdle, 1, 720000);
|
||||
pItem->i32 = tsKeepAliveIdle;
|
||||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
pItem = cfgGetItem(tsCfg, "numOfCommitThreads");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsNumOfCommitThreads = numOfCores / 2;
|
||||
|
@ -839,6 +867,8 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
||||
|
||||
tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32;
|
||||
|
||||
tsKeepAliveIdle = cfgGetItem(pCfg, "keepAliveIdle")->i32;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -878,6 +908,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32;
|
||||
tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32;
|
||||
|
||||
tsKeepAliveIdle = cfgGetItem(pCfg, "keepAliveIdle")->i32;
|
||||
|
||||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
|
||||
|
@ -908,7 +940,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
||||
|
||||
tmqMaxTopicNum= cfgGetItem(pCfg, "tmqMaxTopicNum")->i32;
|
||||
tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32;
|
||||
|
||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||
|
@ -1020,7 +1052,7 @@ int32_t taosApplyLocalCfg(SConfig *pCfg, char *name) {
|
|||
taosSetCoreDump(enableCore);
|
||||
} else if (strcasecmp("enableQueryHb", name) == 0) {
|
||||
tsEnableQueryHb = cfgGetItem(pCfg, "enableQueryHb")->bval;
|
||||
} else if (strcasecmp("ttlChangeOnWrite", name) == 0) {
|
||||
} else if (strcasecmp("ttlChangeOnWrite", name) == 0) {
|
||||
tsTtlChangeOnWrite = cfgGetItem(pCfg, "ttlChangeOnWrite")->bval;
|
||||
}
|
||||
break;
|
||||
|
@ -1249,9 +1281,9 @@ int32_t taosApplyLocalCfg(SConfig *pCfg, char *name) {
|
|||
// tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
|
||||
// } else if (strcasecmp("smlBatchSize", name) == 0) {
|
||||
// tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
|
||||
} else if(strcasecmp("smlTsDefaultName", name) == 0) {
|
||||
} else if (strcasecmp("smlTsDefaultName", name) == 0) {
|
||||
tstrncpy(tsSmlTsDefaultName, cfgGetItem(pCfg, "smlTsDefaultName")->str, TSDB_COL_NAME_LEN);
|
||||
} else if(strcasecmp("smlDot2Underline", name) == 0) {
|
||||
} else if (strcasecmp("smlDot2Underline", name) == 0) {
|
||||
tsSmlDot2Underline = cfgGetItem(pCfg, "smlDot2Underline")->bval;
|
||||
} else if (strcasecmp("shellActivityTimer", name) == 0) {
|
||||
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||
|
|
|
@ -460,7 +460,6 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
|
|||
vmCloseVnodes(pMgmt);
|
||||
vmStopWorker(pMgmt);
|
||||
vnodeCleanup();
|
||||
tfsClose(pMgmt->pTfs);
|
||||
taosThreadRwlockDestroy(&pMgmt->lock);
|
||||
taosMemoryFree(pMgmt);
|
||||
}
|
||||
|
@ -535,20 +534,9 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
|||
pMgmt->msgCb.mgmt = pMgmt;
|
||||
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
||||
|
||||
SDiskCfg dCfg = {0};
|
||||
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
||||
dCfg.level = 0;
|
||||
dCfg.primary = 1;
|
||||
SDiskCfg *pDisks = tsDiskCfg;
|
||||
int32_t numOfDisks = tsDiskCfgNum;
|
||||
if (numOfDisks <= 0 || pDisks == NULL) {
|
||||
pDisks = &dCfg;
|
||||
numOfDisks = 1;
|
||||
}
|
||||
|
||||
pMgmt->pTfs = tfsOpen(pDisks, numOfDisks);
|
||||
pMgmt->pTfs = pInput->pTfs;
|
||||
if (pMgmt->pTfs == NULL) {
|
||||
dError("failed to init tfs since %s", terrstr());
|
||||
dError("tfs is null.");
|
||||
goto _OVER;
|
||||
}
|
||||
tmsgReportStartup("vnode-tfs", "initialized");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "vmInt.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
static inline void vmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||
if (pMsg->info.handle == NULL) return;
|
||||
|
@ -159,6 +160,15 @@ static void vmSendResponse(SRpcMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool vmDataSpaceSufficient(SVnodeObj *pVnode) {
|
||||
STfs *pTfs = pVnode->pImpl->pTfs;
|
||||
if (pTfs) {
|
||||
return tfsDiskSpaceSufficient(pTfs, 0, pVnode->diskPrimary);
|
||||
} else {
|
||||
return osDataSpaceSufficient();
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
if (pMsg->contLen < sizeof(SMsgHead)) {
|
||||
|
@ -204,7 +214,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||
break;
|
||||
case WRITE_QUEUE:
|
||||
if (!osDataSpaceSufficient()) {
|
||||
if (!vmDataSpaceSufficient(pVnode)) {
|
||||
terrno = TSDB_CODE_NO_ENOUGH_DISKSPACE;
|
||||
code = terrno;
|
||||
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "uv.h"
|
||||
|
||||
#include "dmInt.h"
|
||||
#include "tfs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -79,6 +80,7 @@ typedef struct SDnode {
|
|||
TdThreadMutex mutex;
|
||||
TdFilePtr lockfile;
|
||||
SDnodeData data;
|
||||
STfs *pTfs;
|
||||
SMgmtWrapper wrappers[NODE_END];
|
||||
} SDnode;
|
||||
|
||||
|
@ -124,4 +126,4 @@ void dmGetQnodeLoads(SQnodeLoad *pInfo);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_DND_MGMT_H_*/
|
||||
#endif /*_TD_DND_MGMT_H_*/
|
||||
|
|
|
@ -96,28 +96,23 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static bool dmCheckDiskSpace() {
|
||||
osUpdate();
|
||||
// sufficiency
|
||||
if (!osDataSpaceSufficient()) {
|
||||
dWarn("free data disk size: %f GB, not sufficient, expected %f GB at least",
|
||||
(double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
static bool dmDataSpaceAvailable() {
|
||||
SDnode *pDnode = dmInstance();
|
||||
if (pDnode->pTfs) {
|
||||
return tfsDiskSpaceAvailable(pDnode->pTfs, 0);
|
||||
}
|
||||
if (!osLogSpaceSufficient()) {
|
||||
dWarn("free log disk size: %f GB, not sufficient, expected %f GB at least",
|
||||
(double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
if (!osTempSpaceSufficient()) {
|
||||
dWarn("free temp disk size: %f GB, not sufficient, expected %f GB at least",
|
||||
(double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
|
||||
(double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
// availability
|
||||
bool ret = true;
|
||||
if (!osDataSpaceAvailable()) {
|
||||
dError("data disk space unavailable, i.e. %s", tsDataDir);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dmCheckDiskSpace() {
|
||||
osUpdate();
|
||||
// availability
|
||||
bool ret = true;
|
||||
if (!dmDataSpaceAvailable()) {
|
||||
terrno = TSDB_CODE_NO_DISKSPACE;
|
||||
ret = false;
|
||||
}
|
||||
|
@ -134,6 +129,34 @@ static bool dmCheckDiskSpace() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int32_t dmDiskInit() {
|
||||
SDnode *pDnode = dmInstance();
|
||||
SDiskCfg dCfg = {0};
|
||||
tstrncpy(dCfg.dir, tsDataDir, TSDB_FILENAME_LEN);
|
||||
dCfg.level = 0;
|
||||
dCfg.primary = 1;
|
||||
SDiskCfg *pDisks = tsDiskCfg;
|
||||
int32_t numOfDisks = tsDiskCfgNum;
|
||||
if (numOfDisks <= 0 || pDisks == NULL) {
|
||||
pDisks = &dCfg;
|
||||
numOfDisks = 1;
|
||||
}
|
||||
|
||||
pDnode->pTfs = tfsOpen(pDisks, numOfDisks);
|
||||
if (pDnode->pTfs == NULL) {
|
||||
dError("failed to init tfs since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t dmDiskClose() {
|
||||
SDnode *pDnode = dmInstance();
|
||||
tfsClose(pDnode->pTfs);
|
||||
pDnode->pTfs = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool dmCheckDataDirVersion() {
|
||||
char checkDataDirJsonFileName[PATH_MAX] = {0};
|
||||
snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir);
|
||||
|
@ -147,6 +170,7 @@ static bool dmCheckDataDirVersion() {
|
|||
|
||||
int32_t dmInit() {
|
||||
dInfo("start to init dnode env");
|
||||
if (dmDiskInit() != 0) return -1;
|
||||
if (!dmCheckDataDirVersion()) return -1;
|
||||
if (!dmCheckDiskSpace()) return -1;
|
||||
if (dmCheckRepeatInit(dmInstance()) != 0) return -1;
|
||||
|
@ -177,6 +201,7 @@ void dmCleanup() {
|
|||
udfcClose();
|
||||
udfStopUdfd();
|
||||
taosStopCacheRefreshWorker();
|
||||
dmDiskClose();
|
||||
dInfo("dnode env is cleaned up");
|
||||
|
||||
taosCleanupCfg();
|
||||
|
@ -367,6 +392,7 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) {
|
|||
SMgmtInputOpt opt = {
|
||||
.path = pWrapper->path,
|
||||
.name = pWrapper->name,
|
||||
.pTfs = pWrapper->pDnode->pTfs,
|
||||
.pData = &pWrapper->pDnode->data,
|
||||
.processCreateNodeFp = dmProcessCreateNodeReq,
|
||||
.processAlterNodeTypeFp = dmProcessAlterNodeTypeReq,
|
||||
|
|
|
@ -299,7 +299,7 @@ int32_t dmInitClient(SDnode *pDnode) {
|
|||
rpcInit.retryMinInterval = tsRedirectPeriod;
|
||||
rpcInit.retryStepFactor = tsRedirectFactor;
|
||||
rpcInit.retryMaxInterval = tsRedirectMaxPeriod;
|
||||
rpcInit.retryMaxTimouet = tsMaxRetryWaitTime;
|
||||
rpcInit.retryMaxTimeout = tsMaxRetryWaitTime;
|
||||
|
||||
rpcInit.failFastInterval = 5000; // interval threshold(ms)
|
||||
rpcInit.failFastThreshold = 3; // failed threshold
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "monitor.h"
|
||||
#include "qnode.h"
|
||||
#include "sync.h"
|
||||
#include "tfs.h"
|
||||
#include "wal.h"
|
||||
|
||||
#include "libs/function/tudf.h"
|
||||
|
@ -111,6 +112,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
const char *path;
|
||||
const char *name;
|
||||
STfs *pTfs;
|
||||
SDnodeData *pData;
|
||||
SMsgCb msgCb;
|
||||
ProcessCreateNodeFp processCreateNodeFp;
|
||||
|
|
|
@ -70,6 +70,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
|
|||
if (tEncodeI32(pEncoder, innerSz) < 0) return -1;
|
||||
for (int32_t j = 0; j < innerSz; j++) {
|
||||
SStreamTask *pTask = taosArrayGetP(pArray, j);
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
if (tEncodeStreamTask(pEncoder, pTask) < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void* freeStreamTasks(SArray* pTaskLevel) {
|
||||
static void *freeStreamTasks(SArray *pTaskLevel) {
|
||||
int32_t numOfLevel = taosArrayGetSize(pTaskLevel);
|
||||
for (int32_t i = 0; i < numOfLevel; i++) {
|
||||
SArray *pLevel = taosArrayGetP(pTaskLevel, i);
|
||||
|
@ -192,14 +193,14 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
|
|||
SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
if (pVgEpNew == NULL) return NULL;
|
||||
pVgEpNew->vgId = pVgEp->vgId;
|
||||
// pVgEpNew->qmsg = taosStrdup(pVgEp->qmsg);
|
||||
// pVgEpNew->qmsg = taosStrdup(pVgEp->qmsg);
|
||||
pVgEpNew->epSet = pVgEp->epSet;
|
||||
return pVgEpNew;
|
||||
}
|
||||
|
||||
void tDeleteSMqVgEp(SMqVgEp *pVgEp) {
|
||||
if (pVgEp) {
|
||||
// taosMemoryFreeClear(pVgEp->qmsg);
|
||||
// taosMemoryFreeClear(pVgEp->qmsg);
|
||||
taosMemoryFree(pVgEp);
|
||||
}
|
||||
}
|
||||
|
@ -207,14 +208,14 @@ void tDeleteSMqVgEp(SMqVgEp *pVgEp) {
|
|||
int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
|
||||
// tlen += taosEncodeString(buf, pVgEp->qmsg);
|
||||
// tlen += taosEncodeString(buf, pVgEp->qmsg);
|
||||
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
|
||||
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
|
||||
if(sver == 1){
|
||||
if (sver == 1) {
|
||||
uint64_t size = 0;
|
||||
buf = taosDecodeVariantU64(buf, &size);
|
||||
buf = POINTER_SHIFT(buf, size);
|
||||
|
@ -223,7 +224,7 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
|
|||
return (void *)buf;
|
||||
}
|
||||
|
||||
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char* cgroup) {
|
||||
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) {
|
||||
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
|
||||
if (pConsumer == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -260,12 +261,12 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char* cgroup) {
|
|||
}
|
||||
|
||||
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer, bool delete) {
|
||||
if(pConsumer == NULL) return;
|
||||
if (pConsumer == NULL) return;
|
||||
taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree);
|
||||
taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree);
|
||||
if(delete){
|
||||
if (delete) {
|
||||
taosMemoryFree(pConsumer);
|
||||
}
|
||||
}
|
||||
|
@ -392,7 +393,7 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
taosArrayPush(pConsumer->assignedTopics, &topic);
|
||||
}
|
||||
|
||||
if(sver > 1){
|
||||
if (sver > 1) {
|
||||
buf = taosDecodeFixedI8(buf, &pConsumer->withTbName);
|
||||
buf = taosDecodeFixedI8(buf, &pConsumer->autoCommit);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumer->autoCommitInterval);
|
||||
|
@ -401,18 +402,18 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
return (void *)buf;
|
||||
}
|
||||
|
||||
//SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) {
|
||||
// SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp));
|
||||
// if (pConsumerEpNew == NULL) return NULL;
|
||||
// pConsumerEpNew->consumerId = pConsumerEpOld->consumerId;
|
||||
// pConsumerEpNew->vgs = taosArrayDup(pConsumerEpOld->vgs, NULL);
|
||||
// return pConsumerEpNew;
|
||||
//}
|
||||
// SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) {
|
||||
// SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp));
|
||||
// if (pConsumerEpNew == NULL) return NULL;
|
||||
// pConsumerEpNew->consumerId = pConsumerEpOld->consumerId;
|
||||
// pConsumerEpNew->vgs = taosArrayDup(pConsumerEpOld->vgs, NULL);
|
||||
// return pConsumerEpNew;
|
||||
// }
|
||||
//
|
||||
//void tDeleteSMqConsumerEp(void *data) {
|
||||
// SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)data;
|
||||
// taosArrayDestroy(pConsumerEp->vgs);
|
||||
//}
|
||||
// void tDeleteSMqConsumerEp(void *data) {
|
||||
// SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)data;
|
||||
// taosArrayDestroy(pConsumerEp->vgs);
|
||||
// }
|
||||
|
||||
int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
|
||||
int32_t tlen = 0;
|
||||
|
@ -420,7 +421,7 @@ int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
|
|||
tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp);
|
||||
int32_t szVgs = taosArrayGetSize(pConsumerEp->offsetRows);
|
||||
tlen += taosEncodeFixedI32(buf, szVgs);
|
||||
for (int32_t j= 0; j < szVgs; ++j) {
|
||||
for (int32_t j = 0; j < szVgs; ++j) {
|
||||
OffsetRows *offRows = taosArrayGet(pConsumerEp->offsetRows, j);
|
||||
tlen += taosEncodeFixedI32(buf, offRows->vgId);
|
||||
tlen += taosEncodeFixedI64(buf, offRows->rows);
|
||||
|
@ -434,28 +435,28 @@ int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
|
|||
// do nothing
|
||||
}
|
||||
}
|
||||
//#if 0
|
||||
// int32_t sz = taosArrayGetSize(pConsumerEp->vgs);
|
||||
// tlen += taosEncodeFixedI32(buf, sz);
|
||||
// for (int32_t i = 0; i < sz; i++) {
|
||||
// SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i);
|
||||
// tlen += tEncodeSMqVgEp(buf, pVgEp);
|
||||
// }
|
||||
//#endif
|
||||
// #if 0
|
||||
// int32_t sz = taosArrayGetSize(pConsumerEp->vgs);
|
||||
// tlen += taosEncodeFixedI32(buf, sz);
|
||||
// for (int32_t i = 0; i < sz; i++) {
|
||||
// SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i);
|
||||
// tlen += tEncodeSMqVgEp(buf, pVgEp);
|
||||
// }
|
||||
// #endif
|
||||
return tlen;
|
||||
}
|
||||
|
||||
void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t sver) {
|
||||
buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
|
||||
buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver);
|
||||
if (sver > 1){
|
||||
if (sver > 1) {
|
||||
int32_t szVgs = 0;
|
||||
buf = taosDecodeFixedI32(buf, &szVgs);
|
||||
if(szVgs > 0){
|
||||
if (szVgs > 0) {
|
||||
pConsumerEp->offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows));
|
||||
if (NULL == pConsumerEp->offsetRows) return NULL;
|
||||
for (int32_t j= 0; j < szVgs; ++j) {
|
||||
OffsetRows* offRows = taosArrayReserve(pConsumerEp->offsetRows, 1);
|
||||
for (int32_t j = 0; j < szVgs; ++j) {
|
||||
OffsetRows *offRows = taosArrayReserve(pConsumerEp->offsetRows, 1);
|
||||
buf = taosDecodeFixedI32(buf, &offRows->vgId);
|
||||
buf = taosDecodeFixedI64(buf, &offRows->rows);
|
||||
buf = taosDecodeFixedI8(buf, &offRows->offset.type);
|
||||
|
@ -470,21 +471,21 @@ void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t s
|
|||
}
|
||||
}
|
||||
}
|
||||
//#if 0
|
||||
// int32_t sz;
|
||||
// buf = taosDecodeFixedI32(buf, &sz);
|
||||
// pConsumerEp->vgs = taosArrayInit(sz, sizeof(void *));
|
||||
// for (int32_t i = 0; i < sz; i++) {
|
||||
// SMqVgEp *pVgEp = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
// buf = tDecodeSMqVgEp(buf, pVgEp);
|
||||
// taosArrayPush(pConsumerEp->vgs, &pVgEp);
|
||||
// }
|
||||
//#endif
|
||||
// #if 0
|
||||
// int32_t sz;
|
||||
// buf = taosDecodeFixedI32(buf, &sz);
|
||||
// pConsumerEp->vgs = taosArrayInit(sz, sizeof(void *));
|
||||
// for (int32_t i = 0; i < sz; i++) {
|
||||
// SMqVgEp *pVgEp = taosMemoryMalloc(sizeof(SMqVgEp));
|
||||
// buf = tDecodeSMqVgEp(buf, pVgEp);
|
||||
// taosArrayPush(pConsumerEp->vgs, &pVgEp);
|
||||
// }
|
||||
// #endif
|
||||
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
SMqSubscribeObj *tNewSubscribeObj(const char* key) {
|
||||
SMqSubscribeObj *tNewSubscribeObj(const char *key) {
|
||||
SMqSubscribeObj *pSubObj = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
|
||||
if (pSubObj == NULL) {
|
||||
return NULL;
|
||||
|
@ -577,7 +578,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
|||
|
||||
int32_t szVgs = taosArrayGetSize(pSub->offsetRows);
|
||||
tlen += taosEncodeFixedI32(buf, szVgs);
|
||||
for (int32_t j= 0; j < szVgs; ++j) {
|
||||
for (int32_t j = 0; j < szVgs; ++j) {
|
||||
OffsetRows *offRows = taosArrayGet(pSub->offsetRows, j);
|
||||
tlen += taosEncodeFixedI32(buf, offRows->vgId);
|
||||
tlen += taosEncodeFixedI64(buf, offRows->rows);
|
||||
|
@ -617,14 +618,14 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
|
|||
buf = taosDecodeArray(buf, &pSub->unassignedVgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver);
|
||||
buf = taosDecodeStringTo(buf, pSub->dbName);
|
||||
|
||||
if (sver > 1){
|
||||
if (sver > 1) {
|
||||
int32_t szVgs = 0;
|
||||
buf = taosDecodeFixedI32(buf, &szVgs);
|
||||
if(szVgs > 0){
|
||||
if (szVgs > 0) {
|
||||
pSub->offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows));
|
||||
if (NULL == pSub->offsetRows) return NULL;
|
||||
for (int32_t j= 0; j < szVgs; ++j) {
|
||||
OffsetRows* offRows = taosArrayReserve(pSub->offsetRows, 1);
|
||||
for (int32_t j = 0; j < szVgs; ++j) {
|
||||
OffsetRows *offRows = taosArrayReserve(pSub->offsetRows, 1);
|
||||
buf = taosDecodeFixedI32(buf, &offRows->vgId);
|
||||
buf = taosDecodeFixedI64(buf, &offRows->rows);
|
||||
buf = taosDecodeFixedI8(buf, &offRows->offset.type);
|
||||
|
@ -639,71 +640,71 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
|
|||
}
|
||||
}
|
||||
buf = taosDecodeString(buf, &pSub->qmsg);
|
||||
}else{
|
||||
} else {
|
||||
pSub->qmsg = taosStrdup("");
|
||||
}
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
//SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
||||
// SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
|
||||
// if (pEntryNew == NULL) return NULL;
|
||||
// pEntryNew->epoch = pEntry->epoch;
|
||||
// pEntryNew->consumers = taosArrayDup(pEntry->consumers, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
// return pEntryNew;
|
||||
//}
|
||||
// SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
||||
// SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
|
||||
// if (pEntryNew == NULL) return NULL;
|
||||
// pEntryNew->epoch = pEntry->epoch;
|
||||
// pEntryNew->consumers = taosArrayDup(pEntry->consumers, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
// return pEntryNew;
|
||||
// }
|
||||
//
|
||||
//void tDeleteSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
||||
// taosArrayDestroyEx(pEntry->consumers, (FDelete)tDeleteSMqConsumerEp);
|
||||
//}
|
||||
// void tDeleteSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
||||
// taosArrayDestroyEx(pEntry->consumers, (FDelete)tDeleteSMqConsumerEp);
|
||||
// }
|
||||
|
||||
//int32_t tEncodeSMqSubActionLogEntry(void **buf, const SMqSubActionLogEntry *pEntry) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeFixedI32(buf, pEntry->epoch);
|
||||
// tlen += taosEncodeArray(buf, pEntry->consumers, (FEncode)tEncodeSMqSubActionLogEntry);
|
||||
// return tlen;
|
||||
//}
|
||||
// int32_t tEncodeSMqSubActionLogEntry(void **buf, const SMqSubActionLogEntry *pEntry) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeFixedI32(buf, pEntry->epoch);
|
||||
// tlen += taosEncodeArray(buf, pEntry->consumers, (FEncode)tEncodeSMqSubActionLogEntry);
|
||||
// return tlen;
|
||||
// }
|
||||
//
|
||||
//void *tDecodeSMqSubActionLogEntry(const void *buf, SMqSubActionLogEntry *pEntry) {
|
||||
// buf = taosDecodeFixedI32(buf, &pEntry->epoch);
|
||||
// buf = taosDecodeArray(buf, &pEntry->consumers, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
|
||||
// return (void *)buf;
|
||||
//}
|
||||
// void *tDecodeSMqSubActionLogEntry(const void *buf, SMqSubActionLogEntry *pEntry) {
|
||||
// buf = taosDecodeFixedI32(buf, &pEntry->epoch);
|
||||
// buf = taosDecodeArray(buf, &pEntry->consumers, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
|
||||
// return (void *)buf;
|
||||
// }
|
||||
|
||||
//SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
||||
// SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
|
||||
// if (pLogNew == NULL) return pLogNew;
|
||||
// memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
// pLogNew->logs = taosArrayDup(pLog->logs, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
// return pLogNew;
|
||||
//}
|
||||
// SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
||||
// SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
|
||||
// if (pLogNew == NULL) return pLogNew;
|
||||
// memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||
// pLogNew->logs = taosArrayDup(pLog->logs, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||
// return pLogNew;
|
||||
// }
|
||||
//
|
||||
//void tDeleteSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
||||
// taosArrayDestroyEx(pLog->logs, (FDelete)tDeleteSMqConsumerEp);
|
||||
//}
|
||||
// void tDeleteSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
||||
// taosArrayDestroyEx(pLog->logs, (FDelete)tDeleteSMqConsumerEp);
|
||||
// }
|
||||
|
||||
//int32_t tEncodeSMqSubActionLogObj(void **buf, const SMqSubActionLogObj *pLog) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeString(buf, pLog->key);
|
||||
// tlen += taosEncodeArray(buf, pLog->logs, (FEncode)tEncodeSMqSubActionLogEntry);
|
||||
// return tlen;
|
||||
//}
|
||||
// int32_t tEncodeSMqSubActionLogObj(void **buf, const SMqSubActionLogObj *pLog) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeString(buf, pLog->key);
|
||||
// tlen += taosEncodeArray(buf, pLog->logs, (FEncode)tEncodeSMqSubActionLogEntry);
|
||||
// return tlen;
|
||||
// }
|
||||
//
|
||||
//void *tDecodeSMqSubActionLogObj(const void *buf, SMqSubActionLogObj *pLog) {
|
||||
// buf = taosDecodeStringTo(buf, pLog->key);
|
||||
// buf = taosDecodeArray(buf, &pLog->logs, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
|
||||
// return (void *)buf;
|
||||
//}
|
||||
// void *tDecodeSMqSubActionLogObj(const void *buf, SMqSubActionLogObj *pLog) {
|
||||
// buf = taosDecodeStringTo(buf, pLog->key);
|
||||
// buf = taosDecodeArray(buf, &pLog->logs, (FDecode)tDecodeSMqSubActionLogEntry, sizeof(SMqSubActionLogEntry));
|
||||
// return (void *)buf;
|
||||
// }
|
||||
//
|
||||
//int32_t tEncodeSMqOffsetObj(void **buf, const SMqOffsetObj *pOffset) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeString(buf, pOffset->key);
|
||||
// tlen += taosEncodeFixedI64(buf, pOffset->offset);
|
||||
// return tlen;
|
||||
//}
|
||||
// int32_t tEncodeSMqOffsetObj(void **buf, const SMqOffsetObj *pOffset) {
|
||||
// int32_t tlen = 0;
|
||||
// tlen += taosEncodeString(buf, pOffset->key);
|
||||
// tlen += taosEncodeFixedI64(buf, pOffset->offset);
|
||||
// return tlen;
|
||||
// }
|
||||
//
|
||||
//void *tDecodeSMqOffsetObj(void *buf, SMqOffsetObj *pOffset) {
|
||||
// buf = taosDecodeStringTo(buf, pOffset->key);
|
||||
// buf = taosDecodeFixedI64(buf, &pOffset->offset);
|
||||
// return buf;
|
||||
//}
|
||||
// void *tDecodeSMqOffsetObj(void *buf, SMqOffsetObj *pOffset) {
|
||||
// buf = taosDecodeStringTo(buf, pOffset->key);
|
||||
// buf = taosDecodeFixedI64(buf, &pOffset->offset);
|
||||
// return buf;
|
||||
// }
|
||||
|
|
|
@ -515,7 +515,6 @@ int32_t mndRetrieveTagIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, i
|
|||
if (pDb == NULL) return 0;
|
||||
}
|
||||
SSmaAndTagIter *pIter = pShow->pIter;
|
||||
int invalid = -1;
|
||||
while (numOfRows < rows) {
|
||||
pIter->pIdxIter = sdbFetch(pSdb, SDB_IDX, pIter->pIdxIter, (void **)&pIdx);
|
||||
if (pIter->pIdxIter == NULL) break;
|
||||
|
@ -552,7 +551,7 @@ int32_t mndRetrieveTagIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, i
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&invalid, false);
|
||||
colDataSetVal(pColInfo, numOfRows, NULL, true);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pIdx->createdTime, false);
|
||||
|
|
|
@ -232,7 +232,8 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SArray* pTaskList, SStrea
|
|||
|
||||
int32_t mndAddSinkTaskToStream(SStreamObj* pStream, SArray* pTaskList, SMnode* pMnode, int32_t vgId, SVgObj* pVgroup,
|
||||
int32_t fillHistory) {
|
||||
SStreamTask* pTask = tNewStreamTask(pStream->uid, TASK_LEVEL__SINK, fillHistory, 0, pTaskList);
|
||||
int64_t uid = (fillHistory == 0)? pStream->uid:pStream->hTaskUid;
|
||||
SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SINK, fillHistory, 0, pTaskList);
|
||||
if (pTask == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
|
@ -335,8 +336,8 @@ static void setHTasksId(SArray* pTaskList, const SArray* pHTaskList) {
|
|||
(*pHTask)->streamTaskId.taskId = (*pStreamTask)->id.taskId;
|
||||
(*pHTask)->streamTaskId.streamId = (*pStreamTask)->id.streamId;
|
||||
|
||||
mDebug("s-task:0x%x related history task:0x%x, level:%d", (*pStreamTask)->id.taskId, (*pHTask)->id.taskId,
|
||||
(*pHTask)->info.taskLevel);
|
||||
mDebug("s-task:0x%" PRIx64 "-0x%x related history task:0x%" PRIx64 "-0x%x, level:%d", (*pStreamTask)->id.streamId,
|
||||
(*pStreamTask)->id.taskId, (*pHTask)->id.streamId, (*pHTask)->id.taskId, (*pHTask)->info.taskLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "parser.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define MND_STREAM_VER_NUMBER 2
|
||||
#define MND_STREAM_VER_NUMBER 3
|
||||
#define MND_STREAM_RESERVE_SIZE 64
|
||||
|
||||
#define MND_STREAM_MAX_NUM 60
|
||||
|
@ -140,10 +140,12 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) {
|
|||
void *buf = NULL;
|
||||
|
||||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto STREAM_DECODE_OVER;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) {
|
||||
goto STREAM_DECODE_OVER;
|
||||
}
|
||||
|
||||
if (sver != 1 && sver != 2) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
if (sver != MND_STREAM_VER_NUMBER) {
|
||||
terrno = 0;
|
||||
goto STREAM_DECODE_OVER;
|
||||
}
|
||||
|
||||
|
@ -198,12 +200,13 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream) {
|
|||
|
||||
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream) {
|
||||
mTrace("stream:%s, perform update action", pOldStream->name);
|
||||
atomic_exchange_64(&pOldStream->updateTime, pNewStream->updateTime);
|
||||
|
||||
atomic_exchange_32(&pOldStream->version, pNewStream->version);
|
||||
|
||||
taosWLockLatch(&pOldStream->lock);
|
||||
|
||||
pOldStream->status = pNewStream->status;
|
||||
pOldStream->updateTime = pNewStream->updateTime;
|
||||
|
||||
taosWUnLockLatch(&pOldStream->lock);
|
||||
return 0;
|
||||
|
@ -429,9 +432,11 @@ FAIL:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndPersistTaskDeployReq(STrans *pTrans, const SStreamTask *pTask) {
|
||||
int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) {
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, NULL, 0);
|
||||
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
tEncodeStreamTask(&encoder, pTask);
|
||||
|
||||
int32_t size = encoder.pos;
|
||||
|
@ -520,7 +525,6 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr
|
|||
SSdbRaw *pCommitRaw = mndStreamActionEncode(pStream);
|
||||
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -537,7 +541,6 @@ static int32_t mndSetStreamRecover(SMnode *pMnode, STrans *pTrans, const SStream
|
|||
if (pCommitRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("stream trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
@ -646,6 +649,8 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
|
|||
|
||||
pReq->head.vgId = htonl(pTask->info.nodeId);
|
||||
pReq->taskId = pTask->id.taskId;
|
||||
pReq->streamId = pTask->id.streamId;
|
||||
|
||||
STransAction action = {0};
|
||||
memcpy(&action.epSet, &pTask->info.epSet, sizeof(SEpSet));
|
||||
action.pCont = pReq;
|
||||
|
@ -1264,7 +1269,7 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
// task id
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
char idstr[128] = {0};
|
||||
char idstr[128] = {0};
|
||||
int32_t len = tintToHex(pTask->id.taskId, &idstr[4]);
|
||||
idstr[2] = '0';
|
||||
idstr[3] = 'x';
|
||||
|
@ -1304,7 +1309,7 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
colDataSetVal(pColInfo, numOfRows, (const char *)&level, false);
|
||||
|
||||
// status
|
||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||
char status[20 + VARSTR_HEADER_SIZE] = {0};
|
||||
int8_t taskStatus = atomic_load_8(&pTask->status.taskStatus);
|
||||
if (taskStatus == TASK_STATUS__NORMAL) {
|
||||
memcpy(varDataVal(status), "normal", 6);
|
||||
|
@ -1358,6 +1363,8 @@ static int32_t mndPauseStreamTask(STrans *pTrans, SStreamTask *pTask) {
|
|||
}
|
||||
pReq->head.vgId = htonl(pTask->info.nodeId);
|
||||
pReq->taskId = pTask->id.taskId;
|
||||
pReq->streamId = pTask->id.streamId;
|
||||
|
||||
STransAction action = {0};
|
||||
memcpy(&action.epSet, &pTask->info.epSet, sizeof(SEpSet));
|
||||
action.pCont = pReq;
|
||||
|
@ -1370,7 +1377,7 @@ static int32_t mndPauseStreamTask(STrans *pTrans, SStreamTask *pTask) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndPauseAllStreamTaskImpl(STrans *pTrans, SArray* tasks) {
|
||||
int32_t mndPauseAllStreamTaskImpl(STrans *pTrans, SArray *tasks) {
|
||||
int32_t size = taosArrayGetSize(tasks);
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
SArray *pTasks = taosArrayGetP(tasks, i);
|
||||
|
@ -1409,7 +1416,6 @@ static int32_t mndPersistStreamLog(STrans *pTrans, const SStreamObj *pStream, in
|
|||
if (pCommitRaw == NULL) return -1;
|
||||
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
|
||||
mError("stream trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
|
@ -1431,7 +1437,6 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
if (pStream == NULL) {
|
||||
if (pauseReq.igNotExists) {
|
||||
mInfo("stream:%s, not exist, if exist is set", pauseReq.name);
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return 0;
|
||||
} else {
|
||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||
|
@ -1440,6 +1445,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
if (pStream->status == STREAM_STATUS__PAUSE) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1497,6 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t mndResumeStreamTask(STrans *pTrans, SStreamTask *pTask, int8_t igUntreated) {
|
||||
SVResumeStreamTaskReq *pReq = taosMemoryCalloc(1, sizeof(SVResumeStreamTaskReq));
|
||||
if (pReq == NULL) {
|
||||
|
@ -1500,7 +1505,9 @@ static int32_t mndResumeStreamTask(STrans *pTrans, SStreamTask *pTask, int8_t ig
|
|||
}
|
||||
pReq->head.vgId = htonl(pTask->info.nodeId);
|
||||
pReq->taskId = pTask->id.taskId;
|
||||
pReq->streamId = pTask->id.streamId;
|
||||
pReq->igUntreated = igUntreated;
|
||||
|
||||
STransAction action = {0};
|
||||
memcpy(&action.epSet, &pTask->info.epSet, sizeof(SEpSet));
|
||||
action.pCont = pReq;
|
||||
|
|
|
@ -244,7 +244,7 @@ static void doRemoveLostConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, con
|
|||
|
||||
SMqRebOutputVg outputVg = {.oldConsumerId = consumerId, .newConsumerId = -1, .pVgEp = pVgEp};
|
||||
taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg));
|
||||
mInfo("sub:%s mq re-balance remove vgId:%d from consumer:%" PRIx64, pSubKey, pVgEp->vgId, consumerId);
|
||||
mInfo("sub:%s mq re-balance remove vgId:%d from consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, consumerId);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pConsumerEp->vgs);
|
||||
|
|
|
@ -799,6 +799,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
|||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ void sndEnqueueStreamDispatch(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
int32_t taskId = req.taskId;
|
||||
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.streamId, req.taskId);
|
||||
if (pTask) {
|
||||
SRpcMsg rsp = {
|
||||
.info = pMsg->info,
|
||||
|
@ -88,7 +86,7 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t ver) {
|
|||
SReadHandle handle = { .vnode = NULL, .numOfVgroups = numOfChildEp, .pStateBackend = pTask->pState, .fillHistory = pTask->info.fillHistory };
|
||||
initStreamStateAPI(&handle.api);
|
||||
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, 0);
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, 0, pTask->id.taskId);
|
||||
ASSERT(pTask->exec.pExecutor);
|
||||
|
||||
taosThreadMutexInit(&pTask->lock, NULL);
|
||||
|
@ -181,21 +179,21 @@ int32_t sndProcessTaskDropReq(SSnode *pSnode, char *msg, int32_t msgLen) {
|
|||
SVDropStreamTaskReq *pReq = (SVDropStreamTaskReq *)msg;
|
||||
qDebug("snode:%d receive msg to drop stream task:0x%x", pSnode->pMeta->vgId, pReq->taskId);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pSnode->pMeta, pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pSnode->pMeta, pReq->streamId, pReq->taskId);
|
||||
if (pTask == NULL) {
|
||||
qError("vgId:%d failed to acquire s-task:0x%x when dropping it", pSnode->pMeta->vgId, pReq->taskId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
streamMetaUnregisterTask(pSnode->pMeta, pReq->taskId);
|
||||
streamMetaUnregisterTask(pSnode->pMeta, pReq->streamId, pReq->taskId);
|
||||
streamMetaReleaseTask(pSnode->pMeta, pTask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t sndProcessTaskRunReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
SStreamTaskRunReq *pReq = pMsg->pCont;
|
||||
int32_t taskId = pReq->taskId;
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, pReq->streamId, pReq->taskId);
|
||||
if (pTask) {
|
||||
streamProcessRunReq(pTask);
|
||||
streamMetaReleaseTask(pSnode->pMeta, pTask);
|
||||
|
@ -213,9 +211,8 @@ int32_t sndProcessTaskDispatchReq(SSnode *pSnode, SRpcMsg *pMsg, bool exec) {
|
|||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t *)msgBody, msgLen);
|
||||
tDecodeStreamDispatchReq(&decoder, &req);
|
||||
int32_t taskId = req.taskId;
|
||||
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.streamId, req.taskId);
|
||||
if (pTask) {
|
||||
SRpcMsg rsp = { .info = pMsg->info, .code = 0 };
|
||||
streamProcessDispatchMsg(pTask, &req, &rsp, exec);
|
||||
|
@ -235,8 +232,7 @@ int32_t sndProcessTaskRetrieveReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
tDecoderInit(&decoder, msgBody, msgLen);
|
||||
tDecodeStreamRetrieveReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
int32_t taskId = req.dstTaskId;
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.streamId, req.dstTaskId);
|
||||
|
||||
if (pTask) {
|
||||
SRpcMsg rsp = { .info = pMsg->info, .code = 0};
|
||||
|
@ -251,8 +247,11 @@ int32_t sndProcessTaskRetrieveReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t sndProcessTaskDispatchRsp(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
SStreamDispatchRsp *pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = ntohl(pRsp->upstreamTaskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
|
||||
int32_t taskId = htonl(pRsp->upstreamTaskId);
|
||||
int64_t streamId = htobe64(pRsp->streamId);
|
||||
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, streamId, taskId);
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
||||
streamMetaReleaseTask(pSnode->pMeta, pTask);
|
||||
|
@ -260,7 +259,6 @@ int32_t sndProcessTaskDispatchRsp(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t sndProcessTaskRetrieveRsp(SSnode *pSnode, SRpcMsg *pMsg) {
|
||||
|
@ -297,7 +295,7 @@ int32_t sndProcessStreamTaskScanHistoryFinishReq(SSnode *pSnode, SRpcMsg *pMsg)
|
|||
tDecoderClear(&decoder);
|
||||
|
||||
// find task
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.downstreamTaskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.streamId, req.downstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -340,7 +338,7 @@ int32_t sndProcessStreamTaskCheckReq(SSnode *pSnode, SRpcMsg *pMsg) {
|
|||
.upstreamTaskId = req.upstreamTaskId,
|
||||
};
|
||||
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, taskId);
|
||||
SStreamTask *pTask = streamMetaAcquireTask(pSnode->pMeta, req.streamId, taskId);
|
||||
|
||||
if (pTask != NULL) {
|
||||
rsp.status = streamTaskCheckStatus(pTask);
|
||||
|
@ -400,7 +398,7 @@ int32_t sndProcessStreamTaskCheckRsp(SSnode* pSnode, SRpcMsg* pMsg) {
|
|||
qDebug("tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d",
|
||||
rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pSnode->pMeta, rsp.upstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pSnode->pMeta, rsp.streamId, rsp.upstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
qError("tq failed to locate the stream task:0x%x (vgId:%d), it may have been destroyed", rsp.upstreamTaskId,
|
||||
pSnode->pMeta->vgId);
|
||||
|
|
|
@ -127,7 +127,7 @@ void tqDestroyTqHandle(void* data);
|
|||
// tqRead
|
||||
int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset);
|
||||
int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset);
|
||||
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum, uint64_t reqId);
|
||||
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId);
|
||||
|
||||
// tqExec
|
||||
int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows);
|
||||
|
@ -175,7 +175,7 @@ int32_t extractDelDataBlock(const void* pData, int32_t len, int64_t ver, SStream
|
|||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg);
|
||||
int32_t tqDoSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, int64_t consumerId,
|
||||
int32_t type, int64_t sver, int64_t ever);
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq);
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -267,7 +267,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
SReadHandle handle = {.vnode = pVnode, .initTqReader = 1, .pStateBackend = pStreamState};
|
||||
initStorageAPI(&handle.api);
|
||||
|
||||
pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle, TD_VID(pVnode));
|
||||
pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle, TD_VID(pVnode), 0);
|
||||
if (!pRSmaInfo->taskInfo[idx]) {
|
||||
terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
|
||||
return TSDB_CODE_FAILED;
|
||||
|
|
|
@ -289,9 +289,8 @@ int32_t tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) {
|
|||
}
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, &req);
|
||||
tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||
dataRsp.blockNum = 0;
|
||||
dataRsp.rspOffset = dataRsp.reqOffset;
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.reqOffset);
|
||||
tqInfo("tqPushEmptyDataRsp to consumer:0x%"PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf, req.reqId);
|
||||
|
@ -391,7 +390,6 @@ int32_t tqProcessSeekReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
|
||||
tqDebug("tmq seek: consumer:0x%" PRIx64 " vgId:%d, subkey %s", req.consumerId, vgId, req.subKey);
|
||||
|
||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
|
||||
if (pHandle == NULL) {
|
||||
tqWarn("tmq seek: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", req.consumerId, vgId, req.subKey);
|
||||
|
@ -719,7 +717,7 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
walReaderValidVersionRange(pHandle->execHandle.pTqReader->pWalReader, &sver, &ever);
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, &req);
|
||||
tqInitDataRsp(&dataRsp, req.reqOffset);
|
||||
|
||||
if (req.useSnapshot == true) {
|
||||
tqError("consumer:0x%" PRIx64 " vgId:%d subkey:%s snapshot not support wal info", consumerId, vgId, req.subKey);
|
||||
|
@ -960,7 +958,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
|||
.winRange = pTask->dataRange.window};
|
||||
initStorageAPI(&handle.api);
|
||||
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, vgId);
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, vgId, pTask->id.taskId);
|
||||
if (pTask->exec.pExecutor == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -987,7 +985,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) {
|
|||
.winRange = pTask->dataRange.window};
|
||||
initStorageAPI(&handle.api);
|
||||
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, vgId);
|
||||
pTask->exec.pExecutor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, vgId, pTask->id.taskId);
|
||||
if (pTask->exec.pExecutor == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1066,7 +1064,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
.upstreamTaskId = req.upstreamTaskId,
|
||||
};
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, taskId);
|
||||
if (pTask != NULL) {
|
||||
rsp.status = streamTaskCheckStatus(pTask);
|
||||
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||
|
@ -1076,8 +1074,9 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
pTask->id.idStr, pStatus, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status);
|
||||
} else {
|
||||
rsp.status = 0;
|
||||
tqDebug("tq recv task check(taskId:0x%x not built yet) req(reqId:0x%" PRIx64 ") from task:0x%x (vgId:%d), rsp status %d",
|
||||
taskId, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status);
|
||||
tqDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(reqId:0x%" PRIx64
|
||||
") from task:0x%x (vgId:%d), rsp status %d",
|
||||
req.streamId, taskId, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status);
|
||||
}
|
||||
|
||||
return streamSendCheckRsp(pTq->pStreamMeta, &req, &rsp, &pMsg->info, taskId);
|
||||
|
@ -1103,7 +1102,7 @@ int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t sversion, SRpcMsg* pMsg) {
|
|||
tqDebug("tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d",
|
||||
rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, rsp.upstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, rsp.streamId, rsp.upstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("tq failed to locate the stream task:0x%x (vgId:%d), it may have been destroyed", rsp.upstreamTaskId,
|
||||
pTq->pStreamMeta->vgId);
|
||||
|
@ -1153,32 +1152,27 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t ms
|
|||
taosWLockLatch(&pStreamMeta->lock);
|
||||
code = streamMetaRegisterTask(pStreamMeta, sversion, pTask, &added);
|
||||
int32_t numOfTasks = streamMetaGetNumOfTasks(pStreamMeta);
|
||||
taosWUnLockLatch(&pStreamMeta->lock);
|
||||
|
||||
if (code < 0) {
|
||||
tqError("vgId:%d failed to add s-task:0x%x, total:%d", vgId, pTask->id.taskId, numOfTasks);
|
||||
tFreeStreamTask(pTask);
|
||||
taosWUnLockLatch(&pStreamMeta->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// not added into meta store
|
||||
if (!added) {
|
||||
if (added) {
|
||||
tqDebug("vgId:%d s-task:0x%x is deployed and add into meta, numOfTasks:%d", vgId, taskId, numOfTasks);
|
||||
SStreamTask* p = streamMetaAcquireTask(pStreamMeta, pTask->id.streamId, taskId);
|
||||
if (p != NULL) { // reset the downstreamReady flag.
|
||||
streamTaskCheckDownstreamTasks(p);
|
||||
}
|
||||
streamMetaReleaseTask(pStreamMeta, p);
|
||||
} else {
|
||||
tqWarn("vgId:%d failed to add s-task:0x%x, already exists in meta store", vgId, taskId);
|
||||
tFreeStreamTask(pTask);
|
||||
pTask = NULL;
|
||||
}
|
||||
|
||||
taosWUnLockLatch(&pStreamMeta->lock);
|
||||
|
||||
tqDebug("vgId:%d s-task:0x%x is deployed and add into meta, numOfTasks:%d", vgId, taskId, numOfTasks);
|
||||
|
||||
// 3. It's an fill history task, do nothing. wait for the main task to start it
|
||||
SStreamTask* p = streamMetaAcquireTask(pStreamMeta, taskId);
|
||||
if (p != NULL) { // reset the downstreamReady flag.
|
||||
streamTaskCheckDownstreamTasks(p);
|
||||
}
|
||||
|
||||
streamMetaReleaseTask(pStreamMeta, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1181,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SStreamMeta* pMeta = pTq->pStreamMeta;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("vgId:%d failed to acquire stream task:0x%x during stream recover, task may have been destroyed",
|
||||
pMeta->vgId, pReq->taskId);
|
||||
|
@ -1243,7 +1237,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
|
|||
bool done = false;
|
||||
|
||||
// 1. get the related stream task
|
||||
pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.taskId);
|
||||
pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.streamId, pTask->streamTaskId.taskId);
|
||||
if (pStreamTask == NULL) {
|
||||
// todo delete this task, if the related stream task is dropped
|
||||
qError("failed to find s-task:0x%x, it may have been destroyed, drop fill-history task:%s",
|
||||
|
@ -1251,7 +1245,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
tqDebug("s-task:%s fill-history task set status to be dropping", id);
|
||||
|
||||
streamMetaUnregisterTask(pMeta, pTask->id.taskId);
|
||||
streamMetaUnregisterTask(pMeta, pTask->id.streamId, pTask->id.taskId);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1281,7 +1275,6 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
|
|||
if (done) {
|
||||
pTask->tsInfo.step2Start = taosGetTimestampMs();
|
||||
streamTaskEndScanWAL(pTask);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
} else {
|
||||
STimeWindow* pWindow = &pTask->dataRange.window;
|
||||
tqDebug("s-task:%s level:%d verRange:%" PRId64 " - %" PRId64 " window:%" PRId64 "-%" PRId64
|
||||
|
@ -1307,13 +1300,11 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
|
|||
streamSetStatusNormal(pTask);
|
||||
}
|
||||
|
||||
// 4. 1) transfer the ownership of executor state, 2) update the scan data range for source task.
|
||||
// 5. resume the related stream task.
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
streamMetaReleaseTask(pMeta, pStreamTask);
|
||||
|
||||
tqStartStreamTasks(pTq);
|
||||
}
|
||||
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
streamMetaReleaseTask(pMeta, pStreamTask);
|
||||
} else {
|
||||
// todo update the chkInfo version for current task.
|
||||
// this task has an associated history stream task, so we need to scan wal from the end version of
|
||||
|
@ -1362,7 +1353,7 @@ int32_t tqProcessTaskTransferStateReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
tqDebug("vgId:%d start to process transfer state msg, from s-task:0x%x", pTq->pStreamMeta->vgId, req.downstreamTaskId);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.downstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.downstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("failed to find task:0x%x, it may have been dropped already. process transfer state failed", req.downstreamTaskId);
|
||||
return -1;
|
||||
|
@ -1398,7 +1389,7 @@ int32_t tqProcessTaskScanHistoryFinishReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tDecodeStreamScanHistoryFinishReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.downstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.downstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("vgId:%d process scan history finish msg, failed to find task:0x%x, it may be destroyed",
|
||||
pTq->pStreamMeta->vgId, req.downstreamTaskId);
|
||||
|
@ -1424,7 +1415,7 @@ int32_t tqProcessTaskScanHistoryFinishRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tDecodeCompleteHistoryDataMsg(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.upstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.upstreamTaskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("vgId:%d process scan history finish rsp, failed to find task:0x%x, it may be destroyed",
|
||||
pTq->pStreamMeta->vgId, req.upstreamTaskId);
|
||||
|
@ -1515,11 +1506,11 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->streamId, taskId);
|
||||
if (pTask != NULL) {
|
||||
// even in halt status, the data in inputQ must be processed
|
||||
int8_t st = pTask->status.taskStatus;
|
||||
if (st == TASK_STATUS__NORMAL || st == TASK_STATUS__SCAN_HISTORY/* || st == TASK_STATUS__SCAN_HISTORY_WAL*/) {
|
||||
if (st == TASK_STATUS__NORMAL || st == TASK_STATUS__SCAN_HISTORY) {
|
||||
tqDebug("vgId:%d s-task:%s start to process block from inputQ, last chk point:%" PRId64, vgId, pTask->id.idStr,
|
||||
pTask->chkInfo.version);
|
||||
streamProcessRunReq(pTask);
|
||||
|
@ -1532,8 +1523,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||
tqStartStreamTasks(pTq);
|
||||
return 0;
|
||||
} else {
|
||||
tqError("vgId:%d failed to found s-task, taskId:%d", vgId, taskId);
|
||||
} else { // NOTE: pTask->status.schedStatus is not updated since it is not be handled by the run exec.
|
||||
// todo add one function to handle this
|
||||
tqError("vgId:%d failed to found s-task, taskId:0x%x may have been dropped", vgId, taskId);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1549,7 +1541,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
|
|||
tDecoderInit(&decoder, (uint8_t*)msgBody, msgLen);
|
||||
tDecodeStreamDispatchReq(&decoder, &req);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.taskId);
|
||||
if (pTask) {
|
||||
SRpcMsg rsp = {.info = pMsg->info, .code = 0};
|
||||
streamProcessDispatchMsg(pTask, &req, &rsp, exec);
|
||||
|
@ -1563,10 +1555,12 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
|
|||
|
||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t taskId = ntohl(pRsp->upstreamTaskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||
|
||||
int32_t vgId = pTq->pStreamMeta->vgId;
|
||||
int32_t vgId = pTq->pStreamMeta->vgId;
|
||||
int32_t taskId = htonl(pRsp->upstreamTaskId);
|
||||
int64_t streamId = htobe64(pRsp->streamId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, streamId, taskId);
|
||||
|
||||
if (pTask) {
|
||||
streamProcessDispatchRsp(pTask, pRsp, pMsg->code);
|
||||
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||
|
@ -1580,13 +1574,13 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
|
|||
int32_t tqProcessTaskDropReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||
SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg;
|
||||
tqDebug("vgId:%d receive msg to drop stream task:0x%x", TD_VID(pTq->pVnode), pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->streamId, pReq->taskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("vgId:%d failed to acquire s-task:0x%x when dropping it", pTq->pStreamMeta->vgId, pReq->taskId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
streamMetaUnregisterTask(pTq->pStreamMeta, pReq->taskId);
|
||||
streamMetaUnregisterTask(pTq->pStreamMeta, pReq->streamId, pReq->taskId);
|
||||
streamMetaReleaseTask(pTq->pStreamMeta, pTask);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1595,7 +1589,7 @@ int32_t tqProcessTaskPauseReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
SVPauseStreamTaskReq* pReq = (SVPauseStreamTaskReq*)msg;
|
||||
|
||||
SStreamMeta* pMeta = pTq->pStreamMeta;
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
if (pTask == NULL) {
|
||||
tqError("vgId:%d process pause req, failed to acquire task:0x%x, it may have been dropped already", pMeta->vgId,
|
||||
pReq->taskId);
|
||||
|
@ -1608,7 +1602,7 @@ int32_t tqProcessTaskPauseReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
|
|||
|
||||
SStreamTask* pHistoryTask = NULL;
|
||||
if (pTask->historyTaskId.taskId != 0) {
|
||||
pHistoryTask = streamMetaAcquireTask(pMeta, pTask->historyTaskId.taskId);
|
||||
pHistoryTask = streamMetaAcquireTask(pMeta, pTask->historyTaskId.streamId, pTask->historyTaskId.taskId);
|
||||
if (pHistoryTask == NULL) {
|
||||
tqError("vgId:%d process pause req, failed to acquire fill-history task:0x%x, it may have been dropped already",
|
||||
pMeta->vgId, pTask->historyTaskId.taskId);
|
||||
|
@ -1667,13 +1661,13 @@ int32_t tqProcessTaskResumeImpl(STQ* pTq, SStreamTask* pTask, int64_t sversion,
|
|||
|
||||
int32_t tqProcessTaskResumeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) {
|
||||
SVResumeStreamTaskReq* pReq = (SVResumeStreamTaskReq*)msg;
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, pReq->streamId, pReq->taskId);
|
||||
int32_t code = tqProcessTaskResumeImpl(pTq, pTask, sversion, pReq->igUntreated);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SStreamTask* pHistoryTask = streamMetaAcquireTask(pTq->pStreamMeta, pTask->historyTaskId.taskId);
|
||||
SStreamTask* pHistoryTask = streamMetaAcquireTask(pTq->pStreamMeta, pTask->historyTaskId.streamId, pTask->historyTaskId.taskId);
|
||||
if (pHistoryTask) {
|
||||
code = tqProcessTaskResumeImpl(pTq, pHistoryTask, sversion, pReq->igUntreated);
|
||||
}
|
||||
|
@ -1692,8 +1686,7 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
tDecodeStreamRetrieveReq(&decoder, &req);
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
int32_t taskId = req.dstTaskId;
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.dstTaskId);
|
||||
|
||||
if (pTask) {
|
||||
SRpcMsg rsp = {.info = pMsg->info, .code = 0};
|
||||
|
@ -1731,7 +1724,7 @@ int32_t vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
|
|||
tDecoderClear(&decoder);
|
||||
|
||||
int32_t taskId = req.taskId;
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pTq->pStreamMeta, req.streamId, req.taskId);
|
||||
if (pTask != NULL) {
|
||||
SRpcMsg rsp = {.info = pMsg->info, .code = 0};
|
||||
streamProcessDispatchMsg(pTask, &req, &rsp, false);
|
||||
|
|
|
@ -356,7 +356,7 @@ static int restoreHandle(STQ* pTq, void* pVal, int vLen, STqHandle* handle){
|
|||
if(buildHandle(pTq, handle) < 0){
|
||||
return -1;
|
||||
}
|
||||
tqInfo("tq restore %s consumer %" PRId64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
||||
tqInfo("restoreHandle %s consumer 0x%" PRIx64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
||||
return taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ int32_t tqCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle){
|
|||
if(buildHandle(pTq, handle) < 0){
|
||||
return -1;
|
||||
}
|
||||
tqInfo("tq restore %s consumer %" PRId64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
||||
tqInfo("tqCreateHandle %s consumer 0x%" PRIx64 " vgId:%d", handle->subKey, handle->consumerId, vgId);
|
||||
return taosHashPut(pTq->pHandle, handle->subKey, strlen(handle->subKey), handle, sizeof(STqHandle));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t v
|
|||
int32_t numOfTasks = streamMetaGetNumOfTasks(pTq->pStreamMeta);
|
||||
taosRUnLockLatch(&pTq->pStreamMeta->lock);
|
||||
|
||||
tqDebug("handle submit, restore:%d, size:%d", pTq->pVnode->restored, numOfTasks);
|
||||
tqTrace("handle submit, restore:%d, size:%d", pTq->pVnode->restored, numOfTasks);
|
||||
|
||||
// push data for stream processing:
|
||||
// 1. the vnode has already been restored.
|
||||
|
|
|
@ -184,70 +184,63 @@ end:
|
|||
return tbSuid == realTbSuid;
|
||||
}
|
||||
|
||||
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead, uint64_t reqId) {
|
||||
int32_t code = 0;
|
||||
int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId) {
|
||||
int32_t code = -1;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
|
||||
taosThreadMutexLock(&pHandle->pWalReader->mutex);
|
||||
int64_t offset = *fetchOffset;
|
||||
int64_t lastVer = walGetLastVer(pHandle->pWalReader->pWal);
|
||||
int64_t committedVer = walGetCommittedVer(pHandle->pWalReader->pWal);
|
||||
int64_t appliedVer = walGetAppliedVer(pHandle->pWalReader->pWal);
|
||||
|
||||
while (1) {
|
||||
if (walFetchHead(pHandle->pWalReader, offset, *ppCkHead) < 0) {
|
||||
wDebug("vgId:%d, wal start to fetch, index:%" PRId64 ", last index:%" PRId64 " commit index:%" PRId64 ", applied index:%" PRId64,
|
||||
vgId, offset, lastVer, committedVer, appliedVer);
|
||||
|
||||
while (offset <= appliedVer) {
|
||||
if (walFetchHead(pHandle->pWalReader, offset) < 0) {
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", (epoch %d) vgId:%d offset %" PRId64
|
||||
", no more log to return, reqId:0x%" PRIx64,
|
||||
pHandle->consumerId, pHandle->epoch, vgId, offset, reqId);
|
||||
*fetchOffset = offset;
|
||||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
|
||||
tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, reqId:0x%" PRIx64, vgId,
|
||||
pHandle->consumerId, offset, TMSG_INFO((*ppCkHead)->head.msgType), reqId);
|
||||
pHandle->consumerId, offset, TMSG_INFO(pHandle->pWalReader->pHead->head.msgType), reqId);
|
||||
|
||||
if ((*ppCkHead)->head.msgType == TDMT_VND_SUBMIT) {
|
||||
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||
|
||||
if (code < 0) {
|
||||
*fetchOffset = offset;
|
||||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
*fetchOffset = offset;
|
||||
code = 0;
|
||||
if (pHandle->pWalReader->pHead->head.msgType == TDMT_VND_SUBMIT) {
|
||||
code = walFetchBody(pHandle->pWalReader);
|
||||
goto END;
|
||||
} else {
|
||||
if (pHandle->fetchMeta != WITH_DATA) {
|
||||
SWalCont* pHead = &((*ppCkHead)->head);
|
||||
SWalCont* pHead = &(pHandle->pWalReader->pHead->head);
|
||||
if (IS_META_MSG(pHead->msgType) && !(pHead->msgType == TDMT_VND_DELETE && pHandle->fetchMeta == ONLY_META)) {
|
||||
code = walFetchBody(pHandle->pWalReader, ppCkHead);
|
||||
code = walFetchBody(pHandle->pWalReader);
|
||||
if (code < 0) {
|
||||
*fetchOffset = offset;
|
||||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
|
||||
pHead = &(pHandle->pWalReader->pHead->head);
|
||||
if (isValValidForTable(pHandle, pHead)) {
|
||||
*fetchOffset = offset;
|
||||
code = 0;
|
||||
goto END;
|
||||
} else {
|
||||
offset++;
|
||||
code = -1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
code = walSkipFetchBody(pHandle->pWalReader, *ppCkHead);
|
||||
code = walSkipFetchBody(pHandle->pWalReader);
|
||||
if (code < 0) {
|
||||
*fetchOffset = offset;
|
||||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
code = -1;
|
||||
}
|
||||
|
||||
END:
|
||||
taosThreadMutexUnlock(&pHandle->pWalReader->mutex);
|
||||
*fetchOffset = offset;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ int32_t tqStreamTasksStatusCheck(STQ* pTq) {
|
|||
taosWUnLockLatch(&pMeta->lock);
|
||||
|
||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||
int32_t* pTaskId = taosArrayGet(pTaskList, i);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, *pTaskId);
|
||||
SStreamId* pTaskId = taosArrayGet(pTaskList, i);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId);
|
||||
if (pTask == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -242,8 +242,8 @@ int32_t createStreamTaskRunReq(SStreamMeta* pStreamMeta, bool* pScanIdle) {
|
|||
numOfTasks = taosArrayGetSize(pTaskList);
|
||||
|
||||
for (int32_t i = 0; i < numOfTasks; ++i) {
|
||||
int32_t* pTaskId = taosArrayGet(pTaskList, i);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pStreamMeta, *pTaskId);
|
||||
SStreamId* pTaskId = taosArrayGet(pTaskList, i);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pStreamMeta, pTaskId->streamId, pTaskId->taskId);
|
||||
if (pTask == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
static int32_t tqSendMetaPollRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq,
|
||||
const SMqMetaRsp* pRsp, int32_t vgId);
|
||||
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq) {
|
||||
pRsp->reqOffset = pReq->reqOffset;
|
||||
int32_t tqInitDataRsp(SMqDataRsp* pRsp, STqOffsetVal pOffset) {
|
||||
pRsp->reqOffset = pOffset;
|
||||
pRsp->rspOffset = pOffset;
|
||||
|
||||
pRsp->blockData = taosArrayInit(0, sizeof(void*));
|
||||
pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t));
|
||||
|
@ -35,8 +36,9 @@ int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) {
|
||||
pRsp->reqOffset = pReq->reqOffset;
|
||||
static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, STqOffsetVal pOffset) {
|
||||
pRsp->reqOffset = pOffset;
|
||||
pRsp->rspOffset = pOffset;
|
||||
|
||||
pRsp->withTbName = 1;
|
||||
pRsp->withSchema = 1;
|
||||
|
@ -69,7 +71,6 @@ static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) {
|
|||
|
||||
static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg, bool* pBlockReturned) {
|
||||
uint64_t consumerId = pRequest->consumerId;
|
||||
STqOffsetVal reqOffset = pRequest->reqOffset;
|
||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pRequest->subKey);
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
|
||||
|
@ -86,7 +87,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
return 0;
|
||||
} else {
|
||||
// no poll occurs in this vnode for this topic, let's seek to the right offset value.
|
||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
if (pRequest->useSnapshot) {
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey:%s, vgId:%d, (earliest) set offset to be snapshot",
|
||||
consumerId, pHandle->subKey, vgId);
|
||||
|
@ -100,12 +101,12 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef);
|
||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer);
|
||||
}
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
} else if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
walRefLastVer(pTq->pVnode->pWal, pHandle->pRef);
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, pRequest);
|
||||
tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer + 1);
|
||||
|
||||
tqOffsetResetToLog(&dataRsp.rspOffset, pHandle->pRef->refVer + 1);
|
||||
tqInitDataRsp(&dataRsp, *pOffsetVal);
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId,
|
||||
pHandle->subKey, vgId, dataRsp.rspOffset.version);
|
||||
int32_t code = tqSendDataRsp(pHandle, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
|
@ -113,7 +114,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
|
|||
|
||||
*pBlockReturned = true;
|
||||
return code;
|
||||
} else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) {
|
||||
} else if (pRequest->reqOffset.type == TMQ_OFFSET__RESET_NONE) {
|
||||
tqError("tmq poll: subkey:%s, no offset committed for consumer:0x%" PRIx64
|
||||
" in vg %d, subkey %s, reset none failed",
|
||||
pHandle->subKey, consumerId, vgId, pRequest->subKey);
|
||||
|
@ -125,11 +126,11 @@ 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 void setRequestVersion(STqOffsetVal* offset, int64_t ver){
|
||||
// if(offset->type == TMQ_OFFSET__LOG){
|
||||
// offset->version = ver;
|
||||
// }
|
||||
//}
|
||||
|
||||
static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest,
|
||||
SRpcMsg* pMsg, STqOffsetVal* pOffset) {
|
||||
|
@ -138,8 +139,8 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
terrno = 0;
|
||||
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, pRequest);
|
||||
dataRsp.reqOffset.type = pOffset->type; // stroe origin type for getting offset in tmq_get_vgroup_offset
|
||||
tqInitDataRsp(&dataRsp, *pOffset);
|
||||
// dataRsp.reqOffset.type = pOffset->type; // store origin type for getting offset in tmq_get_vgroup_offset
|
||||
|
||||
qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId);
|
||||
int code = tqScanData(pTq, pHandle, &dataRsp, pOffset);
|
||||
|
@ -152,8 +153,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
// lock
|
||||
taosWLockLatch(&pTq->lock);
|
||||
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
|
||||
if (pOffset->version >= ver ||
|
||||
dataRsp.rspOffset.version >= ver) { // check if there are data again to avoid lost data
|
||||
if (dataRsp.rspOffset.version > ver) { // check if there are data again to avoid lost data
|
||||
code = tqRegisterPushHandle(pTq, pHandle, pMsg);
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
goto end;
|
||||
|
@ -161,7 +161,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
taosWUnLockLatch(&pTq->lock);
|
||||
}
|
||||
|
||||
setRequestVersion(&dataRsp.reqOffset, pOffset->version);
|
||||
// setRequestVersion(&dataRsp.reqOffset, pOffset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
|
||||
end : {
|
||||
|
@ -179,11 +179,10 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
SRpcMsg* pMsg, STqOffsetVal* offset) {
|
||||
int code = 0;
|
||||
int32_t vgId = TD_VID(pTq->pVnode);
|
||||
SWalCkHead* pCkHead = NULL;
|
||||
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
|
||||
tqInitTaosxRsp(&taosxRsp, *offset);
|
||||
// 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) {
|
||||
|
@ -216,14 +215,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
if (offset->type == TMQ_OFFSET__LOG) {
|
||||
walReaderVerifyOffset(pHandle->pWalReader, offset);
|
||||
int64_t fetchVer = offset->version;
|
||||
pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048);
|
||||
if (pCkHead == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
walSetReaderCapacity(pHandle->pWalReader, 2048);
|
||||
int totalRows = 0;
|
||||
while (1) {
|
||||
int32_t savedEpoch = atomic_load_32(&pHandle->epoch);
|
||||
|
@ -234,14 +226,14 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
break;
|
||||
}
|
||||
|
||||
if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead, pRequest->reqId) < 0) {
|
||||
if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
// setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto end;
|
||||
}
|
||||
|
||||
SWalCont* pHead = &pCkHead->head;
|
||||
SWalCont* pHead = &pHandle->pWalReader->pHead->head;
|
||||
tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d",
|
||||
pRequest->consumerId, pRequest->epoch, vgId, fetchVer, pHead->msgType);
|
||||
|
||||
|
@ -249,7 +241,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
if (pHead->msgType != TDMT_VND_SUBMIT) {
|
||||
if (totalRows > 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
// setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto end;
|
||||
}
|
||||
|
@ -279,7 +271,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
|
||||
if (totalRows >= 4096 || taosxRsp.createTableNum > 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer + 1);
|
||||
setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
// setRequestVersion(&taosxRsp.reqOffset, offset->version);
|
||||
code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId);
|
||||
goto end;
|
||||
} else {
|
||||
|
@ -291,20 +283,17 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
|
|||
end:
|
||||
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
taosMemoryFreeClear(pCkHead);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg) {
|
||||
int32_t code = -1;
|
||||
STqOffsetVal offset = {0};
|
||||
STqOffsetVal reqOffset = pRequest->reqOffset;
|
||||
|
||||
// 1. reset the offset if needed
|
||||
if (IS_OFFSET_RESET_TYPE(reqOffset.type)) {
|
||||
if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type)) {
|
||||
// handle the reset offset cases, according to the consumer's choice.
|
||||
bool blockReturned = false;
|
||||
code = extractResetOffsetVal(&offset, pTq, pHandle, pRequest, pMsg, &blockReturned);
|
||||
int32_t code = extractResetOffsetVal(&reqOffset, pTq, pHandle, pRequest, pMsg, &blockReturned);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
@ -313,20 +302,17 @@ int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequ
|
|||
if (blockReturned) {
|
||||
return 0;
|
||||
}
|
||||
} else if(reqOffset.type != 0){ // use the consumer specified offset
|
||||
// the offset value can not be monotonious increase??
|
||||
offset = reqOffset;
|
||||
} else {
|
||||
} else if(reqOffset.type == 0){ // use the consumer specified offset
|
||||
uError("req offset type is 0");
|
||||
return TSDB_CODE_TMQ_INVALID_MSG;
|
||||
}
|
||||
|
||||
// this is a normal subscribe requirement
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
return extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &offset);
|
||||
return extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &reqOffset);
|
||||
} else { // todo handle the case where re-balance occurs.
|
||||
// for taosx
|
||||
return extractDataAndRspForDbStbSubscribe(pTq, pHandle, pRequest, pMsg, &offset);
|
||||
return extractDataAndRspForDbStbSubscribe(pTq, pHandle, pRequest, pMsg, &reqOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef struct {
|
|||
} ctx[1];
|
||||
|
||||
// reader
|
||||
SSttFileReader *sttReader;
|
||||
TSttFileReaderArray sttReaderArray[1];
|
||||
|
||||
// iter
|
||||
TTsdbIterArray dataIterArray[1];
|
||||
|
@ -226,7 +226,7 @@ static int32_t tsdbCommitOpenReader(SCommitter2 *committer) {
|
|||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
ASSERT(committer->sttReader == NULL);
|
||||
ASSERT(TARRAY2_SIZE(committer->sttReaderArray) == 0);
|
||||
|
||||
if (committer->ctx->fset == NULL //
|
||||
|| committer->sttTrigger > 1 //
|
||||
|
@ -241,31 +241,32 @@ static int32_t tsdbCommitOpenReader(SCommitter2 *committer) {
|
|||
|
||||
ASSERT(lvl->level == 0);
|
||||
|
||||
if (TARRAY2_SIZE(lvl->fobjArr) == 0) {
|
||||
return 0;
|
||||
STFileObj *fobj = NULL;
|
||||
TARRAY2_FOREACH(lvl->fobjArr, fobj) {
|
||||
SSttFileReader *sttReader;
|
||||
|
||||
SSttFileReaderConfig config = {
|
||||
.tsdb = committer->tsdb,
|
||||
.szPage = committer->szPage,
|
||||
.file = fobj->f[0],
|
||||
};
|
||||
|
||||
code = tsdbSttFileReaderOpen(fobj->fname, &config, &sttReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = TARRAY2_APPEND(committer->sttReaderArray, sttReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
STFileOp op = {
|
||||
.optype = TSDB_FOP_REMOVE,
|
||||
.fid = fobj->f->fid,
|
||||
.of = fobj->f[0],
|
||||
};
|
||||
|
||||
code = TARRAY2_APPEND(committer->fopArray, op);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
ASSERT(TARRAY2_SIZE(lvl->fobjArr) == 1);
|
||||
|
||||
STFileObj *fobj = TARRAY2_FIRST(lvl->fobjArr);
|
||||
|
||||
SSttFileReaderConfig config = {
|
||||
.tsdb = committer->tsdb,
|
||||
.szPage = committer->szPage,
|
||||
.file = fobj->f[0],
|
||||
};
|
||||
code = tsdbSttFileReaderOpen(fobj->fname, &config, &committer->sttReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
STFileOp op = {
|
||||
.optype = TSDB_FOP_REMOVE,
|
||||
.fid = fobj->f->fid,
|
||||
.of = fobj->f[0],
|
||||
};
|
||||
|
||||
code = TARRAY2_APPEND(committer->fopArray, op);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
TSDB_ERROR_LOG(TD_VID(committer->tsdb->pVnode), lino, code);
|
||||
|
@ -273,7 +274,10 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbCommitCloseReader(SCommitter2 *committer) { return tsdbSttFileReaderClose(&committer->sttReader); }
|
||||
static int32_t tsdbCommitCloseReader(SCommitter2 *committer) {
|
||||
TARRAY2_CLEAR(committer->sttReaderArray, tsdbSttFileReaderClose);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
|
||||
int32_t code = 0;
|
||||
|
@ -310,10 +314,11 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// STT
|
||||
if (committer->sttReader) {
|
||||
SSttFileReader *sttReader;
|
||||
TARRAY2_FOREACH(committer->sttReaderArray, sttReader) {
|
||||
// data iter
|
||||
config.type = TSDB_ITER_TYPE_STT;
|
||||
config.sttReader = committer->sttReader;
|
||||
config.sttReader = sttReader;
|
||||
|
||||
code = tsdbIterOpen(&config, &iter);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -323,7 +328,7 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
|
|||
|
||||
// tomb iter
|
||||
config.type = TSDB_ITER_TYPE_STT_TOMB;
|
||||
config.sttReader = committer->sttReader;
|
||||
config.sttReader = sttReader;
|
||||
|
||||
code = tsdbIterOpen(&config, &iter);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
|
|
@ -780,19 +780,20 @@ static int32_t tsdbFSRunBgTask(void *arg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *), void (*free)(void *),
|
||||
void *arg, int64_t *taskid) {
|
||||
static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *),
|
||||
void (*destroy)(void *), void *arg, int64_t *taskid) {
|
||||
if (fs->stop) {
|
||||
if (destroy) {
|
||||
destroy(arg);
|
||||
}
|
||||
return 0; // TODO: use a better error code
|
||||
}
|
||||
|
||||
// check if same task is on
|
||||
// if (fs->bgTaskRunning && fs->bgTaskRunning->type == type) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
for (STFSBgTask *task = fs->bgTaskQueue->next; task != fs->bgTaskQueue; task = task->next) {
|
||||
if (task->type == type) {
|
||||
if (destroy) {
|
||||
destroy(arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -804,7 +805,7 @@ static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32
|
|||
|
||||
task->type = type;
|
||||
task->run = run;
|
||||
task->free = free;
|
||||
task->free = destroy;
|
||||
task->arg = arg;
|
||||
task->scheduleTime = taosGetTimestampMs();
|
||||
task->taskid = ++fs->taskid;
|
||||
|
|
|
@ -359,7 +359,7 @@ static int32_t suidComparFn(const void *target, const void *p2) {
|
|||
if (*uid2 == (*targetUid)) {
|
||||
return 0;
|
||||
} else {
|
||||
return (*targetUid) < (*uid2) ? -1:1;
|
||||
return (*targetUid) < (*uid2) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ static bool existsFromSttBlkStatis(const TStatisBlkArray *pStatisBlkArray, uint6
|
|||
return false;
|
||||
}
|
||||
|
||||
while(i < TARRAY2_SIZE(pStatisBlkArray)) {
|
||||
while (i < TARRAY2_SIZE(pStatisBlkArray)) {
|
||||
SStatisBlk *p = &pStatisBlkArray->data[i];
|
||||
if (p->minTbid.suid > suid) {
|
||||
return false;
|
||||
|
@ -483,14 +483,12 @@ int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pSttFileReader
|
|||
tsdbDebug("load the stt file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||
}
|
||||
|
||||
/*
|
||||
bool exists = existsFromSttBlkStatis(pBlockLoadInfo->pSttStatisBlkArray, suid, uid, pIter->pReader);
|
||||
if (!exists) {
|
||||
pIter->iSttBlk = -1;
|
||||
pIter->pSttBlk = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
*/
|
||||
// bool exists = existsFromSttBlkStatis(pBlockLoadInfo->pSttStatisBlkArray, suid, uid, pIter->pReader);
|
||||
// if (!exists) {
|
||||
// pIter->iSttBlk = -1;
|
||||
// pIter->pSttBlk = NULL;
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
// find the start block, actually we could load the position to avoid repeatly searching for the start position when
|
||||
// the skey is updated.
|
||||
|
|
|
@ -1121,6 +1121,8 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl
|
|||
SBrinRecord* p = taosArrayGet(pTableBlockScanInfo->pBlockList, pBlockInfo->tbBlockIdx + step);
|
||||
memcpy(pRecord, p, sizeof(SBrinRecord));
|
||||
|
||||
*nextIndex = pBlockInfo->tbBlockIdx + step;
|
||||
|
||||
// tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, pIndex->ordinalIndex, pBlock, tGetDataBlk);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -342,18 +342,18 @@ static int32_t tsdbSnapCmprTombData(STsdbSnapReader* reader, uint8_t** data) {
|
|||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
int64_t size = sizeof(SSnapDataHdr);
|
||||
int64_t size = 0;
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(reader->tombBlock->dataArr); i++) {
|
||||
size += TARRAY2_DATA_LEN(reader->tombBlock->dataArr + i);
|
||||
}
|
||||
|
||||
data[0] = taosMemoryMalloc(size);
|
||||
data[0] = taosMemoryMalloc(size + sizeof(SSnapDataHdr));
|
||||
if (data[0] == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
SSnapDataHdr* hdr = (SSnapDataHdr*)data[0];
|
||||
SSnapDataHdr* hdr = (SSnapDataHdr*)(data[0]);
|
||||
hdr->type = SNAP_DATA_DEL;
|
||||
hdr->size = size;
|
||||
|
||||
|
@ -938,7 +938,7 @@ static int32_t tsdbSnapWriteDecmprTombBlock(SSnapDataHdr* hdr, STombBlock* tombB
|
|||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
int64_t size = hdr->size - sizeof(*hdr);
|
||||
int64_t size = hdr->size;
|
||||
ASSERT(size % TOMB_RECORD_ELEM_NUM == 0);
|
||||
size = size / TOMB_RECORD_ELEM_NUM;
|
||||
ASSERT(size % sizeof(int64_t) == 0);
|
||||
|
|
|
@ -628,6 +628,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
return tqProcessVgCommittedInfoReq(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_TMQ_SEEK:
|
||||
return tqProcessSeekReq(pVnode->pTq, pMsg);
|
||||
|
||||
default:
|
||||
vError("unknown msg type:%d in fetch queue", pMsg->msgType);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
|
|
|
@ -1020,7 +1020,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
SStateWinodwPhysiNode *pStateNode = (SStateWinodwPhysiNode *)pNode;
|
||||
|
||||
EXPLAIN_ROW_NEW(level, EXPLAIN_STATE_WINDOW_FORMAT,
|
||||
nodesGetNameFromColumnNode(((STargetNode *)pStateNode->pStateKey)->pExpr));
|
||||
nodesGetNameFromColumnNode(pStateNode->pStateKey));
|
||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||
if (pResNode->pExecInfo) {
|
||||
QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen));
|
||||
|
|
|
@ -304,7 +304,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3
|
|||
return pTaskInfo;
|
||||
}
|
||||
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId) {
|
||||
qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId, int32_t taskId) {
|
||||
if (msg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v
|
|||
}
|
||||
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(readers, vgId, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
code = qCreateExecTask(readers, vgId, taskId, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
|
@ -1075,7 +1075,7 @@ int32_t qStreamInfoResetTimewindowFilter(qTaskInfo_t tinfo) {
|
|||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
STimeWindow* pWindow = &pTaskInfo->streamInfo.fillHistoryWindow;
|
||||
|
||||
qDebug("%s set remove scan-history filter window:%" PRId64 "-%" PRId64 ", new window:%" PRId64 "-%" PRId64,
|
||||
qDebug("%s remove scan-history filter window:%" PRId64 "-%" PRId64 ", set new window:%" PRId64 "-%" PRId64,
|
||||
GET_TASKID(pTaskInfo), pWindow->skey, pWindow->ekey, INT64_MIN, INT64_MAX);
|
||||
|
||||
pWindow->skey = INT64_MIN;
|
||||
|
|
|
@ -1944,7 +1944,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
|
|||
}
|
||||
|
||||
int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId;
|
||||
SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr;
|
||||
SColumnNode* pColNode = (SColumnNode*)(pStateNode->pStateKey);
|
||||
|
||||
if (pStateNode->window.pExprs != NULL) {
|
||||
int32_t numOfScalarExpr = 0;
|
||||
|
@ -3660,6 +3660,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
|||
SStreamSessionAggOperatorInfo* pInfo = pOperator->info;
|
||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||
qDebug("===stream=== stream session agg");
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
} else if (pOperator->status == OP_RES_TO_RETURN) {
|
||||
|
@ -3822,6 +3823,7 @@ void streamSessionReloadState(SOperatorInfo* pOperator) {
|
|||
setSessionOutputBuf(pAggSup, pSeKeyBuf[i].win.skey, pSeKeyBuf[i].win.ekey, pSeKeyBuf[i].groupId, &winInfo);
|
||||
int32_t winNum = compactSessionWindow(pOperator, &winInfo, pInfo->pStUpdated, pInfo->pStDeleted, true);
|
||||
if (winNum > 0) {
|
||||
qDebug("===stream=== reload state. save result %" PRId64 ", %" PRIu64, winInfo.sessionWin.win.skey, winInfo.sessionWin.groupId);
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||
saveResult(winInfo, pInfo->pStUpdated);
|
||||
} else if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||
|
@ -3840,7 +3842,7 @@ void streamSessionReloadState(SOperatorInfo* pOperator) {
|
|||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
if (downstream->fpSet.reloadStreamStateFn) {
|
||||
downstream->fpSet.reloadStreamStateFn(downstream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
|
||||
|
@ -3949,6 +3951,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
|||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
SStreamAggSupporter* pAggSup = &pInfo->streamAggSup;
|
||||
|
||||
qDebug("===stream=== stream session semi agg");
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4459,6 +4462,7 @@ static void compactStateWindow(SOperatorInfo* pOperator, SResultWindowInfo* pCur
|
|||
initSessionOutputBuf(pCurWin, &pCurResult, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset);
|
||||
SResultRow* pWinResult = NULL;
|
||||
initSessionOutputBuf(pNextWin, &pWinResult, pAggSup->pDummyCtx, numOfOutput, pSup->rowEntryInfoOffset);
|
||||
pCurWin->sessionWin.win.ekey = TMAX(pCurWin->sessionWin.win.ekey, pNextWin->sessionWin.win.ekey);
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pCurWin->sessionWin.win, 1);
|
||||
compactFunctions(pSup->pCtx, pAggSup->pDummyCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData);
|
||||
|
@ -4535,7 +4539,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
SExecTaskInfo* pTaskInfo, SReadHandle* pHandle) {
|
||||
SStreamStateWinodwPhysiNode* pStateNode = (SStreamStateWinodwPhysiNode*)pPhyNode;
|
||||
int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId;
|
||||
SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr;
|
||||
SColumnNode* pColNode = (SColumnNode*)(pStateNode->pStateKey);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
SStreamStateAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamStateAggOperatorInfo));
|
||||
|
|
|
@ -1001,7 +1001,12 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
|
|||
SArray* aExtSrc = taosArrayInit(nSrc, POINTER_BYTES);
|
||||
|
||||
size_t maxBufSize = pHandle->numOfPages * pHandle->pageSize;
|
||||
createPageBuf(pHandle);
|
||||
|
||||
int32_t code = createPageBuf(pHandle);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(aExtSrc);
|
||||
return code;
|
||||
}
|
||||
|
||||
SSortSource* pSrc = taosArrayGetP(pHandle->pOrderedSource, 0);
|
||||
int32_t szSort = 0;
|
||||
|
@ -1076,7 +1081,7 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
|
|||
taosArrayDestroy(aExtSrc);
|
||||
|
||||
pHandle->type = SORT_SINGLESOURCE_SORT;
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
|
||||
|
|
|
@ -468,7 +468,8 @@ static int32_t translateStddevMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
|
||||
static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// pseudo column do not need to check parameters
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT,
|
||||
.precision = pFunc->node.resType.precision};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -491,7 +492,8 @@ static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in
|
|||
// pseudo column do not need to check parameters
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP,
|
||||
.precision = pFunc->node.resType.precision};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2363,7 +2365,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "leastsquares",
|
||||
.type = FUNCTION_TYPE_LEASTSQUARES,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC,
|
||||
.translateFunc = translateLeastSQR,
|
||||
.getEnvFunc = getLeastSQRFuncEnv,
|
||||
.initFunc = leastSQRFunctionSetup,
|
||||
|
@ -2929,8 +2931,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "tail",
|
||||
.type = FUNCTION_TYPE_TAIL,
|
||||
.classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC |
|
||||
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||
.classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||
.translateFunc = translateTail,
|
||||
.getEnvFunc = getTailFuncEnv,
|
||||
.initFunc = tailFunctionSetup,
|
||||
|
@ -2941,8 +2942,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "unique",
|
||||
.type = FUNCTION_TYPE_UNIQUE,
|
||||
.classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC |
|
||||
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||
.classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||
.translateFunc = translateUnique,
|
||||
.getEnvFunc = getUniqueFuncEnv,
|
||||
.initFunc = uniqueFunctionSetup,
|
||||
|
|
|
@ -6597,7 +6597,10 @@ typedef struct SProjColPos {
|
|||
} SProjColPos;
|
||||
|
||||
static int32_t projColPosCompar(const void* l, const void* r) {
|
||||
return ((SProjColPos*)l)->colId > ((SProjColPos*)r)->colId;
|
||||
if (((SProjColPos*)l)->colId < ((SProjColPos*)r)->colId) {
|
||||
return -1;
|
||||
}
|
||||
return ((SProjColPos*)l)->colId == ((SProjColPos*)r)->colId ? 0 : 1;
|
||||
}
|
||||
|
||||
static void projColPosDelete(void* p) { nodesDestroyNode(((SProjColPos*)p)->pProj); }
|
||||
|
|
|
@ -1634,9 +1634,9 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pStateKey, &pState->pStateKey);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addDataBlockSlot(pCxt, &pState->pStateKey, pState->window.node.pOutputDataBlockDesc);
|
||||
}
|
||||
// if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = addDataBlockSlot(pCxt, &pState->pStateKey, pState->window.node.pOutputDataBlockDesc);
|
||||
// }
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -833,7 +833,10 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
|
|||
qDebug("succ to open rocksdb cf");
|
||||
}
|
||||
// close default cf
|
||||
if (((rocksdb_column_family_handle_t**)cfHandle)[0] != 0) rocksdb_column_family_handle_destroy(cfHandle[0]);
|
||||
if (((rocksdb_column_family_handle_t**)cfHandle)[0] != 0) {
|
||||
rocksdb_column_family_handle_destroy(cfHandle[0]);
|
||||
cfHandle[0] = NULL;
|
||||
}
|
||||
rocksdb_options_destroy(cfOpts[0]);
|
||||
handle->db = db;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define MAX_STREAM_RESULT_DUMP_THRESHOLD 100
|
||||
|
||||
static int32_t updateCheckPointInfo(SStreamTask* pTask);
|
||||
static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask);
|
||||
|
||||
bool streamTaskShouldStop(const SStreamStatus* pStatus) {
|
||||
int32_t status = atomic_load_8((int8_t*)&pStatus->taskStatus);
|
||||
|
@ -289,7 +290,7 @@ static void waitForTaskIdle(SStreamTask* pTask, SStreamTask* pStreamTask) {
|
|||
static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
|
||||
SStreamMeta* pMeta = pTask->pMeta;
|
||||
|
||||
SStreamTask* pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.taskId);
|
||||
SStreamTask* pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.streamId, pTask->streamTaskId.taskId);
|
||||
if (pStreamTask == NULL) {
|
||||
// todo: destroy the fill-history task here
|
||||
qError("s-task:%s failed to find related stream task:0x%x, it may have been destroyed or closed", pTask->id.idStr,
|
||||
|
@ -349,10 +350,9 @@ static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
|
|||
streamTaskResumeFromHalt(pStreamTask);
|
||||
|
||||
qDebug("s-task:%s fill-history task set status to be dropping, save the state into disk", pTask->id.idStr);
|
||||
int32_t taskId = pTask->id.taskId;
|
||||
|
||||
// 5. free it and remove fill-history task from disk meta-store
|
||||
streamMetaUnregisterTask(pMeta, taskId);
|
||||
streamMetaUnregisterTask(pMeta, pTask->id.streamId, pTask->id.taskId);
|
||||
|
||||
// 6. save to disk
|
||||
taosWLockLatch(&pMeta->lock);
|
||||
|
@ -364,6 +364,16 @@ static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
|
|||
|
||||
// 7. pause allowed.
|
||||
streamTaskEnablePause(pStreamTask);
|
||||
if (taosQueueEmpty(pStreamTask->inputQueue->queue)) {
|
||||
SStreamRefDataBlock* pItem = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM, 0);;
|
||||
SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
|
||||
pDelBlock->info.rows = 0;
|
||||
pDelBlock->info.version = 0;
|
||||
pItem->type = STREAM_INPUT__REF_DATA_BLOCK;
|
||||
pItem->pBlock = pDelBlock;
|
||||
int32_t code = tAppendDataToInputQueue(pStreamTask, (SStreamQueueItem*)pItem);
|
||||
qDebug("s-task:%s append dummy delete block,res:%d", pStreamTask->id.idStr, code);
|
||||
}
|
||||
|
||||
streamSchedExec(pStreamTask);
|
||||
streamMetaReleaseTask(pMeta, pStreamTask);
|
||||
|
@ -534,8 +544,11 @@ int32_t streamExecForAll(SStreamTask* pTask) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// the task may be set dropping/stopping, while it is still in the task queue, therefore, the sched-status can not
|
||||
// be updated by tryExec function, therefore, the schedStatus will always be the TASK_SCHED_STATUS__WAITING.
|
||||
bool streamTaskIsIdle(const SStreamTask* pTask) {
|
||||
return (pTask->status.schedStatus == TASK_SCHED_STATUS__INACTIVE);
|
||||
return (pTask->status.schedStatus == TASK_SCHED_STATUS__INACTIVE || pTask->status.taskStatus == TASK_STATUS__STOP ||
|
||||
pTask->status.taskStatus == TASK_STATUS__DROPPING);
|
||||
}
|
||||
|
||||
int32_t streamTaskEndScanWAL(SStreamTask* pTask) {
|
||||
|
|
|
@ -66,14 +66,14 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
|||
goto _err;
|
||||
}
|
||||
|
||||
_hash_fn_t fp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
|
||||
_hash_fn_t fp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR);
|
||||
pMeta->pTasks = taosHashInit(64, fp, true, HASH_NO_LOCK);
|
||||
if (pMeta->pTasks == NULL) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// task list
|
||||
pMeta->pTaskList = taosArrayInit(4, sizeof(int32_t));
|
||||
pMeta->pTaskList = taosArrayInit(4, sizeof(SStreamId));
|
||||
if (pMeta->pTaskList == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
|
@ -149,47 +149,11 @@ void streamMetaClose(SStreamMeta* pMeta) {
|
|||
taosMemoryFree(pMeta);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t ver, char* msg, int32_t msgLen) {
|
||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
SDecoder decoder;
|
||||
tDecoderInit(&decoder, (uint8_t*)msg, msgLen);
|
||||
if (tDecodeStreamTask(&decoder, pTask) < 0) {
|
||||
tDecoderClear(&decoder);
|
||||
goto FAIL;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
||||
ASSERT(0);
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
if (taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(int32_t), &pTask, sizeof(void*)) < 0) {
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
if (tdbTbUpsert(pMeta->pTaskDb, &pTask->id.taskId, sizeof(int32_t), msg, msgLen, pMeta->txn) < 0) {
|
||||
taosHashRemove(pMeta->pTasks, &pTask->id.taskId, sizeof(int32_t));
|
||||
ASSERT(0);
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
FAIL:
|
||||
if (pTask) tFreeStreamTask(pTask);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
||||
void* buf = NULL;
|
||||
int32_t len;
|
||||
int32_t code;
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
tEncodeSize(tEncodeStreamTask, pTask, len, code);
|
||||
if (code < 0) {
|
||||
return -1;
|
||||
|
@ -228,14 +192,15 @@ int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) {
|
|||
int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask, bool* pAdded) {
|
||||
*pAdded = false;
|
||||
|
||||
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
||||
int64_t keys[2] = {pTask->id.streamId, pTask->id.taskId};
|
||||
void* p = taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (p == NULL) {
|
||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, ver) < 0) {
|
||||
tFreeStreamTask(pTask);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
||||
taosArrayPush(pMeta->pTaskList, &pTask->id);
|
||||
|
||||
if (streamMetaSaveTask(pMeta, pTask) < 0) {
|
||||
tFreeStreamTask(pTask);
|
||||
|
@ -250,7 +215,7 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa
|
|||
return 0;
|
||||
}
|
||||
|
||||
taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, POINTER_BYTES);
|
||||
taosHashPut(pMeta->pTasks, keys, sizeof(keys), &pTask, POINTER_BYTES);
|
||||
*pAdded = true;
|
||||
return 0;
|
||||
}
|
||||
|
@ -261,10 +226,11 @@ int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta) {
|
|||
return (int32_t)size;
|
||||
}
|
||||
|
||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int32_t taskId) {
|
||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId) {
|
||||
taosRLockLatch(&pMeta->lock);
|
||||
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||
int64_t keys[2] = {streamId, taskId};
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (ppTask != NULL) {
|
||||
if (!streamTaskShouldStop(&(*ppTask)->status)) {
|
||||
int32_t ref = atomic_add_fetch_32(&(*ppTask)->refCnt, 1);
|
||||
|
@ -291,22 +257,24 @@ void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
}
|
||||
}
|
||||
|
||||
static void doRemoveIdFromList(SStreamMeta* pMeta, int32_t num, int32_t taskId) {
|
||||
static void doRemoveIdFromList(SStreamMeta* pMeta, int32_t num, SStreamId* id) {
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
int32_t* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
||||
if (*pTaskId == taskId) {
|
||||
SStreamId* pTaskId = taosArrayGet(pMeta->pTaskList, i);
|
||||
if (pTaskId->streamId == id->streamId && pTaskId->taskId == id->taskId) {
|
||||
taosArrayRemove(pMeta->pTaskList, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int32_t taskId) {
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId) {
|
||||
SStreamTask* pTask = NULL;
|
||||
|
||||
// pre-delete operation
|
||||
taosWLockLatch(&pMeta->lock);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||
|
||||
int64_t keys[2] = {streamId, taskId};
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (ppTask) {
|
||||
pTask = *ppTask;
|
||||
atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__DROPPING);
|
||||
|
@ -317,11 +285,12 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int32_t taskId) {
|
|||
}
|
||||
taosWUnLockLatch(&pMeta->lock);
|
||||
|
||||
qDebug("s-task:0x%x set task status:%s", taskId, streamGetTaskStatusStr(TASK_STATUS__DROPPING));
|
||||
qDebug("s-task:0x%x set task status:%s and start to unregister it", taskId,
|
||||
streamGetTaskStatusStr(TASK_STATUS__DROPPING));
|
||||
|
||||
while(1) {
|
||||
while (1) {
|
||||
taosRLockLatch(&pMeta->lock);
|
||||
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
|
||||
if (ppTask) {
|
||||
if ((*ppTask)->status.timerActive == 0) {
|
||||
|
@ -340,15 +309,13 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int32_t taskId) {
|
|||
|
||||
// let's do delete of stream task
|
||||
taosWLockLatch(&pMeta->lock);
|
||||
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||
ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (ppTask) {
|
||||
taosHashRemove(pMeta->pTasks, &taskId, sizeof(int32_t));
|
||||
taosHashRemove(pMeta->pTasks, keys, sizeof(keys));
|
||||
atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__DROPPING);
|
||||
|
||||
ASSERT(pTask->status.timerActive == 0);
|
||||
|
||||
int32_t num = taosArrayGetSize(pMeta->pTaskList);
|
||||
doRemoveIdFromList(pMeta, num, pTask->id.taskId);
|
||||
doRemoveIdFromList(pMeta, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id);
|
||||
|
||||
streamMetaRemoveTask(pMeta, taskId);
|
||||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
@ -426,9 +393,20 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
|||
taosArrayDestroy(pRecycleList);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||
tDecodeStreamTask(&decoder, pTask);
|
||||
if (tDecodeStreamTask(&decoder, pTask) < 0) {
|
||||
tDecoderClear(&decoder);
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
tdbTbcClose(pCur);
|
||||
taosArrayDestroy(pRecycleList);
|
||||
tFreeStreamTask(pTask);
|
||||
qError(
|
||||
"stream read incompatible data, rm %s/vnode/vnode*/tq/stream if taosd cannot start, and rebuild stream "
|
||||
"manually",
|
||||
tsDataDir);
|
||||
return -1;
|
||||
}
|
||||
tDecoderClear(&decoder);
|
||||
|
||||
if (pTask->status.taskStatus == TASK_STATUS__DROPPING) {
|
||||
|
@ -443,7 +421,8 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
|||
}
|
||||
|
||||
// do duplicate task check.
|
||||
void* p = taosHashGet(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
|
||||
int64_t keys[2] = {pTask->id.streamId, pTask->id.taskId};
|
||||
void* p = taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (p == NULL) {
|
||||
if (pMeta->expandFunc(pMeta->ahandle, pTask, pTask->chkInfo.version) < 0) {
|
||||
tdbFree(pKey);
|
||||
|
@ -454,7 +433,7 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
taosArrayPush(pMeta->pTaskList, &pTask->id.taskId);
|
||||
taosArrayPush(pMeta->pTaskList, &pTask->id);
|
||||
} else {
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
|
@ -463,7 +442,7 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (taosHashPut(pMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, sizeof(void*)) < 0) {
|
||||
if (taosHashPut(pMeta->pTasks, keys, sizeof(keys), &pTask, sizeof(void*)) < 0) {
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
tdbTbcClose(pCur);
|
||||
|
@ -483,13 +462,13 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
|
|||
}
|
||||
|
||||
if (taosArrayGetSize(pRecycleList) > 0) {
|
||||
for(int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
||||
int32_t taskId = *(int32_t*) taosArrayGet(pRecycleList, i);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
||||
int32_t taskId = *(int32_t*)taosArrayGet(pRecycleList, i);
|
||||
streamMetaRemoveTask(pMeta, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("vgId:%d load %d task from disk", pMeta->vgId, (int32_t) taosArrayGetSize(pMeta->pTaskList));
|
||||
qDebug("vgId:%d load %d task from disk", pMeta->vgId, (int32_t)taosArrayGetSize(pMeta->pTaskList));
|
||||
taosArrayDestroy(pRecycleList);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
typedef struct SStreamTaskRetryInfo {
|
||||
SStreamMeta* pMeta;
|
||||
int32_t taskId;
|
||||
int32_t taskId;
|
||||
int64_t streamId;
|
||||
} SStreamTaskRetryInfo;
|
||||
|
||||
static int32_t streamSetParamForScanHistory(SStreamTask* pTask);
|
||||
|
@ -502,11 +503,13 @@ int32_t streamProcessScanHistoryFinishRsp(SStreamTask* pTask) {
|
|||
|
||||
taosWLockLatch(&pMeta->lock);
|
||||
streamMetaSaveTask(pMeta, pTask);
|
||||
streamMetaCommit(pMeta);
|
||||
taosWUnLockLatch(&pMeta->lock);
|
||||
|
||||
// history data scan in the stream time window finished, now let's enable the pause
|
||||
streamTaskEnablePause(pTask);
|
||||
|
||||
// for source tasks, let's continue execute.
|
||||
if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) {
|
||||
streamSchedExec(pTask);
|
||||
}
|
||||
|
@ -538,7 +541,9 @@ static void tryLaunchHistoryTask(void* param, void* tmrId) {
|
|||
qDebug("s-task:0x%x in timer to launch related history task", pInfo->taskId);
|
||||
|
||||
taosWLockLatch(&pMeta->lock);
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &pInfo->taskId, sizeof(int32_t));
|
||||
int64_t keys[2] = {pInfo->streamId, pInfo->taskId};
|
||||
|
||||
SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (ppTask) {
|
||||
ASSERT((*ppTask)->status.timerActive >= 1);
|
||||
|
||||
|
@ -554,12 +559,12 @@ static void tryLaunchHistoryTask(void* param, void* tmrId) {
|
|||
}
|
||||
taosWUnLockLatch(&pMeta->lock);
|
||||
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pInfo->taskId);
|
||||
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pInfo->streamId, pInfo->taskId);
|
||||
if (pTask != NULL) {
|
||||
ASSERT(pTask->status.timerActive >= 1);
|
||||
|
||||
// abort the timer if intend to stop task
|
||||
SStreamTask* pHTask = streamMetaAcquireTask(pMeta, pTask->historyTaskId.taskId);
|
||||
SStreamTask* pHTask = streamMetaAcquireTask(pMeta, pTask->historyTaskId.streamId, pTask->historyTaskId.taskId);
|
||||
if (pHTask == NULL && (!streamTaskShouldStop(&pTask->status))) {
|
||||
const char* pStatus = streamGetTaskStatusStr(pTask->status.taskStatus);
|
||||
qWarn(
|
||||
|
@ -593,14 +598,16 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) {
|
|||
SStreamMeta* pMeta = pTask->pMeta;
|
||||
int32_t hTaskId = pTask->historyTaskId.taskId;
|
||||
|
||||
int64_t keys[2] = {pTask->historyTaskId.streamId, pTask->historyTaskId.taskId};
|
||||
// Set the execute conditions, including the query time window and the version range
|
||||
SStreamTask** pHTask = taosHashGet(pMeta->pTasks, &hTaskId, sizeof(hTaskId));
|
||||
SStreamTask** pHTask = taosHashGet(pMeta->pTasks, keys, sizeof(keys));
|
||||
if (pHTask == NULL) {
|
||||
qWarn("s-task:%s vgId:%d failed to launch history task:0x%x, since it is not built yet", pTask->id.idStr,
|
||||
pMeta->vgId, hTaskId);
|
||||
|
||||
SStreamTaskRetryInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamTaskRetryInfo));
|
||||
pInfo->taskId = pTask->id.taskId;
|
||||
pInfo->streamId = pTask->id.streamId;
|
||||
pInfo->pMeta = pTask->pMeta;
|
||||
|
||||
if (pTask->launchTaskTimer == NULL) {
|
||||
|
@ -795,7 +802,8 @@ void launchFillHistoryTask(SStreamTask* pTask) {
|
|||
}
|
||||
|
||||
ASSERT(pTask->status.downstreamReady == 1);
|
||||
qDebug("s-task:%s start to launch related fill-history task:0x%x", pTask->id.idStr, tId);
|
||||
qDebug("s-task:%s start to launch related fill-history task:0x%" PRIx64 "-0x%x", pTask->id.idStr,
|
||||
pTask->historyTaskId.streamId, tId);
|
||||
|
||||
// launch associated fill history task
|
||||
streamLaunchFillHistoryTask(pTask);
|
||||
|
|
|
@ -26,13 +26,14 @@ static int32_t addToTaskset(SArray* pArray, SStreamTask* pTask) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, int8_t fillHistory, int64_t triggerParam, SArray* pTaskList) {
|
||||
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, int8_t fillHistory, int64_t triggerParam,
|
||||
SArray* pTaskList) {
|
||||
SStreamTask* pTask = (SStreamTask*)taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pTask->ver = SSTREAM_TASK_VER;
|
||||
pTask->id.taskId = tGenIdPI32();
|
||||
pTask->id.streamId = streamId;
|
||||
pTask->info.taskLevel = taskLevel;
|
||||
|
@ -72,6 +73,7 @@ int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) {
|
|||
|
||||
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||
if (tStartEncode(pEncoder) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pTask->ver) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pTask->id.streamId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pTask->id.taskId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pTask->info.totalLevel) < 0) return -1;
|
||||
|
@ -135,6 +137,9 @@ int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
|||
|
||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||
if (tStartDecode(pDecoder) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pTask->ver) < 0) return -1;
|
||||
if (pTask->ver != SSTREAM_TASK_VER) return -1;
|
||||
|
||||
if (tDecodeI64(pDecoder, &pTask->id.streamId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pTask->id.taskId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pTask->info.totalLevel) < 0) return -1;
|
||||
|
@ -163,7 +168,7 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
|||
if (tDecodeI64(pDecoder, &pTask->dataRange.window.skey)) return -1;
|
||||
if (tDecodeI64(pDecoder, &pTask->dataRange.window.ekey)) return -1;
|
||||
|
||||
int32_t epSz;
|
||||
int32_t epSz = -1;
|
||||
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
||||
|
||||
pTask->pUpstreamEpInfoList = taosArrayInit(epSz, POINTER_BYTES);
|
||||
|
@ -211,7 +216,7 @@ static void freeItem(void* p) {
|
|||
}
|
||||
|
||||
void tFreeStreamTask(SStreamTask* pTask) {
|
||||
qDebug("free s-task:%s, %p", pTask->id.idStr, pTask);
|
||||
qDebug("free s-task:0x%x, %p", pTask->id.taskId, pTask);
|
||||
|
||||
// remove the ref by timer
|
||||
while(pTask->status.timerActive > 0) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "osEnv.h"
|
||||
#include "tfsInt.h"
|
||||
|
||||
static int32_t tfsMount(STfs *pTfs, SDiskCfg *pCfg);
|
||||
|
@ -113,6 +114,39 @@ SDiskSize tfsGetSize(STfs *pTfs) {
|
|||
return size;
|
||||
}
|
||||
|
||||
bool tfsDiskSpaceAvailable(STfs *pTfs, int32_t level) {
|
||||
if (level < 0 || level >= pTfs->nlevel) {
|
||||
return false;
|
||||
}
|
||||
STfsTier *pTier = TFS_TIER_AT(pTfs, level);
|
||||
for (int32_t id = 0; id < pTier->ndisk; id++) {
|
||||
SDiskID diskId = {.level = level, .id = id};
|
||||
STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId);
|
||||
if (pDisk == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (pDisk->size.avail <= 0) {
|
||||
fError("tfs disk space unavailable. level:%d, disk:%d, path:%s", level, id, pDisk->path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tfsDiskSpaceSufficient(STfs *pTfs, int32_t level, int32_t disk) {
|
||||
if (level < 0 || level >= pTfs->nlevel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
STfsTier *pTier = TFS_TIER_AT(pTfs, level);
|
||||
if (disk < 0 || disk >= pTier->ndisk) {
|
||||
return false;
|
||||
}
|
||||
SDiskID diskId = {.level = level, .id = disk};
|
||||
STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId);
|
||||
return pDisk->size.avail >= tsDataSpace.reserved;
|
||||
}
|
||||
|
||||
int32_t tfsGetDisksAtLevel(STfs *pTfs, int32_t level) {
|
||||
if (level < 0 || level >= pTfs->nlevel) {
|
||||
return 0;
|
||||
|
|
|
@ -293,7 +293,7 @@ bool transReadComplete(SConnBuffer* connBuf);
|
|||
int transResetBuffer(SConnBuffer* connBuf);
|
||||
int transDumpFromBuffer(SConnBuffer* connBuf, char** buf);
|
||||
|
||||
int transSetConnOption(uv_tcp_t* stream);
|
||||
int transSetConnOption(uv_tcp_t* stream, int keepalive);
|
||||
|
||||
void transRefSrvHandle(void* handle);
|
||||
void transUnrefSrvHandle(void* handle);
|
||||
|
|
|
@ -46,14 +46,14 @@ typedef struct {
|
|||
int8_t connType;
|
||||
char label[TSDB_LABEL_LEN];
|
||||
char user[TSDB_UNI_LEN]; // meter ID
|
||||
int32_t compatibilityVer;
|
||||
int32_t compatibilityVer;
|
||||
int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size
|
||||
int8_t encryption; // encrypt or not
|
||||
|
||||
|
||||
int32_t retryMinInterval; // retry init interval
|
||||
int32_t retryStepFactor; // retry interval factor
|
||||
int32_t retryMaxInterval; // retry max interval
|
||||
int32_t retryMaxTimouet;
|
||||
int32_t retryMaxTimeout;
|
||||
|
||||
int32_t failFastThreshold;
|
||||
int32_t failFastInterval;
|
||||
|
|
|
@ -55,7 +55,7 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
pRpc->retryMinInterval = pInit->retryMinInterval; // retry init interval
|
||||
pRpc->retryStepFactor = pInit->retryStepFactor;
|
||||
pRpc->retryMaxInterval = pInit->retryMaxInterval;
|
||||
pRpc->retryMaxTimouet = pInit->retryMaxTimouet;
|
||||
pRpc->retryMaxTimeout = pInit->retryMaxTimeout;
|
||||
|
||||
pRpc->failFastThreshold = pInit->failFastThreshold;
|
||||
pRpc->failFastInterval = pInit->failFastInterval;
|
||||
|
|
|
@ -1202,7 +1202,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
|
|||
cliHandleFastFail(conn, -1);
|
||||
return;
|
||||
}
|
||||
ret = transSetConnOption((uv_tcp_t*)conn->stream);
|
||||
ret = transSetConnOption((uv_tcp_t*)conn->stream, 20);
|
||||
if (ret != 0) {
|
||||
tError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
|
||||
cliHandleFastFail(conn, -1);
|
||||
|
@ -1610,7 +1610,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
|
||||
tGTrace("%s conn %p try to connect to %s", pTransInst->label, conn, conn->dstAddr);
|
||||
pThrd->newConnCount++;
|
||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 4);
|
||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
||||
if (fd == -1) {
|
||||
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
|
@ -1624,7 +1624,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
cliHandleExcept(conn);
|
||||
return;
|
||||
}
|
||||
ret = transSetConnOption((uv_tcp_t*)conn->stream);
|
||||
ret = transSetConnOption((uv_tcp_t*)conn->stream, tsKeepAliveIdle);
|
||||
if (ret != 0) {
|
||||
tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
|
||||
cliHandleExcept(conn);
|
||||
|
@ -2287,7 +2287,7 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
pCtx->retryMinInterval = pTransInst->retryMinInterval;
|
||||
pCtx->retryMaxInterval = pTransInst->retryMaxInterval;
|
||||
pCtx->retryStepFactor = pTransInst->retryStepFactor;
|
||||
pCtx->retryMaxTimeout = pTransInst->retryMaxTimouet;
|
||||
pCtx->retryMaxTimeout = pTransInst->retryMaxTimeout;
|
||||
pCtx->retryInitTimestamp = taosGetTimestampMs();
|
||||
pCtx->retryNextInterval = pCtx->retryMinInterval;
|
||||
pCtx->retryStep = 0;
|
||||
|
|
|
@ -203,10 +203,10 @@ bool transReadComplete(SConnBuffer* connBuf) {
|
|||
return (p->left == 0 || p->invalid) ? true : false;
|
||||
}
|
||||
|
||||
int transSetConnOption(uv_tcp_t* stream) {
|
||||
int transSetConnOption(uv_tcp_t* stream, int keepalive) {
|
||||
#if defined(WINDOWS) || defined(DARWIN)
|
||||
#else
|
||||
uv_tcp_keepalive(stream, 1, 20);
|
||||
uv_tcp_keepalive(stream, 1, keepalive);
|
||||
#endif
|
||||
return uv_tcp_nodelay(stream, 1);
|
||||
// int ret = uv_tcp_keepalive(stream, 5, 60);
|
||||
|
|
|
@ -726,7 +726,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
|||
tError("read error %s", uv_err_name(nread));
|
||||
}
|
||||
// TODO(log other failure reason)
|
||||
tWarn("failed to create connect:%p", q);
|
||||
tWarn("failed to create connect:%p, reason: %s", q, uv_err_name(nread));
|
||||
taosMemoryFree(buf->base);
|
||||
uv_close((uv_handle_t*)q, NULL);
|
||||
return;
|
||||
|
@ -741,10 +741,17 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
|||
uv_pipe_t* pipe = (uv_pipe_t*)q;
|
||||
if (!uv_pipe_pending_count(pipe)) {
|
||||
tError("No pending count");
|
||||
uv_close((uv_handle_t*)q, NULL);
|
||||
return;
|
||||
}
|
||||
if (pThrd->quit) {
|
||||
tWarn("thread already received quit msg, ignore incoming conn");
|
||||
|
||||
uv_close((uv_handle_t*)q, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
uv_handle_type pending = uv_pipe_pending_type(pipe);
|
||||
// uv_handle_type pending = uv_pipe_pending_type(pipe);
|
||||
|
||||
SSvrConn* pConn = createConn(pThrd);
|
||||
|
||||
|
@ -760,7 +767,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
|||
uv_tcp_init(pThrd->loop, pConn->pTcp);
|
||||
pConn->pTcp->data = pConn;
|
||||
|
||||
transSetConnOption((uv_tcp_t*)pConn->pTcp);
|
||||
// transSetConnOption((uv_tcp_t*)pConn->pTcp);
|
||||
|
||||
if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) {
|
||||
uv_os_fd_t fd;
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
#include "taoserror.h"
|
||||
#include "walInt.h"
|
||||
|
||||
static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer);
|
||||
static int32_t walFetchBodyNew(SWalReader *pRead);
|
||||
static int32_t walSkipFetchBodyNew(SWalReader *pRead);
|
||||
|
||||
SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) {
|
||||
SWalReader *pReader = taosMemoryCalloc(1, sizeof(SWalReader));
|
||||
if (pReader == NULL) {
|
||||
|
@ -70,38 +66,29 @@ int32_t walNextValidMsg(SWalReader *pReader) {
|
|||
int64_t fetchVer = pReader->curVersion;
|
||||
int64_t lastVer = walGetLastVer(pReader->pWal);
|
||||
int64_t committedVer = walGetCommittedVer(pReader->pWal);
|
||||
// int64_t appliedVer = walGetAppliedVer(pReader->pWal);
|
||||
|
||||
// if(appliedVer < committedVer){ // wait apply ver equal to commit ver, otherwise may lost data when consume data [TD-24010]
|
||||
// wDebug("vgId:%d, wal apply ver:%"PRId64" smaller than commit ver:%"PRId64, pReader->pWal->cfg.vgId, appliedVer, committedVer);
|
||||
// }
|
||||
|
||||
// int64_t endVer = TMIN(appliedVer, committedVer);
|
||||
int64_t endVer = committedVer;
|
||||
int64_t appliedVer = walGetAppliedVer(pReader->pWal);
|
||||
|
||||
wDebug("vgId:%d, wal start to fetch, index:%" PRId64 ", last index:%" PRId64 " commit index:%" PRId64
|
||||
", end index:%" PRId64,
|
||||
pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, endVer);
|
||||
|
||||
if (fetchVer > endVer){
|
||||
", applied index:%" PRId64,
|
||||
pReader->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer);
|
||||
if (fetchVer > appliedVer){
|
||||
terrno = TSDB_CODE_WAL_LOG_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fetchVer <= endVer) {
|
||||
if (walFetchHeadNew(pReader, fetchVer) < 0) {
|
||||
while (fetchVer <= appliedVer) {
|
||||
if (walFetchHead(pReader, fetchVer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t type = pReader->pHead->head.msgType;
|
||||
if (type == TDMT_VND_SUBMIT || ((type == TDMT_VND_DELETE) && (pReader->cond.deleteMsg == 1)) ||
|
||||
(IS_META_MSG(type) && pReader->cond.scanMeta)) {
|
||||
if (walFetchBodyNew(pReader) < 0) {
|
||||
if (walFetchBody(pReader) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
if (walSkipFetchBodyNew(pReader) < 0) {
|
||||
if (walSkipFetchBody(pReader) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -263,104 +250,8 @@ int32_t walReaderSeekVer(SWalReader *pReader, int64_t ver) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void walSetReaderCapacity(SWalReader *pRead, int32_t capacity) { pRead->capacity = capacity; }
|
||||
|
||||
static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer) {
|
||||
int64_t contLen;
|
||||
bool seeked = false;
|
||||
|
||||
wDebug("vgId:%d, wal starts to fetch head, index:%" PRId64, pRead->pWal->cfg.vgId, fetchVer);
|
||||
|
||||
if (pRead->curVersion != fetchVer) {
|
||||
if (walReaderSeekVer(pRead, fetchVer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
seeked = true;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
contLen = taosReadFile(pRead->pLogFile, pRead->pHead, sizeof(SWalCkHead));
|
||||
if (contLen == sizeof(SWalCkHead)) {
|
||||
break;
|
||||
} else if (contLen == 0 && !seeked) {
|
||||
if(walReadSeekVerImpl(pRead, fetchVer) < 0){
|
||||
return -1;
|
||||
}
|
||||
seeked = true;
|
||||
continue;
|
||||
} else {
|
||||
if (contLen < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
} else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// pRead->curInvalid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t walFetchBodyNew(SWalReader *pReader) {
|
||||
SWalCont *pReadHead = &pReader->pHead->head;
|
||||
int64_t ver = pReadHead->version;
|
||||
|
||||
wDebug("vgId:%d, wal starts to fetch body, ver:%" PRId64 " ,len:%d, total", pReader->pWal->cfg.vgId, ver,
|
||||
pReadHead->bodyLen);
|
||||
|
||||
if (pReader->capacity < pReadHead->bodyLen) {
|
||||
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||
if (ptr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pReader->pHead = ptr;
|
||||
pReadHead = &pReader->pHead->head;
|
||||
pReader->capacity = pReadHead->bodyLen;
|
||||
}
|
||||
|
||||
if (pReadHead->bodyLen != taosReadFile(pReader->pLogFile, pReadHead->body, pReadHead->bodyLen)) {
|
||||
if (pReadHead->bodyLen < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since %s",
|
||||
pReader->pWal->cfg.vgId, pReader->pHead->head.version, ver, tstrerror(terrno));
|
||||
} else {
|
||||
wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since file corrupted",
|
||||
pReader->pWal->cfg.vgId, pReader->pHead->head.version, ver);
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (walValidBodyCksum(pReader->pHead) != 0) {
|
||||
wError("vgId:%d, wal fetch body error:%" PRId64 ", since body checksum not passed", pReader->pWal->cfg.vgId, ver);
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wDebug("vgId:%d, index:%" PRId64 " is fetched, type:%d, cursor advance", pReader->pWal->cfg.vgId, ver, pReader->pHead->head.msgType);
|
||||
pReader->curVersion = ver + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t walSkipFetchBodyNew(SWalReader *pRead) {
|
||||
int64_t code;
|
||||
|
||||
code = taosLSeekFile(pRead->pLogFile, pRead->pHead->head.bodyLen, SEEK_CUR);
|
||||
if (code < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
// pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRead->curVersion++;
|
||||
wDebug("vgId:%d, version advance to %" PRId64 ", skip fetch", pRead->pWal->cfg.vgId, pRead->curVersion);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
||||
int32_t walFetchHead(SWalReader *pRead, int64_t ver) {
|
||||
int64_t code;
|
||||
int64_t contLen;
|
||||
bool seeked = false;
|
||||
|
@ -378,15 +269,13 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
|||
if (pRead->curVersion != ver) {
|
||||
code = walReaderSeekVer(pRead, ver);
|
||||
if (code < 0) {
|
||||
// pRead->curVersion = ver;
|
||||
// pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
seeked = true;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
contLen = taosReadFile(pRead->pLogFile, pHead, sizeof(SWalCkHead));
|
||||
contLen = taosReadFile(pRead->pLogFile, pRead->pHead, sizeof(SWalCkHead));
|
||||
if (contLen == sizeof(SWalCkHead)) {
|
||||
break;
|
||||
} else if (contLen == 0 && !seeked) {
|
||||
|
@ -401,12 +290,11 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
|||
} else {
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
// pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
code = walValidHeadCksum(pHead);
|
||||
code = walValidHeadCksum(pRead->pHead);
|
||||
|
||||
if (code != 0) {
|
||||
wError("vgId:%d, unexpected wal log index:%" PRId64 ", since head checksum not passed", pRead->pWal->cfg.vgId, ver);
|
||||
|
@ -414,32 +302,27 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// pRead->curInvalid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) {
|
||||
int64_t code;
|
||||
|
||||
int32_t walSkipFetchBody(SWalReader *pRead) {
|
||||
wDebug("vgId:%d, skip fetch body %" PRId64 ", first ver:%" PRId64 ", commit ver:%" PRId64 ", last ver:%" PRId64
|
||||
", applied ver:%" PRId64,
|
||||
pRead->pWal->cfg.vgId, pHead->head.version, pRead->pWal->vers.firstVer, pRead->pWal->vers.commitVer,
|
||||
pRead->pWal->cfg.vgId, pRead->pHead->head.version, pRead->pWal->vers.firstVer, pRead->pWal->vers.commitVer,
|
||||
pRead->pWal->vers.lastVer, pRead->pWal->vers.appliedVer);
|
||||
|
||||
code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR);
|
||||
int64_t code = taosLSeekFile(pRead->pLogFile, pRead->pHead->head.bodyLen, SEEK_CUR);
|
||||
if (code < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
// pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRead->curVersion++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
||||
SWalCont *pReadHead = &((*ppHead)->head);
|
||||
int32_t walFetchBody(SWalReader *pRead) {
|
||||
SWalCont *pReadHead = &pRead->pHead->head;
|
||||
int64_t ver = pReadHead->version;
|
||||
|
||||
wDebug("vgId:%d, fetch body %" PRId64 ", first ver:%" PRId64 ", commit ver:%" PRId64 ", last ver:%" PRId64
|
||||
|
@ -448,13 +331,13 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
|||
pRead->pWal->vers.appliedVer);
|
||||
|
||||
if (pRead->capacity < pReadHead->bodyLen) {
|
||||
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
|
||||
if (ptr == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
*ppHead = ptr;
|
||||
pReadHead = &((*ppHead)->head);
|
||||
pRead->pHead = ptr;
|
||||
pReadHead = &pRead->pHead->head;
|
||||
pRead->capacity = pReadHead->bodyLen;
|
||||
}
|
||||
|
||||
|
@ -468,27 +351,24 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
|
|||
pRead->pWal->cfg.vgId, pReadHead->version, ver);
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
// pRead->curInvalid = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pReadHead->version != ver) {
|
||||
wError("vgId:%d, wal fetch body error, index:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId,
|
||||
pReadHead->version, ver);
|
||||
// pRead->curInvalid = 1;
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (walValidBodyCksum(*ppHead) != 0) {
|
||||
if (walValidBodyCksum(pRead->pHead) != 0) {
|
||||
wError("vgId:%d, wal fetch body error, index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId,
|
||||
ver);
|
||||
// pRead->curInvalid = 1;
|
||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRead->curVersion = ver + 1;
|
||||
pRead->curVersion++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,10 +95,10 @@ void osCleanup() {}
|
|||
|
||||
bool osLogSpaceAvailable() { return tsLogSpace.size.avail > 0; }
|
||||
|
||||
bool osDataSpaceAvailable() { return tsDataSpace.size.avail > 0; }
|
||||
|
||||
bool osTempSpaceAvailable() { return tsTempSpace.size.avail > 0; }
|
||||
|
||||
bool osDataSpaceAvailable() { return tsDataSpace.size.avail > 0; }
|
||||
|
||||
bool osLogSpaceSufficient() { return tsLogSpace.size.avail > tsLogSpace.reserved; }
|
||||
|
||||
bool osDataSpaceSufficient() { return tsDataSpace.size.avail > tsDataSpace.reserved; }
|
||||
|
|
|
@ -25,7 +25,7 @@ int32_t qsortHelper(const void* p1, const void* p2, const void* param) {
|
|||
|
||||
// todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually.
|
||||
void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) {
|
||||
#if defined(WINDOWS) || defined(_ALPINE)
|
||||
#if defined(WINDOWS_STASH) || defined(_ALPINE)
|
||||
void* param = compar;
|
||||
taosqsort(base, sz, width, param, qsortHelper);
|
||||
#else
|
||||
|
|
|
@ -768,7 +768,7 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8
|
|||
keyValue[4] = (keyValue[4] == '+' ? '-' : '+');
|
||||
keyValue[10] = 0;
|
||||
sprintf(winStr, "TZ=%s:00", &(keyValue[1]));
|
||||
*tsTimezone = taosStr2Int32(&keyValue[4], NULL, 10);
|
||||
*tsTimezone = -taosStr2Int32(&keyValue[4], NULL, 10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8
|
|||
indexStr = ppp - pp + 3;
|
||||
}
|
||||
sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (p[0] == '+' ? '-' : '+'), p[1], p[2], p[3], p[4]);
|
||||
*tsTimezone = taosStr2Int32(p, NULL, 10);
|
||||
*tsTimezone = -taosStr2Int32(p, NULL, 10);
|
||||
} else {
|
||||
*tsTimezone = 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pgrep taosd || taosd >> /dev/null 2>&1 &
|
||||
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
|
||||
|
||||
cd ../../docs/examples/R
|
||||
wget -N https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/3.2.4/taos-jdbcdriver-3.2.4-dist.jar
|
||||
|
||||
jar_path=`find . -name taos-jdbcdriver-*-dist.jar`
|
||||
echo jar_path=$jar_path
|
||||
R -f connect_native.r --args $jar_path
|
||||
# R -f connect_rest.r --args $jar_path # bug 14704
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue