other: merge 3.0
This commit is contained in:
commit
771065952e
|
@ -16,3 +16,6 @@
|
||||||
[submodule "tools/taos-tools"]
|
[submodule "tools/taos-tools"]
|
||||||
path = tools/taos-tools
|
path = tools/taos-tools
|
||||||
url = https://github.com/taosdata/taos-tools
|
url = https://github.com/taosdata/taos-tools
|
||||||
|
[submodule "tools/taosadapter"]
|
||||||
|
path = tools/taosadapter
|
||||||
|
url = https://github.com/taosdata/taosadapter.git
|
||||||
|
|
14
Jenkinsfile2
14
Jenkinsfile2
|
@ -38,6 +38,7 @@ def pre_test(){
|
||||||
sh '''
|
sh '''
|
||||||
hostname
|
hostname
|
||||||
date
|
date
|
||||||
|
env
|
||||||
'''
|
'''
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WK}
|
cd ${WK}
|
||||||
|
@ -82,23 +83,33 @@ def pre_test(){
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
|
git log -5
|
||||||
|
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
|
||||||
|
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log -5
|
git log -5
|
||||||
|
echo "community log merged: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
cd ${WK}
|
cd ${WK}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log -5
|
git log -5
|
||||||
|
echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
'''
|
'''
|
||||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WK}
|
cd ${WK}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
|
git log -5
|
||||||
|
echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
|
||||||
|
echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log -5
|
git log -5
|
||||||
|
echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log -5
|
git log -5
|
||||||
|
echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
sh '''
|
sh '''
|
||||||
|
@ -113,6 +124,9 @@ def pre_test(){
|
||||||
cd ${WKPY}
|
cd ${WKPY}
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git pull
|
git pull
|
||||||
|
git log -5
|
||||||
|
echo "python connector log: `git log -5`" >>${WKDIR}/jenkins.log
|
||||||
|
echo >>${WKDIR}/jenkins.log
|
||||||
'''
|
'''
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,33 @@ if (NOT DEFINED TD_GRANT)
|
||||||
SET(TD_GRANT FALSE)
|
SET(TD_GRANT FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
IF ("${BUILD_HTTP}" STREQUAL "")
|
||||||
|
IF (TD_LINUX)
|
||||||
|
IF (TD_ARM_32)
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
ELSEIF (TD_DARWIN)
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
ELSEIF (${BUILD_HTTP} MATCHES "false")
|
||||||
|
SET(TD_BUILD_HTTP FALSE)
|
||||||
|
ELSEIF (${BUILD_HTTP} MATCHES "true")
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ELSEIF (${BUILD_HTTP} MATCHES "internal")
|
||||||
|
SET(TD_BUILD_HTTP FALSE)
|
||||||
|
SET(TD_BUILD_TAOSA_INTERNAL TRUE)
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_BUILD_HTTP TRUE)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (TD_BUILD_HTTP)
|
||||||
|
ADD_DEFINITIONS(-DHTTP_EMBEDDED)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" STREQUAL "")
|
IF ("${BUILD_TOOLS}" STREQUAL "")
|
||||||
IF (TD_LINUX)
|
IF (TD_LINUX)
|
||||||
IF (TD_ARM_32)
|
IF (TD_ARM_32)
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
---
|
|
||||||
title: Keywords
|
|
||||||
---
|
|
||||||
|
|
||||||
There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case.
|
|
||||||
|
|
||||||
**Keywords List**
|
|
||||||
|
|
||||||
| | | | | |
|
|
||||||
| ----------- | ---------- | --------- | ---------- | ------------ |
|
|
||||||
| ABORT | CREATE | IGNORE | NULL | STAR |
|
|
||||||
| ACCOUNT | CTIME | IMMEDIATE | OF | STATE |
|
|
||||||
| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT |
|
|
||||||
| ADD | DATABASES | IN | OR | STATE_WINDOW |
|
|
||||||
| AFTER | DAYS | INITIALLY | ORDER | STORAGE |
|
|
||||||
| ALL | DBS | INSERT | PARTITIONS | STREAM |
|
|
||||||
| ALTER | DEFERRED | INSTEAD | PASS | STREAMS |
|
|
||||||
| AND | DELIMITERS | INT | PLUS | STRING |
|
|
||||||
| AS | DESC | INTEGER | PPS | SYNCDB |
|
|
||||||
| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE |
|
|
||||||
| ATTACH | DETACH | INTO | PREV | TABLES |
|
|
||||||
| BEFORE | DISTINCT | IS | PRIVILEGE | TAG |
|
|
||||||
| BEGIN | DIVIDE | ISNULL | QTIME | TAGS |
|
|
||||||
| BETWEEN | DNODE | JOIN | QUERIES | TBNAME |
|
|
||||||
| BIGINT | DNODES | KEEP | QUERY | TIMES |
|
|
||||||
| BINARY | DOT | KEY | QUORUM | TIMESTAMP |
|
|
||||||
| BITAND | DOUBLE | KILL | RAISE | TINYINT |
|
|
||||||
| BITNOT | DROP | LE | REM | TOPIC |
|
|
||||||
| BITOR | EACH | LIKE | REPLACE | TOPICS |
|
|
||||||
| BLOCKS | END | LIMIT | REPLICA | TRIGGER |
|
|
||||||
| BOOL | EQ | LINEAR | RESET | TSERIES |
|
|
||||||
| BY | EXISTS | LOCAL | RESTRICT | UMINUS |
|
|
||||||
| CACHE | EXPLAIN | LP | ROW | UNION |
|
|
||||||
| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED |
|
|
||||||
| CASCADE | FILE | LT | RSHIFT | UPDATE |
|
|
||||||
| CHANGE | FILL | MATCH | SCORES | UPLUS |
|
|
||||||
| CLUSTER | FLOAT | MAXROWS | SELECT | USE |
|
|
||||||
| COLON | FOR | MINROWS | SEMI | USER |
|
|
||||||
| COLUMN | FROM | MINUS | SESSION | USERS |
|
|
||||||
| COMMA | FSYNC | MNODES | SET | USING |
|
|
||||||
| COMP | GE | MODIFY | SHOW | VALUES |
|
|
||||||
| COMPACT | GLOB | MODULES | SLASH | VARIABLE |
|
|
||||||
| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES |
|
|
||||||
| CONFLICT | GROUP | NE | SLIMIT | VGROUPS |
|
|
||||||
| CONNECTION | GT | NONE | SMALLINT | VIEW |
|
|
||||||
| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES |
|
|
||||||
| CONNS | ID | NOTNULL | STable | WAL |
|
|
||||||
| COPY | IF | NOW | STableS | WHERE |
|
|
||||||
| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART |
|
|
||||||
| _WSTOP | _WDURATION | _ROWTS |
|
|
||||||
|
|
||||||
## Explanations
|
|
||||||
### TBNAME
|
|
||||||
`TBNAME` can be considered as a special tag, which represents the name of the subtable, in a STable.
|
|
||||||
|
|
||||||
Get the table name and tag values of all subtables in a STable.
|
|
||||||
```mysql
|
|
||||||
SELECT TBNAME, location FROM meters;
|
|
||||||
```
|
|
||||||
|
|
||||||
Count the number of subtables in a STable.
|
|
||||||
```mysql
|
|
||||||
SELECT COUNT(TBNAME) FROM meters;
|
|
||||||
```
|
|
||||||
|
|
||||||
Only filter on TAGS can be used in WHERE clause in the above two query statements.
|
|
||||||
```mysql
|
|
||||||
taos> SELECT TBNAME, location FROM meters;
|
|
||||||
tbname | location |
|
|
||||||
==================================================================
|
|
||||||
d1004 | California.SanFrancisco |
|
|
||||||
d1003 | California.SanFrancisco |
|
|
||||||
d1002 | California.LosAngeles |
|
|
||||||
d1001 | California.LosAngeles |
|
|
||||||
Query OK, 4 row(s) in set (0.000881s)
|
|
||||||
|
|
||||||
taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2;
|
|
||||||
count(tbname) |
|
|
||||||
========================
|
|
||||||
2 |
|
|
||||||
Query OK, 1 row(s) in set (0.001091s)
|
|
||||||
```
|
|
||||||
### _QSTART/_QSTOP/_QDURATION
|
|
||||||
The start, stop and duration of a query time window.
|
|
||||||
|
|
||||||
### _WSTART/_WSTOP/_WDURATION
|
|
||||||
The start, stop and duration of aggegate query by time window, like interval, session window, state window.
|
|
||||||
|
|
||||||
### _c0/_ROWTS
|
|
||||||
_c0 is equal to _ROWTS, it means the first column of a table or STable.
|
|
|
@ -0,0 +1,315 @@
|
||||||
|
---
|
||||||
|
title: Keywords
|
||||||
|
---
|
||||||
|
|
||||||
|
There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case.
|
||||||
|
|
||||||
|
## Keywords List
|
||||||
|
|
||||||
|
### A
|
||||||
|
|
||||||
|
- ABORT
|
||||||
|
- ACCOUNT
|
||||||
|
- ACCOUNTS
|
||||||
|
- ADD
|
||||||
|
- AFTER
|
||||||
|
- ALL
|
||||||
|
- ALTER
|
||||||
|
- AND
|
||||||
|
- AS
|
||||||
|
- ASC
|
||||||
|
- ATTACH
|
||||||
|
|
||||||
|
### B
|
||||||
|
|
||||||
|
- BEFORE
|
||||||
|
- BEGIN
|
||||||
|
- BETWEEN
|
||||||
|
- BIGINT
|
||||||
|
- BINARY
|
||||||
|
- BITAND
|
||||||
|
- BITNOT
|
||||||
|
- BITOR
|
||||||
|
- BLOCKS
|
||||||
|
- BOOL
|
||||||
|
- BY
|
||||||
|
|
||||||
|
### C
|
||||||
|
|
||||||
|
- CACHE
|
||||||
|
- CACHELAST
|
||||||
|
- CASCADE
|
||||||
|
- CHANGE
|
||||||
|
- CLUSTER
|
||||||
|
- COLON
|
||||||
|
- COLUMN
|
||||||
|
- COMMA
|
||||||
|
- COMP
|
||||||
|
- COMPACT
|
||||||
|
- CONCAT
|
||||||
|
- CONFLICT
|
||||||
|
- CONNECTION
|
||||||
|
- CONNECTIONS
|
||||||
|
- CONNS
|
||||||
|
- COPY
|
||||||
|
- CREATE
|
||||||
|
- CTIME
|
||||||
|
|
||||||
|
### D
|
||||||
|
|
||||||
|
- DATABASE
|
||||||
|
- DATABASES
|
||||||
|
- DAYS
|
||||||
|
- DBS
|
||||||
|
- DEFERRED
|
||||||
|
- DELETE
|
||||||
|
- DELIMITERS
|
||||||
|
- DESC
|
||||||
|
- DESCRIBE
|
||||||
|
- DETACH
|
||||||
|
- DISTINCT
|
||||||
|
- DIVIDE
|
||||||
|
- DNODE
|
||||||
|
- DNODES
|
||||||
|
- DOT
|
||||||
|
- DOUBLE
|
||||||
|
- DROP
|
||||||
|
|
||||||
|
### E
|
||||||
|
|
||||||
|
- END
|
||||||
|
- EQ
|
||||||
|
- EXISTS
|
||||||
|
- EXPLAIN
|
||||||
|
|
||||||
|
### F
|
||||||
|
|
||||||
|
- FAIL
|
||||||
|
- FILE
|
||||||
|
- FILL
|
||||||
|
- FLOAT
|
||||||
|
- FOR
|
||||||
|
- FROM
|
||||||
|
- FSYNC
|
||||||
|
|
||||||
|
### G
|
||||||
|
|
||||||
|
- GE
|
||||||
|
- GLOB
|
||||||
|
- GRANTS
|
||||||
|
- GROUP
|
||||||
|
- GT
|
||||||
|
|
||||||
|
### H
|
||||||
|
|
||||||
|
- HAVING
|
||||||
|
|
||||||
|
### I
|
||||||
|
|
||||||
|
- ID
|
||||||
|
- IF
|
||||||
|
- IGNORE
|
||||||
|
- IMMEDIA
|
||||||
|
- IMPORT
|
||||||
|
- IN
|
||||||
|
- INITIAL
|
||||||
|
- INSERT
|
||||||
|
- INSTEAD
|
||||||
|
- INT
|
||||||
|
- INTEGER
|
||||||
|
- INTERVA
|
||||||
|
- INTO
|
||||||
|
- IS
|
||||||
|
- ISNULL
|
||||||
|
|
||||||
|
### J
|
||||||
|
|
||||||
|
- JOIN
|
||||||
|
|
||||||
|
### K
|
||||||
|
|
||||||
|
- KEEP
|
||||||
|
- KEY
|
||||||
|
- KILL
|
||||||
|
|
||||||
|
### L
|
||||||
|
|
||||||
|
- LE
|
||||||
|
- LIKE
|
||||||
|
- LIMIT
|
||||||
|
- LINEAR
|
||||||
|
- LOCAL
|
||||||
|
- LP
|
||||||
|
- LSHIFT
|
||||||
|
- LT
|
||||||
|
|
||||||
|
### M
|
||||||
|
|
||||||
|
- MATCH
|
||||||
|
- MAXROWS
|
||||||
|
- MINROWS
|
||||||
|
- MINUS
|
||||||
|
- MNODES
|
||||||
|
- MODIFY
|
||||||
|
- MODULES
|
||||||
|
|
||||||
|
### N
|
||||||
|
|
||||||
|
- NE
|
||||||
|
- NONE
|
||||||
|
- NOT
|
||||||
|
- NOTNULL
|
||||||
|
- NOW
|
||||||
|
- NULL
|
||||||
|
|
||||||
|
### O
|
||||||
|
|
||||||
|
- OF
|
||||||
|
- OFFSET
|
||||||
|
- OR
|
||||||
|
- ORDER
|
||||||
|
|
||||||
|
### P
|
||||||
|
|
||||||
|
- PARTITION
|
||||||
|
- PASS
|
||||||
|
- PLUS
|
||||||
|
- PPS
|
||||||
|
- PRECISION
|
||||||
|
- PREV
|
||||||
|
- PRIVILEGE
|
||||||
|
|
||||||
|
### Q
|
||||||
|
|
||||||
|
- QTIME
|
||||||
|
- QUERIE
|
||||||
|
- QUERY
|
||||||
|
- QUORUM
|
||||||
|
|
||||||
|
### R
|
||||||
|
|
||||||
|
- RAISE
|
||||||
|
- REM
|
||||||
|
- REPLACE
|
||||||
|
- REPLICA
|
||||||
|
- RESET
|
||||||
|
- RESTRIC
|
||||||
|
- ROW
|
||||||
|
- RP
|
||||||
|
- RSHIFT
|
||||||
|
|
||||||
|
### S
|
||||||
|
|
||||||
|
- SCORES
|
||||||
|
- SELECT
|
||||||
|
- SEMI
|
||||||
|
- SESSION
|
||||||
|
- SET
|
||||||
|
- SHOW
|
||||||
|
- SLASH
|
||||||
|
- SLIDING
|
||||||
|
- SLIMIT
|
||||||
|
- SMALLIN
|
||||||
|
- SOFFSET
|
||||||
|
- STable
|
||||||
|
- STableS
|
||||||
|
- STAR
|
||||||
|
- STATE
|
||||||
|
- STATEMEN
|
||||||
|
- STATE_WI
|
||||||
|
- STORAGE
|
||||||
|
- STREAM
|
||||||
|
- STREAMS
|
||||||
|
- STRING
|
||||||
|
- SYNCDB
|
||||||
|
|
||||||
|
### T
|
||||||
|
|
||||||
|
- TABLE
|
||||||
|
- TABLES
|
||||||
|
- TAG
|
||||||
|
- TAGS
|
||||||
|
- TBNAME
|
||||||
|
- TIMES
|
||||||
|
- TIMESTAMP
|
||||||
|
- TINYINT
|
||||||
|
- TOPIC
|
||||||
|
- TOPICS
|
||||||
|
- TRIGGER
|
||||||
|
- TSERIES
|
||||||
|
|
||||||
|
### U
|
||||||
|
|
||||||
|
- UMINUS
|
||||||
|
- UNION
|
||||||
|
- UNSIGNED
|
||||||
|
- UPDATE
|
||||||
|
- UPLUS
|
||||||
|
- USE
|
||||||
|
- USER
|
||||||
|
- USERS
|
||||||
|
- USING
|
||||||
|
|
||||||
|
### V
|
||||||
|
|
||||||
|
- VALUES
|
||||||
|
- VARIABLE
|
||||||
|
- VARIABLES
|
||||||
|
- VGROUPS
|
||||||
|
- VIEW
|
||||||
|
- VNODES
|
||||||
|
|
||||||
|
### W
|
||||||
|
|
||||||
|
- WAL
|
||||||
|
- WHERE
|
||||||
|
|
||||||
|
### _
|
||||||
|
|
||||||
|
- _C0
|
||||||
|
- _QSTART
|
||||||
|
- _QSTOP
|
||||||
|
- _QDURATION
|
||||||
|
- _WSTART
|
||||||
|
- _WSTOP
|
||||||
|
- _WDURATION
|
||||||
|
|
||||||
|
## Explanations
|
||||||
|
### TBNAME
|
||||||
|
`TBNAME` can be considered as a special tag, which represents the name of the subtable, in a STable.
|
||||||
|
|
||||||
|
Get the table name and tag values of all subtables in a STable.
|
||||||
|
```mysql
|
||||||
|
SELECT TBNAME, location FROM meters;
|
||||||
|
```
|
||||||
|
|
||||||
|
Count the number of subtables in a STable.
|
||||||
|
```mysql
|
||||||
|
SELECT COUNT(TBNAME) FROM meters;
|
||||||
|
```
|
||||||
|
|
||||||
|
Only filter on TAGS can be used in WHERE clause in the above two query statements.
|
||||||
|
```mysql
|
||||||
|
taos> SELECT TBNAME, location FROM meters;
|
||||||
|
tbname | location |
|
||||||
|
==================================================================
|
||||||
|
d1004 | California.SanFrancisco |
|
||||||
|
d1003 | California.SanFrancisco |
|
||||||
|
d1002 | California.LosAngeles |
|
||||||
|
d1001 | California.LosAngeles |
|
||||||
|
Query OK, 4 row(s) in set (0.000881s)
|
||||||
|
|
||||||
|
taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2;
|
||||||
|
count(tbname) |
|
||||||
|
========================
|
||||||
|
2 |
|
||||||
|
Query OK, 1 row(s) in set (0.001091s)
|
||||||
|
```
|
||||||
|
### _QSTART/_QSTOP/_QDURATION
|
||||||
|
The start, stop and duration of a query time window.
|
||||||
|
|
||||||
|
### _WSTART/_WSTOP/_WDURATION
|
||||||
|
The start, stop and duration of aggegate query by time window, like interval, session window, state window.
|
||||||
|
|
||||||
|
### _c0/_ROWTS
|
||||||
|
_c0 is equal to _ROWTS, it means the first column of a table or STable.
|
|
@ -0,0 +1,49 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
_ "github.com/taosdata/driver-go/v2/taosRestful"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createStable(taos *sql.DB) {
|
||||||
|
_, err := taos.Exec("CREATE DATABASE power")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to create database, err:", err)
|
||||||
|
}
|
||||||
|
_, err = taos.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to create stable, err:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func insertData(taos *sql.DB) {
|
||||||
|
sql := `INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)
|
||||||
|
power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)
|
||||||
|
power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)
|
||||||
|
power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`
|
||||||
|
result, err := taos.Exec(sql)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to insert, err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rowsAffected, err := result.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to get affected rows, err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("RowsAffected", rowsAffected)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var taosDSN = "root:taosdata@http(localhost:6041)/"
|
||||||
|
taos, err := sql.Open("taosRestful", taosDSN)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to connect TDengine, err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer taos.Close()
|
||||||
|
createStable(taos)
|
||||||
|
insertData(taos)
|
||||||
|
}
|
|
@ -45,48 +45,274 @@ title: TDengine 参数限制与保留关键字
|
||||||
|
|
||||||
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
|
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
|
||||||
|
|
||||||
| 关键字列表 | | | | |
|
### A
|
||||||
| ----------- | ---------- | --------- | ---------- | ------------ |
|
|
||||||
| ABORT | CREATE | IGNORE | NULL | STAR |
|
- ABORT
|
||||||
| ACCOUNT | CTIME | IMMEDIATE | OF | STATE |
|
- ACCOUNT
|
||||||
| ACCOUNTS | DATABASE | IMPORT | OFFSET | STATEMENT |
|
- ACCOUNTS
|
||||||
| ADD | DATABASES | IN | OR | STATE_WINDOW |
|
- ADD
|
||||||
| AFTER | DAYS | INITIALLY | ORDER | STORAGE |
|
- AFTER
|
||||||
| ALL | DBS | INSERT | PARTITIONS | STREAM |
|
- ALL
|
||||||
| ALTER | DEFERRED | INSTEAD | PASS | STREAMS |
|
- ALTER
|
||||||
| AND | DELIMITERS | INT | PLUS | STRING |
|
- AND
|
||||||
| AS | DESC | INTEGER | PPS | SYNCDB |
|
- AS
|
||||||
| ASC | DESCRIBE | INTERVAL | PRECISION | TABLE |
|
- ASC
|
||||||
| ATTACH | DETACH | INTO | PREV | TABLES |
|
- ATTACH
|
||||||
| BEFORE | DISTINCT | IS | PRIVILEGE | TAG |
|
|
||||||
| BEGIN | DIVIDE | ISNULL | QTIME | TAGS |
|
### B
|
||||||
| BETWEEN | DNODE | JOIN | QUERIES | TBNAME |
|
|
||||||
| BIGINT | DNODES | KEEP | QUERY | TIMES |
|
- BEFORE
|
||||||
| BINARY | DOT | KEY | QUORUM | TIMESTAMP |
|
- BEGIN
|
||||||
| BITAND | DOUBLE | KILL | RAISE | TINYINT |
|
- BETWEEN
|
||||||
| BITNOT | DROP | LE | REM | TOPIC |
|
- BIGINT
|
||||||
| BITOR | EACH | LIKE | REPLACE | TOPICS |
|
- BINARY
|
||||||
| BLOCKS | END | LIMIT | REPLICA | TRIGGER |
|
- BITAND
|
||||||
| BOOL | EQ | LINEAR | RESET | TSERIES |
|
- BITNOT
|
||||||
| BY | EXISTS | LOCAL | RESTRICT | UMINUS |
|
- BITOR
|
||||||
| CACHE | EXPLAIN | LP | ROW | UNION |
|
- BLOCKS
|
||||||
| CACHELAST | FAIL | LSHIFT | RP | UNSIGNED |
|
- BOOL
|
||||||
| CASCADE | FILE | LT | RSHIFT | UPDATE |
|
- BY
|
||||||
| CHANGE | FILL | MATCH | SCORES | UPLUS |
|
|
||||||
| CLUSTER | FLOAT | MAXROWS | SELECT | USE |
|
### C
|
||||||
| COLON | FOR | MINROWS | SEMI | USER |
|
|
||||||
| COLUMN | FROM | MINUS | SESSION | USERS |
|
- CACHE
|
||||||
| COMMA | FSYNC | MNODES | SET | USING |
|
- CACHELAST
|
||||||
| COMP | GE | MODIFY | SHOW | VALUES |
|
- CASCADE
|
||||||
| COMPACT | GLOB | MODULES | SLASH | VARIABLE |
|
- CHANGE
|
||||||
| CONCAT | GRANTS | NCHAR | SLIDING | VARIABLES |
|
- CLUSTER
|
||||||
| CONFLICT | GROUP | NE | SLIMIT | VGROUPS |
|
- COLON
|
||||||
| CONNECTION | GT | NONE | SMALLINT | VIEW |
|
- COLUMN
|
||||||
| CONNECTIONS | HAVING | NOT | SOFFSET | VNODES |
|
- COMMA
|
||||||
| CONNS | ID | NOTNULL | STABLE | WAL |
|
- COMP
|
||||||
| COPY | IF | NOW | STABLES | WHERE |
|
- COMPACT
|
||||||
| _C0 | _QSTART | _QSTOP | _QDURATION | _WSTART |
|
- CONCAT
|
||||||
| _WSTOP | _WDURATION | _ROWTS |
|
- CONFLICT
|
||||||
|
- CONNECTION
|
||||||
|
- CONNECTIONS
|
||||||
|
- CONNS
|
||||||
|
- COPY
|
||||||
|
- CREATE
|
||||||
|
- CTIME
|
||||||
|
|
||||||
|
### D
|
||||||
|
|
||||||
|
- DATABASE
|
||||||
|
- DATABASES
|
||||||
|
- DAYS
|
||||||
|
- DBS
|
||||||
|
- DEFERRED
|
||||||
|
- DELETE
|
||||||
|
- DELIMITERS
|
||||||
|
- DESC
|
||||||
|
- DESCRIBE
|
||||||
|
- DETACH
|
||||||
|
- DISTINCT
|
||||||
|
- DIVIDE
|
||||||
|
- DNODE
|
||||||
|
- DNODES
|
||||||
|
- DOT
|
||||||
|
- DOUBLE
|
||||||
|
- DROP
|
||||||
|
|
||||||
|
### E
|
||||||
|
|
||||||
|
- END
|
||||||
|
- EQ
|
||||||
|
- EXISTS
|
||||||
|
- EXPLAIN
|
||||||
|
|
||||||
|
### F
|
||||||
|
|
||||||
|
- FAIL
|
||||||
|
- FILE
|
||||||
|
- FILL
|
||||||
|
- FLOAT
|
||||||
|
- FOR
|
||||||
|
- FROM
|
||||||
|
- FSYNC
|
||||||
|
|
||||||
|
### G
|
||||||
|
|
||||||
|
- GE
|
||||||
|
- GLOB
|
||||||
|
- GRANTS
|
||||||
|
- GROUP
|
||||||
|
- GT
|
||||||
|
|
||||||
|
### H
|
||||||
|
|
||||||
|
- HAVING
|
||||||
|
|
||||||
|
### I
|
||||||
|
|
||||||
|
- ID
|
||||||
|
- IF
|
||||||
|
- IGNORE
|
||||||
|
- IMMEDIA
|
||||||
|
- IMPORT
|
||||||
|
- IN
|
||||||
|
- INITIAL
|
||||||
|
- INSERT
|
||||||
|
- INSTEAD
|
||||||
|
- INT
|
||||||
|
- INTEGER
|
||||||
|
- INTERVA
|
||||||
|
- INTO
|
||||||
|
- IS
|
||||||
|
- ISNULL
|
||||||
|
|
||||||
|
### J
|
||||||
|
|
||||||
|
- JOIN
|
||||||
|
|
||||||
|
### K
|
||||||
|
|
||||||
|
- KEEP
|
||||||
|
- KEY
|
||||||
|
- KILL
|
||||||
|
|
||||||
|
### L
|
||||||
|
|
||||||
|
- LE
|
||||||
|
- LIKE
|
||||||
|
- LIMIT
|
||||||
|
- LINEAR
|
||||||
|
- LOCAL
|
||||||
|
- LP
|
||||||
|
- LSHIFT
|
||||||
|
- LT
|
||||||
|
|
||||||
|
### M
|
||||||
|
|
||||||
|
- MATCH
|
||||||
|
- MAXROWS
|
||||||
|
- MINROWS
|
||||||
|
- MINUS
|
||||||
|
- MNODES
|
||||||
|
- MODIFY
|
||||||
|
- MODULES
|
||||||
|
|
||||||
|
### N
|
||||||
|
|
||||||
|
- NE
|
||||||
|
- NONE
|
||||||
|
- NOT
|
||||||
|
- NOTNULL
|
||||||
|
- NOW
|
||||||
|
- NULL
|
||||||
|
|
||||||
|
### O
|
||||||
|
|
||||||
|
- OF
|
||||||
|
- OFFSET
|
||||||
|
- OR
|
||||||
|
- ORDER
|
||||||
|
|
||||||
|
### P
|
||||||
|
|
||||||
|
- PARTITION
|
||||||
|
- PASS
|
||||||
|
- PLUS
|
||||||
|
- PPS
|
||||||
|
- PRECISION
|
||||||
|
- PREV
|
||||||
|
- PRIVILEGE
|
||||||
|
|
||||||
|
### Q
|
||||||
|
|
||||||
|
- QTIME
|
||||||
|
- QUERIE
|
||||||
|
- QUERY
|
||||||
|
- QUORUM
|
||||||
|
|
||||||
|
### R
|
||||||
|
|
||||||
|
- RAISE
|
||||||
|
- REM
|
||||||
|
- REPLACE
|
||||||
|
- REPLICA
|
||||||
|
- RESET
|
||||||
|
- RESTRIC
|
||||||
|
- ROW
|
||||||
|
- RP
|
||||||
|
- RSHIFT
|
||||||
|
|
||||||
|
### S
|
||||||
|
|
||||||
|
- SCORES
|
||||||
|
- SELECT
|
||||||
|
- SEMI
|
||||||
|
- SESSION
|
||||||
|
- SET
|
||||||
|
- SHOW
|
||||||
|
- SLASH
|
||||||
|
- SLIDING
|
||||||
|
- SLIMIT
|
||||||
|
- SMALLIN
|
||||||
|
- SOFFSET
|
||||||
|
- STable
|
||||||
|
- STableS
|
||||||
|
- STAR
|
||||||
|
- STATE
|
||||||
|
- STATEMEN
|
||||||
|
- STATE_WI
|
||||||
|
- STORAGE
|
||||||
|
- STREAM
|
||||||
|
- STREAMS
|
||||||
|
- STRING
|
||||||
|
- SYNCDB
|
||||||
|
|
||||||
|
### T
|
||||||
|
|
||||||
|
- TABLE
|
||||||
|
- TABLES
|
||||||
|
- TAG
|
||||||
|
- TAGS
|
||||||
|
- TBNAME
|
||||||
|
- TIMES
|
||||||
|
- TIMESTAMP
|
||||||
|
- TINYINT
|
||||||
|
- TOPIC
|
||||||
|
- TOPICS
|
||||||
|
- TRIGGER
|
||||||
|
- TSERIES
|
||||||
|
|
||||||
|
### U
|
||||||
|
|
||||||
|
- UMINUS
|
||||||
|
- UNION
|
||||||
|
- UNSIGNED
|
||||||
|
- UPDATE
|
||||||
|
- UPLUS
|
||||||
|
- USE
|
||||||
|
- USER
|
||||||
|
- USERS
|
||||||
|
- USING
|
||||||
|
|
||||||
|
### V
|
||||||
|
|
||||||
|
- VALUES
|
||||||
|
- VARIABLE
|
||||||
|
- VARIABLES
|
||||||
|
- VGROUPS
|
||||||
|
- VIEW
|
||||||
|
- VNODES
|
||||||
|
|
||||||
|
### W
|
||||||
|
|
||||||
|
- WAL
|
||||||
|
- WHERE
|
||||||
|
|
||||||
|
### _
|
||||||
|
|
||||||
|
- _C0
|
||||||
|
- _QSTART
|
||||||
|
- _QSTOP
|
||||||
|
- _QDURATION
|
||||||
|
- _WSTART
|
||||||
|
- _WSTOP
|
||||||
|
- _WDURATION
|
||||||
|
|
||||||
|
|
||||||
## 特殊说明
|
## 特殊说明
|
||||||
### TBNAME
|
### TBNAME
|
|
@ -52,6 +52,7 @@ extern "C" {
|
||||||
#define TSDB_PERFS_TABLE_OFFSETS "offsets"
|
#define TSDB_PERFS_TABLE_OFFSETS "offsets"
|
||||||
#define TSDB_PERFS_TABLE_TRANS "trans"
|
#define TSDB_PERFS_TABLE_TRANS "trans"
|
||||||
#define TSDB_PERFS_TABLE_STREAMS "streams"
|
#define TSDB_PERFS_TABLE_STREAMS "streams"
|
||||||
|
#define TSDB_PERFS_TABLE_APPS "apps"
|
||||||
|
|
||||||
typedef struct SSysDbTableSchema {
|
typedef struct SSysDbTableSchema {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
|
|
@ -234,9 +234,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
|
|
||||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||||
|
|
||||||
SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid,
|
|
||||||
const char* stbFullName, int32_t vgId);
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
|
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
|
||||||
return blockDataGetSerialMetaSize(pBlock->info.numOfCols) + blockDataGetSize(pBlock);
|
return blockDataGetSerialMetaSize(pBlock->info.numOfCols) + blockDataGetSize(pBlock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1134,14 +1134,16 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
|
||||||
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
|
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
|
||||||
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
|
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
|
||||||
void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
|
void tFreeSTableMetaRsp(STableMetaRsp* pRsp);
|
||||||
|
void tFreeSTableIndexRsp(void* info);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray* pArray; // Array of STableMetaRsp
|
SArray* pMetaRsp; // Array of STableMetaRsp
|
||||||
} STableMetaBatchRsp;
|
SArray* pIndexRsp; // Array of STableIndexRsp;
|
||||||
|
} SSTbHbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSTableMetaBatchRsp(void* buf, int32_t bufLen, STableMetaBatchRsp* pRsp);
|
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
|
||||||
int32_t tDeserializeSTableMetaBatchRsp(void* buf, int32_t bufLen, STableMetaBatchRsp* pRsp);
|
int32_t tDeserializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
|
||||||
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp* pRsp);
|
void tFreeSSTbHbRsp(SSTbHbRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
|
@ -1295,8 +1297,17 @@ int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq*
|
||||||
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t connId;
|
int32_t dnodeId;
|
||||||
int32_t queryId;
|
int8_t standby;
|
||||||
|
} SSetStandbyReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq);
|
||||||
|
int32_t tDeserializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t connId; // todo remove
|
||||||
|
int32_t queryId; // todo remove
|
||||||
|
char queryStrId[TSDB_QUERY_ID_LEN];
|
||||||
} SKillQueryReq;
|
} SKillQueryReq;
|
||||||
|
|
||||||
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
|
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
|
||||||
|
@ -1494,9 +1505,9 @@ typedef struct {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
} STaskDropRsp;
|
} STaskDropRsp;
|
||||||
|
|
||||||
#define STREAM_TRIGGER_AT_ONCE 1
|
#define STREAM_TRIGGER_AT_ONCE 1
|
||||||
#define STREAM_TRIGGER_WINDOW_CLOSE 2
|
#define STREAM_TRIGGER_WINDOW_CLOSE 2
|
||||||
#define STREAM_TRIGGER_MAX_DELAY 3
|
#define STREAM_TRIGGER_MAX_DELAY 3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
|
@ -1506,6 +1517,7 @@ typedef struct {
|
||||||
char* sql;
|
char* sql;
|
||||||
char* ast;
|
char* ast;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
|
int64_t maxDelay;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
} SCMCreateStreamReq;
|
} SCMCreateStreamReq;
|
||||||
|
|
||||||
|
@ -2297,6 +2309,29 @@ int32_t tDecodeSMqOffset(SDecoder* decoder, SMqOffset* pOffset);
|
||||||
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
||||||
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
|
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
|
||||||
|
|
||||||
|
// tqOffset
|
||||||
|
enum {
|
||||||
|
TMQ_OFFSET__SNAPSHOT = 1,
|
||||||
|
TMQ_OFFSET__LOG,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
int64_t uid;
|
||||||
|
int64_t ts;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
int64_t version;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
char subKey[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
|
} STqOffset;
|
||||||
|
|
||||||
|
int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset);
|
||||||
|
int32_t tDecodeSTqOffset(SDecoder* pDecoder, STqOffset* pOffset);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
char stb[TSDB_TABLE_FNAME_LEN];
|
char stb[TSDB_TABLE_FNAME_LEN];
|
||||||
|
@ -2393,6 +2428,7 @@ typedef struct {
|
||||||
|
|
||||||
static FORCE_INLINE void tDestroyTSma(STSma* pSma) {
|
static FORCE_INLINE void tDestroyTSma(STSma* pSma) {
|
||||||
if (pSma) {
|
if (pSma) {
|
||||||
|
taosMemoryFreeClear(pSma->dstTbName);
|
||||||
taosMemoryFreeClear(pSma->expr);
|
taosMemoryFreeClear(pSma->expr);
|
||||||
taosMemoryFreeClear(pSma->tagsFilter);
|
taosMemoryFreeClear(pSma->tagsFilter);
|
||||||
}
|
}
|
||||||
|
@ -2421,7 +2457,7 @@ int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq);
|
||||||
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
|
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
|
||||||
|
|
||||||
int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
|
int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
|
||||||
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma);
|
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy);
|
||||||
|
|
||||||
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
|
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
|
||||||
if (tEncodeI32(pEncoder, pReq->number) < 0) return -1;
|
if (tEncodeI32(pEncoder, pReq->number) < 0) return -1;
|
||||||
|
@ -2431,10 +2467,10 @@ static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq) {
|
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) {
|
||||||
if (tDecodeI32(pDecoder, &pReq->number) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pReq->number) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pReq->number; ++i) {
|
for (int32_t i = 0; i < pReq->number; ++i) {
|
||||||
tDecodeTSma(pDecoder, pReq->tSma + i);
|
tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2493,7 +2529,11 @@ typedef struct {
|
||||||
} STableIndexInfo;
|
} STableIndexInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SArray* pIndex;
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
uint64_t suid;
|
||||||
|
int32_t version;
|
||||||
|
SArray* pIndex;
|
||||||
} STableIndexRsp;
|
} STableIndexRsp;
|
||||||
|
|
||||||
int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp);
|
int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp);
|
||||||
|
|
|
@ -140,7 +140,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MQ_CONSUMER_RECOVER, "consumer-recover", SMqConsumerRecoverMsg, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "do-rebalance", SMqDoRebalanceMsg, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DROP_CGROUP, "drop-cgroup", SMqDropCGroupReq, SMqDropCGroupRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "mnode-commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mq-tmr", SMTimerReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "telem-tmr", SMTimerReq, SMTimerReq)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "trans-tmr", NULL, NULL)
|
||||||
|
@ -176,6 +176,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_CHANGE, "vnode-mq-vg-change", SMqRebVgReq, SMqRebVgRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_VG_DELETE, "vnode-mq-vg-delete", SMqVDeleteReq, SMqVDeleteRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_COMMIT_OFFSET, "vnode-commit-offset", STqOffset, STqOffset)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_TASK, "vnode-cancel-task", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TASK, "vnode-drop-task", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL)
|
||||||
|
@ -237,6 +238,8 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_SEND, "sync-snapshot-send", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SNAPSHOT_RSP, "sync-snapshot-rsp", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_MNODE_STANDBY, "set-mnode-standby", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL)
|
||||||
|
|
||||||
#if defined(TD_MSG_NUMBER_)
|
#if defined(TD_MSG_NUMBER_)
|
||||||
TDMT_MAX
|
TDMT_MAX
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
#define TK_BUFFER 60
|
#define TK_BUFFER 60
|
||||||
#define TK_CACHELAST 61
|
#define TK_CACHELAST 61
|
||||||
#define TK_COMP 62
|
#define TK_COMP 62
|
||||||
#define TK_DAYS 63
|
#define TK_DURATION 63
|
||||||
#define TK_NK_VARIABLE 64
|
#define TK_NK_VARIABLE 64
|
||||||
#define TK_FSYNC 65
|
#define TK_FSYNC 65
|
||||||
#define TK_MAXROWS 66
|
#define TK_MAXROWS 66
|
||||||
|
@ -184,76 +184,77 @@
|
||||||
#define TK_TRIGGER 166
|
#define TK_TRIGGER 166
|
||||||
#define TK_AT_ONCE 167
|
#define TK_AT_ONCE 167
|
||||||
#define TK_WINDOW_CLOSE 168
|
#define TK_WINDOW_CLOSE 168
|
||||||
#define TK_WATERMARK 169
|
#define TK_MAX_DELAY 169
|
||||||
#define TK_KILL 170
|
#define TK_WATERMARK 170
|
||||||
#define TK_CONNECTION 171
|
#define TK_KILL 171
|
||||||
#define TK_TRANSACTION 172
|
#define TK_CONNECTION 172
|
||||||
#define TK_BALANCE 173
|
#define TK_TRANSACTION 173
|
||||||
#define TK_VGROUP 174
|
#define TK_BALANCE 174
|
||||||
#define TK_MERGE 175
|
#define TK_VGROUP 175
|
||||||
#define TK_REDISTRIBUTE 176
|
#define TK_MERGE 176
|
||||||
#define TK_SPLIT 177
|
#define TK_REDISTRIBUTE 177
|
||||||
#define TK_SYNCDB 178
|
#define TK_SPLIT 178
|
||||||
#define TK_DELETE 179
|
#define TK_SYNCDB 179
|
||||||
#define TK_NULL 180
|
#define TK_DELETE 180
|
||||||
#define TK_NK_QUESTION 181
|
#define TK_NULL 181
|
||||||
#define TK_NK_ARROW 182
|
#define TK_NK_QUESTION 182
|
||||||
#define TK_ROWTS 183
|
#define TK_NK_ARROW 183
|
||||||
#define TK_TBNAME 184
|
#define TK_ROWTS 184
|
||||||
#define TK_QSTARTTS 185
|
#define TK_TBNAME 185
|
||||||
#define TK_QENDTS 186
|
#define TK_QSTARTTS 186
|
||||||
#define TK_WSTARTTS 187
|
#define TK_QENDTS 187
|
||||||
#define TK_WENDTS 188
|
#define TK_WSTARTTS 188
|
||||||
#define TK_WDURATION 189
|
#define TK_WENDTS 189
|
||||||
#define TK_CAST 190
|
#define TK_WDURATION 190
|
||||||
#define TK_NOW 191
|
#define TK_CAST 191
|
||||||
#define TK_TODAY 192
|
#define TK_NOW 192
|
||||||
#define TK_TIMEZONE 193
|
#define TK_TODAY 193
|
||||||
#define TK_COUNT 194
|
#define TK_TIMEZONE 194
|
||||||
#define TK_FIRST 195
|
#define TK_COUNT 195
|
||||||
#define TK_LAST 196
|
#define TK_FIRST 196
|
||||||
#define TK_LAST_ROW 197
|
#define TK_LAST 197
|
||||||
#define TK_BETWEEN 198
|
#define TK_LAST_ROW 198
|
||||||
#define TK_IS 199
|
#define TK_BETWEEN 199
|
||||||
#define TK_NK_LT 200
|
#define TK_IS 200
|
||||||
#define TK_NK_GT 201
|
#define TK_NK_LT 201
|
||||||
#define TK_NK_LE 202
|
#define TK_NK_GT 202
|
||||||
#define TK_NK_GE 203
|
#define TK_NK_LE 203
|
||||||
#define TK_NK_NE 204
|
#define TK_NK_GE 204
|
||||||
#define TK_MATCH 205
|
#define TK_NK_NE 205
|
||||||
#define TK_NMATCH 206
|
#define TK_MATCH 206
|
||||||
#define TK_CONTAINS 207
|
#define TK_NMATCH 207
|
||||||
#define TK_JOIN 208
|
#define TK_CONTAINS 208
|
||||||
#define TK_INNER 209
|
#define TK_JOIN 209
|
||||||
#define TK_SELECT 210
|
#define TK_INNER 210
|
||||||
#define TK_DISTINCT 211
|
#define TK_SELECT 211
|
||||||
#define TK_WHERE 212
|
#define TK_DISTINCT 212
|
||||||
#define TK_PARTITION 213
|
#define TK_WHERE 213
|
||||||
#define TK_BY 214
|
#define TK_PARTITION 214
|
||||||
#define TK_SESSION 215
|
#define TK_BY 215
|
||||||
#define TK_STATE_WINDOW 216
|
#define TK_SESSION 216
|
||||||
#define TK_SLIDING 217
|
#define TK_STATE_WINDOW 217
|
||||||
#define TK_FILL 218
|
#define TK_SLIDING 218
|
||||||
#define TK_VALUE 219
|
#define TK_FILL 219
|
||||||
#define TK_NONE 220
|
#define TK_VALUE 220
|
||||||
#define TK_PREV 221
|
#define TK_NONE 221
|
||||||
#define TK_LINEAR 222
|
#define TK_PREV 222
|
||||||
#define TK_NEXT 223
|
#define TK_LINEAR 223
|
||||||
#define TK_HAVING 224
|
#define TK_NEXT 224
|
||||||
#define TK_ORDER 225
|
#define TK_HAVING 225
|
||||||
#define TK_SLIMIT 226
|
#define TK_ORDER 226
|
||||||
#define TK_SOFFSET 227
|
#define TK_SLIMIT 227
|
||||||
#define TK_LIMIT 228
|
#define TK_SOFFSET 228
|
||||||
#define TK_OFFSET 229
|
#define TK_LIMIT 229
|
||||||
#define TK_ASC 230
|
#define TK_OFFSET 230
|
||||||
#define TK_NULLS 231
|
#define TK_ASC 231
|
||||||
#define TK_ID 232
|
#define TK_NULLS 232
|
||||||
#define TK_NK_BITNOT 233
|
#define TK_ID 233
|
||||||
#define TK_INSERT 234
|
#define TK_NK_BITNOT 234
|
||||||
#define TK_VALUES 235
|
#define TK_INSERT 235
|
||||||
#define TK_IMPORT 236
|
#define TK_VALUES 236
|
||||||
#define TK_NK_SEMI 237
|
#define TK_IMPORT 237
|
||||||
#define TK_FILE 238
|
#define TK_NK_SEMI 238
|
||||||
|
#define TK_FILE 239
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -32,9 +32,7 @@ typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
bool standby;
|
bool standby;
|
||||||
bool deploy;
|
bool deploy;
|
||||||
int8_t replica;
|
SReplica replica;
|
||||||
int8_t selfIndex;
|
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
} SMnodeOpt;
|
} SMnodeOpt;
|
||||||
|
|
||||||
|
@ -61,7 +59,13 @@ void mndClose(SMnode *pMnode);
|
||||||
* @param pMnode The mnode object.
|
* @param pMnode The mnode object.
|
||||||
*/
|
*/
|
||||||
int32_t mndStart(SMnode *pMnode);
|
int32_t mndStart(SMnode *pMnode);
|
||||||
void mndStop(SMnode *pMnode);
|
|
||||||
|
/**
|
||||||
|
* @brief Stop mnode
|
||||||
|
*
|
||||||
|
* @param pMnode The mnode object.
|
||||||
|
*/
|
||||||
|
void mndStop(SMnode *pMnode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get mnode monitor info.
|
* @brief Get mnode monitor info.
|
||||||
|
@ -73,16 +77,25 @@ void mndStop(SMnode *pMnode);
|
||||||
* @return int32_t 0 for success, -1 for failure.
|
* @return int32_t 0 for success, -1 for failure.
|
||||||
*/
|
*/
|
||||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant);
|
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get mnode loads for status msg.
|
||||||
|
*
|
||||||
|
* @param pMnode The mnode object.
|
||||||
|
* @param pLoad
|
||||||
|
* @return int32_t 0 for success, -1 for failure.
|
||||||
|
*/
|
||||||
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Process the read, write, sync request.
|
* @brief Process the rpc, sync request.
|
||||||
*
|
*
|
||||||
* @param pMsg The request msg.
|
* @param pMsg The request msg.
|
||||||
* @return int32_t 0 for success, -1 for failure.
|
* @return int32_t 0 for success, -1 for failure.
|
||||||
*/
|
*/
|
||||||
int32_t mndProcessRpcMsg(SRpcMsg *pMsg);
|
int32_t mndProcessRpcMsg(SRpcMsg *pMsg);
|
||||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
|
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
|
||||||
|
int32_t mndPreProcessMsg(SRpcMsg *pMsg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generate machine code
|
* @brief Generate machine code
|
||||||
|
|
|
@ -98,14 +98,15 @@ typedef struct SCatalogCfg {
|
||||||
uint32_t stbRentSec;
|
uint32_t stbRentSec;
|
||||||
} SCatalogCfg;
|
} SCatalogCfg;
|
||||||
|
|
||||||
typedef struct SSTableMetaVersion {
|
typedef struct SSTableVersion {
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
char stbName[TSDB_TABLE_NAME_LEN];
|
char stbName[TSDB_TABLE_NAME_LEN];
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
int16_t sversion;
|
int16_t sversion;
|
||||||
int16_t tversion;
|
int16_t tversion;
|
||||||
} SSTableMetaVersion;
|
int32_t smaVer;
|
||||||
|
} SSTableVersion;
|
||||||
|
|
||||||
typedef struct SDbVgVersion {
|
typedef struct SDbVgVersion {
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -267,7 +268,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t
|
||||||
|
|
||||||
int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList);
|
int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList);
|
||||||
|
|
||||||
int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableMetaVersion** stables, uint32_t* num);
|
int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion **stables, uint32_t *num);
|
||||||
|
|
||||||
int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbVgVersion** dbs, uint32_t* num);
|
int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbVgVersion** dbs, uint32_t* num);
|
||||||
|
|
||||||
|
@ -279,6 +280,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
|
||||||
|
|
||||||
int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
|
int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
|
||||||
|
|
||||||
|
int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp);
|
||||||
|
|
||||||
int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo);
|
int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo);
|
||||||
|
|
||||||
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass);
|
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass);
|
||||||
|
|
|
@ -139,6 +139,14 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_TOP_MERGE,
|
FUNCTION_TYPE_TOP_MERGE,
|
||||||
FUNCTION_TYPE_BOTTOM_PARTIAL,
|
FUNCTION_TYPE_BOTTOM_PARTIAL,
|
||||||
FUNCTION_TYPE_BOTTOM_MERGE,
|
FUNCTION_TYPE_BOTTOM_MERGE,
|
||||||
|
FUNCTION_TYPE_FIRST_PARTIAL,
|
||||||
|
FUNCTION_TYPE_FIRST_MERGE,
|
||||||
|
FUNCTION_TYPE_LAST_PARTIAL,
|
||||||
|
FUNCTION_TYPE_LAST_MERGE,
|
||||||
|
FUNCTION_TYPE_AVG_PARTIAL,
|
||||||
|
FUNCTION_TYPE_AVG_MERGE,
|
||||||
|
FUNCTION_TYPE_STDDEV_PARTIAL,
|
||||||
|
FUNCTION_TYPE_STDDEV_MERGE,
|
||||||
|
|
||||||
// user defined funcion
|
// user defined funcion
|
||||||
FUNCTION_TYPE_UDF = 10000
|
FUNCTION_TYPE_UDF = 10000
|
||||||
|
@ -176,6 +184,7 @@ bool fmIsRepeatScanFunc(int32_t funcId);
|
||||||
bool fmIsUserDefinedFunc(int32_t funcId);
|
bool fmIsUserDefinedFunc(int32_t funcId);
|
||||||
bool fmIsDistExecFunc(int32_t funcId);
|
bool fmIsDistExecFunc(int32_t funcId);
|
||||||
bool fmIsForbidFillFunc(int32_t funcId);
|
bool fmIsForbidFillFunc(int32_t funcId);
|
||||||
|
bool fmIsForbidStreamFunc(int32_t funcId);
|
||||||
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
||||||
|
|
||||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);
|
||||||
|
|
|
@ -89,6 +89,7 @@ typedef struct STableOptions {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char comment[TSDB_TB_COMMENT_LEN];
|
char comment[TSDB_TB_COMMENT_LEN];
|
||||||
double filesFactor;
|
double filesFactor;
|
||||||
|
int32_t delay;
|
||||||
SNodeList* pRollupFuncs;
|
SNodeList* pRollupFuncs;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
SNodeList* pSma;
|
SNodeList* pSma;
|
||||||
|
@ -286,9 +287,15 @@ typedef struct SKillStmt {
|
||||||
int32_t targetId;
|
int32_t targetId;
|
||||||
} SKillStmt;
|
} SKillStmt;
|
||||||
|
|
||||||
|
typedef struct SKillQueryStmt {
|
||||||
|
ENodeType type;
|
||||||
|
char queryId[TSDB_QUERY_ID_LEN];
|
||||||
|
} SKillQueryStmt;
|
||||||
|
|
||||||
typedef struct SStreamOptions {
|
typedef struct SStreamOptions {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
|
SNode* pDelay;
|
||||||
SNode* pWatermark;
|
SNode* pWatermark;
|
||||||
} SStreamOptions;
|
} SStreamOptions;
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
||||||
|
@ -252,22 +253,20 @@ typedef struct SNodeList {
|
||||||
SListCell* pTail;
|
SListCell* pTail;
|
||||||
} SNodeList;
|
} SNodeList;
|
||||||
|
|
||||||
#define SNodeptr void*
|
SNode* nodesMakeNode(ENodeType type);
|
||||||
|
void nodesDestroyNode(SNode* pNode);
|
||||||
SNodeptr nodesMakeNode(ENodeType type);
|
|
||||||
void nodesDestroyNode(SNodeptr pNode);
|
|
||||||
|
|
||||||
SNodeList* nodesMakeList();
|
SNodeList* nodesMakeList();
|
||||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListAppend(SNodeList* pList, SNode* pNode);
|
||||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode);
|
||||||
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode);
|
int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode);
|
||||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode);
|
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNode* pNode);
|
||||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
|
||||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||||
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index);
|
SNode* nodesListGetNode(SNodeList* pList, int32_t index);
|
||||||
void nodesDestroyList(SNodeList* pList);
|
void nodesDestroyList(SNodeList* pList);
|
||||||
// Only clear the linked list structure, without releasing the elements inside
|
// Only clear the linked list structure, without releasing the elements inside
|
||||||
void nodesClearList(SNodeList* pList);
|
void nodesClearList(SNodeList* pList);
|
||||||
|
@ -275,9 +274,9 @@ void nodesClearList(SNodeList* pList);
|
||||||
typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes;
|
typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes;
|
||||||
|
|
||||||
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
||||||
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
void nodesWalkExpr(SNode* pNode, FNodeWalker walker, void* pContext);
|
||||||
void nodesWalkExprs(SNodeList* pList, FNodeWalker walker, void* pContext);
|
void nodesWalkExprs(SNodeList* pList, FNodeWalker walker, void* pContext);
|
||||||
void nodesWalkExprPostOrder(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
void nodesWalkExprPostOrder(SNode* pNode, FNodeWalker walker, void* pContext);
|
||||||
void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext);
|
void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContext);
|
||||||
|
|
||||||
typedef EDealRes (*FNodeRewriter)(SNode** pNode, void* pContext);
|
typedef EDealRes (*FNodeRewriter)(SNode** pNode, void* pContext);
|
||||||
|
@ -286,13 +285,13 @@ void nodesRewriteExprs(SNodeList* pList, FNodeRewriter rewriter, void* pContext)
|
||||||
void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext);
|
void nodesRewriteExprPostOrder(SNode** pNode, FNodeRewriter rewriter, void* pContext);
|
||||||
void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext);
|
void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void* pContext);
|
||||||
|
|
||||||
bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
|
bool nodesEqualNode(const SNode* a, const SNode* b);
|
||||||
|
|
||||||
SNodeptr nodesCloneNode(const SNodeptr pNode);
|
SNode* nodesCloneNode(const SNode* pNode);
|
||||||
SNodeList* nodesCloneList(const SNodeList* pList);
|
SNodeList* nodesCloneList(const SNodeList* pList);
|
||||||
|
|
||||||
const char* nodesNodeName(ENodeType type);
|
const char* nodesNodeName(ENodeType type);
|
||||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen);
|
||||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||||
|
|
||||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||||
|
|
|
@ -34,7 +34,13 @@ typedef struct SLogicNode {
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
} SLogicNode;
|
} SLogicNode;
|
||||||
|
|
||||||
typedef enum EScanType { SCAN_TYPE_TAG = 1, SCAN_TYPE_TABLE, SCAN_TYPE_SYSTEM_TABLE, SCAN_TYPE_STREAM } EScanType;
|
typedef enum EScanType {
|
||||||
|
SCAN_TYPE_TAG = 1,
|
||||||
|
SCAN_TYPE_TABLE,
|
||||||
|
SCAN_TYPE_SYSTEM_TABLE,
|
||||||
|
SCAN_TYPE_STREAM,
|
||||||
|
SCAN_TYPE_TABLE_MERGE
|
||||||
|
} EScanType;
|
||||||
|
|
||||||
typedef struct SScanLogicNode {
|
typedef struct SScanLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
|
@ -262,6 +268,7 @@ typedef struct STableScanPhysiNode {
|
||||||
} STableScanPhysiNode;
|
} STableScanPhysiNode;
|
||||||
|
|
||||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
|
typedef STableScanPhysiNode STableMergeScanPhysiNode;
|
||||||
typedef STableScanPhysiNode SStreamScanPhysiNode;
|
typedef STableScanPhysiNode SStreamScanPhysiNode;
|
||||||
|
|
||||||
typedef struct SProjectPhysiNode {
|
typedef struct SProjectPhysiNode {
|
||||||
|
|
|
@ -336,22 +336,21 @@ typedef enum EQueryExecMode {
|
||||||
} EQueryExecMode;
|
} EQueryExecMode;
|
||||||
|
|
||||||
typedef struct SQuery {
|
typedef struct SQuery {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
EQueryExecMode execMode;
|
EQueryExecMode execMode;
|
||||||
bool haveResultSet;
|
bool haveResultSet;
|
||||||
SNode* pRoot;
|
SNode* pRoot;
|
||||||
int32_t numOfResCols;
|
int32_t numOfResCols;
|
||||||
SSchema* pResSchema;
|
SSchema* pResSchema;
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
SCmdMsgInfo* pCmdMsg;
|
SCmdMsgInfo* pCmdMsg;
|
||||||
int32_t msgType;
|
int32_t msgType;
|
||||||
SArray* pTableList;
|
SArray* pTableList;
|
||||||
SArray* pDbList;
|
SArray* pDbList;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
int32_t placeholderNum;
|
int32_t placeholderNum;
|
||||||
SArray* pPlaceholderValues;
|
SArray* pPlaceholderValues;
|
||||||
SNode* pPrepareRoot;
|
SNode* pPrepareRoot;
|
||||||
struct SParseMetaCache* pMetaCache;
|
|
||||||
} SQuery;
|
} SQuery;
|
||||||
|
|
||||||
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
||||||
|
|
|
@ -65,6 +65,7 @@ void qDestroyQuery(SQuery* pQueryNode);
|
||||||
|
|
||||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||||
int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid);
|
int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid);
|
||||||
|
void qCleanupKeywordsTable();
|
||||||
|
|
||||||
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash);
|
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash);
|
||||||
int32_t qResetStmtDataBlock(void* block, bool keepBuf);
|
int32_t qResetStmtDataBlock(void* block, bool keepBuf);
|
||||||
|
|
|
@ -47,8 +47,9 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TAOS_SYNC_PROPOSE_SUCCESS = 0,
|
TAOS_SYNC_PROPOSE_SUCCESS = 0,
|
||||||
TAOS_SYNC_PROPOSE_NOT_LEADER = 1,
|
TAOS_SYNC_PROPOSE_NOT_LEADER = 1,
|
||||||
TAOS_SYNC_PROPOSE_OTHER_ERROR = 2,
|
TAOS_SYNC_ONLY_ONE_REPLICA = 2,
|
||||||
TAOS_SYNC_ONLY_ONE_REPLICA = 3,
|
TAOS_SYNC_NOT_IN_NEW_CONFIG = 3,
|
||||||
|
TAOS_SYNC_OTHER_ERROR = 100,
|
||||||
} ESyncProposeCode;
|
} ESyncProposeCode;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -110,6 +111,7 @@ typedef struct SSyncFSM {
|
||||||
|
|
||||||
void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm);
|
void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm);
|
||||||
void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta);
|
void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta);
|
||||||
|
void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
|
||||||
|
|
||||||
int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
int32_t (*FpGetSnapshot)(struct SSyncFSM* pFsm, SSnapshot* pSnapshot);
|
||||||
|
|
||||||
|
@ -199,15 +201,13 @@ bool syncIsRestoreFinish(int64_t rid);
|
||||||
int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta);
|
int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta);
|
||||||
|
|
||||||
int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg);
|
int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg);
|
||||||
int32_t syncReconfigRaw(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg);
|
|
||||||
|
// build SRpcMsg, need to call syncPropose with SRpcMsg
|
||||||
|
int32_t syncReconfigBuild(int64_t rid, const SSyncCfg* pNewCfg, SRpcMsg* pRpcMsg);
|
||||||
|
|
||||||
int32_t syncLeaderTransfer(int64_t rid);
|
int32_t syncLeaderTransfer(int64_t rid);
|
||||||
int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader);
|
int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader);
|
||||||
|
|
||||||
// to be moved to static
|
|
||||||
void syncStartNormal(int64_t rid);
|
|
||||||
void syncStartStandBy(int64_t rid);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -467,6 +467,7 @@ typedef struct SyncLeaderTransfer {
|
||||||
SRaftId srcId;
|
SRaftId srcId;
|
||||||
SRaftId destId;
|
SRaftId destId;
|
||||||
*/
|
*/
|
||||||
|
SNodeInfo newNodeInfo;
|
||||||
SRaftId newLeaderId;
|
SRaftId newLeaderId;
|
||||||
} SyncLeaderTransfer;
|
} SyncLeaderTransfer;
|
||||||
|
|
||||||
|
|
|
@ -653,6 +653,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
|
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
|
||||||
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
|
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
|
||||||
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
|
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
@ -684,17 +685,23 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003)
|
#define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003)
|
||||||
|
|
||||||
//tsma
|
//tsma
|
||||||
#define TSDB_CODE_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x3100)
|
#define TSDB_CODE_TSMA_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x3100)
|
||||||
#define TSDB_CODE_TSMA_NO_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x3101)
|
#define TSDB_CODE_TSMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x3101)
|
||||||
#define TSDB_CODE_TSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3102)
|
#define TSDB_CODE_TSMA_NO_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x3102)
|
||||||
#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3103)
|
#define TSDB_CODE_TSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3103)
|
||||||
#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3104)
|
#define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3104)
|
||||||
#define TSDB_CODE_TSMA_RM_SKEY_IN_HASH TAOS_DEF_ERROR_CODE(0, 0x3105)
|
#define TSDB_CODE_TSMA_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x3105)
|
||||||
|
#define TSDB_CODE_TSMA_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x3106)
|
||||||
|
#define TSDB_CODE_TSMA_NO_INDEX_IN_CACHE TAOS_DEF_ERROR_CODE(0, 0x3107)
|
||||||
|
|
||||||
|
|
||||||
//rsma
|
//rsma
|
||||||
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
|
||||||
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
|
||||||
|
|
||||||
|
//index
|
||||||
|
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,8 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
|
||||||
#define TSDB_TB_COMMENT_LEN 1025
|
#define TSDB_TB_COMMENT_LEN 1025
|
||||||
|
|
||||||
|
#define TSDB_QUERY_ID_LEN 26
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
* In some scenarios uint16_t (0~65535) is used to store the row len.
|
||||||
* - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header.
|
* - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header.
|
||||||
|
@ -341,6 +343,9 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DB_SCHEMALESS_OFF 0
|
#define TSDB_DB_SCHEMALESS_OFF 0
|
||||||
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
||||||
|
|
||||||
|
// #define TSDB_MIN_ROLLUP_DELAY 1
|
||||||
|
// #define TSDB_MAX_ROLLUP_DELAY 10
|
||||||
|
// #define TSDB_DEFAULT_ROLLUP_DELAY 1
|
||||||
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
|
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
|
||||||
#define TSDB_MAX_ROLLUP_FILE_FACTOR 10
|
#define TSDB_MAX_ROLLUP_FILE_FACTOR 10
|
||||||
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1
|
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1
|
||||||
|
|
|
@ -99,15 +99,15 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
||||||
static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) {
|
static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalog *pCatalog) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
STableMetaBatchRsp batchMetaRsp = {0};
|
SSTbHbRsp hbRsp = {0};
|
||||||
if (tDeserializeSTableMetaBatchRsp(value, valueLen, &batchMetaRsp) != 0) {
|
if (tDeserializeSSTbHbRsp(value, valueLen, &hbRsp) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfBatchs = taosArrayGetSize(batchMetaRsp.pArray);
|
int32_t numOfMeta = taosArrayGetSize(hbRsp.pMetaRsp);
|
||||||
for (int32_t i = 0; i < numOfBatchs; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *rsp = taosArrayGet(batchMetaRsp.pArray, i);
|
STableMetaRsp *rsp = taosArrayGet(hbRsp.pMetaRsp, i);
|
||||||
|
|
||||||
if (rsp->numOfColumns < 0) {
|
if (rsp->numOfColumns < 0) {
|
||||||
tscDebug("hb remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
tscDebug("hb remove stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
||||||
|
@ -116,7 +116,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
tscDebug("hb update stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
tscDebug("hb update stb, db:%s, stb:%s", rsp->dbFName, rsp->stbName);
|
||||||
if (rsp->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (rsp->pSchemas[0].colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
tscError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", rsp->pSchemas[0].colId);
|
tscError("invalid colId[%" PRIi16 "] for the first column in table meta rsp msg", rsp->pSchemas[0].colId);
|
||||||
tFreeSTableMetaBatchRsp(&batchMetaRsp);
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,17 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tFreeSTableMetaBatchRsp(&batchMetaRsp);
|
int32_t numOfIndex = taosArrayGetSize(hbRsp.pIndexRsp);
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp *rsp = taosArrayGet(hbRsp.pIndexRsp, i);
|
||||||
|
|
||||||
|
catalogUpdateTableIndex(pCatalog, rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(hbRsp.pIndexRsp);
|
||||||
|
hbRsp.pIndexRsp = NULL;
|
||||||
|
|
||||||
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +465,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) {
|
int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) {
|
||||||
SSTableMetaVersion *stbs = NULL;
|
SSTableVersion *stbs = NULL;
|
||||||
uint32_t stbNum = 0;
|
uint32_t stbNum = 0;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -469,15 +479,16 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < stbNum; ++i) {
|
for (int32_t i = 0; i < stbNum; ++i) {
|
||||||
SSTableMetaVersion *stb = &stbs[i];
|
SSTableVersion *stb = &stbs[i];
|
||||||
stb->suid = htobe64(stb->suid);
|
stb->suid = htobe64(stb->suid);
|
||||||
stb->sversion = htons(stb->sversion);
|
stb->sversion = htons(stb->sversion);
|
||||||
stb->tversion = htons(stb->tversion);
|
stb->tversion = htons(stb->tversion);
|
||||||
|
stb->smaVer = htonl(stb->smaVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SKv kv = {
|
SKv kv = {
|
||||||
.key = HEARTBEAT_KEY_STBINFO,
|
.key = HEARTBEAT_KEY_STBINFO,
|
||||||
.valueLen = sizeof(SSTableMetaVersion) * stbNum,
|
.valueLen = sizeof(SSTableVersion) * stbNum,
|
||||||
.value = stbs,
|
.value = stbs,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -698,7 +709,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
// taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
||||||
|
|
||||||
taosThreadMutexLock(&clientHbMgr.lock);
|
taosThreadMutexLock(&clientHbMgr.lock);
|
||||||
taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr);
|
taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr);
|
||||||
|
|
|
@ -206,7 +206,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SRetrieveTableRsp* pRsp = NULL;
|
SRetrieveTableRsp* pRsp = NULL;
|
||||||
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
|
||||||
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, false);
|
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -233,9 +233,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SAppInstInfo* getAppInfo(SRequestObj* pRequest) {
|
static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscObj->pAppInfo; }
|
||||||
return pRequest->pTscObj->pAppInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
SRetrieveTableRsp* pRsp = NULL;
|
SRetrieveTableRsp* pRsp = NULL;
|
||||||
|
@ -259,7 +257,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||||
// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows);
|
// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
|
@ -323,7 +321,7 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) {
|
||||||
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pNodeList = taosArrayInit(5, sizeof(SQueryNodeLoad));
|
*pNodeList = taosArrayInit(5, sizeof(SQueryNodeLoad));
|
||||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
|
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
|
||||||
|
@ -401,21 +399,19 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) {
|
||||||
int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||||
tsem_init(&schdRspSem, 0, 0);
|
tsem_init(&schdRspSem, 0, 0);
|
||||||
|
|
||||||
SQueryResult res = {.code = 0, .numOfRows = 0};
|
SQueryResult res = {.code = 0, .numOfRows = 0};
|
||||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self
|
.requestObjRefId = pRequest->self};
|
||||||
};
|
SSchedulerReq req = {.pConn = &conn,
|
||||||
SSchedulerReq req = {.pConn = &conn,
|
.pNodeList = pNodeList,
|
||||||
.pNodeList = pNodeList,
|
.pDag = pDag,
|
||||||
.pDag = pDag,
|
.sql = pRequest->sqlstr,
|
||||||
.sql = pRequest->sqlstr,
|
.startTs = pRequest->metric.start,
|
||||||
.startTs = pRequest->metric.start,
|
.fp = schdExecCallback,
|
||||||
.fp = schdExecCallback,
|
.cbParam = &res};
|
||||||
.cbParam = &res
|
|
||||||
};
|
int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||||
|
|
||||||
int32_t code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
|
||||||
|
|
||||||
pRequest->body.resInfo.execRes = res.res;
|
pRequest->body.resInfo.execRes = res.res;
|
||||||
|
|
||||||
|
@ -455,21 +451,19 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
|
||||||
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) {
|
||||||
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter;
|
||||||
|
|
||||||
SQueryResult res = {0};
|
SQueryResult res = {0};
|
||||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self
|
.requestObjRefId = pRequest->self};
|
||||||
};
|
SSchedulerReq req = {.pConn = &conn,
|
||||||
SSchedulerReq req = {.pConn = &conn,
|
.pNodeList = pNodeList,
|
||||||
.pNodeList = pNodeList,
|
.pDag = pDag,
|
||||||
.pDag = pDag,
|
.sql = pRequest->sqlstr,
|
||||||
.sql = pRequest->sqlstr,
|
.startTs = pRequest->metric.start,
|
||||||
.startTs = pRequest->metric.start,
|
.fp = NULL,
|
||||||
.fp = NULL,
|
.cbParam = NULL};
|
||||||
.cbParam = NULL
|
|
||||||
};
|
int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob, &res);
|
||||||
|
|
||||||
int32_t code = schedulerExecJob(&req,&pRequest->body.queryJob, &res);
|
|
||||||
pRequest->body.resInfo.execRes = res.res;
|
pRequest->body.resInfo.execRes = res.res;
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -482,7 +476,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
return pRequest->code;
|
return pRequest->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type || TDMT_VND_CREATE_TABLE == pRequest->type) {
|
if (TDMT_VND_SUBMIT == pRequest->type || TDMT_VND_DELETE == pRequest->type ||
|
||||||
|
TDMT_VND_CREATE_TABLE == pRequest->type) {
|
||||||
pRequest->body.resInfo.numOfRows = res.numOfRows;
|
pRequest->body.resInfo.numOfRows = res.numOfRows;
|
||||||
|
|
||||||
if (pRequest->body.queryJob != 0) {
|
if (pRequest->body.queryJob != 0) {
|
||||||
|
@ -495,9 +490,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
||||||
return pRequest->code;
|
return pRequest->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) {
|
int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArray* pArray = NULL;
|
SArray* pArray = NULL;
|
||||||
SSubmitRsp* pRsp = (SSubmitRsp*)res;
|
SSubmitRsp* pRsp = (SSubmitRsp*)res;
|
||||||
if (pRsp->nBlocks <= 0) {
|
if (pRsp->nBlocks <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -519,7 +514,7 @@ int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog
|
||||||
taosArrayPush(pArray, &tbSver);
|
taosArrayPush(pArray, &tbSver);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = *epset};
|
.mgmtEps = *epset};
|
||||||
|
@ -532,7 +527,7 @@ _return:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet *epset) {
|
int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog, SEpSet* epset) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SArray* pArray = NULL;
|
SArray* pArray = NULL;
|
||||||
SArray* pTbArray = (SArray*)res;
|
SArray* pTbArray = (SArray*)res;
|
||||||
|
@ -553,7 +548,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog,
|
||||||
taosArrayPush(pArray, &tbSver);
|
taosArrayPush(pArray, &tbSver);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = *epset};
|
.mgmtEps = *epset};
|
||||||
|
@ -575,15 +570,15 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCatalog* pCatalog = NULL;
|
SCatalog* pCatalog = NULL;
|
||||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||||
|
|
||||||
int32_t code = catalogGetHandle(pAppInfo->clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pAppInfo->clusterId, &pCatalog);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp);
|
SEpSet epset = getEpSet_s(&pAppInfo->mgmtEp);
|
||||||
SQueryExecRes* pRes = &pRequest->body.resInfo.execRes;
|
SQueryExecRes* pRes = &pRequest->body.resInfo.execRes;
|
||||||
|
|
||||||
switch (pRes->msgType) {
|
switch (pRes->msgType) {
|
||||||
|
@ -601,8 +596,8 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
tscError("0x%"PRIx64", invalid exec result for request type %d, reqId:0x%"PRIx64, pRequest->self,
|
tscError("0x%" PRIx64 ", invalid exec result for request type %d, reqId:0x%" PRIx64, pRequest->self,
|
||||||
pRequest->type, pRequest->requestId);
|
pRequest->type, pRequest->requestId);
|
||||||
code = TSDB_CODE_APP_ERROR;
|
code = TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,13 +605,13 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
||||||
SRequestObj* pRequest = (SRequestObj*) param;
|
SRequestObj* pRequest = (SRequestObj*)param;
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||||
tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code),
|
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||||
pRequest->retry, pRequest->requestId);
|
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||||
pRequest->prevCode = code;
|
pRequest->prevCode = code;
|
||||||
doAsyncQuery(pRequest, true);
|
doAsyncQuery(pRequest, true);
|
||||||
return;
|
return;
|
||||||
|
@ -624,7 +619,7 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = handleQueryExecRsp(pRequest);
|
code = handleQueryExecRsp(pRequest);
|
||||||
ASSERT(pRequest->code == TSDB_CODE_SUCCESS);
|
ASSERT(pRequest->code == TSDB_CODE_SUCCESS);
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,35 +722,34 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pNodeList);
|
code = qCreateQueryPlan(&cxt, &pRequest->body.pDag, pNodeList);
|
||||||
if (code) {
|
if (code) {
|
||||||
tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId);
|
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
|
pRequest->requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SRequestConnInfo conn = {.pTrans = pAppInfo->pTransporter,
|
SRequestConnInfo conn = {
|
||||||
.requestId = pRequest->requestId,
|
.pTrans = pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self};
|
||||||
.requestObjRefId = pRequest->self
|
|
||||||
};
|
|
||||||
SSchedulerReq req = {.pConn = &conn,
|
SSchedulerReq req = {.pConn = &conn,
|
||||||
.pNodeList = pNodeList,
|
.pNodeList = pNodeList,
|
||||||
.pDag = pRequest->body.pDag,
|
.pDag = pRequest->body.pDag,
|
||||||
.sql = pRequest->sqlstr,
|
.sql = pRequest->sqlstr,
|
||||||
.startTs = pRequest->metric.start,
|
.startTs = pRequest->metric.start,
|
||||||
.fp = schedulerExecCb,
|
.fp = schedulerExecCb,
|
||||||
.cbParam = pRequest
|
.cbParam = pRequest};
|
||||||
};
|
|
||||||
code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
code = schedulerAsyncExecJob(&req, &pRequest->body.queryJob);
|
||||||
} else {
|
} else {
|
||||||
tscError("0x%"PRIx64" failed to create query plan, code:%s 0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId);
|
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||||
|
pRequest->requestId);
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo not to be released here
|
// todo not to be released here
|
||||||
taosArrayDestroy(pNodeList);
|
taosArrayDestroy(pNodeList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_EXEC_MODE_EMPTY_RESULT:
|
case QUERY_EXEC_MODE_EMPTY_RESULT:
|
||||||
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -786,7 +780,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
|
||||||
|
@ -989,23 +983,22 @@ void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg,
|
||||||
switch (pSendInfo->target.type) {
|
switch (pSendInfo->target.type) {
|
||||||
case TARGET_TYPE_MNODE:
|
case TARGET_TYPE_MNODE:
|
||||||
if (NULL == pTscObj) {
|
if (NULL == pTscObj) {
|
||||||
tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
tscError("mnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEpSet* pOrig = &pTscObj->pAppInfo->mgmtEp.epSet;
|
SEpSet* pOrig = &pTscObj->pAppInfo->mgmtEp.epSet;
|
||||||
SEp* pOrigEp = &pOrig->eps[pOrig->inUse];
|
SEp* pOrigEp = &pOrig->eps[pOrig->inUse];
|
||||||
SEp* pNewEp = &pEpSet->eps[pEpSet->inUse];
|
SEp* pNewEp = &pEpSet->eps[pEpSet->inUse];
|
||||||
tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client",
|
tscDebug("mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in client", pOrig->inUse, pOrig->numOfEps,
|
||||||
pOrig->inUse, pOrig->numOfEps, pOrigEp->fqdn, pOrigEp->port,
|
pOrigEp->fqdn, pOrigEp->port, pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port);
|
||||||
pEpSet->inUse, pEpSet->numOfEps, pNewEp->fqdn, pNewEp->port);
|
|
||||||
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, pEpSet);
|
updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, pEpSet);
|
||||||
break;
|
break;
|
||||||
case TARGET_TYPE_VNODE: {
|
case TARGET_TYPE_VNODE: {
|
||||||
if (NULL == pTscObj) {
|
if (NULL == pTscObj) {
|
||||||
tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
tscError("vnode epset changed but not able to update it, msg:%s, reqObjRefId:%" PRIx64,
|
||||||
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
TMSG_INFO(pMsg->msgType), pSendInfo->requestObjRefId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,14 +1408,14 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
p += sizeof(uint64_t);
|
p += sizeof(uint64_t);
|
||||||
|
|
||||||
// check fields
|
// check fields
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int16_t type = *(int16_t*) p;
|
int16_t type = *(int16_t*)p;
|
||||||
p += sizeof(int16_t);
|
p += sizeof(int16_t);
|
||||||
|
|
||||||
int32_t bytes = *(int32_t*) p;
|
int32_t bytes = *(int32_t*)p;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
|
||||||
// ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);
|
/*ASSERT(type == pFields[i].type && bytes == pFields[i].bytes);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t* colLength = (int32_t*)p;
|
int32_t* colLength = (int32_t*)p;
|
||||||
|
|
|
@ -25,12 +25,13 @@
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
|
||||||
#define TSC_VAR_NOT_RELEASE 1
|
#define TSC_VAR_NOT_RELEASE 1
|
||||||
#define TSC_VAR_RELEASED 0
|
#define TSC_VAR_RELEASED 0
|
||||||
|
|
||||||
static int32_t sentinel = TSC_VAR_NOT_RELEASE;
|
static int32_t sentinel = TSC_VAR_NOT_RELEASE;
|
||||||
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt);
|
static int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt);
|
||||||
|
|
||||||
int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
int taos_options(TSDB_OPTION option, const void *arg, ...) {
|
||||||
static int32_t lock = 0;
|
static int32_t lock = 0;
|
||||||
|
@ -61,6 +62,9 @@ void taos_cleanup(void) {
|
||||||
|
|
||||||
cleanupTaskQueue();
|
cleanupTaskQueue();
|
||||||
|
|
||||||
|
fmFuncMgtDestroy();
|
||||||
|
qCleanupKeywordsTable();
|
||||||
|
|
||||||
id = clientConnRefPool;
|
id = clientConnRefPool;
|
||||||
clientConnRefPool = -1;
|
clientConnRefPool = -1;
|
||||||
taosCloseRef(id);
|
taosCloseRef(id);
|
||||||
|
@ -177,8 +181,8 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
||||||
return pResInfo->userFields;
|
return pResInfo->userFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void syncQueryFn(void* param, void* res, int32_t code) {
|
static void syncQueryFn(void *param, void *res, int32_t code) {
|
||||||
SSyncQueryParam* pParam = param;
|
SSyncQueryParam *pParam = param;
|
||||||
pParam->pRequest = res;
|
pParam->pRequest = res;
|
||||||
pParam->pRequest->code = code;
|
pParam->pRequest->code = code;
|
||||||
|
|
||||||
|
@ -190,10 +194,10 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STscObj* pTscObj = (STscObj*)taos;
|
STscObj *pTscObj = (STscObj *)taos;
|
||||||
|
|
||||||
#if SYNC_ON_TOP_OF_ASYNC
|
#if SYNC_ON_TOP_OF_ASYNC
|
||||||
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
SSyncQueryParam *param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||||
tsem_init(¶m->sem, 0, 0);
|
tsem_init(¶m->sem, 0, 0);
|
||||||
|
|
||||||
taos_query_a(pTscObj, sql, syncQueryFn, param);
|
taos_query_a(pTscObj, sql, syncQueryFn, param);
|
||||||
|
@ -606,16 +610,30 @@ const char *taos_get_server_info(TAOS *taos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct SqlParseWrapper {
|
typedef struct SqlParseWrapper {
|
||||||
SParseContext* pCtx;
|
SParseContext *pCtx;
|
||||||
SCatalogReq catalogReq;
|
SCatalogReq catalogReq;
|
||||||
SRequestObj* pRequest;
|
SRequestObj *pRequest;
|
||||||
SQuery* pQuery;
|
SQuery *pQuery;
|
||||||
} SqlParseWrapper;
|
} SqlParseWrapper;
|
||||||
|
|
||||||
void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
|
static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
|
||||||
SqlParseWrapper *pWrapper = (SqlParseWrapper*) param;
|
taosArrayDestroy(pWrapper->catalogReq.pDbVgroup);
|
||||||
SQuery* pQuery = pWrapper->pQuery;
|
taosArrayDestroy(pWrapper->catalogReq.pDbCfg);
|
||||||
SRequestObj* pRequest = pWrapper->pRequest;
|
taosArrayDestroy(pWrapper->catalogReq.pDbInfo);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pTableMeta);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pTableHash);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pUdf);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pIndex);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pUser);
|
||||||
|
taosArrayDestroy(pWrapper->catalogReq.pTableIndex);
|
||||||
|
taosMemoryFree(pWrapper->pCtx);
|
||||||
|
taosMemoryFree(pWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
|
||||||
|
SqlParseWrapper *pWrapper = (SqlParseWrapper *)param;
|
||||||
|
SQuery *pQuery = pWrapper->pQuery;
|
||||||
|
SRequestObj *pRequest = pWrapper->pRequest;
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery);
|
code = qAnalyseSqlSemantic(pWrapper->pCtx, &pWrapper->catalogReq, pResultMeta, pQuery);
|
||||||
|
@ -630,22 +648,22 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
|
||||||
TSWAP(pRequest->dbList, (pQuery)->pDbList);
|
TSWAP(pRequest->dbList, (pQuery)->pDbList);
|
||||||
TSWAP(pRequest->tableList, (pQuery)->pTableList);
|
TSWAP(pRequest->tableList, (pQuery)->pTableList);
|
||||||
|
|
||||||
taosMemoryFree(pWrapper);
|
destorySqlParseWrapper(pWrapper);
|
||||||
launchAsyncQuery(pRequest, pQuery);
|
launchAsyncQuery(pRequest, pQuery);
|
||||||
} else {
|
} else {
|
||||||
|
destorySqlParseWrapper(pWrapper);
|
||||||
tscDebug("error happens, code:%d", code);
|
tscDebug("error happens, code:%d", code);
|
||||||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||||
tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code),
|
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||||
pRequest->retry, pRequest->requestId);
|
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||||
pRequest->prevCode = code;
|
pRequest->prevCode = code;
|
||||||
doAsyncQuery(pRequest, true);
|
doAsyncQuery(pRequest, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to app directly
|
// return to app directly
|
||||||
taosMemoryFree(pWrapper);
|
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self,
|
||||||
tscError("0x%" PRIx64 " error occurs, code:%s, return to user app, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
tstrerror(code), pRequest->requestId);
|
||||||
pRequest->requestId);
|
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
}
|
}
|
||||||
|
@ -670,7 +688,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
||||||
}
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = NULL;
|
SRequestObj *pRequest = NULL;
|
||||||
int32_t code = buildRequest(taos, sql, sqlLen, &pRequest);
|
int32_t code = buildRequest(taos, sql, sqlLen, &pRequest);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
fp(param, NULL, terrno);
|
fp(param, NULL, terrno);
|
||||||
|
@ -678,11 +696,11 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->body.queryFp = fp;
|
pRequest->body.queryFp = fp;
|
||||||
pRequest->body.param = param;
|
pRequest->body.param = param;
|
||||||
doAsyncQuery(pRequest, false);
|
doAsyncQuery(pRequest, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) {
|
int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
|
||||||
const STscObj *pTscObj = pRequest->pTscObj;
|
const STscObj *pTscObj = pRequest->pTscObj;
|
||||||
|
|
||||||
*pCxt = taosMemoryCalloc(1, sizeof(SParseContext));
|
*pCxt = taosMemoryCalloc(1, sizeof(SParseContext));
|
||||||
|
@ -690,28 +708,30 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
**pCxt = (SParseContext){.requestId = pRequest->requestId,
|
**pCxt = (SParseContext){
|
||||||
.requestRid = pRequest->self,
|
.requestId = pRequest->requestId,
|
||||||
.acctId = pTscObj->acctId,
|
.requestRid = pRequest->self,
|
||||||
.db = pRequest->pDb,
|
.acctId = pTscObj->acctId,
|
||||||
.topicQuery = false,
|
.db = pRequest->pDb,
|
||||||
.pSql = pRequest->sqlstr,
|
.topicQuery = false,
|
||||||
.sqlLen = pRequest->sqlLen,
|
.pSql = pRequest->sqlstr,
|
||||||
.pMsg = pRequest->msgBuf,
|
.sqlLen = pRequest->sqlLen,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
.pMsg = pRequest->msgBuf,
|
||||||
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
.pStmtCb = NULL,
|
.pTransporter = pTscObj->pAppInfo->pTransporter,
|
||||||
.pUser = pTscObj->user,
|
.pStmtCb = NULL,
|
||||||
.schemalessType = pTscObj->schemalessType,
|
.pUser = pTscObj->user,
|
||||||
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
.schemalessType = pTscObj->schemalessType,
|
||||||
.async = true,};
|
.isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
|
||||||
|
.async = true,
|
||||||
|
};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) {
|
void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
||||||
SParseContext* pCxt = NULL;
|
SParseContext *pCxt = NULL;
|
||||||
STscObj *pTscObj = pRequest->pTscObj;
|
STscObj *pTscObj = pRequest->pTscObj;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) {
|
if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) {
|
||||||
code = pRequest->prevCode;
|
code = pRequest->prevCode;
|
||||||
|
@ -748,28 +768,29 @@ void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) {
|
||||||
pWrapper->pRequest = pRequest;
|
pWrapper->pRequest = pRequest;
|
||||||
pWrapper->catalogReq = catalogReq;
|
pWrapper->catalogReq = catalogReq;
|
||||||
|
|
||||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||||
.requestId = pCxt->requestId,
|
.requestId = pCxt->requestId,
|
||||||
.requestObjRefId = pCxt->requestRid,
|
.requestObjRefId = pCxt->requestRid,
|
||||||
.mgmtEps = pCxt->mgmtEpSet};
|
.mgmtEps = pCxt->mgmtEpSet};
|
||||||
|
|
||||||
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId,
|
code = catalogAsyncGetAllMeta(pCxt->pCatalog, &conn, pRequest->requestId, &catalogReq, retrieveMetaCallback, pWrapper,
|
||||||
&catalogReq, retrieveMetaCallback, pWrapper, &pRequest->body.queryJob);
|
&pRequest->body.queryJob);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
tscError("0x%"PRIx64" error happens, code:%d - %s, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId);
|
tscError("0x%" PRIx64 " error happens, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code),
|
||||||
|
pRequest->requestId);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
pRequest->body.queryFp(pRequest->body.param, pRequest, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fetchCallback(void* pResult, void* param, int32_t code) {
|
static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||||
SRequestObj* pRequest = (SRequestObj*) param;
|
SRequestObj *pRequest = (SRequestObj *)param;
|
||||||
|
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
pResultInfo->pData = pResult;
|
pResultInfo->pData = pResult;
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
|
@ -785,7 +806,8 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->code = setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp*)pResultInfo->pData, pResultInfo->convertUcs4, false);
|
pRequest->code =
|
||||||
|
setQueryResultFromRsp(pResultInfo, (SRetrieveTableRsp *)pResultInfo->pData, pResultInfo->convertUcs4, false);
|
||||||
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
if (pRequest->code != TSDB_CODE_SUCCESS) {
|
||||||
pResultInfo->numOfRows = 0;
|
pResultInfo->numOfRows = 0;
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
|
@ -801,7 +823,7 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT (res != NULL && fp != NULL);
|
ASSERT(res != NULL && fp != NULL);
|
||||||
|
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
pRequest->body.fetchFp = fp;
|
pRequest->body.fetchFp = fp;
|
||||||
|
@ -825,7 +847,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
schedulerAsyncFetchRows(pRequest->body.queryJob, fetchCallback, pRequest);
|
schedulerAsyncFetchRows(pRequest->body.queryJob, fetchCallback, pRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) {
|
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT(res != NULL && fp != NULL);
|
ASSERT(res != NULL && fp != NULL);
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
|
|
||||||
|
@ -838,9 +860,9 @@ void taos_fetch_raw_block_a(TAOS_RES* res, __taos_async_fn_t fp, void* param) {
|
||||||
taos_fetch_rows_a(res, fp, param);
|
taos_fetch_rows_a(res, fp, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* taos_get_raw_block(TAOS_RES* res) {
|
const void *taos_get_raw_block(TAOS_RES *res) {
|
||||||
ASSERT(res != NULL);
|
ASSERT(res != NULL);
|
||||||
SRequestObj* pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
|
|
||||||
return pRequest->body.resInfo.pData;
|
return pRequest->body.resInfo.pData;
|
||||||
}
|
}
|
||||||
|
@ -924,26 +946,25 @@ int taos_stmt_set_tags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) {
|
||||||
return stmtSetTbTags(stmt, tags);
|
return stmtSetTbTags(stmt, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) { return taos_stmt_set_tbname(stmt, name); }
|
int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name) { return taos_stmt_set_tbname(stmt, name); }
|
||||||
|
|
||||||
int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) {
|
int taos_stmt_get_tag_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
|
||||||
if (stmt == NULL || NULL == fieldNum) {
|
if (stmt == NULL || NULL == fieldNum) {
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
tscError("NULL parameter for %s", __FUNCTION__);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmtGetTagFields(stmt, fieldNum, fields);
|
return stmtGetTagFields(stmt, fieldNum, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt_get_col_fields(TAOS_STMT *stmt, int* fieldNum, TAOS_FIELD_E** fields) {
|
int taos_stmt_get_col_fields(TAOS_STMT *stmt, int *fieldNum, TAOS_FIELD_E **fields) {
|
||||||
if (stmt == NULL || NULL == fieldNum) {
|
if (stmt == NULL || NULL == fieldNum) {
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
tscError("NULL parameter for %s", __FUNCTION__);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmtGetColFields(stmt, fieldNum, fields);
|
return stmtGetColFields(stmt, fieldNum, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,4 +1123,3 @@ int taos_stmt_close(TAOS_STMT *stmt) {
|
||||||
|
|
||||||
return stmtClose(stmt);
|
return stmtClose(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -132,6 +132,7 @@ typedef struct {
|
||||||
// statistics
|
// statistics
|
||||||
int64_t pollCnt;
|
int64_t pollCnt;
|
||||||
// offset
|
// offset
|
||||||
|
int64_t committedOffset;
|
||||||
int64_t currentOffset;
|
int64_t currentOffset;
|
||||||
// connection info
|
// connection info
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
|
@ -193,6 +194,26 @@ typedef struct {
|
||||||
void* userParam;
|
void* userParam;
|
||||||
} SMqCommitCbParam;
|
} SMqCommitCbParam;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tmq_t* tmq;
|
||||||
|
int8_t automatic;
|
||||||
|
int8_t async;
|
||||||
|
int8_t freeOffsets;
|
||||||
|
int32_t waitingRspNum;
|
||||||
|
int32_t totalRspNum;
|
||||||
|
tmq_resp_err_t rspErr;
|
||||||
|
tmq_commit_cb* userCb;
|
||||||
|
SArray* successfulOffsets;
|
||||||
|
SArray* failedOffsets;
|
||||||
|
void* userParam;
|
||||||
|
tsem_t rspSem;
|
||||||
|
} SMqCommitCbParamSet;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMqCommitCbParamSet* params;
|
||||||
|
STqOffset* pOffset;
|
||||||
|
} SMqCommitCbParam2;
|
||||||
|
|
||||||
tmq_conf_t* tmq_conf_new() {
|
tmq_conf_t* tmq_conf_new() {
|
||||||
tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t));
|
tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t));
|
||||||
conf->withTbName = false;
|
conf->withTbName = false;
|
||||||
|
@ -343,6 +364,139 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tmqCommitCb2(void* param, const SDataBuf* pBuf, int32_t code) {
|
||||||
|
SMqCommitCbParam2* pParam = (SMqCommitCbParam2*)param;
|
||||||
|
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
||||||
|
// push into array
|
||||||
|
if (code == 0) {
|
||||||
|
taosArrayPush(pParamSet->failedOffsets, &pParam->pOffset);
|
||||||
|
} else {
|
||||||
|
taosArrayPush(pParamSet->successfulOffsets, &pParam->pOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// count down waiting rsp
|
||||||
|
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||||
|
ASSERT(waitingRspNum >= 0);
|
||||||
|
|
||||||
|
if (waitingRspNum == 0) {
|
||||||
|
// if no more waiting rsp
|
||||||
|
if (pParamSet->async) {
|
||||||
|
// call async cb func
|
||||||
|
if (pParamSet->automatic && pParamSet->tmq->commitCb) {
|
||||||
|
pParamSet->tmq->commitCb(pParamSet->tmq, pParamSet->rspErr, NULL, pParamSet->tmq->commitCbUserParam);
|
||||||
|
} else if (!pParamSet->automatic && pParamSet->userCb) {
|
||||||
|
// sem post
|
||||||
|
pParamSet->userCb(pParamSet->tmq, pParamSet->rspErr, NULL, pParamSet->userParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree);
|
||||||
|
taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tmqCommitInner2(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_t automatic, int8_t async,
|
||||||
|
tmq_commit_cb* userCb, void* userParam) {
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet));
|
||||||
|
if (pParamSet == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pParamSet->tmq = tmq;
|
||||||
|
pParamSet->automatic = automatic;
|
||||||
|
pParamSet->async = async;
|
||||||
|
pParamSet->freeOffsets = 1;
|
||||||
|
pParamSet->userCb = userCb;
|
||||||
|
pParamSet->userParam = userParam;
|
||||||
|
tsem_init(&pParamSet->rspSem, 0, 0);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||||
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
|
for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||||
|
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, i);
|
||||||
|
STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset));
|
||||||
|
if (pOffset == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int32_t tlen = strlen(tmq->groupId);
|
||||||
|
memcpy(pOffset->subKey, tmq->groupId, tlen);
|
||||||
|
pOffset->subKey[tlen] = TMQ_SEPARATOR;
|
||||||
|
strcpy(pOffset->subKey + tlen + 1, pTopic->topicName);
|
||||||
|
int32_t len;
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSTqOffset, pOffset, len, code);
|
||||||
|
if (code < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
|
||||||
|
((SMsgHead*)buf)->vgId = htonl(pVg->vgId);
|
||||||
|
|
||||||
|
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||||
|
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, abuf, len);
|
||||||
|
tEncodeSTqOffset(&encoder, pOffset);
|
||||||
|
|
||||||
|
// build param
|
||||||
|
SMqCommitCbParam2* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam2));
|
||||||
|
pParam->params = pParamSet;
|
||||||
|
pParam->pOffset = pOffset;
|
||||||
|
|
||||||
|
// build send info
|
||||||
|
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
|
if (pMsgSendInfo == NULL) {
|
||||||
|
// TODO
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pMsgSendInfo->msgInfo = (SDataBuf){
|
||||||
|
.pData = buf,
|
||||||
|
.len = len,
|
||||||
|
.handle = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
pMsgSendInfo->requestId = generateRequestId();
|
||||||
|
pMsgSendInfo->requestObjRefId = 0;
|
||||||
|
pMsgSendInfo->param = pParam;
|
||||||
|
pMsgSendInfo->fp = tmqCommitCb2;
|
||||||
|
pMsgSendInfo->msgType = TDMT_MND_MQ_COMMIT_OFFSET;
|
||||||
|
// send msg
|
||||||
|
|
||||||
|
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
int64_t transporterId = 0;
|
||||||
|
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, pMsgSendInfo);
|
||||||
|
pParamSet->waitingRspNum++;
|
||||||
|
pParamSet->totalRspNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!async) {
|
||||||
|
tsem_wait(&pParamSet->rspSem);
|
||||||
|
code = pParamSet->rspErr;
|
||||||
|
tsem_destroy(&pParamSet->rspSem);
|
||||||
|
} else {
|
||||||
|
code = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != 0 && async) {
|
||||||
|
if (automatic) {
|
||||||
|
tmq->commitCb(tmq, code, NULL, tmq->commitCbUserParam);
|
||||||
|
} else {
|
||||||
|
userCb(tmq, code, NULL, userParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!async) {
|
||||||
|
taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree);
|
||||||
|
taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tmqCommitInner(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_t automatic, int8_t async,
|
int32_t tmqCommitInner(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int8_t automatic, int8_t async,
|
||||||
tmq_commit_cb* userCb, void* userParam) {
|
tmq_commit_cb* userCb, void* userParam) {
|
||||||
SMqCMCommitOffsetReq req;
|
SMqCMCommitOffsetReq req;
|
||||||
|
@ -890,12 +1044,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
|
||||||
sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId);
|
sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId);
|
||||||
int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey));
|
int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey));
|
||||||
int64_t offset = pVgEp->offset;
|
int64_t offset = pVgEp->offset;
|
||||||
tscDebug("consumer %ld epoch %d vg %d offset og to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset);
|
tscDebug("consumer %ld(epoch %d) original offset of vg %d is %ld", tmq->consumerId, epoch, pVgEp->vgId, offset);
|
||||||
if (pOffset != NULL) {
|
if (pOffset != NULL) {
|
||||||
offset = *pOffset;
|
offset = *pOffset;
|
||||||
tscDebug("consumer %ld epoch %d vg %d found %s", tmq->consumerId, epoch, pVgEp->vgId, vgKey);
|
tscDebug("consumer %ld(epoch %d) receive offset of vg %d, full key is %s", tmq->consumerId, epoch, pVgEp->vgId,
|
||||||
|
vgKey);
|
||||||
}
|
}
|
||||||
tscDebug("consumer %ld epoch %d vg %d offset set to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset);
|
tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset);
|
||||||
SMqClientVg clientVg = {
|
SMqClientVg clientVg = {
|
||||||
.pollCnt = 0,
|
.pollCnt = 0,
|
||||||
.currentOffset = offset,
|
.currentOffset = offset,
|
||||||
|
@ -1226,9 +1381,8 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
|
if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) {
|
||||||
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
|
SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper;
|
||||||
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
|
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
|
||||||
/*printf("handle poll rsp %d\n", rspMsg->head.mqMsgType);*/
|
int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
|
||||||
if (pollRspWrapper->msg.head.epoch == atomic_load_32(&tmq->epoch)) {
|
if (pollRspWrapper->msg.head.epoch == consumerEpoch) {
|
||||||
/*printf("epoch match\n");*/
|
|
||||||
SMqClientVg* pVg = pollRspWrapper->vgHandle;
|
SMqClientVg* pVg = pollRspWrapper->vgHandle;
|
||||||
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
|
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
|
||||||
pVg->currentOffset = pollRspWrapper->msg.rspOffset;
|
pVg->currentOffset = pollRspWrapper->msg.rspOffset;
|
||||||
|
@ -1243,7 +1397,8 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
return pRsp;
|
return pRsp;
|
||||||
} else {
|
} else {
|
||||||
/*printf("epoch mismatch\n");*/
|
tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", pollRspWrapper->msg.head.epoch,
|
||||||
|
consumerEpoch);
|
||||||
taosFreeQitem(pollRspWrapper);
|
taosFreeQitem(pollRspWrapper);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1263,10 +1418,14 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
|
||||||
SMqRspObj* rspObj;
|
SMqRspObj* rspObj;
|
||||||
int64_t startTime = taosGetTimestampMs();
|
int64_t startTime = taosGetTimestampMs();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
tmqHandleAllDelayedTask(tmq);
|
||||||
|
tmqPollImpl(tmq, timeout);
|
||||||
rspObj = tmqHandleAllRsp(tmq, timeout, false);
|
rspObj = tmqHandleAllRsp(tmq, timeout, false);
|
||||||
if (rspObj) {
|
if (rspObj) {
|
||||||
return (TAOS_RES*)rspObj;
|
return (TAOS_RES*)rspObj;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// in no topic status also need process delayed task
|
// in no topic status also need process delayed task
|
||||||
if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__INIT) {
|
if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__INIT) {
|
||||||
|
@ -1359,8 +1518,7 @@ const char* tmq_get_table_name(TAOS_RES* res) {
|
||||||
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
pRspObj->resIter >= pRspObj->rsp.blockNum) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
const char* name = taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter);
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1260,4 +1260,28 @@ TEST(testCase, sml_16368_Test) {
|
||||||
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS);
|
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS);
|
||||||
ASSERT_EQ(taos_errno(pRes), 0);
|
ASSERT_EQ(taos_errno(pRes), 0);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
TEST(testCase, sml_dup_time_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists dup_time schemaless 1");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
const char *sql[] = {
|
||||||
|
//"test_ms,t0=t c0=f 1626006833641",
|
||||||
|
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||||
|
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||||
|
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||||
|
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
|
||||||
|
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000"
|
||||||
|
};
|
||||||
|
pRes = taos_query(taos, "use dup_time");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0);
|
||||||
|
ASSERT_EQ(taos_errno(pRes), 0);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -91,8 +91,8 @@ static const SSysDbTableSchema userDBSchema[] = {
|
||||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
{.name = "single_stable_model", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
// {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
// {.name = "schemaless", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||||
{.name = "retension", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "retention", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
|
||||||
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
|
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
|
||||||
};
|
};
|
||||||
|
@ -137,7 +137,7 @@ static const SSysDbTableSchema streamSchema[] = {
|
||||||
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||||
{.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema userTblsSchema[] = {
|
static const SSysDbTableSchema userTblsSchema[] = {
|
||||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
|
@ -221,7 +221,9 @@ static const SSysDbTableSchema transSchema[] = {
|
||||||
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
{.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||||
{.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "last_action_info",
|
||||||
|
.bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE,
|
||||||
|
.type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const SSysDbTableSchema configSchema[] = {
|
static const SSysDbTableSchema configSchema[] = {
|
||||||
|
@ -314,8 +316,6 @@ static const SSysDbTableSchema querySchema[] = {
|
||||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const SSysTableMeta perfsMeta[] = {
|
static const SSysTableMeta perfsMeta[] = {
|
||||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
||||||
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)},
|
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)},
|
||||||
|
|
|
@ -1708,6 +1708,7 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
||||||
pTag->keyLen = strlen(pTag->key);
|
pTag->keyLen = strlen(pTag->key);
|
||||||
pTag->type = TSDB_DATA_TYPE_UBIGINT;
|
pTag->type = TSDB_DATA_TYPE_UBIGINT;
|
||||||
pTag->u = groupId;
|
pTag->u = groupId;
|
||||||
|
pTag->length = sizeof(uint64_t);
|
||||||
taosArrayPush(tags, &pTag);
|
taosArrayPush(tags, &pTag);
|
||||||
|
|
||||||
void* cname = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + 1);
|
void* cname = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN + 1);
|
||||||
|
@ -1728,173 +1729,6 @@ char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId) {
|
||||||
return rname.childTableName;
|
return rname.childTableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, bool createTb, int64_t suid,
|
|
||||||
const char* stbFullName, int32_t vgId) {
|
|
||||||
SSubmitReq* ret = NULL;
|
|
||||||
SArray* tagArray = taosArrayInit(1, sizeof(STagVal));
|
|
||||||
if (!tagArray) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cal size
|
|
||||||
int32_t cap = sizeof(SSubmitReq);
|
|
||||||
int32_t sz = taosArrayGetSize(pBlocks);
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
|
||||||
int32_t rows = pDataBlock->info.rows;
|
|
||||||
// TODO min
|
|
||||||
int32_t rowSize = pDataBlock->info.rowSize;
|
|
||||||
int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);
|
|
||||||
int32_t schemaLen = 0;
|
|
||||||
|
|
||||||
if (createTb) {
|
|
||||||
SVCreateTbReq createTbReq = {0};
|
|
||||||
char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
|
||||||
createTbReq.name = cname;
|
|
||||||
createTbReq.flags = 0;
|
|
||||||
createTbReq.type = TSDB_CHILD_TABLE;
|
|
||||||
createTbReq.ctb.suid = suid;
|
|
||||||
|
|
||||||
STagVal tagVal = {.cid = 1,
|
|
||||||
.type = TSDB_DATA_TYPE_UBIGINT,
|
|
||||||
.pData = (uint8_t*)&pDataBlock->info.groupId,
|
|
||||||
.nData = sizeof(uint64_t)};
|
|
||||||
STag* pTag = NULL;
|
|
||||||
taosArrayClear(tagArray);
|
|
||||||
taosArrayPush(tagArray, &tagVal);
|
|
||||||
tTagNew(tagArray, 1, false, &pTag);
|
|
||||||
if (pTag == NULL) {
|
|
||||||
tdDestroySVCreateTbReq(&createTbReq);
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
createTbReq.ctb.pTag = (uint8_t*)pTag;
|
|
||||||
|
|
||||||
int32_t code;
|
|
||||||
tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code);
|
|
||||||
|
|
||||||
tdDestroySVCreateTbReq(&createTbReq);
|
|
||||||
if (code < 0) {
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign data
|
|
||||||
// TODO
|
|
||||||
ret = taosMemoryCalloc(1, cap + 46);
|
|
||||||
ret = POINTER_SHIFT(ret, 46);
|
|
||||||
ret->header.vgId = vgId;
|
|
||||||
ret->version = htonl(1);
|
|
||||||
ret->length = sizeof(SSubmitReq);
|
|
||||||
ret->numOfBlocks = htonl(sz);
|
|
||||||
|
|
||||||
void* submitBlk = POINTER_SHIFT(ret, sizeof(SSubmitReq));
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
|
||||||
|
|
||||||
SSubmitBlk* blkHead = submitBlk;
|
|
||||||
blkHead->numOfRows = htons(pDataBlock->info.rows);
|
|
||||||
blkHead->sversion = htonl(pTSchema->version);
|
|
||||||
// TODO
|
|
||||||
blkHead->suid = htobe64(suid);
|
|
||||||
// uid is assigned by vnode
|
|
||||||
blkHead->uid = 0;
|
|
||||||
|
|
||||||
int32_t rows = pDataBlock->info.rows;
|
|
||||||
/*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/
|
|
||||||
/*blkHead->dataLen = htonl(rows * maxLen);*/
|
|
||||||
blkHead->dataLen = 0;
|
|
||||||
|
|
||||||
void* blockData = POINTER_SHIFT(submitBlk, sizeof(SSubmitBlk));
|
|
||||||
|
|
||||||
int32_t schemaLen = 0;
|
|
||||||
if (createTb) {
|
|
||||||
SVCreateTbReq createTbReq = {0};
|
|
||||||
char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
|
||||||
createTbReq.name = cname;
|
|
||||||
createTbReq.flags = 0;
|
|
||||||
createTbReq.type = TSDB_CHILD_TABLE;
|
|
||||||
createTbReq.ctb.suid = suid;
|
|
||||||
|
|
||||||
STagVal tagVal = {.cid = 1,
|
|
||||||
.type = TSDB_DATA_TYPE_UBIGINT,
|
|
||||||
.pData = (uint8_t*)&pDataBlock->info.groupId,
|
|
||||||
.nData = sizeof(uint64_t)};
|
|
||||||
taosArrayClear(tagArray);
|
|
||||||
taosArrayPush(tagArray, &tagVal);
|
|
||||||
STag* pTag = NULL;
|
|
||||||
tTagNew(tagArray, 1, false, &pTag);
|
|
||||||
if (pTag == NULL) {
|
|
||||||
tdDestroySVCreateTbReq(&createTbReq);
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
taosMemoryFreeClear(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
createTbReq.ctb.pTag = (uint8_t*)pTag;
|
|
||||||
|
|
||||||
int32_t code;
|
|
||||||
tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code);
|
|
||||||
if (code < 0) {
|
|
||||||
tdDestroySVCreateTbReq(&createTbReq);
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
taosMemoryFreeClear(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SEncoder encoder = {0};
|
|
||||||
tEncoderInit(&encoder, blockData, schemaLen);
|
|
||||||
code = tEncodeSVCreateTbReq(&encoder, &createTbReq);
|
|
||||||
tEncoderClear(&encoder);
|
|
||||||
tdDestroySVCreateTbReq(&createTbReq);
|
|
||||||
|
|
||||||
if (code < 0) {
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
taosMemoryFreeClear(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
blkHead->schemaLen = htonl(schemaLen);
|
|
||||||
|
|
||||||
STSRow* rowData = POINTER_SHIFT(blockData, schemaLen);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < rows; j++) {
|
|
||||||
SRowBuilder rb = {0};
|
|
||||||
tdSRowInit(&rb, pTSchema->version);
|
|
||||||
tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen);
|
|
||||||
tdSRowResetBuf(&rb, rowData);
|
|
||||||
|
|
||||||
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
|
||||||
const STColumn* pColumn = &pTSchema->columns[k];
|
|
||||||
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k);
|
|
||||||
if (colDataIsNull_s(pColData, j)) {
|
|
||||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k);
|
|
||||||
} else {
|
|
||||||
void* data = colDataGetData(pColData, j);
|
|
||||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
|
||||||
rowData = POINTER_SHIFT(rowData, rowLen);
|
|
||||||
blkHead->dataLen += rowLen;
|
|
||||||
}
|
|
||||||
int32_t dataLen = blkHead->dataLen;
|
|
||||||
blkHead->dataLen = htonl(dataLen);
|
|
||||||
|
|
||||||
ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
|
||||||
blkHead = POINTER_SHIFT(blkHead, schemaLen + dataLen);
|
|
||||||
/*submitBlk = blkHead;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->length = htonl(ret->length);
|
|
||||||
taosArrayDestroy(tagArray);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols,
|
void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols,
|
||||||
int8_t needCompress) {
|
int8_t needCompress) {
|
||||||
// todo extract method
|
// todo extract method
|
||||||
|
|
|
@ -692,6 +692,7 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
|
||||||
void tFreeSMAltertbReq(SMAlterStbReq *pReq) {
|
void tFreeSMAltertbReq(SMAlterStbReq *pReq) {
|
||||||
taosArrayDestroy(pReq->pFields);
|
taosArrayDestroy(pReq->pFields);
|
||||||
pReq->pFields = NULL;
|
pReq->pFields = NULL;
|
||||||
|
taosMemoryFreeClear(pReq->comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSEpSet(void *buf, int32_t bufLen, const SEpSet *pEpset) {
|
int32_t tSerializeSEpSet(void *buf, int32_t bufLen, const SEpSet *pEpset) {
|
||||||
|
@ -2437,6 +2438,10 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->tbName) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pRsp->dbFName) < 0) return -1;
|
||||||
|
if (tEncodeU64(&encoder, pRsp->suid) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pRsp->version) < 0) return -1;
|
||||||
int32_t num = taosArrayGetSize(pRsp->pIndex);
|
int32_t num = taosArrayGetSize(pRsp->pIndex);
|
||||||
if (tEncodeI32(&encoder, num) < 0) return -1;
|
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
|
@ -2471,6 +2476,10 @@ int32_t tDeserializeSTableIndexRsp(void *buf, int32_t bufLen, STableIndexRsp *pR
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->tbName) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, pRsp->dbFName) < 0) return -1;
|
||||||
|
if (tDecodeU64(&decoder, &pRsp->suid) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pRsp->version) < 0) return -1;
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
|
@ -2630,18 +2639,35 @@ int32_t tSerializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp)
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatchRsp *pRsp) {
|
int32_t tSerializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp);
|
||||||
if (tEncodeI32(&encoder, numOfBatch) < 0) return -1;
|
if (tEncodeI32(&encoder, numOfMeta) < 0) return -1;
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pArray, i);
|
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pMetaRsp, i);
|
||||||
if (tEncodeSTableMetaRsp(&encoder, pMetaRsp) < 0) return -1;
|
if (tEncodeSTableMetaRsp(&encoder, pMetaRsp) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp);
|
||||||
|
if (tEncodeI32(&encoder, numOfIndex) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i);
|
||||||
|
if (tEncodeCStr(&encoder, pIndexRsp->tbName) < 0) return -1;
|
||||||
|
if (tEncodeCStr(&encoder, pIndexRsp->dbFName) < 0) return -1;
|
||||||
|
if (tEncodeU64(&encoder, pIndexRsp->suid) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pIndexRsp->version) < 0) return -1;
|
||||||
|
int32_t num = taosArrayGetSize(pIndexRsp->pIndex);
|
||||||
|
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
STableIndexInfo *pInfo = (STableIndexInfo *)taosArrayGet(pIndexRsp->pIndex, i);
|
||||||
|
if (tSerializeSTableIndexInfo(&encoder, pInfo) < 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2661,26 +2687,58 @@ int32_t tDeserializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatchRsp *pRsp) {
|
int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
int32_t numOfMeta = 0;
|
||||||
if (tDecodeI32(&decoder, &numOfBatch) < 0) return -1;
|
if (tDecodeI32(&decoder, &numOfMeta) < 0) return -1;
|
||||||
|
pRsp->pMetaRsp = taosArrayInit(numOfMeta, sizeof(STableMetaRsp));
|
||||||
pRsp->pArray = taosArrayInit(numOfBatch, sizeof(STableMetaRsp));
|
if (pRsp->pMetaRsp == NULL) {
|
||||||
if (pRsp->pArray == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
STableMetaRsp tableMetaRsp = {0};
|
STableMetaRsp tableMetaRsp = {0};
|
||||||
if (tDecodeSTableMetaRsp(&decoder, &tableMetaRsp) < 0) return -1;
|
if (tDecodeSTableMetaRsp(&decoder, &tableMetaRsp) < 0) return -1;
|
||||||
taosArrayPush(pRsp->pArray, &tableMetaRsp);
|
taosArrayPush(pRsp->pMetaRsp, &tableMetaRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t numOfIndex = 0;
|
||||||
|
if (tDecodeI32(&decoder, &numOfIndex) < 0) return -1;
|
||||||
|
|
||||||
|
pRsp->pIndexRsp = taosArrayInit(numOfIndex, sizeof(STableIndexRsp));
|
||||||
|
if (pRsp->pIndexRsp == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp tableIndexRsp = {0};
|
||||||
|
if (tDecodeCStrTo(&decoder, tableIndexRsp.tbName) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(&decoder, tableIndexRsp.dbFName) < 0) return -1;
|
||||||
|
if (tDecodeU64(&decoder, &tableIndexRsp.suid) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &tableIndexRsp.version) < 0) return -1;
|
||||||
|
int32_t num = 0;
|
||||||
|
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||||
|
if (num > 0) {
|
||||||
|
tableIndexRsp.pIndex = taosArrayInit(num, sizeof(STableIndexInfo));
|
||||||
|
if (NULL == tableIndexRsp.pIndex) return -1;
|
||||||
|
STableIndexInfo info;
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
if (tDeserializeSTableIndexInfo(&decoder, &info) < 0) return -1;
|
||||||
|
if (NULL == taosArrayPush(tableIndexRsp.pIndex, &info)) {
|
||||||
|
taosMemoryFree(info.expr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosArrayPush(pRsp->pIndexRsp, &tableIndexRsp);
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -2689,14 +2747,32 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc
|
||||||
|
|
||||||
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
|
void tFreeSTableMetaRsp(STableMetaRsp *pRsp) { taosMemoryFreeClear(pRsp->pSchemas); }
|
||||||
|
|
||||||
void tFreeSTableMetaBatchRsp(STableMetaBatchRsp *pRsp) {
|
void tFreeSTableIndexRsp(void *info) {
|
||||||
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
|
if (NULL == info) {
|
||||||
for (int32_t i = 0; i < numOfBatch; ++i) {
|
return;
|
||||||
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pArray, i);
|
}
|
||||||
|
|
||||||
|
STableIndexRsp *pInfo = (STableIndexRsp *)info;
|
||||||
|
|
||||||
|
taosArrayDestroyEx(pInfo->pIndex, tFreeSTableIndexInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tFreeSSTbHbRsp(SSTbHbRsp *pRsp) {
|
||||||
|
int32_t numOfMeta = taosArrayGetSize(pRsp->pMetaRsp);
|
||||||
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
|
STableMetaRsp *pMetaRsp = taosArrayGet(pRsp->pMetaRsp, i);
|
||||||
tFreeSTableMetaRsp(pMetaRsp);
|
tFreeSTableMetaRsp(pMetaRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pRsp->pArray);
|
taosArrayDestroy(pRsp->pMetaRsp);
|
||||||
|
|
||||||
|
int32_t numOfIndex = taosArrayGetSize(pRsp->pIndexRsp);
|
||||||
|
for (int32_t i = 0; i < numOfIndex; ++i) {
|
||||||
|
STableIndexRsp *pIndexRsp = taosArrayGet(pRsp->pIndexRsp, i);
|
||||||
|
tFreeSTableIndexRsp(pIndexRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pRsp->pIndexRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSShowRsp(void *buf, int32_t bufLen, SShowRsp *pRsp) {
|
int32_t tSerializeSShowRsp(void *buf, int32_t bufLen, SShowRsp *pRsp) {
|
||||||
|
@ -3293,8 +3369,7 @@ int32_t tSerializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq)
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->connId) < 0) return -1;
|
if (tEncodeCStr(&encoder, pReq->queryStrId) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pReq->queryId) < 0) return -1;
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -3307,8 +3382,7 @@ int32_t tDeserializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->connId) < 0) return -1;
|
if (tDecodeCStrTo(&decoder, pReq->queryStrId) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &pReq->queryId) < 0) return -1;
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -3506,6 +3580,33 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) {
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
|
if (tEncodeI8(&encoder, pReq->standby) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSSetStandbyReq(void *buf, int32_t bufLen, SSetStandbyReq *pReq) {
|
||||||
|
SDecoder decoder = {0};
|
||||||
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||||
|
if (tDecodeI8(&decoder, &pReq->standby) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) {
|
int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -3897,7 +3998,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma, bool deepCopy) {
|
||||||
if (tDecodeI8(pCoder, &pSma->version) < 0) return -1;
|
if (tDecodeI8(pCoder, &pSma->version) < 0) return -1;
|
||||||
if (tDecodeI8(pCoder, &pSma->intervalUnit) < 0) return -1;
|
if (tDecodeI8(pCoder, &pSma->intervalUnit) < 0) return -1;
|
||||||
if (tDecodeI8(pCoder, &pSma->slidingUnit) < 0) return -1;
|
if (tDecodeI8(pCoder, &pSma->slidingUnit) < 0) return -1;
|
||||||
|
@ -3909,17 +4010,30 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
||||||
if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->dstTbUid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->dstTbUid) < 0) return -1;
|
||||||
if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1;
|
if (deepCopy) {
|
||||||
|
if (tDecodeCStrAlloc(pCoder, &pSma->dstTbName) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->offset) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->offset) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->sliding) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->sliding) < 0) return -1;
|
||||||
if (pSma->exprLen > 0) {
|
if (pSma->exprLen > 0) {
|
||||||
if (tDecodeCStr(pCoder, &pSma->expr) < 0) return -1;
|
if (deepCopy) {
|
||||||
|
if (tDecodeCStrAlloc(pCoder, &pSma->expr) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tDecodeCStr(pCoder, &pSma->expr) < 0) return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pSma->expr = NULL;
|
pSma->expr = NULL;
|
||||||
}
|
}
|
||||||
if (pSma->tagsFilterLen > 0) {
|
if (pSma->tagsFilterLen > 0) {
|
||||||
if (tDecodeCStr(pCoder, &pSma->tagsFilter) < 0) return -1;
|
if (deepCopy) {
|
||||||
|
if (tDecodeCStrAlloc(pCoder, &pSma->tagsFilter) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tDecodeCStr(pCoder, &pSma->tagsFilter) < 0) return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pSma->tagsFilter = NULL;
|
pSma->tagsFilter = NULL;
|
||||||
}
|
}
|
||||||
|
@ -3942,7 +4056,7 @@ int32_t tEncodeSVCreateTSmaReq(SEncoder *pCoder, const SVCreateTSmaReq *pReq) {
|
||||||
int32_t tDecodeSVCreateTSmaReq(SDecoder *pCoder, SVCreateTSmaReq *pReq) {
|
int32_t tDecodeSVCreateTSmaReq(SDecoder *pCoder, SVCreateTSmaReq *pReq) {
|
||||||
if (tStartDecode(pCoder) < 0) return -1;
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
tDecodeTSma(pCoder, pReq);
|
tDecodeTSma(pCoder, pReq, false);
|
||||||
|
|
||||||
tEndDecode(pCoder);
|
tEndDecode(pCoder);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4064,6 +4178,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
if (tEncodeI32(&encoder, sqlLen) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
if (tEncodeI32(&encoder, astLen) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1;
|
if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1;
|
||||||
|
if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1;
|
||||||
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1;
|
||||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
||||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
||||||
|
@ -4090,6 +4205,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
|
||||||
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &sqlLen) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &astLen) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1;
|
if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1;
|
||||||
|
if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1;
|
||||||
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1;
|
||||||
|
|
||||||
if (sqlLen > 0) {
|
if (sqlLen > 0) {
|
||||||
|
@ -4746,3 +4862,31 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp *pRsp) {
|
||||||
taosMemoryFree(pRsp->pMeta);
|
taosMemoryFree(pRsp->pMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSTqOffset(SEncoder *pEncoder, const STqOffset *pOffset) {
|
||||||
|
if (tEncodeI8(pEncoder, pOffset->type) < 0) return -1;
|
||||||
|
if (pOffset->type == TMQ_OFFSET__SNAPSHOT) {
|
||||||
|
if (tEncodeI64(pEncoder, pOffset->uid) < 0) return -1;
|
||||||
|
if (tEncodeI64(pEncoder, pOffset->ts) < 0) return -1;
|
||||||
|
} else if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
|
if (tEncodeI64(pEncoder, pOffset->version) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
if (tEncodeCStr(pEncoder, pOffset->subKey) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeSTqOffset(SDecoder *pDecoder, STqOffset *pOffset) {
|
||||||
|
if (tDecodeI8(pDecoder, &pOffset->type) < 0) return -1;
|
||||||
|
if (pOffset->type == TMQ_OFFSET__SNAPSHOT) {
|
||||||
|
if (tDecodeI64(pDecoder, &pOffset->uid) < 0) return -1;
|
||||||
|
if (tDecodeI64(pDecoder, &pOffset->ts) < 0) return -1;
|
||||||
|
} else if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||||
|
if (tDecodeI64(pDecoder, &pOffset->version) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
if (tDecodeCStrTo(pDecoder, pOffset->subKey) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -34,39 +34,31 @@ typedef struct SMnodeMgmt {
|
||||||
SSingleWorker writeWorker;
|
SSingleWorker writeWorker;
|
||||||
SSingleWorker syncWorker;
|
SSingleWorker syncWorker;
|
||||||
SSingleWorker monitorWorker;
|
SSingleWorker monitorWorker;
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
|
||||||
int8_t replica;
|
|
||||||
bool stopped;
|
bool stopped;
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
} SMnodeMgmt;
|
} SMnodeMgmt;
|
||||||
|
|
||||||
// mmFile.c
|
// mmFile.c
|
||||||
int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed);
|
int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed);
|
||||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed);
|
int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed);
|
||||||
|
|
||||||
// mmInt.c
|
|
||||||
int32_t mmAcquire(SMnodeMgmt *pMgmt);
|
|
||||||
void mmRelease(SMnodeMgmt *pMgmt);
|
|
||||||
|
|
||||||
// mmHandle.c
|
// mmHandle.c
|
||||||
SArray *mmGetMsgHandles();
|
SArray *mmGetMsgHandles();
|
||||||
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|
||||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg);
|
|
||||||
|
|
||||||
// mmWorker.c
|
// mmWorker.c
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
||||||
void mmStopWorker(SMnodeMgmt *pMgmt);
|
void mmStopWorker(SMnodeMgmt *pMgmt);
|
||||||
int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||||
int32_t mmPutRpcMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
|
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mmInt.h"
|
#include "mmInt.h"
|
||||||
|
|
||||||
int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
|
int32_t mmReadFile(SMnodeMgmt *pMgmt, SReplica *pReplica, bool *pDeployed) {
|
||||||
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 4096;
|
int32_t maxLen = 4096;
|
||||||
|
@ -52,61 +52,54 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
|
||||||
}
|
}
|
||||||
*pDeployed = deployed->valueint;
|
*pDeployed = deployed->valueint;
|
||||||
|
|
||||||
cJSON *mnodes = cJSON_GetObjectItem(root, "mnodes");
|
cJSON *id = cJSON_GetObjectItem(root, "id");
|
||||||
if (mnodes != NULL) {
|
if (id) {
|
||||||
if (!mnodes || mnodes->type != cJSON_Array) {
|
if (id->type != cJSON_Number) {
|
||||||
dError("failed to read %s since nodes not found", file);
|
dError("failed to read %s since id not found", file);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
if (pReplica) {
|
||||||
pMgmt->replica = cJSON_GetArraySize(mnodes);
|
|
||||||
if (pMgmt->replica <= 0 || pMgmt->replica > TSDB_MAX_REPLICA) {
|
|
||||||
dError("failed to read %s since mnodes size %d invalid", file, pMgmt->replica);
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMgmt->replica; ++i) {
|
|
||||||
cJSON *node = cJSON_GetArrayItem(mnodes, i);
|
|
||||||
if (node == NULL) break;
|
|
||||||
|
|
||||||
SReplica *pReplica = &pMgmt->replicas[i];
|
|
||||||
|
|
||||||
cJSON *id = cJSON_GetObjectItem(node, "id");
|
|
||||||
if (!id || id->type != cJSON_Number) {
|
|
||||||
dError("failed to read %s since id not found", file);
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
pReplica->id = id->valueint;
|
pReplica->id = id->valueint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cJSON *fqdn = cJSON_GetObjectItem(node, "fqdn");
|
cJSON *fqdn = cJSON_GetObjectItem(root, "fqdn");
|
||||||
if (!fqdn || fqdn->type != cJSON_String || fqdn->valuestring == NULL) {
|
if (fqdn) {
|
||||||
dError("failed to read %s since fqdn not found", file);
|
if (fqdn->type != cJSON_String || fqdn->valuestring == NULL) {
|
||||||
goto _OVER;
|
dError("failed to read %s since fqdn not found", file);
|
||||||
}
|
goto _OVER;
|
||||||
|
}
|
||||||
|
if (pReplica) {
|
||||||
tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN);
|
tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cJSON *port = cJSON_GetObjectItem(node, "port");
|
cJSON *port = cJSON_GetObjectItem(root, "port");
|
||||||
if (!port || port->type != cJSON_Number) {
|
if (port) {
|
||||||
dError("failed to read %s since port not found", file);
|
if (port->type != cJSON_Number) {
|
||||||
goto _OVER;
|
dError("failed to read %s since port not found", file);
|
||||||
}
|
goto _OVER;
|
||||||
pReplica->port = port->valueint;
|
}
|
||||||
|
if (pReplica) {
|
||||||
|
pReplica->port = (uint16_t)port->valueint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (content != NULL) taosMemoryFree(content);
|
if (content != NULL) taosMemoryFree(content);
|
||||||
if (root != NULL) cJSON_Delete(root);
|
if (root != NULL) cJSON_Delete(root);
|
||||||
if (pFile != NULL) taosCloseFile(&pFile);
|
if (pFile != NULL) taosCloseFile(&pFile);
|
||||||
|
if (code == 0) {
|
||||||
|
dDebug("succcessed to read file %s, deployed:%d", file, *pDeployed);
|
||||||
|
}
|
||||||
|
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
|
int32_t mmWriteFile(SMnodeMgmt *pMgmt, const SReplica *pReplica, bool deployed) {
|
||||||
char file[PATH_MAX] = {0};
|
char file[PATH_MAX] = {0};
|
||||||
char realfile[PATH_MAX] = {0};
|
char realfile[PATH_MAX] = {0};
|
||||||
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
|
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
|
||||||
|
@ -124,26 +117,11 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
|
||||||
char *content = taosMemoryCalloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
|
if (pReplica != NULL && pReplica->id > 0) {
|
||||||
int8_t replica = (pMsg != NULL ? pMsg->replica : pMgmt->replica);
|
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
||||||
if (replica > 0) {
|
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
||||||
len += snprintf(content + len, maxLen - len, " \"mnodes\": [{\n");
|
len += snprintf(content + len, maxLen - len, " \"port\": %u\n,", pReplica->port);
|
||||||
for (int32_t i = 0; i < replica; ++i) {
|
|
||||||
SReplica *pReplica = &pMgmt->replicas[i];
|
|
||||||
if (pMsg != NULL) {
|
|
||||||
pReplica = &pMsg->replicas[i];
|
|
||||||
}
|
|
||||||
len += snprintf(content + len, maxLen - len, " \"id\": %d,\n", pReplica->id);
|
|
||||||
len += snprintf(content + len, maxLen - len, " \"fqdn\": \"%s\",\n", pReplica->fqdn);
|
|
||||||
len += snprintf(content + len, maxLen - len, " \"port\": %u\n", pReplica->port);
|
|
||||||
if (i < replica - 1) {
|
|
||||||
len += snprintf(content + len, maxLen - len, " },{\n");
|
|
||||||
} else {
|
|
||||||
len += snprintf(content + len, maxLen - len, " }],\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
|
len += snprintf(content + len, maxLen - len, " \"deployed\": %d\n", deployed);
|
||||||
len += snprintf(content + len, maxLen - len, "}\n");
|
len += snprintf(content + len, maxLen - len, "}\n");
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,6 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
|
||||||
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->grant);
|
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->grant);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
|
||||||
pInfo->isMnode = 1;
|
|
||||||
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonMmInfo mmInfo = {0};
|
SMonMmInfo mmInfo = {0};
|
||||||
mmGetMonitorInfo(pMgmt, &mmInfo);
|
mmGetMonitorInfo(pMgmt, &mmInfo);
|
||||||
|
@ -50,6 +45,11 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
||||||
|
pInfo->isMnode = 1;
|
||||||
|
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
SMonMloadInfo mloads = {0};
|
SMonMloadInfo mloads = {0};
|
||||||
mmGetMnodeLoads(pMgmt, &mloads);
|
mmGetMnodeLoads(pMgmt, &mloads);
|
||||||
|
@ -90,7 +90,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
SMnodeMgmt mgmt = {0};
|
SMnodeMgmt mgmt = {0};
|
||||||
mgmt.path = pInput->path;
|
mgmt.path = pInput->path;
|
||||||
mgmt.name = pInput->name;
|
mgmt.name = pInput->name;
|
||||||
if (mmWriteFile(&mgmt, &createReq, deployed) != 0) {
|
if (mmWriteFile(&mgmt, &createReq.replicas[0], deployed) != 0) {
|
||||||
dError("failed to write mnode file since %s", terrstr());
|
dError("failed to write mnode file since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -126,115 +126,119 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
SArray *mmGetMsgHandles() {
|
SArray *mmGetMsgHandles() {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SArray *pArray = taosArrayInit(64, sizeof(SMgmtHandle));
|
SArray *pArray = taosArrayInit(128, sizeof(SMgmtHandle));
|
||||||
if (pArray == NULL) goto _OVER;
|
if (pArray == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_QNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONNECT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_ACCT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_ACCT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_USER, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_MNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_QNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_QNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_QNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_QNODE_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_QNODE_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_BNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_BNODE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_COMPACT_DB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_COMPACT_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_DB_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_VGROUP_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_REDISTRIBUTE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_REDISTRIBUTE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_TABLE_INDEX, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_TABLE_INDEX, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TOPIC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SUBSCRIBE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_ASK_EP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_DROP_CGROUP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_MQ_COMMIT_OFFSET, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_TRANS, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_QUERY, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY, mmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ static bool mmDeployRequired(const SMgmtInputOpt *pInput) {
|
||||||
static int32_t mmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
static int32_t mmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||||
SMnodeMgmt mgmt = {0};
|
SMnodeMgmt mgmt = {0};
|
||||||
mgmt.path = pInput->path;
|
mgmt.path = pInput->path;
|
||||||
if (mmReadFile(&mgmt, required) != 0) {
|
if (mmReadFile(&mgmt, NULL, required) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,33 +43,19 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu
|
||||||
pOption->deploy = true;
|
pOption->deploy = true;
|
||||||
pOption->msgCb = pMgmt->msgCb;
|
pOption->msgCb = pMgmt->msgCb;
|
||||||
pOption->dnodeId = pMgmt->pData->dnodeId;
|
pOption->dnodeId = pMgmt->pData->dnodeId;
|
||||||
|
pOption->replica.id = 1;
|
||||||
pOption->replica = 1;
|
pOption->replica.port = tsServerPort;
|
||||||
pOption->selfIndex = 0;
|
tstrncpy(pOption->replica.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||||
|
|
||||||
SReplica *pReplica = &pOption->replicas[0];
|
|
||||||
pReplica->id = 1;
|
|
||||||
pReplica->port = tsServerPort;
|
|
||||||
tstrncpy(pReplica->fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
|
static void mmBuildOptionForOpen(SMnodeMgmt *pMgmt, const SReplica *pReplica, SMnodeOpt *pOption) {
|
||||||
pOption->deploy = false;
|
|
||||||
pOption->standby = false;
|
pOption->standby = false;
|
||||||
|
pOption->deploy = false;
|
||||||
pOption->msgCb = pMgmt->msgCb;
|
pOption->msgCb = pMgmt->msgCb;
|
||||||
pOption->dnodeId = pMgmt->pData->dnodeId;
|
pOption->dnodeId = pMgmt->pData->dnodeId;
|
||||||
|
if (pReplica->id > 0) {
|
||||||
if (pMgmt->replica > 0) {
|
|
||||||
pOption->standby = true;
|
pOption->standby = true;
|
||||||
pOption->replica = 1;
|
pOption->replica = *pReplica;
|
||||||
pOption->selfIndex = 0;
|
|
||||||
SReplica *pReplica = &pOption->replicas[0];
|
|
||||||
for (int32_t i = 0; i < pMgmt->replica; ++i) {
|
|
||||||
if (pMgmt->replicas[i].id != pMgmt->pData->dnodeId) continue;
|
|
||||||
pReplica->id = pMgmt->replicas[i].id;
|
|
||||||
pReplica->port = pMgmt->replicas[i].port;
|
|
||||||
memcpy(pReplica->fqdn, pMgmt->replicas[i].fqdn, TSDB_FQDN_LEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,12 +91,13 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
pMgmt->path = pInput->path;
|
pMgmt->path = pInput->path;
|
||||||
pMgmt->name = pInput->name;
|
pMgmt->name = pInput->name;
|
||||||
pMgmt->msgCb = pInput->msgCb;
|
pMgmt->msgCb = pInput->msgCb;
|
||||||
pMgmt->msgCb.putToQueueFp = (PutToQueueFp)mmPutRpcMsgToQueue;
|
pMgmt->msgCb.putToQueueFp = (PutToQueueFp)mmPutMsgToQueue;
|
||||||
pMgmt->msgCb.mgmt = pMgmt;
|
pMgmt->msgCb.mgmt = pMgmt;
|
||||||
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
taosThreadRwlockInit(&pMgmt->lock, NULL);
|
||||||
|
|
||||||
bool deployed = false;
|
bool deployed = false;
|
||||||
if (mmReadFile(pMgmt, &deployed) != 0) {
|
SReplica replica = {0};
|
||||||
|
if (mmReadFile(pMgmt, &replica, &deployed) != 0) {
|
||||||
dError("failed to read file since %s", terrstr());
|
dError("failed to read file since %s", terrstr());
|
||||||
mmClose(pMgmt);
|
mmClose(pMgmt);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -123,7 +110,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
mmBuildOptionForDeploy(pMgmt, pInput, &option);
|
mmBuildOptionForDeploy(pMgmt, pInput, &option);
|
||||||
} else {
|
} else {
|
||||||
dInfo("mnode start to open");
|
dInfo("mnode start to open");
|
||||||
mmBuildOptionForOpen(pMgmt, &option);
|
mmBuildOptionForOpen(pMgmt, &replica, &option);
|
||||||
}
|
}
|
||||||
|
|
||||||
pMgmt->pMnode = mndOpen(pMgmt->path, &option);
|
pMgmt->pMnode = mndOpen(pMgmt->path, &option);
|
||||||
|
@ -141,8 +128,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||||
}
|
}
|
||||||
tmsgReportStartup("mnode-worker", "initialized");
|
tmsgReportStartup("mnode-worker", "initialized");
|
||||||
|
|
||||||
if (!deployed || pMgmt->replica > 0) {
|
if (!deployed || replica.id > 0) {
|
||||||
pMgmt->replica = 0;
|
|
||||||
deployed = true;
|
deployed = true;
|
||||||
if (mmWriteFile(pMgmt, NULL, deployed) != 0) {
|
if (mmWriteFile(pMgmt, NULL, deployed) != 0) {
|
||||||
dError("failed to write mnode file since %s", terrstr());
|
dError("failed to write mnode file since %s", terrstr());
|
||||||
|
@ -178,22 +164,3 @@ SMgmtFunc mmGetMgmtFunc() {
|
||||||
|
|
||||||
return mgmtFunc;
|
return mgmtFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmAcquire(SMnodeMgmt *pMgmt) {
|
|
||||||
int32_t code = 0;
|
|
||||||
|
|
||||||
taosThreadRwlockRdlock(&pMgmt->lock);
|
|
||||||
if (pMgmt->stopped) {
|
|
||||||
code = -1;
|
|
||||||
} else {
|
|
||||||
atomic_add_fetch_32(&pMgmt->refCount, 1);
|
|
||||||
}
|
|
||||||
taosThreadRwlockUnlock(&pMgmt->lock);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mmRelease(SMnodeMgmt *pMgmt) {
|
|
||||||
taosThreadRwlockRdlock(&pMgmt->lock);
|
|
||||||
atomic_sub_fetch_32(&pMgmt->refCount, 1);
|
|
||||||
taosThreadRwlockUnlock(&pMgmt->lock);
|
|
||||||
}
|
|
|
@ -16,6 +16,25 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mmInt.h"
|
#include "mmInt.h"
|
||||||
|
|
||||||
|
static inline int32_t mmAcquire(SMnodeMgmt *pMgmt) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
if (pMgmt->stopped) {
|
||||||
|
code = -1;
|
||||||
|
} else {
|
||||||
|
atomic_add_fetch_32(&pMgmt->refCount, 1);
|
||||||
|
}
|
||||||
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void mmRelease(SMnodeMgmt *pMgmt) {
|
||||||
|
taosThreadRwlockRdlock(&pMgmt->lock);
|
||||||
|
atomic_sub_fetch_32(&pMgmt->refCount, 1);
|
||||||
|
taosThreadRwlockUnlock(&pMgmt->lock);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.code = code,
|
.code = code,
|
||||||
|
@ -26,7 +45,7 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
dTrace("msg:%p, get from mnode queue", pMsg);
|
dTrace("msg:%p, get from mnode queue", pMsg);
|
||||||
|
@ -53,11 +72,10 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
dTrace("msg:%p, get from mnode-sync queue", pMsg);
|
|
||||||
|
|
||||||
pMsg->info.node = pMgmt->pMnode;
|
pMsg->info.node = pMgmt->pMnode;
|
||||||
|
dTrace("msg:%p, get from mnode-sync queue", pMsg);
|
||||||
|
|
||||||
SMsgHead *pHead = pMsg->pCont;
|
SMsgHead *pHead = pMsg->pCont;
|
||||||
pHead->contLen = ntohl(pHead->contLen);
|
pHead->contLen = ntohl(pHead->contLen);
|
||||||
|
@ -70,66 +88,70 @@ static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) {
|
static inline int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pMsg) {
|
||||||
dTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType));
|
if (mmAcquire(pMgmt) == 0) {
|
||||||
taosWriteQitem(pWorker->queue, pMsg);
|
dTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType));
|
||||||
return 0;
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
mmRelease(pMgmt);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
dTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, terrstr(),
|
||||||
|
TMSG_INFO(pMsg->msgType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutNodeMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return mmPutNodeMsgToWorker(&pMgmt->writeWorker, pMsg);
|
return mmPutMsgToWorker(pMgmt, &pMgmt->writeWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return mmPutNodeMsgToWorker(&pMgmt->syncWorker, pMsg);
|
return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutNodeMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return mmPutNodeMsgToWorker(&pMgmt->readWorker, pMsg);
|
return mmPutMsgToWorker(pMgmt, &pMgmt->readWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutNodeMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
mndPreprocessQueryMsg(pMgmt->pMnode, pMsg);
|
pMsg->info.node = pMgmt->pMnode;
|
||||||
|
if (mndPreProcessMsg(pMsg) != 0) {
|
||||||
return mmPutNodeMsgToWorker(&pMgmt->queryWorker, pMsg);
|
dError("msg:%p, failed to pre-process in mnode since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return mmPutMsgToWorker(pMgmt, &pMgmt->queryWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||||
return mmPutNodeMsgToWorker(&pMgmt->monitorWorker, pMsg);
|
return mmPutMsgToWorker(pMgmt, &pMgmt->monitorWorker, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmPutRpcMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||||
|
SSingleWorker *pWorker = NULL;
|
||||||
|
switch (qtype) {
|
||||||
|
case WRITE_QUEUE:
|
||||||
|
pWorker = &pMgmt->writeWorker;
|
||||||
|
break;
|
||||||
|
case QUERY_QUEUE:
|
||||||
|
pWorker = &pMgmt->queryWorker;
|
||||||
|
break;
|
||||||
|
case READ_QUEUE:
|
||||||
|
pWorker = &pMgmt->readWorker;
|
||||||
|
break;
|
||||||
|
case SYNC_QUEUE:
|
||||||
|
pWorker = &pMgmt->syncWorker;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pWorker == NULL) return -1;
|
||||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||||
if (pMsg == NULL) return -1;
|
if (pMsg == NULL) return -1;
|
||||||
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
memcpy(pMsg, pRpc, sizeof(SRpcMsg));
|
||||||
|
|
||||||
switch (qtype) {
|
dTrace("msg:%p, is created and will put int %s queue", pMsg, pWorker->name);
|
||||||
case WRITE_QUEUE:
|
return mmPutMsgToWorker(pMgmt, pWorker, pMsg);
|
||||||
dTrace("msg:%p, is created and will put into vnode-write queue", pMsg);
|
|
||||||
taosWriteQitem(pMgmt->writeWorker.queue, pMsg);
|
|
||||||
return 0;
|
|
||||||
case QUERY_QUEUE:
|
|
||||||
dTrace("msg:%p, is created and will put into vnode-query queue", pMsg);
|
|
||||||
taosWriteQitem(pMgmt->queryWorker.queue, pMsg);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case READ_QUEUE:
|
|
||||||
dTrace("msg:%p, is created and will put into vnode-read queue", pMsg);
|
|
||||||
taosWriteQitem(pMgmt->readWorker.queue, pMsg);
|
|
||||||
return 0;
|
|
||||||
case SYNC_QUEUE:
|
|
||||||
if (mmAcquire(pMgmt) == 0) {
|
|
||||||
dTrace("msg:%p, is created and will put into vnode-sync queue", pMsg);
|
|
||||||
taosWriteQitem(pMgmt->syncWorker.queue, pMsg);
|
|
||||||
mmRelease(pMgmt);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
|
@ -137,7 +159,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
.min = tsNumOfMnodeQueryThreads,
|
.min = tsNumOfMnodeQueryThreads,
|
||||||
.max = tsNumOfMnodeQueryThreads,
|
.max = tsNumOfMnodeQueryThreads,
|
||||||
.name = "mnode-query",
|
.name = "mnode-query",
|
||||||
.fp = (FItem)mmProcessQueue,
|
.fp = (FItem)mmProcessRpcMsg,
|
||||||
.param = pMgmt,
|
.param = pMgmt,
|
||||||
};
|
};
|
||||||
if (tSingleWorkerInit(&pMgmt->queryWorker, &qCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->queryWorker, &qCfg) != 0) {
|
||||||
|
@ -149,7 +171,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
.min = tsNumOfMnodeReadThreads,
|
.min = tsNumOfMnodeReadThreads,
|
||||||
.max = tsNumOfMnodeReadThreads,
|
.max = tsNumOfMnodeReadThreads,
|
||||||
.name = "mnode-read",
|
.name = "mnode-read",
|
||||||
.fp = (FItem)mmProcessQueue,
|
.fp = (FItem)mmProcessRpcMsg,
|
||||||
.param = pMgmt,
|
.param = pMgmt,
|
||||||
};
|
};
|
||||||
if (tSingleWorkerInit(&pMgmt->readWorker, &rCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->readWorker, &rCfg) != 0) {
|
||||||
|
@ -161,7 +183,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
.min = 1,
|
.min = 1,
|
||||||
.max = 1,
|
.max = 1,
|
||||||
.name = "mnode-write",
|
.name = "mnode-write",
|
||||||
.fp = (FItem)mmProcessQueue,
|
.fp = (FItem)mmProcessRpcMsg,
|
||||||
.param = pMgmt,
|
.param = pMgmt,
|
||||||
};
|
};
|
||||||
if (tSingleWorkerInit(&pMgmt->writeWorker, &wCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->writeWorker, &wCfg) != 0) {
|
||||||
|
@ -173,7 +195,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
.min = 1,
|
.min = 1,
|
||||||
.max = 1,
|
.max = 1,
|
||||||
.name = "mnode-sync",
|
.name = "mnode-sync",
|
||||||
.fp = (FItem)mmProcessSyncQueue,
|
.fp = (FItem)mmProcessSyncMsg,
|
||||||
.param = pMgmt,
|
.param = pMgmt,
|
||||||
};
|
};
|
||||||
if (tSingleWorkerInit(&pMgmt->syncWorker, &sCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->syncWorker, &sCfg) != 0) {
|
||||||
|
@ -185,7 +207,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
||||||
.min = 1,
|
.min = 1,
|
||||||
.max = 1,
|
.max = 1,
|
||||||
.name = "mnode-monitor",
|
.name = "mnode-monitor",
|
||||||
.fp = (FItem)mmProcessQueue,
|
.fp = (FItem)mmProcessRpcMsg,
|
||||||
.param = pMgmt,
|
.param = pMgmt,
|
||||||
};
|
};
|
||||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
||||||
|
|
|
@ -344,6 +344,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT_RSMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT_RSMA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_CHANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_COMMIT_OFFSET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_CONSUME, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_DELETE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
@ -373,6 +374,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_REQUEST_VOTE_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
|
|
@ -123,10 +123,12 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
|
||||||
dError("node:%s, failed to create since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to create since %s", pWrapper->name, terrstr());
|
||||||
} else {
|
} else {
|
||||||
dInfo("node:%s, has been created", pWrapper->name);
|
dInfo("node:%s, has been created", pWrapper->name);
|
||||||
(void)dmOpenNode(pWrapper);
|
code = dmOpenNode(pWrapper);
|
||||||
(void)dmStartNode(pWrapper);
|
if (code == 0) {
|
||||||
pWrapper->required = true;
|
code = dmStartNode(pWrapper);
|
||||||
|
}
|
||||||
pWrapper->deployed = true;
|
pWrapper->deployed = true;
|
||||||
|
pWrapper->required = true;
|
||||||
pWrapper->proc.ptype = pDnode->ptype;
|
pWrapper->proc.ptype = pDnode->ptype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,12 @@ typedef struct {
|
||||||
} STelemMgmt;
|
} STelemMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
sem_t syncSem;
|
sem_t syncSem;
|
||||||
int64_t sync;
|
int64_t sync;
|
||||||
bool standby;
|
bool standby;
|
||||||
int32_t errCode;
|
SReplica replica;
|
||||||
int32_t transId;
|
int32_t errCode;
|
||||||
|
int32_t transId;
|
||||||
} SSyncMgmt;
|
} SSyncMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -98,9 +99,6 @@ typedef struct SMnode {
|
||||||
bool stopped;
|
bool stopped;
|
||||||
bool restored;
|
bool restored;
|
||||||
bool deploy;
|
bool deploy;
|
||||||
int8_t replica;
|
|
||||||
int8_t selfIndex;
|
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
|
||||||
char *path;
|
char *path;
|
||||||
int64_t checkTime;
|
int64_t checkTime;
|
||||||
SSdb *pSdb;
|
SSdb *pSdb;
|
||||||
|
@ -126,8 +124,6 @@ void mndReleaseRpcRef(SMnode *pMnode);
|
||||||
void mndSetRestore(SMnode *pMnode, bool restored);
|
void mndSetRestore(SMnode *pMnode, bool restored);
|
||||||
void mndSetStop(SMnode *pMnode);
|
void mndSetStop(SMnode *pMnode);
|
||||||
bool mndGetStop(SMnode *pMnode);
|
bool mndGetStop(SMnode *pMnode);
|
||||||
int32_t mndAcquireSyncRef(SMnode *pMnode);
|
|
||||||
void mndReleaseSyncRef(SMnode *pMnode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,9 @@ int32_t mndInitSma(SMnode *pMnode);
|
||||||
void mndCleanupSma(SMnode *pMnode);
|
void mndCleanupSma(SMnode *pMnode);
|
||||||
SSmaObj *mndAcquireSma(SMnode *pMnode, char *smaName);
|
SSmaObj *mndAcquireSma(SMnode *pMnode, char *smaName);
|
||||||
void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma);
|
void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma);
|
||||||
|
int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb);
|
||||||
|
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||||
|
int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ void mndCleanupStb(SMnode *pMnode);
|
||||||
SStbObj *mndAcquireStb(SMnode *pMnode, char *stbName);
|
SStbObj *mndAcquireStb(SMnode *pMnode, char *stbName);
|
||||||
void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
|
void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
|
||||||
SSdbRaw *mndStbActionEncode(SStbObj *pStb);
|
SSdbRaw *mndStbActionEncode(SStbObj *pStb);
|
||||||
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbs, int32_t numOfStbs, void **ppRsp,
|
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbs, int32_t numOfStbs, void **ppRsp,
|
||||||
int32_t *pRspLen);
|
int32_t *pRspLen);
|
||||||
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
|
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
|
||||||
|
|
||||||
|
|
|
@ -183,12 +183,12 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention));
|
pDb->cfg.pRetensions = taosArrayInit(pDb->cfg.numOfRetensions, sizeof(SRetention));
|
||||||
if (pDb->cfg.pRetensions == NULL) goto _OVER;
|
if (pDb->cfg.pRetensions == NULL) goto _OVER;
|
||||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||||
SRetention retension = {0};
|
SRetention retention = {0};
|
||||||
SDB_GET_INT64(pRaw, dataPos, &retension.freq, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &retention.freq, _OVER)
|
||||||
SDB_GET_INT64(pRaw, dataPos, &retension.keep, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &retention.keep, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &retention.freqUnit, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &retention.keepUnit, _OVER)
|
||||||
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) {
|
if (taosArrayPush(pDb->cfg.pRetensions, &retention) == NULL) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq);
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
||||||
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db);
|
||||||
|
@ -935,6 +935,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
|
||||||
if (mndDropOffsetByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
if (mndDropOffsetByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||||
if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||||
if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||||
|
if (mndDropSmasByDb(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||||
if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER;
|
if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER;
|
||||||
|
|
||||||
SUserObj *pUser = mndAcquireUser(pMnode, pDb->createUser);
|
SUserObj *pUser = mndAcquireUser(pMnode, pDb->createUser);
|
||||||
|
@ -1366,7 +1367,7 @@ char *buildRetension(SArray *pRetension) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables,
|
static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables,
|
||||||
bool sysDb) {
|
bool sysDb, ESdbStatus objStatus) {
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
||||||
|
@ -1379,7 +1380,9 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
||||||
}
|
}
|
||||||
|
|
||||||
char *status = "ready";
|
char *status = "ready";
|
||||||
char statusB[24] = {0};
|
if (objStatus == SDB_STATUS_CREATING) status = "creating";
|
||||||
|
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
|
||||||
|
char statusB[24] = {0};
|
||||||
STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status));
|
STR_WITH_SIZE_TO_VARSTR(statusB, status, strlen(status));
|
||||||
|
|
||||||
if (sysDb) {
|
if (sysDb) {
|
||||||
|
@ -1503,8 +1506,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, rows, (const char *)statusB, false);
|
colDataAppend(pColInfo, rows, (const char *)statusB, false);
|
||||||
|
|
||||||
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false);
|
// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false);
|
||||||
|
|
||||||
char *p = buildRetension(pDb->cfg.pRetensions);
|
char *p = buildRetension(pDb->cfg.pRetensions);
|
||||||
|
|
||||||
|
@ -1548,29 +1551,30 @@ static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, v
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
ESdbStatus objStatus = 0;
|
||||||
|
|
||||||
// Append the information_schema database into the result.
|
// Append the information_schema database into the result.
|
||||||
if (!pShow->sysDbRsp) {
|
if (!pShow->sysDbRsp) {
|
||||||
SDbObj infoschemaDb = {0};
|
SDbObj infoschemaDb = {0};
|
||||||
setInformationSchemaDbCfg(&infoschemaDb);
|
setInformationSchemaDbCfg(&infoschemaDb);
|
||||||
dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true);
|
dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true, 0);
|
||||||
|
|
||||||
numOfRows += 1;
|
numOfRows += 1;
|
||||||
|
|
||||||
SDbObj perfschemaDb = {0};
|
SDbObj perfschemaDb = {0};
|
||||||
setPerfSchemaDbCfg(&perfschemaDb);
|
setPerfSchemaDbCfg(&perfschemaDb);
|
||||||
dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true);
|
dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true, 0);
|
||||||
|
|
||||||
numOfRows += 1;
|
numOfRows += 1;
|
||||||
pShow->sysDbRsp = true;
|
pShow->sysDbRsp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (numOfRows < rowsCapacity) {
|
while (numOfRows < rowsCapacity) {
|
||||||
pShow->pIter = sdbFetch(pSdb, SDB_DB, pShow->pIter, (void **)&pDb);
|
pShow->pIter = sdbFetchAll(pSdb, SDB_DB, pShow->pIter, (void **)&pDb, &objStatus);
|
||||||
if (pShow->pIter == NULL) {
|
if (pShow->pIter == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1582,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL);
|
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL);
|
||||||
|
|
||||||
dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false);
|
dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false, objStatus);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
sdbRelease(pSdb, pDb);
|
sdbRelease(pSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
|
||||||
dnodeObj.id = 1;
|
dnodeObj.id = 1;
|
||||||
dnodeObj.createdTime = taosGetTimestampMs();
|
dnodeObj.createdTime = taosGetTimestampMs();
|
||||||
dnodeObj.updateTime = dnodeObj.createdTime;
|
dnodeObj.updateTime = dnodeObj.createdTime;
|
||||||
dnodeObj.port = pMnode->replicas[0].port;
|
dnodeObj.port = tsServerPort;
|
||||||
memcpy(&dnodeObj.fqdn, pMnode->replicas[0].fqdn, TSDB_FQDN_LEN);
|
memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||||
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL);
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL);
|
||||||
|
|
|
@ -289,11 +289,9 @@ static int32_t mndExecSteps(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
||||||
pMnode->replica = pOption->replica;
|
|
||||||
pMnode->selfIndex = pOption->selfIndex;
|
|
||||||
memcpy(&pMnode->replicas, pOption->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA);
|
|
||||||
pMnode->msgCb = pOption->msgCb;
|
pMnode->msgCb = pOption->msgCb;
|
||||||
pMnode->selfDnodeId = pOption->dnodeId;
|
pMnode->selfDnodeId = pOption->dnodeId;
|
||||||
|
pMnode->syncMgmt.replica = pOption->replica;
|
||||||
pMnode->syncMgmt.standby = pOption->standby;
|
pMnode->syncMgmt.standby = pOption->standby;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,22 +380,17 @@ void mndStop(SMnode *pMnode) {
|
||||||
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SMnode *pMnode = pMsg->info.node;
|
SMnode *pMnode = pMsg->info.node;
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
int32_t code = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
int32_t code = TAOS_SYNC_OTHER_ERROR;
|
||||||
|
|
||||||
if (!syncEnvIsStart()) {
|
if (!syncEnvIsStart()) {
|
||||||
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process sync msg:%p type:%s since syncEnv stop", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
return TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
return TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
SSyncNode *pSyncNode = syncNodeAcquire(pMgmt->sync);
|
||||||
if (pSyncNode == NULL) {
|
if (pSyncNode == NULL) {
|
||||||
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process sync msg:%p type:%s since syncNode is null", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
return TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
return TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
if (mndAcquireSyncRef(pMnode) != 0) {
|
|
||||||
mError("failed to process sync msg:%p type:%s since %s", pMsg, TMSG_INFO(pMsg->msgType), terrstr());
|
|
||||||
return TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char logBuf[512] = {0};
|
char logBuf[512] = {0};
|
||||||
|
@ -428,7 +421,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg);
|
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg);
|
||||||
syncClientRequestDestroy(pSyncMsg);
|
syncClientRequestDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
} else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
|
||||||
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg);
|
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnRequestVoteSnapshotCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnRequestVoteSnapshotCb(pSyncNode, pSyncMsg);
|
||||||
|
@ -445,7 +437,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnAppendEntriesReplySnapshotCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnAppendEntriesReplySnapshotCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) {
|
} else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) {
|
||||||
SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pMsg);
|
SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnSnapshotSendCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnSnapshotSendCb(pSyncNode, pSyncMsg);
|
||||||
|
@ -454,12 +445,14 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg);
|
||||||
syncSnapshotRspDestroy(pSyncMsg);
|
syncSnapshotRspDestroy(pSyncMsg);
|
||||||
|
} else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
||||||
|
code = syncSetStandby(pMgmt->sync);
|
||||||
|
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
code = TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
if (pMsg->msgType == TDMT_SYNC_TIMEOUT) {
|
||||||
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pMsg);
|
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pMsg);
|
||||||
|
@ -493,13 +486,16 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
|
} else if (pMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
||||||
|
code = syncSetStandby(pMgmt->sync);
|
||||||
|
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
mError("failed to process msg:%p since invalid type:%s", pMsg, TMSG_INFO(pMsg->msgType));
|
||||||
code = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
code = TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseSyncRef(pMnode);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,24 +748,3 @@ void mndSetStop(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndGetStop(SMnode *pMnode) { return pMnode->stopped; }
|
bool mndGetStop(SMnode *pMnode) { return pMnode->stopped; }
|
||||||
|
|
||||||
int32_t mndAcquireSyncRef(SMnode *pMnode) {
|
|
||||||
int32_t code = 0;
|
|
||||||
taosThreadRwlockRdlock(&pMnode->lock);
|
|
||||||
if (pMnode->stopped) {
|
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
|
||||||
code = -1;
|
|
||||||
} else {
|
|
||||||
int32_t ref = atomic_add_fetch_32(&pMnode->syncRef, 1);
|
|
||||||
// mTrace("mnode sync is acquired, ref:%d", ref);
|
|
||||||
}
|
|
||||||
taosThreadRwlockUnlock(&pMnode->lock);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mndReleaseSyncRef(SMnode *pMnode) {
|
|
||||||
taosThreadRwlockRdlock(&pMnode->lock);
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pMnode->syncRef, 1);
|
|
||||||
// mTrace("mnode sync is released, ref:%d", ref);
|
|
||||||
taosThreadRwlockUnlock(&pMnode->lock);
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ int32_t mndInitMnode(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_SYNC_SET_MNODE_STANDBY_RSP, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_SYNC_SET_VNODE_STANDBY_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
||||||
|
@ -460,6 +462,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
int32_t numOfReplicas = 0;
|
int32_t numOfReplicas = 0;
|
||||||
SDAlterMnodeReq alterReq = {0};
|
SDAlterMnodeReq alterReq = {0};
|
||||||
SDDropMnodeReq dropReq = {0};
|
SDDropMnodeReq dropReq = {0};
|
||||||
|
SSetStandbyReq standbyReq = {0};
|
||||||
SEpSet alterEpset = {0};
|
SEpSet alterEpset = {0};
|
||||||
SEpSet dropEpSet = {0};
|
SEpSet dropEpSet = {0};
|
||||||
|
|
||||||
|
@ -494,6 +497,31 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
|
||||||
dropEpSet.eps[0].port = pDnode->port;
|
dropEpSet.eps[0].port = pDnode->port;
|
||||||
memcpy(dropEpSet.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
memcpy(dropEpSet.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
|
||||||
|
|
||||||
|
standbyReq.dnodeId = pDnode->id;
|
||||||
|
standbyReq.standby = 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq) + sizeof(SMsgHead);
|
||||||
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
tSerializeSSetStandbyReq((char*)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
||||||
|
SMsgHead *pHead = pReq;
|
||||||
|
pHead->contLen = htonl(contLen);
|
||||||
|
pHead->vgId = htonl(MNODE_HANDLE);
|
||||||
|
|
||||||
|
STransAction action = {
|
||||||
|
.epSet = dropEpSet,
|
||||||
|
.pCont = pReq,
|
||||||
|
.contLen = contLen,
|
||||||
|
.msgType = TDMT_SYNC_SET_MNODE_STANDBY,
|
||||||
|
.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq);
|
||||||
void *pReq = taosMemoryMalloc(contLen);
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
@ -632,7 +660,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SMnodeObj *pObj = NULL;
|
SMnodeObj *pObj = NULL;
|
||||||
ESdbStatus objStatus;
|
ESdbStatus objStatus = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
||||||
case HEARTBEAT_KEY_STBINFO: {
|
case HEARTBEAT_KEY_STBINFO: {
|
||||||
void *rspMsg = NULL;
|
void *rspMsg = NULL;
|
||||||
int32_t rspLen = 0;
|
int32_t rspLen = 0;
|
||||||
mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen);
|
mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableVersion), &rspMsg, &rspLen);
|
||||||
if (rspMsg && rspLen > 0) {
|
if (rspMsg && rspLen > 0) {
|
||||||
SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg};
|
SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg};
|
||||||
taosArrayPush(hbRsp.info, &kv1);
|
taosArrayPush(hbRsp.info, &kv1);
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
#include "mndMnode.h"
|
#include "mndMnode.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
|
||||||
int32_t mndPreprocessQueryMsg(SMnode * pMnode, SRpcMsg * pMsg) {
|
int32_t mndPreProcessMsg(SRpcMsg *pMsg) {
|
||||||
if (TDMT_VND_QUERY != pMsg->msgType) {
|
if (TDMT_VND_QUERY != pMsg->msgType) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
SMnode *pMnode = pMsg->info.node;
|
||||||
return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
return qWorkerPreprocessQueryMsg(pMnode->pQuery, pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||||
|
|
||||||
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
||||||
if (opNum != 1) {
|
if (opNum != 1) {
|
||||||
|
@ -85,7 +85,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||||
if (qSubPlanToString(plan, pDst, pDstLen) < 0) {
|
if (qSubPlanToString(plan, pDst, pDstLen) < 0) {
|
||||||
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
terrno = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
goto END;
|
goto END;
|
||||||
|
@ -93,7 +93,7 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pAst) nodesDestroyNode(pAst);
|
if (pAst) nodesDestroyNode(pAst);
|
||||||
if (pPlan) nodesDestroyNode(pPlan);
|
if (pPlan) nodesDestroyNode((SNode*)pPlan);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,8 +378,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SArray* taskInnerLevel = taosArrayInit(0, sizeof(void*));
|
SArray* taskInnerLevel = taosArrayInit(0, sizeof(void*));
|
||||||
taosArrayPush(pStream->tasks, &taskInnerLevel);
|
taosArrayPush(pStream->tasks, &taskInnerLevel);
|
||||||
|
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE);
|
ASSERT(plan->subplanType == SUBPLAN_TYPE_MERGE);
|
||||||
|
|
||||||
pFinalTask = tNewSStreamTask(pStream->uid);
|
pFinalTask = tNewSStreamTask(pStream->uid);
|
||||||
|
@ -407,8 +407,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SArray* taskSourceLevel = taosArrayInit(0, sizeof(void*));
|
SArray* taskSourceLevel = taosArrayInit(0, sizeof(void*));
|
||||||
taosArrayPush(pStream->tasks, &taskSourceLevel);
|
taosArrayPush(pStream->tasks, &taskSourceLevel);
|
||||||
|
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 1);
|
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 1);
|
||||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
||||||
|
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
|
@ -449,9 +449,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
|
||||||
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
SArray* taskOneLevel = taosArrayInit(0, sizeof(void*));
|
||||||
taosArrayPush(pStream->tasks, &taskOneLevel);
|
taosArrayPush(pStream->tasks, &taskOneLevel);
|
||||||
|
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||||
ASSERT(LIST_LENGTH(inner->pNodeList) == 1);
|
ASSERT(LIST_LENGTH(inner->pNodeList) == 1);
|
||||||
SSubplan* plan = nodesListGetNode(inner->pNodeList, 0);
|
SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||||
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
ASSERT(plan->subplanType == SUBPLAN_TYPE_SCAN);
|
||||||
|
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
|
@ -509,7 +509,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, 0);
|
SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0);
|
||||||
|
|
||||||
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
int32_t opNum = LIST_LENGTH(inner->pNodeList);
|
||||||
if (opNum != 1) {
|
if (opNum != 1) {
|
||||||
|
@ -517,7 +517,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
|
||||||
terrno = TSDB_CODE_MND_INVALID_TOPIC_QUERY;
|
terrno = TSDB_CODE_MND_INVALID_TOPIC_QUERY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
plan = nodesListGetNode(inner->pNodeList, 0);
|
plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pSub->unassignedVgs);
|
ASSERT(pSub->unassignedVgs);
|
||||||
|
|
|
@ -38,12 +38,13 @@ static int32_t mndSmaActionInsert(SSdb *pSdb, SSmaObj *pSma);
|
||||||
static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSpSmatb);
|
static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSpSmatb);
|
||||||
static int32_t mndSmaActionUpdate(SSdb *pSdb, SSmaObj *pOld, SSmaObj *pNew);
|
static int32_t mndSmaActionUpdate(SSdb *pSdb, SSmaObj *pOld, SSmaObj *pNew);
|
||||||
static int32_t mndSmaGetVgEpSet(SMnode *pMnode, SDbObj *pDb, SVgEpSet **ppVgEpSet, int32_t *numOfVgroups);
|
static int32_t mndSmaGetVgEpSet(SMnode *pMnode, SDbObj *pDb, SVgEpSet **ppVgEpSet, int32_t *numOfVgroups);
|
||||||
static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessGetSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessGetSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter);
|
||||||
|
static void mndDestroySmaObj(SSmaObj *pSmaObj);
|
||||||
|
|
||||||
int32_t mndInitSma(SMnode *pMnode) {
|
int32_t mndInitSma(SMnode *pMnode) {
|
||||||
SSdbTable table = {
|
SSdbTable table = {
|
||||||
|
@ -56,8 +57,8 @@ int32_t mndInitSma(SMnode *pMnode) {
|
||||||
.deleteFp = (SdbDeleteFp)mndSmaActionDelete,
|
.deleteFp = (SdbDeleteFp)mndSmaActionDelete,
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessMCreateSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessCreateSmaReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessMDropSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessDropSmaReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_SMA_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_SMA_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_SMA_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_DROP_SMA_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetSmaReq);
|
||||||
|
@ -79,7 +80,6 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) {
|
||||||
if (pRaw == NULL) goto _OVER;
|
if (pRaw == NULL) goto _OVER;
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
|
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSma->name, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSma->name, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSma->stb, TSDB_TABLE_FNAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSma->stb, TSDB_TABLE_FNAME_LEN, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSma->db, TSDB_DB_FNAME_LEN, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSma->db, TSDB_DB_FNAME_LEN, _OVER)
|
||||||
|
@ -100,6 +100,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pSma->tagsFilterLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pSma->tagsFilterLen, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pSma->sqlLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pSma->sqlLen, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pSma->astLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pSma->astLen, _OVER)
|
||||||
|
|
||||||
if (pSma->exprLen > 0) {
|
if (pSma->exprLen > 0) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER)
|
||||||
}
|
}
|
||||||
|
@ -115,6 +116,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) {
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -193,6 +195,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -383,6 +386,28 @@ static int32_t mndSetCreateSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, S
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetUpdateSmaStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
||||||
|
SStbObj stbObj = {0};
|
||||||
|
taosRLockLatch(&pStb->lock);
|
||||||
|
memcpy(&stbObj, pStb, sizeof(SStbObj));
|
||||||
|
taosRUnLockLatch(&pStb->lock);
|
||||||
|
stbObj.numOfColumns = 0;
|
||||||
|
stbObj.pColumns = NULL;
|
||||||
|
stbObj.numOfTags = 0;
|
||||||
|
stbObj.pTags = NULL;
|
||||||
|
stbObj.updateTime = taosGetTimestampMs();
|
||||||
|
stbObj.lock = 0;
|
||||||
|
stbObj.smaVer++;
|
||||||
|
|
||||||
|
SSdbRaw *pCommitRaw = mndStbActionEncode(&stbObj);
|
||||||
|
if (pCommitRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
||||||
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
|
@ -421,6 +446,7 @@ static int32_t mndSetCreateSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
||||||
SSmaObj *pSma) {
|
SSmaObj *pSma) {
|
||||||
|
@ -457,7 +483,6 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans,
|
||||||
pSma->schemaTag.pSchema[0].flags = 0;
|
pSma->schemaTag.pSchema[0].flags = 0;
|
||||||
snprintf(pSma->schemaTag.pSchema[0].name, TSDB_COL_NAME_LEN, "groupId");
|
snprintf(pSma->schemaTag.pSchema[0].name, TSDB_COL_NAME_LEN, "groupId");
|
||||||
|
|
||||||
|
|
||||||
int32_t smaContLen = 0;
|
int32_t smaContLen = 0;
|
||||||
void *pSmaReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &smaContLen);
|
void *pSmaReq = mndBuildVCreateSmaReq(pMnode, pVgroup, pSma, &smaContLen);
|
||||||
if (pSmaReq == NULL) return -1;
|
if (pSmaReq == NULL) return -1;
|
||||||
|
@ -481,6 +506,13 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mndDestroySmaObj(SSmaObj *pSmaObj) {
|
||||||
|
if (pSmaObj) {
|
||||||
|
taosMemoryFreeClear(pSmaObj->schemaRow.pSchema);
|
||||||
|
taosMemoryFreeClear(pSmaObj->schemaTag.pSchema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) {
|
static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCreate, SDbObj *pDb, SStbObj *pStb) {
|
||||||
SSmaObj smaObj = {0};
|
SSmaObj smaObj = {0};
|
||||||
memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
|
memcpy(smaObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -504,34 +536,23 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
smaObj.tagsFilterLen = pCreate->tagsFilterLen;
|
smaObj.tagsFilterLen = pCreate->tagsFilterLen;
|
||||||
smaObj.sqlLen = pCreate->sqlLen;
|
smaObj.sqlLen = pCreate->sqlLen;
|
||||||
smaObj.astLen = pCreate->astLen;
|
smaObj.astLen = pCreate->astLen;
|
||||||
|
|
||||||
if (smaObj.exprLen > 0) {
|
if (smaObj.exprLen > 0) {
|
||||||
smaObj.expr = taosMemoryMalloc(smaObj.exprLen);
|
smaObj.expr = pCreate->expr;
|
||||||
if (smaObj.expr == NULL) goto _OVER;
|
|
||||||
memcpy(smaObj.expr, pCreate->expr, smaObj.exprLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smaObj.tagsFilterLen > 0) {
|
if (smaObj.tagsFilterLen > 0) {
|
||||||
smaObj.tagsFilter = taosMemoryMalloc(smaObj.tagsFilterLen);
|
smaObj.tagsFilter = pCreate->tagsFilter;
|
||||||
if (smaObj.tagsFilter == NULL) goto _OVER;
|
|
||||||
memcpy(smaObj.tagsFilter, pCreate->tagsFilter, smaObj.tagsFilterLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smaObj.sqlLen > 0) {
|
if (smaObj.sqlLen > 0) {
|
||||||
smaObj.sql = taosMemoryMalloc(smaObj.sqlLen);
|
smaObj.sql = pCreate->sql;
|
||||||
if (smaObj.sql == NULL) goto _OVER;
|
|
||||||
memcpy(smaObj.sql, pCreate->sql, smaObj.sqlLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smaObj.astLen > 0) {
|
if (smaObj.astLen > 0) {
|
||||||
smaObj.ast = taosMemoryMalloc(smaObj.astLen);
|
smaObj.ast = pCreate->ast;
|
||||||
if (smaObj.ast == NULL) goto _OVER;
|
|
||||||
memcpy(smaObj.ast, pCreate->ast, smaObj.astLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SStreamObj streamObj = {0};
|
SStreamObj streamObj = {0};
|
||||||
tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN);
|
tstrncpy(streamObj.name, pCreate->name, TSDB_STREAM_FNAME_LEN);
|
||||||
tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN);
|
tstrncpy(streamObj.sourceDb, pDb->name, TSDB_DB_FNAME_LEN);
|
||||||
|
tstrncpy(streamObj.targetDb, streamObj.sourceDb, TSDB_DB_FNAME_LEN);
|
||||||
streamObj.createTime = taosGetTimestampMs();
|
streamObj.createTime = taosGetTimestampMs();
|
||||||
streamObj.updateTime = streamObj.createTime;
|
streamObj.updateTime = streamObj.createTime;
|
||||||
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
streamObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
||||||
|
@ -559,7 +580,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
if (mndSetCreateSmaVgroupRedoLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaCommitLogs(pMnode, pTrans, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupCommitLogs(pMnode, pTrans, &streamObj.fixedSinkVg) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
|
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
if (mndSetCreateSmaVgroupRedoActions(pMnode, pTrans, pDb, &streamObj.fixedSinkVg, &smaObj) != 0) goto _OVER;
|
||||||
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER;
|
if (mndAddStreamToTrans(pMnode, &streamObj, pCreate->ast, STREAM_TRIGGER_AT_ONCE, 0, pTrans) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
@ -567,6 +589,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
|
mndDestroySmaObj(&smaObj);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +622,7 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
|
@ -713,6 +736,7 @@ static int32_t mndSetDropSmaVgroupCommitLogs(SMnode *pMnode, STrans *pTrans, SVg
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SSmaObj *pSma) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
|
@ -753,6 +777,7 @@ static int32_t mndSetDropSmaRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
SVnodeGid *pVgid = pVgroup->vnodeGid + 0;
|
||||||
|
@ -781,13 +806,17 @@ static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SD
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) {
|
static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *pSma) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SVgObj *pVgroup = NULL;
|
SVgObj *pVgroup = NULL;
|
||||||
STrans *pTrans = NULL;
|
SStbObj *pStb = NULL;
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||||
if (pVgroup == NULL) goto _OVER;
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
|
||||||
|
pStb = mndAcquireStb(pMnode, pSma->stb);
|
||||||
|
if (pStb == NULL) goto _OVER;
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq);
|
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB, pReq);
|
||||||
if (pTrans == NULL) goto _OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
||||||
|
@ -798,7 +827,8 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
||||||
if (mndSetDropSmaVgroupRedoLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupRedoLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
|
if (mndSetUpdateSmaStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
|
// if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
|
||||||
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
|
@ -807,10 +837,78 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
||||||
_OVER:
|
_OVER:
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
mndReleaseVgroup(pMnode, pVgroup);
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
mndReleaseStb(pMnode, pStb);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq) {
|
int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SSmaObj *pSma = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
SVgObj *pVgroup = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pSma->stbUid == pStb->uid) {
|
||||||
|
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||||
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
|
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
||||||
|
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
||||||
|
// if (mndSetDropSmaRedoActions(pMnode, pTrans, pDb, pSma) != 0) goto _OVER;
|
||||||
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
pVgroup = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pSma);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
sdbRelease(pSdb, pSma);
|
||||||
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
SSmaObj *pSma = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
SVgObj *pVgroup = NULL;
|
||||||
|
int32_t code = -1;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pSma->dbUid == pDb->uid) {
|
||||||
|
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||||
|
if (pVgroup == NULL) goto _OVER;
|
||||||
|
if (mndSetDropSmaVgroupCommitLogs(pMnode, pTrans, pVgroup) != 0) goto _OVER;
|
||||||
|
if (mndSetDropSmaVgroupRedoActions(pMnode, pTrans, pDb, pVgroup) != 0) goto _OVER;
|
||||||
|
if (mndSetDropSmaCommitLogs(pMnode, pTrans, pSma) != 0) goto _OVER;
|
||||||
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
pVgroup = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sdbRelease(pSdb, pSma);
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
sdbRelease(pSdb, pSma);
|
||||||
|
mndReleaseVgroup(pMnode, pVgroup);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
|
@ -899,18 +997,30 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndGetTableSma(SMnode *pMnode, STableIndexReq *indexReq, STableIndexRsp *rsp, bool *exist) {
|
int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSmaObj *pSma = NULL;
|
SSmaObj *pSma = NULL;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
STableIndexInfo info;
|
STableIndexInfo info;
|
||||||
|
|
||||||
|
SStbObj *pStb = mndAcquireStb(pMnode, tbFName);
|
||||||
|
if (NULL == pStb) {
|
||||||
|
*exist = false;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(rsp->dbFName, pStb->db);
|
||||||
|
strcpy(rsp->tbName, pStb->name + strlen(pStb->db) + 1);
|
||||||
|
rsp->suid = pStb->uid;
|
||||||
|
rsp->version = pStb->smaVer;
|
||||||
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
if (pSma->stb[0] != indexReq->tbFName[0] || strcmp(pSma->stb, indexReq->tbFName)) {
|
if (pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,14 +1032,14 @@ static int32_t mndGetTableSma(SMnode *pMnode, STableIndexReq *indexReq, STableIn
|
||||||
info.dstTbUid = pSma->dstTbUid;
|
info.dstTbUid = pSma->dstTbUid;
|
||||||
info.dstVgId = pSma->dstVgId;
|
info.dstVgId = pSma->dstVgId;
|
||||||
|
|
||||||
SVgObj* pVg = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
SVgObj *pVg = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||||
if (pVg == NULL) {
|
if (pVg == NULL) {
|
||||||
code = -1;
|
code = -1;
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
info.epSet = mndGetVgroupEpset(pMnode, pVg);
|
info.epSet = mndGetVgroupEpset(pMnode, pVg);
|
||||||
|
|
||||||
info.expr = taosMemoryMalloc(pSma->exprLen + 1);
|
info.expr = taosMemoryMalloc(pSma->exprLen + 1);
|
||||||
if (info.expr == NULL) {
|
if (info.expr == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -953,7 +1063,7 @@ static int32_t mndGetTableSma(SMnode *pMnode, STableIndexReq *indexReq, STableIn
|
||||||
|
|
||||||
sdbRelease(pSdb, pSma);
|
sdbRelease(pSdb, pSma);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,10 +1115,10 @@ _OVER:
|
||||||
|
|
||||||
static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
|
static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
|
||||||
STableIndexReq indexReq = {0};
|
STableIndexReq indexReq = {0};
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STableIndexRsp rsp = {0};
|
STableIndexRsp rsp = {0};
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
|
|
||||||
if (tDeserializeSTableIndexReq(pReq->pCont, pReq->contLen, &indexReq) != 0) {
|
if (tDeserializeSTableIndexReq(pReq->pCont, pReq->contLen, &indexReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
@ -1022,7 +1132,7 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = mndGetTableSma(pMnode, &indexReq, &rsp, &exist);
|
code = mndGetTableSma(pMnode, indexReq.tbFName, &rsp, &exist);
|
||||||
if (code) {
|
if (code) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -1055,7 +1165,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
@ -1114,4 +1223,4 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
||||||
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter) {
|
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,12 @@
|
||||||
#include "mndPerfSchema.h"
|
#include "mndPerfSchema.h"
|
||||||
#include "mndScheduler.h"
|
#include "mndScheduler.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
|
#include "mndSma.h"
|
||||||
#include "mndTopic.h"
|
#include "mndTopic.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
#include "mndSma.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
|
||||||
#define STB_VER_NUMBER 1
|
#define STB_VER_NUMBER 1
|
||||||
|
@ -36,9 +38,9 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb);
|
static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb);
|
||||||
static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb);
|
static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb);
|
||||||
static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew);
|
static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew);
|
||||||
static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessAlterStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMDropStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
||||||
|
@ -54,9 +56,9 @@ int32_t mndInitStb(SMnode *pMnode) {
|
||||||
.deleteFp = (SdbDeleteFp)mndStbActionDelete,
|
.deleteFp = (SdbDeleteFp)mndStbActionDelete,
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessCreateStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessAlterStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessMDropStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessDropStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp);
|
||||||
|
@ -318,12 +320,17 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
pOld->updateTime = pNew->updateTime;
|
pOld->updateTime = pNew->updateTime;
|
||||||
pOld->tagVer = pNew->tagVer;
|
pOld->tagVer = pNew->tagVer;
|
||||||
pOld->colVer = pNew->colVer;
|
pOld->colVer = pNew->colVer;
|
||||||
|
pOld->smaVer = pNew->smaVer;
|
||||||
pOld->nextColId = pNew->nextColId;
|
pOld->nextColId = pNew->nextColId;
|
||||||
pOld->ttl = pNew->ttl;
|
pOld->ttl = pNew->ttl;
|
||||||
pOld->numOfColumns = pNew->numOfColumns;
|
if (pNew->numOfColumns > 0) {
|
||||||
pOld->numOfTags = pNew->numOfTags;
|
pOld->numOfColumns = pNew->numOfColumns;
|
||||||
memcpy(pOld->pColumns, pNew->pColumns, pOld->numOfColumns * sizeof(SSchema));
|
memcpy(pOld->pColumns, pNew->pColumns, pOld->numOfColumns * sizeof(SSchema));
|
||||||
memcpy(pOld->pTags, pNew->pTags, pOld->numOfTags * sizeof(SSchema));
|
}
|
||||||
|
if (pNew->numOfTags > 0) {
|
||||||
|
pOld->numOfTags = pNew->numOfTags;
|
||||||
|
memcpy(pOld->pTags, pNew->pTags, pOld->numOfTags * sizeof(SSchema));
|
||||||
|
}
|
||||||
if (pNew->commentLen != 0) {
|
if (pNew->commentLen != 0) {
|
||||||
memcpy(pOld->comment, pNew->comment, pNew->commentLen);
|
memcpy(pOld->comment, pNew->comment, pNew->commentLen);
|
||||||
}
|
}
|
||||||
|
@ -361,7 +368,7 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
|
||||||
return mndAcquireDb(pMnode, db);
|
return mndAcquireDb(pMnode, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSchema) {
|
static FORCE_INLINE int32_t schemaExColIdCompare(const void *colId, const void *pSchema) {
|
||||||
if (*(col_id_t *)colId < ((SSchema *)pSchema)->colId) {
|
if (*(col_id_t *)colId < ((SSchema *)pSchema)->colId) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (*(col_id_t *)colId > ((SSchema *)pSchema)->colId) {
|
} else if (*(col_id_t *)colId > ((SSchema *)pSchema)->colId) {
|
||||||
|
@ -395,14 +402,14 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
req.pRSmaParam.xFilesFactor = pStb->xFilesFactor;
|
req.pRSmaParam.xFilesFactor = pStb->xFilesFactor;
|
||||||
req.pRSmaParam.delay = pStb->delay;
|
req.pRSmaParam.delay = pStb->delay;
|
||||||
if (pStb->ast1Len > 0) {
|
if (pStb->ast1Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, pStb->pAst1, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0,
|
if (mndConvertRsmaTask(&req.pRSmaParam.qmsg1, &req.pRSmaParam.qmsg1Len, pStb->pAst1, pStb->uid,
|
||||||
req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) {
|
STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pStb->ast2Len > 0) {
|
if (pStb->ast2Len > 0) {
|
||||||
if (mndConvertRsmaTask(&req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, pStb->pAst2, pStb->uid, STREAM_TRIGGER_AT_ONCE, 0,
|
if (mndConvertRsmaTask(&req.pRSmaParam.qmsg2, &req.pRSmaParam.qmsg2Len, pStb->pAst2, pStb->uid,
|
||||||
req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) {
|
STREAM_TRIGGER_AT_ONCE, 0, req.pRSmaParam.xFilesFactor) != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +768,7 @@ int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
|
@ -1271,7 +1278,7 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp, int32_t *smaVer) {
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
|
snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
|
||||||
|
|
||||||
|
@ -1288,6 +1295,10 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (smaVer) {
|
||||||
|
*smaVer = pStb->smaVer;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = mndBuildStbSchemaImp(pDb, pStb, tbName, pRsp);
|
int32_t code = mndBuildStbSchemaImp(pDb, pStb, tbName, pRsp);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
@ -1296,7 +1307,7 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
|
||||||
|
|
||||||
static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, SStbObj *pObj, void **pCont,
|
static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, SStbObj *pObj, void **pCont,
|
||||||
int32_t *pLen) {
|
int32_t *pLen) {
|
||||||
int ret;
|
int32_t ret;
|
||||||
SEncoder ec = {0};
|
SEncoder ec = {0};
|
||||||
uint32_t contLen = 0;
|
uint32_t contLen = 0;
|
||||||
SMAlterStbRsp alterRsp = {0};
|
SMAlterStbRsp alterRsp = {0};
|
||||||
|
@ -1415,7 +1426,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
|
@ -1545,6 +1556,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
|
||||||
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER;
|
||||||
if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
||||||
|
if (mndDropSmasByStb(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -1554,7 +1566,7 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMDropStbReq(SRpcMsg *pReq) {
|
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
|
@ -1634,7 +1646,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName);
|
mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName);
|
||||||
if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) {
|
if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp, NULL) != 0) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1667,51 +1679,86 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int32_t numOfStbs, void **ppRsp,
|
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t numOfStbs, void **ppRsp,
|
||||||
int32_t *pRspLen) {
|
int32_t *pRspLen) {
|
||||||
STableMetaBatchRsp batchMetaRsp = {0};
|
SSTbHbRsp hbRsp = {0};
|
||||||
batchMetaRsp.pArray = taosArrayInit(numOfStbs, sizeof(STableMetaRsp));
|
hbRsp.pMetaRsp = taosArrayInit(numOfStbs, sizeof(STableMetaRsp));
|
||||||
if (batchMetaRsp.pArray == NULL) {
|
if (hbRsp.pMetaRsp == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hbRsp.pIndexRsp = taosArrayInit(numOfStbs, sizeof(STableIndexRsp));
|
||||||
|
if (NULL == hbRsp.pIndexRsp) {
|
||||||
|
taosArrayDestroy(hbRsp.pMetaRsp);
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfStbs; ++i) {
|
for (int32_t i = 0; i < numOfStbs; ++i) {
|
||||||
SSTableMetaVersion *pStbVersion = &pStbVersions[i];
|
SSTableVersion *pStbVersion = &pStbVersions[i];
|
||||||
pStbVersion->suid = be64toh(pStbVersion->suid);
|
pStbVersion->suid = be64toh(pStbVersion->suid);
|
||||||
pStbVersion->sversion = ntohs(pStbVersion->sversion);
|
pStbVersion->sversion = ntohs(pStbVersion->sversion);
|
||||||
pStbVersion->tversion = ntohs(pStbVersion->tversion);
|
pStbVersion->tversion = ntohs(pStbVersion->tversion);
|
||||||
|
pStbVersion->smaVer = ntohl(pStbVersion->smaVer);
|
||||||
|
|
||||||
STableMetaRsp metaRsp = {0};
|
STableMetaRsp metaRsp = {0};
|
||||||
|
int32_t smaVer = 0;
|
||||||
mDebug("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName);
|
mDebug("stb:%s.%s, start to retrieve meta", pStbVersion->dbFName, pStbVersion->stbName);
|
||||||
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp) != 0) {
|
if (mndBuildStbSchema(pMnode, pStbVersion->dbFName, pStbVersion->stbName, &metaRsp, &smaVer) != 0) {
|
||||||
metaRsp.numOfColumns = -1;
|
metaRsp.numOfColumns = -1;
|
||||||
metaRsp.suid = pStbVersion->suid;
|
metaRsp.suid = pStbVersion->suid;
|
||||||
|
taosArrayPush(hbRsp.pMetaRsp, &metaRsp);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStbVersion->sversion != metaRsp.sversion || pStbVersion->tversion != metaRsp.tversion) {
|
if (pStbVersion->sversion != metaRsp.sversion || pStbVersion->tversion != metaRsp.tversion) {
|
||||||
taosArrayPush(batchMetaRsp.pArray, &metaRsp);
|
taosArrayPush(hbRsp.pMetaRsp, &metaRsp);
|
||||||
} else {
|
} else {
|
||||||
tFreeSTableMetaRsp(&metaRsp);
|
tFreeSTableMetaRsp(&metaRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pStbVersion->smaVer && pStbVersion->smaVer != smaVer) {
|
||||||
|
bool exist = false;
|
||||||
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
STableIndexRsp indexRsp = {0};
|
||||||
|
indexRsp.pIndex = taosArrayInit(10, sizeof(STableIndexInfo));
|
||||||
|
if (NULL == indexRsp.pIndex) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(tbFName, "%s.%s", pStbVersion->dbFName, pStbVersion->stbName);
|
||||||
|
int32_t code = mndGetTableSma(pMnode, tbFName, &indexRsp, &exist);
|
||||||
|
if (code || !exist) {
|
||||||
|
indexRsp.suid = pStbVersion->suid;
|
||||||
|
indexRsp.version = -1;
|
||||||
|
indexRsp.pIndex = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(indexRsp.dbFName, pStbVersion->dbFName);
|
||||||
|
strcpy(indexRsp.tbName, pStbVersion->stbName);
|
||||||
|
|
||||||
|
taosArrayPush(hbRsp.pIndexRsp, &indexRsp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rspLen = tSerializeSTableMetaBatchRsp(NULL, 0, &batchMetaRsp);
|
int32_t rspLen = tSerializeSSTbHbRsp(NULL, 0, &hbRsp);
|
||||||
if (rspLen < 0) {
|
if (rspLen < 0) {
|
||||||
tFreeSTableMetaBatchRsp(&batchMetaRsp);
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pRsp = taosMemoryMalloc(rspLen);
|
void *pRsp = taosMemoryMalloc(rspLen);
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
tFreeSTableMetaBatchRsp(&batchMetaRsp);
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tSerializeSTableMetaBatchRsp(pRsp, rspLen, &batchMetaRsp);
|
tSerializeSSTbHbRsp(pRsp, rspLen, &hbRsp);
|
||||||
tFreeSTableMetaBatchRsp(&batchMetaRsp);
|
tFreeSSTbHbRsp(&hbRsp);
|
||||||
*ppRsp = pRsp;
|
*ppRsp = pRsp;
|
||||||
*pRspLen = rspLen;
|
*pRspLen = rspLen;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -235,10 +235,10 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesNodeToString(pPlan, false, pStr, NULL);
|
code = nodesNodeToString((SNode*)pPlan, false, pStr, NULL);
|
||||||
}
|
}
|
||||||
nodesDestroyNode(pAst);
|
nodesDestroyNode(pAst);
|
||||||
nodesDestroyNode(pPlan);
|
nodesDestroyNode((SNode*)pPlan);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,15 +188,15 @@ int32_t mndInitSync(SMnode *pMnode) {
|
||||||
syncInfo.isStandBy = pMgmt->standby;
|
syncInfo.isStandBy = pMgmt->standby;
|
||||||
syncInfo.snapshotEnable = true;
|
syncInfo.snapshotEnable = true;
|
||||||
|
|
||||||
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
mInfo("start to open mnode sync, standby:%d", pMgmt->standby);
|
||||||
pCfg->replicaNum = pMnode->replica;
|
if (pMgmt->standby || pMgmt->replica.id > 0) {
|
||||||
pCfg->myIndex = pMnode->selfIndex;
|
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
||||||
mInfo("start to open mnode sync, replica:%d myindex:%d standby:%d", pCfg->replicaNum, pCfg->myIndex, pMgmt->standby);
|
pCfg->replicaNum = 1;
|
||||||
for (int32_t i = 0; i < pMnode->replica; ++i) {
|
pCfg->myIndex = 0;
|
||||||
SNodeInfo *pNode = &pCfg->nodeInfo[i];
|
SNodeInfo *pNode = &pCfg->nodeInfo[0];
|
||||||
tstrncpy(pNode->nodeFqdn, pMnode->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
|
tstrncpy(pNode->nodeFqdn, pMgmt->replica.fqdn, sizeof(pNode->nodeFqdn));
|
||||||
pNode->nodePort = pMnode->replicas[i].port;
|
pNode->nodePort = pMgmt->replica.port;
|
||||||
mInfo("index:%d, fqdn:%s port:%d", i, pNode->nodeFqdn, pNode->nodePort);
|
mInfo("fqdn:%s port:%u", pNode->nodeFqdn, pNode->nodePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsem_init(&pMgmt->syncSem, 0, 0);
|
tsem_init(&pMgmt->syncSem, 0, 0);
|
||||||
|
@ -236,7 +236,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
tsem_wait(&pMgmt->syncSem);
|
tsem_wait(&pMgmt->syncSem);
|
||||||
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
||||||
terrno = TSDB_CODE_APP_NOT_READY;
|
terrno = TSDB_CODE_APP_NOT_READY;
|
||||||
} else if (code == TAOS_SYNC_PROPOSE_OTHER_ERROR) {
|
} else if (code == TAOS_SYNC_OTHER_ERROR) {
|
||||||
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_APP_ERROR;
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
|
@ -254,13 +254,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
|
||||||
void mndSyncStart(SMnode *pMnode) {
|
void mndSyncStart(SMnode *pMnode) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
|
||||||
|
syncStart(pMgmt->sync);
|
||||||
|
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
||||||
|
|
||||||
|
/*
|
||||||
if (pMgmt->standby) {
|
if (pMgmt->standby) {
|
||||||
syncStartStandBy(pMgmt->sync);
|
syncStartStandBy(pMgmt->sync);
|
||||||
} else {
|
} else {
|
||||||
syncStart(pMgmt->sync);
|
syncStart(pMgmt->sync);
|
||||||
}
|
}
|
||||||
mDebug("mnode sync started, id:%" PRId64 " standby:%d", pMgmt->sync, pMgmt->standby);
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndSyncStop(SMnode *pMnode) {}
|
void mndSyncStop(SMnode *pMnode) {}
|
||||||
|
|
|
@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
if (nodesNodeToString((SNode*)pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||||
taosMemoryFree(topicObj.ast);
|
taosMemoryFree(topicObj.ast);
|
||||||
taosMemoryFree(topicObj.sql);
|
taosMemoryFree(topicObj.sql);
|
||||||
|
|
|
@ -1347,13 +1347,11 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
STransAction *pAction = taosArrayGet(pArray, i);
|
STransAction *pAction = taosArrayGet(pArray, i);
|
||||||
if (pAction->errCode != 0) {
|
mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id,
|
||||||
mInfo("trans:%d, %s:%d set processed for kill msg received, errCode from %s to success", pTrans->id,
|
mndTransStr(pAction->stage), i, tstrerror(pAction->errCode));
|
||||||
mndTransStr(pAction->stage), i, tstrerror(pAction->errCode));
|
pAction->msgSent = 1;
|
||||||
pAction->msgSent = 1;
|
pAction->msgReceived = 1;
|
||||||
pAction->msgReceived = 1;
|
pAction->errCode = 0;
|
||||||
pAction->errCode = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mndTransExecute(pMnode, pTrans);
|
mndTransExecute(pMnode, pTrans);
|
||||||
|
|
|
@ -322,6 +322,33 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *mndBuildSetVnodeStandbyReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||||
|
SSetStandbyReq standbyReq = {0};
|
||||||
|
standbyReq.dnodeId = pDnode->id;
|
||||||
|
standbyReq.standby = 1;
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSSetStandbyReq(NULL, 0, &standbyReq);
|
||||||
|
if (contLen < 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
contLen += sizeof(SMsgHead);
|
||||||
|
void *pReq = taosMemoryMalloc(contLen);
|
||||||
|
if (pReq == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerializeSSetStandbyReq((char *)pReq + sizeof(SMsgHead), contLen, &standbyReq);
|
||||||
|
SMsgHead *pHead = pReq;
|
||||||
|
pHead->contLen = htonl(contLen);
|
||||||
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
|
*pContLen = contLen;
|
||||||
|
return pReq;
|
||||||
|
}
|
||||||
|
|
||||||
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||||
SDropVnodeReq dropReq = {0};
|
SDropVnodeReq dropReq = {0};
|
||||||
dropReq.dnodeId = pDnode->id;
|
dropReq.dnodeId = pDnode->id;
|
||||||
|
@ -898,6 +925,39 @@ int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
|
||||||
|
SVnodeGid *pVgid, bool isRedo) {
|
||||||
|
STransAction action = {0};
|
||||||
|
|
||||||
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||||
|
if (pDnode == NULL) return -1;
|
||||||
|
action.epSet = mndGetDnodeEpset(pDnode);
|
||||||
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
|
||||||
|
int32_t contLen = 0;
|
||||||
|
void *pReq = mndBuildSetVnodeStandbyReq(pMnode, pDnode, pDb, pVgroup, &contLen);
|
||||||
|
if (pReq == NULL) return -1;
|
||||||
|
|
||||||
|
action.pCont = pReq;
|
||||||
|
action.contLen = contLen;
|
||||||
|
action.msgType = TDMT_SYNC_SET_VNODE_STANDBY;
|
||||||
|
action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED;
|
||||||
|
|
||||||
|
if (isRedo) {
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mndTransAppendUndoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pReq);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
||||||
bool isRedo) {
|
bool isRedo) {
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
@ -952,6 +1012,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
|
||||||
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
SVnodeGid del = newVg.vnodeGid[vnIndex];
|
||||||
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
newVg.vnodeGid[vnIndex] = newVg.vnodeGid[newVg.replica];
|
||||||
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
memset(&newVg.vnodeGid[newVg.replica], 0, sizeof(SVnodeGid));
|
||||||
|
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1;
|
||||||
|
@ -1031,6 +1092,7 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
|
||||||
memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid));
|
memcpy(pGid, &pVgroup->vnodeGid[pVgroup->replica], sizeof(SVnodeGid));
|
||||||
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
||||||
|
|
||||||
|
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, pVgroup) != 0) return -1;
|
||||||
|
@ -1341,12 +1403,14 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S
|
||||||
|
|
||||||
SVnodeGid del1 = {0};
|
SVnodeGid del1 = {0};
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
||||||
|
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
|
|
||||||
SVnodeGid del2 = {0};
|
SVnodeGid del2 = {0};
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
||||||
|
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del2, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
|
@ -1396,6 +1460,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
||||||
} else if (newVg1.replica == 3) {
|
} else if (newVg1.replica == 3) {
|
||||||
SVnodeGid del1 = {0};
|
SVnodeGid del1 = {0};
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVg1, pArray, &del1) != 0) goto _OVER;
|
||||||
|
if (mndAddSetVnodeStandByAction(pMnode, pTrans, pDb, pVgroup, &del1, true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg1, TDMT_VND_ALTER_REPLICA) != 0) goto _OVER;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
|
||||||
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
|
||||||
|
|
|
@ -31,7 +31,7 @@ target_sources(
|
||||||
"src/sma/smaEnv.c"
|
"src/sma/smaEnv.c"
|
||||||
"src/sma/smaOpen.c"
|
"src/sma/smaOpen.c"
|
||||||
"src/sma/smaRollup.c"
|
"src/sma/smaRollup.c"
|
||||||
"src/sma/smaTimeRange2.c"
|
"src/sma/smaTimeRange.c"
|
||||||
|
|
||||||
# tsdb
|
# tsdb
|
||||||
"src/tsdb/tsdbCommit.c"
|
"src/tsdb/tsdbCommit.c"
|
||||||
|
|
|
@ -38,8 +38,6 @@ typedef struct SSmaStatItem SSmaStatItem;
|
||||||
typedef struct SSmaKey SSmaKey;
|
typedef struct SSmaKey SSmaKey;
|
||||||
typedef struct SRSmaInfo SRSmaInfo;
|
typedef struct SRSmaInfo SRSmaInfo;
|
||||||
|
|
||||||
#define SMA_IVLD_FID INT_MIN
|
|
||||||
|
|
||||||
struct SSmaEnv {
|
struct SSmaEnv {
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
@ -49,45 +47,38 @@ struct SSmaEnv {
|
||||||
#define SMA_ENV_LOCK(env) ((env)->lock)
|
#define SMA_ENV_LOCK(env) ((env)->lock)
|
||||||
#define SMA_ENV_TYPE(env) ((env)->type)
|
#define SMA_ENV_TYPE(env) ((env)->type)
|
||||||
#define SMA_ENV_STAT(env) ((env)->pStat)
|
#define SMA_ENV_STAT(env) ((env)->pStat)
|
||||||
#define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems)
|
#define SMA_ENV_STAT_ITEM(env) ((env)->pStat->tsmaStatItem)
|
||||||
|
|
||||||
struct SSmaStatItem {
|
struct SSmaStatItem {
|
||||||
int8_t state; // ETsdbSmaStat
|
int8_t state; // ETsdbSmaStat
|
||||||
STSma *pTSma; // cache schema
|
STSma *pTSma; // cache schema
|
||||||
|
STSchema *pTSchema;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSmaStat {
|
struct SSmaStat {
|
||||||
union {
|
union {
|
||||||
SHashObj *smaStatItems; // key: indexUid, value: SSmaStatItem for tsma
|
SSmaStatItem tsmaStatItem;
|
||||||
SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo;
|
SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo;
|
||||||
};
|
};
|
||||||
T_REF_DECLARE()
|
T_REF_DECLARE()
|
||||||
};
|
};
|
||||||
#define SMA_STAT_ITEMS(s) ((s)->smaStatItems)
|
#define SMA_STAT_ITEM(s) ((s)->tsmaStatItem)
|
||||||
#define SMA_STAT_INFO_HASH(s) ((s)->rsmaInfoHash)
|
#define SMA_STAT_INFO_HASH(s) ((s)->rsmaInfoHash)
|
||||||
|
|
||||||
void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
|
void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
|
||||||
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
|
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
|
||||||
#if 0
|
|
||||||
int32_t tbGetTSmaStatus(SSma *pSma, STSma *param, void *result);
|
|
||||||
int32_t tbRemoveTSmaData(SSma *pSma, STSma *param, STimeWindow *pWin);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t tdInitSma(SSma *pSma);
|
|
||||||
int32_t tdDropTSma(SSma *pSma, char *pMsg);
|
int32_t tdDropTSma(SSma *pSma, char *pMsg);
|
||||||
int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid);
|
int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid);
|
||||||
int32_t tdInsertRSmaData(SSma *pSma, char *msg);
|
int32_t tdInsertRSmaData(SSma *pSma, char *msg);
|
||||||
|
|
||||||
int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat);
|
int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat);
|
||||||
int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat);
|
int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat);
|
||||||
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck);
|
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
|
||||||
|
|
||||||
int32_t tdLockSma(SSma *pSma);
|
int32_t tdLockSma(SSma *pSma);
|
||||||
int32_t tdUnLockSma(SSma *pSma);
|
int32_t tdUnLockSma(SSma *pSma);
|
||||||
|
|
||||||
static FORCE_INLINE int16_t tdTSmaAdd(SSma *pSma, int16_t n) { return atomic_add_fetch_16(&SMA_TSMA_NUM(pSma), n); }
|
|
||||||
static FORCE_INLINE int16_t tdTSmaSub(SSma *pSma, int16_t n) { return atomic_sub_fetch_16(&SMA_TSMA_NUM(pSma), n); }
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdRLockSmaEnv(SSmaEnv *pEnv) {
|
static FORCE_INLINE int32_t tdRLockSmaEnv(SSmaEnv *pEnv) {
|
||||||
int code = taosThreadRwlockRdlock(&(pEnv->lock));
|
int code = taosThreadRwlockRdlock(&(pEnv->lock));
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -160,11 +151,10 @@ static FORCE_INLINE void tdSmaStatSetDropped(SSmaStatItem *pStatItem) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType);
|
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType);
|
||||||
void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem);
|
void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem);
|
||||||
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, SDiskID did);
|
void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
|
||||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskID did, SSmaEnv **pEnv);
|
|
||||||
|
|
||||||
void *tdFreeRSmaInfo(SRSmaInfo *pInfo);
|
void *tdFreeRSmaInfo(SRSmaInfo *pInfo);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ extern "C" {
|
||||||
#define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0)
|
#define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
typedef struct STqOffsetCfg STqOffsetCfg;
|
|
||||||
typedef struct STqOffsetStore STqOffsetStore;
|
typedef struct STqOffsetStore STqOffsetStore;
|
||||||
|
|
||||||
// tqRead
|
// tqRead
|
||||||
|
@ -127,14 +126,15 @@ typedef struct {
|
||||||
} STqHandle;
|
} STqHandle;
|
||||||
|
|
||||||
struct STQ {
|
struct STQ {
|
||||||
char* path;
|
char* path;
|
||||||
SHashObj* pushMgr; // consumerId -> STqHandle*
|
SHashObj* pushMgr; // consumerId -> STqHandle*
|
||||||
SHashObj* handles; // subKey -> STqHandle
|
SHashObj* handles; // subKey -> STqHandle
|
||||||
SHashObj* pStreamTasks; // taksId -> SStreamTask
|
SHashObj* pStreamTasks; // taksId -> SStreamTask
|
||||||
SVnode* pVnode;
|
STqOffsetStore* pOffsetStore;
|
||||||
SWal* pWal;
|
SVnode* pVnode;
|
||||||
TDB* pMetaStore;
|
SWal* pWal;
|
||||||
TTB* pExecStore;
|
TDB* pMetaStore;
|
||||||
|
TTB* pExecStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -157,17 +157,19 @@ int32_t tqMetaClose(STQ* pTq);
|
||||||
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle);
|
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle);
|
||||||
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key);
|
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t size;
|
||||||
|
} STqOffsetHead;
|
||||||
|
|
||||||
|
STqOffsetStore* tqOffsetOpen();
|
||||||
|
void tqOffsetClose(STqOffsetStore*);
|
||||||
|
STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey);
|
||||||
|
int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset);
|
||||||
|
int32_t tqOffsetSnapshot(STqOffsetStore* pStore);
|
||||||
|
|
||||||
// tqSink
|
// tqSink
|
||||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data);
|
||||||
|
|
||||||
// tqOffset
|
|
||||||
STqOffsetStore* tqOffsetOpen(STqOffsetCfg*);
|
|
||||||
void tqOffsetClose(STqOffsetStore*);
|
|
||||||
int64_t tqOffsetFetch(STqOffsetStore* pStore, const char* subscribeKey);
|
|
||||||
int32_t tqOffsetCommit(STqOffsetStore* pStore, const char* subscribeKey, int64_t offset);
|
|
||||||
int32_t tqOffsetPersist(STqOffsetStore* pStore, const char* subscribeKey);
|
|
||||||
int32_t tqOffsetPersistAll(STqOffsetStore* pStore);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -137,6 +137,7 @@ int tqCommit(STQ*);
|
||||||
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd);
|
int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd);
|
||||||
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
|
int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId);
|
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId);
|
||||||
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen);
|
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen);
|
||||||
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data);
|
int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data);
|
||||||
|
@ -146,6 +147,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg);
|
int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg);
|
||||||
|
|
||||||
|
SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid,
|
||||||
|
const char* stbFullName, int32_t vgId);
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
int32_t smaOpen(SVnode* pVnode);
|
int32_t smaOpen(SVnode* pVnode);
|
||||||
int32_t smaClose(SSma* pSma);
|
int32_t smaClose(SSma* pSma);
|
||||||
|
@ -244,7 +248,6 @@ struct STbUidStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSma {
|
struct SSma {
|
||||||
int16_t nTSma;
|
|
||||||
bool locked;
|
bool locked;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
|
@ -260,7 +263,6 @@ struct SSma {
|
||||||
#define SMA_META(s) ((s)->pVnode->pMeta)
|
#define SMA_META(s) ((s)->pVnode->pMeta)
|
||||||
#define SMA_VID(s) TD_VID((s)->pVnode)
|
#define SMA_VID(s) TD_VID((s)->pVnode)
|
||||||
#define SMA_TFS(s) ((s)->pVnode->pTfs)
|
#define SMA_TFS(s) ((s)->pVnode->pTfs)
|
||||||
#define SMA_TSMA_NUM(s) ((s)->nTSma)
|
|
||||||
#define SMA_TSMA_ENV(s) ((s)->pTSmaEnv)
|
#define SMA_TSMA_ENV(s) ((s)->pTSmaEnv)
|
||||||
#define SMA_RSMA_ENV(s) ((s)->pRSmaEnv)
|
#define SMA_RSMA_ENV(s) ((s)->pRSmaEnv)
|
||||||
#define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb)
|
#define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb)
|
||||||
|
|
|
@ -75,7 +75,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma) < 0) return -1;
|
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -663,12 +663,23 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
|
||||||
|
|
||||||
void * entryKey = NULL, *entryVal = NULL;
|
void * entryKey = NULL, *entryVal = NULL;
|
||||||
int32_t nEntryKey, nEntryVal;
|
int32_t nEntryKey, nEntryVal;
|
||||||
|
bool first = true;
|
||||||
while (1) {
|
while (1) {
|
||||||
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
||||||
if (valid < 0) {
|
if (valid < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
STagIdxKey *p = entryKey;
|
STagIdxKey *p = entryKey;
|
||||||
|
if (p->type != pCursor->type) {
|
||||||
|
if (first) {
|
||||||
|
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||||
|
if (valid < 0) break;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
int32_t cmp = (*param->filterFunc)(p->data, pKey->data, pKey->type);
|
int32_t cmp = (*param->filterFunc)(p->data, pKey->data, pKey->type);
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
|
|
|
@ -44,3 +44,209 @@ int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t*
|
||||||
smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days);
|
smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO: Assume that the final generated result it less than 3M
|
||||||
|
*
|
||||||
|
* @param pReq
|
||||||
|
* @param pDataBlocks
|
||||||
|
* @param vgId
|
||||||
|
* @param suid // TODO: check with Liao whether suid response is reasonable
|
||||||
|
*
|
||||||
|
* TODO: colId should be set
|
||||||
|
*/
|
||||||
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
||||||
|
tb_uid_t suid, const char* stbName, bool isCreateCtb) {
|
||||||
|
int32_t sz = taosArrayGetSize(pDataBlocks);
|
||||||
|
int32_t bufSize = sizeof(SSubmitReq);
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info;
|
||||||
|
bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(pBlkInfo->numOfCols));
|
||||||
|
bufSize += sizeof(SSubmitBlk);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pReq = taosMemoryCalloc(1, bufSize);
|
||||||
|
if (!(*pReq)) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
void* pDataBuf = *pReq;
|
||||||
|
|
||||||
|
SArray* pTagArray = NULL;
|
||||||
|
int32_t msgLen = sizeof(SSubmitReq);
|
||||||
|
int32_t numOfBlks = 0;
|
||||||
|
int32_t schemaLen = 0;
|
||||||
|
SRowBuilder rb = {0};
|
||||||
|
tdSRowInit(&rb, pTSchema->version);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
|
||||||
|
SDataBlockInfo* pDataBlkInfo = &pDataBlock->info;
|
||||||
|
int32_t colNum = pDataBlkInfo->numOfCols;
|
||||||
|
int32_t rows = pDataBlkInfo->rows;
|
||||||
|
int32_t rowSize = pDataBlkInfo->rowSize;
|
||||||
|
int64_t groupId = pDataBlkInfo->groupId;
|
||||||
|
|
||||||
|
if (rb.nCols != colNum) {
|
||||||
|
tdSRowSetTpInfo(&rb, colNum, pTSchema->flen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isCreateCtb) {
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
const char* ctbName = buildCtbNameByGroupId(stbName, pDataBlock->info.groupId);
|
||||||
|
if (metaGetTableEntryByName(&mr, ctbName) != 0) {
|
||||||
|
smaDebug("vgId:%d, no tsma ctb %s exists", vgId, ctbName);
|
||||||
|
}
|
||||||
|
SVCreateTbReq ctbReq = {0};
|
||||||
|
ctbReq.name = ctbName;
|
||||||
|
ctbReq.type = TSDB_CHILD_TABLE;
|
||||||
|
ctbReq.ctb.suid = suid;
|
||||||
|
|
||||||
|
STagVal tagVal = {.cid = colNum + PRIMARYKEY_TIMESTAMP_COL_ID,
|
||||||
|
.type = TSDB_DATA_TYPE_BIGINT,
|
||||||
|
.i64 = groupId};
|
||||||
|
STag* pTag = NULL;
|
||||||
|
if(!pTagArray) {
|
||||||
|
pTagArray = taosArrayInit(1, sizeof(STagVal));
|
||||||
|
if (!pTagArray) goto _err;
|
||||||
|
}
|
||||||
|
taosArrayClear(pTagArray);
|
||||||
|
taosArrayPush(pTagArray, &tagVal);
|
||||||
|
tTagNew(pTagArray, 1, false, &pTag);
|
||||||
|
if (pTag == NULL) {
|
||||||
|
tdDestroySVCreateTbReq(&ctbReq);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
ctbReq.ctb.pTag = (uint8_t*)pTag;
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSVCreateTbReq, &ctbReq, schemaLen, code);
|
||||||
|
|
||||||
|
tdDestroySVCreateTbReq(&ctbReq);
|
||||||
|
if (code < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SSubmitBlk* pSubmitBlk = POINTER_SHIFT(pDataBuf, msgLen);
|
||||||
|
pSubmitBlk->suid = suid;
|
||||||
|
pSubmitBlk->uid = groupId;
|
||||||
|
pSubmitBlk->numOfRows = rows;
|
||||||
|
|
||||||
|
msgLen += sizeof(SSubmitBlk);
|
||||||
|
int32_t dataLen = 0;
|
||||||
|
for (int32_t j = 0; j < rows; ++j) { // iterate by row
|
||||||
|
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf
|
||||||
|
bool isStartKey = false;
|
||||||
|
int32_t offset = 0;
|
||||||
|
for (int32_t k = 0; k < colNum; ++k) { // iterate by column
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
|
STColumn* pCol = &pTSchema->columns[k];
|
||||||
|
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||||
|
switch (pColInfoData->info.type) {
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
if (!isStartKey) {
|
||||||
|
isStartKey = true;
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true,
|
||||||
|
offset, k);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var,
|
||||||
|
true, offset, k);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true,
|
||||||
|
offset, k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true,
|
||||||
|
offset, k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
|
case TSDB_DATA_TYPE_BLOB:
|
||||||
|
case TSDB_DATA_TYPE_JSON:
|
||||||
|
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||||
|
uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type);
|
||||||
|
TASSERT(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
|
||||||
|
if (pCol->type == pColInfoData->info.type) {
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset,
|
||||||
|
k);
|
||||||
|
} else {
|
||||||
|
char tv[8] = {0};
|
||||||
|
if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
float v = 0;
|
||||||
|
GET_TYPED_DATA(v, float, pColInfoData->info.type, var);
|
||||||
|
SET_TYPED_DATA(&tv, pCol->type, v);
|
||||||
|
} else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
double v = 0;
|
||||||
|
GET_TYPED_DATA(v, double, pColInfoData->info.type, var);
|
||||||
|
SET_TYPED_DATA(&tv, pCol->type, v);
|
||||||
|
} else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) {
|
||||||
|
int64_t v = 0;
|
||||||
|
GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var);
|
||||||
|
SET_TYPED_DATA(&tv, pCol->type, v);
|
||||||
|
} else {
|
||||||
|
uint64_t v = 0;
|
||||||
|
GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var);
|
||||||
|
SET_TYPED_DATA(&tv, pCol->type, v);
|
||||||
|
}
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset,
|
||||||
|
k);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
|
||||||
|
TASSERT(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset += TYPE_BYTES[pCol->type]; // sum/avg would convert to int64_t/uint64_t/double during aggregation
|
||||||
|
}
|
||||||
|
dataLen += TD_ROW_LEN(rb.pBuf);
|
||||||
|
#ifdef TD_DEBUG_PRINT_ROW
|
||||||
|
tdSRowPrint(rb.pBuf, pTSchema, __func__);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
++numOfBlks;
|
||||||
|
|
||||||
|
pSubmitBlk->dataLen = dataLen;
|
||||||
|
msgLen += pSubmitBlk->dataLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pReq)->length = msgLen;
|
||||||
|
|
||||||
|
(*pReq)->header.vgId = htonl(vgId);
|
||||||
|
(*pReq)->header.contLen = htonl(msgLen);
|
||||||
|
(*pReq)->length = (*pReq)->header.contLen;
|
||||||
|
(*pReq)->numOfBlocks = htonl(numOfBlks);
|
||||||
|
SSubmitBlk* blk = (SSubmitBlk*)((*pReq) + 1);
|
||||||
|
while (numOfBlks--) {
|
||||||
|
int32_t dataLen = blk->dataLen;
|
||||||
|
blk->uid = htobe64(blk->uid);
|
||||||
|
blk->suid = htobe64(blk->suid);
|
||||||
|
blk->padding = htonl(blk->padding);
|
||||||
|
blk->sversion = htonl(blk->sversion);
|
||||||
|
blk->dataLen = htonl(blk->dataLen);
|
||||||
|
blk->schemaLen = htonl(blk->schemaLen);
|
||||||
|
blk->numOfRows = htons(blk->numOfRows);
|
||||||
|
blk = (SSubmitBlk*)(blk->data + dataLen);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_err:
|
||||||
|
taosMemoryFreeClear(*pReq);
|
||||||
|
taosArrayDestroy(pTagArray);
|
||||||
|
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -17,123 +17,17 @@
|
||||||
|
|
||||||
typedef struct SSmaStat SSmaStat;
|
typedef struct SSmaStat SSmaStat;
|
||||||
|
|
||||||
static const char *TSDB_SMA_DNAME[] = {
|
|
||||||
"", // TSDB_SMA_TYPE_BLOCK
|
|
||||||
"tsma", // TSDB_SMA_TYPE_TIME_RANGE
|
|
||||||
"rsma", // TSDB_SMA_TYPE_ROLLUP
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SMA_TEST_INDEX_NAME "smaTestIndexName" // TODO: just for test
|
|
||||||
#define SMA_TEST_INDEX_UID 2000000001 // TODO: just for test
|
|
||||||
#define SMA_STATE_HASH_SLOT 4
|
|
||||||
|
|
||||||
#define RSMA_TASK_INFO_HASH_SLOT 8
|
#define RSMA_TASK_INFO_HASH_SLOT 8
|
||||||
|
|
||||||
typedef struct SPoolMem {
|
|
||||||
int64_t size;
|
|
||||||
struct SPoolMem *prev;
|
|
||||||
struct SPoolMem *next;
|
|
||||||
} SPoolMem;
|
|
||||||
|
|
||||||
// declaration of static functions
|
// declaration of static functions
|
||||||
|
|
||||||
// insert data
|
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType);
|
||||||
|
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path);
|
||||||
static void tdGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]);
|
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv);
|
||||||
|
|
||||||
// Pool Memory
|
|
||||||
static SPoolMem *openPool();
|
|
||||||
static void clearPool(SPoolMem *pPool);
|
|
||||||
static void closePool(SPoolMem *pPool);
|
|
||||||
static void *poolMalloc(void *arg, size_t size);
|
|
||||||
static void poolFree(void *arg, void *ptr);
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
static SPoolMem *openPool() {
|
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path) {
|
||||||
SPoolMem *pPool = (SPoolMem *)taosMemoryMalloc(sizeof(*pPool));
|
|
||||||
|
|
||||||
pPool->prev = pPool->next = pPool;
|
|
||||||
pPool->size = 0;
|
|
||||||
|
|
||||||
return pPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clearPool(SPoolMem *pPool) {
|
|
||||||
if (!pPool) return;
|
|
||||||
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
do {
|
|
||||||
pMem = pPool->next;
|
|
||||||
|
|
||||||
if (pMem == pPool) break;
|
|
||||||
|
|
||||||
pMem->next->prev = pMem->prev;
|
|
||||||
pMem->prev->next = pMem->next;
|
|
||||||
pPool->size -= pMem->size;
|
|
||||||
|
|
||||||
taosMemoryFree(pMem);
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
assert(pPool->size == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void closePool(SPoolMem *pPool) {
|
|
||||||
if (pPool) {
|
|
||||||
clearPool(pPool);
|
|
||||||
taosMemoryFree(pPool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *poolMalloc(void *arg, size_t size) {
|
|
||||||
void *ptr = NULL;
|
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
pMem = (SPoolMem *)taosMemoryMalloc(sizeof(*pMem) + size);
|
|
||||||
if (!pMem) {
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
pMem->size = sizeof(*pMem) + size;
|
|
||||||
pMem->next = pPool->next;
|
|
||||||
pMem->prev = pPool;
|
|
||||||
|
|
||||||
pPool->next->prev = pMem;
|
|
||||||
pPool->next = pMem;
|
|
||||||
pPool->size += pMem->size;
|
|
||||||
|
|
||||||
ptr = (void *)(&pMem[1]);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void poolFree(void *arg, void *ptr) {
|
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
|
||||||
SPoolMem *pMem;
|
|
||||||
|
|
||||||
pMem = &(((SPoolMem *)ptr)[-1]);
|
|
||||||
|
|
||||||
pMem->next->prev = pMem->prev;
|
|
||||||
pMem->prev->next = pMem->next;
|
|
||||||
pPool->size -= pMem->size;
|
|
||||||
|
|
||||||
taosMemoryFree(pMem);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tdInitSma(SSma *pSma) {
|
|
||||||
int32_t numOfTSma = taosArrayGetSize(metaGetSmaTbUids(SMA_META(pSma)));
|
|
||||||
if (numOfTSma > 0) {
|
|
||||||
atomic_store_16(&SMA_TSMA_NUM(pSma), (int16_t)numOfTSma);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tdGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) {
|
|
||||||
snprintf(dirName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s", TD_DIRSEP, vgId, TD_DIRSEP, TSDB_SMA_DNAME[smaType]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path, SDiskID did) {
|
|
||||||
SSmaEnv *pEnv = NULL;
|
SSmaEnv *pEnv = NULL;
|
||||||
|
|
||||||
pEnv = (SSmaEnv *)taosMemoryCalloc(1, sizeof(SSmaEnv));
|
pEnv = (SSmaEnv *)taosMemoryCalloc(1, sizeof(SSmaEnv));
|
||||||
|
@ -156,18 +50,17 @@ static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return pEnv;
|
return pEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskID did, SSmaEnv **pEnv) {
|
static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaEnv **pEnv) {
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*pEnv)) {
|
if (!(*pEnv)) {
|
||||||
if (!(*pEnv = tdNewSmaEnv(pSma, smaType, path, did))) {
|
if (!(*pEnv = tdNewSmaEnv(pSma, smaType, path))) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,15 +76,16 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SDiskI
|
||||||
*/
|
*/
|
||||||
void tdDestroySmaEnv(SSmaEnv *pSmaEnv) {
|
void tdDestroySmaEnv(SSmaEnv *pSmaEnv) {
|
||||||
if (pSmaEnv) {
|
if (pSmaEnv) {
|
||||||
tdDestroySmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv));
|
pSmaEnv->pStat = tdFreeSmaState(pSmaEnv->pStat, SMA_ENV_TYPE(pSmaEnv));
|
||||||
taosMemoryFreeClear(pSmaEnv->pStat);
|
|
||||||
taosThreadRwlockDestroy(&(pSmaEnv->lock));
|
taosThreadRwlockDestroy(&(pSmaEnv->lock));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) {
|
void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) {
|
||||||
tdDestroySmaEnv(pSmaEnv);
|
if (pSmaEnv) {
|
||||||
taosMemoryFreeClear(pSmaEnv);
|
tdDestroySmaEnv(pSmaEnv);
|
||||||
|
taosMemoryFreeClear(pSmaEnv);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +133,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
} else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
} else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
||||||
SMA_STAT_ITEMS(*pSmaStat) =
|
// TODO
|
||||||
taosHashInit(SMA_STATE_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
|
||||||
|
|
||||||
if (!SMA_STAT_ITEMS(*pSmaStat)) {
|
|
||||||
taosMemoryFreeClear(*pSmaStat);
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -262,6 +150,12 @@ void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
||||||
|
tdDestroySmaState(pSmaStat, smaType);
|
||||||
|
taosMemoryFreeClear(pSmaStat);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Release resources allocated for its member fields, not including itself.
|
* @brief Release resources allocated for its member fields, not including itself.
|
||||||
*
|
*
|
||||||
|
@ -270,16 +164,10 @@ void *tdFreeSmaStatItem(SSmaStatItem *pSmaStatItem) {
|
||||||
*/
|
*/
|
||||||
int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
|
||||||
if (pSmaStat) {
|
if (pSmaStat) {
|
||||||
// TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready.
|
|
||||||
if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
|
||||||
void *item = taosHashIterate(SMA_STAT_ITEMS(pSmaStat), NULL);
|
tdFreeSmaStatItem(&pSmaStat->tsmaStatItem);
|
||||||
while (item) {
|
|
||||||
SSmaStatItem *pItem = *(SSmaStatItem **)item;
|
|
||||||
tdFreeSmaStatItem(pItem);
|
|
||||||
item = taosHashIterate(SMA_STAT_ITEMS(pSmaStat), item);
|
|
||||||
}
|
|
||||||
taosHashCleanup(SMA_STAT_ITEMS(pSmaStat));
|
|
||||||
} else if (smaType == TSDB_SMA_TYPE_ROLLUP) {
|
} else if (smaType == TSDB_SMA_TYPE_ROLLUP) {
|
||||||
|
// TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready.
|
||||||
void *infoHash = taosHashIterate(SMA_STAT_INFO_HASH(pSmaStat), NULL);
|
void *infoHash = taosHashIterate(SMA_STAT_INFO_HASH(pSmaStat), NULL);
|
||||||
while (infoHash) {
|
while (infoHash) {
|
||||||
SRSmaInfo *pInfoHash = *(SRSmaInfo **)infoHash;
|
SRSmaInfo *pInfoHash = *(SRSmaInfo **)infoHash;
|
||||||
|
@ -317,7 +205,7 @@ int32_t tdUnLockSma(SSma *pSma) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck) {
|
int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
|
||||||
SSmaEnv *pEnv = NULL;
|
SSmaEnv *pEnv = NULL;
|
||||||
|
|
||||||
// return if already init
|
// return if already init
|
||||||
|
@ -344,26 +232,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType, bool onlyCheck) {
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
char rname[TSDB_FILENAME_LEN] = {0};
|
char rname[TSDB_FILENAME_LEN] = {0};
|
||||||
|
|
||||||
SDiskID did = {0};
|
if (tdInitSmaEnv(pSma, smaType, rname, &pEnv) < 0) {
|
||||||
if (tfsAllocDisk(SMA_TFS(pSma), TFS_PRIMARY_LEVEL, &did) < 0) {
|
|
||||||
tdUnLockSma(pSma);
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (did.level < 0 || did.id < 0) {
|
|
||||||
tdUnLockSma(pSma);
|
|
||||||
smaError("vgId:%d, init sma env failed since invalid did(%d,%d)", SMA_VID(pSma), did.level, did.id);
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
tdGetSmaDir(SMA_VID(pSma), smaType, rname);
|
|
||||||
|
|
||||||
if (tfsMkdirRecurAt(SMA_TFS(pSma), rname, did) < 0) {
|
|
||||||
tdUnLockSma(pSma);
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tdInitSmaEnv(pSma, smaType, rname, did, &pEnv) < 0) {
|
|
||||||
tdUnLockSma(pSma);
|
tdUnLockSma(pSma);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,9 @@ int32_t smaClose(SSma *pSma) {
|
||||||
if SMA_RSMA_TSDB0 (pSma) tsdbClose(&SMA_RSMA_TSDB0(pSma));
|
if SMA_RSMA_TSDB0 (pSma) tsdbClose(&SMA_RSMA_TSDB0(pSma));
|
||||||
if SMA_RSMA_TSDB1 (pSma) tsdbClose(&SMA_RSMA_TSDB1(pSma));
|
if SMA_RSMA_TSDB1 (pSma) tsdbClose(&SMA_RSMA_TSDB1(pSma));
|
||||||
if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma));
|
if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma));
|
||||||
taosMemoryFree(pSma);
|
// SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma));
|
||||||
|
// SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma));
|
||||||
|
taosMemoryFreeClear(pSma);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -181,7 +181,7 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP, false) != TSDB_CODE_SUCCESS) {
|
if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_ROLLUP) != TSDB_CODE_SUCCESS) {
|
||||||
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,21 +16,9 @@
|
||||||
#include "sma.h"
|
#include "sma.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
typedef STsdbCfg STSmaKeepCfg;
|
|
||||||
|
|
||||||
#undef _TEST_SMA_PRINT_DEBUG_LOG_
|
|
||||||
#define SMA_STORAGE_MINUTES_MAX 86400
|
#define SMA_STORAGE_MINUTES_MAX 86400
|
||||||
#define SMA_STORAGE_MINUTES_DAY 1440
|
#define SMA_STORAGE_MINUTES_DAY 1440
|
||||||
#define SMA_STORAGE_MINUTES_MIN 1440
|
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
|
||||||
#define SMA_STORAGE_TSDB_MINUTES 86400
|
|
||||||
#define SMA_STORAGE_TSDB_TIMES 10
|
|
||||||
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file TODO: the feasible value?
|
|
||||||
#define SMA_KEY_LEN 16 // TSKEY+groupId 8+8
|
|
||||||
#define SMA_DROP_EXPIRED_TIME 10 // default is 10 seconds
|
|
||||||
|
|
||||||
#define SMA_STATE_ITEM_HASH_SLOT 32
|
|
||||||
|
|
||||||
// static func
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Judge the tsma file split days
|
* @brief Judge the tsma file split days
|
||||||
|
@ -80,79 +68,23 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read data
|
|
||||||
|
|
||||||
// implementation
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert/Update Time-range-wise SMA data.
|
* @brief create tsma meta and result stable
|
||||||
* - If interval < SMA_STORAGE_SPLIT_HOURS(e.g. 24), save the SMA data as a part of DFileSet to e.g.
|
|
||||||
* v3f1900.tsma.${sma_index_name}. The days is the same with that for TS data files.
|
|
||||||
* - If interval >= SMA_STORAGE_SPLIT_HOURS, save the SMA data to e.g. vnode3/tsma/v3f632.tsma.${sma_index_name}. The
|
|
||||||
* days is 30 times of the interval, and the minimum days is SMA_STORAGE_TSDB_DAYS(30d).
|
|
||||||
* - The destination file of one data block for some interval is determined by its start TS key.
|
|
||||||
*
|
*
|
||||||
* @param pSma
|
* @param pSma
|
||||||
* @param msg
|
* @param version
|
||||||
|
* @param pMsg
|
||||||
* @return int32_t
|
* @return int32_t
|
||||||
*/
|
*/
|
||||||
int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
|
||||||
STsdbCfg *pCfg = SMA_TSDB_CFG(pSma);
|
|
||||||
|
|
||||||
const SArray *pDataBlocks = (const SArray *)msg;
|
|
||||||
|
|
||||||
// TODO: destroy SSDataBlocks(msg)
|
|
||||||
|
|
||||||
// For super table aggregation, the sma data is stored in vgroup calculated from the hash value of stable name. Thus
|
|
||||||
// the sma data would arrive ahead of the update-expired-window msg.
|
|
||||||
if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE, false) != TSDB_CODE_SUCCESS) {
|
|
||||||
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pDataBlocks) {
|
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
|
||||||
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma));
|
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
|
||||||
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma));
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSmaEnv *pEnv = SMA_TSMA_ENV(pSma);
|
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
|
||||||
SSmaStatItem *pItem = NULL;
|
|
||||||
|
|
||||||
tdRefSmaStat(pSma, pStat);
|
|
||||||
|
|
||||||
if (pStat && SMA_STAT_ITEMS(pStat)) {
|
|
||||||
pItem = taosHashGet(SMA_STAT_ITEMS(pStat), &indexUid, sizeof(indexUid));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pItem || !(pItem = *(SSmaStatItem **)pItem) || tdSmaStatIsDropped(pItem)) {
|
|
||||||
terrno = TSDB_CODE_TSMA_INVALID_STAT;
|
|
||||||
tdUnRefSmaStat(pSma, pStat);
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
STSma *pTSma = pItem->pTSma;
|
|
||||||
|
|
||||||
tdUnRefSmaStat(pSma, pStat);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
|
int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
|
||||||
SSmaCfg *pCfg = (SSmaCfg *)pMsg;
|
SSmaCfg *pCfg = (SSmaCfg *)pMsg;
|
||||||
|
|
||||||
if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TD_VID(pSma->pVnode) == pCfg->dstVgId) {
|
if (TD_VID(pSma->pVnode) == pCfg->dstVgId) {
|
||||||
|
// create tsma meta in dstVgId
|
||||||
|
if (metaCreateTSma(SMA_META(pSma), version, pCfg) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// create stable to save tsma result in dstVgId
|
// create stable to save tsma result in dstVgId
|
||||||
SVCreateStbReq pReq = {0};
|
SVCreateStbReq pReq = {0};
|
||||||
pReq.name = pCfg->dstTbName;
|
pReq.name = pCfg->dstTbName;
|
||||||
|
@ -165,6 +97,82 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdTSmaAdd(pSma, 1);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert/Update Time-range-wise SMA data.
|
||||||
|
*
|
||||||
|
* @param pSma
|
||||||
|
* @param msg
|
||||||
|
* @return int32_t
|
||||||
|
*/
|
||||||
|
int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
|
||||||
|
const SArray *pDataBlocks = (const SArray *)msg;
|
||||||
|
// TODO: destroy SSDataBlocks(msg)
|
||||||
|
if (!pDataBlocks) {
|
||||||
|
terrno = TSDB_CODE_TSMA_INVALID_PTR;
|
||||||
|
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma));
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
||||||
|
terrno = TSDB_CODE_TSMA_INVALID_PARA;
|
||||||
|
smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma));
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) != 0) {
|
||||||
|
terrno = TSDB_CODE_TSMA_INIT_FAILED;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSmaEnv *pEnv = SMA_TSMA_ENV(pSma);
|
||||||
|
SSmaStat *pStat = NULL;
|
||||||
|
SSmaStatItem *pItem = NULL;
|
||||||
|
|
||||||
|
if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) {
|
||||||
|
terrno = TSDB_CODE_TSMA_INVALID_STAT;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
tdRefSmaStat(pSma, pStat);
|
||||||
|
pItem = &pStat->tsmaStatItem;
|
||||||
|
|
||||||
|
ASSERT(pItem);
|
||||||
|
|
||||||
|
if (!pItem->pTSma) {
|
||||||
|
STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid);
|
||||||
|
if (!pTSma) {
|
||||||
|
terrno = TSDB_CODE_TSMA_NO_INDEX_IN_META;
|
||||||
|
smaWarn("vgId:%d, tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), indexUid, tstrerror(terrno));
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
pItem->pTSma = pTSma;
|
||||||
|
pItem->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1);
|
||||||
|
ASSERT(pItem->pTSchema); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pItem->pTSma->indexUid == indexUid);
|
||||||
|
|
||||||
|
SSubmitReq *pSubmitReq = NULL;
|
||||||
|
|
||||||
|
pSubmitReq = tdBlockToSubmit((const SArray *)msg, pItem->pTSchema, true, pItem->pTSma->dstTbUid,
|
||||||
|
pItem->pTSma->dstTbName, pItem->pTSma->dstVgId);
|
||||||
|
|
||||||
|
ASSERT(pSubmitReq); // TODO
|
||||||
|
|
||||||
|
ASSERT(!strncasecmp("td.tsma.rst.tb", pItem->pTSma->dstTbName, 14));
|
||||||
|
|
||||||
|
SRpcMsg submitReqMsg = {
|
||||||
|
.msgType = TDMT_VND_SUBMIT,
|
||||||
|
.pCont = pSubmitReq,
|
||||||
|
.contLen = ntohl(pSubmitReq->length),
|
||||||
|
};
|
||||||
|
|
||||||
|
ASSERT(tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) == 0);
|
||||||
|
|
||||||
|
tdUnRefSmaStat(pSma, pStat);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
|
@ -47,7 +47,7 @@ void tqCleanUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||||
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
|
||||||
if (pTq == NULL) {
|
if (pTq == NULL) {
|
||||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -66,19 +66,23 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tqOffsetOpen(pTq) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
return pTq;
|
return pTq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqClose(STQ* pTq) {
|
void tqClose(STQ* pTq) {
|
||||||
if (pTq) {
|
if (pTq) {
|
||||||
taosMemoryFreeClear(pTq->path);
|
tqOffsetClose(pTq->pOffsetStore);
|
||||||
taosHashCleanup(pTq->handles);
|
taosHashCleanup(pTq->handles);
|
||||||
taosHashCleanup(pTq->pStreamTasks);
|
taosHashCleanup(pTq->pStreamTasks);
|
||||||
taosHashCleanup(pTq->pushMgr);
|
taosHashCleanup(pTq->pushMgr);
|
||||||
|
taosMemoryFree(pTq->path);
|
||||||
tqMetaClose(pTq);
|
tqMetaClose(pTq);
|
||||||
taosMemoryFree(pTq);
|
taosMemoryFree(pTq);
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) {
|
int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) {
|
||||||
|
@ -109,6 +113,33 @@ int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
|
STqOffset offset = {0};
|
||||||
|
SDecoder decoder;
|
||||||
|
tDecoderInit(&decoder, msg, msgLen);
|
||||||
|
if (tDecodeSTqOffset(&decoder, &offset) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
|
if (offset.type == TMQ_OFFSET__SNAPSHOT) {
|
||||||
|
tqDebug("receive offset commit msg to %s, offset(type:snapshot) uid: %ld, ts: %ld", offset.subKey, offset.uid,
|
||||||
|
offset.ts);
|
||||||
|
} else if (offset.type == TMQ_OFFSET__LOG) {
|
||||||
|
tqDebug("receive offset commit msg to %s, offset(type:log) version: %ld", offset.subKey, offset.version);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tqOffsetWrite(pTq->pOffsetStore, &offset) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
SMqPollReq* pReq = pMsg->pCont;
|
SMqPollReq* pReq = pMsg->pCont;
|
||||||
int64_t consumerId = pReq->consumerId;
|
int64_t consumerId = pReq->consumerId;
|
||||||
|
|
|
@ -16,26 +16,128 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
enum ETqOffsetPersist {
|
|
||||||
TQ_OFFSET_PERSIST__LAZY = 1,
|
|
||||||
TQ_OFFSET_PERSIST__EAGER,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct STqOffsetCfg {
|
|
||||||
int8_t persistPolicy;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct STqOffsetStore {
|
struct STqOffsetStore {
|
||||||
STqOffsetCfg cfg;
|
char* fname;
|
||||||
SHashObj* pHash; // SHashObj<subscribeKey, offset>
|
STQ* pTq;
|
||||||
|
SHashObj* pHash; // SHashObj<subscribeKey, offset>
|
||||||
};
|
};
|
||||||
|
|
||||||
STqOffsetStore* tqOffsetOpen(STqOffsetCfg* pCfg) {
|
static char* buildFileName(const char* path) {
|
||||||
STqOffsetStore* pStore = taosMemoryMalloc(sizeof(STqOffsetStore));
|
int32_t len = strlen(path);
|
||||||
|
char* fname = taosMemoryCalloc(1, len + 20);
|
||||||
|
snprintf(fname, len + 20, "%s/offset", path);
|
||||||
|
return fname;
|
||||||
|
}
|
||||||
|
|
||||||
|
STqOffsetStore* tqOffsetOpen(STQ* pTq) {
|
||||||
|
STqOffsetStore* pStore = taosMemoryCalloc(1, sizeof(STqOffsetStore));
|
||||||
if (pStore == NULL) {
|
if (pStore == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(&pStore->cfg, pCfg, sizeof(STqOffsetCfg));
|
pStore->pTq = pTq;
|
||||||
|
pTq->pOffsetStore = pStore;
|
||||||
|
|
||||||
pStore->pHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK);
|
pStore->pHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK);
|
||||||
|
if (pStore->pHash == NULL) {
|
||||||
|
if (pStore->pHash) taosHashCleanup(pStore->pHash);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
char* fname = buildFileName(pStore->pTq->path);
|
||||||
|
TdFilePtr pFile = taosOpenFile(fname, TD_FILE_READ);
|
||||||
|
if (pFile != NULL) {
|
||||||
|
STqOffsetHead head = {0};
|
||||||
|
int64_t code;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if ((code = taosReadFile(pFile, &head, sizeof(STqOffsetHead))) != sizeof(STqOffsetHead)) {
|
||||||
|
if (code == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
// TODO handle error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int32_t size = htonl(head.size);
|
||||||
|
void* memBuf = taosMemoryCalloc(1, size);
|
||||||
|
if ((code = taosReadFile(pFile, memBuf, size)) != size) {
|
||||||
|
ASSERT(0);
|
||||||
|
// TODO handle error
|
||||||
|
}
|
||||||
|
STqOffset offset;
|
||||||
|
SDecoder decoder;
|
||||||
|
tDecoderInit(&decoder, memBuf, size);
|
||||||
|
if (tDecodeSTqOffset(&decoder, &offset) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
if (taosHashPut(pStore->pHash, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset)) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
taosMemoryFree(fname);
|
||||||
|
}
|
||||||
return pStore;
|
return pStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tqOffsetClose(STqOffsetStore* pStore) {
|
||||||
|
tqOffsetSnapshot(pStore);
|
||||||
|
taosHashCleanup(pStore->pHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey) {
|
||||||
|
return (STqOffset*)taosHashGet(pStore->pHash, subscribeKey, strlen(subscribeKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset) {
|
||||||
|
return taosHashPut(pStore->pHash, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
|
||||||
|
// open file
|
||||||
|
// TODO file name should be with a version
|
||||||
|
char* fname = buildFileName(pStore->pTq->path);
|
||||||
|
TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
|
if (pFile == NULL) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
void* pIter = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = taosHashIterate(pStore->pHash, pIter);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
STqOffset* pOffset = (STqOffset*)pIter;
|
||||||
|
int32_t bodyLen;
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSTqOffset, pOffset, bodyLen, code);
|
||||||
|
ASSERT(code == 0);
|
||||||
|
if (code < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
taosHashCancelIterate(pStore->pHash, pIter);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t totLen = sizeof(STqOffsetHead) + bodyLen;
|
||||||
|
void* buf = taosMemoryCalloc(1, totLen);
|
||||||
|
void* abuf = POINTER_SHIFT(buf, sizeof(STqOffsetHead));
|
||||||
|
|
||||||
|
((STqOffsetHead*)buf)->size = htonl(bodyLen);
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, abuf, bodyLen);
|
||||||
|
tEncodeSTqOffset(&encoder, pOffset);
|
||||||
|
// write file
|
||||||
|
int64_t writeLen;
|
||||||
|
if ((writeLen = taosWriteFile(pFile, buf, totLen)) != bodyLen) {
|
||||||
|
ASSERT(0);
|
||||||
|
tqError("write offset incomplete, len %d, write len %ld", bodyLen, writeLen);
|
||||||
|
taosHashCancelIterate(pStore->pHash, pIter);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// close and rename file
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
taosMemoryFree(fname);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,174 @@
|
||||||
|
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
|
SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, bool createTb, int64_t suid,
|
||||||
|
const char* stbFullName, int32_t vgId) {
|
||||||
|
SSubmitReq* ret = NULL;
|
||||||
|
SArray* tagArray = taosArrayInit(1, sizeof(STagVal));
|
||||||
|
if (!tagArray) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cal size
|
||||||
|
int32_t cap = sizeof(SSubmitReq);
|
||||||
|
int32_t sz = taosArrayGetSize(pBlocks);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
|
int32_t rows = pDataBlock->info.rows;
|
||||||
|
// TODO min
|
||||||
|
int32_t rowSize = pDataBlock->info.rowSize;
|
||||||
|
int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);
|
||||||
|
int32_t schemaLen = 0;
|
||||||
|
|
||||||
|
if (createTb) {
|
||||||
|
SVCreateTbReq createTbReq = {0};
|
||||||
|
char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||||
|
createTbReq.name = cname;
|
||||||
|
createTbReq.flags = 0;
|
||||||
|
createTbReq.type = TSDB_CHILD_TABLE;
|
||||||
|
createTbReq.ctb.suid = suid;
|
||||||
|
|
||||||
|
STagVal tagVal = {
|
||||||
|
.cid = pDataBlock->info.numOfCols + 1,
|
||||||
|
.type = TSDB_DATA_TYPE_UBIGINT,
|
||||||
|
.i64 = (int64_t)pDataBlock->info.groupId,
|
||||||
|
};
|
||||||
|
STag* pTag = NULL;
|
||||||
|
taosArrayClear(tagArray);
|
||||||
|
taosArrayPush(tagArray, &tagVal);
|
||||||
|
tTagNew(tagArray, 1, false, &pTag);
|
||||||
|
if (pTag == NULL) {
|
||||||
|
tdDestroySVCreateTbReq(&createTbReq);
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
createTbReq.ctb.pTag = (uint8_t*)pTag;
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code);
|
||||||
|
|
||||||
|
tdDestroySVCreateTbReq(&createTbReq);
|
||||||
|
if (code < 0) {
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign data
|
||||||
|
// TODO
|
||||||
|
ret = rpcMallocCont(cap);
|
||||||
|
ret->header.vgId = vgId;
|
||||||
|
ret->version = htonl(1);
|
||||||
|
ret->length = sizeof(SSubmitReq);
|
||||||
|
ret->numOfBlocks = htonl(sz);
|
||||||
|
|
||||||
|
void* submitBlk = POINTER_SHIFT(ret, sizeof(SSubmitReq));
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||||
|
|
||||||
|
SSubmitBlk* blkHead = submitBlk;
|
||||||
|
blkHead->numOfRows = htons(pDataBlock->info.rows);
|
||||||
|
blkHead->sversion = htonl(pTSchema->version);
|
||||||
|
// TODO
|
||||||
|
blkHead->suid = htobe64(suid);
|
||||||
|
// uid is assigned by vnode
|
||||||
|
blkHead->uid = 0;
|
||||||
|
|
||||||
|
int32_t rows = pDataBlock->info.rows;
|
||||||
|
/*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/
|
||||||
|
/*blkHead->dataLen = htonl(rows * maxLen);*/
|
||||||
|
blkHead->dataLen = 0;
|
||||||
|
|
||||||
|
void* blockData = POINTER_SHIFT(submitBlk, sizeof(SSubmitBlk));
|
||||||
|
|
||||||
|
int32_t schemaLen = 0;
|
||||||
|
if (createTb) {
|
||||||
|
SVCreateTbReq createTbReq = {0};
|
||||||
|
char* cname = buildCtbNameByGroupId(stbFullName, pDataBlock->info.groupId);
|
||||||
|
createTbReq.name = cname;
|
||||||
|
createTbReq.flags = 0;
|
||||||
|
createTbReq.type = TSDB_CHILD_TABLE;
|
||||||
|
createTbReq.ctb.suid = suid;
|
||||||
|
|
||||||
|
STagVal tagVal = {
|
||||||
|
.cid = pDataBlock->info.numOfCols + 1,
|
||||||
|
.type = TSDB_DATA_TYPE_UBIGINT,
|
||||||
|
.i64 = (int64_t)pDataBlock->info.groupId,
|
||||||
|
};
|
||||||
|
taosArrayClear(tagArray);
|
||||||
|
taosArrayPush(tagArray, &tagVal);
|
||||||
|
STag* pTag = NULL;
|
||||||
|
tTagNew(tagArray, 1, false, &pTag);
|
||||||
|
if (pTag == NULL) {
|
||||||
|
tdDestroySVCreateTbReq(&createTbReq);
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
taosMemoryFreeClear(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
createTbReq.ctb.pTag = (uint8_t*)pTag;
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSVCreateTbReq, &createTbReq, schemaLen, code);
|
||||||
|
if (code < 0) {
|
||||||
|
tdDestroySVCreateTbReq(&createTbReq);
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
taosMemoryFreeClear(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SEncoder encoder = {0};
|
||||||
|
tEncoderInit(&encoder, blockData, schemaLen);
|
||||||
|
code = tEncodeSVCreateTbReq(&encoder, &createTbReq);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
tdDestroySVCreateTbReq(&createTbReq);
|
||||||
|
|
||||||
|
if (code < 0) {
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
taosMemoryFreeClear(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blkHead->schemaLen = htonl(schemaLen);
|
||||||
|
|
||||||
|
STSRow* rowData = POINTER_SHIFT(blockData, schemaLen);
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < rows; j++) {
|
||||||
|
SRowBuilder rb = {0};
|
||||||
|
tdSRowInit(&rb, pTSchema->version);
|
||||||
|
tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen);
|
||||||
|
tdSRowResetBuf(&rb, rowData);
|
||||||
|
|
||||||
|
for (int32_t k = 0; k < pTSchema->numOfCols; k++) {
|
||||||
|
const STColumn* pColumn = &pTSchema->columns[k];
|
||||||
|
SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
|
if (colDataIsNull_s(pColData, j)) {
|
||||||
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k);
|
||||||
|
} else {
|
||||||
|
void* data = colDataGetData(pColData, j);
|
||||||
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||||
|
rowData = POINTER_SHIFT(rowData, rowLen);
|
||||||
|
blkHead->dataLen += rowLen;
|
||||||
|
}
|
||||||
|
int32_t dataLen = blkHead->dataLen;
|
||||||
|
blkHead->dataLen = htonl(dataLen);
|
||||||
|
|
||||||
|
ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||||
|
blkHead = POINTER_SHIFT(blkHead, schemaLen + dataLen);
|
||||||
|
/*submitBlk = blkHead;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
ret->length = htonl(ret->length);
|
||||||
|
taosArrayDestroy(tagArray);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
|
||||||
const SArray* pRes = (const SArray*)data;
|
const SArray* pRes = (const SArray*)data;
|
||||||
SVnode* pVnode = (SVnode*)vnode;
|
SVnode* pVnode = (SVnode*)vnode;
|
||||||
|
|
|
@ -110,6 +110,8 @@ int32_t tsdbBegin(STsdb *pTsdb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCommit(STsdb *pTsdb) {
|
int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
|
if (!pTsdb) return 0;
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCommitH commith = {0};
|
SCommitH commith = {0};
|
||||||
SDFileSet *pSet = NULL;
|
SDFileSet *pSet = NULL;
|
||||||
|
|
|
@ -20,6 +20,7 @@ extern const char *TSDB_LEVEL_DNAME[];
|
||||||
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
||||||
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
||||||
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
|
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
|
||||||
|
#define TSDB_MAX_INIT_FSETS (365000)
|
||||||
|
|
||||||
static int tsdbComparFidFSet(const void *arg1, const void *arg2);
|
static int tsdbComparFidFSet(const void *arg1, const void *arg2);
|
||||||
static void tsdbResetFSStatus(SFSStatus *pStatus);
|
static void tsdbResetFSStatus(SFSStatus *pStatus);
|
||||||
|
@ -210,6 +211,10 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (maxFSet > TSDB_MAX_INIT_FSETS) {
|
||||||
|
maxFSet = TSDB_MAX_INIT_FSETS;
|
||||||
|
}
|
||||||
|
|
||||||
pfs->cstatus = tsdbNewFSStatus(maxFSet);
|
pfs->cstatus = tsdbNewFSStatus(maxFSet);
|
||||||
if (pfs->cstatus == NULL) {
|
if (pfs->cstatus == NULL) {
|
||||||
tsdbFreeFS(pfs);
|
tsdbFreeFS(pfs);
|
||||||
|
|
|
@ -148,17 +148,24 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
||||||
case TDMT_VND_MQ_VG_CHANGE:
|
case TDMT_VND_MQ_VG_CHANGE:
|
||||||
if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||||
// TODO: handle error
|
goto _err;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_MQ_VG_DELETE:
|
case TDMT_VND_MQ_VG_DELETE:
|
||||||
if (tqProcessVgDeleteReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) {
|
if (tqProcessVgDeleteReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) {
|
||||||
// TODO: handle error
|
goto _err;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TDMT_VND_MQ_COMMIT_OFFSET:
|
||||||
|
if (tqProcessOffsetCommitReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||||
|
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TDMT_STREAM_TASK_DEPLOY: {
|
case TDMT_STREAM_TASK_DEPLOY: {
|
||||||
if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case TDMT_VND_ALTER_CONFIRM:
|
case TDMT_VND_ALTER_CONFIRM:
|
||||||
|
@ -277,7 +284,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, int64_t version, SRpcMsg *pMsg, SRp
|
||||||
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// blockDebugShowData(data, __func__);
|
blockDebugShowData(data, __func__);
|
||||||
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +296,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
int32_t ret = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
int32_t ret = TAOS_SYNC_OTHER_ERROR;
|
||||||
|
|
||||||
if (syncEnvIsStart()) {
|
if (syncEnvIsStart()) {
|
||||||
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
SSyncNode *pSyncNode = syncNodeAcquire(pVnode->sync);
|
||||||
|
@ -368,15 +375,19 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
ret = syncNodeOnAppendEntriesReplyCb(pSyncNode, pSyncMsg);
|
||||||
syncAppendEntriesReplyDestroy(pSyncMsg);
|
syncAppendEntriesReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
|
} else if (pRpcMsg->msgType == TDMT_SYNC_SET_MNODE_STANDBY) {
|
||||||
|
ret = syncSetStandby(pVnode->sync);
|
||||||
|
SRpcMsg rsp = {.code = ret, .info = pMsg->info};
|
||||||
|
tmsgSendRsp(&rsp);
|
||||||
} else {
|
} else {
|
||||||
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
vError("==vnodeProcessSyncReq== error msg type:%d", pRpcMsg->msgType);
|
||||||
ret = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
ret = TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncNodeRelease(pSyncNode);
|
syncNodeRelease(pSyncNode);
|
||||||
} else {
|
} else {
|
||||||
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
vError("==vnodeProcessSyncReq== error syncEnv stop");
|
||||||
ret = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
ret = TAOS_SYNC_OTHER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -901,8 +912,8 @@ static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void
|
||||||
static int32_t vnodeProcessAlterHasnRangeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessAlterHasnRangeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
vInfo("vgId:%d, alter hashrange msg will be processed", TD_VID(pVnode));
|
vInfo("vgId:%d, alter hashrange msg will be processed", TD_VID(pVnode));
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
// 1. stop work
|
// 1. stop work
|
||||||
// 2. adjust hash range / compact / remove wals / rename vgroups
|
// 2. adjust hash range / compact / remove wals / rename vgroups
|
||||||
// 3. reload sync
|
// 3. reload sync
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -66,7 +66,13 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort);
|
vInfo("vgId:%d, replica:%d %s:%u", TD_VID(pVnode), r, pNode->nodeFqdn, pNode->nodePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncReconfig(pVnode->sync, &cfg);
|
SRpcMsg rpcMsg = {.info = pMsg->info};
|
||||||
|
if (syncReconfigBuild(pVnode->sync, &cfg, &rpcMsg) != 0) {
|
||||||
|
vError("vgId:%d, failed to build reconfig msg since %s", TD_VID(pVnode), terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return syncPropose(pVnode->sync, &rpcMsg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
|
@ -241,6 +247,30 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
|
||||||
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void **ppWriter) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM));
|
||||||
pFsm->data = pVnode;
|
pFsm->data = pVnode;
|
||||||
|
@ -250,6 +280,14 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
|
||||||
pFsm->FpGetSnapshot = vnodeSyncGetSnapshot;
|
pFsm->FpGetSnapshot = vnodeSyncGetSnapshot;
|
||||||
pFsm->FpRestoreFinishCb = NULL;
|
pFsm->FpRestoreFinishCb = NULL;
|
||||||
pFsm->FpReConfigCb = vnodeSyncReconfig;
|
pFsm->FpReConfigCb = vnodeSyncReconfig;
|
||||||
|
|
||||||
|
pFsm->FpSnapshotStartRead = vnodeSnapshotStartRead;
|
||||||
|
pFsm->FpSnapshotStopRead = vnodeSnapshotStopRead;
|
||||||
|
pFsm->FpSnapshotDoRead = vnodeSnapshotDoRead;
|
||||||
|
pFsm->FpSnapshotStartWrite = vnodeSnapshotStartWrite;
|
||||||
|
pFsm->FpSnapshotStopWrite = vnodeSnapshotStopWrite;
|
||||||
|
pFsm->FpSnapshotDoWrite = vnodeSnapshotDoWrite;
|
||||||
|
|
||||||
return pFsm;
|
return pFsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,11 +321,14 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
||||||
|
|
||||||
void vnodeSyncStart(SVnode *pVnode) {
|
void vnodeSyncStart(SVnode *pVnode) {
|
||||||
syncSetMsgCb(pVnode->sync, &pVnode->msgCb);
|
syncSetMsgCb(pVnode->sync, &pVnode->msgCb);
|
||||||
|
syncStart(pVnode->sync);
|
||||||
|
/*
|
||||||
if (pVnode->config.standby) {
|
if (pVnode->config.standby) {
|
||||||
syncStartStandBy(pVnode->sync);
|
syncStartStandBy(pVnode->sync);
|
||||||
} else {
|
} else {
|
||||||
syncStart(pVnode->sync);
|
syncStart(pVnode->sync);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); }
|
void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); }
|
||||||
|
|
|
@ -121,7 +121,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
STSmaWrapper dstTSmaWrapper = {0};
|
STSmaWrapper dstTSmaWrapper = {0};
|
||||||
void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper);
|
void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper, false);
|
||||||
EXPECT_NE(result, nullptr);
|
EXPECT_NE(result, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number);
|
EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number);
|
||||||
|
|
|
@ -57,6 +57,8 @@ enum {
|
||||||
CTG_OP_DROP_TB_META,
|
CTG_OP_DROP_TB_META,
|
||||||
CTG_OP_UPDATE_USER,
|
CTG_OP_UPDATE_USER,
|
||||||
CTG_OP_UPDATE_VG_EPSET,
|
CTG_OP_UPDATE_VG_EPSET,
|
||||||
|
CTG_OP_UPDATE_TB_INDEX,
|
||||||
|
CTG_OP_DROP_TB_INDEX,
|
||||||
CTG_OP_MAX
|
CTG_OP_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,25 +130,33 @@ typedef struct SCtgUserCtx {
|
||||||
SUserAuthInfo user;
|
SUserAuthInfo user;
|
||||||
} SCtgUserCtx;
|
} SCtgUserCtx;
|
||||||
|
|
||||||
typedef struct SCtgTbMetaCache {
|
typedef STableIndexRsp STableIndex;
|
||||||
SRWLatch stbLock;
|
|
||||||
SRWLatch metaLock; // RC between cache destroy and all other operations
|
typedef struct SCtgTbCache {
|
||||||
SHashObj *metaCache; //key:tbname, value:STableMeta
|
SRWLatch metaLock;
|
||||||
SHashObj *stbCache; //key:suid, value:STableMeta*
|
STableMeta *pMeta;
|
||||||
} SCtgTbMetaCache;
|
SRWLatch indexLock;
|
||||||
|
STableIndex *pIndex;
|
||||||
|
} SCtgTbCache;
|
||||||
|
|
||||||
|
typedef struct SCtgVgCache {
|
||||||
|
SRWLatch vgLock;
|
||||||
|
SDBVgInfo *vgInfo;
|
||||||
|
} SCtgVgCache;
|
||||||
|
|
||||||
typedef struct SCtgDBCache {
|
typedef struct SCtgDBCache {
|
||||||
SRWLatch vgLock;
|
SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
int8_t deleted;
|
int8_t deleted;
|
||||||
SDBVgInfo *vgInfo;
|
SCtgVgCache vgCache;
|
||||||
SCtgTbMetaCache tbCache;
|
SHashObj *tbCache; // key:tbname, value:SCtgTbCache
|
||||||
|
SHashObj *stbCache; // key:suid, value:STableMeta*
|
||||||
} SCtgDBCache;
|
} SCtgDBCache;
|
||||||
|
|
||||||
typedef struct SCtgRentSlot {
|
typedef struct SCtgRentSlot {
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
bool needSort;
|
bool needSort;
|
||||||
SArray *meta; // element is SDbVgVersion or SSTableMetaVersion
|
SArray *meta; // element is SDbVgVersion or SSTableVersion
|
||||||
} SCtgRentSlot;
|
} SCtgRentSlot;
|
||||||
|
|
||||||
typedef struct SCtgRentMgmt {
|
typedef struct SCtgRentMgmt {
|
||||||
|
@ -245,8 +255,10 @@ typedef struct SCtgCacheStat {
|
||||||
uint64_t userNum;
|
uint64_t userNum;
|
||||||
uint64_t vgHitNum;
|
uint64_t vgHitNum;
|
||||||
uint64_t vgMissNum;
|
uint64_t vgMissNum;
|
||||||
uint64_t tblHitNum;
|
uint64_t tbMetaHitNum;
|
||||||
uint64_t tblMissNum;
|
uint64_t tbMetaMissNum;
|
||||||
|
uint64_t tbIndexHitNum;
|
||||||
|
uint64_t tbIndexMissNum;
|
||||||
uint64_t userHitNum;
|
uint64_t userHitNum;
|
||||||
uint64_t userMissNum;
|
uint64_t userMissNum;
|
||||||
} SCtgCacheStat;
|
} SCtgCacheStat;
|
||||||
|
@ -268,10 +280,10 @@ typedef struct SCtgUpdateVgMsg {
|
||||||
SDBVgInfo* dbInfo;
|
SDBVgInfo* dbInfo;
|
||||||
} SCtgUpdateVgMsg;
|
} SCtgUpdateVgMsg;
|
||||||
|
|
||||||
typedef struct SCtgUpdateTblMsg {
|
typedef struct SCtgUpdateTbMetaMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
STableMetaOutput* output;
|
STableMetaOutput* pMeta;
|
||||||
} SCtgUpdateTblMsg;
|
} SCtgUpdateTbMetaMsg;
|
||||||
|
|
||||||
typedef struct SCtgDropDBMsg {
|
typedef struct SCtgDropDBMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
|
@ -305,6 +317,17 @@ typedef struct SCtgUpdateUserMsg {
|
||||||
SGetUserAuthRsp userAuth;
|
SGetUserAuthRsp userAuth;
|
||||||
} SCtgUpdateUserMsg;
|
} SCtgUpdateUserMsg;
|
||||||
|
|
||||||
|
typedef struct SCtgUpdateTbIndexMsg {
|
||||||
|
SCatalog* pCtg;
|
||||||
|
STableIndex* pIndex;
|
||||||
|
} SCtgUpdateTbIndexMsg;
|
||||||
|
|
||||||
|
typedef struct SCtgDropTbIndexMsg {
|
||||||
|
SCatalog* pCtg;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
} SCtgDropTbIndexMsg;
|
||||||
|
|
||||||
typedef struct SCtgUpdateEpsetMsg {
|
typedef struct SCtgUpdateEpsetMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
@ -465,12 +488,11 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation);
|
int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation);
|
||||||
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache);
|
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache);
|
||||||
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache);
|
void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache);
|
||||||
void ctgReleaseVgInfo(SCtgDBCache *dbCache);
|
void ctgRUnlockVgInfo(SCtgDBCache *dbCache);
|
||||||
int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache);
|
|
||||||
int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist);
|
int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist);
|
||||||
int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||||
int32_t ctgReadTbVerFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *sver, int32_t *tver, int32_t *tbType, uint64_t *suid, char *stbName);
|
int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver, int32_t *tver, int32_t *tbType, uint64_t *suid, char *stbName);
|
||||||
int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass);
|
int32_t ctgChkAuthFromCache(SCatalog* pCtg, char* user, char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass);
|
||||||
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId);
|
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId);
|
||||||
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char *dbFName, bool syncReq);
|
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char *dbFName, bool syncReq);
|
||||||
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq);
|
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq);
|
||||||
|
@ -479,12 +501,18 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
|
||||||
int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq);
|
int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq);
|
||||||
int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq);
|
int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq);
|
||||||
int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char *dbFName, int32_t vgId, SEpSet* pEpSet);
|
int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char *dbFName, int32_t vgId, SEpSet* pEpSet);
|
||||||
|
int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex **pIndex, bool syncOp);
|
||||||
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type);
|
int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type);
|
||||||
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size);
|
int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size);
|
||||||
int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size);
|
int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size);
|
||||||
int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq);
|
int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq);
|
||||||
int32_t ctgStartUpdateThread();
|
int32_t ctgStartUpdateThread();
|
||||||
int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask);
|
int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask);
|
||||||
|
void ctgReleaseVgInfoToCache(SCatalog* pCtg, SCtgDBCache *dbCache);
|
||||||
|
int32_t ctgReadTbIndexFromCache(SCatalog* pCtg, SName* pTableName, SArray** pRes);
|
||||||
|
int32_t ctgDropTbIndexEnqueue(SCatalog* pCtg, SName* pName, bool syncOp);
|
||||||
|
int32_t ctgOpDropTbIndex(SCtgCacheOperation *operation);
|
||||||
|
int32_t ctgOpUpdateTbIndex(SCtgCacheOperation *operation);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,7 +521,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
|
||||||
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask);
|
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask);
|
||||||
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask);
|
int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask);
|
||||||
int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *indexName, SIndexInfo *out, SCtgTask* pTask);
|
int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *indexName, SIndexInfo *out, SCtgTask* pTask);
|
||||||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName* name, SArray** out, SCtgTask* pTask);
|
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask);
|
||||||
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask);
|
int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask);
|
||||||
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask);
|
int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask);
|
||||||
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask);
|
int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask);
|
||||||
|
@ -521,6 +549,8 @@ void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
||||||
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
||||||
char *ctgTaskTypeStr(CTG_TASK_TYPE type);
|
char *ctgTaskTypeStr(CTG_TASK_TYPE type);
|
||||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask);
|
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask);
|
||||||
|
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
|
||||||
|
void ctgFreeSTableIndex(void *info);
|
||||||
|
|
||||||
|
|
||||||
extern SCatalogMgmt gCtgMgmt;
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
|
|
|
@ -96,8 +96,7 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
|
||||||
if (NULL != dbCache) {
|
if (NULL != dbCache) {
|
||||||
input.dbId = dbCache->dbId;
|
input.dbId = dbCache->dbId;
|
||||||
|
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
input.vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
||||||
|
@ -349,8 +348,8 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, co
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
*pass = false;
|
*pass = false;
|
||||||
|
|
||||||
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, user, dbFName, type, &inCache, pass));
|
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, (char*)user, (char*)dbFName, type, &inCache, pass));
|
||||||
|
|
||||||
if (inCache) {
|
if (inCache) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -382,6 +381,45 @@ _return:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgGetTbIndex(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pRes) {
|
||||||
|
CTG_ERR_RET(ctgReadTbIndexFromCache(pCtg, pTableName, pRes));
|
||||||
|
if (*pRes) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndex *pIndex = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
|
if (NULL == pIndex) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pIndex, NULL);
|
||||||
|
if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) {
|
||||||
|
code = 0;
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
CTG_ERR_JRET(code);
|
||||||
|
|
||||||
|
SArray* pInfo = NULL;
|
||||||
|
CTG_ERR_JRET(ctgCloneTableIndex(pIndex->pIndex, &pInfo));
|
||||||
|
|
||||||
|
*pRes = pInfo;
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, &pIndex, false));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
tFreeSTableIndexRsp(pIndex);
|
||||||
|
taosMemoryFree(pIndex);
|
||||||
|
|
||||||
|
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
|
||||||
|
*pRes = NULL;
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pVgList) {
|
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pVgList) {
|
||||||
STableMeta *tbMeta = NULL;
|
STableMeta *tbMeta = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -404,7 +442,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
|
||||||
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo));
|
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo));
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
vgHash = dbCache->vgInfo->vgHash;
|
vgHash = dbCache->vgCache.vgInfo->vgHash;
|
||||||
} else {
|
} else {
|
||||||
vgHash = vgInfo->vgHash;
|
vgHash = vgInfo->vgHash;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +480,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgRUnlockVgInfo(dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,12 +669,11 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers
|
||||||
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
*version = dbCache->vgInfo->vgVersion;
|
*version = dbCache->vgCache.vgInfo->vgVersion;
|
||||||
*dbId = dbCache->dbId;
|
*dbId = dbCache->dbId;
|
||||||
*tableNum = dbCache->vgInfo->numOfTable;
|
*tableNum = dbCache->vgCache.vgInfo->numOfTable;
|
||||||
|
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
|
|
||||||
ctgDebug("Got db vgVersion from cache, dbFName:%s, vgVersion:%d", dbFName, *version);
|
ctgDebug("Got db vgVersion from cache, dbFName:%s, vgVersion:%d", dbFName, *version);
|
||||||
|
|
||||||
|
@ -661,7 +698,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
|
||||||
SDBVgInfo *vgInfo = NULL;
|
SDBVgInfo *vgInfo = NULL;
|
||||||
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, dbFName, &dbCache, &vgInfo));
|
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, dbFName, &dbCache, &vgInfo));
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
vgHash = dbCache->vgInfo->vgHash;
|
vgHash = dbCache->vgCache.vgInfo->vgHash;
|
||||||
} else {
|
} else {
|
||||||
vgHash = vgInfo->vgHash;
|
vgHash = vgInfo->vgHash;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +711,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgRUnlockVgInfo(dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,6 +778,30 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp) {
|
||||||
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (NULL == pCtg || NULL == pRsp) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndex* pIndex = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
|
if (NULL == pIndex) {
|
||||||
|
CTG_API_LEAVE(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(pIndex, pRsp, sizeof(STableIndex));
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, &pIndex, false));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) {
|
int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -932,12 +993,12 @@ int32_t catalogGetTableHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const
|
||||||
SDBVgInfo *vgInfo = NULL;
|
SDBVgInfo *vgInfo = NULL;
|
||||||
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo));
|
CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo));
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgInfo, pTableName, pVgroup));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgCache.vgInfo, pTableName, pVgroup));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgRUnlockVgInfo(dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
ctgReleaseDBCache(pCtg, dbCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,14 +1121,14 @@ _return:
|
||||||
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableMetaVersion** stables, uint32_t* num) {
|
int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion **stables, uint32_t *num) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
if (NULL == pCtg || NULL == stables || NULL == num) {
|
if (NULL == pCtg || NULL == stables || NULL == num) {
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void**)stables, num, sizeof(SSTableMetaVersion)));
|
CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void **)stables, num, sizeof(SSTableVersion)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion** dbs, uint32_t* num) {
|
int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion** dbs, uint32_t* num) {
|
||||||
|
@ -1138,7 +1199,12 @@ int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo *pConn, const SNam
|
||||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_API_LEAVE(ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pRes, NULL));
|
int32_t code = 0;
|
||||||
|
CTG_ERR_JRET(ctgGetTbIndex(pCtg, pConn, (SName*)pTableName, pRes));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* funcName, SFuncInfo* pInfo) {
|
int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* funcName, SFuncInfo* pInfo) {
|
||||||
|
|
|
@ -261,54 +261,48 @@ int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgHandleForceUpdate(SCatalog* pCtg, SCtgJob *pJob, const SCatalogReq* pReq) {
|
int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, const SCatalogReq* pReq) {
|
||||||
int32_t dbNum = pJob->dbCfgNum + pJob->dbVgNum + pJob->dbInfoNum;
|
SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
if (dbNum > 0) {
|
if (NULL == pDb) {
|
||||||
if (dbNum > pJob->dbCfgNum && dbNum > pJob->dbVgNum && dbNum > pJob->dbInfoNum) {
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
SHashObj* pDb = taosHashInit(dbNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
|
||||||
if (NULL == pDb) {
|
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pJob->dbVgNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbVgroup, i);
|
|
||||||
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pJob->dbCfgNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbCfg, i);
|
|
||||||
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pJob->dbInfoNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbInfo, i);
|
|
||||||
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* dbFName = taosHashIterate(pDb, NULL);
|
|
||||||
while (dbFName) {
|
|
||||||
ctgDropDbVgroupEnqueue(pCtg, dbFName, true);
|
|
||||||
dbFName = taosHashIterate(pDb, dbFName);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosHashCleanup(pDb);
|
|
||||||
} else {
|
|
||||||
for (int32_t i = 0; i < pJob->dbVgNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbVgroup, i);
|
|
||||||
CTG_ERR_RET(ctgDropDbVgroupEnqueue(pCtg, dbFName, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pJob->dbCfgNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbCfg, i);
|
|
||||||
CTG_ERR_RET(ctgDropDbVgroupEnqueue(pCtg, dbFName, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pJob->dbInfoNum; ++i) {
|
|
||||||
char* dbFName = taosArrayGet(pReq->pDbInfo, i);
|
|
||||||
CTG_ERR_RET(ctgDropDbVgroupEnqueue(pCtg, dbFName, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->dbVgNum; ++i) {
|
||||||
|
char* dbFName = taosArrayGet(pReq->pDbVgroup, i);
|
||||||
|
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->dbCfgNum; ++i) {
|
||||||
|
char* dbFName = taosArrayGet(pReq->pDbCfg, i);
|
||||||
|
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->dbInfoNum; ++i) {
|
||||||
|
char* dbFName = taosArrayGet(pReq->pDbInfo, i);
|
||||||
|
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->tbMetaNum; ++i) {
|
||||||
|
SName* name = taosArrayGet(pReq->pTableMeta, i);
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(name, dbFName);
|
||||||
|
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->tbHashNum; ++i) {
|
||||||
|
SName* name = taosArrayGet(pReq->pTableHash, i);
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(name, dbFName);
|
||||||
|
taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* dbFName = taosHashIterate(pDb, NULL);
|
||||||
|
while (dbFName) {
|
||||||
|
ctgDropDbVgroupEnqueue(pCtg, dbFName, true);
|
||||||
|
dbFName = taosHashIterate(pDb, dbFName);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pDb);
|
||||||
|
|
||||||
int32_t tbNum = pJob->tbMetaNum + pJob->tbHashNum;
|
int32_t tbNum = pJob->tbMetaNum + pJob->tbHashNum;
|
||||||
if (tbNum > 0) {
|
if (tbNum > 0) {
|
||||||
|
@ -344,6 +338,11 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, SCtgJob *pJob, const SCatalogReq* p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pJob->tbIndexNum; ++i) {
|
||||||
|
SName* name = taosArrayGet(pReq->pTableIndex, i);
|
||||||
|
ctgDropTbIndexEnqueue(pCtg, name, true);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +398,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq->forceUpdate) {
|
if (pReq->forceUpdate) {
|
||||||
CTG_ERR_JRET(ctgHandleForceUpdate(pCtg, pJob, pReq));
|
CTG_ERR_JRET(ctgHandleForceUpdate(pCtg, *taskNum, pJob, pReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taskIdx = 0;
|
int32_t taskIdx = 0;
|
||||||
|
@ -680,15 +679,14 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
||||||
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
|
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
|
||||||
if (NULL != dbCache) {
|
if (NULL != dbCache) {
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgInfo, ctx->pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
||||||
|
|
||||||
ctx->vgId = vgInfo.vgId;
|
ctx->vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
|
||||||
|
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
} else {
|
} else {
|
||||||
SBuildUseDBInput input = {0};
|
SBuildUseDBInput input = {0};
|
||||||
|
|
||||||
|
@ -786,8 +784,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgHandleTaskEnd(pTask, code);
|
ctgHandleTaskEnd(pTask, code);
|
||||||
|
@ -868,7 +865,13 @@ int32_t ctgHandleGetTbIndexRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
|
CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target));
|
||||||
|
|
||||||
TSWAP(pTask->res, pTask->msgCtx.out);
|
STableIndex* pOut = (STableIndex*)pTask->msgCtx.out;
|
||||||
|
SArray* pInfo = NULL;
|
||||||
|
CTG_ERR_JRET(ctgCloneTableIndex(pOut->pIndex, &pInfo));
|
||||||
|
pTask->res = pInfo;
|
||||||
|
|
||||||
|
SCtgTbIndexCtx* ctx = pTask->taskCtx;
|
||||||
|
CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pTask->pJob->pCtg, (STableIndex**)&pTask->msgCtx.out, false));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) {
|
if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) {
|
||||||
|
@ -939,7 +942,6 @@ _return:
|
||||||
|
|
||||||
int32_t ctgHandleGetUserRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
|
int32_t ctgHandleGetUserRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgDBCache *dbCache = NULL;
|
|
||||||
SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx;
|
SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx;
|
||||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||||
bool pass = false;
|
bool pass = false;
|
||||||
|
@ -1008,7 +1010,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
|
||||||
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
|
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache));
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_RET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgInfo, ctx->pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
||||||
|
|
||||||
|
@ -1026,8 +1028,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
@ -1057,7 +1058,10 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
|
||||||
|
|
||||||
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, pCtx->dbFName, &dbCache));
|
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, pCtx->dbFName, &dbCache));
|
||||||
if (NULL != dbCache) {
|
if (NULL != dbCache) {
|
||||||
CTG_ERR_JRET(ctgGenerateVgList(pCtg, dbCache->vgInfo->vgHash, (SArray**)&pTask->res));
|
CTG_ERR_JRET(ctgGenerateVgList(pCtg, dbCache->vgCache.vgInfo->vgHash, (SArray**)&pTask->res));
|
||||||
|
|
||||||
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
|
dbCache = NULL;
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgHandleTaskEnd(pTask, 0));
|
CTG_ERR_JRET(ctgHandleTaskEnd(pTask, 0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1072,8 +1076,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
@ -1092,7 +1095,10 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
|
||||||
if (NULL == pTask->res) {
|
if (NULL == pTask->res) {
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgInfo, pCtx->pName, (SVgroupInfo*)pTask->res));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pCtx->pName, (SVgroupInfo*)pTask->res));
|
||||||
|
|
||||||
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
|
dbCache = NULL;
|
||||||
|
|
||||||
CTG_ERR_JRET(ctgHandleTaskEnd(pTask, 0));
|
CTG_ERR_JRET(ctgHandleTaskEnd(pTask, 0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1107,8 +1113,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
@ -1119,6 +1124,15 @@ int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) {
|
||||||
SCatalog* pCtg = pTask->pJob->pCtg;
|
SCatalog* pCtg = pTask->pJob->pCtg;
|
||||||
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
SRequestConnInfo* pConn = &pTask->pJob->conn;
|
||||||
SCtgTbIndexCtx* pCtx = (SCtgTbIndexCtx*)pTask->taskCtx;
|
SCtgTbIndexCtx* pCtx = (SCtgTbIndexCtx*)pTask->taskCtx;
|
||||||
|
SArray* pRes = NULL;
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgReadTbIndexFromCache(pCtg, pCtx->pName, &pRes));
|
||||||
|
if (pRes) {
|
||||||
|
pTask->res = pRes;
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgGetTbIndexFromMnode(pCtg, pConn, pCtx->pName, NULL, pTask));
|
CTG_ERR_RET(ctgGetTbIndexFromMnode(pCtg, pConn, pCtx->pName, NULL, pTask));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1157,9 +1171,12 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
|
||||||
SDbInfo* pInfo = (SDbInfo*)pTask->res;
|
SDbInfo* pInfo = (SDbInfo*)pTask->res;
|
||||||
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, pCtx->dbFName, &dbCache));
|
CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, pCtx->dbFName, &dbCache));
|
||||||
if (NULL != dbCache) {
|
if (NULL != dbCache) {
|
||||||
pInfo->vgVer = dbCache->vgInfo->vgVersion;
|
pInfo->vgVer = dbCache->vgCache.vgInfo->vgVersion;
|
||||||
pInfo->dbId = dbCache->dbId;
|
pInfo->dbId = dbCache->dbId;
|
||||||
pInfo->tbNum = dbCache->vgInfo->numOfTable;
|
pInfo->tbNum = dbCache->vgCache.vgInfo->numOfTable;
|
||||||
|
|
||||||
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
|
dbCache = NULL;
|
||||||
} else {
|
} else {
|
||||||
pInfo->vgVer = CTG_DEFAULT_INVALID_VERSION;
|
pInfo->vgVer = CTG_DEFAULT_INVALID_VERSION;
|
||||||
}
|
}
|
||||||
|
@ -1169,8 +1186,7 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (dbCache) {
|
if (dbCache) {
|
||||||
ctgReleaseVgInfo(dbCache);
|
ctgReleaseVgInfoToCache(pCtg, dbCache);
|
||||||
ctgReleaseDBCache(pCtg, dbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,7 @@
|
||||||
#include "catalogInt.h"
|
#include "catalogInt.h"
|
||||||
|
|
||||||
extern SCatalogMgmt gCtgMgmt;
|
extern SCatalogMgmt gCtgMgmt;
|
||||||
SCtgDebug gCTGDebug = {.apiEnable = true};
|
SCtgDebug gCTGDebug = {.lockEnable = true, .apiEnable = true};
|
||||||
|
|
||||||
void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
|
void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
|
||||||
ASSERT(*(int32_t*)param == 1);
|
ASSERT(*(int32_t*)param == 1);
|
||||||
|
@ -266,11 +266,11 @@ int32_t ctgdGetStatNum(char *option, void *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgdGetTbMetaNum(SCtgDBCache *dbCache) {
|
int32_t ctgdGetTbMetaNum(SCtgDBCache *dbCache) {
|
||||||
return dbCache->tbCache.metaCache ? (int32_t)taosHashGetSize(dbCache->tbCache.metaCache) : 0;
|
return dbCache->tbCache ? (int32_t)taosHashGetSize(dbCache->tbCache) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgdGetStbNum(SCtgDBCache *dbCache) {
|
int32_t ctgdGetStbNum(SCtgDBCache *dbCache) {
|
||||||
return dbCache->tbCache.stbCache ? (int32_t)taosHashGetSize(dbCache->tbCache.stbCache) : 0;
|
return dbCache->stbCache ? (int32_t)taosHashGetSize(dbCache->stbCache) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgdGetRentNum(SCtgRentMgmt *rent) {
|
int32_t ctgdGetRentNum(SCtgRentMgmt *rent) {
|
||||||
|
@ -363,17 +363,17 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
|
||||||
|
|
||||||
dbFName = taosHashGetKey(pIter, &len);
|
dbFName = taosHashGetKey(pIter, &len);
|
||||||
|
|
||||||
int32_t metaNum = dbCache->tbCache.metaCache ? taosHashGetSize(dbCache->tbCache.metaCache) : 0;
|
int32_t metaNum = dbCache->tbCache ? taosHashGetSize(dbCache->tbCache) : 0;
|
||||||
int32_t stbNum = dbCache->tbCache.stbCache ? taosHashGetSize(dbCache->tbCache.stbCache) : 0;
|
int32_t stbNum = dbCache->stbCache ? taosHashGetSize(dbCache->stbCache) : 0;
|
||||||
int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION;
|
||||||
int32_t hashMethod = -1;
|
int32_t hashMethod = -1;
|
||||||
int32_t vgNum = 0;
|
int32_t vgNum = 0;
|
||||||
|
|
||||||
if (dbCache->vgInfo) {
|
if (dbCache->vgCache.vgInfo) {
|
||||||
vgVersion = dbCache->vgInfo->vgVersion;
|
vgVersion = dbCache->vgCache.vgInfo->vgVersion;
|
||||||
hashMethod = dbCache->vgInfo->hashMethod;
|
hashMethod = dbCache->vgCache.vgInfo->hashMethod;
|
||||||
if (dbCache->vgInfo->vgHash) {
|
if (dbCache->vgCache.vgInfo->vgHash) {
|
||||||
vgNum = taosHashGetSize(dbCache->vgInfo->vgHash);
|
vgNum = taosHashGetSize(dbCache->vgCache.vgInfo->vgHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, SArray** out, SCtgTask* pTask) {
|
int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
|
||||||
|
@ -448,10 +448,11 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
void* pOut = taosMemoryCalloc(1, POINTER_BYTES);
|
void* pOut = taosMemoryCalloc(1, sizeof(STableIndex));
|
||||||
if (NULL == pOut) {
|
if (NULL == pOut) {
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
|
|
@ -44,6 +44,16 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctgFreeSTableIndex(void *info) {
|
||||||
|
if (NULL == info) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STableIndex *pInfo = (STableIndex *)info;
|
||||||
|
|
||||||
|
taosArrayDestroyEx(pInfo->pIndex, tFreeSTableIndexInfo);
|
||||||
|
}
|
||||||
|
|
||||||
void ctgFreeSMetaData(SMetaData* pData) {
|
void ctgFreeSMetaData(SMetaData* pData) {
|
||||||
taosArrayDestroy(pData->pTableMeta);
|
taosArrayDestroy(pData->pTableMeta);
|
||||||
pData->pTableMeta = NULL;
|
pData->pTableMeta = NULL;
|
||||||
|
@ -110,25 +120,39 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
|
||||||
taosMemoryFreeClear(mgmt->slots);
|
taosMemoryFreeClear(mgmt->slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctgFreeStbMetaCache(SCtgDBCache *dbCache) {
|
||||||
void ctgFreeTbMetaCache(SCtgTbMetaCache *cache) {
|
if (NULL == dbCache->stbCache) {
|
||||||
CTG_LOCK(CTG_WRITE, &cache->stbLock);
|
return;
|
||||||
if (cache->stbCache) {
|
|
||||||
int32_t stblNum = taosHashGetSize(cache->stbCache);
|
|
||||||
taosHashCleanup(cache->stbCache);
|
|
||||||
cache->stbCache = NULL;
|
|
||||||
CTG_CACHE_STAT_DEC(stblNum, stblNum);
|
|
||||||
}
|
}
|
||||||
CTG_UNLOCK(CTG_WRITE, &cache->stbLock);
|
|
||||||
|
|
||||||
CTG_LOCK(CTG_WRITE, &cache->metaLock);
|
int32_t stblNum = taosHashGetSize(dbCache->stbCache);
|
||||||
if (cache->metaCache) {
|
taosHashCleanup(dbCache->stbCache);
|
||||||
int32_t tblNum = taosHashGetSize(cache->metaCache);
|
dbCache->stbCache = NULL;
|
||||||
taosHashCleanup(cache->metaCache);
|
CTG_CACHE_STAT_DEC(stblNum, stblNum);
|
||||||
cache->metaCache = NULL;
|
}
|
||||||
CTG_CACHE_STAT_DEC(tblNum, tblNum);
|
|
||||||
|
void ctgFreeTbCacheImpl(SCtgTbCache *pCache) {
|
||||||
|
taosMemoryFreeClear(pCache->pMeta);
|
||||||
|
if (pCache->pIndex) {
|
||||||
|
taosArrayDestroyEx(pCache->pIndex->pIndex, tFreeSTableIndexInfo);
|
||||||
|
taosMemoryFreeClear(pCache->pIndex);
|
||||||
}
|
}
|
||||||
CTG_UNLOCK(CTG_WRITE, &cache->metaLock);
|
}
|
||||||
|
|
||||||
|
void ctgFreeTbCache(SCtgDBCache *dbCache) {
|
||||||
|
if (NULL == dbCache->tbCache) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tblNum = taosHashGetSize(dbCache->tbCache);
|
||||||
|
SCtgTbCache *pCache = taosHashIterate(dbCache->tbCache, NULL);
|
||||||
|
while (NULL != pCache) {
|
||||||
|
ctgFreeTbCacheImpl(pCache);
|
||||||
|
pCache = taosHashIterate(dbCache->tbCache, pCache);
|
||||||
|
}
|
||||||
|
taosHashCleanup(dbCache->tbCache);
|
||||||
|
dbCache->tbCache = NULL;
|
||||||
|
CTG_CACHE_STAT_DEC(tblNum, tblNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
|
void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
|
||||||
|
@ -144,16 +168,18 @@ void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
|
||||||
taosMemoryFreeClear(vgInfo);
|
taosMemoryFreeClear(vgInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctgFreeVgInfoCache(SCtgDBCache *dbCache) {
|
||||||
|
ctgFreeVgInfo(dbCache->vgCache.vgInfo);
|
||||||
|
}
|
||||||
|
|
||||||
void ctgFreeDbCache(SCtgDBCache *dbCache) {
|
void ctgFreeDbCache(SCtgDBCache *dbCache) {
|
||||||
if (NULL == dbCache) {
|
if (NULL == dbCache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_LOCK(CTG_WRITE, &dbCache->vgLock);
|
ctgFreeVgInfoCache(dbCache);
|
||||||
ctgFreeVgInfo (dbCache->vgInfo);
|
ctgFreeStbMetaCache(dbCache);
|
||||||
CTG_UNLOCK(CTG_WRITE, &dbCache->vgLock);
|
ctgFreeTbCache(dbCache);
|
||||||
|
|
||||||
ctgFreeTbMetaCache(&dbCache->tbCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,16 +193,13 @@ void ctgFreeHandle(SCatalog* pCtg) {
|
||||||
void *pIter = taosHashIterate(pCtg->dbCache, NULL);
|
void *pIter = taosHashIterate(pCtg->dbCache, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SCtgDBCache *dbCache = pIter;
|
SCtgDBCache *dbCache = pIter;
|
||||||
|
|
||||||
atomic_store_8(&dbCache->deleted, 1);
|
atomic_store_8(&dbCache->deleted, 1);
|
||||||
|
|
||||||
ctgFreeDbCache(dbCache);
|
ctgFreeDbCache(dbCache);
|
||||||
|
|
||||||
pIter = taosHashIterate(pCtg->dbCache, pIter);
|
pIter = taosHashIterate(pCtg->dbCache, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pCtg->dbCache);
|
taosHashCleanup(pCtg->dbCache);
|
||||||
|
|
||||||
CTG_CACHE_STAT_DEC(dbNum, dbNum);
|
CTG_CACHE_STAT_DEC(dbNum, dbNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,14 +209,12 @@ void ctgFreeHandle(SCatalog* pCtg) {
|
||||||
void *pIter = taosHashIterate(pCtg->userCache, NULL);
|
void *pIter = taosHashIterate(pCtg->userCache, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SCtgUserAuth *userCache = pIter;
|
SCtgUserAuth *userCache = pIter;
|
||||||
|
|
||||||
ctgFreeSCtgUserAuth(userCache);
|
ctgFreeSCtgUserAuth(userCache);
|
||||||
|
|
||||||
pIter = taosHashIterate(pCtg->userCache, pIter);
|
pIter = taosHashIterate(pCtg->userCache, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pCtg->userCache);
|
taosHashCleanup(pCtg->userCache);
|
||||||
|
|
||||||
CTG_CACHE_STAT_DEC(userNum, userNum);
|
CTG_CACHE_STAT_DEC(userNum, userNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,9 +273,9 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_MND_GET_TABLE_INDEX: {
|
case TDMT_MND_GET_TABLE_INDEX: {
|
||||||
SArray** pOut = (SArray**)pCtx->out;
|
STableIndex* pOut = (STableIndex*)pCtx->out;
|
||||||
if (pOut) {
|
if (pOut) {
|
||||||
taosArrayDestroyEx(*pOut, tFreeSTableIndexInfo);
|
taosArrayDestroyEx(pOut->pIndex, tFreeSTableIndexInfo);
|
||||||
taosMemoryFreeClear(pCtx->out);
|
taosMemoryFreeClear(pCtx->out);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -535,9 +556,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
|
int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
|
||||||
if (*(uint64_t *)key1 < ((SSTableMetaVersion*)key2)->suid) {
|
if (*(uint64_t *)key1 < ((SSTableVersion*)key2)->suid) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (*(uint64_t *)key1 > ((SSTableMetaVersion*)key2)->suid) {
|
} else if (*(uint64_t *)key1 > ((SSTableVersion*)key2)->suid) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -555,9 +576,9 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) {
|
int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) {
|
||||||
if (((SSTableMetaVersion*)key1)->suid < ((SSTableMetaVersion*)key2)->suid) {
|
if (((SSTableVersion*)key1)->suid < ((SSTableVersion*)key2)->suid) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (((SSTableMetaVersion*)key1)->suid > ((SSTableMetaVersion*)key2)->suid) {
|
} else if (((SSTableVersion*)key1)->suid > ((SSTableVersion*)key2)->suid) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -640,6 +661,28 @@ int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) {
|
||||||
|
if (NULL == pIndex) {
|
||||||
|
*pRes = NULL;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t num = taosArrayGetSize(pIndex);
|
||||||
|
*pRes = taosArrayInit(num, sizeof(STableIndexInfo));
|
||||||
|
if (NULL == *pRes) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
STableIndexInfo *pInfo = taosArrayGet(pIndex, i);
|
||||||
|
pInfo = taosArrayPush(*pRes, pInfo);
|
||||||
|
pInfo->expr = strdup(pInfo->expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask) {
|
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask) {
|
||||||
if (msgType == TDMT_VND_TABLE_META) {
|
if (msgType == TDMT_VND_TABLE_META) {
|
||||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
|
|
@ -895,9 +895,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
|
||||||
output = (STableMetaOutput *)taosMemoryMalloc(sizeof(STableMetaOutput));
|
output = (STableMetaOutput *)taosMemoryMalloc(sizeof(STableMetaOutput));
|
||||||
ctgTestBuildCTableMetaOutput(output);
|
ctgTestBuildCTableMetaOutput(output);
|
||||||
|
|
||||||
SCtgUpdateTblMsg *msg = (SCtgUpdateTblMsg *)taosMemoryMalloc(sizeof(SCtgUpdateTblMsg));
|
SCtgUpdateTbMetaMsg *msg = (SCtgUpdateTbMetaMsg *)taosMemoryMalloc(sizeof(SCtgUpdateTbMetaMsg));
|
||||||
msg->pCtg = pCtg;
|
msg->pCtg = pCtg;
|
||||||
msg->output = output;
|
msg->pMeta = output;
|
||||||
operation.data = msg;
|
operation.data = msg;
|
||||||
|
|
||||||
code = ctgOpUpdateTbMeta(&operation);
|
code = ctgOpUpdateTbMeta(&operation);
|
||||||
|
@ -989,7 +989,7 @@ TEST(tableMeta, normalTable) {
|
||||||
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
||||||
|
|
||||||
SDbVgVersion *dbs = NULL;
|
SDbVgVersion *dbs = NULL;
|
||||||
SSTableMetaVersion *stb = NULL;
|
SSTableVersion *stb = NULL;
|
||||||
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (i < 5) {
|
while (i < 5) {
|
||||||
|
@ -1098,7 +1098,7 @@ TEST(tableMeta, childTableCase) {
|
||||||
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
||||||
|
|
||||||
SDbVgVersion *dbs = NULL;
|
SDbVgVersion *dbs = NULL;
|
||||||
SSTableMetaVersion *stb = NULL;
|
SSTableVersion *stb = NULL;
|
||||||
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (i < 5) {
|
while (i < 5) {
|
||||||
|
@ -1220,7 +1220,7 @@ TEST(tableMeta, superTableCase) {
|
||||||
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
ASSERT_EQ(tableMeta->tableInfo.rowSize, 12);
|
||||||
|
|
||||||
SDbVgVersion *dbs = NULL;
|
SDbVgVersion *dbs = NULL;
|
||||||
SSTableMetaVersion *stb = NULL;
|
SSTableVersion *stb = NULL;
|
||||||
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (i < 5) {
|
while (i < 5) {
|
||||||
|
@ -2299,7 +2299,7 @@ TEST(rentTest, allRent) {
|
||||||
SArray *vgList = NULL;
|
SArray *vgList = NULL;
|
||||||
ctgTestStop = false;
|
ctgTestStop = false;
|
||||||
SDbVgVersion *dbs = NULL;
|
SDbVgVersion *dbs = NULL;
|
||||||
SSTableMetaVersion *stable = NULL;
|
SSTableVersion *stable = NULL;
|
||||||
uint32_t num = 0;
|
uint32_t num = 0;
|
||||||
|
|
||||||
ctgTestInitLogFile();
|
ctgTestInitLogFile();
|
||||||
|
|
|
@ -211,7 +211,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
||||||
SExplainResNode *pResNode = NULL;
|
SExplainResNode *pResNode = NULL;
|
||||||
FOREACH(node, pPhysiChildren) {
|
FOREACH(node, pPhysiChildren) {
|
||||||
QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode));
|
QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode));
|
||||||
QRY_ERR_RET(nodesListAppend(*pChildren, pResNode));
|
QRY_ERR_RET(nodesListAppend(*pChildren, (SNode*)pResNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -715,7 +715,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_NEW(level + 1, "Sort Key: ");
|
EXPLAIN_ROW_NEW(level + 1, "Sort Key: ");
|
||||||
if (pResNode->pExecInfo) {
|
if (pResNode->pExecInfo) {
|
||||||
for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) {
|
for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) {
|
||||||
SOrderByExprNode *ptn = nodesListGetNode(pSortNode->pSortKeys, i);
|
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pSortNode->pSortKeys, i);
|
||||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1039,7 +1039,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_NEW(level + 1, "Merge Key: ");
|
EXPLAIN_ROW_NEW(level + 1, "Merge Key: ");
|
||||||
if (pResNode->pExecInfo) {
|
if (pResNode->pExecInfo) {
|
||||||
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
||||||
SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i);
|
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1078,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT);
|
||||||
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
|
||||||
SOrderByExprNode *ptn = nodesListGetNode(pMergeNode->pMergeKeys, i);
|
SOrderByExprNode *ptn = (SOrderByExprNode*)nodesListGetNode(pMergeNode->pMergeKeys, i);
|
||||||
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
|
||||||
}
|
}
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
|
@ -29,10 +29,7 @@ typedef struct {
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
} SGroupKeys, SStateKeys;
|
} SGroupKeys, SStateKeys;
|
||||||
|
|
||||||
int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList);
|
|
||||||
uint64_t calcGroupId(char* pData, int32_t len);
|
uint64_t calcGroupId(char* pData, int32_t len);
|
||||||
void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex);
|
|
||||||
int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -336,12 +336,6 @@ typedef struct STableScanInfo {
|
||||||
int32_t dataBlockLoadFlag;
|
int32_t dataBlockLoadFlag;
|
||||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
||||||
|
|
||||||
SArray* pGroupCols;
|
|
||||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
|
||||||
char* keyBuf; // group by keys for hash
|
|
||||||
int32_t groupKeyLen; // total group by column width
|
|
||||||
SHashObj* pGroupSet; // quick locate the window object for each result
|
|
||||||
|
|
||||||
SSampleExecInfo sample; // sample execution info
|
SSampleExecInfo sample; // sample execution info
|
||||||
int32_t curTWinIdx;
|
int32_t curTWinIdx;
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
@ -792,7 +786,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
|
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
|
||||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
|
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
@ -830,7 +824,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, SArray* pTableIdList,
|
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle,
|
||||||
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup);
|
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData idata = {{0}};
|
SColumnInfoData idata = {{0}};
|
||||||
SSlotDescNode* pDescNode = nodesListGetNode(pNode->pSlots, i);
|
SSlotDescNode* pDescNode = (SSlotDescNode*)nodesListGetNode(pNode->pSlots, i);
|
||||||
// if (!pDescNode->output) { // todo disable it temporarily
|
// if (!pDescNode->output) { // todo disable it temporarily
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
@ -2875,7 +2875,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
SNodeListNode* pNode = nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
SNodeListNode* pNode = (SNodeListNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4459,7 +4459,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
||||||
if (NULL == res) { // todo handle error
|
if (NULL == res) { // todo handle error
|
||||||
} else {
|
} else {
|
||||||
res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
nodesListAppend(pFuncNode->pParameterList, res);
|
nodesListAppend(pFuncNode->pParameterList, (SNode*)res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -4523,7 +4523,6 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
|
||||||
|
|
||||||
static int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STableListInfo* pListInfo,
|
static int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STableListInfo* pListInfo,
|
||||||
SNode* pTagCond);
|
SNode* pTagCond);
|
||||||
static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo);
|
|
||||||
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
static SArray* extractColumnInfo(SNodeList* pNodeList);
|
||||||
|
|
||||||
static SArray* createSortInfo(SNodeList* pNodeList);
|
static SArray* createSortInfo(SNodeList* pNodeList);
|
||||||
|
@ -4557,6 +4556,85 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey){
|
||||||
|
if(groupKey == NULL) {
|
||||||
|
return TDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
if (pTableListInfo->map == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
int32_t keyLen = 0;
|
||||||
|
void *keyBuf = NULL;
|
||||||
|
int32_t numOfGroupCols = taosArrayGetSize(groupKey);
|
||||||
|
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
||||||
|
SColumn* pCol = taosArrayGet(groupKey, j);
|
||||||
|
keyLen += pCol->bytes; // actual data + null_flag
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols;
|
||||||
|
keyLen += nullFlagSize;
|
||||||
|
|
||||||
|
keyBuf = taosMemoryCalloc(1, keyLen);
|
||||||
|
if (keyBuf == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++){
|
||||||
|
STableKeyInfo *info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pHandle->meta, 0);
|
||||||
|
metaGetTableEntryByUid(&mr, info->uid);
|
||||||
|
|
||||||
|
char* isNull = (char*)keyBuf;
|
||||||
|
char* pStart = (char*)keyBuf + sizeof(int8_t) * numOfGroupCols;
|
||||||
|
for (int32_t j = 0; j < numOfGroupCols; ++j) {
|
||||||
|
SColumn* pCol = taosArrayGet(groupKey, j);
|
||||||
|
|
||||||
|
if(strcmp(pCol->name, "tbname") == 0){
|
||||||
|
isNull[i] = 0;
|
||||||
|
memcpy(pStart, mr.me.name, strlen(mr.me.name));
|
||||||
|
pStart += strlen(mr.me.name);
|
||||||
|
}else{
|
||||||
|
STagVal tagVal = {0};
|
||||||
|
tagVal.cid = pCol->colId;
|
||||||
|
const char* p = metaGetTableTagVal(&mr.me, pCol->type, &tagVal);
|
||||||
|
if(p == NULL){
|
||||||
|
isNull[j] = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
isNull[i] = 0;
|
||||||
|
if (pCol->type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
// int32_t dataLen = getJsonValueLen(pkey->pData);
|
||||||
|
// memcpy(pStart, (pkey->pData), dataLen);
|
||||||
|
// pStart += dataLen;
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
|
memcpy(pStart, tagVal.pData, tagVal.nData);
|
||||||
|
pStart += tagVal.nData;
|
||||||
|
ASSERT(tagVal.nData <= pCol->bytes);
|
||||||
|
} else {
|
||||||
|
memcpy(pStart, &(tagVal.i64), pCol->bytes);
|
||||||
|
pStart += pCol->bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = (int32_t) (pStart - (char*)keyBuf);
|
||||||
|
uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len);
|
||||||
|
if (groupId) {
|
||||||
|
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t));
|
||||||
|
} else {
|
||||||
|
uint64_t tmpId = calcGroupId(keyBuf, len);
|
||||||
|
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
}
|
||||||
|
taosMemoryFree(keyBuf);
|
||||||
|
return TDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
||||||
uint64_t queryId, uint64_t taskId, STableListInfo* pTableListInfo, SNode* pTagCond) {
|
uint64_t queryId, uint64_t taskId, STableListInfo* pTableListInfo, SNode* pTagCond) {
|
||||||
int32_t type = nodeType(pPhyNode);
|
int32_t type = nodeType(pPhyNode);
|
||||||
|
@ -4570,15 +4648,23 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
if (pDataReader == NULL && terrno != 0) {
|
if (pDataReader == NULL && terrno != 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SArray* groupKyes = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
|
||||||
int32_t code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
int32_t code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo);
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbCleanupReadHandle(pDataReader);
|
tsdbCleanupReadHandle(pDataReader);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
||||||
|
code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
||||||
|
taosArrayDestroy(groupKeys);
|
||||||
|
if (code){
|
||||||
|
tsdbCleanupReadHandle(pDataReader);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator =
|
||||||
createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, groupKyes, pTaskInfo);
|
createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
|
|
||||||
STableScanInfo* pScanInfo = pOperator->info;
|
STableScanInfo* pScanInfo = pOperator->info;
|
||||||
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder;
|
||||||
|
@ -4604,12 +4690,18 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else {
|
} else {
|
||||||
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
|
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
|
||||||
}
|
}
|
||||||
SArray* tableIdList = extractTableIdList(pTableListInfo);
|
|
||||||
|
SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionKeys);
|
||||||
|
int32_t code = generateGroupIdMap(pTableListInfo, pHandle, groupKeys); //todo for json
|
||||||
|
taosArrayDestroy(groupKeys);
|
||||||
|
if (code){
|
||||||
|
tsdbCleanupReadHandle(pDataReader);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
SOperatorInfo* pOperator =
|
||||||
createStreamScanOperatorInfo(pDataReader, pHandle, tableIdList, pTableScanNode, pTaskInfo, &twSup);
|
createStreamScanOperatorInfo(pDataReader, pHandle, pTableScanNode, pTaskInfo, &twSup);
|
||||||
|
|
||||||
taosArrayDestroy(tableIdList);
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||||
|
@ -4932,6 +5024,7 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* extractPartitionColInfo(SNodeList* pNodeList) {
|
SArray* extractPartitionColInfo(SNodeList* pNodeList) {
|
||||||
|
if(!pNodeList) return NULL;
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
size_t numOfCols = LIST_LENGTH(pNodeList);
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
|
@ -5036,7 +5129,9 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
|
||||||
|
|
||||||
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
||||||
code = doFilterTag(pTagCond, &metaArg, res);
|
code = doFilterTag(pTagCond, &metaArg, res);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_INDEX_REBUILDING){ // todo
|
||||||
|
// doFilter();
|
||||||
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid);
|
qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid);
|
||||||
taosArrayDestroy(res);
|
taosArrayDestroy(res);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
@ -5044,6 +5139,7 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
|
||||||
} else {
|
} else {
|
||||||
qDebug("sucess to get tableIds, size: %d, suid: %" PRIu64 "", (int)taosArrayGetSize(res), tableUid);
|
qDebug("sucess to get tableIds, size: %d, suid: %" PRIu64 "", (int)taosArrayGetSize(res), tableUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(res); i++) {
|
for (int i = 0; i < taosArrayGetSize(res); i++) {
|
||||||
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)};
|
STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)};
|
||||||
taosArrayPush(pListInfo->pTableList, &info);
|
taosArrayPush(pListInfo->pTableList, &info);
|
||||||
|
@ -5060,18 +5156,6 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
|
|
||||||
SArray* tableIdList = taosArrayInit(4, sizeof(uint64_t));
|
|
||||||
|
|
||||||
// Transfer the Array of STableKeyInfo into uid list.
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTableGroupInfo->pTableList); ++i) {
|
|
||||||
STableKeyInfo* pkeyInfo = taosArrayGet(pTableGroupInfo->pTableList, i);
|
|
||||||
taosArrayPush(tableIdList, &pkeyInfo->uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tableIdList;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
|
||||||
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId, SNode* pTagCond) {
|
STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId, SNode* pTagCond) {
|
||||||
int32_t code =
|
int32_t code =
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue