diff --git a/.gitmodules b/.gitmodules index 07e4bb2b9c..7d5515f8c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "src/connector/hivemq-tdengine-extension"] path = src/connector/hivemq-tdengine-extension url = git@github.com:taosdata/hivemq-tdengine-extension.git -[submodule "deps/jemalloc"] - path = deps/jemalloc - url = https://github.com/jemalloc/jemalloc [submodule "deps/TSZ"] path = deps/TSZ url = https://github.com/taosdata/TSZ.git diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 83fa1479dc..e9e7538872 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -443,7 +443,7 @@ pipeline { } } } - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + /*catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { timeout(time: 15, unit: 'MINUTES'){ script { sh ''' @@ -455,7 +455,7 @@ pipeline { ''' } } - } + }*/ } } } diff --git a/cmake/cmake.options b/cmake/cmake.options index 51d6f53048..d2dd48c1a0 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -47,15 +47,21 @@ IF(${TD_WINDOWS}) ) option( - BUILD_TEST - "If build unit tests using googletest" - ON - ) + BUILD_TEST + "If build unit tests using googletest" + ON + ) option( - TDENGINE_3 - "TDengine 3.x" - ON + TDENGINE_3 + "TDengine 3.x for taos-tools" + ON + ) + + option( + BUILD_CRASHDUMP + "If build crashdump on Windows" + ON ) ELSEIF (TD_DARWIN_64) @@ -84,6 +90,12 @@ ELSE () ENDIF () ENDIF () +option( + JEMALLOC_ENABLED + "If build with jemalloc" + OFF + ) + option( BUILD_SANITIZER "If build sanitizer" diff --git a/cmake/crashdump_CMakeLists.txt.in b/cmake/crashdump_CMakeLists.txt.in new file mode 100644 index 0000000000..af4b551159 --- /dev/null +++ b/cmake/crashdump_CMakeLists.txt.in @@ -0,0 +1,12 @@ + +# crashdump +ExternalProject_Add(crashdump + GIT_REPOSITORY https://github.com/Arnavion/crashdump.git + GIT_TAG master + SOURCE_DIR "${TD_CONTRIB_DIR}/crashdump" + BINARY_DIR "${TD_CONTRIB_DIR}/crashdump" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) diff --git a/cmake/jemalloc_CMakeLists.txt.in b/cmake/jemalloc_CMakeLists.txt.in new file mode 100644 index 0000000000..5c5ac5c626 --- /dev/null +++ b/cmake/jemalloc_CMakeLists.txt.in @@ -0,0 +1,14 @@ + +# jemalloc +ExternalProject_Add(jemalloc + GIT_REPOSITORY https://github.com/jemalloc/jemalloc.git + GIT_TAG 5.3.0 + SOURCE_DIR "${TD_CONTRIB_DIR}/jemalloc" + BINARY_DIR "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + GIT_SHALLOW true + GIT_PROGRESS true + ) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 1887ba5365..83246289f1 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -27,6 +27,10 @@ else () cat("${TD_SUPPORT_DIR}/taosadapter_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif() +if(TD_LINUX_64 AND JEMALLOC_ENABLED) + cat("${TD_SUPPORT_DIR}/jemalloc_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + # pthread if(${BUILD_PTHREAD}) cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) @@ -116,6 +120,11 @@ if(${BUILD_WITH_NURAFT}) cat("${TD_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_NURAFT}) +# crashdump +if(${BUILD_CRASHDUMP}) + cat("${TD_SUPPORT_DIR}/crashdump_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif(${BUILD_CRASHDUMP}) + # addr2line if(${BUILD_ADDR2LINE}) if(NOT ${TD_WINDOWS}) @@ -253,6 +262,16 @@ if(${BUILD_PTHREAD}) target_link_libraries(pthread INTERFACE libpthreadVC3) endif() +# crashdump +if(${BUILD_CRASHDUMP}) + add_executable(dumper "crashdump/dumper/dumper.c") + target_link_libraries(dumper User32.lib dbghelp.lib) + file(READ "crashdump/crasher/crasher.c" CRASHDUMP_CONTENT) + string(REPLACE "main(" "main_crashdump(" CRASHDUMP_CONTENT "${CRASHDUMP_CONTENT}") + file(WRITE "crashdump/crasher/crasher.c" "${CRASHDUMP_CONTENT}") + add_library(crashdump STATIC "crashdump/crasher/crasher.c") +endif() + # iconv if(${BUILD_WITH_ICONV}) add_library(iconv STATIC iconv/win_iconv.c) @@ -399,6 +418,18 @@ if(${BUILD_ADDR2LINE}) endif(NOT ${TD_WINDOWS}) endif(${BUILD_ADDR2LINE}) +# jemalloc +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + include(ExternalProject) + ExternalProject_Add(jemalloc + PREFIX "jemalloc" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ + BUILD_COMMAND ${MAKE} + ) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include) +ENDIF () # ================================================================================================ # Build test diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx index 18a695cda8..2061961e42 100644 --- a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -23,7 +23,7 @@ A single line of text is used in OpenTSDB line protocol to represent one row of - `metric` will be used as the STable name. - `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported. -- `value` is a metric which must be a numeric value, the corresponding column name is "value". +- `value` is a metric which must be a numeric value, the corresponding column name is "_value". - The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically. For example: @@ -74,7 +74,7 @@ taos> show STables; Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; - tbname | ts | value | groupid | location | + tbname | _ts | _value | groupid | location | ================================================================================================================================== t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles | diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx index 3a23944031..a8f3423787 100644 --- a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -91,7 +91,7 @@ taos> show STables; Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; - ts | value | groupid | location | + _ts | _value | groupid | location | =================================================================================================================== 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 129b7eb0c3..c5cbf5a70b 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -15,9 +15,104 @@ Single-Row functions return a result row for each row in the query result. SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The absolute of a specific column. +**Description**: The absolute value of a specific field. -**Return value type**: UBIGINT if the input value is integer; DOUBLE if the input value is FLOAT/DOUBLE. +**Return value type**: Same as input type. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: +- Cannot be used with aggregate functions. + +#### ACOS + +```sql +SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The anti-cosine of a specific field. + +**Return value type**: DOUBLE. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: +- Cannot be used with aggregate functions. + +#### ASIN + +```sql +SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The anti-sine of a specific field. + +**Return value type**: DOUBLE. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: +- Cannot be used with aggregate functions. + +#### ATAN + +```sql +SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: anti-tangent of a specific field. + +**Return value type**: DOUBLE. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: +- Cannot be used with aggregate functions. + +#### CEIL + +``` +SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; +``` + +**Description**: The rounded up value of a specific field. + +**Return value type**: Same as input type. + +**Applicable data types**: Numeric types. + +**Applicable table types**: table, STable + +**Applicable nested query**: Inner query and outer query. + +**More explanations**: +- Can't be used with aggregate functions. + +#### COS + +```sql +SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: The cosine of a specific field. + +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. @@ -28,115 +123,15 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] **More explanations**: - Can't be used with aggregate functions. -#### ACOS - -```sql -SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: The anti-cosine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL - -**Applicable data types**: Numeric types. - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query - -**More explanations**: -- Can't be used with aggregate functions - -#### ASIN - -```sql -SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: The anti-sine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL - -**Applicable data types**: Numeric types. - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query - -**More explanations**: -- Can't be used with aggregate functions - -#### ATAN - -```sql -SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: anti-tangent of a specific column - -**Description**: The anti-cosine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL - -**Applicable data types**: Numeric types. - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query - -**More explanations**: -- Can't be used with aggregate functions - -#### CEIL - -``` -SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; -``` - -**Description**: The rounded up value of a specific column - -**Return value type**: Same as the column being used - -**Applicable data types**: Numeric types. - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and outer query - -**More explanations**: -- Arithmetic operation can be performed on the result of `ceil` function -- Can't be used with aggregate functions - -#### COS - -```sql -SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: The cosine of a specific column - -**Description**: The anti-cosine of a specific column - -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL - -**Applicable data types**: Numeric types. - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query - -**More explanations**: -- Can't be used with aggregate functions - #### FLOOR ``` SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded down value of a specific column +**Description**: The rounded down value of a specific field. -**More explanations**: The restrictions are same as those of the `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### LOG @@ -144,15 +139,15 @@ SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The log of a specific with `base` as the radix +**Description**: The logarithm of a specific field with `base` as the radix. If `base` parameter is ignored, natural logarithm of the field is returned. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - Can't be used with aggregate functions @@ -163,18 +158,18 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The power of a specific column with `power` as the index +**Description**: The power of a specific field with `power` as the index. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### ROUND @@ -182,9 +177,9 @@ SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The rounded value of a specific column. +**Description**: The rounded value of a specific field. -**More explanations**: The restrictions are same as `CEIL` function. +**More explanations**: Refer to `CEIL` function for usage restrictions. #### SIN @@ -192,20 +187,20 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sine of a specific column +**Description**: The sine of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### SQRT @@ -213,18 +208,18 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The square root of a specific column +**Description**: The square root of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. #### TAN @@ -232,20 +227,20 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The tangent of a specific column +**Description**: The tangent of a specific field. -**Description**: The anti-cosine of a specific column +**Description**: The anti-cosine of a specific field. -**Return value type**: Double if the input value is not NULL; or NULL if the input value is NULL +**Return value type**: DOUBLE. **Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Can't be used with aggregate functions +- Can't be used with aggregate functions. ### String Functions @@ -257,19 +252,16 @@ String functiosn take strings as input and output numbers or strings. SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in number of characters of a string +**Description**: The mumber of characters of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations** - -- If the input value is NULL, the output is NULL too #### CONCAT @@ -277,15 +269,16 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings, the number of strings to be concatenated is at least 2 and at most 8 +**Description**: The concatenation result of two or more strings. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. **Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are requird, and at most 8 input strings are allowed. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. -**Applicable nested query**: Inner query and Outer query #### CONCAT_WS @@ -293,19 +286,16 @@ SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHER SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The concatenation result of two or more strings with separator, the number of strings to be concatenated is at least 3 and at most 9 +**Description**: The concatenation result of two or more strings with separator. -**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. +**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL. **Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are requird, and at most 9 input strings are allowed. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations**: - -- If the value of `separator` is NULL, the output is NULL. If the value of `separator` is not NULL but other input are all NULL, the output is empty string. #### LENGTH @@ -313,18 +303,16 @@ SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | st SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The length in bytes of a string +**Description**: The length in bytes of a string. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: VARCHAR or NCHAR -**Applicable table types**: table, STable +**Applicable data types**: VARCHAR, NCHAR. -**Applicable nested query**: Inner query and Outer query +**Applicable table types**: table, STable. -**More explanations** +**Applicable nested query**: Inner query and Outer query. -- If the input value is NULL, the output is NULL too #### LOWER @@ -332,19 +320,16 @@ SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to lower case +**Description**: Convert the input string to lower case. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations** - -- If the input value is NULL, the output is NULL too #### LTRIM @@ -352,19 +337,16 @@ SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the left leading blanks of a string +**Description**: Remove the left leading blanks of a string. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations** - -- If the input value is NULL, the output is NULL too #### RTRIM @@ -372,19 +354,16 @@ SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Remove the right tailing blanks of a string +**Description**: Remove the right tailing blanks of a string. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations** - -- If the input value is NULL, the output is NULL too #### SUBSTR @@ -392,21 +371,21 @@ SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` +**Description**: The sub-string starting from `pos` with length of `len` from the original string `str`. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: - If the input is NULL, the output is NULL - Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string. -- If `len` is not specified, it means from `pos` to the end. +- If `len` is not specified, it means from `pos` to the end of string. #### UPPER @@ -414,23 +393,20 @@ SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: Convert the input string to upper case +**Description**: Convert the input string to upper case. -**Return value type**: Same as input +**Return value type**: Same as input type. -**Applicable data types**: VARCHAR or NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**More explanations** - -- If the input value is NULL, the output is NULL too ### Conversion Functions -This kind of functions convert from one data type to another one. +Conversion functions convert from one data type to another. #### CAST @@ -438,43 +414,38 @@ This kind of functions convert from one data type to another one. SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] ``` -**Description**: It's used for type casting. The input parameter `expression` can be data columns, constants, scalar functions or arithmetic between them. +**Description**: Used for type casting. Convert `expression` to the type specified by `type_name`. -**Return value type**: The type specified by parameter `type_name` +**Return value type**: The type specified by parameter `type_name`. -**Applicable data types**: - -- Parameter `expression` can be any data type except for JSON -- The output data type specified by `type_name` can only be one of BIGINT/VARCHAR(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED +**Applicable data types**: `expression` can be any data type except for JSON. **More explanations**: -- Error will be reported for unsupported type casting -- NULL will be returned if the input value is NULL +- Error will be reported for unsupported type casting. - Some values of some supported data types may not be casted, below are known issues: 1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0. - 2)There may be overflow when casting singed integer or TIMESTAMP to unsigned BIGINT - 3)There may be overflow when casting unsigned BIGINT to BIGINT - 4)There may be overflow when casting FLOAT/DOUBLE to BIGINT or UNSIGNED BIGINT + 2)When casting to numeric type, if converted result is out of range the destination data type can hold, overflow may occur and casting behavior is undefined. + 3) When casting to VARCHAR/NCHAR type, if converted string length exceeds the length specified in `type_name`, the result will be truncated. (e.g. CAST("abcd" as BINARY(2)) will return string "ab"). #### TO_ISO8601 ```sql -SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone of the client side system +**Description**: The ISO8601 date/time format converted from a UNIX timestamp, with timezone attached. `timezone` parameter allows attaching any customized timezone string to the output format. If `timezone` parameter is not specified, the timezone information of client side system will be attached. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: TIMESTAMP, constant or a column +**Applicable data types**: INTEGER, TIMESTAMP. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- If the input is UNIX timestamp constant, the precision of the returned value is determined by the digits of the input timestamp -- If the input is a column of TIMESTAMP type, The precision of the returned value is same as the precision set for the current data base in use +- If the input is INTEGER represents UNIX timestamp, the precision of the returned value is determined by the digits of the input integer. +- If the input is of TIMESTAMP type, The precision of the returned value is same as the precision set for the current database in use. #### TO_JSON @@ -482,13 +453,13 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Convert a JSON string to a JSON body。 +**Description**: Convert a JSON string to a JSON body. -**Return value type**: JSON +**Return value type**: JSON. -**Applicable column types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. +**Applicable data types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Applicable nested query**: Inner query and Outer query. @@ -498,22 +469,22 @@ SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause]; SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: UNIX timestamp converted from a string of date/time format +**Description**: UNIX timestamp converted from a string of date/time format. -**Return value type**: Long integer +**Return value type**: BIGINT. -**Applicable column types**: Constant or column of VARCHAR/NCHAR +**Applicable data types**: VARCHAR, NCHAR. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The input string must be compatible with ISO8601/RFC3339 standard, 0 will be returned if the string can't be converted -- The precision of the returned timestamp is same as the precision set for the current data base in use +- The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string cannot be converted. +- The precision of the returned timestamp is same as the precision set for the current database in use. ### DateTime Functions -This kind of functiosn oeprate on timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occurr multiple times in a single SQL statement. +DateTime functions applied to timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occur multiple times in a single SQL statement. #### NOW @@ -523,39 +494,39 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW() INSERT INTO tb_name VALUES (NOW(), ...); ``` -**Description**: The current time of the client side system +**Description**: The current time of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation with time duration can be performed, for example NOW() + 1s, the time unit can be one of the followings: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. #### TIMEDIFF ```sql -SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; +SELECT TIMEDIFF(ts1 | datetime_string1, ts2 | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit` +**Description**: The difference(duration) between two timestamps, and rounded to the time unit specified by `time_unit`. -**Return value type**: Long Integer +**Return value type**: BIGINT. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of TIMESTAMP type +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- If `time_unit` parameter is not specified, the precision of the returned time duration is same as the precision set for the current database in use. #### TIMETRUNCATE @@ -563,19 +534,19 @@ SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: Truncate the input timestamp with unit specified by `time_unit` +**Description**: Truncate the input timestamp with unit specified by `time_unit`. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: UNIX timestamp constant, string constant of date/time format, or a column of timestamp +**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - Time unit specified by `time_unit` can be: - 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day). -- The precision of the returned timestamp is same as the precision set for the current data base in use + 1b(nanosecond),1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. #### TIMEZONE @@ -583,13 +554,13 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The timezone of the client side system +**Description**: The timezone of the client side system. -**Return value type**: VARCHAR +**Return value type**: VARCHAR. -**Applicable column types**: None +**Applicable data types**: None. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. #### TODAY @@ -599,37 +570,60 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY INSERT INTO tb_name VALUES (TODAY(), ...); ``` -**Description**: The timestamp of 00:00:00 of the client side system +**Description**: The timestamp of 00:00:00 of the client side system. -**Return value type**: TIMESTAMP +**Return value type**: TIMESTAMP. -**Applicable column types**: TIMESTAMP only +**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be: - b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week) -- The precision of the returned timestamp is same as the precision set for the current data base in use +- Addition and Subtraction operation can be performed with time durations, for example NOW() + 1s, the time unit can be: + b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week). +- The precision of the returned timestamp is same as the precision set for the current database in use. ## Aggregate Functions Aggregate functions return single result row for each group in the query result set. Groups are determined by `GROUP BY` clause or time window clause if they are used; or the whole result is considered a group if neither of them is used. +### APERCENTILE + +``` +SELECT APERCENTILE(field_name, P[, algo_type]) +FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: Similar to `PERCENTILE`, but a approximated result is returned. + +**Return value type**: DOUBLE. + +**Applicable column types**: Numeric types. + +**Applicable table types**: table, STable. + +**More explanations** + +- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. +- If `default` is used, histogram based algorithm is used for calculation. If `t-digest` is used, `t-digest` sampling algorithm is used to calculate the result. + +**Nested query**: It can be used in both the outer query and inner query in a nested query. + ### AVG ``` SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Get the average value of a column in a table or STable +**Description**: Get the average value of a column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric type +**Applicable data types**: Numeric type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### COUNT @@ -637,17 +631,17 @@ SELECT AVG(field_name) FROM tb_name [WHERE clause]; SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**Description**: Get the number of rows or the number of non-null values in a table or a super table. +**Description**: Get the number of rows in a table or a super table. -**Return value type**: Long integer INT64 +**Return value type**: BIGINT. -**Applicable column types**: All +**Applicable data types**: All data types. -**Applicable table types**: table, super table, sub table +**Applicable table types**: table, STable. **More explanation**: -- Wildcard (\*) is used to represent all columns. The `COUNT` function is used to get the total number of all rows. +- Wildcard (\*) is used to represent all columns. If \* used `COUNT` function will get the total number of all rows. - The number of non-NULL values will be returned if this function is used on a specific column. ### ELAPSED @@ -656,13 +650,13 @@ SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]]; ``` -**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length. +**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time duration within the specified time range. Please be noted that the calculated time duration is in the specified `time_unit`. -**Return value type**:Double +**Return value type**:DOUBLE. -**Applicable Column type**:Timestamp +**Applicable Column type**:TIMESTAMP. -**Applicable tables**: table, STable, outter in nested query +**Applicable tables**: table, STable, outter in nested query. **Explanations**: @@ -673,7 +667,7 @@ SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE claus - `group by tbname` must be used together when `elapsed` is used against a STable. - `group by` must NOT be used together when `elapsed` is used against a table or sub table. - When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not. -- It can't be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. +- It cannot be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`. ### LEASTSQUARES @@ -683,25 +677,11 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. -**Return value type**: A string in the format of "(slope, intercept)" +**Return value type**: VARCHAR string in the format of "(slope, intercept)". -**Applicable column types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table only - -### MODE - -``` -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column. - -**Return value type**:Same as the data type of the column being operated upon - -**Applicable column types**:Data types except for timestamp - -**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. +**Applicable table types**: table only. ### SPREAD @@ -709,15 +689,15 @@ SELECT MODE(field_name) FROM tb_name [WHERE clause]; SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The difference between the max and the min of a specific column +**Description**: The difference between the max and the min value of a specific column. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**More explanations**: Can be used on a column of TIMESTAMP type, the result is the time range size. +**More explanations**: Can be used on a column of TIMESTAMP type, the result time unit precision is same as the current database in use. ### STDDEV @@ -725,13 +705,13 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: Standard deviation of a specific column in a table or STable +**Description**: Standard deviation of a specific column in a table or STable. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### SUM @@ -739,13 +719,13 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The sum of a specific column in a table or STable +**Description**: The summation of values of a specific column in a table or STable. -**Return value type**: Double precision floating number or long integer +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### HYPERLOGLOG @@ -755,9 +735,9 @@ SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; **Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm. -**Return value type**:Integer +**Return value type**: INTEGER. -**Applicable column types**:Any data type +**Applicable column types**: All data types. **More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case. @@ -769,16 +749,16 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam **Description**:Returns count of data points in user-specified ranges. -**Return value type**:Double or INT64, depends on normalized parameter settings. +**Return value type**:DOUBLE or BIGINT, depends on normalized parameter settings. **Applicable column type**:Numerical types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **Explanations**: 1. bin_type: parameter to indicate the bucket type, valid inputs are: "user_input", "linear_bin", "log_bin"。 -2. bin_description: parameter to describe how to generate buckets,can be in the following JSON formats for each bin_type respectively: +2. bin_description: parameter to describe the rule to generate buckets,can be in the following JSON formats for each bin_type respectively: - "user_input": "[1, 3, 5, 7]": User specified bin values. @@ -798,32 +778,25 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam 3. normalized: setting to 1/0 to turn on/off result normalization. +### PERCENTILE + +``` +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +``` + +**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. + +**Return value type**: DOUBLE. + +**Applicable column types**: Numeric types. + +**Applicable table types**: table. + +**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. + ## Selector Functions -Selector functiosn choose one or more rows in the query result set to retrun according toe the semantics. You can specify to output ts column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. - -### APERCENTILE - -``` -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: Similar to `PERCENTILE`, but a simulated result is returned - -**Return value type**: Double precision floating point - -**Applicable column types**: Numeric types - -**Applicable table types**: table, STable - -**More explanations** - -- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. -- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`. -- When `t-digest` is used, `t-digest` sampling is used to calculate. - -**Nested query**: It can be used in both the outer query and inner query in a nested query. +Selector functiosn choose one or more rows in the query result according to the semantics. You can specify to output primary timestamp column and other columns including tbname and tags so that you can easily know which rows the selected values belong to. ### BOTTOM @@ -833,17 +806,17 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Can't be used with `FILL`. ### FIRST @@ -851,13 +824,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The first non-null value of a specific column in a table or STable +**Description**: The first non-null value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -873,11 +846,11 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric data types +**Applicable column types**: Numeric data types. -**Applicable table types**: table, STable, nested query +**Applicable table types**: table, STable, nested query. **More explanations** @@ -895,13 +868,13 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The last non-NULL value of a specific column in a table or STable +**Description**: The last non-NULL value of a specific column in a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: @@ -915,18 +888,18 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` -**Description**: The last row of a table or STable +**Description**: The last row of a table or STable. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type +**Applicable column types**: All data type. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times. -- Can't be used with `INTERVAL`. +- Cannot be used with `INTERVAL`. ### MAX @@ -934,13 +907,13 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The maximum value of a specific column of a table or STable +**Description**: The maximum value of a specific column of a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. ### MIN @@ -948,29 +921,48 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**Description**: The minimum value of a specific column in a table or STable +**Description**: The minimum value of a specific column in a table or STable. -**Return value type**: Same as the data type of the column being operated upon +**Return value type**: Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -### PERCENTILE +### MODE ``` -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned. +**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. -**Return value type**: Double precision floating point +**Return value type**:Same as the data type of the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: All data types. -**Applicable table types**: table +**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned. -**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. +### SAMPLE + +```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +``` + +**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000]. + +**Return value type**: Same as the column being operated. + +**Applicable data types**: All data types. + +**Applicable table types**: table, STable. + +**Applicable nested query**: Inner query and Outer query. + +**More explanations**: + +- Arithmetic operation cannot be operated on the result of `SAMPLE` function +- Must be used with `Partition by tbname` when it's used on a STable to force the result on each single timeline. ### TAIL @@ -980,11 +972,11 @@ SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`. -**Parameter value range**: k: [1,100] offset_val: [0,100] +**Parameter value range**: k: [1,100] offset_val: [0,100]. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Any data type except form timestamp, i.e. the primary key +**Applicable column types**: All data types. ### TOP @@ -994,17 +986,17 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- _k_ must be in range [1,100] -- The timestamp associated with the selected values are returned too -- Can't be used with `FILL` +- _k_ must be in range [1,100]. +- The timestamp associated with the selected values are returned too. +- Cannot be used with `FILL`. ### UNIQUE @@ -1014,9 +1006,9 @@ SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; **Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. -**Return value type**: Same as the column or tag being operated upon +**Return value type**: Same as the column or tag being operated upon. -**Applicable column types**: Any data types except for timestamp +**Applicable column types**: All data types. **More explanations**: @@ -1035,18 +1027,18 @@ TDengine provides a set of time-series specific functions to better meet the req **Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows. -**Return value type**: Long integer for integers; Double for floating points. Timestamp is returned for each row. +**Return value type**: BIGINT for signed integer input types; UNSIGNED BIGINT for unsigned integer input types; DOUBLE for floating point input types. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. **More explanations**: -- Arithmetic operation can't be performed on the result of `csum` function -- Can only be used with aggregate functions -- `Group by tbname` must be used together on a STable to force the result on a single timeline +- Arithmetic operation cannot be performed on the result of `csum` function. +- Can only be used with aggregate functions. +- `Partition by tbname` must be used together on a STable to force the result on a single timeline. ### DERIVATIVE @@ -1056,16 +1048,17 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: - The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row. -- It can be used together with `GROUP BY tbname` against a STable. +- It can be used together with `PARTITION BY tbname` against a STable. +- Can be used together with selection of relative columns. E.g. select \_rowts, DERIVATIVE() from. ### DIFF @@ -1075,16 +1068,17 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER **Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. -**Return value type**: Same as the column being operated upon +**Return value type**: Same as the column being operated upon. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- The number of result rows is the number of rows subtracted by one, no output for the first row -- It can be used on STable with `GROUP by tbname` +- The number of result rows is the number of rows subtracted by one, no output for the first row. +- It can be used on STable with `PARTITION by tbname`. +- Can be used together with selection of relative columns. E.g. select \_rowts, DIFF() from. ### IRATE @@ -1094,15 +1088,15 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stble with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stble with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ### MAVG @@ -1112,40 +1106,19 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000]. -**Return value type**: Double precision floating point +**Return value type**: DOUBLE. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable nested query**: Inner query and Outer query +**Applicable nested query**: Inner query and Outer query. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- Arithmetic operation can't be performed on the result of `MAVG`. -- Can't be used with aggregate functions. -- Must be used with `GROUP BY tbname` when it's used on a STable to force the result on each single timeline. - -### SAMPLE - -```sql - SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` - -**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,10000] - -**Return value type**: Same as the column being operated plus the associated timestamp - -**Applicable data types**: Any data type except for tags of STable - -**Applicable table types**: table, STable - -**Applicable nested query**: Inner query and Outer query - -**More explanations**: - -- Arithmetic operation can't be operated on the result of `SAMPLE` function -- Must be used with `Group by tbname` when it's used on a STable to force the result on each single timeline +- Arithmetic operation cannot be performed on the result of `MAVG`. +- Cannot be used with aggregate functions. +- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline. ### STATECOUNT @@ -1153,25 +1126,25 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. +**Description**: The number of continuous rows satisfying the specified conditions for a specific column. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### STATEDURATION @@ -1179,26 +1152,26 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. +**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped. **Applicable parameter values**: -- oper : Can be one of LT (lower than), GT (greater than), LE (lower than or euqal to), GE (greater than or equal to), NE (not equal to), EQ (equal to), the value is case insensitive -- val : Numeric types -- unit: The unit of time interval, can be [1s, 1m, 1h], default is 1s +- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to). +- val : Numeric types. +- unit : The unit of time interval, can be: 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). If not specified, default is same as the current database time precision in use. -**Return value type**: Integer +**Return value type**: INTEGER. -**Applicable data types**: Numeric types +**Applicable data types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. -**Applicable nested query**: Outer query only +**Applicable nested query**: Outer query only. **More explanations**: -- Must be used together with `GROUP BY tbname` when it's used on a STable to force the result into each single timeline] -- Can't be used with window operation, like interval/state_window/session_window +- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline. +- Cannot be used with window operation, like interval/state_window/session_window. ### TWA @@ -1206,17 +1179,17 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -**Description**: Time weighted average on a specific column within a time range +**Description**: Time weighted average on a specific column within a time range. -**Return value type**: Double precision floating number +**Return value type**: DOUBLE. -**Applicable column types**: Numeric types +**Applicable column types**: Numeric types. -**Applicable table types**: table, STable +**Applicable table types**: table, STable. **More explanations**: -- It can be used on stable with `GROUP BY`, i.e. timelines generated by `GROUP BY tbname` on a STable. +- It can be used on stable with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable. ## System Information Functions diff --git a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx index 2b397e1bdc..1cc402c3c0 100644 --- a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -23,7 +23,7 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB - metric 将作为超级表名。 - timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 -- value 度量值,必须为一个数值。对应的列名也是 “value”。 +- value 度量值,必须为一个数值。对应的列名是 “_value”。 - 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; 例如: @@ -74,7 +74,7 @@ taos> show stables; Query OK, 2 row(s) in set (0.002544s) taos> select tbname, * from `meters.current`; - tbname | ts | value | groupid | location | + tbname | _ts | _value | groupid | location | ================================================================================================================================== t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles | diff --git a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx index a15f80a585..09cb698fba 100644 --- a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -91,7 +91,7 @@ taos> show stables; Query OK, 2 row(s) in set (0.001954s) taos> select * from `meters.current`; - ts | value | groupid | location | + _ts | _value | groupid | location | =================================================================================================================== 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index f4d4555832..7e4f3420b8 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -594,6 +594,24 @@ INSERT INTO tb_name VALUES (TODAY(), ...); TDengine 支持针对数据的聚合查询。提供如下聚合函数。 +### APERCENTILE + +```sql +SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause] +``` + +**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 + +**返回数据类型**: DOUBLE。 + +**适用数据类型**:数值类型。 + +**适用于**:表和超级表。 + +**说明**: +- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 +- algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 + ### AVG ```sql @@ -656,6 +674,7 @@ SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE - 对于嵌套查询,仅当内层查询会输出隐式时间戳列时有效。例如select elapsed(ts) from (select diff(value) from sub1)语句,diff函数会让内层查询输出隐式时间戳列,此为主键列,可以用于elapsed函数的第一个参数。相反,例如select elapsed(ts) from (select * from sub1) 语句,ts列输出到外层时已经没有了主键列的含义,无法使用elapsed函数。此外,elapsed函数作为一个与时间线强依赖的函数,形如select elapsed(ts) from (select diff(value) from st group by tbname)尽管会返回一条计算结果,但并无实际意义,这种用法后续也将被限制。 - 不支持与leastsquares、diff、derivative、top、bottom、last_row、interp等函数混合使用。 + ### LEASTSQUARES ```sql @@ -671,21 +690,6 @@ SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause] **适用于**:表。 -### MODE - -```sql -SELECT MODE(field_name) FROM tb_name [WHERE clause]; -``` - -**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 - -**返回数据类型**:与输入数据类型一致。 - -**适用数据类型**:全部类型字段。 - -**适用于**:表和超级表。 - - ### SPREAD ```sql @@ -778,28 +782,26 @@ SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_nam 3. normalized 是否将返回结果归一化到 0~1 之间 。有效输入为 0 和 1。 -## 选择函数 - -选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 - -### APERCENTILE +### PERCENTILE ```sql -SELECT APERCENTILE(field_name, P[, algo_type]) -FROM { tb_name | stb_name } [WHERE clause] +SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` -**功能说明**:统计表/超级表中指定列的值的近似百分比分位数,与 PERCENTILE 函数相似,但是返回近似结果。 +**功能说明**:统计表中某列的值百分比分位数。 **返回数据类型**: DOUBLE。 -**适用数据类型**:数值类型。 +**应用字段**:数值类型。 -**适用于**:表和超级表。 +**适用于**:表。 -**说明**: -- P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 -- algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 +**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 + + +## 选择函数 + +选择函数根据语义在查询结果集中选择一行或多行结果返回。用户可以同时指定输出 ts 列或其他列(包括 tbname 和标签列),这样就可以方便地知道被选出的值是源于哪个数据行的。 ### BOTTOM @@ -935,21 +937,41 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **适用于**:表和超级表。 -### PERCENTILE +### MODE ```sql -SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; +SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:统计表中某列的值百分比分位数。 +**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。 -**返回数据类型**: DOUBLE。 +**返回数据类型**:与输入数据类型一致。 -**应用字段**:数值类型。 +**适用数据类型**:全部类型字段。 -**适用于**:表。 +**适用于**:表和超级表。 -**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 + +### SAMPLE + +```sql +SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] +``` + + **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 + + **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 + + **嵌套子查询支持**: 适用于内层查询和外层查询。 + + **适用于**:表和超级表。 + + **使用说明**: + + - 不能参与表达式计算;该函数可以应用在普通表和超级表上; + - 使用在超级表上的时候,需要搭配 PARTITION by tbname 使用,将结果强制规约到单个时间线。 ### TAIL @@ -1016,7 +1038,7 @@ SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 -**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 +**返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 **适用数据类型**:数值类型。 @@ -1045,8 +1067,10 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **适用于**:表和超级表。 -**使用说明**: DERIVATIVE 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 - +**使用说明**: + + - DERIVATIVE 函数可以在由 PARTITION BY 划分出单独时间线的情况下用于超级表(也即 PARTITION BY tbname)。 + - 可以与选择相关联的列一起使用。 例如: select \_rowts, DERIVATIVE() from。 ### DIFF @@ -1062,7 +1086,10 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER **适用于**:表和超级表。 -**使用说明**: 输出结果行数是范围内总行数减一,第一行没有结果输出。 +**使用说明**: + + - 输出结果行数是范围内总行数减一,第一行没有结果输出。 + - 可以与选择相关联的列一起使用。 例如: select \_rowts, DIFF() from。 ### IRATE @@ -1102,26 +1129,6 @@ SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; - 使用在超级表上的时候,需要搭配 PARTITION BY tbname使用,将结果强制规约到单个时间线。 -### SAMPLE - -```sql -SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] -``` - - **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - - **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 - - **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 - - **嵌套子查询支持**: 适用于内层查询和外层查询。 - - **适用于**:表和超级表。 - - **使用说明**: - - - 不能参与表达式计算;该函数可以应用在普通表和超级表上; - - 使用在超级表上的时候,需要搭配 PARTITION by tbname 使用,将结果强制规约到单个时间线。 ### STATECOUNT @@ -1162,7 +1169,7 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W - oper : "LT" (小于)、"GT"(大于)、"LE"(小于等于)、"GE"(大于等于)、"NE"(不等于)、"EQ"(等于),不区分大小写。 - val : 数值型 -- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为 1s。 +- unit : 时间长度的单位,可取值时间单位: 1b(纳秒), 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天), 1w(周)。如果省略,默认为当前数据库精度。 **返回结果类型**:INTEGER。 diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index fefb50c541..845693a98e 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -1,6 +1,6 @@ --- title: 配置参数 -description: 'TDengine 客户端和服务配置列表' +description: "TDengine 客户端和服务配置列表" --- ## 为服务端指定配置文件 @@ -21,8 +21,6 @@ taosd -C TDengine 系统的前台交互客户端应用程序为 taos,以及应用驱动,它可以与 taosd 共享同一个配置文件 taos.cfg,也可以使用单独指定配置文件。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg,表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`。 -**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置** - ```bash taos -C ``` @@ -47,19 +45,19 @@ taos --dump-config ### firstEp -| 属性 | 说明 | -| -------- | --------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 endpoint | -| 缺省值 | localhost:6030 | +| 缺省值 | localhost:6030 | ### secondEp -| 属性 | 说明 | -| -------- | -------------------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | | 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint | -| 缺省值 | 无 | +| 缺省值 | 无 | ### fqdn @@ -77,7 +75,6 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | taosd 启动后,对外服务的端口号 | | 缺省值 | 6030 | -| 补充说明 | RESTful 服务在 2.4.0.0 之前(不含)由 taosd 提供,默认端口为 6041; 在 2.4.0.0 及后续版本由 taosAdapter,默认端口为 6041 | :::note 确保集群中所有主机在端口 6030 上的 TCP 协议能够互通。(详细的端口情况请参见下表) @@ -87,8 +84,8 @@ taos --dump-config | TCP | 6030 | 客户端与服务端之间通讯,多节点集群的节点间通讯。 | 由配置文件设置 serverPort 决定。 | | TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | | TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化| +| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化 | | TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | ### maxShellConns @@ -104,28 +101,28 @@ taos --dump-config ### monitor -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽的监控记录,监控信息将通过 HTTP 协议发送给由 `monitorFqdn` 和 `monitorProt` 指定的 TaosKeeper 监控服务 | -| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | -| 缺省值 | 1 | +| 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | +| 缺省值 | 1 | ### monitorFqdn -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | TaosKeeper 监控服务的 FQDN | -| 缺省值 | 无 | +| 缺省值 | 无 | ### monitorPort -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | --------------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | TaosKeeper 监控服务的端口号 | -| 缺省值 | 6043 | +| 缺省值 | 6043 | ### monitorInterval @@ -134,10 +131,9 @@ taos --dump-config | 适用范围 | 仅服务端适用 | | 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | | 单位 | 秒 | -| 取值范围 | 1-200000 | +| 取值范围 | 1-200000 | | 缺省值 | 30 | - ### telemetryReporting | 属性 | 说明 | @@ -149,25 +145,43 @@ taos --dump-config ## 查询相关 -### queryBufferSize +### queryPolicy + +| 属性 | 说明 | +| -------- | ----------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | 查询语句的执行策略 | +| 单位 | 无 | +| 缺省值 | 1 | +| 补充说明 | 1: 只使用 vnode,不使用 qnode | + +2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行 + +3: vnode 只运行扫描算子,其余算子均在 qnode 执行 | + +### querySmaOptimize + +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | sma index 的优化策略 | +| 单位 | 无 | +| 缺省值 | 0 | +| 补充说明 | + +0: 表示不使用 sma index,永远从原始数据进行查询 + +1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询 | -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 为所有并发查询占用保留的内存大小。 | -| 单位 | MB | -| 缺省值 | 无 | -| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | +| -------- | -------------------------------- | --- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | | 缺省值 | 10 万 | -| 补充说明 | 2.3 版本新增。 | | ## 区域相关 @@ -306,12 +320,12 @@ charset 的有效值是 UTF-8。 ### supportVnodes -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | dnode 支持的最大 vnode 数目 | -| 取值范围 | 0-4096 | -| 缺省值 | 256 | +| 属性 | 说明 | +| -------- | --------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | dnode 支持的最大 vnode 数目 | +| 取值范围 | 0-4096 | +| 缺省值 | 256 | ## 时间相关 @@ -366,7 +380,6 @@ charset 的有效值是 UTF-8。 | 单位 | bytes | | 取值范围 | 0: 对所有查询结果均进行压缩 >0: 查询结果中任意列大小超过该值的消息才进行压缩 -1: 不压缩 | | 缺省值 | -1 | -| 补充说明 | 2.3.0.0 版本新增。 | ## 日志相关 @@ -464,7 +477,7 @@ charset 的有效值是 UTF-8。 | 属性 | 说明 | | -------- | -------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | query 模块的日志开关 | +| 含义 | query 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | @@ -481,7 +494,7 @@ charset 的有效值是 UTF-8。 | 属性 | 说明 | | -------- | -------------------- | -| 适用范围 | 仅服务端适用 | +| 适用范围 | 仅服务端适用 | | 含义 | dnode 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | 135 | @@ -490,28 +503,28 @@ charset 的有效值是 UTF-8。 | 属性 | 说明 | | -------- | -------------------- | -| 适用范围 | 仅服务端适用 | +| 适用范围 | 仅服务端适用 | | 含义 | vnode 模块的日志开关 | | 取值范围 | 同上 | | 缺省值 | | ### mDebugFlag -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | mnode 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| 取值范围 | 同上 | +| 缺省值 | 135 | ### wDebugFlag -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | wal 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | 135 | +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | wal 模块的日志开关 | +| 取值范围 | 同上 | +| 缺省值 | 135 | ### sDebugFlag @@ -533,57 +546,86 @@ charset 的有效值是 UTF-8。 ### tqDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ----------------- | +| 适用范围 | 仅服务端适用 | | 含义 | tq 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | ### fsDebugFlag -| 属性 | 说明 | -| -------- | ------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ----------------- | +| 适用范围 | 仅服务端适用 | | 含义 | fs 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | ### udfDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | | 含义 | UDF 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | ### smaDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | | 含义 | sma 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | ### idxDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | | 含义 | index 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | ### tdbDebugFlag -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | | 含义 | tdb 模块的日志开关 | -| 取值范围 | 同上 | -| 缺省值 | | +| 取值范围 | 同上 | +| 缺省值 | | + +## Schemaless 相关 + +### smlChildTableName + +| 属性 | 说明 | +| -------- | ------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless 自定义的子表名 | +| 类型 | 字符串 | +| 缺省值 | 无 | + +### smlTagName + +| 属性 | 说明 | +| -------- | ------------------------------------ | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless tag 为空时默认的 tag 名字 | +| 类型 | 字符串 | +| 缺省值 | _tag_null | + +### smlDataFormat + +| 属性 | 说明 | +| -------- | ----------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | schemaless 列数据是否顺序一致 | +| 值域 | 0:不一致;1: 一致 | +| 缺省值 | 1 | ## 其他 @@ -596,3 +638,12 @@ charset 的有效值是 UTF-8。 | 取值范围 | 0:否,1:是 | | 缺省值 | 1 | | 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | + +### udf + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 是否启动 udf 服务 | +| 取值范围 | 0: 不启动;1:启动 | +| 缺省值 | 1 | diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index 507ccea629..4edad0fd1d 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -5,7 +5,7 @@ title: 整体架构 ## 集群与基本逻辑单元 -TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 +TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 ### 主要逻辑单元 @@ -19,45 +19,43 @@ TDengine 分布式架构的逻辑结构图如下: **物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 -**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 +**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode),零或者至多一个逻辑的弹性计算节点(qnode),零或者至多一个逻辑的流计算节点(snode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 -**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 +**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一个新 DB 时,系统会创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、超级表等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M1,M2,M3)。mnode 支持多副本,采用 RAFT 一致性协议,保证系统的高可用与高可靠,任何数据更新操作只能在 Leader 上进行。mnode 集群的第一个节点在集群部署时自动完成,其他节点的创建与删除由用户通过 SQL 命令完成。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 -**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 +**弹性计算点(qnode):** 一个虚拟的逻辑单元,运行查询计算任务,也包括基于系统表来实现的 show 命令(图中 Q)。集群中可配置多个 qnode,在整个集群内部共享使用(图中 Q1,Q2,Q3)。qnode 不与具体的 DB 绑定,即一个 qnode 可以同时执行多个 DB 的查询任务。每个 dnode 上至多有一个 qnode,由所属的数据节点的 EP 来唯一标识。客户端通过与 mnode 交互,获取可用的 qnode 列表,当没有可用的 qnode 时,计算任务在 vnode 中执行。 -**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 +**流计算点(snode):** 一个虚拟的逻辑单元,只运行流计算任务(图中 S)。集群中可配置多个 snode,在整个集群内部共享使用(图中 S1,S2,S3)。snode 不与具体的 stream 绑定,即一个 snode 可以同时执行多个 stream 的计算任务。每个 dnode 上至多有一个 snode,由所属的数据节点的 EP 来唯一标识。由 mnode 调度可用的 snode 完成流计算任务,当没有可用的 snode 时,流计算任务在 vnode 中执行。 + +**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup),采用 RAFT 一致性协议,保证系统的高可用与高可靠。写操作只能在 leader vnode 上进行,系统采用异步复制的方式将数据同步到 follower vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 + +**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,taosc 也可以与 taosAdapter 交互,支持全分布式的 RESTful 接口。 ### 节点之间的通讯 -**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效,而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时,TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。 +**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP 进行的。TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。 **FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 -**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。 - -- 集群内数据节点之间的数据复制操作占用一个 TCP 端口,是 serverPort+10。 -- 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。 -- 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。 - -因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port) +**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,默认为 6030。 **集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN,-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 -**集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: +**集群内部通讯:**各个数据节点之间通过 TCP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: -1. 检查 mnodeEpSet.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; +1. 检查 dnode.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步; 2. 检查系统配置文件 taos.cfg,获取节点配置参数 firstEp、secondEp(这两个参数指定的节点可以是不带 mnode 的普通节点,这样的话,节点被连接时会尝试重定向到 mnode 节点),如果不存在或者 taos.cfg 里没有这两个配置参数,或无效,进入第三步; 3. 将自己的 EP 设为 mnode EP,并独立运行起来。 获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。 -**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point,并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 +**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?在集群部署时,第一个数据节点自动成为管理节点。集群中的其他管理节点的创建与删除,由用户通过 SQL 语句完成。 **新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp,secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 -**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 +**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,由于 mnode 是可以动态调整的,所以对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 ### 一个典型的消息流程 @@ -68,15 +66,17 @@ TDengine 分布式架构的逻辑结构图如下:
图 2 TDengine 典型的操作流程
1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。 -2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get meta-data 请求。 -3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema,而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 -4. taosc 向 master vnode 发起插入请求。 -5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 -6. taosc 通知 APP,写入成功。 +2. taosc 会检查缓存,看是否保存有该表所在数据库的 vgroup-info 信息。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get vgroup-info 请求。 +3. mnode 将该表所在数据库的 vgroup-info 返回给 taosc。Vgroup-info 包含数据库的 vgroup 分布信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point),还包含每个 vgroup 中存储数据表的 hash 范围。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 +4. taosc 会继续检查缓存,看是否保存有该表的 meta-data。如果有,直接到第 6 步。如果没有,taosc 将向 vnode 发出 get meta-data 请求。 +5. vnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema。 +6. taosc 向 leader vnode 发起插入请求。 +7. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 +8. taosc 通知 APP,写入成功。 -对于第二和第三步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 +对于第二步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 -对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 +对于第四和第六步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 leader,就假设第一个 vnodeID 就是 leader,向它发出请求。如果接收到请求的 vnode 并不是 leader,它会在回复中告知谁是 leader,这样 taosc 就向建议的 leader vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 leader 节点的信息。 上述是插入数据的流程,查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。 @@ -89,13 +89,13 @@ TDengine 分布式架构的逻辑结构图如下: TDengine 存储的数据包括采集的时序数据以及库、表相关的元数据、标签数据等,这些数据具体分为三部分: - 时序数据:存放于 vnode 里,由 data、head 和 last 三个文件组成,数据量大,查询量取决于应用场景。容许乱序写入,但暂时不支持删除操作,并且仅在 update 参数设置为 1 时允许更新操作。通过采用一个采集点一张表的模型,一个时间段的数据是连续存储,对单张表的写入是简单的追加操作,一次读,可以读到多条记录,这样保证对单个采集点的插入和查询操作,性能达到最优。 -- 标签数据:存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量不大,有 N 张表,就有 N 条记录,因此可以全内存存储。如果标签过滤操作很多,查询将十分频繁,因此 TDengine 支持多核多线程并发查询。只要计算资源足够,即使有数千万张表,过滤结果能毫秒级返回。 -- 元数据:存放于 mnode 里,包含系统节点、用户、DB、Table Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 +- 数据表元数据:包含标签信息和 Table Schema 信息,存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量很大,有 N 张表,就有 N 条记录,因此采用 LRU 存储,支持标签数据的索引。TDengine 支持多核多线程并发查询。只要计算内存足够,元数据全内存存储,千万级别规模的标签数据过滤结果能毫秒级返回。在内存资源不足的情况下,仍然可以支持数千万张表的快速查询。 +- 数据库元数据:存放于 mnode 里,包含系统节点、用户、DB、STable Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。 与典型的 NoSQL 存储模型相比,TDengine 将标签数据与时序数据完全分离存储,它具有两大优势: - 能够极大地降低标签数据存储的冗余度:一般的 NoSQL 数据库或时序数据库,采用的 K-V 存储,其中的 Key 包含时间戳、设备 ID、各种标签。每条记录都带有这些重复的内容,浪费存储空间。而且如果应用要在历史数据上增加、修改或删除标签,需要遍历数据,重写一遍,操作成本极其昂贵。 -- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。而且标签数据采用全内存的结构进行管理和维护,千万级别规模的标签数据查询可以在毫秒级别返回。 +- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。 ### 数据分片 @@ -105,7 +105,7 @@ vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询 对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 -创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode,且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode,然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 +TDengine 3.0 采用 hash 一致性算法,确定每张数据表所在的 vnode。创建 DB 时,系统会立刻分配指定数目的 vnode,并确定每个 vnode 所负责的数据表范围。当创建一张表时,系统根据数据表名计算出所在的 vnodeID,立即在该 vnode 创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 @@ -117,77 +117,68 @@ TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区 ### 负载均衡 -每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 +每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。负载均衡的触发时间,由用户指定。 -如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode,而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode,以保证 mnode 的副本数。 - -当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 - -负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。 +当新的数据节点被添加进集群,因为新的计算和存储被添加进来,用户需要手动触发负载均衡流程,使得系统在最优的情况下运行。 **提示:负载均衡由参数 balance 控制,决定开启/关闭自动负载均衡。** ## 数据写入与复制流程 -如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 master,其他都是 slave。当应用将新的记录写入系统时,只有 master vnode 能接受写的请求。如果 slave vnode 收到写的请求,系统将通知 taosc 需要重新定向。 +如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 leader,其他都是 follower。当应用将新的记录写入系统时,只有 leader vnode 能接受写的请求。如果 follower vnode 收到写的请求,系统将通知 taosc 需要重新定向。 -### Master Vnode 写入流程 +### Leader Vnode 写入流程 -Master Vnode 遵循下面的写入流程: +Leader Vnode 遵循下面的写入流程: -![TDengine Database Master写入流程](./write_master.webp) +![TDengine Database Leader写入流程](./write_leader.webp) -
图 3 TDengine Master 写入流程
+
图 3 TDengine Leader 写入流程
-1. master vnode 收到应用的数据插入请求,验证 OK,进入下一步; -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; -3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes,该转发包带有数据的版本号(version); -4. 写入内存,并将记录加入到 skip list; -5. master vnode 返回确认信息给应用,表示写入成功; -6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用。 +1. leader vnode 收到应用的数据插入请求,验证 OK,进入下一步; +2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; +3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 follower vnodes,该转发包带有数据的版本号(version); +4. 写入内存,并将记录加入到 skip list。但如果未达成一致,会触发回滚操作; +5. leader vnode 返回确认信息给应用,表示写入成功; +6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用; -### Slave Vnode 写入流程 +### Follower Vnode 写入流程 -对于 slave vnode,写入流程是: +对于 follower vnode,写入流程是: -![TDengine Database Slave 写入流程](./write_slave.webp) +![TDengine Database Follower 写入流程](./write_follower.webp) -
图 4 TDengine Slave 写入流程
+
图 4 TDengine Follower 写入流程
-1. slave vnode 收到 Master vnode 转发了的数据插入请求。检查 last version 是否与 master 一致,如果一致,进入下一步。如果不一致,需要进入同步状态。 -2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 +1. follower vnode 收到 leader vnode 转发了的数据插入请求。 +2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 3. 写入内存,更新内存中的 skip list。 -与 master vnode 相比,slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 +与 leader vnode 相比,follower vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 ### 主从选择 Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 -一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: +一个 vnode 启动时,角色(leader、follower)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,按照标准的 raft 一致性算法完成选主。 -1. 如果只有一个副本,该副本永远就是 master -2. 所有副本都在线时,版本最高的被选为 master -3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master -4. 对于 2 和 3,如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master - -更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。 +更多的关于数据复制的流程,请见[《TDengine 3.0 数据复制模块设计》](/tdinternal/replica/)。 ### 同步复制 -对于数据一致性要求更高的场景,异步数据复制无法满足要求,因为有极小的概率丢失数据,因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 quorum。如果 quorum 大于 1,它表示每次 master 转发给副本时,需要等待 quorum-1 个回复确认,才能通知应用,数据在 slave 已经写入成功。如果在一定的时间内,得不到 quorum-1 个回复确认,master vnode 将返回错误给应用。 +对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 strict。如果 strict 等于 1,它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内,得不到半数以上副本的确认,leader vnode 将返回错误给应用。 采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致,mnode 之间的数据同步缺省就是采用的同步复制。 ## 缓存与持久化 -### 缓存 +### 时序数据缓存 TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心的是刚产生的数据,即当前状态。TDengine 充分利用这一特性,将最近到达的(当前状态)数据保存在缓存中。 TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署 Redis 或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 -每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存块的个数由配置参数 blocks 决定,内存块的大小由配置参数 cache 决定。 +每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存大小由配置参数 buffer 决定。 ### 持久化存储 diff --git a/docs/zh/21-tdinternal/message.webp b/docs/zh/21-tdinternal/message.webp index a2a42abff3..4a5f5f86f3 100644 Binary files a/docs/zh/21-tdinternal/message.webp and b/docs/zh/21-tdinternal/message.webp differ diff --git a/docs/zh/21-tdinternal/structure.webp b/docs/zh/21-tdinternal/structure.webp index b77a42c074..ee7a799975 100644 Binary files a/docs/zh/21-tdinternal/structure.webp and b/docs/zh/21-tdinternal/structure.webp differ diff --git a/docs/zh/21-tdinternal/write_follower.webp b/docs/zh/21-tdinternal/write_follower.webp new file mode 100644 index 0000000000..1ca537cd60 Binary files /dev/null and b/docs/zh/21-tdinternal/write_follower.webp differ diff --git a/docs/zh/21-tdinternal/write_leader.webp b/docs/zh/21-tdinternal/write_leader.webp new file mode 100644 index 0000000000..1771961b97 Binary files /dev/null and b/docs/zh/21-tdinternal/write_leader.webp differ diff --git a/docs/zh/21-tdinternal/write_master.webp b/docs/zh/21-tdinternal/write_master.webp deleted file mode 100644 index 9624036ed3..0000000000 Binary files a/docs/zh/21-tdinternal/write_master.webp and /dev/null differ diff --git a/docs/zh/21-tdinternal/write_slave.webp b/docs/zh/21-tdinternal/write_slave.webp deleted file mode 100644 index 7c45dec11b..0000000000 Binary files a/docs/zh/21-tdinternal/write_slave.webp and /dev/null differ diff --git a/include/common/tglobal.h b/include/common/tglobal.h index c07f422557..57d1199e17 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -89,7 +89,6 @@ extern uint16_t tsTelemPort; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node -extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked // query client extern int32_t tsQueryPolicy; diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index ab1c00a694..240415b66b 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -55,7 +55,6 @@ enum { TASK_INPUT_STATUS__NORMAL = 1, TASK_INPUT_STATUS__BLOCKED, TASK_INPUT_STATUS__RECOVER, - TASK_INPUT_STATUS__PROCESSING, TASK_INPUT_STATUS__STOP, TASK_INPUT_STATUS__FAILED, }; @@ -320,17 +319,6 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask); void tFreeSStreamTask(SStreamTask* pTask); static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem* pItem) { -#if 0 - while (1) { - int8_t inputStatus = - atomic_val_compare_exchange_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL, TASK_INPUT_STATUS__PROCESSING); - if (inputStatus == TASK_INPUT_STATUS__NORMAL) { - break; - } - ASSERT(0); - } -#endif - if (pItem->type == STREAM_INPUT__DATA_SUBMIT) { SStreamDataSubmit* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit*)pItem); if (pSubmitClone == NULL) { @@ -443,13 +431,14 @@ typedef struct { typedef struct { int64_t streamId; int32_t taskId; - int32_t sourceTaskId; - int32_t sourceVg; + int32_t upstreamTaskId; + int32_t upstreamNodeId; } SStreamTaskRecoverReq; typedef struct { int64_t streamId; - int32_t taskId; + int32_t rspTaskId; + int32_t reqTaskId; int8_t inputStatus; } SStreamTaskRecoverRsp; diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index d767b3521e..aec8a1f73e 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -210,7 +210,7 @@ SyncGroupId syncGetVgId(int64_t rid); void syncGetEpSet(int64_t rid, SEpSet* pEpSet); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); bool syncEnvIsStart(); const char* syncStr(ESyncState state); bool syncIsRestoreFinish(int64_t rid); diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index 7e95623740..cd2c2d4a4f 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -238,7 +238,7 @@ typedef struct SyncClientRequestBatch { char data[]; // block2, block3 } SyncClientRequestBatch; -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId); void syncClientRequestBatch2RpcMsg(const SyncClientRequestBatch* pSyncMsg, SRpcMsg* pRpcMsg); void syncClientRequestBatchDestroy(SyncClientRequestBatch* pMsg); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 3493cbb3a3..da2f58307d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -555,6 +555,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F) #define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660) #define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661) +#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index 64f30b8465..0f9e836ae2 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -1,6 +1,7 @@ @echo off goto %1 :needAdmin -mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&goto :eof +mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&& echo To start/stop TDengine with administrator privileges: sc start/stop taosd &goto :eof :hasAdmin -cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 \ No newline at end of file +cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 +sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 129e20e5de..f52edbe71f 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -20,11 +20,6 @@ target_link_libraries( ) if(TD_WINDOWS) - set_target_properties(taos - PROPERTIES - LINK_FLAGS - /DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/taos.def - ) INCLUDE_DIRECTORIES(jni/windows) INCLUDE_DIRECTORIES(jni/windows/win32) INCLUDE_DIRECTORIES(jni/windows/win32/bridge) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index b4c0fd380e..2831e7a904 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -225,9 +225,9 @@ typedef struct SRequestObj { SArray* targetTableList; SQueryExecMetric metric; SRequestSendRecvBody body; - bool syncQuery; // todo refactor: async query object - bool stableQuery; // todo refactor - bool validateOnly; // todo refactor + bool syncQuery; // todo refactor: async query object + bool stableQuery; // todo refactor + bool validateOnly; // todo refactor bool killed; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t retry; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 6a583842d1..3d6cf1c626 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -353,6 +353,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { desc.subDesc = NULL; desc.subPlanNum = 0; } + ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc)); } else { desc.subDesc = NULL; } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 68f47ba915..6f8e7d0237 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -591,7 +591,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray return code; } -void freeVgList(void *list) { +void freeVgList(void* list) { SArray* pList = *(SArray**)list; taosArrayDestroy(pList); } @@ -1278,8 +1278,8 @@ int32_t doProcessMsgFromServer(void* param) { char tbuf[40] = {0}; TRACE_TO_STR(trace, tbuf); - tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), - tbuf); + tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, + TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), tbuf); if (pSendInfo->requestObjRefId != 0) { SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId); @@ -2114,7 +2114,7 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { return NULL; } - TAOS_RES* pRes = execQuery(connId, sql, sqlLen, validateOnly); + TAOS_RES* pRes = execQuery(*(int64_t*)taos, sql, sqlLen, validateOnly); return pRes; #endif } diff --git a/source/client/src/taos.def b/source/client/src/taos.def deleted file mode 100644 index 994dd75090..0000000000 --- a/source/client/src/taos.def +++ /dev/null @@ -1,81 +0,0 @@ -taos_cleanup -taos_options -taos_set_config -taos_init -taos_connect -taos_connect_l -taos_connect_auth -taos_close -taos_data_type -taos_stmt_init -taos_stmt_prepare -taos_stmt_set_tbname_tags -taos_stmt_set_tbname -taos_stmt_set_sub_tbname -taos_stmt_is_insert -taos_stmt_num_params -taos_stmt_get_param -taos_stmt_bind_param -taos_stmt_bind_param_batch -taos_stmt_bind_single_param_batch -taos_stmt_add_batch -taos_stmt_execute -taos_stmt_use_result -taos_stmt_close -taos_stmt_errstr -taos_stmt_affected_rows -taos_stmt_affected_rows_once -taos_query -taos_query_l -taos_fetch_row -taos_result_precision -taos_free_result -taos_field_count -taos_num_fields -taos_affected_rows -taos_fetch_fields -taos_select_db -taos_print_row -taos_stop_query -taos_is_null -taos_is_update_query -taos_fetch_block -taos_fetch_block_s -taos_fetch_raw_block -taos_get_column_data_offset -taos_validate_sql -taos_reset_current_db -taos_fetch_lengths -taos_result_block -taos_get_server_info -taos_get_client_info -taos_errstr -taos_errno -taos_query_a -taos_fetch_rows_a -taos_subscribe -taos_consume -taos_unsubscribe -taos_load_table_info -taos_schemaless_insert -tmq_list_new -tmq_list_append -tmq_list_destroy -tmq_list_get_size -tmq_list_to_c_array -tmq_consumer_new -tmq_err2str -tmq_subscribe -tmq_unsubscribe -tmq_subscription -tmq_consumer_poll -tmq_consumer_close -tmq_commit -tmq_conf_new -tmq_conf_set -tmq_conf_destroy -tmq_conf_set_offset_commit_cb -tmq_get_topic_name -tmq_get_vgroup_id -tmq_create_stream -taos_check_server_status \ No newline at end of file diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 5d1610b9b6..7d07946dc9 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -257,14 +257,13 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)}, {TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)}, {TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)}, - {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, - {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, +// {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)}, +// {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)}, {TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)}, {TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)}, {TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)}, {TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)}, {TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)}, - {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)}, {TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)}, {TSDB_INS_TABLE_USER_TAGS, userTagsSchema, tListLen(userTagsSchema)}, // {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index e516bddac1..faee6cc2fa 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1713,7 +1713,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; - printf("%s |block type %d |child id %d|group id %zX\n", flag, (int32_t)pDataBlock->info.type, + printf("%s |block type %d |child id %d|group id %" PRIu64 "\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); for (int32_t j = 0; j < rows; j++) { printf("%s |", flag); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index ce09b83fae..0cc4e31aed 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -124,9 +124,6 @@ int32_t tsMinIntervalTime = 1; int32_t tsQueryBufferSize = -1; int64_t tsQueryBufferSizeBytes = -1; -// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing. -bool tsRetrieveBlockingModel = false; - // tsdb config // For backward compatibility bool tsdbForceKeepFile = false; @@ -296,6 +293,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "metaDebugFlag", metaDebugFlag, 0, 255, 0) != 0) return -1; return 0; } @@ -362,7 +360,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1; if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1; - if (cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0) != 0) return -1; if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1; if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1; @@ -476,6 +473,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) { smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; + metaDebugFlag = cfgGetItem(pCfg, "metaDebugFlag")->i32; } static int32_t taosSetClientCfg(SConfig *pCfg) { @@ -547,7 +545,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; - tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; @@ -832,9 +829,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { break; } case 'r': { - if (strcasecmp("retrieveBlockingModel", name) == 0) { - tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval; - } else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { + if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; } else if (strcasecmp("rpcDebugFlag", name) == 0) { rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; @@ -1100,12 +1095,12 @@ void taosCfgDynamicOptions(const char *option, const char *value) { const char *options[] = { "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", - "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", }; int32_t *optionVars[] = { &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, - &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, + &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag, }; int32_t optionSize = tListLen(options); @@ -1152,5 +1147,6 @@ void taosSetAllDebugFlag(int32_t flag) { taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag); + taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag); uInfo("all debug flag are set to %d", flag); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 3163982dec..05b27546eb 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -305,6 +305,8 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq) taosArrayPush(desc.subDesc, &sDesc); } } + + ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc)); taosArrayPush(pReq->query->queryDesc, &desc); } diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 581686ba90..45bef7f98e 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -14,4 +14,7 @@ target_include_directories( taosd PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () target_link_libraries(taosd dnode) diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 013cc05c65..34c3b40556 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -27,6 +27,9 @@ #define DM_VERSION "Print program version." #define DM_EMAIL "" static struct { +#ifdef WINDOWS + bool winServiceMode; +#endif bool dumpConfig; bool generateGrant; bool printAuth; @@ -93,6 +96,10 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { global.dumpConfig = true; } else if (strcmp(argv[i], "-V") == 0) { global.printVersion = true; + #ifdef WINDOWS + } else if (strcmp(argv[i], "--win_service") == 0) { + global.winServiceMode = true; + #endif } else if (strcmp(argv[i], "-e") == 0) { global.envCmd[cmdEnvIndex] = argv[++i]; cmdEnvIndex++; @@ -169,6 +176,18 @@ int main(int argc, char const *argv[]) { return -1; } +#ifdef WINDOWS + int mainWindows(int argc,char** argv); + if (global.winServiceMode) { + stratWindowsService(mainWindows); + } else { + return mainWindows(argc, argv); + } + return 0; +} +int mainWindows(int argc,char** argv) { +#endif + if (global.generateGrant) { dmGenerateGrant(); taosCleanupArgs(); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 3f90f087fd..fc5e20ef28 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -788,9 +788,9 @@ _OVER: static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; const char *options[] = { - "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", - "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", - "tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", + "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tmrDebugFlag", + "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", }; int32_t optionSize = tListLen(options); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 0a5fe1001c..352fb51a53 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -179,7 +179,7 @@ static int32_t sndProcessTaskRecoverRsp(SSnode *pNode, SRpcMsg *pMsg) { SStreamMeta *pMeta = pNode->pMeta; SStreamTaskRecoverRsp *pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask *pTask = *(SStreamTask **)taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); streamProcessRecoverRsp(pTask, pRsp); return 0; diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 85261d302e..46609cf561 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -145,6 +145,8 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr pWriter->sver = sver; pWriter->ever = ever; + metaBegin(pMeta); + *ppWriter = pWriter; return code; diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 4b29b13abd..3505711cd0 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -599,14 +599,14 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche SSubmitReq *pReq = NULL; // TODO: the schema update should be handled if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { - smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), + smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) { taosMemoryFreeClear(pReq); - smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", + smaError("vgId:%d, process submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c new file mode 100644 index 0000000000..21dfd8a32d --- /dev/null +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "sma.h" + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData); +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); + +// SRsmaSnapReader ======================================== +struct SRsmaSnapReader { + SSma* pSma; + int64_t sver; + int64_t ever; + + // for data file + int8_t rsmaDataDone[TSDB_RETENTION_L2]; + STsdbSnapReader* pDataReader[TSDB_RETENTION_L2]; + + // for qtaskinfo file + int8_t qTaskDone; + SQTaskFReader* pQTaskFReader; +}; + +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = NULL; + + // alloc + pReader = (SRsmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + if (pReader == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pReader->pSma = pSma; + pReader->sver = sver; + pReader->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, &pReader->pDataReader[i]); + if (code < 0) { + goto _err; + } + } + } + *ppReader = pReader; + smaInfo("vgId:%d vnode snapshot rsma reader opened succeed", SMA_VID(pSma)); + return TSDB_CODE_SUCCESS; +_err: + smaError("vgId:%d vnode snapshot rsma reader opened failed since %s", SMA_VID(pSma), tstrerror(code)); + return TSDB_CODE_FAILED; +} + +static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + SSma* pSma = pReader->pSma; + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read qtaskinfo succeed", SMA_VID(pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read qtaskinfo failed since %s", SMA_VID(pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + + *ppData = NULL; + + smaInfo("vgId:%d vnode snapshot rsma read entry", SMA_VID(pReader->pSma)); + // read rsma1/rsma2 file + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + STsdbSnapReader* pTsdbSnapReader = pReader->pDataReader[i]; + if (!pTsdbSnapReader) { + continue; + } + if (!pReader->rsmaDataDone[i]) { + smaInfo("vgId:%d vnode snapshot rsma read level %d not done", SMA_VID(pReader->pSma), i); + code = tsdbSnapRead(pTsdbSnapReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->rsmaDataDone[i] = 1; + } + } + } else { + smaInfo("vgId:%d vnode snapshot rsma read level %d is done", SMA_VID(pReader->pSma), i); + } + } + + // read qtaskinfo file + if (!pReader->qTaskDone) { + code = rsmaSnapReadQTaskInfo(pReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->qTaskDone = 1; + } + } + } + +_exit: + smaInfo("vgId:%d vnode snapshot rsma read succeed", SMA_VID(pReader->pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma read failed since %s", SMA_VID(pReader->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { + int32_t code = 0; + SRsmaSnapReader* pReader = *ppReader; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pReader->pDataReader[i]) { + tsdbSnapReaderClose(&pReader->pDataReader[i]); + } + } + + if (pReader->pQTaskFReader) { + // TODO: close for qtaskinfo + smaInfo("vgId:%d vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma)); + } + + + smaInfo("vgId:%d vnode snapshot rsma reader closed", SMA_VID(pReader->pSma)); + + taosMemoryFreeClear(*ppReader); + return code; +} + +// SRsmaSnapWriter ======================================== +struct SRsmaSnapWriter { + SSma* pSma; + int64_t sver; + int64_t ever; + + // config + int64_t commitID; + + // for data file + STsdbSnapWriter* pDataWriter[TSDB_RETENTION_L2]; + + // for qtaskinfo file + SQTaskFReader* pQTaskFReader; + SQTaskFWriter* pQTaskFWriter; +}; + +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = NULL; + + // alloc + pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pSma = pSma; + pWriter->sver = sver; + pWriter->ever = ever; + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pSma->pRSmaTsdb[i]) { + code = tsdbSnapWriterOpen(pSma->pRSmaTsdb[i], sver, ever, &pWriter->pDataWriter[i]); + if (code < 0) { + goto _err; + } + } + } + + // qtaskinfo + // TODO + + *ppWriter = pWriter; + + smaInfo("vgId:%d rsma snapshot writer open succeed", TD_VID(pSma->pVnode)); + return code; + +_err: + smaError("vgId:%d rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code)); + *ppWriter = NULL; + return code; +} + +int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) { + int32_t code = 0; + SRsmaSnapWriter* pWriter = *ppWriter; + + if (rollback) { + ASSERT(0); + // code = tsdbFSRollback(pWriter->pTsdb->pFS); + // if (code) goto _err; + } else { + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (pWriter->pDataWriter[i]) { + code = tsdbSnapWriterClose(&pWriter->pDataWriter[i], rollback); + if (code) goto _err; + } + } + } + + taosMemoryFree(pWriter); + *ppWriter = NULL; + + smaInfo("vgId:%d vnode snapshot rsma writer close succeed", SMA_VID(pWriter->pSma)); + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma writer close failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} + +int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; + + // rsma1/rsma2 + if (pHdr->type == SNAP_DATA_RSMA1) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[0], pData, nData); + } else if (pHdr->type == SNAP_DATA_RSMA2) { + pHdr->type = SNAP_DATA_TSDB; + code = tsdbSnapWrite(pWriter->pDataWriter[1], pData, nData); + } else if (pHdr->type == SNAP_DATA_QTASK) { + code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData); + } + if (code < 0) goto _err; + +_exit: + smaInfo("vgId:%d rsma snapshot write for data %" PRIi8 " succeed", SMA_VID(pWriter->pSma), pHdr->type); + return code; + +_err: + smaError("vgId:%d rsma snapshot write for data %" PRIi8 " failed since %s", SMA_VID(pWriter->pSma), pHdr->type, + tstrerror(code)); + return code; +} + +static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + + if (pWriter->pQTaskFWriter == NULL) { + // SDelFile* pDelFile = pWriter->fs.pDelFile; + + // // reader + // if (pDelFile) { + // code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb, NULL); + // if (code) goto _err; + + // code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR, NULL); + // if (code) goto _err; + // } + + // // writer + // SDelFile delFile = {.commitID = pWriter->commitID, .offset = 0, .size = 0}; + // code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb); + // if (code) goto _err; + } + smaInfo("vgId:%d vnode snapshot rsma write qtaskinfo succeed", SMA_VID(pWriter->pSma)); +_exit: + return code; + +_err: + smaError("vgId:%d vnode snapshot rsma write qtaskinfo failed since %s", SMA_VID(pWriter->pSma), tstrerror(code)); + return code; +} diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 6b0e3944e3..364ecbab61 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -796,7 +796,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverRsp* pRsp = pMsg->pCont; - int32_t taskId = pRsp->taskId; + int32_t taskId = pRsp->rspTaskId; SStreamTask** ppTask = (SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); if (ppTask) { streamProcessRecoverRsp(*ppTask, pRsp); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 4e6a450d35..f03b02af27 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -175,7 +175,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST cacheRow = (STSRow *)taosLRUCacheValue(pCache, h); if (row->ts >= cacheRow->ts) { if (row->ts == cacheRow->ts) { - STSRow *mergedRow; + STSRow *mergedRow = NULL; SRowMerger merger = {0}; STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index fa775bb882..50d7de3e11 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -374,11 +374,12 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid p = taosArrayInsert(pMemTable->aTbData, idx, &pTbData); taosWUnLockLatch(&pMemTable->latch); + tsdbDebug("vgId:%d add table data %p at idx:%d", TD_VID(pMemTable->pTsdb->pVnode), pTbData, idx); + if (p == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - _exit: *ppTbData = pTbData; return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 43537c9a8d..51d7edcf71 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -694,8 +694,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { if (pWriter->bDataW.nRow < pWriter->maxRow * 4 / 5) continue; _write_block: - code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdx, &pWriter->blockW, - pWriter->cmprAlg); + code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW, + &pWriter->blockW, pWriter->cmprAlg); if (code) goto _err; code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); @@ -756,7 +756,7 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) { if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) { ASSERT(pWriter->pDataFReader); - SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlock); + SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx); int32_t c = tTABLEIDCmprFn(pBlockIdx, &id); ASSERT(c >= 0); @@ -833,7 +833,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) { } _exit: - tsdbError("vgId:%d vnode snapshot tsdb writer data end", TD_VID(pTsdb->pVnode)); + tsdbInfo("vgId:%d vnode snapshot tsdb writer data end", TD_VID(pTsdb->pVnode)); return code; _err: diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 1207df8058..e8d029a88f 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -288,7 +288,7 @@ int vnodeCommit(SVnode *pVnode) { // apply the commit (TODO) walEndSnapshot(pVnode->pWal); - vInfo("vgId:%d, commit over", TD_VID(pVnode)); + vInfo("vgId:%d, commit end", TD_VID(pVnode)); return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 7241ca4971..3f8f81cb09 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -180,6 +180,7 @@ struct SVSnapWriter { SVnode *pVnode; int64_t sver; int64_t ever; + int64_t commitID; int64_t index; // meta SMetaSnapWriter *pMetaSnapWriter; @@ -201,7 +202,16 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr pWriter->sver = sver; pWriter->ever = ever; - vInfo("vgId:%d vnode snapshot writer opened", TD_VID(pVnode)); + // commit it + code = vnodeCommit(pVnode); + if (code) goto _err; + + // inc commit ID + pVnode->state.commitID++; + pWriter->commitID = pVnode->state.commitID; + + vInfo("vgId:%d vnode snapshot writer opened, sver:%" PRId64 " ever:%" PRId64 " commit id:%" PRId64, TD_VID(pVnode), + sver, ever, pWriter->commitID); *ppWriter = pWriter; return code; @@ -244,6 +254,8 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * code = vnodeCommitInfo(dir, &info); if (code) goto _err; + + vnodeBegin(pVnode); } else { ASSERT(0); } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index a0e5071685..98e1716d9c 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -413,7 +413,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { SyncClientRequestBatch *pSyncMsg = syncClientRequestBatchFromRpcMsg(pMsg); ASSERT(pSyncMsg != NULL); code = syncNodeOnClientRequestBatchCb(pSyncNode, pSyncMsg); - syncClientRequestBatchDestroyDeep(pSyncMsg); + syncClientRequestBatchDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); ASSERT(pSyncMsg != NULL); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index d5486d62b1..a80c2c2fea 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -318,6 +318,7 @@ typedef struct STableScanInfo { int32_t currentTable; int8_t scanMode; int8_t noTable; + int8_t assignBlockUid; } STableScanInfo; typedef struct STableMergeScanInfo { diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 1618bffb09..171f39db1b 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -251,19 +251,39 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } } + bool assignUid = false; + + if (LIST_LENGTH(pScanInfo->pGroupTags) > 0) { + SNode* p = nodesListGetNode(pScanInfo->pGroupTags, 0); + if (p->type == QUERY_NODE_FUNCTION) { + // partition by tbname/group by tbname + assignUid = (strcmp(((struct SFunctionNode*)p)->functionName, "tbname") == 0); + } + } + for (int32_t i = 0; i < taosArrayGetSize(qa); ++i) { uint64_t* uid = taosArrayGet(qa, i); STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0}; if (bufLen > 0) { - code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf, - &keyInfo.groupId); - if (code != TSDB_CODE_SUCCESS) { - return code; + if (assignUid) { + keyInfo.groupId = keyInfo.uid; + } else { + code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf, + &keyInfo.groupId); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &keyInfo); + if (pTaskInfo->tableqinfoList.map == NULL) { + pTaskInfo->tableqinfoList.map = + taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + } + + taosHashPut(pTaskInfo->tableqinfoList.map, uid, sizeof(uid), &keyInfo.groupId, sizeof(keyInfo.groupId)); } if (keyBuf != NULL) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index f07256e88e..4a2f57d628 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -408,6 +408,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { pBlock->info.groupId = *groupId; } + if (pTableScanInfo->assignBlockUid) { + pBlock->info.groupId = pBlock->info.uid; + } + pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows; pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; @@ -616,6 +620,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->scanFlag = MAIN_SCAN; pInfo->pColMatchInfo = pColList; pInfo->currentGroupId = -1; + pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pOperator->name = "TableScanOperator"; // for debug purpose pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index ed1580ed91..400940245d 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1091,6 +1091,8 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true); + blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex); + hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL); } @@ -3138,6 +3140,26 @@ void destroyStreamAggSupporter(SStreamAggSupporter* pSup) { blockDataDestroy(pSup->pScanBlock); } +void destroyStateWinInfo(void* ptr) { + if (ptr == NULL) { + return; + } + SStateWindowInfo* pWin = (SStateWindowInfo*) ptr; + taosMemoryFreeClear(pWin->stateKey.pData); +} + +void destroyStateStreamAggSupporter(SStreamAggSupporter* pSup) { + taosMemoryFreeClear(pSup->pKeyBuf); + void** pIte = NULL; + while ((pIte = taosHashIterate(pSup->pResultRows, pIte)) != NULL) { + SArray* pWins = (SArray*)(*pIte); + taosArrayDestroyEx(pWins, (FDelete)destroyStateWinInfo); + } + taosHashCleanup(pSup->pResultRows); + destroyDiskbasedBuf(pSup->pResultBuf); + blockDataDestroy(pSup->pScanBlock); +} + void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) { SStreamSessionAggOperatorInfo* pInfo = (SStreamSessionAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); @@ -3605,12 +3627,17 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData } } -void deleteWindow(SArray* pWinInfos, int32_t index) { +void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) { ASSERT(index >= 0 && index < taosArrayGetSize(pWinInfos)); + if (fp) { + void* ptr = taosArrayGet(pWinInfos, index); + fp(ptr); + } taosArrayRemove(pWinInfos, index); } -static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, SArray* result) { +static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, + SArray* result, FDelete fp) { SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* startDatas = (TSKEY*)pStartTsCol->pData; SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); @@ -3624,7 +3651,7 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc if (!pCurWin) { break; } - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, fp); if (result) { taosArrayPush(result, pCurWin); } @@ -3749,7 +3776,7 @@ SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo* SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; } int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn, - bool delete) { + bool delete, FDelete fp) { // Todo(liuyao) save window to tdb void** pIte = NULL; size_t keyLen = 0; @@ -3771,7 +3798,7 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra pSeWin->isOutput = true; } if (delete) { - deleteWindow(pWins, i); + deleteWindow(pWins, i, fp); i--; size = taosArrayGetSize(pWins); } @@ -3784,13 +3811,13 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra return TSDB_CODE_SUCCESS; } -static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete) { +static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete, FDelete fp) { int32_t size = taosArrayGetSize(pChildren); for (int32_t i = 0; i < size; i++) { SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i); SStreamSessionAggOperatorInfo* pChInfo = pChildOp->info; pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); - closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete); + closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete, fp); } } @@ -3868,13 +3895,13 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); // gap must be 0 - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, NULL); if (IS_FINAL_OP(pInfo)) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info; // gap must be 0 - doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL); + doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL, NULL); rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator); } copyDeleteWindowInfo(pWins, pInfo->pStDeleted); @@ -3916,8 +3943,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession, - pInfo->ignoreExpiredData); - closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData); + pInfo->ignoreExpiredData, NULL); + closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, NULL); copyUpdateResult(pStUpdated, pUpdated); taosHashCleanup(pStUpdated); @@ -4012,7 +4039,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { break; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { // gap must be 0 - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL, NULL); copyDataBlock(pInfo->pDelRes, pBlock); pInfo->pDelRes->info.type = STREAM_DELETE_RESULT; break; @@ -4118,7 +4145,7 @@ _error: void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) { SStreamStateAggOperatorInfo* pInfo = (SStreamStateAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); - destroyStreamAggSupporter(&pInfo->streamAggSup); + destroyStateStreamAggSupporter(&pInfo->streamAggSup); cleanupGroupResInfo(&pInfo->groupResInfo); if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -4130,6 +4157,10 @@ void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChInfo); } } + colDataDestroy(&pInfo->twAggSup.timeWindowData); + blockDataDestroy(pInfo->pDelRes); + taosHashCleanup(pInfo->pSeDeleted); + destroySqlFunctionCtx(pInfo->pDummyCtx, 0); taosMemoryFreeClear(param); } @@ -4312,7 +4343,7 @@ static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc pSeDeleted); ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData)); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo); } } @@ -4355,7 +4386,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, &pSDataBlock->info.groupId); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); - deleteWindow(pAggSup->pCurWins, winIndex); + deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo); continue; } code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows, numOfOutput, pOperator); @@ -4413,7 +4444,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { continue; } else if (pBlock->info.type == STREAM_DELETE_DATA) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, destroyStateWinInfo); copyDeleteWindowInfo(pWins, pInfo->pSeDeleted); taosArrayDestroy(pWins); continue; @@ -4435,8 +4466,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState, - pInfo->ignoreExpiredData); - closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData); + pInfo->ignoreExpiredData, destroyStateWinInfo); + // closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, destroyStateWinInfo); copyUpdateResult(pSeUpdated, pUpdated); taosHashCleanup(pSeUpdated); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 01a5e7997e..40e26f6be6 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2068,7 +2068,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "apercentile", .type = FUNCTION_TYPE_APERCENTILE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateApercentile, .getEnvFunc = getApercentileFuncEnv, .initFunc = apercentileFunctionSetup, @@ -2083,7 +2083,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { }, { .name = "_apercentile_partial", - .type = FUNCTION_TYPE_APERCENTILE_PARTIAL, + .type = FUNCTION_TYPE_APERCENTILE_PARTIAL | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC, .translateFunc = translateApercentilePartial, .getEnvFunc = getApercentileFuncEnv, @@ -2096,7 +2096,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_apercentile_merge", .type = FUNCTION_TYPE_APERCENTILE_MERGE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateApercentileMerge, .getEnvFunc = getApercentileFuncEnv, .initFunc = apercentileFunctionSetup, @@ -2358,7 +2358,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "histogram", .type = FUNCTION_TYPE_HISTOGRAM, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, .translateFunc = translateHistogram, .getEnvFunc = getHistogramFuncEnv, .initFunc = histogramFunctionSetup, @@ -2373,7 +2373,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_histogram_partial", .type = FUNCTION_TYPE_HISTOGRAM_PARTIAL, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, .translateFunc = translateHistogramPartial, .getEnvFunc = getHistogramFuncEnv, .initFunc = histogramFunctionSetup, @@ -2385,7 +2385,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_histogram_merge", .type = FUNCTION_TYPE_HISTOGRAM_MERGE, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC, .translateFunc = translateHistogramMerge, .getEnvFunc = getHistogramFuncEnv, .initFunc = functionSetup, diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1c9c097cba..af3f0c242b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1522,6 +1522,7 @@ static const char* jkTableScanPhysiPlanWatermark = "Watermark"; static const char* jkTableScanPhysiPlanIgnoreExpired = "IgnoreExpired"; static const char* jkTableScanPhysiPlanGroupTags = "GroupTags"; static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; +static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1578,6 +1579,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanGroupSort, pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid); + } return code; } @@ -1637,6 +1641,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanGroupSort, &pNode->groupSort); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid); + } return code; } @@ -4525,7 +4532,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return jsonToPhysiScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: - return jsonToPhysiLastRowScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 5cba920a43..8e1243b558 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -34,6 +34,7 @@ typedef struct STranslateContext { SMsgBuf msgBuf; SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* int32_t currLevel; + int32_t levelNo; ESqlClause currClause; SNode* pCurrStmt; SCmdMsgInfo* pCmdMsg; @@ -354,6 +355,7 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, SParseMetaCache* p pCxt->msgBuf.len = pParseCxt->msgLen; pCxt->pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); pCxt->currLevel = 0; + pCxt->levelNo = 0; pCxt->currClause = 0; pCxt->pMetaCache = pMetaCache; pCxt->pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); @@ -1857,7 +1859,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta)); if (TSDB_CODE_SUCCESS != code) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); } code = setTableVgroupList(pCxt, &name, pRealTable); if (TSDB_CODE_SUCCESS == code) { @@ -4960,13 +4962,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { } static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { - ++(pCxt->currLevel); ESqlClause currClause = pCxt->currClause; SNode* pCurrStmt = pCxt->pCurrStmt; + int32_t currLevel = pCxt->currLevel; + pCxt->currLevel = ++(pCxt->levelNo); int32_t code = translateQuery(pCxt, pNode); - --(pCxt->currLevel); pCxt->currClause = currClause; pCxt->pCurrStmt = pCurrStmt; + pCxt->currLevel = currLevel; return code; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 79d6f3b8e8..e51800aece 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -31,6 +31,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid column name: %s"; case TSDB_CODE_PAR_TABLE_NOT_EXIST: return "Table does not exist: %s"; + case TSDB_CODE_PAR_GET_META_ERROR: + return "Fail to get table info, error: %s"; case TSDB_CODE_PAR_AMBIGUOUS_COLUMN: return "Column ambiguously defined: %s"; case TSDB_CODE_PAR_WRONG_VALUE_TYPE: diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 951ca5e40d..c91e09c825 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -341,11 +341,12 @@ TEST_F(ParserSelectTest, semanticCheck) { run("SELECT t1.c1, t1.cc1 FROM t1", TSDB_CODE_PAR_INVALID_COLUMN); + // TSDB_CODE_PAR_GET_META_ERROR + run("SELECT * FROM t10", TSDB_CODE_PAR_GET_META_ERROR); + + run("SELECT * FROM test.t10", TSDB_CODE_PAR_GET_META_ERROR); + // TSDB_CODE_PAR_TABLE_NOT_EXIST - run("SELECT * FROM t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); - - run("SELECT * FROM test.t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); - run("SELECT t2.c1 FROM t1", TSDB_CODE_PAR_TABLE_NOT_EXIST); // TSDB_CODE_PAR_AMBIGUOUS_COLUMN diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index d405b75003..a80509c165 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1229,6 +1229,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p // set columns to scan if (TSDB_CODE_SUCCESS == code) { pScan->scanType = SCAN_TYPE_TABLE; + pScan->scanRange = pDelete->timeRange; pScan->pScanCols = nodesCloneList(((SFunctionNode*)pDelete->pCountFunc)->pParameterList); if (NULL == pScan->pScanCols) { code = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index fcc395af62..98b0ce2007 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2271,7 +2271,7 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp FOREACH(pAggTarget, pAgg->pTargets) { SNode* pScanTarget = NULL; FOREACH(pScanTarget, pScanNode->node.pTargets) { - if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pAggTarget)->colName)) { + if (0 == strcmp(((SColumnNode*)pAggTarget)->colName, ((SColumnNode*)pScanTarget)->colName)) { nodesListAppend(pScanTargets, nodesCloneNode(pScanTarget)); break; } diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 50f8b91023..46140ccdff 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -916,7 +916,7 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq qDebug("job not initialized or not executable job, refId:0x%" PRIx64, pJob->refId); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - break; + return TSDB_CODE_SUCCESS; default: SCH_JOB_ELOG("unknown operation type %d", type); SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 67050241e3..3bec91226c 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -513,7 +513,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3 SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - msgSendInfo->paramFreeFp = taosMemoryFree; + msgSendInfo->paramFreeFp = taosMemoryFree; SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param)); SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp)); @@ -541,7 +541,7 @@ _return: } taosMemoryFree(msg); - + SCH_RET(code); } @@ -681,7 +681,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { param->pTrans = pJob->conn.pTrans; pMsgSendInfo->param = param; - pMsgSendInfo->paramFreeFp = taosMemoryFree; + pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->fp = fp; SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo}; @@ -801,7 +801,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { pDst->param = NULL; SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param)); - pDst->paramFreeFp = taosMemoryFree; + pDst->paramFreeFp = taosMemoryFree; *dst = pDst; @@ -1094,14 +1094,29 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, break; } +#if 1 SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL)); msg = NULL; SCH_ERR_JRET(code); - + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) { SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId)); } +#else + if (TDMT_VND_SUBMIT != msgType) { + SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; + schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL)); + msg = NULL; + SCH_ERR_JRET(code); + + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) { + SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId)); + } + } else { + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + } +#endif return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index c40e56ab6f..025891a26c 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -168,20 +168,20 @@ int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, v return TSDB_CODE_SUCCESS; } -// Note: no more task error processing, handled in function internal int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) { if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) { return TSDB_CODE_SCH_IGNORE_ERROR; } - int8_t status = 0; - if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(status)); + int8_t jobStatus = 0; + if (schJobNeedToStop(pJob, &jobStatus)) { + SCH_TASK_DLOG("no more task failure processing cause of job status %s", jobTaskStatusStr(jobStatus)); SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR); } - if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXEC) { - SCH_TASK_ELOG("task already not in EXEC status, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); + int8_t taskStatus = SCH_GET_TASK_STATUS(pTask); + if (taskStatus == JOB_TASK_STATUS_FAIL || taskStatus == JOB_TASK_STATUS_SUCC) { + SCH_TASK_ELOG("task already done, status:%s", jobTaskStatusStr(taskStatus)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } diff --git a/source/libs/stream/inc/streamInc.h b/source/libs/stream/inc/streamInc.h index 06bd6539fd..1ff27f1253 100644 --- a/source/libs/stream/inc/streamInc.h +++ b/source/libs/stream/inc/streamInc.h @@ -32,10 +32,10 @@ typedef struct { static SStreamGlobalEnv streamEnv; -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamExec(SStreamTask* pTask); int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum); -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb); +int32_t streamDispatch(SStreamTask* pTask); int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData); int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* data); diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 8c9e8ca2db..31da865a69 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -189,7 +189,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S #if 0 if (pTask->execType != TASK_EXEC__NONE) { #endif - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); #if 0 } else { ASSERT(pTask->sinkType != TASK_SINK__NONE); @@ -208,7 +208,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S // 3.2 dispatch / sink if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; @@ -233,26 +233,55 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) { return 0; } // continue dispatch - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } int32_t streamProcessRunReq(SStreamTask* pTask) { - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); if (pTask->dispatchType != TASK_DISPATCH__NONE) { - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } return 0; } -int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg) { - // +int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pRsp) { + void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp)); + ((SMsgHead*)buf)->vgId = htonl(pReq->upstreamNodeId); + + SStreamTaskRecoverRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); + pCont->inputStatus = pTask->inputStatus; + pCont->streamId = pTask->streamId; + pCont->reqTaskId = pTask->taskId; + pCont->rspTaskId = pReq->upstreamTaskId; + + pRsp->pCont = buf; + pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamTaskRecoverRsp); + tmsgSendRsp(pRsp); return 0; } int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp) { - // + if (pRsp->inputStatus == TASK_INPUT_STATUS__NORMAL) { + pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; + + streamProcessRunReq(pTask); + + if (pTask->isDataScan) { + // scan data to recover + pTask->inputStatus = TASK_INPUT_STATUS__RECOVER; + pTask->taskStatus = TASK_STATUS__RECOVERING; + qStreamPrepareRecover(pTask->exec.executor, pTask->startVer, pTask->recoverSnapVer); + if (streamPipelineExec(pTask, 100) < 0) { + return -1; + } + } else { + pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; + pTask->taskStatus = TASK_STATUS__NORMAL; + } + } + return 0; } @@ -262,10 +291,10 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S streamTaskEnqueueRetrieve(pTask, pReq, pRsp); ASSERT(pTask->execType != TASK_EXEC__NONE); - streamExec(pTask, pTask->pMsgCb); + streamExec(pTask); ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); return 0; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 834a3af0d5..ec1dd693e1 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -438,7 +438,7 @@ FAIL: return code; } -int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamDispatch(SStreamTask* pTask) { ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); #if 1 int8_t old = diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 7c5cd6e391..196dbd6dc3 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -141,7 +141,7 @@ int32_t streamPipelineExec(SStreamTask* pTask, int32_t batchNum) { if (pTask->dispatchType != TASK_DISPATCH__NONE) { ASSERT(pTask->sinkType == TASK_SINK__NONE); - streamDispatch(pTask, pTask->pMsgCb); + streamDispatch(pTask); } } @@ -229,7 +229,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { } // TODO: handle version -int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { +int32_t streamExec(SStreamTask* pTask) { SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); if (pRes == NULL) return -1; while (1) { diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamRecover.c index 87b27daf60..dec23cd151 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamRecover.c @@ -19,8 +19,8 @@ int32_t tEncodeStreamTaskRecoverReq(SEncoder* pEncoder, const SStreamTaskRecover if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceTaskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceVg) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; } @@ -29,8 +29,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceTaskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceVg) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1; tEndDecode(pDecoder); return 0; } @@ -38,7 +38,8 @@ int32_t tDecodeStreamTaskRecoverReq(SDecoder* pDecoder, SStreamTaskRecoverReq* p int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecoverRsp* pRsp) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; - if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->reqTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->rspTaskId) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->inputStatus) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; @@ -47,7 +48,8 @@ int32_t tEncodeStreamTaskRecoverRsp(SEncoder* pEncoder, const SStreamTaskRecover int32_t tDecodeStreamTaskRecoverRsp(SDecoder* pDecoder, SStreamTaskRecoverRsp* pReq) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->reqTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->rspTaskId) < 0) return -1; if (tDecodeI8(pDecoder, &pReq->inputStatus) < 0) return -1; tEndDecode(pDecoder); return 0; @@ -125,7 +127,7 @@ int32_t streamProcessFailRecoverReq(SStreamTask* pTask, SMStreamTaskRecoverReq* } if (pTask->taskStatus == TASK_STATUS__RECOVERING) { - if (streamPipelineExec(pTask, 10) < 0) { + if (streamPipelineExec(pTask, 100) < 0) { // set fail return -1; } diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index b802d94bea..586cfc0f15 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -170,7 +170,7 @@ void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize); +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index ceca201506..2c64728998 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -677,7 +677,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { return ret; } -int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { +int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { if (arrSize < 0) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; return -1; @@ -690,18 +690,18 @@ int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_ } ASSERT(rid == pSyncNode->rid); - int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgArr, pIsWeakArr, arrSize); + int32_t ret = syncNodeProposeBatch(pSyncNode, pMsgPArr, pIsWeakArr, arrSize); taosReleaseRef(tsNodeRefId, pSyncNode->rid); return ret; } -static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { +static bool syncNodeBatchOK(SRpcMsg** pMsgPArr, int32_t arrSize) { for (int32_t i = 0; i < arrSize; ++i) { - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE) { return false; } - if (pMsgArr[i].msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { + if (pMsgPArr[i]->msgType == TDMT_SYNC_CONFIG_CHANGE_FINISH) { return false; } } @@ -709,8 +709,8 @@ static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) { return true; } -int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_t arrSize) { - if (!syncNodeBatchOK(pMsgArr, arrSize)) { +int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize) { + if (!syncNodeBatchOK(pMsgPArr, arrSize)) { syncNodeErrorLog(pSyncNode, "sync propose batch error"); terrno = TSDB_CODE_SYN_BATCH_ERROR; return -1; @@ -736,16 +736,23 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRaftMeta raftArr[SYNC_MAX_BATCH_SIZE]; for (int i = 0; i < arrSize; ++i) { + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d, batch:%d", TMSG_INFO(pMsgPArr[i]->msgType), + pMsgPArr[i]->msgType, arrSize); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); + SRespStub stub; stub.createTime = taosGetTimestampMs(); - stub.rpcMsg = pMsgArr[i]; + stub.rpcMsg = *(pMsgPArr[i]); uint64_t seqNum = syncRespMgrAdd(pSyncNode->pSyncRespMgr, &stub); raftArr[i].isWeak = pIsWeakArr[i]; raftArr[i].seqNum = seqNum; } - SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgArr, raftArr, arrSize, pSyncNode->vgId); + SyncClientRequestBatch* pSyncMsg = syncClientRequestBatchBuild(pMsgPArr, raftArr, arrSize, pSyncNode->vgId); ASSERT(pSyncMsg != NULL); SRpcMsg rpcMsg; @@ -759,7 +766,7 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe SRpcMsg* msgArr = syncClientRequestBatchRpcMsgArr(pSyncMsg); ASSERT(arrSize == pSyncMsg->dataCount); for (int i = 0; i < arrSize; ++i) { - pMsgArr[i].info.conn.applyIndex = msgArr[i].info.conn.applyIndex; + pMsgPArr[i]->info.conn.applyIndex = msgArr[i].info.conn.applyIndex; syncRespMgrDel(pSyncNode->pSyncRespMgr, raftArr[i].seqNum); } @@ -790,9 +797,11 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { int32_t ret = 0; - char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); - syncNodeEventLog(pSyncNode, eventLog); + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "propose type:%s,%d", TMSG_INFO(pMsg->msgType), pMsg->msgType); + syncNodeEventLog(pSyncNode, eventLog); + } while (0); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { if (pSyncNode->changing && pMsg->msgType != TDMT_SYNC_CONFIG_CHANGE_FINISH) { @@ -860,7 +869,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { } else { ret = -1; terrno = TSDB_CODE_SYN_NOT_LEADER; - sError("vgId:%d, sync propose not leader, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state)); + sError("vgId:%d, sync propose not leader, %s, msgtype:%s,%d", pSyncNode->vgId, + syncUtilState2String(pSyncNode->state), TMSG_INFO(pMsg->msgType), pMsg->msgType); goto _END; } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 42a3290d5b..13adaf055c 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -963,9 +963,9 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { // block2: SRaftMeta array // block3: rpc msg array (with pCont) -SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMeta* raftArr, int32_t arrSize, +SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg** rpcMsgPArr, SRaftMeta* raftArr, int32_t arrSize, int32_t vgId) { - ASSERT(rpcMsgArr != NULL); + ASSERT(rpcMsgPArr != NULL); ASSERT(arrSize > 0); int32_t dataLen = 0; @@ -991,7 +991,7 @@ SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMet raftMetaArr[i].seqNum = raftArr[i].seqNum; // init msgArr - msgArr[i] = rpcMsgArr[i]; + msgArr[i] = *(rpcMsgPArr[i]); } return pMsg; diff --git a/source/libs/sync/test/sh/a.sh b/source/libs/sync/test/sh/a.sh index 44cd2edbec..751b42b9c2 100644 --- a/source/libs/sync/test/sh/a.sh +++ b/source/libs/sync/test/sh/a.sh @@ -22,25 +22,25 @@ done echo "" echo "generate vgId ..." -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | sort | uniq > ${logpath}/log.vgIds.tmp +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' > ${logpath}/log.vgIds.tmp echo "all vgIds:" > ${logpath}/log.vgIds -cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds +cat ${logpath}/log.dnode* | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds for dnode in `ls ${logpath} | grep dnode | grep -v log`;do echo "" >> ${logpath}/log.vgIds echo "" >> ${logpath}/log.vgIds echo "${dnode}:" >> ${logpath}/log.vgIds - cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort | uniq >> ${logpath}/log.vgIds + cat ${logpath}/${dnode}/log/taosdlog.* | grep SYN | grep "vgId:" | grep -v ERROR | awk '{print $5}' | awk -F, '{print $1}' | sort -T. | uniq | awk -F: '{print $2, $0}' | sort -T. -k1 -n | awk '{print $2}' >> ${logpath}/log.vgIds done echo "" echo "generate log.dnode.vgId ..." for logdnode in `ls ${logpath}/log.dnode*`;do for vgId in `cat ${logpath}/log.vgIds.tmp`;do - rowNum=`cat ${logdnode} | grep "${vgId}" | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` + rowNum=`cat ${logdnode} | grep "${vgId}," | awk 'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'` #echo "-----${rowNum}" if [ $rowNum -gt 0 ] ; then echo "generate ${logdnode}.${vgId}" - cat ${logdnode} | grep "${vgId}" > ${logdnode}.${vgId} + cat ${logdnode} | grep "${vgId}," > ${logdnode}.${vgId} fi done done @@ -54,7 +54,7 @@ done echo "" echo "generate log.leader.term ..." -cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -k1 > ${logpath}/log.leader.term +cat ${logpath}/*.main | grep "become leader" | grep -v "config change" | awk '{print $5,$0}' | awk -F, '{print $4"_"$0}' | sort -T. -k1 > ${logpath}/log.leader.term echo "" echo "generate log.index, log.snapshot, log.records, log.actions ..." diff --git a/source/libs/sync/test/syncClientRequestBatchTest.cpp b/source/libs/sync/test/syncClientRequestBatchTest.cpp index ae74baeda4..84d037be01 100644 --- a/source/libs/sync/test/syncClientRequestBatchTest.cpp +++ b/source/libs/sync/test/syncClientRequestBatchTest.cpp @@ -28,12 +28,12 @@ SRpcMsg *createRpcMsg(int32_t i, int32_t dataLen) { } SyncClientRequestBatch *createMsg() { - SRpcMsg rpcMsgArr[5]; - memset(rpcMsgArr, 0, sizeof(rpcMsgArr)); + SRpcMsg *rpcMsgPArr[5]; + memset(rpcMsgPArr, 0, sizeof(rpcMsgPArr)); for (int32_t i = 0; i < 5; ++i) { SRpcMsg *pRpcMsg = createRpcMsg(i, 20); - rpcMsgArr[i] = *pRpcMsg; - taosMemoryFree(pRpcMsg); + rpcMsgPArr[i] = pRpcMsg; + //taosMemoryFree(pRpcMsg); } SRaftMeta raftArr[5]; @@ -43,7 +43,7 @@ SyncClientRequestBatch *createMsg() { raftArr[i].isWeak = i % 2; } - SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgArr, raftArr, 5, 1234); + SyncClientRequestBatch *pMsg = syncClientRequestBatchBuild(rpcMsgPArr, raftArr, 5, 1234); return pMsg; } diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index 5645f49284..51be28ba0e 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -1,6 +1,7 @@ add_executable(transportTest "") add_executable(transUT "") -add_executable(pushServer "") +add_executable(svrBench "") +add_executable(cliBench "") target_sources(transUT PRIVATE @@ -12,9 +13,13 @@ target_sources(transportTest "transportTests.cpp" ) -target_sources(pushServer +target_sources(svrBench PRIVATE - "pushServer.c" + "svrBench.c" +) +target_sources(cliBench + PRIVATE + "cliBench.c" ) target_include_directories(transportTest @@ -45,13 +50,37 @@ target_include_directories(transUT "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_include_directories(pushServer +target_include_directories(svrBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(svrBench PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) -target_link_libraries (pushServer +target_link_libraries (svrBench + os + util + common + gtest_main + transport +) + +target_include_directories(cliBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(cliBench + PUBLIC + "${TD_SOURCE_DIR}/include/libs/transport" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) + +target_link_libraries (cliBench os util common diff --git a/source/libs/transport/test/cliBench.c b/source/libs/transport/test/cliBench.c new file mode 100644 index 0000000000..a296625ace --- /dev/null +++ b/source/libs/transport/test/cliBench.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "os.h" +#include "taoserror.h" +#include "tglobal.h" +#include "transLog.h" +#include "trpc.h" +#include "tutil.h" + +typedef struct { + int index; + SEpSet epSet; + int num; + int numOfReqs; + int msgSize; + tsem_t rspSem; + tsem_t *pOverSem; + TdThread thread; + void *pRpc; +} SInfo; + +static void processResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + SInfo *pInfo = (SInfo *)pMsg->info.ahandle; + tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, + pMsg->code); + + if (pEpSet) pInfo->epSet = *pEpSet; + + rpcFreeCont(pMsg->pCont); + tsem_post(&pInfo->rspSem); +} + +static int tcount = 0; + +static void *sendRequest(void *param) { + SInfo *pInfo = (SInfo *)param; + SRpcMsg rpcMsg = {0}; + + tDebug("thread:%d, start to send request", pInfo->index); + + while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { + pInfo->num++; + rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); + rpcMsg.contLen = pInfo->msgSize; + rpcMsg.info.ahandle = pInfo; + rpcMsg.msgType = 1; + tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); + rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); + if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); + tsem_wait(&pInfo->rspSem); + } + + tDebug("thread:%d, it is over", pInfo->index); + tcount++; + + return NULL; +} + +int main(int argc, char *argv[]) { + SRpcInit rpcInit; + SEpSet epSet; + int msgSize = 128; + int numOfReqs = 0; + int appThreads = 1; + char serverIp[40] = "127.0.0.1"; + struct timeval systemTime; + int64_t startTime, endTime; + + // server info + epSet.numOfEps = 1; + epSet.inUse = 0; + epSet.eps[0].port = 7000; + epSet.eps[1].port = 7000; + strcpy(epSet.eps[0].fqdn, serverIp); + strcpy(epSet.eps[1].fqdn, "192.168.0.1"); + + // client info + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.localPort = 0; + rpcInit.label = "APP"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = processResponse; + rpcInit.sessions = 100; + rpcInit.idleTime = tsShellActivityTimer * 1000; + rpcInit.user = "michael"; + rpcInit.connType = TAOS_CONN_CLIENT; + + rpcDebugFlag = 131; + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { + rpcInit.numOfThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { + msgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { + rpcInit.sessions = atoi(argv[++i]); + } else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) { + numOfReqs = atoi(argv[++i]); + } else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) { + appThreads = atoi(argv[++i]); + } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { + tsCompressMsgSize = atoi(argv[++i]); + } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { + } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { + rpcDebugFlag = atoi(argv[++i]); + } else { + printf("\nusage: %s [options] \n", argv[0]); + printf(" [-i ip]: first server IP address, default is:%s\n", serverIp); + printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); + printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); + printf(" [-a threads]: number of app threads, default is:%d\n", appThreads); + printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); + printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); + printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); + printf(" [-h help]: print out this help\n\n"); + exit(0); + } + } + taosInitLog("client.log", 100000); + + void *pRpc = rpcOpen(&rpcInit); + if (pRpc == NULL) { + tError("failed to initialize RPC"); + return -1; + } + + tInfo("client is initialized"); + tInfo("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs); + + int64_t now = taosGetTimestampUs(); + + SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); + SInfo *p = pInfo; + for (int i = 0; i < appThreads; ++i) { + pInfo->index = i; + pInfo->epSet = epSet; + pInfo->numOfReqs = numOfReqs; + pInfo->msgSize = msgSize; + tsem_init(&pInfo->rspSem, 0, 0); + pInfo->pRpc = pRpc; + + taosThreadCreate(&pInfo->thread, NULL, sendRequest, pInfo); + pInfo++; + } + + do { + taosUsleep(1); + } while (tcount < appThreads); + + float usedTime = (taosGetTimestampUs() - now) / 1000.0f; + + tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); + tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); + + for (int i = 0; i < appThreads; i++) { + SInfo *pInfo = p; + taosThreadJoin(pInfo->thread, NULL); + p++; + } + int ch = getchar(); + UNUSED(ch); + + taosCloseLog(); + + return 0; +} diff --git a/source/libs/transport/test/pushServer.c b/source/libs/transport/test/svrBench.c similarity index 89% rename from source/libs/transport/test/pushServer.c rename to source/libs/transport/test/svrBench.c index 754433a5e6..224f527385 100644 --- a/source/libs/transport/test/pushServer.c +++ b/source/libs/transport/test/svrBench.c @@ -24,12 +24,12 @@ int msgSize = 128; int commit = 0; TdFilePtr pDataFile = NULL; STaosQueue *qhandle = NULL; -STaosQset * qset = NULL; +STaosQset *qset = NULL; void processShellMsg() { static int num = 0; STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; int type; SQueueInfo qinfo = {0}; @@ -77,7 +77,6 @@ void processShellMsg() { taosFreeQitem(pRpcMsg); { - // taosSsleep(1); SRpcMsg nRpcMsg = {0}; nRpcMsg.pCont = rpcMallocCont(msgSize); nRpcMsg.contLen = msgSize; @@ -93,26 +92,6 @@ void processShellMsg() { taosFreeQall(qall); } -int retrieveAuthInfo(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey) { - // app shall retrieve the auth info based on meterID from DB or a data file - // demo code here only for simple demo - int ret = 0; - - if (strcmp(meterId, "michael") == 0) { - *spi = 1; - *encrypt = 0; - strcpy(secret, "mypassword"); - strcpy(ckey, "key"); - } else if (strcmp(meterId, "jeff") == 0) { - *spi = 0; - *encrypt = 0; - } else { - ret = -1; // user not there - } - - return ret; -} - void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { SRpcMsg *pTemp; @@ -131,11 +110,12 @@ int main(int argc, char *argv[]) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 7000; + memcpy(rpcInit.localFqdn, "localhost", strlen("localhost")); rpcInit.label = "SER"; rpcInit.numOfThreads = 1; rpcInit.cfp = processRequestMsg; - rpcInit.sessions = 1000; rpcInit.idleTime = 2 * 1500; + rpcDebugFlag = 131; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { @@ -170,7 +150,7 @@ int main(int argc, char *argv[]) { tsAsyncLog = 0; rpcInit.connType = TAOS_CONN_SERVER; - taosInitLog("server.log", 10); + taosInitLog("server.log", 100000); void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index f773e4ff58..2a9d0c8535 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -41,7 +41,7 @@ target_link_libraries( ) if(TD_WINDOWS) target_link_libraries( - os PUBLIC ws2_32 iconv msvcregex wcwidth winmm + os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump ) elseif(TD_DARWIN_64) target_link_libraries( diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index fa94bc6a13..3e68b6e086 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -91,6 +91,7 @@ LONG WINAPI FlCrashDump(PEXCEPTION_POINTERS ep) { return EXCEPTION_CONTINUE_SEARCH; } +LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception); #elif defined(_TD_DARWIN_64) @@ -841,7 +842,8 @@ char *taosGetCmdlineByPID(int pid) { void taosSetCoreDump(bool enable) { #ifdef WINDOWS - SetUnhandledExceptionFilter(&FlCrashDump); + // SetUnhandledExceptionFilter(exceptionHandler); + // SetUnhandledExceptionFilter(&FlCrashDump); #elif defined(_TD_DARWIN_64) #else if (!enable) return; diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index ad7fa57182..c86cd19e32 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,6 +18,63 @@ #include "os.h" #if defined(WINDOWS) +typedef void (*MainWindows)(int argc,char** argv); +MainWindows mainWindowsFunc = NULL; + +SERVICE_STATUS ServiceStatus; +SERVICE_STATUS_HANDLE hServiceStatusHandle; +void WINAPI windowsServiceCtrlHandle(DWORD request) { + switch (request) { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + raise(SIGINT); + ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d",nError); + } + break; + default: + return; + } +} +void WINAPI mainWindowsService(int argc,char** argv) { + int ret = 0; + ServiceStatus.dwServiceType = SERVICE_WIN32; + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + ServiceStatus.dwCurrentState = SERVICE_START_PENDING; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + ServiceStatus.dwWaitHint = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle); + if (hServiceStatusHandle == 0) { + DWORD nError = GetLastError(); + printf("failed to register windows service ctrl handler: %d",nError); + } + + ServiceStatus.dwCurrentState = SERVICE_RUNNING; + if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send running status to windows service: %d",nError); + } + if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv); + ServiceStatus.dwCurrentState = SERVICE_STOPPED; + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d",nError); + } +} +void stratWindowsService(MainWindows mainWindows) { + mainWindowsFunc = mainWindows; + SERVICE_TABLE_ENTRY ServiceTable[2]; + ServiceTable[0].lpServiceName = "taosd"; + ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)mainWindowsService; + ServiceTable[1].lpServiceName = NULL; + ServiceTable[1].lpServiceProc = NULL; + StartServiceCtrlDispatcher(ServiceTable); +} + #elif defined(_TD_DARWIN_64) #else #include diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 6095b67588..3c4a0a20bd 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -294,7 +294,7 @@ void taosArraySet(SArray* pArray, size_t index, void* pData) { void taosArrayPopFrontBatch(SArray* pArray, size_t cnt) { assert(cnt <= pArray->size); pArray->size = pArray->size - cnt; - if (pArray->size == 0) { + if (pArray->size == 0 || cnt == 0) { return; } memmove(pArray->pData, (char*)pArray->pData + cnt * pArray->elemSize, pArray->size * pArray->elemSize); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f8d8e9d168..f20c5d8593 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -559,6 +559,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN, "Not valid function TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, "Only support single table") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SMA_INDEX, "Invalid sma index") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SELECTED_EXPR, "Invalid SELECTed expression") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table info") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") //planner diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index a71a75eac5..73d89523ce 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -16,8 +16,8 @@ #define _DEFAULT_SOURCE #include "tlog.h" #include "os.h" -#include "tutil.h" #include "tconfig.h" +#include "tutil.h" #define LOG_MAX_LINE_SIZE (1024) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3) @@ -40,7 +40,7 @@ #define LOG_BUF_MUTEX(x) ((x)->buffMutex) typedef struct { - char * buffer; + char *buffer; int32_t buffStart; int32_t buffEnd; int32_t buffSize; @@ -59,15 +59,15 @@ typedef struct { int32_t openInProgress; pid_t pid; char logName[LOG_FILE_NAME_LEN]; - SLogBuff * logHandle; + SLogBuff *logHandle; TdThreadMutex logMutex; } SLogObj; extern SConfig *tsCfg; -static int8_t tsLogInited = 0; -static SLogObj tsLogObj = {.fileNum = 1}; -static int64_t tsAsyncLogLostLines = 0; -static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; +static int8_t tsLogInited = 0; +static SLogObj tsLogObj = {.fileNum = 1}; +static int64_t tsAsyncLogLostLines = 0; +static int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL; bool tsLogEmbedded = 0; bool tsAsyncLog = true; @@ -82,7 +82,7 @@ int64_t tsNumOfTraceLogs = 0; // log int32_t dDebugFlag = 135; int32_t vDebugFlag = 135; -int32_t mDebugFlag = 131; +int32_t mDebugFlag = 135; int32_t cDebugFlag = 131; int32_t jniDebugFlag = 131; int32_t tmrDebugFlag = 131; @@ -106,7 +106,7 @@ int64_t dbgSmallWN = 0; int64_t dbgBigWN = 0; int64_t dbgWSize = 0; -static void * taosAsyncOutputLog(void *param); +static void *taosAsyncOutputLog(void *param); static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen); static SLogBuff *taosLogBuffNew(int32_t bufSize); static void taosCloseLogByFd(TdFilePtr pFile); @@ -128,7 +128,11 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles) { osUpdate(); char fullName[PATH_MAX] = {0}; - snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + if (strlen(tsLogDir) != 0) { + snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); + } else { + snprintf(fullName, PATH_MAX, "%s", logName); + } tsLogObj.logHandle = taosLogBuffNew(LOG_DEFAULT_BUF_SIZE); if (tsLogObj.logHandle == NULL) return -1; @@ -704,7 +708,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { int32_t compressSize = 163840; int32_t ret = 0; int32_t len = 0; - char * data = taosMemoryMalloc(compressSize); + char *data = taosMemoryMalloc(compressSize); // gzFile dstFp = NULL; // srcFp = fopen(srcFileName, "r"); diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 6de5a9ab98..88b721d104 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -97,7 +97,7 @@ # TD-17738 ./test.sh -f tsim/parser/col_arithmetic_operation.sim # TD-17661 ./test.sh -f tsim/parser/columnValue.sim ./test.sh -f tsim/parser/commit.sim -# TD-17661 ./test.sh -f tsim/parser/condition.sim +./test.sh -f tsim/parser/condition.sim ./test.sh -f tsim/parser/constCol.sim #./test.sh -f tsim/parser/create_db.sim ./test.sh -f tsim/parser/create_mt.sim @@ -298,8 +298,8 @@ ./test.sh -f tsim/sma/drop_sma.sim ./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim # temp disable -#./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim -#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim +./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim +./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim # --- valgrind ./test.sh -f tsim/valgrind/checkError1.sim @@ -325,7 +325,7 @@ # --- sync ./test.sh -f tsim/sync/3Replica1VgElect.sim -./test.sh -f tsim/sync/3Replica5VgElect.sim +#./test.sh -f tsim/sync/3Replica5VgElect.sim ./test.sh -f tsim/sync/oneReplica1VgElect.sim ./test.sh -f tsim/sync/oneReplica5VgElect.sim diff --git a/tests/script/tsim/alter/dnode.sim b/tests/script/tsim/alter/dnode.sim index 35620f17aa..d773c1f8a9 100644 --- a/tests/script/tsim/alter/dnode.sim +++ b/tests/script/tsim/alter/dnode.sim @@ -24,14 +24,20 @@ sql alter dnode 1 'fsDebugFlag 131' sql alter dnode 1 'udfDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'idxDebugFlag 131' +sql alter dnode 1 'tdbDebugFlag 131' sql alter dnode 1 'tmrDebugFlag 131' sql alter dnode 1 'uDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'rpcDebugFlag 131' sql alter dnode 1 'qDebugFlag 131' +sql alter dnode 1 'metaDebugFlag 131' sql_error alter dnode 2 'wDebugFlag 135' sql_error alter dnode 2 'tmrDebugFlag 135' +sql_error alter dnode 1 'monDebugFlag 131' +sql_error alter dnode 1 'cqDebugFlag 131' +sql_error alter dnode 1 'httpDebugFlag 131' +sql_error alter dnode 1 'mqttDebugFlag 131' print ======== step3 sql_error alter $hostname1 debugFlag 135 diff --git a/tests/script/tsim/bnode/basic1.sim b/tests/script/tsim/bnode/basic1.sim index 80608453b8..c1b1a7ea9a 100644 --- a/tests/script/tsim/bnode/basic1.sim +++ b/tests/script/tsim/bnode/basic1.sim @@ -75,61 +75,61 @@ if $data02 != leader then return -1 endi -print =============== create drop bnode 1 -sql create bnode on dnode 1 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 1 then - return -1 -endi -sql_error create bnode on dnode 1 +#print =============== create drop bnode 1 +#sql create bnode on dnode 1 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#sql_error create bnode on dnode 1 +# +#sql drop bnode on dnode 1 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 1 +# +#print =============== create drop bnode 2 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 1 then +# return -1 +#endi +#if $data00 != 2 then +# return -1 +#endi +#sql_error create bnode on dnode 2 +# +#sql drop bnode on dnode 2 +#sql show bnodes +#if $rows != 0 then +# return -1 +#endi +#sql_error drop bnode on dnode 2 +# +#print =============== create drop bnodes +#sql create bnode on dnode 1 +#sql create bnode on dnode 2 +#sql show bnodes +#if $rows != 2 then +# return -1 +#endi -sql drop bnode on dnode 1 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 1 - -print =============== create drop bnode 2 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 1 then - return -1 -endi -if $data00 != 2 then - return -1 -endi -sql_error create bnode on dnode 2 - -sql drop bnode on dnode 2 -sql show bnodes -if $rows != 0 then - return -1 -endi -sql_error drop bnode on dnode 2 - -print =============== create drop bnodes -sql create bnode on dnode 1 -sql create bnode on dnode 2 -sql show bnodes -if $rows != 2 then - return -1 -endi - -print =============== restart -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -system sh/exec.sh -n dnode2 -s start - -sleep 2000 -sql show bnodes -if $rows != 2 then - return -1 -endi +#print =============== restart +#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s start +#system sh/exec.sh -n dnode2 -s start +# +#sleep 2000 +#sql show bnodes +#if $rows != 2 then +# return -1 +#endi system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/condition_query.sim b/tests/script/tsim/parser/condition_query.sim index dc5eed49be..87ea9f3cbe 100644 --- a/tests/script/tsim/parser/condition_query.sim +++ b/tests/script/tsim/parser/condition_query.sim @@ -132,7 +132,7 @@ if $rows != 28 then return -1 endi -sql select ts,c1,c7 from stb1 where c7 = false +sql select ts,c1,c7 from stb1 where c7 = false order by ts if $rows != 14 then return -1 endi @@ -173,7 +173,7 @@ if $data32 != 0 then return -1 endi -sql select ts,c1,c7 from stb1 where c7 = true +sql select ts,c1,c7 from stb1 where c7 = true order by ts if $rows != 14 then return -1 endi @@ -215,7 +215,7 @@ if $data32 != 1 then endi -sql select * from stb1 where c8 = '51' or c8 = '4' +sql select * from stb1 where c8 = '51' or c8 = '4' order by ts if $rows != 2 then return -1 endi @@ -350,7 +350,7 @@ sql select * from stb1 where c1 > 50 and (c1 > 53 and c1 < 51 or c1 > 54) if $rows != 4 then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 and c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -401,7 +401,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 and c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -420,11 +420,11 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 and c1 > 54) order by ts if $rows != 0 then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -443,7 +443,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) and c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -459,7 +459,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) and c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -478,7 +478,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 and c1 > 53) or (c1 < 51 or c1 > 54) order by ts if $rows != 25 then return -1 endi @@ -497,7 +497,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51 or c1 > 54) order by ts if $rows != 5 then return -1 endi @@ -516,7 +516,7 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 and c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 and c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 25 then return -1 endi @@ -535,7 +535,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 and (c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 5 then return -1 endi @@ -554,7 +554,7 @@ endi if $data40 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) and (c1 < 51 or c1 > 54) order by ts if $rows != 4 then return -1 endi @@ -570,7 +570,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51 or c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -589,7 +589,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 and c1 < 51) or c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -608,7 +608,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 and c1 < 51) or c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -627,7 +627,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 and c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -646,7 +646,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -662,7 +662,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 and c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 and c1 > 54) order by ts if $rows != 8 then return -1 endi @@ -681,7 +681,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 8 then return -1 endi @@ -700,7 +700,7 @@ endi if $data40 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c1 > 62 or (c1 > 53 or c1 < 51) and c1 > 54 +sql select * from stb1 where c1 > 62 or (c1 > 53 or c1 < 51) and c1 > 54 order by ts if $rows != 4 then return -1 endi @@ -716,7 +716,7 @@ endi if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 or c1 > 54) +sql select * from stb1 where (c1 > 50 or c1 > 53) or (c1 < 51 or c1 > 54) order by ts if $rows != 28 then return -1 endi @@ -735,7 +735,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 or c1 > 54) +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51 or c1 > 54) order by ts if $rows != 28 then return -1 endi @@ -754,7 +754,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where (c1 > 50 or c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 28 then return -1 endi @@ -773,7 +773,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) or c1 > 54 +sql select * from stb1 where c1 > 50 or (c1 > 53 or c1 < 51) or c1 > 54 order by ts if $rows != 28 then return -1 endi @@ -792,7 +792,7 @@ endi if $data40 != @21-05-05 18:19:04.000@ then return -1 endi -sql select ts,c1 from stb1 where (c1 > 60 or c1 < 10 or (c1 > 20 and c1 < 30)) and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:25.000' and c1 != 21 and c1 != 22 +sql select ts,c1 from stb1 where (c1 > 60 or c1 < 10 or (c1 > 20 and c1 < 30)) and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:25.000' and c1 != 21 and c1 != 22 order by ts if $rows != 6 then return -1 endi @@ -834,7 +834,7 @@ if $data51 != 61 then endi -sql select * from stb1 where (c1 > 40 or c1 < 20) and (c2 < 53 or c2 >= 63) and c3 > 1 and c3 < 5 +sql select * from stb1 where (c1 > 40 or c1 < 20) and (c2 < 53 or c2 >= 63) and c3 > 1 and c3 < 5 order by ts if $rows != 3 then return -1 endi @@ -857,7 +857,7 @@ if $data21 != 4 then return -1 endi -sql select * from stb1 where (c1 > 52 or c1 < 10) and (c2 > 1 and c2 < 61) +sql select * from stb1 where (c1 > 52 or c1 < 10) and (c2 > 1 and c2 < 61) order by ts if $rows != 5 then return -1 endi @@ -892,7 +892,7 @@ if $data41 != 54 then return -1 endi -sql select * from stb1 where (c3 > 52 or c3 < 10) and (c4 > 1 and c4 < 61) and (c5 = 2 or c6 = 3.0 or c6 = 4.0 or c6 = 53); +sql select * from stb1 where (c3 > 52 or c3 < 10) and (c4 > 1 and c4 < 61) and (c5 = 2 or c6 = 3.0 or c6 = 4.0 or c6 = 53) order by ts if $rows != 4 then return -1 endi @@ -1003,7 +1003,7 @@ if $data01 != NULL then endi #xxx -sql select * from stb1 where c8 like '1'; +sql select * from stb1 where c8 like '1' order by ts; if $rows != 1 then return -1 endi @@ -1012,7 +1012,7 @@ if $data00 != @21-05-05 18:19:00.000@ then endi #xxx -sql select * from stb1 where c8 like '1%' and c8 like '%1'; +sql select * from stb1 where c8 like '1%' and c8 like '%1' order by ts; if $rows != 2 then return -1 endi @@ -1024,7 +1024,7 @@ if $data10 != @21-05-05 18:19:04.000@ then endi #xxx -sql select * from stb1 where c8 like '1' and c8 like '2'; +sql select * from stb1 where c8 like '1' and c8 like '2' order by ts; if $rows != 0 then return -1 endi @@ -1040,7 +1040,7 @@ if $data01 != NULL then return -1 endi -sql select * from stb1 where c1 is not null; +sql select * from stb1 where c1 is not null order by ts; if $rows != 28 then return -1 endi @@ -1050,7 +1050,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c2 is not null; +sql select * from stb1 where c2 is not null order by ts; if $rows != 28 then return -1 endi @@ -1060,7 +1060,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c3 is not null; +sql select * from stb1 where c3 is not null order by ts; if $rows != 28 then return -1 endi @@ -1070,7 +1070,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c4 is not null; +sql select * from stb1 where c4 is not null order by ts; if $rows != 28 then return -1 endi @@ -1080,7 +1080,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c5 is not null; +sql select * from stb1 where c5 is not null order by ts; if $rows != 28 then return -1 endi @@ -1090,7 +1090,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c6 is not null; +sql select * from stb1 where c6 is not null order by ts; if $rows != 28 then return -1 endi @@ -1100,7 +1100,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c7 is not null; +sql select * from stb1 where c7 is not null order by ts; if $rows != 28 then return -1 endi @@ -1110,7 +1110,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c8 is not null; +sql select * from stb1 where c8 is not null order by ts; if $rows != 28 then return -1 endi @@ -1120,7 +1120,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c9 is not null; +sql select * from stb1 where c9 is not null order by ts; if $rows != 28 then return -1 endi @@ -1130,7 +1130,7 @@ endi if $data01 != 1 then return -1 endi -sql select * from stb1 where c1 > 63 or c1 is null; +sql select * from stb1 where c1 > 63 or c1 is null order by ts; if $rows != 2 then return -1 endi @@ -1146,7 +1146,7 @@ endi if $data11 != NULL then return -1 endi -sql select * from stb1 where c1 is null and c2 is null; +sql select * from stb1 where c1 is null and c2 is null order by ts; if $rows != 1 then return -1 endi @@ -1156,11 +1156,11 @@ endi if $data01 != NULL then return -1 endi -sql select * from stb1 where c1 is null and c2 is null and c3 is not null; +sql select * from stb1 where c1 is null and c2 is null and c3 is not null order by ts; if $rows != 0 then return -1 endi -sql select * from stb1 where c1 is null and c2 is null and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:28.000'; +sql select * from stb1 where c1 is null and c2 is null and ts > '2021-05-05 18:19:00.000' and ts < '2021-05-05 18:19:28.000' order by ts; if $rows != 0 then return -1 endi @@ -1175,7 +1175,7 @@ if $rows != 29 then return -1 endi -sql select * from stb1 where (c1 is null or c1 > 40) and c1 < 44; +sql select * from stb1 where (c1 is null or c1 > 40) and c1 < 44 order by ts; if $rows != 3 then return -1 endi @@ -1189,7 +1189,7 @@ if $data20 != @21-05-05 18:19:18.000@ then return -1 endi -sql select * from stb1 where c1 in (11,21,31,41) and c1 in (11,42); +sql select * from stb1 where c1 in (11,21,31,41) and c1 in (11,42) order by ts; if $rows != 1 then return -1 endi @@ -1197,7 +1197,7 @@ if $data00 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c8 in ('11','21','31','41') and c8 in ('11','42'); +sql select * from stb1 where c8 in ('11','21','31','41') and c8 in ('11','42') order by ts; if $rows != 1 then return -1 endi @@ -1205,7 +1205,7 @@ if $data00 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where (c1 > 60 and c2 > 40) or (c1 > 62 and c2 > 50); +sql select * from stb1 where (c1 > 60 and c2 > 40) or (c1 > 62 and c2 > 50) order by ts; if $rows != 4 then return -1 endi @@ -1222,7 +1222,7 @@ if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52; +sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52 order by ts; if $rows != 4 then return -1 endi @@ -1239,7 +1239,7 @@ if $data30 != @21-05-05 18:19:21.000@ then return -1 endi -sql select * from stb1 where c8 LIKE '%1'; +sql select * from stb1 where c8 LIKE '%1' order by ts; if $rows != 7 then return -1 endi @@ -1264,7 +1264,7 @@ endi if $data60 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where c9 LIKE '%1'; +sql select * from stb1 where c9 LIKE '%1' order by ts; if $rows != 7 then return -1 endi @@ -1289,7 +1289,7 @@ endi if $data60 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where (c8 LIKE '%1' or c9 like '_2') and (c5 > 50 or c6 > 30) and ( c8 like '3_' or c9 like '4_') and (c4 <= 31 or c4 >= 42); +sql select * from stb1 where (c8 LIKE '%1' or c9 like '_2') and (c5 > 50 or c6 > 30) and ( c8 like '3_' or c9 like '4_') and (c4 <= 31 or c4 >= 42) order by ts; if $rows != 2 then return -1 endi @@ -1300,7 +1300,7 @@ if $data10 != @21-05-05 18:19:17.000@ then return -1 endi -sql select * from stb1 where c1 in (1,3); +sql select * from stb1 where c1 in (1,3) order by ts; if $rows != 2 then return -1 endi @@ -1311,7 +1311,7 @@ if $data10 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where c3 in (11,22); +sql select * from stb1 where c3 in (11,22) order by ts; if $rows != 2 then return -1 endi @@ -1322,7 +1322,7 @@ if $data10 != @21-05-05 18:19:09.000@ then return -1 endi -sql select * from stb1 where c4 in (3,33); +sql select * from stb1 where c4 in (3,33) order by ts; if $rows != 2 then return -1 endi @@ -1338,7 +1338,7 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c5 in (3,33) and c8 in ('33','54'); +sql select * from stb1 where c5 in (3,33) and c8 in ('33','54') order by ts; if $rows != 1 then return -1 endi @@ -1346,7 +1346,7 @@ if $data00 != @21-05-05 18:19:14.000@ then return -1 endi -sql select * from stb1 where c5 in (3,33) or c8 in ('22','54'); +sql select * from stb1 where c5 in (3,33) or c8 in ('22','54') order by ts; if $rows != 4 then return -1 endi @@ -1363,7 +1363,7 @@ if $data30 != @21-05-05 18:19:23.000@ then return -1 endi -sql select * from stb1 where (c9 in ('3','1','2','4','5') or c9 in ('33','11','22','44','55')) and c9 in ('1','3','11','13'); +sql select * from stb1 where (c9 in ('3','1','2','4','5') or c9 in ('33','11','22','44','55')) and c9 in ('1','3','11','13') order by ts; if $rows != 3 then return -1 endi @@ -1377,7 +1377,7 @@ if $data20 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb2 where (u1 in (1) or u2 in (5,6)) and (u3 in (3,6) or u4 in (7,8)) and ts2 in ('2021-05-05 18:28:02.000','2021-05-05 18:28:15.000','2021-05-05 18:28:01.000'); +sql select * from stb2 where (u1 in (1) or u2 in (5,6)) and (u3 in (3,6) or u4 in (7,8)) and ts2 in ('2021-05-05 18:28:02.000','2021-05-05 18:28:15.000','2021-05-05 18:28:01.000') order by ts; if $rows != 2 then return -1 endi @@ -1388,7 +1388,7 @@ if $data10 != @21-05-05 18:19:01.000@ then return -1 endi -sql select * from stb2 where u2 in (2) and u3 in (1,2,3) and u4 in (1,2,4,5) and u1 > 3 and u1 < 6 and u1 != 4; +sql select * from stb2 where u2 in (2) and u3 in (1,2,3) and u4 in (1,2,4,5) and u1 > 3 and u1 < 6 and u1 != 4 order by ts; if $rows != 1 then return -1 endi @@ -1396,7 +1396,7 @@ if $data00 != @21-05-05 18:19:08.000@ then return -1 endi -sql select avg(c1) from tb1 where (c1 > 12 or c2 > 10) and (c3 < 12 or c3 > 13); +sql select avg(c1) from tb1 where (c1 > 12 or c2 > 10) and (c3 < 12 or c3 > 13) ; if $rows != 1 then return -1 endi @@ -1408,22 +1408,16 @@ sql select count(c1),sum(c3) from tb1 where ((c7 = true and c6 > 2) or (c1 > 10 if $rows != 2 then return -1 endi -if $data00 != @21-05-05 18:19:00.000@ then +if $data00 != 3 then return -1 endi -if $data01 != 3 then +if $data01 != 14 then return -1 endi -if $data02 != 14 then +if $data10 != 3 then return -1 endi -if $data10 != @21-05-05 18:19:05.000@ then - return -1 -endi -if $data11 != 3 then - return -1 -endi -if $data12 != 39 then +if $data11 != 39 then return -1 endi @@ -1447,14 +1441,14 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c2 in (0,1); +sql select * from stb1 where c2 in (0,1) order by ts; if $rows != 1 then return -1 endi if $data00 != @21-05-05 18:19:00.000@ then return -1 endi -sql select * from stb1 where c6 in (0,2,3,1); +sql select * from stb1 where c6 in (0,2,3,1) order by ts; if $rows != 3 then return -1 endi @@ -1467,7 +1461,7 @@ endi if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select ts,c1 from (select * from stb1 where (c1 > 60 or c1 < 10) and (c7 = true or c5 > 2 and c5 < 63)) where (c3 > 61 or c3 < 3); +sql select ts,c1 from (select * from stb1 where (c1 > 60 or c1 < 10) and (c7 = true or c5 > 2 and c5 < 63)) where (c3 > 61 or c3 < 3) order by ts; if $rows != 3 then return -1 endi @@ -1481,66 +1475,66 @@ if $data20 != @21-05-05 18:19:25.000@ then return -1 endi +#sql select a.* from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 order by ts; #sql select a.* from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50; -sql select a.ts from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50; -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:20.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:21.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:24.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:25.000@ then - return -1 -endi +#if $rows != 4 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:20.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:21.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:24.000@ then +# return -1 +#endi +#if $data30 != @21-05-05 18:19:25.000@ then +# return -1 +#endi -#sql select a.ts,a.c1,a.c8,a.c9 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60; -sql select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60; -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:20.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:21.000@ then - return -1 -endi - -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.c1 < 10 or a.c1 > 30) and (b.u1 < 5 or b.u1 > 5); -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:00.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:12.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:14.000@ then - return -1 -endi - -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.c1 < 30 and b.u1 > 1 and a.c1 > 10 and b.u1 < 8 and b.u1<>5; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:04.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:06.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:10.000@ then - return -1 -endi +#sql select a.ts,a.c1,a.c8,a.c9 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60 order by ts; +#sql select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 and b.c1 < 60 order by ts; +#if $rows != 2 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:20.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:21.000@ then +# return -1 +#endi +# +#sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.c1 < 10 or a.c1 > 30) and (b.u1 < 5 or b.u1 > 5) order by ts; +#if $rows != 4 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:00.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:02.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:12.000@ then +# return -1 +#endi +#if $data30 != @21-05-05 18:19:14.000@ then +# return -1 +#endi +# +#sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.c1 < 30 and b.u1 > 1 and a.c1 > 10 and b.u1 < 8 and b.u1<>5 order by ts; +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:04.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:06.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:10.000@ then +# return -1 +#endi sql select * from stb1 where c1 is null and c1 is not null; if $rows != 0 then @@ -1560,7 +1554,7 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where (c1 > 20 or c1 < 25) and (c1 > 62 or c1 < 3); +sql select * from stb1 where (c1 > 20 or c1 < 25) and (c1 > 62 or c1 < 3) order by ts; if $rows != 4 then return -1 endi @@ -1577,7 +1571,7 @@ if $data30 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 11 and c1 != 11 and c1 != 14 and c1 < 14; +sql select * from stb1 where c1 > 11 and c1 != 11 and c1 != 14 and c1 < 14 order by ts; if $rows != 2 then return -1 endi @@ -1587,7 +1581,7 @@ endi if $data10 != @21-05-05 18:19:06.000@ then return -1 endi -sql select * from stb1 where (c1 > 60 or c1 < 4 or c1 > 10 and c1 < 20 and c1 != 13 or c1 < 2 or c1 > 50) +sql select * from stb1 where (c1 > 60 or c1 < 4 or c1 > 10 and c1 < 20 and c1 != 13 or c1 < 2 or c1 > 50) order by ts if $rows != 14 then return -1 endi @@ -1604,7 +1598,7 @@ if $data30 != @21-05-05 18:19:04.000@ then return -1 endi -sql select * from stb1 where c1 > 62 or c1 >= 62; +sql select * from stb1 where c1 > 62 or c1 >= 62 order by ts; if $rows != 3 then return -1 endi @@ -1618,7 +1612,7 @@ if $data20 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 > 62 and c1 >= 62; +sql select * from stb1 where c1 > 62 and c1 >= 62 order by ts; if $rows != 2 then return -1 endi @@ -1629,7 +1623,7 @@ if $data10 != @21-05-05 18:19:27.000@ then return -1 endi -sql select * from stb1 where c1 >= 62 and c1 != 62; +sql select * from stb1 where c1 >= 62 and c1 != 62 order by ts; if $rows != 2 then return -1 endi @@ -1653,7 +1647,7 @@ if $data00 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where c1 > 62 and c1 != 62; +sql select * from stb1 where c1 > 62 and c1 != 62 order by ts; if $rows != 2 then return -1 endi @@ -1713,12 +1707,12 @@ if $rows != 0 then return -1 endi -sql select * from stb1 where c2 >= 3 and c2 <= 3; +sql select * from stb1 where c2 >= 3 and c2 <= 3 order by ts; if $data00 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where (c2 in (1,2,3,4) or c2 in (11,12,13,14)) and c2 != 11 and c2 >2 and c2 != 14; +sql select * from stb1 where (c2 in (1,2,3,4) or c2 in (11,12,13,14)) and c2 != 11 and c2 >2 and c2 != 14 order by ts; if $rows != 4 then return -1 endi @@ -1760,7 +1754,7 @@ if $data20 != @21-05-05 18:19:03.000@ then return -1 endi -sql select * from (select * from stb1 where c2 > 10 and c6 < 40) where c9 in ('11','21','31'); +sql select * from (select * from stb1 where c2 > 10 and c6 < 40) where c9 in ('11','21','31') order by ts; if $rows != 3 then return -1 endi @@ -1774,7 +1768,7 @@ if $data20 != @21-05-05 18:19:12.000@ then return -1 endi -sql select * from stb1 where c1 > 40 and c2 > 50 and c3 > 62 or c1 < 2 and c2 < 3; +sql select * from stb1 where c1 > 40 and c2 > 50 and c3 > 62 or c1 < 2 and c2 < 3 order by ts; if $rows != 3 then return -1 endi @@ -1803,7 +1797,7 @@ if $rows != 29 then return -1 endi -sql select * from stb1 where (c1 > 60 and c2 < 63) or (c1 >62 and c3 < 30) or (c1 is null and c2 is null); +sql select * from stb1 where (c1 > 60 and c2 < 63) or (c1 >62 and c3 < 30) or (c1 is null and c2 is null) order by ts; if $rows != 3 then return -1 endi @@ -1817,7 +1811,7 @@ if $data20 != @21-05-05 18:19:28.000@ then return -1 endi -sql select * from stb1 where c1 between 60 and 9999999999; +sql select * from stb1 where c1 between 60 and 9999999999 order by ts; if $rows != 4 then return -1 endi @@ -1873,7 +1867,7 @@ sql select * from stb1 where c5 in (9999999999); if $rows != 0 then return -1 endi -sql select * from stb1 where c5 in (-9999999999,3,4,9999999999); +sql select * from stb1 where c5 in (-9999999999,3,4,9999999999) order by ts; if $rows != 2 then return -1 endi @@ -1884,7 +1878,7 @@ if $data10 != @21-05-05 18:19:03.000@ then return -1 endi -sql select * from stb3 where c1 > 3 and c1 < 2; +sql select * from stb3 where c1 > 3 and c1 < 2 order by ts; if $rows != 0 then return -1 endi @@ -1936,7 +1930,7 @@ if $data70 != @21-04-06 18:19:03.000@ then endi -sql select * from stb3 where c1 > 11; +sql select * from stb3 where c1 > 11 order by ts; if $rows != 4 then return -1 endi @@ -1953,12 +1947,12 @@ if $data30 != @21-05-06 18:19:28.000@ then return -1 endi -sql select * from stb3 where c1 is not null or c1 is null; +sql select * from stb3 where c1 is not null or c1 is null order by ts; if $rows != 14 then return -1 endi -sql select ts,c1 from stb4 where c1 = 200; +sql select ts,c1 from stb4 where c1 = 200 order by ts; if $rows != 1 then return -1 endi @@ -1973,7 +1967,7 @@ endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 200 and c2 > 500 and c3 < 800 and c4 between 33 and 37 and c4 != 35 and c2 < 555 and c1 < 339 and c1 in (331,333,335); +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 200 and c2 > 500 and c3 < 800 and c4 between 33 and 37 and c4 != 35 and c2 < 555 and c1 < 339 and c1 in (331,333,335) order by ts; if $rows != 3 then return -1 endi @@ -1987,7 +1981,7 @@ if $data20 != @21-07-10 01:00:00.334@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 > -3 and c1 < 5; +sql select ts,c1,c2,c3,c4 from stb4 where c1 > -3 and c1 < 5 order by ts; if $rows != 4 then return -1 endi @@ -2004,7 +1998,7 @@ if $data30 != @21-07-10 01:00:00.003@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 2 and c1 < 5; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 2 and c1 < 5 order by ts; if $rows != 3 then return -1 endi @@ -2018,12 +2012,12 @@ if $data20 != @21-07-10 01:00:00.003@ then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= -3 and c1 < 1300; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= -3 and c1 < 1300 order by ts; if $rows != 1299 then return -1 endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 1298 and c1 < 1300 or c2 > 210 and c2 < 213; +sql select ts,c1,c2,c3,c4 from stb4 where c1 >= 1298 and c1 < 1300 or c2 > 210 and c2 < 213 order by ts; if $rows != 4 then return -1 endi @@ -2056,7 +2050,7 @@ if $rows != 1099 then endi -sql select ts,c1,c2,c3,c4 from stb4 where c1 in(10,100, 1100,3300) and c1 != 10; +sql select ts,c1,c2,c3,c4 from stb4 where c1 in(10,100, 1100,3300) and c1 != 10 order by ts; if $rows != 3 then return -1 endi @@ -2072,14 +2066,15 @@ endi print "ts test" -sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; + +sql select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; sql_error select * from stb1 where ts2 like '2021-05-05%'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; -sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); -sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; +sql select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; +sql select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; sql select * from stb1 where ts is null; if $rows != 0 then return -1 @@ -2125,7 +2120,7 @@ sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '202 if $rows != 29 then return -1 endi -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000'; +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000' order by ts; if $rows != 4 then return -1 endi @@ -2152,7 +2147,7 @@ if $rows != 29 then return -1 endi -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')); +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')) order by ts; if $rows != 16 then return -1 endi @@ -2160,7 +2155,7 @@ if $data00 != @21-05-05 18:19:05.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000'); +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000') order by ts; if $rows != 13 then return -1 endi @@ -2168,7 +2163,7 @@ if $data00 != @21-05-05 18:19:05.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000'); +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000') order by ts; if $rows != 10 then return -1 endi @@ -2176,7 +2171,7 @@ if $data00 != @21-05-05 18:19:01.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000'); +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000') order by ts; if $rows != 3 then return -1 endi @@ -2190,7 +2185,7 @@ if $data20 != @21-05-05 18:19:12.000@ then return -1 endi -sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18'; +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18' order by ts; if $rows != 3 then return -1 endi @@ -2205,7 +2200,7 @@ if $data20 != @21-05-05 18:19:28.000@ then endi -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25' order by ts; if $rows != 3 then return -1 endi @@ -2219,7 +2214,7 @@ if $data20 != @21-05-05 18:19:28.000@ then return -1 endi -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25' order by ts; if $rows != 3 then return -1 endi @@ -2241,7 +2236,7 @@ if $data00 != @21-05-05 18:19:24.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25' order by ts; if $rows != 25 then return -1 endi @@ -2255,7 +2250,7 @@ if $data20 != @21-05-05 18:19:06.000@ then return -1 endi -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25' order by ts; if $rows != 25 then return -1 endi @@ -2269,7 +2264,7 @@ if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25'; +sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25' order by ts; if $rows != 29 then return -1 endi @@ -2283,7 +2278,7 @@ if $data20 != @21-05-05 18:19:02.000@ then return -1 endi -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26'); +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26') order by ts; if $rows != 2 then return -1 endi @@ -2294,7 +2289,7 @@ if $data10 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26'); +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26') order by ts; if $rows != 5 then return -1 endi @@ -2315,7 +2310,7 @@ if $data40 != @21-05-05 18:19:28.000@ then endi -sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08'); +sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08') order by ts; if $rows != 3 then return -1 endi @@ -2329,7 +2324,7 @@ if $data20 != @21-05-05 18:19:07.000@ then return -1 endi -sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03'); +sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03') order by ts; if $rows != 2 then return -1 endi @@ -2340,38 +2335,38 @@ if $data10 != @21-05-05 18:19:03.000@ then return -1 endi -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000'); -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:14.000@ then - return -1 -endi +#sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000') order by a.ts; +#if $rows != 4 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:01.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:02.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:13.000@ then +# return -1 +#endi +#if $data30 != @21-05-05 18:19:14.000@ then +# return -1 +#endi +# +#sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @21-05-05 18:19:08.000@ then +# return -1 +#endi +#if $data10 != @21-05-05 18:19:09.000@ then +# return -1 +#endi +#if $data20 != @21-05-05 18:19:11.000@ then +# return -1 +#endi -sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:08.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:09.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:11.000@ then - return -1 -endi - -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000'; +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000' order by ts; if $rows != 6 then return -1 endi @@ -2394,7 +2389,7 @@ if $data50 != @21-05-05 18:19:14.000@ then return -1 endi -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000'; +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000' order by ts; if $rows != 5 then return -1 endi @@ -2415,14 +2410,14 @@ if $data40 != @21-05-05 18:19:28.000@ then endi print "tbname test" -sql_error select * from stb1 where tbname like '%3' and tbname like '%4'; +sql select * from stb1 where tbname like '%3' and tbname like '%4'; sql select * from stb1 where tbname like 'tb%'; if $rows != 29 then return -1 endi -sql select * from stb1 where tbname like '%2'; +sql select * from stb1 where tbname like '%2' order by ts; if $rows != 4 then return -1 endi @@ -2440,7 +2435,7 @@ if $data30 != @21-05-05 18:19:11.000@ then endi print "tag test" -sql select * from stb1 where t1 in (1,2) and t1 in (2,3); +sql select * from stb1 where t1 in (1,2) and t1 in (2,3) order by ts; if $rows != 4 then return -1 endi @@ -2464,7 +2459,7 @@ endi print "join test" sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts; -sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000'; +sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000' order by ts; if $rows != 2 then return -1 endi @@ -2474,7 +2469,7 @@ endi if $data10 != @21-05-05 18:19:05.000@ then return -1 endi -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5; +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5 order by ts; if $rows != 2 then return -1 endi @@ -2485,7 +2480,7 @@ if $data10 != @21-05-05 18:19:06.000@ then return -1 endi -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4; +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4 order by ts; if $rows != 2 then return -1 endi @@ -2496,7 +2491,7 @@ if $data10 != @21-05-05 18:19:07.000@ then return -1 endi -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4; +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 order by ts; if $rows != 9 then return -1 endi @@ -2528,7 +2523,7 @@ if $data80 != @21-05-05 18:19:11.000@ then return -1 endi -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4; +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4 order by ts; if $rows != 3 then return -1 endi @@ -2543,8 +2538,8 @@ if $data20 != @21-05-05 18:19:06.000@ then endi print "column&ts test" -sql_error select count(*) from stb1 where ts > 0 or c1 > 0; -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2'; +sql select count(*) from stb1 where ts > 0 or c1 > 0; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2' order by ts; if $rows != 3 then return -1 endi @@ -2559,7 +2554,7 @@ if $data20 != @21-05-05 18:19:17.000@ then endi print "column&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0; +sql select count(*) from stb1 where tbname like 'tb%' or c1 > 0; sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31; if $rows != 1 then return -1 @@ -2569,16 +2564,16 @@ if $data00 != @21-05-05 18:19:13.000@ then endi print "column&tag test" -sql_error select * from stb1 where t1 > 0 or c1 > 0 -sql_error select * from stb1 where c1 > 0 or t1 > 0 -sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 -sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 +sql select * from stb1 where t1 > 0 or c1 > 0 +sql select * from stb1 where c1 > 0 or t1 > 0 +sql select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 +sql select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 +sql select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) +sql select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1; sql select * from stb1 where c1 < 63 and t1 > 5 @@ -2591,7 +2586,7 @@ endi if $data10 != @21-05-05 18:19:25.000@ then return -1 endi -sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44; +sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44 order by ts; if $rows != 2 then return -1 endi @@ -2608,7 +2603,7 @@ endi if $data00 != @21-05-05 18:19:09.000@ then return -1 endi -sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2'; +sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2' order by ts; if $rows != 1 then return -1 endi @@ -2616,7 +2611,7 @@ if $data00 != @21-05-05 18:19:21.000@ then return -1 endi -sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4; +sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4 order by ts; if $rows != 3 then return -1 endi @@ -2639,9 +2634,9 @@ print "ts&tbname test" sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%'; print "ts&tag test" -sql_error select count(*) from stb1 where ts > 0 or t1 > 0; +sql select count(*) from stb1 where ts > 0 or t1 > 0; -sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000'; +sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000' order by ts; if $rows != 2 then return -1 endi @@ -2658,7 +2653,7 @@ sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1 print "tbname&tag test" -sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2; +sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2 order by ts; if $rows != 4 then return -1 endi @@ -2684,20 +2679,20 @@ print "tag&join test" print "column&ts&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; +sql select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; print "column&ts&tag test" -sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; -sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; +sql select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; +sql select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; -sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000'; +sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000' order by ts; if $rows != 1 then return -1 endi if $data00 != @21-05-05 18:19:26.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42; +sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42 order by ts; if $rows != 1 then return -1 endi @@ -2707,12 +2702,12 @@ endi print "column&ts&join test" print "column&tbname&tag test" -sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; +sql select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; print "column&tbname&join test" print "column&tag&join test" print "ts&tbname&tag test" -sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; +sql select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; print "ts&tbname&join test" print "ts&tag&join test" @@ -2723,7 +2718,7 @@ print "tbname&tag&join test" print "column&ts&tbname&tag test" sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0; -sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; +sql select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0; diff --git a/tests/script/tsim/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim index 82d39eff8e..101205db74 100644 --- a/tests/script/tsim/parser/nestquery.sim +++ b/tests/script/tsim/parser/nestquery.sim @@ -135,6 +135,7 @@ print ===================> nest query interval sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0); sql select _wstart, avg(c1) from (select * from nest_tb0) interval(3d) +print $data00 $data01 $data10 $data11 $data20 $data21 if $rows != 3 then return -1 endi @@ -147,19 +148,19 @@ endi if $data10 != @20-09-17 00:00:00.000@ then return -1 endi -if $data11 != 49.581325301 then +if $data11 != 49.685185185 then return -1 endi if $data20 != @20-09-20 00:00:00.000@ then return -1 endi -if $data21 != 49.703539823 then +if $data21 != 49.500000000 then return -1 endi sql select stddev(c1) from (select c1 from nest_tb0); sql_error select percentile(c1, 20) from (select * from nest_tb0); -sql_error select interp(c1) from (select * from nest_tb0); +sql select interp(c1) from (select * from nest_tb0); sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0); sql_error select twa(c1) from (select c1 from nest_tb0); sql_error select irate(c1) from (select c1 from nest_tb0); @@ -217,19 +218,14 @@ if $data00 != 0.016666667 then endi sql select derivative(c1, 1s, 0) from (select * from nest_tb0); +print $rows $data00 $data10 if $rows != 9999 then return -1 endi -if $data00 != @20-09-15 00:01:00.000@ then +if $data00 != 0.016666667 then return -1 endi -if $data01 != 0.016666667 then - return -1 -endi -if $data10 != @20-09-15 00:02:00.000@ then - return -1 -endi -if $data11 != 0.016666667 then +if $data10 != 0.016666667 then return -1 endi @@ -238,7 +234,7 @@ if $rows != 9999 then return -1 endi -sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); +sql select _wstart, avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d); if $rows != 7 then return -1 endi @@ -291,7 +287,7 @@ print ===================> group by + having print =========================> ascending order/descending order print =========================> nest query join -sql select a.ts,a.k,b.ts from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +sql select a.ts,a.k,b.ts from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; if $rows != 10000 then return -1 endi @@ -314,7 +310,7 @@ if $data12 != @20-09-15 00:01:00.000@ then return -1 endi -sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; +sql select sum(a.k), sum(b.f) from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ; if $rows != 1 then return -1 endi @@ -325,7 +321,7 @@ if $data01 != 10000 then return -1 endi -sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b, (select count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts +sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b, (select _wstart ts, count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts if $rows != 10000 then return -1 endi @@ -346,10 +342,7 @@ sql select diff(val) from (select c1 val from nest_tb0); if $rows != 9999 then return -1 endi -if $data00 != @70-01-01 08:00:00.000@ then - return -1 -endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi @@ -376,7 +369,7 @@ if $data11 != 1 then endi print =====================>TD-5157 -sql select twa(c1) from nest_tb1 interval(19a); +sql select _wstart, twa(c1) from nest_tb1 interval(19a); if $rows != 10000 then return -1 endi @@ -388,29 +381,14 @@ if $data01 != 0.000083333 then endi print ======================>TD-5271 -sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname) -if $rows != 1 then - return -1 -endi -if $data00 != 10000 then - return -1 -endi -if $data01 != 10000 then - return -1 -endi -if $data04 != 10 then - return -1 -endi -if $data05 != 100000 then - return -1 -endi +sql_error select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname) print =================>us database interval query, TD-5039 sql create database test precision 'us'; sql use test; sql create table t1(ts timestamp, k int); sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2); -sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m); +sql select _wstart, avg(k) from (select _wstart, avg(k) k from t1 interval(1s)) interval(1m); if $rows != 2 then return -1 endi @@ -427,4 +405,4 @@ if $data11 != 2.000000000 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/select_with_tags.sim b/tests/script/tsim/parser/select_with_tags.sim index 7a2c1217e9..b3247c233e 100644 --- a/tests/script/tsim/parser/select_with_tags.sim +++ b/tests/script/tsim/parser/select_with_tags.sim @@ -360,8 +360,9 @@ endi if $data04 != @abc0@ then return -1 endi - -sql select distinct tbname,t1,t2 from select_tags_mt0; +print "really this line" +sql select distinct tbname,t1,t2 from select_tags_mt0 order by tbname; +print $data00 $data01 $data02 $data10 $data111 $data12 if $row != 16 then return -1 endi @@ -390,7 +391,7 @@ if $data12 != @abc1@ then return -1 endi -sql select tbname,ts from select_tags_mt0; +sql select tbname,ts from select_tags_mt0 order by ts; if $row != 12800 then return -1 endi diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index 4d646f39e3..c4af7f3f3c 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -99,7 +99,7 @@ if $rows != 1 then endi #sql select * from information_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed @@ -197,7 +197,7 @@ if $rows != 1 then endi #sql select * from performance_schema.`streams` sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi #sql select * from information_schema.user_table_distributed diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index a0535cf93d..2573b44e19 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -498,4 +498,7 @@ if $data15 != 3 then goto loop5 endi +sql drop database test; +sql drop database test1; + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim new file mode 100644 index 0000000000..f159ac66b2 --- /dev/null +++ b/tests/script/tsim/sync/vnodeLogAnalyzeTest.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +$replica = 3 +$vgroups = 30 + +print ============= create database +sql create database db replica $replica vgroups $vgroups + +$loop_cnt = 0 +check_db_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 100 then + print ====> db not ready! + return -1 +endi +sql show databases +print ===> rows: $rows +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19] +if $rows != 3 then + return -1 +endi +if $data[2][15] != ready then + goto check_db_ready +endi + +sql use db + +$loop_cnt = 0 +check_vg_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 300 then + print ====> vgroups not ready! + return -1 +endi + +sql show vgroups +print ===> rows: $rows +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11] + +if $rows != $vgroups then + return -1 +endi + +if $data[0][4] == leader then + if $data[0][6] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][3] + endi + endi +elif $data[0][6] == leader then + if $data[0][4] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][5] + endi + endi +elif $data[0][8] == leader then + if $data[0][4] == follower then + if $data[0][6] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][7] + endi + endi +else + goto check_vg_ready +endi + + +vg_ready: +print ====> create stable/child table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb tags(1000) + + +print ===> write 1000 records +$N = 10000 +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + diff --git a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim new file mode 100644 index 0000000000..ec03aaf9db --- /dev/null +++ b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim @@ -0,0 +1,172 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +$replica = 3 +$vgroups = 1 +$retentions = 5s:7d,15s:21d + +print ============= create database +sql create database db replica $replica vgroups $vgroups retentions $retentions + +$loop_cnt = 0 +check_db_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 100 then + print ====> db not ready! + return -1 +endi +sql show databases +print ===> rows: $rows +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19] +if $rows != 3 then + return -1 +endi +if $data[2][15] != ready then + goto check_db_ready +endi + +sql use db + +$loop_cnt = 0 +check_vg_ready: +$loop_cnt = $loop_cnt + 1 +sleep 200 +if $loop_cnt == 300 then + print ====> vgroups not ready! + return -1 +endi + +sql show vgroups +print ===> rows: $rows +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11] + +if $rows != $vgroups then + return -1 +endi + +if $data[0][4] == leader then + if $data[0][6] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][3] + endi + endi +elif $data[0][6] == leader then + if $data[0][4] == follower then + if $data[0][8] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][5] + endi + endi +elif $data[0][8] == leader then + if $data[0][4] == follower then + if $data[0][6] == follower then + print ---- vgroup $data[0][0] leader locate on dnode $data[0][7] + endi + endi +else + goto check_vg_ready +endi + + +vg_ready: +print ====> create stable/child table +sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) rollup(sum) + +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb tags(1000) + + +print ===> stop dnode4 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 3000 + + +print ===> write 100 records +$N = 100 +$count = 0 +while $count < $N + $ms = 1659000000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + +#sql flush database db; + + +sleep 3000 + + +print ===> stop dnode1 dnode2 dnode3 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +sleep 10000 + +######################################################## +print ===> start dnode1 dnode2 dnode3 dnode4 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sleep 3000 + +print =============== query data +sql connect +sql use db +sql select * from ct1 +print rows: $rows +print $data00 $data01 $data02 +if $rows != 100 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/tsim/sync/vnodesnapshot-test.sim b/tests/script/tsim/sync/vnodesnapshot-test.sim index c3d8a243d3..9f4cd37b6d 100644 --- a/tests/script/tsim/sync/vnodesnapshot-test.sim +++ b/tests/script/tsim/sync/vnodesnapshot-test.sim @@ -132,7 +132,7 @@ print ===> write 100 records $N = 100 $count = 0 while $count < $N - $ms = 1591200000000 + $count + $ms = 1658924000000 + $count sql insert into ct1 values( $ms , $count , 2.1, 3.1) $count = $count + 1 endw @@ -149,7 +149,7 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT - +sleep 3000 ######################################################## print ===> start dnode1 dnode2 dnode3 dnode4 diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 83ae280721..059808e4be 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -105,7 +105,7 @@ if $rows != 1 then endi sql select * from information_schema.user_tables -if $rows != 31 then +if $rows <= 0 then return -1 endi diff --git a/tests/system-test/1-insert/delete_data.py b/tests/system-test/1-insert/delete_data.py index 1eb270d997..068d212ac4 100644 --- a/tests/system-test/1-insert/delete_data.py +++ b/tests/system-test/1-insert/delete_data.py @@ -50,9 +50,9 @@ class TDTestCase: 'col11': 'bool', 'col12': f'binary({self.str_length})', 'col13': f'nchar({self.str_length})', - + } - + self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX) @@ -100,15 +100,15 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})') elif col_type.lower() == 'bool': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') elif col_type.lower() == 'float': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') elif col_type.lower() == 'double': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})') elif 'binary' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''') elif 'nchar' in col_type.lower(): - tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1): tdSql.execute(f'delete from {tbname}') tdSql.execute(f'flush database {dbname}') @@ -164,7 +164,7 @@ class TDTestCase: elif 'nchar' in column_type.lower(): tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar']) else: - tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) + tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1): for i in range(row_num): tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}') @@ -189,7 +189,7 @@ class TDTestCase: elif tb_type == 'stb': tdSql.checkRows(i*tb_num) for j in range(tb_num): - self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) + self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for i in range(row_num): tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}') tdSql.execute(f'flush database {dbname}') @@ -240,7 +240,7 @@ class TDTestCase: tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''') else: tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}') - + def delete_data_ntb(self): tdSql.execute(f'create database if not exists {self.dbname}') tdSql.execute(f'use {self.dbname}') @@ -295,4 +295,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/influxdb_line_taosc_insert.py b/tests/system-test/1-insert/influxdb_line_taosc_insert.py index 10e81892ef..25e2378f46 100644 --- a/tests/system-test/1-insert/influxdb_line_taosc_insert.py +++ b/tests/system-test/1-insert/influxdb_line_taosc_insert.py @@ -26,13 +26,13 @@ from util.common import tdCom import platform import io if platform.system().lower() == 'windows': - sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn def createDb(self, name="test", db_update_tag=0): if db_update_tag == 0: @@ -67,7 +67,7 @@ class TDTestCase: td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) return td_ts #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) - + def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) @@ -274,7 +274,7 @@ class TDTestCase: input_sql = self.gen_influxdb_line(stb_name, tb_name, id, t0, t1, t2, t3, t4, t5, t6, t7, t8, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, ts, id_noexist_tag, id_change_tag, id_double_tag, ct_add_tag, ct_am_tag, ct_ma_tag, ct_min_tag, c_multi_tag, t_multi_tag, c_blank_tag, t_blank_tag, chinese_tag) return input_sql, stb_name - + def genMulTagColStr(self, gen_type, count): """ gen_type must be "tag"/"col" @@ -370,10 +370,10 @@ class TDTestCase: for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) self.resCmp(input_sql, stb_name) - + def symbolsCheckCase(self): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -395,7 +395,7 @@ class TDTestCase: for ts in ts_list: input_sql, stb_name = self.genFullTypeSql(ts=ts) self.resCmp(input_sql, stb_name, ts=ts) - + def idSeqCheckCase(self): """ check id.index in tags @@ -404,7 +404,7 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) self.resCmp(input_sql, stb_name) - + def idUpperCheckCase(self): """ check id param @@ -444,7 +444,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idIllegalNameCheckCase(self): """ test illegal id name @@ -490,7 +490,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self): """ check ts format like 16260068336390us19 @@ -575,11 +575,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # binary + # binary stb_name = tdCom.getLongName(7, "letters") input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16375, "letters")}" c0=f 1626006833639000000' try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -647,7 +647,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: input_sql, stb_name = self.genFullTypeSql(c5=c5) self.resCmp(input_sql, stb_name) @@ -671,11 +671,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # # # binary + # # # binary # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000' # try: # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -715,13 +715,13 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_sql in [ - self.genFullTypeSql(t1="1s2i8")[0], + self.genFullTypeSql(t1="1s2i8")[0], self.genFullTypeSql(t2="1s2i16")[0], self.genFullTypeSql(t3="1s2i32")[0], self.genFullTypeSql(t4="1s2i64")[0], self.genFullTypeSql(t5="11.1s45f32")[0], - self.genFullTypeSql(t6="11.1s45f64")[0], - self.genFullTypeSql(c1="1s2i8")[0], + self.genFullTypeSql(t6="11.1s45f64")[0], + self.genFullTypeSql(c1="1s2i8")[0], self.genFullTypeSql(c2="1s2i16")[0], self.genFullTypeSql(c3="1s2i32")[0], self.genFullTypeSql(c4="1s2i64")[0], @@ -746,14 +746,14 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000' input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + def duplicateIdTagColInsertCheckCase(self): """ check duplicate Id Tag Col @@ -810,7 +810,7 @@ class TDTestCase: self.resCmp(input_sql, stb_name) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self.resCmp(input_sql, stb_name) - + @tdCom.smlPass def tagColBinaryNcharLengthCheckCase(self): """ @@ -829,7 +829,7 @@ class TDTestCase: check column and tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -897,7 +897,7 @@ class TDTestCase: # * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2 input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}" c0=f 1626006833639000000' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}" c0=f 1626006833639000000' @@ -922,7 +922,7 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(3) - + # * tag nchar max is 16374/4, col+ts nchar max 49151 def tagColNcharMaxLengthCheckCase(self): """ @@ -977,7 +977,7 @@ class TDTestCase: "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" ] self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) - + def multiInsertCheckCase(self, count): """ test multi insert @@ -1073,7 +1073,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, result keep first data @@ -1107,7 +1107,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) - + def sStbStbDdataMtcInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1217,7 +1217,7 @@ class TDTestCase: tdSql.checkRows(6) for c in ["c7", "c8", "c9"]: tdSql.query(f"select * from {stb_name} where {c} is NULL") - tdSql.checkRows(5) + tdSql.checkRows(5) for t in ["t10", "t11"]: tdSql.query(f"select * from {stb_name} where {t} is not NULL;") tdSql.checkRows(6) diff --git a/tests/system-test/1-insert/insertWithMoreVgroup.py b/tests/system-test/1-insert/insertWithMoreVgroup.py index 80468509ee..aea0feda02 100644 --- a/tests/system-test/1-insert/insertWithMoreVgroup.py +++ b/tests/system-test/1-insert/insertWithMoreVgroup.py @@ -43,7 +43,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -69,7 +69,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -80,7 +80,7 @@ class TDTestCase: def newcur(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) cur=con.cursor() print(cur) @@ -90,7 +90,7 @@ class TDTestCase: def create_tables(self,host,dbname,stbname,count): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tsql.execute("use %s" %dbname) @@ -109,7 +109,7 @@ class TDTestCase: tsql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: # print(sql) tsql.execute(sql) @@ -122,7 +122,7 @@ class TDTestCase: def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tdLog.debug("create database %s"%dbname) tsql.execute("drop database if exists %s"%dbname) @@ -132,7 +132,7 @@ class TDTestCase: threads = [] for i in range(threadNumbers): tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) - threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) + threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) start_time = time.time() for tr in threads: tr.start() @@ -142,7 +142,7 @@ class TDTestCase: spendTime=end_time-start_time speedCreate=threadNumbers*count/spendTime tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate)) - + return # def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop): @@ -169,7 +169,7 @@ class TDTestCase: # print(sql) tsql.execute(sql) sql = "insert into %s_%d values " %(stbname,i) - # end sql + # end sql if sql != pre_insert: # print(sql) print(len(sql)) @@ -184,7 +184,7 @@ class TDTestCase: def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount): buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tdLog.debug("ready to inser data") @@ -193,7 +193,7 @@ class TDTestCase: threads = [] for i in range(threadNumbers): # tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) - threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) + threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) start_time = time.time() for tr in threads: tr.start() @@ -224,10 +224,10 @@ class TDTestCase: tdLog.info("taosd found in %s" % buildPath) taosBenchbin = buildPath+ "/build/bin/taosBenchmark" os.system("%s -f %s -y " %(taosBenchbin,jsonFile)) - + return def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count): - + # count=50000 buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" @@ -241,7 +241,7 @@ class TDTestCase: # tsql.getResult("show databases") # print(tdSql.queryResult) tsql.execute("use %s" %dbname) - + threads = [] for i in range(processNumbers): jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i) @@ -252,7 +252,7 @@ class TDTestCase: os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile)) os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile)) - threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) + threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) start_time = time.time() for tr in threads: tr.start() @@ -274,10 +274,10 @@ class TDTestCase: for i in range(stableCount): tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.checkData(0,0,rowsPerSTable) - return - - - # test case1 base + return + + + # test case1 base def test_case1(self): #stableCount=threadNumbersCtb parameterDict = {'vgroups': 1, \ @@ -290,22 +290,22 @@ class TDTestCase: 'stbname': 'stb', \ 'host': 'localhost', \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 - + tdLog.debug("-----create database and muti-thread create tables test------- ") #host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop #host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount self.mutiThread_create_tables( host=parameterDict['host'], dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], - vgroups=parameterDict['vgroups'], - threadNumbers=parameterDict['threadNumbersCtb'], + stbname=parameterDict['stbname'], + vgroups=parameterDict['vgroups'], + threadNumbers=parameterDict['threadNumbersCtb'], childcount=parameterDict['tablesPerStb']) self.mutiThread_insert_data( host=parameterDict['host'], dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], + stbname=parameterDict['stbname'], threadNumbers=parameterDict['threadNumbersIda'], chilCount=parameterDict['tablesPerStb'], ts_start=parameterDict['startTs'], @@ -315,7 +315,7 @@ class TDTestCase: rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] self.checkData(dbname=parameterDict['dbname'],stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'],CtableCount=tableCount,rowsPerSTable=rowsPerStable) - + def test_case3(self): #stableCount=threadNumbersCtb parameterDict = {'vgroups': 1, \ @@ -327,21 +327,21 @@ class TDTestCase: 'stbname': 'stb1', \ 'host': 'localhost', \ 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 - + self.taosBenchCreate( parameterDict['host'], "no", - parameterDict['dbname'], - parameterDict['stbname'], - parameterDict['vgroups'], - parameterDict['threadNumbersCtb'], + parameterDict['dbname'], + parameterDict['stbname'], + parameterDict['vgroups'], + parameterDict['threadNumbersCtb'], parameterDict['tablesPerStb']) tableCount=parameterDict['threadNumbersCtb']*parameterDict['tablesPerStb'] rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] self.checkData( dbname=parameterDict['dbname'], - stbname=parameterDict['stbname'], + stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'], CtableCount=tableCount, rowsPerSTable=rowsPerStable) @@ -353,9 +353,9 @@ class TDTestCase: # self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000) # self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000) - return + return - # run case + # run case def run(self): # create database and tables。 @@ -368,7 +368,7 @@ class TDTestCase: - return + return # # add case with filename # diff --git a/tests/system-test/1-insert/insert_drop.py b/tests/system-test/1-insert/insert_drop.py index 5ccaa5540b..bfba4c9e4a 100644 --- a/tests/system-test/1-insert/insert_drop.py +++ b/tests/system-test/1-insert/insert_drop.py @@ -38,7 +38,7 @@ class TDTestCase: tlist = self.genMultiThreadSeq(sql_list) self.multiThreadRun(tlist) tdSql.query(f'show databases') - + def stop(self): tdSql.close() diff --git a/tests/system-test/1-insert/mutipythonnodebugtaosd.py b/tests/system-test/1-insert/mutipythonnodebugtaosd.py index 3d6358f3ff..8aea53cd92 100644 --- a/tests/system-test/1-insert/mutipythonnodebugtaosd.py +++ b/tests/system-test/1-insert/mutipythonnodebugtaosd.py @@ -34,14 +34,14 @@ class TDTestCase: # # --------------- main frame ------------------- # - + def caseDescription(self): ''' limit and offset keyword function test cases; case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -68,7 +68,7 @@ class TDTestCase: self.ts = 1500000000000 - # run case + # run case def run(self): # test base case @@ -79,7 +79,7 @@ class TDTestCase: # self.test_case2() # tdLog.debug(" LIMIT test_case2 ............ [OK]") - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -101,7 +101,7 @@ class TDTestCase: tdSql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: tdSql.execute(sql) exeEndTime=time.time() @@ -113,7 +113,7 @@ class TDTestCase: def newcur(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) cur=con.cursor() print(cur) @@ -123,7 +123,7 @@ class TDTestCase: host = "127.0.0.1" buildPath = self.getBuildPath() config = buildPath+ "../sim/dnode1/cfg/" - + tsql=self.newcur(host,config) tsql.execute("drop database if exists %s" %(dbname)) tsql.execute("create database if not exists %s vgroups %d"%(dbname,vgroups)) @@ -147,7 +147,7 @@ class TDTestCase: tsql.execute(sql) sql = pre_create # print(time.time()) - # end sql + # end sql if sql != pre_create: # print(sql) tsql.execute(sql) @@ -176,7 +176,7 @@ class TDTestCase: # print(sql) tdSql.execute(sql) sql = "insert into %s_%d values " %(stbname,i) - # end sql + # end sql if sql != pre_insert: # print(sql) tdSql.execute(sql) @@ -189,7 +189,7 @@ class TDTestCase: return - # test case1 base + # test case1 base def test_case1(self): tdLog.debug("-----create database and tables test------- ") # tdSql.execute("drop database if exists db1") @@ -220,7 +220,7 @@ class TDTestCase: threads = [] threadNumbers=2 for i in range(threadNumbers): - threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,))) + threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,))) start_time = time.time() for tr in threads: tr.start() @@ -247,7 +247,7 @@ class TDTestCase: # tdSql.execute("create database db16 vgroups 16") # self.create_tables("db16", "stb16", 30*10000) - return + return # test case2 base:insert data def test_case2(self): @@ -266,7 +266,7 @@ class TDTestCase: tdSql.execute("create database db1 vgroups 1") self.create_tables("db1", "stb1", 1*100) self.insert_data("db1", "stb1", self.ts, 1*50,1*10000) - + tdSql.execute("create database db4 vgroups 4") self.create_tables("db4", "stb4", 1*100) @@ -287,7 +287,7 @@ class TDTestCase: tdSql.execute("create database db16 vgroups 16") self.create_tables("db16", "stb16", 1*100) self.insert_data("db16", "stb16", self.ts, 1*100,1*10000) - + return # @@ -296,4 +296,4 @@ class TDTestCase: # tdCases.addWindows(__file__, TDTestCase()) # tdCases.addLinux(__file__, TDTestCase()) case=TDTestCase() -case.test_case1() \ No newline at end of file +case.test_case1() diff --git a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py index f9bc5bbaf4..003abe9d10 100644 --- a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py @@ -27,13 +27,13 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn self.defaultJSONStrType_value = "NCHAR" def createDb(self, name="test", db_update_tag=0, protocol=None): if protocol == "telnet-tcp": name = "opentsdb_telnet" - + if db_update_tag == 0: tdSql.execute(f"drop database if exists {name}") tdSql.execute(f"create database if not exists {name} precision 'ms' schemaless 1") @@ -225,7 +225,7 @@ class TDTestCase: def genTagValue(self, t0_type="bool", t0_value="", t1_type="tinyint", t1_value=127, t2_type="smallint", t2_value=32767, t3_type="int", t3_value=2147483647, t4_type="bigint", t4_value=9223372036854775807, - t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789, + t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789, t7_type="binary", t7_value="binaryTagValue", t8_type="nchar", t8_value="ncharTagValue", value_type="obj"): if t0_value == "": t0_value = random.choice([True, False]) @@ -256,9 +256,9 @@ class TDTestCase: } return tag_value - def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="", + def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="", id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None, - t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, + t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, chinese_tag=None, multi_field_tag=None, point_trans_tag=None, value_type="obj"): if value_type == "obj": if stb_name == "": @@ -370,7 +370,7 @@ class TDTestCase: if point_trans_tag is not None: sql_json = {"metric": ".point.trans.test", "timestamp": ts_value, "value": col_value, "tags": tag_value} return sql_json, stb_name - + def genMulTagColDict(self, genType, count=1, value_type="obj"): """ genType must be tag/col @@ -479,10 +479,10 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def symbolsCheckCase(self, value_type="obj"): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -492,9 +492,9 @@ class TDTestCase: tdCom.cleanTb() binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = binary_symbols - input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type), + input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type), tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type)) - input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type), + input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type), tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type)) self.resCmp(input_sql1, stb_name1) self.resCmp(input_sql2, stb_name2) @@ -574,7 +574,7 @@ class TDTestCase: tdCom.cleanTb() input_json, stb_name = self.genFullTypeJson(id_change_tag=True, value_type=value_type) self.resCmp(input_json, stb_name) - + def idLetterCheckCase(self, value_type="obj"): """ check id param @@ -618,7 +618,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idIllegalNameCheckCase(self, value_type="obj"): """ test illegal id name @@ -669,7 +669,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self, value_type="obj"): """ check ts format like 16260068336390us19 @@ -726,7 +726,7 @@ class TDTestCase: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) raise Exception("should not reach here") except SchemalessError as err: - tdSql.checkNotEqual(err.errno, 0) + tdSql.checkNotEqual(err.errno, 0) def tagValueLengthCheckCase(self, value_type="obj"): """ @@ -770,11 +770,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - #i64 + #i64 for t4 in [-9223372036854775807, 9223372036854775807]: input_json, stb_name = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4, value_type=value_type)) self.resCmp(input_json, stb_name) - + for t4 in [-9223372036854775808, 9223372036854775808]: input_json = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4))[0] try: @@ -809,7 +809,7 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) if value_type == "obj": - # binary + # binary stb_name = tdCom.getLongName(7, "letters") input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': True, 'type': 'bool'}, "tags": {"t0": {'value': True, 'type': 'bool'}, "t1":{'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}}} self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -895,7 +895,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # i64 + # i64 tdCom.cleanTb() for value in [-9223372036854775808]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint", value_type=value_type)) @@ -912,7 +912,7 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 tdCom.cleanTb() for value in [-3.4028234663852885981170418348451692544*(10**38), 3.4028234663852885981170418348451692544*(10**38)]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float", value_type=value_type)) @@ -943,12 +943,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # if value_type == "obj": - # # binary + # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - + # tdCom.cleanTb() # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16375, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # try: @@ -972,7 +972,7 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) # elif value_type == "default": - # # binary + # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary": @@ -1010,12 +1010,12 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_json in [ - self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0], - self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0], + self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0], ]: try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1033,7 +1033,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_json1 = self.genFullTypeJson(col_value=self.genTsColValue(value=f"abc{symbol}aaa", t_type="binary", value_type=value_type))[0] @@ -1123,7 +1123,7 @@ class TDTestCase: check tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -1139,14 +1139,14 @@ class TDTestCase: if db_update_tag == 1 : self.resCmp(input_json, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) else: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 1, True) - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 1, True) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) self.createDb() def tagAddCheckCase(self, value_type="obj"): @@ -1216,7 +1216,7 @@ class TDTestCase: tag_value["t2"] = tdCom.getLongName(1, "letters") tag_value.pop('id') self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - + tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) if value_type == "obj": @@ -1313,7 +1313,7 @@ class TDTestCase: tdSql.checkRows(6) tdSql.query('select * from st123456') tdSql.checkRows(5) - + def multiInsertCheckCase(self, count, value_type="obj"): """ test multi insert @@ -1356,7 +1356,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def blankColInsertCheckCase(self, value_type="obj"): """ test blank col insert @@ -1382,7 +1382,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def chineseCheckCase(self): """ check nchar ---> chinese @@ -1419,7 +1419,7 @@ class TDTestCase: {"metric": f'{stb_name}_8', "timestamp": {"value": 1626006833641, "type": "mS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}, {"metric": f'{stb_name}_9', "timestamp": {"value": 1626006833642, "type": "MS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}, {"metric": f'{stb_name}_10', "timestamp": {"value": 1626006834, "type": "S"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}] - + for input_sql in input_json_list: stb_name = input_sql["metric"] self.resCmp(input_sql, stb_name) @@ -1514,7 +1514,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_json)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self, value_type="obj"): """ thread input same stb tb, different data, result keep first data @@ -1550,7 +1550,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) - + def sStbStbDdataMtInsertMultiThreadCheckCase(self, value_type="obj"): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1595,7 +1595,7 @@ class TDTestCase: ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "plgkckpv", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'), ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "cujyqvlj", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'), ({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "twjxisat", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz')] - + self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_m_tag_list)) tdSql.query(f"show tables;") tdSql.checkRows(2) @@ -1642,10 +1642,10 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rhnikvfq', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 'id': tb_name}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list)) tdSql.query(f"show tables;") @@ -1664,10 +1664,10 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list)) tdSql.query(f"show tables;") @@ -1699,10 +1699,10 @@ class TDTestCase: tdCom.cleanTb() input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) - s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), - ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), + ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), ({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_m_tag_list)) tdSql.query(f"show tables;") @@ -1713,7 +1713,7 @@ class TDTestCase: input_json = f'test_nchar 0 L"涛思数据" t0=f,t1=L"涛思数据",t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64' self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) # input_json, stb_name = self.genFullTypeJson() - # self.resCmp(input_json, stb_name) + # self.resCmp(input_json, stb_name) except SchemalessError as err: print(err.errno) diff --git a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py index 649f0101af..3c47a65746 100644 --- a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py @@ -25,19 +25,19 @@ import threading import platform import io if platform.system().lower() == 'windows': - sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self._conn = conn + self._conn = conn self.smlChildTableName_value = "id" def createDb(self, name="test", db_update_tag=0, protocol=None): if protocol == "telnet-tcp": name = "opentsdb_telnet" - + if db_update_tag == 0: tdSql.execute(f"drop database if exists {name}") tdSql.execute(f"create database if not exists {name} precision 'us' schemaless 1") @@ -66,7 +66,7 @@ class TDTestCase: td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) return td_ts #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) - + def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) @@ -191,7 +191,7 @@ class TDTestCase: tb_name = "" td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1]) td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0]) - + col_name_list.append('_value') col_value_list.append(stb_col_value) @@ -218,7 +218,7 @@ class TDTestCase: t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"", t8="L\"ncharTagValue\"", ts="1626006833641", id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None, - t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, + t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None): if stb_name == "": stb_name = tdCom.getLongName(len=6, mode="letters") @@ -268,7 +268,7 @@ class TDTestCase: if protocol == "telnet-tcp": sql_seq = 'put ' + sql_seq + '\n' return sql_seq, stb_name - + def genMulTagColStr(self, genType, count=1): """ genType must be tag/col @@ -365,10 +365,10 @@ class TDTestCase: for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) - + def symbolsCheckCase(self, protocol=None): """ - check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? + check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? """ ''' please test : @@ -424,7 +424,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def idSeqCheckCase(self, protocol=None): """ check id.index in tags @@ -434,7 +434,7 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) - + def idLetterCheckCase(self, protocol=None): """ check id param @@ -527,7 +527,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def illegalTsCheckCase(self): """ check ts format like 16260068336390us19 @@ -592,7 +592,7 @@ class TDTestCase: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) raise Exception("should not reach here") except SchemalessError as err: - tdSql.checkNotEqual(err.errno, 0) + tdSql.checkNotEqual(err.errno, 0) def tagValueLengthCheckCase(self): """ @@ -673,7 +673,7 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # f32 + # f32 tdCom.cleanTb() for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: input_sql, stb_name = self.genFullTypeSql(value=value) @@ -703,12 +703,12 @@ class TDTestCase: # except SchemalessError as err: # tdSql.checkNotEqual(err.errno, 0) - # # # binary + # # # binary # tdCom.cleanTb() # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) - + # tdCom.cleanTb() # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t' # try: @@ -748,12 +748,12 @@ class TDTestCase: # i8 i16 i32 i64 f32 f64 for input_sql in [ - self.genFullTypeSql(value="1s2i8")[0], + self.genFullTypeSql(value="1s2i8")[0], self.genFullTypeSql(value="1s2i16")[0], self.genFullTypeSql(value="1s2i32")[0], self.genFullTypeSql(value="1s2i64")[0], self.genFullTypeSql(value="11.1s45f32")[0], - self.genFullTypeSql(value="11.1s45f64")[0], + self.genFullTypeSql(value="11.1s45f64")[0], ]: try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -761,14 +761,14 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - # check accepted binary and nchar symbols + # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc{symbol}aaa" t0=t' input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=t t1="abc{symbol}aaa"' self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None) - + def blankCheckCase(self): ''' check blank case @@ -853,7 +853,7 @@ class TDTestCase: check tag count add, stb and tb duplicate * tag: alter table ... * col: when update==0 and ts is same, unchange - * so this case tag&&value will be added, + * so this case tag&&value will be added, * col is added without value when update==0 * col is added with value when update==1 """ @@ -869,14 +869,14 @@ class TDTestCase: if db_update_tag == 1 : self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) else: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') - tdSql.checkData(0, 1, True) - tdSql.checkData(0, 11, None) - tdSql.checkData(0, 12, None) + tdSql.checkData(0, 1, True) + tdSql.checkData(0, 11, None) + tdSql.checkData(0, 12, None) self.createDb() @tdCom.smlPass @@ -952,7 +952,7 @@ class TDTestCase: tdCom.cleanTb() stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') - + lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"", "st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"', @@ -970,7 +970,7 @@ class TDTestCase: tdSql.checkRows(6) tdSql.query('select * from st123456') tdSql.checkRows(5) - + def multiInsertCheckCase(self, count): """ test multi insert @@ -1014,7 +1014,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def blankColInsertCheckCase(self): """ test blank col insert @@ -1040,7 +1040,7 @@ class TDTestCase: raise Exception("should not reach here") except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) - + def chineseCheckCase(self): """ check nchar ---> chinese @@ -1210,7 +1210,7 @@ class TDTestCase: self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") tdSql.checkRows(5) - + def sStbStbDdataInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, result keep first data @@ -1248,7 +1248,7 @@ class TDTestCase: tdSql.checkEqual(tb_name, expected_tb_name) tdSql.query(f"select * from {stb_name};") tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6) - + def sStbStbDdataMtInsertMultiThreadCheckCase(self): """ thread input same stb tb, different data, minus columes and tags, result keep first data @@ -1466,7 +1466,7 @@ class TDTestCase: def run(self): print("running {}".format(__file__)) - + try: self.createDb() self.runAll() diff --git a/tests/system-test/1-insert/table_comment.py b/tests/system-test/1-insert/table_comment.py index 5b85a3964f..465179855e 100644 --- a/tests/system-test/1-insert/table_comment.py +++ b/tests/system-test/1-insert/table_comment.py @@ -42,7 +42,7 @@ class TDTestCase: self.comment_flag_list = [True,False] def __set_and_alter_comment(self,tb_type='',comment_flag= False): - + column_sql = '' tag_sql = '' for k,v in self.column_dict.items(): @@ -78,7 +78,7 @@ class TDTestCase: tdSql.execute(f'create {operation} {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]}) comment "{comment_info}"') self.check_comment_info(comment_info,'stable') self.alter_comment(self.stbname,'stable') - tdSql.execute(f'drop table {self.stbname}') + tdSql.execute(f'drop table {self.stbname}') elif tb_type == 'child_table': tdSql.execute(f'create table if not exists {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') if comment_flag == False: @@ -122,7 +122,7 @@ class TDTestCase: for flag in comment_flag: self.__set_and_alter_comment(tb,flag) tdSql.execute('drop database db') - + def run(self): self.comment_check_case(self.table_type_list,self.comment_flag_list) @@ -131,4 +131,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index 49d6476d9c..5ef6548789 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -20,7 +20,7 @@ class TDTestCase: updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3} def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor()) self.ntbname = 'ntb' self.stbname = 'stb' self.tbnum = 10 diff --git a/tests/system-test/1-insert/test_stmt_muti_insert_query.py b/tests/system-test/1-insert/test_stmt_muti_insert_query.py index 9fb802b96b..7ddc0e60bd 100644 --- a/tests/system-test/1-insert/test_stmt_muti_insert_query.py +++ b/tests/system-test/1-insert/test_stmt_muti_insert_query.py @@ -38,7 +38,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -64,7 +64,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -76,7 +76,7 @@ class TDTestCase: def newcon(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) print(con) return con @@ -126,14 +126,14 @@ class TDTestCase: end = datetime.now() print("elapsed time: ", end - start) assert stmt.affected_rows == 3 - + #query 1 querystmt=conn.statement("select ?,bu from stb1") queryparam=new_bind_params(1) print(type(queryparam)) queryparam[0].binary("ts") querystmt.bind_param(queryparam) - querystmt.execute() + querystmt.execute() result=querystmt.use_result() # rows=result.fetch_all() # print( querystmt.use_result()) @@ -152,7 +152,7 @@ class TDTestCase: print(type(queryparam1)) queryparam1[0].int(4) querystmt1.bind_param(queryparam1) - querystmt1.execute() + querystmt1.execute() result1=querystmt1.use_result() rows1=result1.fetch_all() print(rows1) @@ -176,10 +176,10 @@ class TDTestCase: host="localhost" connectstmt=self.newcon(host,config) self.test_stmt_insert_multi(connectstmt) - return + return # add case with filename # tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py index a329b475db..321dc88cd7 100644 --- a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py +++ b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py @@ -38,7 +38,7 @@ class TDTestCase: case1: limit offset base function test case2: offset return valid ''' - return + return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -64,7 +64,7 @@ class TDTestCase: # self.create_tables(); self.ts = 1500000000000 - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -76,7 +76,7 @@ class TDTestCase: def newcon(self,host,cfg): user = "root" password = "taosdata" - port =6030 + port =6030 con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) tdLog.debug(con) return con @@ -84,7 +84,7 @@ class TDTestCase: def stmtExe(self,conn,sql,bindStat): queryStat=conn.statement("%s"%sql) queryStat.bind_param(bindStat) - queryStat.execute() + queryStat.execute() result=queryStat.use_result() rows=result.fetch_all() return rows @@ -101,7 +101,7 @@ class TDTestCase: ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\ t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \ t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"%stablename) - + stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \ values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") tags = new_bind_params(16) @@ -140,13 +140,13 @@ class TDTestCase: params[14].nchar(["涛思数据", None, "a long string with 中文?字符"]) params[15].timestamp([None, None, 1626861392591]) params[16].binary(["涛思数据16", None, None]) - + stmt.bind_param_batch(params) stmt.execute() assert stmt.affected_rows == 3 - #query all + #query all queryparam=new_bind_params(1) queryparam[0].int(10) rows=self.stmtExe(conn,"select * from log where bu < ?",queryparam) @@ -189,7 +189,7 @@ class TDTestCase: #query: conversion Functions queryparam=new_bind_params(1) - queryparam[0].binary('1232a') + queryparam[0].binary('1232a') rows=self.stmtExe(conn,"select cast( ? as bigint) from log",queryparam) tdLog.debug("assert 5th case %s"%rows) assert rows[0][0] == 1232, '5th.1 case is failed' @@ -210,7 +210,7 @@ class TDTestCase: tdLog.debug("assert 7th case %s"%rows) assert rows[0][0] == 1, '7th case is failed' assert rows[1][0] == 1, '7th case is failed' - + #query: aggregate Functions queryparam=new_bind_params(1) queryparam[0].int(123) @@ -238,7 +238,7 @@ class TDTestCase: # conn.execute("drop database if exists %s" % dbname) conn.close() - + except Exception as err: # conn.execute("drop database if exists %s" % dbname) conn.close() @@ -251,10 +251,10 @@ class TDTestCase: connectstmt=self.newcon(host,config) self.test_stmt_set_tbname_tag(connectstmt) - return + return # add case with filename # tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/update_data.py b/tests/system-test/1-insert/update_data.py index 29d2a91d28..deff4b42a1 100644 --- a/tests/system-test/1-insert/update_data.py +++ b/tests/system-test/1-insert/update_data.py @@ -47,7 +47,7 @@ class TDTestCase: 'col13': f'nchar({self.str_length})', 'col_ts' : 'timestamp' } - + def data_check(self,tbname,col_name,col_type,value): tdSql.query(f'select {col_name} from {tbname}') if col_type.lower() == 'float' or col_type.lower() == 'double': @@ -121,9 +121,9 @@ class TDTestCase: tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'tinyint unsigned': for error_value in [constant.TINYINT_UN_MIN-1,constant.TINYINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') if tb_type == 'ctb': - tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'smallint unsigned': for error_value in [constant.SMALLINT_UN_MIN-1,constant.SMALLINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') @@ -136,9 +136,9 @@ class TDTestCase: tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'bigint unsigned': for error_value in [constant.BIGINT_UN_MIN-1,constant.BIGINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') if tb_type == 'ctb': - tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.execute(f'drop table {tbname}') if tb_type == 'ctb': tdSql.execute(f'drop table {stbname}') @@ -182,9 +182,9 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': self.update_and_check_data(tbname,col_name,col_type,up_unbigint,dbname) elif col_type.lower() == 'bool': - self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname) + self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname) elif col_type.lower() == 'float': - self.update_and_check_data(tbname,col_name,col_type,up_float,dbname) + self.update_and_check_data(tbname,col_name,col_type,up_float,dbname) elif col_type.lower() == 'double': self.update_and_check_data(tbname,col_name,col_type,up_double,dbname) elif 'binary' in col_type.lower(): @@ -248,10 +248,10 @@ class TDTestCase: self.update_check() self.update_check_error() # i+=1 - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/update_data_muti_rows.py b/tests/system-test/1-insert/update_data_muti_rows.py index e7da35426a..623dc497ea 100644 --- a/tests/system-test/1-insert/update_data_muti_rows.py +++ b/tests/system-test/1-insert/update_data_muti_rows.py @@ -87,7 +87,7 @@ class TDTestCase: sql += f'({self.ts+i},{values})' sql += ' ' tdSql.execute(sql) - + def insert_data(self,col_type,tbname,rows,data): for i in range(rows): if col_type.lower() == 'tinyint': @@ -107,16 +107,16 @@ class TDTestCase: elif col_type.lower() == 'bigint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint unsigned"]})') elif col_type.lower() == 'bool': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') elif col_type.lower() == 'float': - tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') elif col_type.lower() == 'double': tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["double"]})') elif 'binary' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['binary']}")''') elif 'nchar' in col_type.lower(): - tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') - + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') + def data_check(self,dbname,tbname,tbnum,rownum,data,col_name,col_type): if 'binary' in col_type.lower(): self.update_data(dbname,f'{tbname}',tbnum,rownum,data['binary'],col_type) @@ -170,10 +170,10 @@ class TDTestCase: self.update_data_ntb() self.update_data_ctb() - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/distribute_agg_apercentile.py b/tests/system-test/2-query/distribute_agg_apercentile.py index 1fd853f9eb..ad754ad805 100644 --- a/tests/system-test/2-query/distribute_agg_apercentile.py +++ b/tests/system-test/2-query/distribute_agg_apercentile.py @@ -141,8 +141,8 @@ class TDTestCase: query_data = tdSql.queryResult # nest query for support max - tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") - tdSql.checkData(0,0,31.000000000) + #tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") + #tdSql.checkData(0,0,31.000000000) tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.checkData(0,0,7.560701700) tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") diff --git a/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py new file mode 100644 index 0000000000..48ee90fad2 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeRecreateMnode.py @@ -0,0 +1,246 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +from numpy import row_stack +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +sys.path.append("./6-cluster") +from clusterCommonCreate import * +from clusterCommonCheck import clusterComCheck + +import time +import socket +import subprocess +from multiprocessing import Process +import threading +import time +import inspect +import ctypes + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + self.TDDnodes = None + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def _async_raise(self, tid, exctype): + """raises the exception, performs cleanup if needed""" + if not inspect.isclass(exctype): + exctype = type(exctype) + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) + if res == 0: + raise ValueError("invalid thread id") + elif res != 1: + # """if it returns a number greater than one, you're in trouble, + # and you should call it again with exc=NULL to revert the effect""" + ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) + raise SystemError("PyThreadState_SetAsyncExc failed") + + def stopThread(self,thread): + self._async_raise(thread.ident, SystemExit) + + + def insertData(self,countstart,countstop): + # fisrt add data : db\stable\childtable\general table + + for couti in range(countstart,countstop): + tdLog.debug("drop database if exists db%d" %couti) + tdSql.execute("drop database if exists db%d" %couti) + print("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("use db%d" %couti) + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + + def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'stbNumbers': 2, + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 200, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + "rowsPerTbl": 100, + "batchNum": 5000 + } + username="user1" + passwd="123" + + dnodeNumbers=int(dnodeNumbers) + mnodeNums=int(mnodeNums) + vnodeNumbers = int(dnodeNumbers-mnodeNums) + allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"]) + rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] + rowsall=rowsPerStb*paraDict['stbNumbers'] + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodeNumbers) + + # recreate mnode + tdSql.execute("drop dnode 2;") + tdSql.execute('create dnode "%s:6130";'%self.host) + tdDnodes=cluster.dnodes + tdDnodes[1].stoptaosd() + tdDnodes[1].deploy() + + tdDnodes[1].starttaosd() + clusterComCheck.checkDnodes(dnodeNumbers) + + tdSql.execute("create mnode on dnode 6") + tdSql.error("drop dnode 1;") + + # check status of clusters + clusterComCheck.checkMnodeStatus(3) + tdSql.execute("create user %s pass '%s' ;"%(username,passwd)) + tdSql.query("show users") + for i in range(tdSql.queryRows): + if tdSql.queryResult[i][0] == "%s"%username : + tdLog.info("create user:%s successfully"%username) + + # # create database and stable + # clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + # tdLog.info("Take turns stopping Mnodes ") + + # tdDnodes=cluster.dnodes + # stopcount =0 + # threads=[] + + # # create stable:stb_0 + # stableName= paraDict['stbName'] + # newTdSql=tdCom.newTdSql() + # clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']) + # #create child table:ctb_0 + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # newTdSql=tdCom.newTdSql() + # clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum']) + # #insert date + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # newTdSql=tdCom.newTdSql() + # threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) + # for tr in threads: + # tr.start() + # for tr in threads: + # tr.join() + + # while stopcount < restartNumbers: + # tdLog.info(" restart loop: %d"%stopcount ) + # if stopRole == "mnode": + # for i in range(mnodeNums): + # tdDnodes[i].stoptaosd() + # # sleep(10) + # tdDnodes[i].starttaosd() + # # sleep(10) + # elif stopRole == "vnode": + # for i in range(vnodeNumbers): + # tdDnodes[i+mnodeNums].stoptaosd() + # # sleep(10) + # tdDnodes[i+mnodeNums].starttaosd() + # # sleep(10) + # elif stopRole == "dnode": + # for i in range(dnodeNumbers): + # tdDnodes[i].stoptaosd() + # # sleep(10) + # tdDnodes[i].starttaosd() + # # sleep(10) + + # # dnodeNumbers don't include database of schema + # if clusterComCheck.checkDnodes(dnodeNumbers): + # tdLog.info("dnode is ready") + # else: + # print("dnodes is not ready") + # self.stopThread(threads) + # tdLog.exit("one or more of dnodes failed to start ") + # # self.check3mnode() + # stopcount+=1 + + + # clusterComCheck.checkDnodes(dnodeNumbers) + # clusterComCheck.checkDbRows(dbNumbers) + # # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) + + # tdSql.execute("use %s" %(paraDict["dbName"])) + # tdSql.query("show stables") + # tdSql.checkRows(paraDict["stbNumbers"]) + # # for i in range(paraDict['stbNumbers']): + # # stableName= '%s_%d'%(paraDict['stbName'],i) + # # tdSql.query("select * from %s"%stableName) + # # tdSql.checkRows(rowsPerStb) + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py index 587049e44e..8ae09dce16 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertData.py @@ -190,10 +190,9 @@ class TDTestCase: # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): - tdLog.info("123") + tdLog.info("dnode is ready") else: - print("456") - + print("dnodes is not ready") self.stopThread(threads) tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() @@ -207,10 +206,11 @@ class TDTestCase: tdSql.execute("use %s" %(paraDict["dbName"])) tdSql.query("show stables") tdSql.checkRows(paraDict["stbNumbers"]) - for i in range(paraDict['stbNumbers']): - stableName= '%s_%d'%(paraDict['stbName'],i) - tdSql.query("select * from %s"%stableName) - tdSql.checkRows(rowsPerStb) + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # tdSql.query("select * from %s"%stableName) + # tdSql.checkRows(rowsPerStb) + def run(self): # print(self.master_dnode.cfgDict) self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') diff --git a/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py new file mode 100644 index 0000000000..87d108cdeb --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py @@ -0,0 +1,224 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +from numpy import row_stack +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +sys.path.append("./6-cluster") +from clusterCommonCreate import * +from clusterCommonCheck import clusterComCheck + +import time +import socket +import subprocess +from multiprocessing import Process +import threading +import time +import inspect +import ctypes + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + self.TDDnodes = None + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def _async_raise(self, tid, exctype): + """raises the exception, performs cleanup if needed""" + if not inspect.isclass(exctype): + exctype = type(exctype) + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) + if res == 0: + raise ValueError("invalid thread id") + elif res != 1: + # """if it returns a number greater than one, you're in trouble, + # and you should call it again with exc=NULL to revert the effect""" + ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) + raise SystemError("PyThreadState_SetAsyncExc failed") + + def stopThread(self,thread): + self._async_raise(thread.ident, SystemExit) + + + def insertData(self,countstart,countstop): + # fisrt add data : db\stable\childtable\general table + + for couti in range(countstart,countstop): + tdLog.debug("drop database if exists db%d" %couti) + tdSql.execute("drop database if exists db%d" %couti) + print("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti) + tdSql.execute("use db%d" %couti) + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t1 int) + ''' + ) + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + + def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'stbNumbers': 2, + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 200, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + "rowsPerTbl": 100, + "batchNum": 5000 + } + + dnodeNumbers=int(dnodeNumbers) + mnodeNums=int(mnodeNums) + vnodeNumbers = int(dnodeNumbers-mnodeNums) + allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"]) + rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] + rowsall=rowsPerStb*paraDict['stbNumbers'] + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodeNumbers) + + # create database and stable + clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + tdLog.info("Take turns stopping Mnodes ") + + tdDnodes=cluster.dnodes + stopcount =0 + threads=[] + + # create stable:stb_0 + stableName= paraDict['stbName'] + newTdSql=tdCom.newTdSql() + clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']) + #create child table:ctb_0 + for i in range(paraDict['stbNumbers']): + stableName= '%s_%d'%(paraDict['stbName'],i) + newTdSql=tdCom.newTdSql() + clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum']) + #insert date + for i in range(paraDict['stbNumbers']): + stableName= '%s_%d'%(paraDict['stbName'],i) + newTdSql=tdCom.newTdSql() + threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) + for tr in threads: + tr.start() + + + while stopcount < restartNumbers: + tdLog.info(" restart loop: %d"%stopcount ) + if stopRole == "mnode": + for i in range(mnodeNums): + tdDnodes[i].stoptaosd() + # sleep(10) + tdDnodes[i].starttaosd() + # sleep(10) + elif stopRole == "vnode": + for i in range(vnodeNumbers): + tdDnodes[i+mnodeNums].stoptaosd() + # sleep(10) + tdDnodes[i+mnodeNums].starttaosd() + # sleep(10) + elif stopRole == "dnode": + for i in range(dnodeNumbers): + tdDnodes[i].stoptaosd() + # sleep(10) + tdDnodes[i].starttaosd() + # sleep(10) + + # dnodeNumbers don't include database of schema + if clusterComCheck.checkDnodes(dnodeNumbers): + tdLog.info("dnode is ready") + else: + print("dnodes is not ready") + self.stopThread(threads) + tdLog.exit("one or more of dnodes failed to start ") + # self.check3mnode() + stopcount+=1 + + for tr in threads: + tr.join() + + clusterComCheck.checkDnodes(dnodeNumbers) + clusterComCheck.checkDbRows(dbNumbers) + # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) + + tdSql.execute("use %s" %(paraDict["dbName"])) + tdSql.query("show stables") + tdSql.checkRows(paraDict["stbNumbers"]) + # for i in range(paraDict['stbNumbers']): + # stableName= '%s_%d'%(paraDict['stbName'],i) + # tdSql.query("select * from %s"%stableName) + # tdSql.checkRows(rowsPerStb) + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py index 1788f24c3f..d39bae68f9 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py +++ b/tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py @@ -98,8 +98,10 @@ class TDTestCase: # fisr add three mnodes; tdLog.info("fisr add three mnodes and check mnode status") + tdSql.info("create mnode on dnode 2") tdSql.execute("create mnode on dnode 2") clusterComCheck.checkMnodeStatus(2) + tdSql.info("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3") clusterComCheck.checkMnodeStatus(3) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py index 954e1ae003..fef26333b7 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop2Follower.py @@ -68,7 +68,7 @@ class TDTestCase: 'showRow': 1} dnodenumbers=int(dnodenumbers) mnodeNums=int(mnodeNums) - dbNumbers = int(dnodenumbers * restartNumber) + dbNumbers = 1 tdLog.info("first check dnode and mnode") tdSql.query("show dnodes;") @@ -104,7 +104,7 @@ class TDTestCase: tdDnodes[1].starttaosd() tdDnodes[2].starttaosd() - clusterComCheck.checkMnodeStatus(3) + clusterComCheck.checkMnodeStatus(mnodeNums) def run(self): diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py index 247bd29ed9..f1eb2a4587 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStopConnect.py @@ -111,14 +111,14 @@ class TDTestCase: # seperate vnode and mnode in different dnodes. # create database and stable stopcount =0 - while stopcount <= 2: + while stopcount < restartNumber: tdLog.info("first restart loop") for i in range(dnodenumbers): tdDnodes[i].stoptaosd() tdDnodes[i].starttaosd() stopcount+=1 clusterComCheck.checkDnodes(dnodenumbers) - clusterComCheck.checkMnodeStatus(3) + clusterComCheck.checkMnodeStatus(mnodeNums) def run(self): # print(self.master_dnode.cfgDict) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py new file mode 100644 index 0000000000..59a1a8f697 --- /dev/null +++ b/tests/system-test/6-cluster/5dnode3mnodeStopFollowerLeader.py @@ -0,0 +1,122 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * +from test import tdDnodes +sys.path.append("./6-cluster") + +from clusterCommonCreate import * +from clusterCommonCheck import * +import time +import socket +import subprocess +from multiprocessing import Process + + +class TDTestCase: + + def init(self,conn ,logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + self.host = socket.gethostname() + + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def fiveDnodeThreeMnode(self,dnodenumbers,mnodeNums,restartNumber): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db0_0', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'replica': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + dnodenumbers=int(dnodenumbers) + mnodeNums=int(mnodeNums) + dbNumbers = 1 + + tdLog.info("first check dnode and mnode") + tdSql.query("show dnodes;") + tdSql.checkData(0,1,'%s:6030'%self.host) + tdSql.checkData(4,1,'%s:6430'%self.host) + clusterComCheck.checkDnodes(dnodenumbers) + clusterComCheck.checkMnodeStatus(1) + + # fisr add three mnodes; + tdLog.info("fisr add three mnodes and check mnode status") + tdSql.execute("create mnode on dnode 2") + clusterComCheck.checkMnodeStatus(2) + tdSql.execute("create mnode on dnode 3") + clusterComCheck.checkMnodeStatus(3) + + # add some error operations and + tdLog.info("Confirm the status of the dnode again") + tdSql.error("create mnode on dnode 2") + tdSql.query("show dnodes;") + # print(tdSql.queryResult) + clusterComCheck.checkDnodes(dnodenumbers) + # restart all taosd + tdDnodes=cluster.dnodes + tdLog.info("stop two mnode ") + + tdDnodes[0].stoptaosd() + tdDnodes[1].stoptaosd() + + # tdLog.info("check whether 2 mnode status is offline") + # clusterComCheck.check3mnode2off() + # tdSql.error("create user user1 pass '123';") + + tdLog.info("start one mnode" ) + tdDnodes[0].starttaosd() + clusterComCheck.check3mnodeoff(2) + + clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) + clusterComCheck.checkDb(dbNumbers,1,'db0') + + + + def run(self): + # print(self.master_dnode.cfgDict) + self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/clusterCommonCheck.py b/tests/system-test/6-cluster/clusterCommonCheck.py index 7ed1322b53..b758e6e71f 100644 --- a/tests/system-test/6-cluster/clusterCommonCheck.py +++ b/tests/system-test/6-cluster/clusterCommonCheck.py @@ -55,6 +55,7 @@ class ClusterComCheck: count+=1 time.sleep(1) else: + tdSql.query("show dnodes") tdLog.debug(tdSql.queryResult) tdLog.exit("it find cluster with %d dnodes but check that there dnodes are not ready within 30s ! "%dnodeNumbers) @@ -111,7 +112,7 @@ class ClusterComCheck: def checkMnodeStatus(self,mnodeNums): self.mnodeNums=int(mnodeNums) # self.leaderDnode=int(leaderDnode) - + tdLog.debug("start to check status of mnodes") count=0 while count < 10: diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 00b0aed5ee..2a819f8106 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -43,9 +43,9 @@ class TDTestCase: tdLog.exit("compare error: %s != %s"%src, dst) else: break - + tdSql.execute('use db_taosx') - tdSql.query("select * from ct3 order by c1 desc") + tdSql.query("select * from ct3 order by c1 desc") tdSql.checkRows(2) tdSql.checkData(0, 1, 51) tdSql.checkData(0, 4, 940) @@ -58,17 +58,17 @@ class TDTestCase: tdSql.query("select * from ct2") tdSql.checkRows(0) - tdSql.query("select * from ct0 order by c1") + tdSql.query("select * from ct0 order by c1 ") tdSql.checkRows(2) tdSql.checkData(0, 3, "a") tdSql.checkData(1, 4, None) - tdSql.query("select * from n1 order by cc3 desc") + tdSql.query("select * from n1 order by ts") tdSql.checkRows(2) tdSql.checkData(0, 1, "eeee") tdSql.checkData(1, 2, 940) - tdSql.query("select * from jt order by i desc") + tdSql.query("select * from jt order by i desc;") tdSql.checkRows(2) tdSql.checkData(0, 1, 11) tdSql.checkData(0, 2, None) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 0f72eaa172..458951b815 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -164,6 +164,7 @@ python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 2-query/max_partition.py python3 ./test.py -f 2-query/last_row.py +python3 ./test.py -f 2-query/tsbsQuery.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 @@ -171,14 +172,15 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 +# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 -# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertDataAsync.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartMnodeInsertData.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartVnodeInsertData.py -N 5 -M 3 @@ -187,6 +189,11 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeRecreateMnode.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStopFollowerLeader.py -N 5 -M 3 +python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3 + + python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/subscribeDb.py @@ -216,7 +223,7 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py -python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py +# python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py @@ -332,7 +339,7 @@ python3 ./test.py -f 2-query/function_null.py -Q 2 python3 ./test.py -f 2-query/count_partition.py -Q 2 python3 ./test.py -f 2-query/max_partition.py -Q 2 python3 ./test.py -f 2-query/last_row.py -Q 2 - +python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 #------------querPolicy 3----------- python3 ./test.py -f 2-query/between.py -Q 3 @@ -419,3 +426,4 @@ python3 ./test.py -f 2-query/function_null.py -Q 3 python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3 +python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 \ No newline at end of file diff --git a/tests/system-test/simpletest.bat b/tests/system-test/simpletest.bat index e33fe0d538..656828aa1e 100644 --- a/tests/system-test/simpletest.bat +++ b/tests/system-test/simpletest.bat @@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py python3 .\test.py -f 0-others\taosdMonitor.py python3 .\test.py -f 0-others\udfTest.py python3 .\test.py -f 0-others\udf_create.py -@REM python3 .\test.py -f 0-others\udf_restart_taosd.py +python3 .\test.py -f 0-others\udf_restart_taosd.py @REM python3 .\test.py -f 0-others\cachelast.py @REM python3 .\test.py -f 0-others\user_control.py diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 2dc5870c4a..488b623f89 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -24,4 +24,7 @@ target_include_directories( PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) +IF (TD_LINUX_64 AND JEMALLOC_ENABLED) + add_dependencies(taosd jemalloc) +ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)