diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 37dd448b87..48f31c6daf 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 6a2d9fc + GIT_TAG e04f39b SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp index 942130d4fa..a90477880f 100644 Binary files a/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp and b/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp differ diff --git a/docs/en/14-reference/07-tdinsight/index.md b/docs/en/14-reference/07-tdinsight/index.md index 1c58dd6a76..652d5ded0b 100644 --- a/docs/en/14-reference/07-tdinsight/index.md +++ b/docs/en/14-reference/07-tdinsight/index.md @@ -326,11 +326,12 @@ Currently, only the number of logins per minute is reported. Support monitoring taosAdapter request statistics and status details. Includes. -1. **http_request_inflight**: number of real-time requests. -2. **http_request_total**: number of total requests. -3. **http_request_fail**: number of failed requets. -4. **CPU Used**: CPU usage of taosAdapter. -5. **Memory Used**: Memory usage of taosAdapter. +1. **Http Request Total**: number of total requests. +2. **Http Request Fail**: number of failed requests. +3. **CPU Used**: CPU usage of taosAdapter. +4. **Memory Used**: Memory usage of taosAdapter. +5. **Http Request Inflight**: number of real-time requests. +6. **Http Status Code**: taosAdapter http status code. ## Upgrade diff --git a/docs/en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx index b33e1c1199..5a2942b144 100644 --- a/docs/en/20-third-party/01-grafana.mdx +++ b/docs/en/20-third-party/01-grafana.mdx @@ -156,13 +156,13 @@ You can setup a zero-configuration stack for TDengine + Grafana by [docker-compo services: tdengine: - image: tdengine/tdengine:2.6.0.2 + image: tdengine/tdengine:3.0.2.4 environment: TAOS_FQDN: tdengine volumes: - tdengine-data:/var/lib/taos/ grafana: - image: grafana/grafana:8.5.6 + image: grafana/grafana:9.3.6 volumes: - ./tdengine.yml/:/etc/grafana/provisioning/tdengine.yml - grafana-data:/var/lib/grafana @@ -197,11 +197,18 @@ As shown above, select the `TDengine` data source in the `Query` and enter the c - INPUT SQL: Enter the desired query (the results being two columns and multiple rows), such as `select _wstart, avg(mem_system) from log.dnodes_info where ts >= $from and ts < $to interval($interval)`. In this statement, $from, $to, and $interval are variables that Grafana replaces with the query time range and interval. In addition to the built-in variables, custom template variables are also supported. - ALIAS BY: This allows you to set the current query alias. - GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement. +- Group by column name(s): `group by` or `partition by` columns name split by comma. By setting `Group by column name(s)`, it can show multi-dimension data if Sql is `group by` or `partition by`. Such as, it can show data by `dnode_ep` if sql is `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)` and `Group by column name(s)` is `dnode_ep`. +- Format to: format legend for `group by` or `partition by`. Such as it can display series data by `dnode_ep` if sql is `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)` and `Group by column name(s)` is `dnode_ep` and `Format to` is `mem_system_{{dnode_ep}}`. Follow the default prompt to query the average system memory usage for the specified interval on the server where the current TDengine deployment is located as follows. ![TDengine Database TDinsight plugin create dashboard 2](./grafana/create_dashboard2.webp) +查询每台 TDengine 服务器指定间隔系统内存平均使用量如下. +The example to query the average system memory usage for the specified interval on each server as follows. + +![TDengine Database TDinsight plugin create dashboard 2](./grafana/create_dashboard3.webp) + > For more information on how to use Grafana to create the appropriate monitoring interface and for more details on using Grafana, refer to the official Grafana [documentation](https://grafana.com/docs/). ### Importing the Dashboard diff --git a/docs/en/20-third-party/grafana/create_dashboard1.webp b/docs/en/20-third-party/grafana/create_dashboard1.webp index 55eb388833..df41d66d50 100644 Binary files a/docs/en/20-third-party/grafana/create_dashboard1.webp and b/docs/en/20-third-party/grafana/create_dashboard1.webp differ diff --git a/docs/en/20-third-party/grafana/create_dashboard2.webp b/docs/en/20-third-party/grafana/create_dashboard2.webp index bb40e40718..ba50f52996 100644 Binary files a/docs/en/20-third-party/grafana/create_dashboard2.webp and b/docs/en/20-third-party/grafana/create_dashboard2.webp differ diff --git a/docs/en/20-third-party/grafana/create_dashboard3.webp b/docs/en/20-third-party/grafana/create_dashboard3.webp new file mode 100644 index 0000000000..84f387f87b Binary files /dev/null and b/docs/en/20-third-party/grafana/create_dashboard3.webp differ diff --git a/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp index 942130d4fa..a90477880f 100644 Binary files a/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp and b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp differ diff --git a/docs/zh/14-reference/07-tdinsight/index.mdx b/docs/zh/14-reference/07-tdinsight/index.mdx index 7f4c46a636..8ec11378ee 100644 --- a/docs/zh/14-reference/07-tdinsight/index.mdx +++ b/docs/zh/14-reference/07-tdinsight/index.mdx @@ -345,11 +345,12 @@ TDinsight 仪表盘旨在提供 TDengine 相关资源的使用情况和状态, 支持监控 taosAdapter 请求统计和状态详情。包括: -1. **http_request_inflight**: 即时处理请求数 -2. **http_request_total**: 请求总数。 -3. **http_request_fail**: 请求总数。 -4. **CPU Used**: taosAdapter CPU 使用情况。 -5. **Memory Used**: taosAdapter 内存使用情况。 +1. **Http Request Total**: 请求总数。 +2. **Http Request Fail**: 请求总数。 +3. **CPU Used**: taosAdapter CPU 使用情况。 +4. **Memory Used**: taosAdapter 内存使用情况。 +5. **Http Request Inflight**: 即时处理请求数。 +6. **Http Status Code**: taosAdapter http 状态码。 ## 升级 diff --git a/docs/zh/20-third-party/01-grafana.mdx b/docs/zh/20-third-party/01-grafana.mdx index d5cfe847ca..5927dc4fca 100644 --- a/docs/zh/20-third-party/01-grafana.mdx +++ b/docs/zh/20-third-party/01-grafana.mdx @@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource 或者从 [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) 或 [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) 下载 .zip 文件到本地并解压到 Grafana 插件目录。命令行下载示例如下: ```bash -GF_VERSION=3.2.7 +GF_VERSION=3.2.9 # from GitHub wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip # from Grafana @@ -156,13 +156,13 @@ docker run -d \ services: tdengine: - image: tdengine/tdengine:2.6.0.2 + image: tdengine/tdengine:3.0.2.4 environment: TAOS_FQDN: tdengine volumes: - tdengine-data:/var/lib/taos/ grafana: - image: grafana/grafana:8.5.6 + image: grafana/grafana:9.3.6 volumes: - ./tdengine.yml/:/etc/grafana/provisioning/tdengine.yml - grafana-data:/var/lib/grafana @@ -197,11 +197,17 @@ docker run -d \ - INPUT SQL:输入要查询的语句(该 SQL 语句的结果集应为两列多行),例如:`select _wstart, avg(mem_system) from log.dnodes_info where ts >= $from and ts < $to interval($interval)` ,其中,from、to 和 interval 为 TDengine 插件的内置变量,表示从 Grafana 插件面板获取的查询范围和时间间隔。除了内置变量外,`也支持可以使用自定义模板变量`。 - ALIAS BY:可设置当前查询别名。 - GENERATE SQL: 点击该按钮会自动替换相应变量,并生成最终执行的语句。 +- Group by column name(s): **半角**逗号分隔的 `group by` 或 `partition by` 列名。如果是 `group by` or `partition by` 查询语句,设置 `Group by` 列,可以展示多维数据。例如:INPUT SQL 为 `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)`,设置 Group by 列名为 `dnode_ep`,可以按 `dnode_ep` 展示数据。 +- Format to: Group by 或 Partition by 场景下多维数据 legend 格式化格式。例如上述 INPUT SQL,将 Format to 设置为 `mem_system_{{dnode_ep}}`,展示的 legend 名字为格式化的列名。 按照默认提示查询当前 TDengine 部署所在服务器指定间隔系统内存平均使用量如下: ![TDengine Database Grafana plugin create dashboard](./create_dashboard2.webp) +查询每台 TDengine 服务器指定间隔系统内存平均使用量如下: + +![TDengine Database Grafana plugin create dashboard](./create_dashboard3.webp) + > 关于如何使用 Grafana 创建相应的监测界面以及更多有关使用 Grafana 的信息,请参考 Grafana 官方的[文档](https://grafana.com/docs/)。 ### 导入 Dashboard diff --git a/docs/zh/20-third-party/create_dashboard1.webp b/docs/zh/20-third-party/create_dashboard1.webp index 55eb388833..df41d66d50 100644 Binary files a/docs/zh/20-third-party/create_dashboard1.webp and b/docs/zh/20-third-party/create_dashboard1.webp differ diff --git a/docs/zh/20-third-party/create_dashboard2.webp b/docs/zh/20-third-party/create_dashboard2.webp index bb40e40718..ba50f52996 100644 Binary files a/docs/zh/20-third-party/create_dashboard2.webp and b/docs/zh/20-third-party/create_dashboard2.webp differ diff --git a/docs/zh/20-third-party/create_dashboard3.webp b/docs/zh/20-third-party/create_dashboard3.webp new file mode 100644 index 0000000000..84f387f87b Binary files /dev/null and b/docs/zh/20-third-party/create_dashboard3.webp differ diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index dfdbaa6fdd..5aeff0e2fa 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -35,6 +35,20 @@ dumpName="taosdump" demoName="taosdemo" xname="taosx" +clientName2="taos" +serverName2="taosd" +productName2="TDengine" +emailName2="taosdata.com" + +benchmarkName2="${clientName2}Benchmark" +dumpName2="${clientName2}dump" +uninstallScript2="rm${clientName2}" + +historyFile="${clientName2}_history" +logDir="/var/log/${clientName2}" +configDir="/etc/${clientName2}" +installDir="/usr/local/${clientName}" + data_dir=${dataDir} log_dir=${logDir} cfg_install_dir=${configDir} @@ -217,6 +231,13 @@ function install_bin() { [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + + if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName2} || : + [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName2} || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : + fi } function install_lib() { @@ -518,7 +539,7 @@ function install_config() { local_fqdn_check echo - echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}" + echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName2}:6030) of an existing ${productName2} cluster node to join${NC}" echo echo -e -n "${GREEN}OR leave it blank to build one${NC}:" read firstEp @@ -655,6 +676,9 @@ function clean_service_on_systemd() { fi ${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null ${csudo}rm -f ${tarbitratord_service_config} + # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + # ${csudo}rm -f ${service_config_dir}/${serverName2}.service + # fi } function install_service_on_systemd() { @@ -663,6 +687,13 @@ function install_service_on_systemd() { [ -f ${script_dir}/cfg/${serverName}.service ] && ${csudo}cp ${script_dir}/cfg/${serverName}.service \ ${service_config_dir}/ || : + + # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + # [ -f ${script_dir}/cfg/${serverName}.service ] && + # ${csudo}cp ${script_dir}/cfg/${serverName}.service \ + # ${service_config_dir}/${serverName2}.service || : + # fi + ${csudo}systemctl daemon-reload ${csudo}systemctl enable ${serverName} @@ -793,7 +824,7 @@ function updateProduct() { tar -zxf ${tarName} install_jemalloc - echo -e "${GREEN}Start to update ${productName}...${NC}" + echo -e "${GREEN}Start to update ${productName2}...${NC}" # Stop the service if running if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then if ((${service_mod} == 0)); then @@ -830,25 +861,25 @@ function updateProduct() { echo echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure Taos Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure Adapter ${NC}: edit ${configDir}/taosadapter.toml" if ((${service_mod} == 0)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}" elif ((${service_mod} == 1)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}service taosadapter start${NC}" else echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}" [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${clientName} Adapter ${NC}: taosadapter &${NC}" fi if [ ${openresty_work} = 'true' ]; then - echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}" + echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}" else - echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell${NC}" + echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}" fi if ((${prompt_force} == 1)); then @@ -856,13 +887,13 @@ function updateProduct() { echo -e "${RED}Please run '${serverName} --force-keep-file' at first time for the exist ${productName} $exist_version!${NC}" fi echo - echo -e "\033[44;32;1m${productName} is updated successfully!${NC}" + echo -e "\033[44;32;1m${productName2} is updated successfully!${NC}" else install_bin install_config echo - echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}" + echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" fi rm -rf $(tar -tf ${tarName} | grep -v "^\./$") @@ -876,7 +907,7 @@ function installProduct() { fi tar -zxf ${tarName} - echo -e "${GREEN}Start to install ${productName}...${NC}" + echo -e "${GREEN}Start to install ${productName2}...${NC}" install_main_path @@ -965,7 +996,7 @@ serverFqdn=$(hostname) if [ "$verType" == "server" ]; then # Check default 2.x data file. if [ -x ${data_dir}/dnode/dnodeCfg.json ]; then - echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of tdengine 2.x, please clear it before installing!\033[0m" + echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m" else # Install server and client if [ -x ${bin_dir}/${serverName} ]; then diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index f7d677c982..1543c59297 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -23,6 +23,16 @@ osType=Linux pagMode=full verMode=edge +clientName2="taos" +serverName2="taosd" +productName2="TDengine" +emailName2="taosdata.com" + +benchmarkName2="${clientName2}Benchmark" +dumpName2="${clientName2}dump" +demoName2="${clientName2}demo" +uninstallScript2="rm${clientName2}" + if [ "$osType" != "Darwin" ]; then script_dir=$(dirname $(readlink -f "$0")) # Dynamic directory @@ -112,6 +122,15 @@ function install_bin() { fi [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + + if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + #Make link + [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || : + if [ "$osType" != "Darwin" ]; then + [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/${demoName2} || : + fi + [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript2} || : + fi } function clean_lib() { @@ -263,9 +282,9 @@ function update_TDengine() { exit 1 fi tar -zxf ${tarName} - echo -e "${GREEN}Start to update ${productName} client...${NC}" + echo -e "${GREEN}Start to update ${productName2} client...${NC}" # Stop the client shell if running - if ps aux | grep -v grep | grep ${clientName} &> /dev/null; then + if ps aux | grep -v grep | grep ${clientName2} &> /dev/null; then kill_client sleep 1 fi @@ -284,7 +303,7 @@ function update_TDengine() { install_config echo - echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}" + echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" rm -rf $(tar -tf ${tarName}) } @@ -296,7 +315,7 @@ function install_TDengine() { exit 1 fi tar -zxf ${tarName} - echo -e "${GREEN}Start to install ${productName} client...${NC}" + echo -e "${GREEN}Start to install ${productName2} client...${NC}" install_main_path install_log @@ -311,7 +330,7 @@ function install_TDengine() { install_config echo - echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" + echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" rm -rf $(tar -tf ${tarName}) } @@ -321,7 +340,7 @@ function install_TDengine() { # Install or updata client and client # if server is already install, don't install client if [ -e ${bin_dir}/${serverName} ]; then - echo -e "\033[44;32;1mThere are already installed ${productName} server, so don't need install client!${NC}" + echo -e "\033[44;32;1mThere are already installed ${productName2} server, so don't need install client!${NC}" exit 0 fi diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index db28de8dec..208bfc183c 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -13,7 +13,13 @@ osType=$5 verMode=$6 verType=$7 pagMode=$8 -dbName=$9 +#comVersion=$9 +dbName=$10 + +productName2="${11}" +#serverName2="${12}d" +clientName2="${12}" +# cusEmail2=${13} productName="TDengine" clientName="taos" @@ -38,15 +44,21 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/${productName}-enterprise-client-${version}" + install_dir="${release_dir}/${productName2}-enterprise-client-${version}" elif [ "$verMode" == "cloud" ]; then - install_dir="${release_dir}/${productName}-cloud-client-${version}" + install_dir="${release_dir}/${productName2}-cloud-client-${version}" else - install_dir="${release_dir}/${productName}-client-${version}" + install_dir="${release_dir}/${productName2}-client-${version}" fi # Directories and files. +if [ "$verMode" == "cluster" ]; then + sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh + sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh + sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh +fi + if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/${clientName} @@ -131,22 +143,28 @@ fi cd ${curr_dir} cp ${install_files} ${install_dir} +cp ${install_dir}/install_client.sh install_client_temp.sh if [ "$osType" == "Darwin" ]; then - sed 's/osType=Linux/osType=Darwin/g' ${install_dir}/install_client.sh >>install_client_temp.sh + sed -i 's/osType=Linux/osType=Darwin/g' install_client_temp.sh mv install_client_temp.sh ${install_dir}/install_client.sh fi if [ "$verMode" == "cluster" ]; then - sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install_client.sh >>install_client_temp.sh + sed -i 's/verMode=edge/verMode=cluster/g' install_client_temp.sh + sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_client_temp.sh + sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_client_temp.sh + sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_client_temp.sh + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_client_temp.sh + mv install_client_temp.sh ${install_dir}/install_client.sh fi if [ "$verMode" == "cloud" ]; then - sed 's/verMode=edge/verMode=cloud/g' ${install_dir}/install_client.sh >>install_client_temp.sh + sed -i 's/verMode=edge/verMode=cloud/g' install_client_temp.sh mv install_client_temp.sh ${install_dir}/install_client.sh fi if [ "$pagMode" == "lite" ]; then - sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install_client.sh >>install_client_temp.sh + sed -i 's/pagMode=full/pagMode=lite/g' install_client_temp.sh mv install_client_temp.sh ${install_dir}/install_client.sh fi chmod a+x ${install_dir}/install_client.sh diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 0ee548242f..0a34d81b7f 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -16,6 +16,10 @@ verType=$7 pagMode=$8 versionComp=$9 dbName=${10} +productName2="${11}" +serverName2="${12}d" +clientName2="${12}" +cusEmail2="${13}" script_dir="$(dirname $(readlink -f $0))" top_dir="$(readlink -f ${script_dir}/../..)" @@ -38,11 +42,11 @@ release_dir="${top_dir}/release" #package_name='linux' if [ "$verMode" == "cluster" ]; then - install_dir="${release_dir}/${productName}-enterprise-server-${version}" + install_dir="${release_dir}/${productName2}-enterprise-server-${version}" elif [ "$verMode" == "cloud" ]; then - install_dir="${release_dir}/${productName}-cloud-server-${version}" + install_dir="${release_dir}/${productName2}-cloud-server-${version}" else - install_dir="${release_dir}/${productName}-server-${version}" + install_dir="${release_dir}/${productName2}-server-${version}" fi if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then @@ -50,11 +54,11 @@ if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" taostools_ver=$(git tag |grep -v taos | sort | tail -1) - taostools_install_dir="${release_dir}/${clientName}Tools-${taostools_ver}" + taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}" cd ${curr_dir} else - taostools_install_dir="${release_dir}/${clientName}Tools-${version}" + taostools_install_dir="${release_dir}/${clientName2}Tools-${version}" fi # Directories and files @@ -225,6 +229,10 @@ fi if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh + sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh + sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh + sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh fi if [ "$verMode" == "cloud" ]; then @@ -247,16 +255,21 @@ fi cd ${curr_dir} cp ${install_files} ${install_dir} +cp ${install_dir}/install.sh install_temp.sh if [ "$verMode" == "cluster" ]; then - sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install.sh >>install_temp.sh + sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh + sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh + sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh + sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$verMode" == "cloud" ]; then - sed 's/verMode=edge/verMode=cloud/g' ${install_dir}/install.sh >>install_temp.sh + sed -i 's/verMode=edge/verMode=cloud/g' install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$pagMode" == "lite" ]; then - sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install.sh >>install_temp.sh + sed -i 's/pagMode=full/pagMode=lite/g' install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi chmod a+x ${install_dir}/install.sh diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 8e5630ec2f..9c50c4582d 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -36,6 +36,16 @@ clientName="taos" uninstallScript="rmtaos" productName="TDengine" +serverName2="taosd" +clientName2="taos" +productName2="TDengine" + +benchmarkName2="${clientName2}Benchmark" +dumpName2="${clientName2}dump" +uninstallScript2="rm${clientName2}" + +installDir="/usr/local/${clientName}" + #install main path install_main_dir=${installDir} data_link_dir=${installDir}/data @@ -107,6 +117,15 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/tarbitrator || : ${csudo}rm -f ${bin_link_dir}/set_core || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : + ${csudo}rm -f ${bin_link_dir}/taoskeeper || : + ${csudo}rm -f ${bin_link_dir}/taosx || : + + if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : + fi } function clean_local_bin() { @@ -147,7 +166,7 @@ function clean_log() { function clean_service_on_systemd() { taosd_service_config="${service_config_dir}/${taos_service_name}.service" if systemctl is-active --quiet ${taos_service_name}; then - echo "${productName} ${serverName} is running, stopping it..." + echo "${productName2} ${serverName2} is running, stopping it..." ${csudo}systemctl stop ${taos_service_name} &>/dev/null || echo &>/dev/null fi ${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null @@ -155,7 +174,7 @@ function clean_service_on_systemd() { taosadapter_service_config="${service_config_dir}/taosadapter.service" if systemctl is-active --quiet ${taosadapter_service_name}; then - echo "${productName} taosAdapter is running, stopping it..." + echo "${productName2} ${clientName2}Adapter is running, stopping it..." ${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null fi ${csudo}systemctl disable ${taosadapter_service_name} &>/dev/null || echo &>/dev/null @@ -163,7 +182,7 @@ function clean_service_on_systemd() { tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" if systemctl is-active --quiet ${tarbitrator_service_name}; then - echo "${productName} tarbitrator is running, stopping it..." + echo "${productName2} tarbitrator is running, stopping it..." ${csudo}systemctl stop ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null fi ${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null @@ -172,12 +191,12 @@ function clean_service_on_systemd() { function clean_service_on_sysvinit() { if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then - echo "${productName} ${serverName} is running, stopping it..." + echo "${productName2} ${serverName2} is running, stopping it..." ${csudo}service ${serverName} stop || : fi if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then - echo "${productName} tarbitrator is running, stopping it..." + echo "${productName2} tarbitrator is running, stopping it..." ${csudo}service tarbitratord stop || : fi @@ -272,5 +291,5 @@ if [ "$osType" = "Darwin" ]; then ${csudo}rm -rf /Applications/TDengine.app fi -echo -e "${GREEN}${productName} is removed successfully!${NC}" +echo -e "${GREEN}${productName2} is removed successfully!${NC}" echo diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index 7ab7fa8599..10a0fb5e02 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -12,6 +12,15 @@ installDir="/usr/local/taos" clientName="taos" uninstallScript="rmtaos" +clientName2="taos" +productName2="TDengine" + +benchmarkName2="${clientName}Benchmark" +dumpName2="${clientName}dump" +uninstallScript2="rm${clientName}" + +installDir="/usr/local/${clientName}" + #install main path install_main_dir=${installDir} @@ -40,6 +49,12 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/taosdump || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}rm -f ${bin_link_dir}/set_core || : + + if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : + fi } function clean_lib() { @@ -82,5 +97,5 @@ clean_config ${csudo}rm -rf ${install_main_dir} -echo -e "${GREEN}TDengine client is removed successfully!${NC}" +echo -e "${GREEN}${productName2} client is removed successfully!${NC}" echo diff --git a/packaging/tools/tdengine.iss b/packaging/tools/tdengine.iss index 3a22c73774..b2dac600ab 100644 --- a/packaging/tools/tdengine.iss +++ b/packaging/tools/tdengine.iss @@ -3,7 +3,7 @@ #define MyAppURL "http://www.taosdata.com/" #define MyAppBeforeInstallTxt "windows_before_install.txt" #define MyAppIco "favicon.ico" -#define MyAppInstallDir "C:\TDengine" +#define MyAppInstallDir "C:\{#CusName}" #define MyAppOutputDir "./" #define MyAppSourceDir "C:\TDengine" ;#define MyAppAllFile "\*" @@ -18,7 +18,6 @@ #define MyAppDLLName "\driver\*.dll" ;#define MyAppVersion "3.0" ;#define MyAppInstallName "TDengine" -;#define MyAppInstallName "TDengine" [Setup] VersionInfoVersion={#MyAppVersion} AppId={{A0F7A93C-79C4-485D-B2B8-F0D03DF42FAB} @@ -59,11 +58,14 @@ Source: {#MyAppSourceDir}{#MyAppDriverName}; DestDir: "{app}\driver"; Flags: igN Source: {#MyAppSourceDir}{#MyAppIncludeName}; DestDir: "{app}\include"; Flags: igNoreversion recursesubdirs createallsubdirs Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExcludeSource} ; Flags: igNoreversion recursesubdirs createallsubdirs Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs +Source: {#MyAppSourceDir}\taos.exe; DestDir: "{app}"; DestName: "{#CusPrompt}.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs +Source: {#MyAppSourceDir}\taosBenchmark.exe; DestDir: "{app}"; DestName: "{#CusPrompt}Benchmark.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs +Source: {#MyAppSourceDir}\taosdump.exe; DestDir: "{app}"; DestName: "{#CusPrompt}dump.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs [run] -Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\TDengine\\taosd.exe --win_service""" ; Flags: runhidden -Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe""" ; Flags: runhidden +Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\{#CusName}\\taosd.exe --win_service""" ; Flags: runhidden +Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\{#CusName}\\taosadapter.exe""" ; Flags: runhidden [UninstallRun] RunOnceId: "stoptaosd"; Filename: {sys}\sc.exe; Parameters: "stop taosd" ; Flags: runhidden @@ -73,8 +75,8 @@ RunOnceId: "deltaosadapter"; Filename: {sys}\sc.exe; Parameters: "delete taosada [Registry] Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ - ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\TDengine"; \ - Check: NeedsAddPath('C:\TDengine') + ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\{#CusName}"; \ + Check: NeedsAddPath('C:\{#CusName}') [Code] function NeedsAddPath(Param: string): boolean; @@ -104,11 +106,11 @@ Name: "desktopicon";Description: "{cm:CreateDesktopIcon}"; GroupDescription:"{cm [Icons] Name:"{group}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; IconFilename: "{app}\include\{#MyAppIco}" -Name:"{group}\Open TDengine Directory"; Filename: "{app}\" +Name:"{group}\Open {#CusName} Directory"; Filename: "{app}\" Name:"{group}\Taosdemo"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taosdemo.exe" ; IconFilename: "{app}\include\{#MyAppIco}" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" ; IconFilename: "{app}\include\{#MyAppIco}" Name:"{commondesktop}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; Tasks: desktopicon; WorkingDir: "{app}" ; IconFilename: "{app}\include\{#MyAppIco}" [Messages] -ConfirmUninstall=Do you really want to uninstall TDengine from your computer?%n%nPress [Y] to completely delete %1 and all its components;%nPress [N] to keep the software on your computer. +ConfirmUninstall=Do you really want to uninstall {#CusName} from your computer?%n%nPress [Y] to completely delete %1 and all its components;%nPress [N] to keep the software on your computer. diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 0072075623..c3e8d7ef1d 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -209,6 +209,8 @@ static FORCE_INLINE void tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) { smaDebug("vgId:%d, unref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref); } +int32_t smaPreClose(SSma *pSma); + // rsma void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree); int32_t tdRSmaFSOpen(SSma *pSma, int64_t version, int8_t rollback); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 38f04bb8e8..51011ef791 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -17,18 +17,26 @@ extern SSmaMgmt smaMgmt; -static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma); +static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit); static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo); static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma); static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat); +/** + * @brief only applicable to Rollup SMA + * + * @param pSma + * @return int32_t + */ +int32_t smaPreClose(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma, false); } + /** * @brief async commit, only applicable to Rollup SMA * * @param pSma * @return int32_t */ -int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); } +int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma, true); } /** * @brief async commit, only applicable to Rollup SMA @@ -122,9 +130,10 @@ _exit: * 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write) * * @param pSma + * @param isCommit * @return int32_t */ -static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { +static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit) { int32_t code = 0; int32_t lino = 0; @@ -139,28 +148,30 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { // step 1: set rsma stat atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED); - while (atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 1) != 0) { - ++nLoops; - if (nLoops > 1000) { - sched_yield(); - nLoops = 0; + if (isCommit) { + while (atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 1) != 0) { + ++nLoops; + if (nLoops > 1000) { + sched_yield(); + nLoops = 0; + } + } + + pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied; + if (ASSERTS(pRSmaStat->commitAppliedVer >= -1, "commit applied version %" PRIi64 " < -1", + pRSmaStat->commitAppliedVer)) { + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); } } - pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied; - if (ASSERTS(pRSmaStat->commitAppliedVer >= 0, "commit applied version %" PRIi64 " < 0", - pRSmaStat->commitAppliedVer)) { - code = TSDB_CODE_APP_ERROR; - TSDB_CHECK_CODE(code, lino, _exit); - } - // step 2: wait for all triggered fetch tasks to finish nLoops = 0; while (1) { - if (T_REF_VAL_GET(pStat) == 0) { - smaDebug("vgId:%d, rsma commit, fetch tasks are all finished", SMA_VID(pSma)); + if (atomic_load_32(&pRSmaStat->nFetchAll) <= 0) { + smaDebug("vgId:%d, rsma commit:%d, fetch tasks are all finished", SMA_VID(pSma), isCommit); break; } else { - smaDebug("vgId:%d, rsma commit, fetch tasks are not all finished yet", SMA_VID(pSma)); + smaDebug("vgId:%d, rsma commit%d, fetch tasks are not all finished yet", SMA_VID(pSma), isCommit); } ++nLoops; if (nLoops > 1000) { @@ -174,7 +185,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { * 1) This is high cost task and should not put in asyncPreCommit originally. * 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently. */ - smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma), + smaInfo("vgId:%d, rsma commit:%d, wait for all items to be consumed, TID:%p", SMA_VID(pSma), isCommit, (void *)taosGetSelfPthreadId()); nLoops = 0; while (atomic_load_64(&pRSmaStat->nBufItems) > 0) { @@ -184,10 +195,13 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { nLoops = 0; } } + + if (!isCommit) goto _exit; + smaInfo("vgId:%d, rsma commit, all items are consumed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); TSDB_CHECK_CODE(code, lino, _exit); - + smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); #if 0 // consuming task of qTaskInfo clone @@ -223,7 +237,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { _exit: if (code) { - smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pSma), __func__, lino, tstrerror(code)); + smaError("vgId:%d, %s failed at line %d since %s(%d)", SMA_VID(pSma), __func__, lino, tstrerror(code), isCommit); } return code; } @@ -243,7 +257,7 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) { if (!pSmaEnv) { goto _exit; } - + code = tdRSmaFSCommit(pSma); TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 21c2839943..00000cb129 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -167,6 +167,7 @@ _exit: int32_t smaClose(SSma *pSma) { if (pSma) { + smaPreClose(pSma); taosThreadMutexDestroy(&pSma->mutex); SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 55b52e8bf8..9f57887d48 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -209,7 +209,7 @@ static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) { } SSnapDataHdr* pHdr = (SSnapDataHdr*)*ppData; - pHdr->type = SNAP_DATA_TSDB; + pHdr->type = pReader->type; pHdr->size = size; memcpy(pHdr->data, pReader->aBuf[3], aBufN[3]); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 2441345d82..f0cd08f8fa 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -296,12 +296,6 @@ int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { tsem_wait(&pVnode->canCommit); - taosThreadMutexLock(&pVnode->mutex); - ASSERT(pVnode->onCommit == NULL); - pVnode->onCommit = pVnode->inUse; - pVnode->inUse = NULL; - taosThreadMutexUnlock(&pVnode->mutex); - pVnode->state.commitTerm = pVnode->state.applyTerm; pInfo->info.config = pVnode->config; @@ -331,6 +325,12 @@ int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { code = smaPrepareAsyncCommit(pVnode->pSma); if (code) goto _exit; + taosThreadMutexLock(&pVnode->mutex); + ASSERT(pVnode->onCommit == NULL); + pVnode->onCommit = pVnode->inUse; + pVnode->inUse = NULL; + taosThreadMutexUnlock(&pVnode->mutex); + _exit: if (code) { vError("vgId:%d, %s failed at line %d since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, lino, diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index ea7528b1cb..07abdc0040 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -16,6 +16,9 @@ print $data00 $data01 $data02 sql use test; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); + sql create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql insert into t1 values(1648791213000,1,2,3,1.0,1); @@ -79,86 +82,88 @@ endi if $data03 != 1 then print ======$data03 - return -1 + goto loop1 endi if $data04 != 1 then print ======$data04 - return -1 + goto loop1 endi if $data05 != 3 then print ======$data05 - return -1 + goto loop1 endi if $data06 != 5 then print ======$data06 - return -1 + goto loop1 endi # row 1 if $data11 != 1 then print ======$data11 - return -1 + goto loop1 endi if $data12 != 1 then print ======$data12 - return -1 + goto loop1 endi if $data13 != 2 then print ======$data13 - return -1 + goto loop1 endi if $data14 != 2 then print ======$data14 - return -1 + goto loop1 endi if $data15 != 3 then print ======$data15 - return -1 + goto loop1 endi if $data16 != 4 then print ======$data16 - return -1 + goto loop1 endi # row 2 if $data21 != 1 then print ======$data21 - return -1 + goto loop1 endi if $data22 != 1 then print ======$data22 - return -1 + goto loop1 endi if $data23 != 1 then print ======$data23 - return -1 + goto loop1 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop1 endi if $data25 != 3 then print ======$data25 - return -1 + goto loop1 endi if $data26 != 6 then print ======$data26 - return -1 + goto loop1 endi +print loop1 end + sql insert into t1 values(1648791213011,1,2,3,1.0,7); $loop_count = 0 @@ -174,33 +179,31 @@ endi if $data21 != 2 then print =====data21=$data21 goto loop2 - return -1 endi if $data22 != 2 then print =====data22=$data22 goto loop2 - return -1 endi if $data23 != 2 then print ======$data23 - return -1 + goto loop2 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop2 endi if $data25 != 3 then print ======$data25 - return -1 + goto loop2 endi if $data26 != 7 then print ======$data26 - return -1 + goto loop2 endi sql insert into t1 values(1648791213011,1,2,3,1.0,8); @@ -238,99 +241,93 @@ endi if $data21 != 1 then print =====data21=$data21 goto loop3 - return -1 endi if $data22 != 1 then print =====data22=$data22 goto loop3 - return -1 endi if $data23 != 10 then print ======$data23 - return -1 + goto loop3 endi if $data24 != 10 then print ======$data24 - return -1 + goto loop3 endi if $data25 != 10 then print ======$data25 - return -1 + goto loop3 endi if $data26 != 12 then print ======$data26 - return -1 + goto loop3 endi # row 3 if $data31 != 1 then print =====data31=$data31 goto loop3 - return -1 endi if $data32 != 1 then print =====data32=$data32 goto loop3 - return -1 endi if $data33 != 3 then print ======$data33 - return -1 + goto loop3 endi if $data34 != 3 then print ======$data34 - return -1 + goto loop3 endi if $data35 != 3 then print ======$data35 - return -1 + goto loop3 endi if $data36 != 10 then print ======$data36 - return -1 + goto loop3 endi # row 4 if $data41 != 1 then print =====data41=$data41 goto loop3 - return -1 endi if $data42 != 1 then print =====data42=$data42 goto loop3 - return -1 endi if $data43 != 1 then print ======$data43 - return -1 + goto loop3 endi if $data44 != 1 then print ======$data44 - return -1 + goto loop3 endi if $data45 != 3 then print ======$data45 - return -1 + goto loop3 endi if $data46 != 11 then print ======$data46 - return -1 + goto loop3 endi sql insert into t1 values(1648791213030,3,12,12,12.0,13); @@ -360,95 +357,93 @@ endi if $data02 != 2 then print ======$data02 - return -1 + goto loop4 endi if $data03 != 6 then print ======$data03 - return -1 + goto loop4 endi if $data04 != 3 then print ======$data04 - return -1 + goto loop4 endi if $data05 != 3 then print ======$data05 - return -1 + goto loop4 endi if $data06 != 15 then print ======$data06 - return -1 + goto loop4 endi # row 1 if $data11 != 1 then print =====data11=$data11 goto loop4 - return -1 endi if $data12 != 1 then print =====data12=$data12 goto loop4 - return -1 endi if $data13 != 15 then print ======$data13 - return -1 + goto loop4 endi if $data14 != 15 then print ======$data14 - return -1 + goto loop4 endi if $data15 != 15 then print ======$data15 - return -1 + goto loop4 endi if $data16 != 16 then print ======$data16 - return -1 + goto loop4 endi # row 2 if $data21 != 1 then print =====data21=$data21 goto loop4 - return -1 endi if $data22 != 1 then print =====data22=$data22 goto loop4 - return -1 endi if $data23 != 1 then print ======$data23 - return -1 + goto loop4 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop4 endi if $data25 != 13 then print ======$data25 - return -1 + goto loop4 endi if $data26 != 14 then print ======$data26 - return -1 + goto loop4 endi +print loop4 end + sql create database test1 vgroups 1; sql select * from information_schema.ins_databases; @@ -457,6 +452,9 @@ print $data00 $data01 $data02 sql use test1; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); + sql create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql insert into t1 values(1648791212000,2,2,3,1.0,1); @@ -502,6 +500,9 @@ sql create database test3 vgroups 1; sql use test3; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); + sql create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); sql insert into t1 values(1648791212000,1,2,3,1.0,1); sql insert into t1 values(1648791213000,2,2,3,1.0,1); @@ -543,7 +544,6 @@ if $rows != 10 then goto loop6 endi - sql drop stream if exists streams4; sql drop database if exists test4; sql drop stable if exists streamt4; @@ -552,6 +552,9 @@ sql use test4; sql create table st (ts timestamp, c1 tinyint, c2 smallint) tags (t1 tinyint) ; sql create table t1 using st tags (-81) ; sql create table t2 using st tags (-81) ; + +print create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1); + sql create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1); sql insert into t1 (ts, c1) values (1668073288209, 11); @@ -636,7 +639,7 @@ sql insert into t1 (ts, c1) values (1668073288225, 65); sql insert into t1 (ts, c1) values (1668073288226, 65); $loop_count = 0 -loop8: +loop81: sleep 200 @@ -649,27 +652,27 @@ endi if $rows != 2 then print =====rows=$rows - goto loop8 + goto loop81 endi if $data01 != 11 then print =====data01=$data01 - goto loop8 + goto loop81 endi if $data02 != 5 then print =====data02=$data02 - goto loop8 + goto loop81 endi if $data11 != 29 then print =====data11=$data11 - goto loop8 + goto loop81 endi if $data12 != 1 then print =====data12=$data12 - goto loop8 + goto loop81 endi sql insert into t1 (ts, c1) values (1668073288224, 64); @@ -738,6 +741,9 @@ sql use test5; sql create table tb (ts timestamp, a int); sql insert into tb values (now + 1m , 1 ); sql create table b (c timestamp, d int, e int , f int, g double); + +print create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); + sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); sql insert into b values(1648791213000,NULL,NULL,NULL,NULL); sql select * from streamt order by c1, c2, c3; @@ -792,4 +798,6 @@ if $data00 != 2 then goto loop10 endi +print state0 end + system sh/exec.sh -n dnode1 -s stop -x SIGINT