Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7c6e73f
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a7c6e73f
编写于
12月 28, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-1925
上级
90a15691
a2d974cf
变更
229
展开全部
显示空白变更内容
内联
并排
Showing
229 changed file
with
6381 addition
and
4533 deletion
+6381
-4533
Jenkinsfile
Jenkinsfile
+17
-6
alert/go.mod
alert/go.mod
+1
-1
cmake/version.inc
cmake/version.inc
+1
-1
documentation20/webdocs/markdowndocs/Documentation-ch.md
documentation20/webdocs/markdowndocs/Documentation-ch.md
+15
-2
documentation20/webdocs/markdowndocs/Getting Started-ch.md
documentation20/webdocs/markdowndocs/Getting Started-ch.md
+1
-1
documentation20/webdocs/markdowndocs/Model-ch.md
documentation20/webdocs/markdowndocs/Model-ch.md
+2
-0
documentation20/webdocs/markdowndocs/Super Table-ch.md
documentation20/webdocs/markdowndocs/Super Table-ch.md
+2
-2
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
+78
-97
documentation20/webdocs/markdowndocs/Taos Error Code-ch.md
documentation20/webdocs/markdowndocs/Taos Error Code-ch.md
+0
-1
documentation20/webdocs/markdowndocs/administrator-ch.md
documentation20/webdocs/markdowndocs/administrator-ch.md
+12
-18
documentation20/webdocs/markdowndocs/architecture-ch.md
documentation20/webdocs/markdowndocs/architecture-ch.md
+5
-5
documentation20/webdocs/markdowndocs/cluster-ch.md
documentation20/webdocs/markdowndocs/cluster-ch.md
+2
-0
documentation20/webdocs/markdowndocs/connector-ch.md
documentation20/webdocs/markdowndocs/connector-ch.md
+33
-75
documentation20/webdocs/markdowndocs/connector-java-ch.md
documentation20/webdocs/markdowndocs/connector-java-ch.md
+21
-24
documentation20/webdocs/markdowndocs/faq-ch.md
documentation20/webdocs/markdowndocs/faq-ch.md
+12
-21
documentation20/webdocs/markdowndocs/insert-ch.md
documentation20/webdocs/markdowndocs/insert-ch.md
+13
-16
documentation20/webdocs/markdowndocs/replica-ch.md
documentation20/webdocs/markdowndocs/replica-ch.md
+8
-8
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+13
-11
packaging/tools/post.sh
packaging/tools/post.sh
+7
-1
packaging/tools/preun.sh
packaging/tools/preun.sh
+1
-1
packaging/tools/set_core.sh
packaging/tools/set_core.sh
+25
-5
snap/snapcraft.yaml
snap/snapcraft.yaml
+2
-2
src/balance/src/bnMain.c
src/balance/src/bnMain.c
+49
-104
src/balance/src/bnScore.c
src/balance/src/bnScore.c
+1
-1
src/balance/src/bnThread.c
src/balance/src/bnThread.c
+5
-1
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+0
-7
src/client/inc/tscLog.h
src/client/inc/tscLog.h
+2
-2
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+12
-12
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+14
-3
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+13
-27
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+36
-29
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+11
-19
src/client/src/tscServer.c
src/client/src/tscServer.c
+29
-64
src/client/src/tscSql.c
src/client/src/tscSql.c
+7
-24
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+9
-10
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+27
-47
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+30
-27
src/common/inc/tulog.h
src/common/inc/tulog.h
+1
-1
src/common/src/tglobal.c
src/common/src/tglobal.c
+84
-50
src/connector/nodejs/nodetaos/cinterface.js
src/connector/nodejs/nodetaos/cinterface.js
+4
-4
src/dnode/inc/dnodeCfg.h
src/dnode/inc/dnodeCfg.h
+1
-0
src/dnode/src/dnodeCfg.c
src/dnode/src/dnodeCfg.c
+6
-0
src/dnode/src/dnodeMRead.c
src/dnode/src/dnodeMRead.c
+0
-2
src/dnode/src/dnodeMWrite.c
src/dnode/src/dnodeMWrite.c
+0
-1
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+1
-1
src/dnode/src/dnodeTelemetry.c
src/dnode/src/dnodeTelemetry.c
+1
-1
src/dnode/src/dnodeVMgmt.c
src/dnode/src/dnodeVMgmt.c
+2
-1
src/dnode/src/dnodeVRead.c
src/dnode/src/dnodeVRead.c
+3
-2
src/dnode/src/dnodeVWrite.c
src/dnode/src/dnodeVWrite.c
+1
-0
src/dnode/src/dnodeVnodes.c
src/dnode/src/dnodeVnodes.c
+8
-4
src/inc/dnode.h
src/inc/dnode.h
+2
-0
src/inc/taosdef.h
src/inc/taosdef.h
+4
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+15
-6
src/inc/tsdb.h
src/inc/tsdb.h
+2
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+109
-108
src/inc/ttype.h
src/inc/ttype.h
+1
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+1
-3
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+87
-9
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+3
-0
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+5
-3
src/mnode/inc/mnodeDnode.h
src/mnode/inc/mnodeDnode.h
+6
-3
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+25
-2
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+39
-25
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+23
-0
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+2
-0
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+2
-0
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+13
-8
src/os/inc/osSocket.h
src/os/inc/osSocket.h
+1
-0
src/os/src/detail/osSocket.c
src/os/src/detail/osSocket.c
+4
-0
src/os/src/windows/wSocket.c
src/os/src/windows/wSocket.c
+1
-0
src/plugins/http/src/httpResp.c
src/plugins/http/src/httpResp.c
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+6
-8
src/query/inc/qHistogram.h
src/query/inc/qHistogram.h
+1
-1
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+2
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+0
-5
src/query/inc/queryLog.h
src/query/inc/queryLog.h
+2
-2
src/query/inc/sql.y
src/query/inc/sql.y
+87
-84
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+377
-681
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+4
-4
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+7
-1
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+1
-1
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+1
-0
src/query/src/qUtil.c
src/query/src/qUtil.c
+3
-172
src/query/src/sql.c
src/query/src/sql.c
+1241
-1246
src/query/tests/histogramTest.cpp
src/query/tests/histogramTest.cpp
+5
-5
src/rpc/inc/rpcLog.h
src/rpc/inc/rpcLog.h
+1
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+1
-1
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+11
-9
src/sync/inc/syncTcp.h
src/sync/inc/syncTcp.h
+3
-3
src/sync/src/syncArbitrator.c
src/sync/src/syncArbitrator.c
+7
-7
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+216
-94
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+25
-9
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+9
-3
src/sync/src/syncTcp.c
src/sync/src/syncTcp.c
+5
-5
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+23
-14
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+8
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+40
-4
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+55
-17
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+7
-6
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+166
-34
src/util/inc/hash.h
src/util/inc/hash.h
+7
-6
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-0
src/util/inc/tref.h
src/util/inc/tref.h
+2
-0
src/util/inc/tsocket.h
src/util/inc/tsocket.h
+1
-1
src/util/src/hash.c
src/util/src/hash.c
+3
-3
src/util/src/tcache.c
src/util/src/tcache.c
+6
-5
src/util/src/tconfig.c
src/util/src/tconfig.c
+27
-1
src/util/src/tlog.c
src/util/src/tlog.c
+2
-2
src/util/src/tnettest.c
src/util/src/tnettest.c
+1
-1
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+9
-1
src/util/src/tsocket.c
src/util/src/tsocket.c
+14
-2
src/util/src/ttimer.c
src/util/src/ttimer.c
+1
-1
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+2
-1
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+26
-5
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+2
-1
src/vnode/src/vnodeMgmt.c
src/vnode/src/vnodeMgmt.c
+6
-2
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+14
-7
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+1
-1
tests/Jenkinsfile
tests/Jenkinsfile
+41
-41
tests/pytest/concurrent_inquiry.py
tests/pytest/concurrent_inquiry.py
+49
-14
tests/pytest/crash_gen/crash_gen_main.py
tests/pytest/crash_gen/crash_gen_main.py
+11
-8
tests/pytest/crash_gen/db.py
tests/pytest/crash_gen/db.py
+9
-1
tests/pytest/crash_gen/misc.py
tests/pytest/crash_gen/misc.py
+2
-1
tests/pytest/crash_gen_bootstrap.py
tests/pytest/crash_gen_bootstrap.py
+1
-1
tests/pytest/handle_crash_gen_val_log.sh
tests/pytest/handle_crash_gen_val_log.sh
+4
-3
tests/pytest/import_merge/importCacheFileH.py
tests/pytest/import_merge/importCacheFileH.py
+1
-1
tests/pytest/import_merge/importCacheFileHO.py
tests/pytest/import_merge/importCacheFileHO.py
+1
-1
tests/pytest/import_merge/importCacheFileHPO.py
tests/pytest/import_merge/importCacheFileHPO.py
+1
-1
tests/pytest/import_merge/importCacheFileS.py
tests/pytest/import_merge/importCacheFileS.py
+1
-1
tests/pytest/import_merge/importCacheFileSub.py
tests/pytest/import_merge/importCacheFileSub.py
+1
-1
tests/pytest/import_merge/importCacheFileT.py
tests/pytest/import_merge/importCacheFileT.py
+1
-1
tests/pytest/import_merge/importCacheFileTO.py
tests/pytest/import_merge/importCacheFileTO.py
+1
-1
tests/pytest/import_merge/importCacheFileTPO.py
tests/pytest/import_merge/importCacheFileTPO.py
+1
-1
tests/pytest/import_merge/importDataH2.py
tests/pytest/import_merge/importDataH2.py
+1
-1
tests/pytest/import_merge/importDataHO.py
tests/pytest/import_merge/importDataHO.py
+1
-1
tests/pytest/import_merge/importDataHO2.py
tests/pytest/import_merge/importDataHO2.py
+1
-1
tests/pytest/import_merge/importDataHPO.py
tests/pytest/import_merge/importDataHPO.py
+1
-1
tests/pytest/import_merge/importDataLastH.py
tests/pytest/import_merge/importDataLastH.py
+1
-1
tests/pytest/import_merge/importDataLastHO.py
tests/pytest/import_merge/importDataLastHO.py
+1
-1
tests/pytest/import_merge/importDataLastHPO.py
tests/pytest/import_merge/importDataLastHPO.py
+1
-1
tests/pytest/import_merge/importDataLastS.py
tests/pytest/import_merge/importDataLastS.py
+1
-1
tests/pytest/import_merge/importDataLastSub.py
tests/pytest/import_merge/importDataLastSub.py
+3
-3
tests/pytest/import_merge/importDataLastT.py
tests/pytest/import_merge/importDataLastT.py
+1
-1
tests/pytest/import_merge/importDataLastTO.py
tests/pytest/import_merge/importDataLastTO.py
+1
-1
tests/pytest/import_merge/importDataLastTPO.py
tests/pytest/import_merge/importDataLastTPO.py
+1
-1
tests/pytest/import_merge/importDataS.py
tests/pytest/import_merge/importDataS.py
+1
-1
tests/pytest/import_merge/importDataSub.py
tests/pytest/import_merge/importDataSub.py
+1
-1
tests/pytest/import_merge/importDataT.py
tests/pytest/import_merge/importDataT.py
+1
-1
tests/pytest/import_merge/importDataTO.py
tests/pytest/import_merge/importDataTO.py
+1
-1
tests/pytest/import_merge/importDataTPO.py
tests/pytest/import_merge/importDataTPO.py
+2
-2
tests/pytest/import_merge/importHORestart.py
tests/pytest/import_merge/importHORestart.py
+1
-1
tests/pytest/import_merge/importHPORestart.py
tests/pytest/import_merge/importHPORestart.py
+1
-1
tests/pytest/import_merge/importHRestart.py
tests/pytest/import_merge/importHRestart.py
+1
-1
tests/pytest/import_merge/importInsertThenImport.py
tests/pytest/import_merge/importInsertThenImport.py
+1
-1
tests/pytest/import_merge/importLastH.py
tests/pytest/import_merge/importLastH.py
+1
-1
tests/pytest/import_merge/importLastHO.py
tests/pytest/import_merge/importLastHO.py
+1
-1
tests/pytest/import_merge/importLastHPO.py
tests/pytest/import_merge/importLastHPO.py
+1
-1
tests/pytest/import_merge/importLastS.py
tests/pytest/import_merge/importLastS.py
+1
-1
tests/pytest/import_merge/importLastSub.py
tests/pytest/import_merge/importLastSub.py
+1
-1
tests/pytest/import_merge/importLastT.py
tests/pytest/import_merge/importLastT.py
+1
-1
tests/pytest/import_merge/importLastTO.py
tests/pytest/import_merge/importLastTO.py
+1
-1
tests/pytest/import_merge/importLastTPO.py
tests/pytest/import_merge/importLastTPO.py
+1
-1
tests/pytest/import_merge/importSRestart.py
tests/pytest/import_merge/importSRestart.py
+1
-1
tests/pytest/import_merge/importSubRestart.py
tests/pytest/import_merge/importSubRestart.py
+1
-1
tests/pytest/import_merge/importTORestart.py
tests/pytest/import_merge/importTORestart.py
+1
-1
tests/pytest/import_merge/importTPORestart.py
tests/pytest/import_merge/importTPORestart.py
+1
-1
tests/pytest/import_merge/importTRestart.py
tests/pytest/import_merge/importTRestart.py
+1
-1
tests/pytest/insert/restfulInsert.py
tests/pytest/insert/restfulInsert.py
+1
-1
tests/pytest/pytest_1.sh
tests/pytest/pytest_1.sh
+14
-6
tests/pytest/pytest_2.sh
tests/pytest/pytest_2.sh
+1
-0
tests/pytest/query/query.py
tests/pytest/query/query.py
+20
-1
tests/pytest/table/alter_wal0.py
tests/pytest/table/alter_wal0.py
+4
-3
tests/script/general/db/alter_tables_d2.sim
tests/script/general/db/alter_tables_d2.sim
+98
-18
tests/script/general/db/alter_tables_v1.sim
tests/script/general/db/alter_tables_v1.sim
+91
-16
tests/script/general/db/alter_tables_v4.sim
tests/script/general/db/alter_tables_v4.sim
+78
-13
tests/script/general/db/delete_reusevnode.sim
tests/script/general/db/delete_reusevnode.sim
+0
-2
tests/script/general/db/delete_writing1.sim
tests/script/general/db/delete_writing1.sim
+0
-1
tests/script/general/http/restful_full.sim
tests/script/general/http/restful_full.sim
+1
-1
tests/script/general/parser/mixed_blocks.sim
tests/script/general/parser/mixed_blocks.sim
+17
-1
tests/script/general/table/delete_writing.sim
tests/script/general/table/delete_writing.sim
+0
-2
tests/script/general/wal/sync.sim
tests/script/general/wal/sync.sim
+30
-9
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
tests/script/jenkins/basic_3.txt
tests/script/jenkins/basic_3.txt
+32
-34
tests/script/jenkins/unique.txt
tests/script/jenkins/unique.txt
+2
-0
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+2
-0
tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
+4
-2
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
+160
-327
tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
...ipt/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
+8
-0
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
+5
-3
tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim
...script/unique/arbitrator/sync_replica3_alterTable_add.sim
+3
-9
tests/script/unique/arbitrator/sync_replica_alterTable_background_add.sim
...que/arbitrator/sync_replica_alterTable_background_add.sim
+3
-0
tests/script/unique/big/balance.sim
tests/script/unique/big/balance.sim
+33
-22
tests/script/unique/big/tcp.sim
tests/script/unique/big/tcp.sim
+2
-3
tests/script/unique/cluster/balance1.sim
tests/script/unique/cluster/balance1.sim
+48
-23
tests/script/unique/cluster/balance2.sim
tests/script/unique/cluster/balance2.sim
+47
-15
tests/script/unique/cluster/balance3.sim
tests/script/unique/cluster/balance3.sim
+142
-92
tests/script/unique/cluster/vgroup100.sim
tests/script/unique/cluster/vgroup100.sim
+0
-5
tests/script/unique/db/delete.sim
tests/script/unique/db/delete.sim
+0
-5
tests/script/unique/db/delete_part.sim
tests/script/unique/db/delete_part.sim
+34
-17
tests/script/unique/db/replica_add12.sim
tests/script/unique/db/replica_add12.sim
+155
-48
tests/script/unique/db/replica_add13.sim
tests/script/unique/db/replica_add13.sim
+171
-27
tests/script/unique/db/replica_add23.sim
tests/script/unique/db/replica_add23.sim
+171
-27
tests/script/unique/db/replica_part.sim
tests/script/unique/db/replica_part.sim
+181
-31
tests/script/unique/db/replica_reduce21.sim
tests/script/unique/db/replica_reduce21.sim
+49
-16
tests/script/unique/db/replica_reduce31.sim
tests/script/unique/db/replica_reduce31.sim
+116
-21
tests/script/unique/db/replica_reduce32.sim
tests/script/unique/db/replica_reduce32.sim
+164
-28
tests/script/unique/dnode/balance1.sim
tests/script/unique/dnode/balance1.sim
+7
-9
tests/script/unique/dnode/balance2.sim
tests/script/unique/dnode/balance2.sim
+30
-11
tests/script/unique/dnode/balance3.sim
tests/script/unique/dnode/balance3.sim
+36
-14
tests/script/unique/dnode/offline3.sim
tests/script/unique/dnode/offline3.sim
+111
-0
tests/script/unique/dnode/reason.sim
tests/script/unique/dnode/reason.sim
+91
-20
tests/script/unique/dnode/remove1.sim
tests/script/unique/dnode/remove1.sim
+26
-10
tests/script/unique/dnode/remove2.sim
tests/script/unique/dnode/remove2.sim
+30
-7
tests/script/unique/dnode/vnode_clean.sim
tests/script/unique/dnode/vnode_clean.sim
+12
-14
tests/script/unique/import/replica2.sim
tests/script/unique/import/replica2.sim
+78
-10
tests/script/unique/import/replica3.sim
tests/script/unique/import/replica3.sim
+63
-7
tests/script/unique/mnode/mgmt20.sim
tests/script/unique/mnode/mgmt20.sim
+2
-3
tests/script/unique/mnode/mgmt22.sim
tests/script/unique/mnode/mgmt22.sim
+6
-8
tests/script/unique/mnode/mgmt23.sim
tests/script/unique/mnode/mgmt23.sim
+25
-16
tests/script/unique/mnode/mgmt33.sim
tests/script/unique/mnode/mgmt33.sim
+64
-26
tests/script/unique/mnode/mgmt34.sim
tests/script/unique/mnode/mgmt34.sim
+74
-35
tests/script/unique/mnode/mgmtr2.sim
tests/script/unique/mnode/mgmtr2.sim
+12
-9
tests/script/unique/vnode/many.sim
tests/script/unique/vnode/many.sim
+31
-1
tests/script/unique/vnode/replica2_repeat.sim
tests/script/unique/vnode/replica2_repeat.sim
+33
-2
tests/script/unique/vnode/replica3_basic.sim
tests/script/unique/vnode/replica3_basic.sim
+82
-8
tests/script/unique/vnode/replica3_repeat.sim
tests/script/unique/vnode/replica3_repeat.sim
+37
-2
tests/test-all.sh
tests/test-all.sh
+66
-3
未找到文件。
Jenkinsfile
浏览文件 @
a7c6e73f
...
@@ -79,14 +79,25 @@ pipeline {
...
@@ -79,14 +79,25 @@ pipeline {
changeRequest
()
changeRequest
()
}
}
parallel
{
parallel
{
stage
(
'python'
)
{
stage
(
'python
_1
'
)
{
agent
{
label
'p
ytest
'
}
agent
{
label
'p
1
'
}
steps
{
steps
{
pre_test
()
pre_test
()
sh
'''
sh
'''
cd ${WKC}/tests
cd ${WKC}/tests
./test-all.sh pytest
./test-all.sh p1
date'''
}
}
stage
(
'python_2'
)
{
agent
{
label
'p2'
}
steps
{
pre_test
()
sh
'''
cd ${WKC}/tests
./test-all.sh p2
date'''
date'''
}
}
}
}
...
@@ -96,7 +107,7 @@ pipeline {
...
@@ -96,7 +107,7 @@ pipeline {
pre_test
()
pre_test
()
sh
'''
sh
'''
cd ${WKC}/tests
cd ${WKC}/tests
./test-all.sh b1
./test-all.sh b1
fq
date'''
date'''
}
}
}
}
...
@@ -120,7 +131,7 @@ pipeline {
...
@@ -120,7 +131,7 @@ pipeline {
sh
'''
sh
'''
date
date
cd ${WKC}/tests
cd ${WKC}/tests
./test-all.sh b2
./test-all.sh b2
fq
date
date
'''
'''
}
}
...
@@ -141,7 +152,7 @@ pipeline {
...
@@ -141,7 +152,7 @@ pipeline {
sh
'''
sh
'''
date
date
cd ${WKC}/tests
cd ${WKC}/tests
./test-all.sh b3
./test-all.sh b3
fq
date'''
date'''
}
}
}
}
...
...
alert/go.mod
浏览文件 @
a7c6e73f
...
@@ -5,7 +5,7 @@ go 1.14
...
@@ -5,7 +5,7 @@ go 1.14
require (
require (
github.com/jmoiron/sqlx v1.2.0
github.com/jmoiron/sqlx v1.2.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/taosdata/driver-go v0.0.0-2020
0727182616-1a3b1941c206
github.com/taosdata/driver-go v0.0.0-2020
1113094317-050667e5b4d0
go.uber.org/zap v1.14.1
go.uber.org/zap v1.14.1
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
...
...
cmake/version.inc
浏览文件 @
a7c6e73f
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF
(
DEFINED
VERNUMBER
)
IF
(
DEFINED
VERNUMBER
)
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
ELSE
()
ELSE
()
SET
(
TD_VER_NUMBER
"2.0.1
1
.0"
)
SET
(
TD_VER_NUMBER
"2.0.1
2
.0"
)
ENDIF
()
ENDIF
()
IF
(
DEFINED
VERCOMPATIBLE
)
IF
(
DEFINED
VERCOMPATIBLE
)
...
...
documentation20/webdocs/markdowndocs/Documentation-ch.md
浏览文件 @
a7c6e73f
...
@@ -128,5 +128,18 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
...
@@ -128,5 +128,18 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
## [培训和FAQ](https://www.taosdata.com/cn/faq)
## [培训和FAQ](https://www.taosdata.com/cn/faq)
-
[
FAQ
](
https://www.taosdata.com/cn/documentation20/faq
)
:常见问题与答案
<ul>
-
[
应用案列
](
https://www.taosdata.com/cn/blog/?categories=4
)
:一些使用实例来解释如何使用TDengine
<li><a
l
href=
"https://www.taosdata.com/blog/2020/12/25/2126.html"
>
技术公开课:开源、高效的物联网大数据平台,TDengine内核技术剖析
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1941.html"
>
TDengine视频教程-快速上手
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1945.html"
>
TDengine视频教程-数据建模
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1961.html"
>
TDengine视频教程-集群搭建
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1951.html"
>
TDengine视频教程-Go Connector
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1955.html"
>
TDengine视频教程-JDBC Connector
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1957.html"
>
TDengine视频教程-NodeJS Connector
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1963.html"
>
TDengine视频教程-Python Connector
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1965.html"
>
TDengine视频教程-RESTful Connector
</a></li>
<li><a
l
href=
"https://www.taosdata.com/blog/2020/11/11/1959.html"
>
TDengine视频教程-“零”代码运维监控
</a></li>
<li><a
l
href=
"https://www.taosdata.com/cn/documentation20/faq"
>
FAQ:常见问题与答案
</a></li>
<li><a
l
href=
"https://www.taosdata.com/cn/blog/?categories=4"
>
应用案例:一些使用实例来解释如何使用TDengine
</a></li>
</ul>
documentation20/webdocs/markdowndocs/Getting Started-ch.md
浏览文件 @
a7c6e73f
...
@@ -20,7 +20,7 @@ TDengine的安装非常简单,从下载到安装成功仅仅只要几秒钟。
...
@@ -20,7 +20,7 @@ TDengine的安装非常简单,从下载到安装成功仅仅只要几秒钟。
-
TDengine-server-2.0.10.0-Linux-x64.deb (2.7M)
-
TDengine-server-2.0.10.0-Linux-x64.deb (2.7M)
-
TDengine-server-2.0.10.0-Linux-x64.tar.gz (4.5M)
-
TDengine-server-2.0.10.0-Linux-x64.tar.gz (4.5M)
具体的安装过程,请参见
<a
href=
"https://www.taosdata.com/blog/2019/08/09/566.html"
>
TDengine多种安装包的安装和卸载
</a>
。
具体的安装过程,请参见
<a
href=
"https://www.taosdata.com/blog/2019/08/09/566.html"
>
TDengine多种安装包的安装和卸载
</a>
以及
<a
href=
"https://www.taosdata.com/blog/2020/11/11/1941.html"
>
视频教程
</a>
。
## 轻松启动
## 轻松启动
...
...
documentation20/webdocs/markdowndocs/Model-ch.md
浏览文件 @
a7c6e73f
...
@@ -59,3 +59,5 @@ INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 21
...
@@ -59,3 +59,5 @@ INSERT INTO d1001 USING METERS TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 21
TDengine支持多列模型,只要物理量是一个数据采集点同时采集的(时间戳一致),这些量就可以作为不同列放在一张超级表里。但还有一种极限的设计,单列模型,每个采集的物理量都单独建表,因此每种类型的物理量都单独建立一超级表。比如电流、电压、相位,就建三张超级表。
TDengine支持多列模型,只要物理量是一个数据采集点同时采集的(时间戳一致),这些量就可以作为不同列放在一张超级表里。但还有一种极限的设计,单列模型,每个采集的物理量都单独建表,因此每种类型的物理量都单独建立一超级表。比如电流、电压、相位,就建三张超级表。
TDengine建议尽可能采用多列模型,因为插入效率以及存储效率更高。但对于有些场景,一个采集点的采集量的种类经常变化,这个时候,如果采用多列模型,就需要频繁修改超级表的结构定义,让应用变的复杂,这个时候,采用单列模型会显得简单。
TDengine建议尽可能采用多列模型,因为插入效率以及存储效率更高。但对于有些场景,一个采集点的采集量的种类经常变化,这个时候,如果采用多列模型,就需要频繁修改超级表的结构定义,让应用变的复杂,这个时候,采用单列模型会显得简单。
关于数据建模请参考
<a
href=
"https://www.taosdata.com/blog/2020/11/11/1945.html"
>
视频教程
</a>
。
documentation20/webdocs/markdowndocs/Super Table-ch.md
浏览文件 @
a7c6e73f
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
浏览文件 @
a7c6e73f
...
@@ -77,7 +77,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -77,7 +77,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
SHOW VARIABLES;
SHOW VARIABLES;
```
```
-
**使用数据库**
-
**使用数据库**
```mysql
```mysql
...
@@ -85,7 +84,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -85,7 +84,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
```
```
使用/切换数据库
使用/切换数据库
-
**删除数据库**
-
**删除数据库**
```
mysql
```
mysql
DROP DATABASE [IF EXISTS] db_name;
DROP DATABASE [IF EXISTS] db_name;
...
@@ -120,7 +118,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -120,7 +118,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
**Tips**: 以上所有参数修改后都可以用show databases来确认是否修改成功。
**Tips**: 以上所有参数修改后都可以用show databases来确认是否修改成功。
-
**显示系统所有数据库**
-
**显示系统所有数据库**
```
mysql
```
mysql
SHOW DATABASES;
SHOW DATABASES;
...
@@ -153,7 +150,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -153,7 +150,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
显示当前数据库下的所有数据表信息。说明:可在like中使用通配符进行名称的匹配。 通配符匹配:1)’%’ (百分号)匹配0到任意个字符;2)’_’下划线匹配一个字符。
显示当前数据库下的所有数据表信息。说明:可在like中使用通配符进行名称的匹配。 通配符匹配:1)’%’ (百分号)匹配0到任意个字符;2)’_’下划线匹配一个字符。
-
**在线修改显示字符宽度**
-
**在线修改显示字符宽度**
```mysql
```mysql
...
@@ -234,7 +230,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -234,7 +230,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
```mysql
```mysql
ALTER TABLE stb_name ADD TAG new_tag_name tag_type;
ALTER TABLE stb_name ADD TAG new_tag_name tag_type;
```
```
为STable增加一个新的标签,并指定新标签的类型。标签总数不能超过128个,总长度不超过16k个字符
.
为STable增加一个新的标签,并指定新标签的类型。标签总数不能超过128个,总长度不超过16k个字符
。
-
**删除标签**
-
**删除标签**
...
@@ -265,28 +261,24 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -265,28 +261,24 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
```
```
向表tb_name中插入一条记录
向表tb_name中插入一条记录
-
**插入一条记录,数据对应到指定的列**
-
**插入一条记录,数据对应到指定的列**
```
mysql
```
mysql
INSERT INTO tb_name (field1_name, ...) VALUES(field1_value, ...)
INSERT INTO tb_name (field1_name, ...) VALUES(field1_value, ...)
```
```
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。
-
**插入多条记录**
-
**插入多条记录**
```
mysql
```
mysql
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...)...;
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...)...;
```
```
向表tb_name中插入多条记录
向表tb_name中插入多条记录
-
**按指定的列插入多条记录**
-
**按指定的列插入多条记录**
```
mysql
```
mysql
INSERT INTO tb_name (field1_name, ...) VALUES(field1_value1, ...) (field1_value2, ...)
INSERT INTO tb_name (field1_name, ...) VALUES(field1_value1, ...) (field1_value2, ...)
```
```
向表tb_name中按指定的列插入多条记录
向表tb_name中按指定的列插入多条记录
-
**向多个表插入多条记录**
-
**向多个表插入多条记录**
```
mysql
```
mysql
INSERT INTO tb1_name VALUES (field1_value1, ...)(field1_value2, ...)...
INSERT INTO tb1_name VALUES (field1_value1, ...)(field1_value2, ...)...
...
@@ -294,7 +286,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
...
@@ -294,7 +286,6 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
```
```
同时向表tb1_name和tb2_name中分别插入多条记录
同时向表tb1_name和tb2_name中分别插入多条记录
-
**同时向多个表按列插入多条记录**
-
**同时向多个表按列插入多条记录**
```
mysql
```
mysql
INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...)
INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...)
...
@@ -382,7 +373,6 @@ taos> SELECT * FROM meters;
...
@@ -382,7 +373,6 @@ taos> SELECT * FROM meters;
Query OK, 9 row(s) in set (0.002022s)
Query OK, 9 row(s) in set (0.002022s)
```
```
通配符支持表名前缀,以下两个SQL语句均为返回全部的列:
通配符支持表名前缀,以下两个SQL语句均为返回全部的列:
```
mysql
```
mysql
SELECT * FROM d1001;
SELECT * FROM d1001;
...
@@ -613,7 +603,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
...
@@ -613,7 +603,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 1 row(s) in set (0.001075s)
Query OK, 1 row(s) in set (0.001075s)
```
```
- **AVG**
- **AVG**
```mysql
```mysql
SELECT AVG(field_name) FROM tb_name [WHERE clause];
SELECT AVG(field_name) FROM tb_name [WHERE clause];
...
@@ -757,7 +746,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
...
@@ -757,7 +746,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 1 row(s) in set (0.000987s)
Query OK, 1 row(s) in set (0.000987s)
```
```
- **FIRST**
- **FIRST**
```mysql
```mysql
SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause];
...
@@ -937,7 +925,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
...
@@ -937,7 +925,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 2 row(s) in set (0.001162s)
Query OK, 2 row(s) in set (0.001162s)
```
```
- **SPREAD**
- **SPREAD**
```mysql
```mysql
SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause];
SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause];
...
@@ -962,7 +949,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
...
@@ -962,7 +949,6 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
Query OK, 1 row(s) in set (0.000836s)
Query OK, 1 row(s) in set (0.000836s)
```
```
- **四则运算**
- **四则运算**
```mysql
```mysql
...
@@ -1010,7 +996,6 @@ SELECT function_list FROM stb_name
...
@@ -1010,7 +996,6 @@ SELECT function_list FROM stb_name
4. PREV填充:使用前一个非NULL值填充数据。例如:fill(prev)。
4. PREV填充:使用前一个非NULL值填充数据。例如:fill(prev)。
说明:
说明:
1. 使用FILL语句的时候可能生成大量的填充输出,务必指定查询的时间区间。针对每次查询,系统可返回不超过1千万条具有插值的结果。
1. 使用FILL语句的时候可能生成大量的填充输出,务必指定查询的时间区间。针对每次查询,系统可返回不超过1千万条具有插值的结果。
2. 在时间维度聚合中,返回的结果中时间序列严格单调递增。
2. 在时间维度聚合中,返回的结果中时间序列严格单调递增。
...
@@ -1040,8 +1025,6 @@ SELECT AVG(current),MAX(current),LEASTSQUARES(current, start_val, step_val), PER
...
@@ -1040,8 +1025,6 @@ SELECT AVG(current),MAX(current),LEASTSQUARES(current, start_val, step_val), PER
- SQL语句最大长度65480个字符,但可通过系统配置参数maxSQLLength修改,最长可配置为1M
- SQL语句最大长度65480个字符,但可通过系统配置参数maxSQLLength修改,最长可配置为1M
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
## TAOS SQL其他约定
## TAOS SQL其他约定
**group by的限制**
**group by的限制**
...
@@ -1055,5 +1038,3 @@ TAOS SQL支持表之间按主键时间戳来join两张表的列,暂不支持
...
@@ -1055,5 +1038,3 @@ TAOS SQL支持表之间按主键时间戳来join两张表的列,暂不支持
**is not null与不为空的表达式适用范围**
**is not null与不为空的表达式适用范围**
is not null支持所有类型的列。不为空的表达式为 <>"",仅对非数值类型的列适用。
is not null支持所有类型的列。不为空的表达式为 <>"",仅对非数值类型的列适用。
\ No newline at end of file
documentation20/webdocs/markdowndocs/Taos Error Code-ch.md
浏览文件 @
a7c6e73f
# TDengine 2.0 错误码以及对应的十进制码
# TDengine 2.0 错误码以及对应的十进制码
| 状态码 | 模 | 错误码(十六进制) | 错误描述 | 错误码(十进制) |
| 状态码 | 模 | 错误码(十六进制) | 错误描述 | 错误码(十进制) |
|-----------------------| :---: | :---------: | :------------------------ | ---------------- |
|-----------------------| :---: | :---------: | :------------------------ | ---------------- |
|TSDB_CODE_RPC_ACTION_IN_PROGRESS| 0 | 0x0001| "Action in progress"| -2147483647|
|TSDB_CODE_RPC_ACTION_IN_PROGRESS| 0 | 0x0001| "Action in progress"| -2147483647|
...
...
documentation20/webdocs/markdowndocs/administrator-ch.md
浏览文件 @
a7c6e73f
...
@@ -159,7 +159,7 @@ ALTER DNODE <dnode_id> <config>
...
@@ -159,7 +159,7 @@ ALTER DNODE <dnode_id> <config>
## 客户端配置
## 客户端配置
TDengine系统的前台交互客户端应用程序为taos,以及应用驱动,它与taosd共享同一个配置文件taos.cfg。运行taos时,使用参数-c指定配置文件目录,如taos -c /home/cfg,表示使用/home/cfg/目录下的taos.cfg配置文件中的参数,缺省目录是/etc/taos。更多taos的使用方法请见
[
Shell命令行程序
](
https://www.taosdata.com/cn/documentation/administrator/#_TDengine_Shell命令行程序
)
。本节主要说明 taos 客户端应用在配置文件 taos.cfg 文件中使用到的参数。
TDengine系统的前台交互客户端应用程序为taos,以及应用驱动,它与taosd共享同一个配置文件taos.cfg。运行taos时,使用参数-c指定配置文件目录,如taos -c /home/cfg,表示使用/home/cfg/目录下的taos.cfg配置文件中的参数,缺省目录是/etc/taos。更多taos的使用方法请见
<a
href=
"https://www.taosdata.com/cn/documentation/administrator/#_TDengine_Shell命令行程序"
>
Shell命令行程序
</a>
。本节主要说明 taos 客户端应用在配置文件 taos.cfg 文件中使用到的参数。
**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置**
**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置**
...
@@ -247,7 +247,6 @@ taos -C 或 taos --dump-config
...
@@ -247,7 +247,6 @@ taos -C 或 taos --dump-config
Shell中binary 和 nchar字段的显示宽度上限,超过此限制的部分将被隐藏。默认值:30。可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项。
Shell中binary 和 nchar字段的显示宽度上限,超过此限制的部分将被隐藏。默认值:30。可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项。
## 用户管理
## 用户管理
系统管理员可以在CLI界面里添加、删除用户,也可以修改密码。CLI里SQL语法如下:
系统管理员可以在CLI界面里添加、删除用户,也可以修改密码。CLI里SQL语法如下:
...
@@ -428,8 +427,6 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
...
@@ -428,8 +427,6 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
您可以通过修改系统配置文件taos.cfg来配置不同的数据目录和日志目录。
您可以通过修改系统配置文件taos.cfg来配置不同的数据目录和日志目录。
## TDengine参数限制与保留关键字
## TDengine参数限制与保留关键字
-
数据库名:不能包含“.”以及特殊字符,不能超过32个字符
-
数据库名:不能包含“.”以及特殊字符,不能超过32个字符
...
@@ -448,8 +445,6 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
...
@@ -448,8 +445,6 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
-
库的个数:仅受节点个数限制
-
库的个数:仅受节点个数限制
-
单个库上虚拟节点个数:不能超过64个
-
单个库上虚拟节点个数:不能超过64个
目前TDengine有将近200个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable名、数据列名及标签列名等。这些关键字列表如下:
目前TDengine有将近200个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable名、数据列名及标签列名等。这些关键字列表如下:
| 关键字列表 | | | | |
| 关键字列表 | | | | |
...
@@ -490,4 +485,3 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
...
@@ -490,4 +485,3 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下
| CONCAT | GLOB | METRICS | SEMI | WAVG |
| CONCAT | GLOB | METRICS | SEMI | WAVG |
| CONFIGS | GRANTS | MIN | SET | WHERE |
| CONFIGS | GRANTS | MIN | SET | WHERE |
| CONFLICT | GROUP | | | |
| CONFLICT | GROUP | | | |
\ No newline at end of file
documentation20/webdocs/markdowndocs/architecture-ch.md
浏览文件 @
a7c6e73f
#
数据模型和整体架构
#
数据模型和整体架构
## 数据模型
## 数据模型
### 物联网典型场景
### 物联网典型场景
...
@@ -150,7 +150,7 @@ TDengine 分布式架构的逻辑结构图如下:
...
@@ -150,7 +150,7 @@ TDengine 分布式架构的逻辑结构图如下:
<center>
图 1 TDengine架构示意图
</center>
<center>
图 1 TDengine架构示意图
</center>
一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过taosc的API与TDengine集群进行互动。下面对每个逻辑单元进行简要介绍。
一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过taosc的API与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
)
》
。
**物理节点(pnode):**
pnode是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有OS的物理机、虚拟机或Docker容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine完全依赖FQDN来进行网络通讯,如果不了解FQDN,请看博文
<a
href=
"https://www.taosdata.com/blog/2020/09/11/1824.html"
>
《一篇文章说清楚TDengine的FQDN》
</a>
。
**数据节点(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)。dnode在系统中的唯一标识由实例的End Point (EP )决定。EP是dnode所在物理节点的FQDN (Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。
...
...
documentation20/webdocs/markdowndocs/cluster-ch.md
浏览文件 @
a7c6e73f
...
@@ -226,3 +226,5 @@ SHOW MNODES;
...
@@ -226,3 +226,5 @@ SHOW MNODES;
如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。
如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。
TDengine提供一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。请点击
[
安装包下载
](
https://www.taosdata.com/cn/all-downloads/
)
,在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数
`-p`
可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。如果副本数为奇数,即使配置了arbitrator, 系统也不会去建立连接。
TDengine提供一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。请点击
[
安装包下载
](
https://www.taosdata.com/cn/all-downloads/
)
,在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数
`-p`
可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。如果副本数为奇数,即使配置了arbitrator, 系统也不会去建立连接。
关于集群搭建请参考
<a
href=
"https://www.taosdata.com/blog/2020/11/11/1961.html"
>
视频教程
</a>
。
documentation20/webdocs/markdowndocs/connector-ch.md
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
documentation20/webdocs/markdowndocs/connector-java-ch.md
浏览文件 @
a7c6e73f
# Java Connector
# Java Connector
**Java连接器支持的系统有:**
Java连接器支持的系统有:
|
**CPU类型**
| x64(64bit) | | | ARM64 | ARM32 |
|
**CPU类型**
| x64(64bit) | | | aarch64 | aarch32 |
| ------------ | ------------ | -------- | -------- | -------- | -------- |
| ------------ | ------------ | -------- | -------- | -------- | -------- |
|
**OS类型**
| Linux | Win64 | Win32 | Linux | Linux |
|
**OS类型**
| Linux | Win64 | Win32 | Linux | Linux |
|
**支持与否**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
|
**支持与否**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
**支持**
|
Java连接器的使用请参见
<a
href=
https://www.taosdata.com/blog/2020/11/11/1955.html
>
视频教程
</a>
。
TDengine 为了方便 Java 应用使用,提供了遵循 JDBC 标准(3.0)API 规范的
`taos-jdbcdriver`
实现。目前可以通过
[
Sonatype Repository
][
1
]
搜索并下载。
TDengine 为了方便 Java 应用使用,提供了遵循 JDBC 标准(3.0)API 规范的
`taos-jdbcdriver`
实现。目前可以通过
[
Sonatype Repository
][
1
]
搜索并下载。
由于 TDengine 是使用 c 语言开发的,使用 taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。
由于 TDengine 是使用 c 语言开发的,使用 taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。
...
@@ -26,7 +27,6 @@ TDengine 的 JDBC 驱动实现尽可能的与关系型数据库驱动保持一
...
@@ -26,7 +27,6 @@ TDengine 的 JDBC 驱动实现尽可能的与关系型数据库驱动保持一
*
目前不支持表间的 union 操作。
*
目前不支持表间的 union 操作。
*
目前不支持嵌套查询(nested query),对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet还没关闭的情况下执行了新的查询,TSDBJDBCDriver 则会自动关闭上一个 ResultSet。
*
目前不支持嵌套查询(nested query),对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet还没关闭的情况下执行了新的查询,TSDBJDBCDriver 则会自动关闭上一个 ResultSet。
## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本
## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本
| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 |
| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 |
...
@@ -75,7 +75,6 @@ maven 项目中使用如下 pom.xml 配置即可:
...
@@ -75,7 +75,6 @@ maven 项目中使用如下 pom.xml 配置即可:
下载
[
TDengine
][
3
]
源码之后,进入 taos-jdbcdriver 源码目录
`src/connector/jdbc`
执行
`mvn clean package`
即可生成相应 jar 包。
下载
[
TDengine
][
3
]
源码之后,进入 taos-jdbcdriver 源码目录
`src/connector/jdbc`
执行
`mvn clean package`
即可生成相应 jar 包。
## 使用说明
## 使用说明
### 获取连接
### 获取连接
...
@@ -217,7 +216,6 @@ while(resultSet.next()){
...
@@ -217,7 +216,6 @@ while(resultSet.next()){
```
```
> 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。
> 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。
### 订阅
### 订阅
#### 创建
#### 创建
...
@@ -232,7 +230,7 @@ TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from met
...
@@ -232,7 +230,7 @@ TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from met
*
sql:订阅的查询语句,此语句只能是
`select`
语句,只应查询原始数据,只能按时间正序查询数据
*
sql:订阅的查询语句,此语句只能是
`select`
语句,只应查询原始数据,只能按时间正序查询数据
*
restart:如果订阅已经存在,是重新开始,还是继续之前的订阅
*
restart:如果订阅已经存在,是重新开始,还是继续之前的订阅
如上面的例子将使用 SQL 语句
`select * from meters`
创建一个名为
`topic
'
的订阅,如果这个订阅已经存在,将继续之前的查询进度,而不是从头开始消费所有的数据。
如上面的例子将使用 SQL 语句
`select * from meters`
创建一个名为
`topic
`
的订阅,如果这个订阅已经存在,将继续之前的查询进度,而不是从头开始消费所有的数据。
#### 消费数据
#### 消费数据
...
@@ -260,7 +258,6 @@ sub.close(true);
...
@@ -260,7 +258,6 @@ sub.close(true);
`close`
方法关闭一个订阅。如果其参数为
`true`
表示保留订阅进度信息,后续可以创建同名订阅继续消费数据;如为
`false`
则不保留订阅进度。
`close`
方法关闭一个订阅。如果其参数为
`true`
表示保留订阅进度信息,后续可以创建同名订阅继续消费数据;如为
`false`
则不保留订阅进度。
### 关闭资源
### 关闭资源
```
java
```
java
...
...
documentation20/webdocs/markdowndocs/faq-ch.md
浏览文件 @
a7c6e73f
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
3.
在服务器,执行
`systemctl status taosd`
检查
*taosd*
运行状态。如果没有运行,启动
*taosd*
3.
在服务器,执行
`systemctl status taosd`
检查
*taosd*
运行状态。如果没有运行,启动
*taosd*
4.
确认客户端连接时指定了正确的服务器FQDN (Fully Qualified Domain Name(可在服务器上执行Linux命令hostname -f获得)),FQDN配置参考:
[
一篇文章说清楚TDengine的FQDN
](
https://www.taosdata.com/blog/2020/09/11/1824.html
)
。
4.
确认客户端连接时指定了正确的服务器FQDN (Fully Qualified Domain Name(可在服务器上执行Linux命令hostname -f获得)),FQDN配置参考:
<a
href=
"https://www.taosdata.com/blog/2020/09/11/1824.html"
>
一篇文章说清楚TDengine的FQDN
</a>
。
5.
ping服务器FQDN,如果没有反应,请检查你的网络,DNS设置,或客户端所在计算机的系统hosts文件
5.
ping服务器FQDN,如果没有反应,请检查你的网络,DNS设置,或客户端所在计算机的系统hosts文件
...
@@ -51,19 +51,16 @@
...
@@ -51,19 +51,16 @@
*
Windows 系统请使用 PowerShell 命令 Net-TestConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
*
Windows 系统请使用 PowerShell 命令 Net-TestConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
10.
也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):
[
TDengine 内嵌网络检测工具使用指南
](
https://www.taosdata.com/blog/2020/09/08/1816.html
)
。
10.
也可以使用taos程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括TCP和UDP):
<a
href=
"https://www.taosdata.com/blog/2020/09/08/1816.html"
>
TDengine 内嵌网络检测工具使用指南
</a>
。
## 6. 遇到错误“Unexpected generic error in RPC”或者"TDengine Error: Unable to resolve FQDN", 我怎么办?
## 6. 遇到错误“Unexpected generic error in RPC”或者"TDengine Error: Unable to resolve FQDN", 我怎么办?
产生这个错误,是由于客户端或数据节点无法解析FQDN(Fully Qualified Domain Name)导致。对于TAOS Shell或客户端应用,请做如下检查:
产生这个错误,是由于客户端或数据节点无法解析FQDN(Fully Qualified Domain Name)导致。对于TAOS Shell或客户端应用,请做如下检查:
1.
请检查连接的服务器的FQDN是否正确,FQDN配置参考:
[
一篇文章说清楚TDengine的FQDN
](
https://www.taosdata.com/blog/2020/09/11/1824.html
)
。
1.
请检查连接的服务器的FQDN是否正确,FQDN配置参考:
<a
href=
"https://www.taosdata.com/blog/2020/09/11/1824.html"
>
一篇文章说清楚TDengine的FQDN
</a>
。
2.
如果网络配置有DNS server, 请检查是否正常工作
2.
如果网络配置有DNS server, 请检查是否正常工作
3.
如果网络没有配置DNS server, 请检查客户端所在机器的hosts文件,查看该FQDN是否配置,并是否有正确的IP地址。
3.
如果网络没有配置DNS server, 请检查客户端所在机器的hosts文件,查看该FQDN是否配置,并是否有正确的IP地址。
4.
如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法连接服务器的
4.
如果网络配置OK,从客户端所在机器,你需要能Ping该连接的FQDN,否则客户端是无法连接服务器的
## 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误
## 7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误
如果你确认语法正确,2.0之前版本,请检查SQL语句长度是否超过64K。如果超过,也会返回这个错误。
如果你确认语法正确,2.0之前版本,请检查SQL语句长度是否超过64K。如果超过,也会返回这个错误。
...
@@ -86,7 +83,7 @@ TDengine还没有一组专用的validation queries。然而建议你使用系统
...
@@ -86,7 +83,7 @@ TDengine还没有一组专用的validation queries。然而建议你使用系统
## 11. 最有效的写入数据的方法是什么?windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?
## 11. 最有效的写入数据的方法是什么?windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?
w
indows下插入nchar类的数据中如果有中文,请先确认系统的地区设置成了中国(在Control Panel里可以设置),这时cmd中的
`taos`
客户端应该已经可以正常工作了;如果是在IDE里开发Java应用,比如Eclipse, Intellij,请确认IDE里的文件编码为GBK(这是Java默认的编码类型),然后在生成Connection时,初始化客户端的配置,具体语句如下:
W
indows下插入nchar类的数据中如果有中文,请先确认系统的地区设置成了中国(在Control Panel里可以设置),这时cmd中的
`taos`
客户端应该已经可以正常工作了;如果是在IDE里开发Java应用,比如Eclipse, Intellij,请确认IDE里的文件编码为GBK(这是Java默认的编码类型),然后在生成Connection时,初始化客户端的配置,具体语句如下:
```
JAVA
```
JAVA
Class.forName("com.taosdata.jdbc.TSDBDriver");
Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties();
Properties properties = new Properties();
...
@@ -94,7 +91,7 @@ properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
...
@@ -94,7 +91,7 @@ properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8");
Connection = DriverManager.getConnection(url, properties);
Connection = DriverManager.getConnection(url, properties);
```
```
## 12.TDengine GO windows驱动的如何编译?
## 12.TDengine GO windows驱动的如何编译?
请看为此问题撰写的
<a
href=
'blog/2020/01/06/tdengine-go-windows驱动的编译/'
>
技术博客
请看为此问题撰写的
<a
href=
'blog/2020/01/06/tdengine-go-windows驱动的编译/'
>
技术博客
</a>
## 13.JDBC报错: the excuted SQL is not a DML or a DDL?
## 13.JDBC报错: the excuted SQL is not a DML or a DDL?
请更新至最新的JDBC驱动
请更新至最新的JDBC驱动
...
@@ -109,14 +106,10 @@ Connection = DriverManager.getConnection(url, properties);
...
@@ -109,14 +106,10 @@ Connection = DriverManager.getConnection(url, properties);
常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。
常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。
## 15. 表名显示不全
## 15. 表名显示不全
由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用
\G
参数来调整结果的显示方式。
由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用
\G
参数来调整结果的显示方式。
## 16. 如何进行数据迁移?
## 16. 如何进行数据迁移?
TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A移动机器B时,注意如下两件事:
TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A移动机器B时,注意如下两件事:
...
@@ -125,11 +118,9 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A
...
@@ -125,11 +118,9 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A
-
2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。
-
2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。
-
1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
-
1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。
## 17. 怎么报告问题?
## 17. 怎么报告问题?
如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包
:
如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包
:
1.
/var/log/taos
1.
/var/log/taos
2.
/etc/taos
2.
/etc/taos
...
...
documentation20/webdocs/markdowndocs/insert-ch.md
浏览文件 @
a7c6e73f
...
@@ -28,10 +28,10 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6,
...
@@ -28,10 +28,10 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6,
-
写入的数据的时间戳必须大于当前时间减去配置参数keep的时间。如果keep配置为3650天,那么无法写入比3650天还老的数据。写入数据的时间戳也不能大于当前时间加配置参数days。如果days配置为2,那么无法写入比当前时间还晚2天的数据。
-
写入的数据的时间戳必须大于当前时间减去配置参数keep的时间。如果keep配置为3650天,那么无法写入比3650天还老的数据。写入数据的时间戳也不能大于当前时间加配置参数days。如果days配置为2,那么无法写入比当前时间还晚2天的数据。
## Prometheus直接写入
## Prometheus直接写入
[
Prometheus
](
https://www.prometheus.io/
)
作为Cloud Native Computing Fundation毕业的项目,在性能监控以及K8S性能监控领域有着非常广泛的应用。TDengine提供一个小工具
[
Bailongma
](
https://github.com/taosdata/Bailongma
)
,只需在Prometheus做简单配置,无需任何代码,就可将Prometheus采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文
[
用Docker容器快速搭建一个Devops监控Demo
](
https://www.taosdata.com/blog/2020/02/03/1189.html
)
即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。
<a
href=
"https://www.prometheus.io/"
>
Prometheus
</a>
作为Cloud Native Computing Fundation毕业的项目,在性能监控以及K8S性能监控领域有着非常广泛的应用。TDengine提供一个小工具
<a
href=
"https://github.com/taosdata/Bailongma"
>
Bailongma
</a>
,只需在Prometheus做简单配置,无需任何代码,就可将Prometheus采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文
<a
href=
"https://www.taosdata.com/blog/2020/02/03/1189.html"
>
用Docker容器快速搭建一个Devops监控Demo
</a>
即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。
### 从源代码编译blm_prometheus
### 从源代码编译blm_prometheus
用户需要从github下载
[
Bailongma
](
https://github.com/taosdata/Bailongma
)
的源码,使用Golang语言编译器编译生成可执行文件。在开始编译前,需要准备好以下条件:
用户需要从github下载
<a
href=
"https://github.com/taosdata/Bailongma"
>
Bailongma
</a>
的源码,使用Golang语言编译器编译生成可执行文件。在开始编译前,需要准备好以下条件:
-
Linux操作系统的服务器
-
Linux操作系统的服务器
-
安装好Golang, 1.10版本以上
-
安装好Golang, 1.10版本以上
-
对应的TDengine版本。因为用到了TDengine的客户端动态链接库,因此需要安装好和服务端相同版本的TDengine程序;比如服务端版本是TDengine 2.0.0, 则在bailongma所在的linux服务器(可以与TDengine在同一台服务器,或者不同服务器)
-
对应的TDengine版本。因为用到了TDengine的客户端动态链接库,因此需要安装好和服务端相同版本的TDengine程序;比如服务端版本是TDengine 2.0.0, 则在bailongma所在的linux服务器(可以与TDengine在同一台服务器,或者不同服务器)
...
@@ -45,10 +45,10 @@ go build
...
@@ -45,10 +45,10 @@ go build
一切正常的情况下,就会在对应的目录下生成一个blm_prometheus的可执行程序。
一切正常的情况下,就会在对应的目录下生成一个blm_prometheus的可执行程序。
### 安装Prometheus
### 安装Prometheus
通过Prometheus的官网下载安装。
[
下载地址
](
https://prometheus.io/download/
)
通过Prometheus的官网下载安装。
<a
href=
"https://prometheus.io/download/"
>
下载地址
</a>
### 配置Prometheus
### 配置Prometheus
参考Prometheus的
[
配置文档
](
https://prometheus.io/docs/prometheus/latest/configuration/configuration/
)
,
在Prometheus的配置文件中的
<remote_write>
部分,增加以下配置
参考Prometheus的
<a
href=
"https://prometheus.io/docs/prometheus/latest/configuration/configuration/"
>
配置文档
</a>
,
在Prometheus的配置文件中的
<remote_write>
部分,增加以下配置
-
url: bailongma API服务提供的URL, 参考下面的blm_prometheus启动示例章节
-
url: bailongma API服务提供的URL, 参考下面的blm_prometheus启动示例章节
...
@@ -113,10 +113,10 @@ select * from apiserver_request_latencies_bucket;
...
@@ -113,10 +113,10 @@ select * from apiserver_request_latencies_bucket;
```
```
## Telegraf直接写入
## Telegraf直接写入
[
Telegraf
](
https://www.influxdata.com/time-series-platform/telegraf/
)
是一流行的IT运维数据采集开源工具,TDengine提供一个小工具
[
Bailongma
](
https://github.com/taosdata/Bailongma
)
,只需在Telegraf做简单配置,无需任何代码,就可将Telegraf采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文
[
用Docker容器快速搭建一个Devops监控Demo
](
https://www.taosdata.com/blog/2020/02/03/1189.html
)
即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。
<a
href=
"https://www.influxdata.com/time-series-platform/telegraf/"
Telegraf
</
a
>
是一流行的IT运维数据采集开源工具,TDengine提供一个小工具
<a
href=
"https://github.com/taosdata/Bailongma"
>
Bailongma
</a>
,只需在Telegraf做简单配置,无需任何代码,就可将Telegraf采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文
<a
href=
"https://www.taosdata.com/blog/2020/02/03/1189.html"
>
用Docker容器快速搭建一个Devops监控Demo
</a>
即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。
### 从源代码编译blm_telegraf
### 从源代码编译blm_telegraf
用户需要从github下载
[
Bailongma
](
https://github.com/taosdata/Bailongma
)
的源码,使用Golang语言编译器编译生成可执行文件。在开始编译前,需要准备好以下条件:
用户需要从github下载
<a
href=
"https://github.com/taosdata/Bailongma"
>
Bailongma
</a>
的源码,使用Golang语言编译器编译生成可执行文件。在开始编译前,需要准备好以下条件:
-
Linux操作系统的服务器
-
Linux操作系统的服务器
-
安装好Golang, 1.10版本以上
-
安装好Golang, 1.10版本以上
...
@@ -148,7 +148,7 @@ go build
...
@@ -148,7 +148,7 @@ go build
-
hostname: 区分不同采集设备的机器名称,需确保其唯一性
-
hostname: 区分不同采集设备的机器名称,需确保其唯一性
-
metric_batch_size: 100,允许Telegraf每批次写入记录最大数量,增大其数量可以降低Telegraf的请求发送频率。
-
metric_batch_size: 100,允许Telegraf每批次写入记录最大数量,增大其数量可以降低Telegraf的请求发送频率。
关于如何使用Telegraf采集数据以及更多有关使用Telegraf的信息,请参考Telegraf官方的
[
文档
](
https://docs.influxdata.com/telegraf/v1.11/
)
。
关于如何使用Telegraf采集数据以及更多有关使用Telegraf的信息,请参考Telegraf官方的
<a
href=
"https://docs.influxdata.com/telegraf/v1.11/"
>
文档
</a>
。
### 启动blm_telegraf程序
### 启动blm_telegraf程序
blm_telegraf程序有以下选项,在启动blm_telegraf程序时可以通过设定这些选项来设定blm_telegraf的配置。
blm_telegraf程序有以下选项,在启动blm_telegraf程序时可以通过设定这些选项来设定blm_telegraf的配置。
...
@@ -218,15 +218,12 @@ use telegraf;
...
@@ -218,15 +218,12 @@ use telegraf;
select * from cpu;
select * from cpu;
```
```
MQTT是一流行的物联网数据传输协议,TDengine 可以很方便的接入 MQTT Broker 接受的数据并写入到 TDengine。
MQTT是一流行的物联网数据传输协议,TDengine 可以很方便的接入 MQTT Broker 接受的数据并写入到 TDengine。
## EMQ Broker 直接写入
## EMQ Broker 直接写入
[
EMQ
](
https://github.com/emqx/emqx
)
是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDengine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考
[
EMQ 官方文档
](
https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine
)
。
<a
href=
"https://github.com/emqx/emqx"
>
EMQ
</a>
是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDengine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考
<a
href=
"https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine"
>
EMQ 官方文档
</a>
。
## HiveMQ Broker 直接写入
## HiveMQ Broker 直接写入
[
HiveMQ
](
https://www.hivemq.com/
)
是一个提供免费个人版和企业版的 MQTT 代理,主要用于企业和新兴的机器到机器M2M通讯和内部传输,满足可伸缩性、易管理和安全特性。HiveMQ 提供了开源的插件开发包。可以通过 HiveMQ extension - TDengine 保存数据到 TDengine。详细使用方法请参考
[
HiveMQ extension - TDengine 说明文档
](
https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README.md
)
。
<a
href=
"https://www.hivemq.com/"
>
HiveMQ
</a>
是一个提供免费个人版和企业版的 MQTT 代理,主要用于企业和新兴的机器到机器M2M通讯和内部传输,满足可伸缩性、易管理和安全特性。HiveMQ 提供了开源的插件开发包。可以通过 HiveMQ extension - TDengine 保存数据到 TDengine。详细使用方法请参考
<a
href=
"https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README.md"
>
HiveMQ extension - TDengine 说明文档
</a>
。
documentation20/webdocs/markdowndocs/replica-ch.md
浏览文件 @
a7c6e73f
...
@@ -30,7 +30,7 @@ TDengine里存在vnode, mnode, vnode用来存储时序数据,mnode用来存储
...
@@ -30,7 +30,7 @@ TDengine里存在vnode, mnode, vnode用来存储时序数据,mnode用来存储
-
master: 具有最新的数据,容许客户端往里写入数据,一个虚拟节点组,至多一个master.
-
master: 具有最新的数据,容许客户端往里写入数据,一个虚拟节点组,至多一个master.
-
slave:与master是同步的,但不容许客户端往里写入数据,根据配置,可以容许客户端对其进行查询。
-
slave:与master是同步的,但不容许客户端往里写入数据,根据配置,可以容许客户端对其进行查询。
-
unsynced: 节点处于非同步状态,比如虚拟节点刚启动、或与其他虚拟节点的连接出现故障等。处于该状态时,该虚拟节点既不能提供写入,也不能提供查询服务
-
unsynced: 节点处于非同步状态,比如虚拟节点刚启动、或与其他虚拟节点的连接出现故障等。处于该状态时,该虚拟节点既不能提供写入,也不能提供查询服务
。
-
offline: 由于宕机或网络原因,无法访问到某虚拟节点时,其他虚拟节点将该虚拟节点标为离线。但请注意,该虚拟节点本身的状态可能是unsynced或其他,但不会是离线。
-
offline: 由于宕机或网络原因,无法访问到某虚拟节点时,其他虚拟节点将该虚拟节点标为离线。但请注意,该虚拟节点本身的状态可能是unsynced或其他,但不会是离线。
**Quorum:**
**Quorum:**
...
@@ -83,10 +83,10 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性
...
@@ -83,10 +83,10 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性
如果一个虚拟节点(vnode A)检测到与同一虚拟节点组内另外一虚拟节点(vnode B)的连接中断,vnode A将立即把vnode B的role设置为offline。无论是接收到另外一虚拟节点发来的status消息,还是检测与另外一虚拟节点的连接中断,该虚拟节点都将进入状态处理流程。状态处理流程的规则如下:
如果一个虚拟节点(vnode A)检测到与同一虚拟节点组内另外一虚拟节点(vnode B)的连接中断,vnode A将立即把vnode B的role设置为offline。无论是接收到另外一虚拟节点发来的status消息,还是检测与另外一虚拟节点的连接中断,该虚拟节点都将进入状态处理流程。状态处理流程的规则如下:
1.
如果检测到在线的节点数没有超过一半,则将自己的状态设置为unsynced.
1.
如果检测到在线的节点数没有超过一半,则将自己的状态设置为unsynced.
2.
如果在线的虚拟节点数超过一半,会检查master节点是否存在,如果存在,则会决定是否将自己状态改为slave或启动数据恢复流程
2.
如果在线的虚拟节点数超过一半,会检查master节点是否存在,如果存在,则会决定是否将自己状态改为slave或启动数据恢复流程
。
3.
如果master不存在,则会检查自己保存的各虚拟节点的状态信息与从另一节点接收到的是否一致,如果一致,说明节点组里状态已经稳定一致,则会触发选举流程。如果不一致,说明状态还没趋于一致,即使master不存在,也不进行选主。由于要求状态信息一致才进行选举,每个虚拟节点根据同样的信息,会选出同一个虚拟节点做master,无需投票表决。
3.
如果master不存在,则会检查自己保存的各虚拟节点的状态信息与从另一节点接收到的是否一致,如果一致,说明节点组里状态已经稳定一致,则会触发选举流程。如果不一致,说明状态还没趋于一致,即使master不存在,也不进行选主。由于要求状态信息一致才进行选举,每个虚拟节点根据同样的信息,会选出同一个虚拟节点做master,无需投票表决。
4.
自己的状态是根据规则自己决定并修改的,并不需要其他节点同意,包括成为master。一个节点无权修改其他节点的状态。
4.
自己的状态是根据规则自己决定并修改的,并不需要其他节点同意,包括成为master。一个节点无权修改其他节点的状态。
5.
如果一个虚拟节点检测到自己或其他虚拟节点的role发生改变,该节点会广播它自己保存的各个虚拟节点的状态信息(role和version)
.
5.
如果一个虚拟节点检测到自己或其他虚拟节点的role发生改变,该节点会广播它自己保存的各个虚拟节点的状态信息(role和version)
。
具体的流程图如下:
具体的流程图如下:
...
@@ -124,7 +124,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性
...
@@ -124,7 +124,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性
如果一虚拟节点(vnode B) 处于unsynced状态,master存在(vnode A),而且其版本号比master的低,它将立即启动数据恢复流程。在理解恢复流程时,需要澄清几个关于文件的概念和处理规则。
如果一虚拟节点(vnode B) 处于unsynced状态,master存在(vnode A),而且其版本号比master的低,它将立即启动数据恢复流程。在理解恢复流程时,需要澄清几个关于文件的概念和处理规则。
1.
每个文件(无论是archived data的file还是wal)都有一个index, 这需要应用来维护(vnode里,该index就是fileId
*
3 + 0/1/2, 对应data, head与last三个文件)。如果index为0,表示系统里最老的数据文件。对于m
n
ode里的文件,数量是固定的,对应于acct, user, db, table等文件。
1.
每个文件(无论是archived data的file还是wal)都有一个index, 这需要应用来维护(vnode里,该index就是fileId
*
3 + 0/1/2, 对应data, head与last三个文件)。如果index为0,表示系统里最老的数据文件。对于mode里的文件,数量是固定的,对应于acct, user, db, table等文件。
2.
任何一个数据文件(file)有名字、大小,还有一个magic number。只有文件名、大小与magic number一致时,两个文件才判断是一样的,无需同步。Magic number可以是checksum, 也可以是简单的文件大小。怎么计算magic,换句话说,如何检测数据文件是否有效,完全由应用决定。
2.
任何一个数据文件(file)有名字、大小,还有一个magic number。只有文件名、大小与magic number一致时,两个文件才判断是一样的,无需同步。Magic number可以是checksum, 也可以是简单的文件大小。怎么计算magic,换句话说,如何检测数据文件是否有效,完全由应用决定。
3.
文件名的处理有点复杂,因为每台服务器的路径可能不一致。比如node A的TDengine的数据文件存放在 /etc/taos目录下,而node B的数据存放在 /home/jhtao目录下。因此同步模块需要应用在启动一个同步实例时提供一个path,这样两台服务器的绝对路径可以不一样,但仍然可以做对比,做同步。
3.
文件名的处理有点复杂,因为每台服务器的路径可能不一致。比如node A的TDengine的数据文件存放在 /etc/taos目录下,而node B的数据存放在 /home/jhtao目录下。因此同步模块需要应用在启动一个同步实例时提供一个path,这样两台服务器的绝对路径可以不一样,但仍然可以做对比,做同步。
4.
当sync模块调用回调函数getFileInfo获得数据文件信息时,有如下的规则
4.
当sync模块调用回调函数getFileInfo获得数据文件信息时,有如下的规则
...
@@ -212,10 +212,10 @@ Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系
...
@@ -212,10 +212,10 @@ Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系
相同之处:
相同之处:
-
三大流程一致:Raft里有Leader election, replication, safety,完全对应TDengine的选举、数据转发、数据恢复三个流程
-
三大流程一致:Raft里有Leader election, replication, safety,完全对应TDengine的选举、数据转发、数据恢复三个流程
。
-
节点状态定义一致:Raft里每个节点有Leader, Follower, Candidate三个状态,TDengine里是Master, Slave, Unsynced, Offline。多了一个offlince, 但本质上是一样的,因为offline是外界看一个节点的状态,但该节点本身是处于master, slave 或unsynced的
-
节点状态定义一致:Raft里每个节点有Leader, Follower, Candidate三个状态,TDengine里是Master, Slave, Unsynced, Offline。多了一个offlince, 但本质上是一样的,因为offline是外界看一个节点的状态,但该节点本身是处于master, slave 或unsynced的
。
-
数据转发流程完全一样,Master(leader)需要等待回复确认。
-
数据转发流程完全一样,Master(leader)需要等待回复确认。
-
数据恢复流程几乎一样,Raft没有涉及历史数据同步问题,只考虑了WAL数据同步
-
数据恢复流程几乎一样,Raft没有涉及历史数据同步问题,只考虑了WAL数据同步
。
不同之处:
不同之处:
...
@@ -226,7 +226,7 @@ Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系
...
@@ -226,7 +226,7 @@ Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系
## Meta Data的数据复制
## Meta Data的数据复制
TDengine里存在时序数据,也存在Meta Data。Meta Data对数据的可靠性要求更高,那么TDengine设计能否满足要求呢?下面做个仔细分析
TDengine里存在时序数据,也存在Meta Data。Meta Data对数据的可靠性要求更高,那么TDengine设计能否满足要求呢?下面做个仔细分析
。
TDengine里Meta Data包括以下:
TDengine里Meta Data包括以下:
...
...
packaging/cfg/taos.cfg
浏览文件 @
a7c6e73f
...
@@ -39,10 +39,10 @@
...
@@ -39,10 +39,10 @@
# number of management nodes in the system
# number of management nodes in the system
# numOfMnodes 3
# numOfMnodes 3
# enable/disable backuping vnode directory when removing
d
node
# enable/disable backuping vnode directory when removing
v
node
# vnodeBak 1
# vnodeBak 1
#
if report installation / use information
#
enable/disable installation / usage report
# telemetryReporting 1
# telemetryReporting 1
# enable/disable load balancing
# enable/disable load balancing
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
# minimum time window, milli-second
# minimum time window, milli-second
# minIntervalTime 10
# minIntervalTime 10
# maximum delay before launching a stream compution, milli-second
# maximum delay before launching a stream comput
at
ion, milli-second
# maxStreamCompDelay 20000
# maxStreamCompDelay 20000
# maximum delay before launching a stream computation for the first time, milli-second
# maximum delay before launching a stream computation for the first time, milli-second
...
@@ -156,7 +156,7 @@
...
@@ -156,7 +156,7 @@
# max number of connections allowed in dnode
# max number of connections allowed in dnode
# maxShellConns 5000
# maxShellConns 5000
# max num
erber of connections allowed in client
# max num
ber of connections allowed in client
# maxConnections 5000
# maxConnections 5000
# stop writing logs when the disk size of the log folder is less than this value
# stop writing logs when the disk size of the log folder is less than this value
...
@@ -187,7 +187,7 @@
...
@@ -187,7 +187,7 @@
# restfulRowLimit 10240
# restfulRowLimit 10240
# The following parameter is used to limit the maximum number of lines in log files.
# The following parameter is used to limit the maximum number of lines in log files.
# max number of
row
s per log filters
# max number of
line
s per log filters
# numOfLogLines 10000000
# numOfLogLines 10000000
# enable/disable async log
# enable/disable async log
...
@@ -199,7 +199,9 @@
...
@@ -199,7 +199,9 @@
# The following parameters are used for debug purpose only.
# The following parameters are used for debug purpose only.
# debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
# debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
# 131: output warning and error, 135: output debug, warning and error, 143 : output trace, debug, warning and error to log.
# 131: output warning and error
# 135: output debug, warning and error
# 143: output trace, debug, warning and error to log
# 199: output debug, warning and error to both screen and file
# 199: output debug, warning and error to both screen and file
# 207: output trace, debug, warning and error to both screen and file
# 207: output trace, debug, warning and error to both screen and file
...
@@ -231,10 +233,10 @@
...
@@ -231,10 +233,10 @@
# cDebugFlag 131
# cDebugFlag 131
# debug flag for JNI
# debug flag for JNI
# jniDebug
f
lag 131
# jniDebug
F
lag 131
# debug flag for storage
# debug flag for storage
# uDebug
f
lag 131
# uDebug
F
lag 131
# debug flag for http server
# debug flag for http server
# httpDebugFlag 131
# httpDebugFlag 131
...
@@ -243,12 +245,12 @@
...
@@ -243,12 +245,12 @@
# monDebugFlag 131
# monDebugFlag 131
# debug flag for query
# debug flag for query
# qDebug
f
lag 131
# qDebug
F
lag 131
# debug flag for vnode
# debug flag for vnode
# vDebug
f
lag 131
# vDebug
F
lag 131
# debug flag for
http server
# debug flag for
TSDB
# tsdbDebugFlag 131
# tsdbDebugFlag 131
# debug flag for continue query
# debug flag for continue query
...
...
packaging/tools/post.sh
浏览文件 @
a7c6e73f
...
@@ -266,8 +266,14 @@ function install_config() {
...
@@ -266,8 +266,14 @@ function install_config() {
${
csudo
}
chmod
644
${
cfg_install_dir
}
/
*
${
csudo
}
chmod
644
${
cfg_install_dir
}
/
*
fi
fi
# Save standard input to 6 and open / dev / TTY on standard input
exec
6<&0 0</dev/tty
local_fqdn_check
local_fqdn_check
# restore the backup standard input, and turn off 6
exec
0<&6 6<&-
${
csudo
}
mv
${
cfg_dir
}
/taos.cfg
${
cfg_dir
}
/taos.cfg.org
${
csudo
}
mv
${
cfg_dir
}
/taos.cfg
${
cfg_dir
}
/taos.cfg.org
${
csudo
}
ln
-s
${
cfg_install_dir
}
/taos.cfg
${
cfg_dir
}
${
csudo
}
ln
-s
${
cfg_install_dir
}
/taos.cfg
${
cfg_dir
}
#FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
#FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
...
@@ -422,7 +428,7 @@ function install_service() {
...
@@ -422,7 +428,7 @@ function install_service() {
}
}
function
install_TDengine
()
{
function
install_TDengine
()
{
echo
-e
"
${
GREEN
}
Start to install TD
E
ngine...
${
NC
}
"
echo
-e
"
${
GREEN
}
Start to install TD
e
ngine...
${
NC
}
"
#install log and data dir , then ln to /usr/local/taos
#install log and data dir , then ln to /usr/local/taos
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
...
...
packaging/tools/preun.sh
浏览文件 @
a7c6e73f
...
@@ -119,4 +119,4 @@ if ((${service_mod}==2)); then
...
@@ -119,4 +119,4 @@ if ((${service_mod}==2)); then
kill_taosd
kill_taosd
fi
fi
echo
-e
"
${
GREEN
}
TD
E
ngine is removed successfully!
${
NC
}
"
echo
-e
"
${
GREEN
}
TD
e
ngine is removed successfully!
${
NC
}
"
packaging/tools/set_core.sh
浏览文件 @
a7c6e73f
...
@@ -2,19 +2,39 @@
...
@@ -2,19 +2,39 @@
#
#
# This file is used to set config for core when taosd crash
# This file is used to set config for core when taosd crash
set
-e
# Color setting
RED
=
'\033[0;31m'
GREEN
=
'\033[1;32m'
GREEN_DARK
=
'\033[0;32m'
GREEN_UNDERLINE
=
'\033[4;32m'
NC
=
'\033[0m'
# set -e
# set -x
# set -x
corePath
=
$1
csudo
=
""
csudo
=
""
if
command
-v
sudo
>
/dev/null
;
then
if
command
-v
sudo
>
/dev/null
;
then
csudo
=
"sudo"
csudo
=
"sudo"
fi
fi
#ulimit -c unlimited
if
[[
!
-n
${
corePath
}
]]
;
then
echo
-e
-n
"
${
GREEN
}
Please enter a file directory to save the coredump file
${
NC
}
:"
read
corePath
while
true
;
do
if
[[
!
-z
"
$corePath
"
]]
;
then
break
else
read
-p
"Please enter a file directory to save the coredump file:"
corePath
fi
done
fi
ulimit
-c
unlimited
${
csudo
}
sed
-i
'/ulimit -c unlimited/d'
/etc/profile
||
:
${
csudo
}
sed
-i
'/ulimit -c unlimited/d'
/etc/profile
||
:
${
csudo
}
sed
-i
'$a\ulimit -c unlimited'
/etc/profile
||
:
${
csudo
}
sed
-i
'$a\ulimit -c unlimited'
/etc/profile
||
:
source
/etc/profile
source
/etc/profile
${
csudo
}
mkdir
-p
/coredump
||
:
${
csudo
}
mkdir
-p
${
corePath
}
||
:
${
csudo
}
sysctl
-w
kernel.core_pattern
=
'/coredump/core-%e-%p'
||
:
${
csudo
}
sysctl
-w
kernel.core_pattern
=
${
corePath
}
/core-%e-%p
||
:
${
csudo
}
echo
'/coredump/core-%e-%p'
|
${
csudo
}
tee
/proc/sys/kernel/core_pattern
||
:
${
csudo
}
echo
"
${
corePath
}
/core-%e-%p"
|
${
csudo
}
tee
/proc/sys/kernel/core_pattern
||
:
snap/snapcraft.yaml
浏览文件 @
a7c6e73f
name
:
tdengine
name
:
tdengine
base
:
core18
base
:
core18
version
:
'
2.0.1
1
.0'
version
:
'
2.0.1
2
.0'
icon
:
snap/gui/t-dengine.svg
icon
:
snap/gui/t-dengine.svg
summary
:
an open-source big data platform designed and optimized for IoT.
summary
:
an open-source big data platform designed and optimized for IoT.
description
:
|
description
:
|
...
@@ -72,7 +72,7 @@ parts:
...
@@ -72,7 +72,7 @@ parts:
-
usr/bin/taosd
-
usr/bin/taosd
-
usr/bin/taos
-
usr/bin/taos
-
usr/bin/taosdemo
-
usr/bin/taosdemo
-
usr/lib/libtaos.so.2.0.1
1
.0
-
usr/lib/libtaos.so.2.0.1
2
.0
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so
-
usr/lib/libtaos.so
...
...
src/balance/src/bnMain.c
浏览文件 @
a7c6e73f
...
@@ -44,7 +44,7 @@ static void bnUnLock() {
...
@@ -44,7 +44,7 @@ static void bnUnLock() {
static
bool
bnCheckFree
(
SDnodeObj
*
pDnode
)
{
static
bool
bnCheckFree
(
SDnodeObj
*
pDnode
)
{
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
||
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
||
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
mError
(
"dnode:%d, status:%s not available"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
);
mError
(
"dnode:%d, status:%s not available"
,
pDnode
->
dnodeId
,
dnodeStatus
[
pDnode
->
status
]
);
return
false
;
return
false
;
}
}
...
@@ -92,13 +92,12 @@ static void bnDiscardVnode(SVgObj *pVgroup, SVnodeGid *pVnodeGid) {
...
@@ -92,13 +92,12 @@ static void bnDiscardVnode(SVgObj *pVgroup, SVnodeGid *pVnodeGid) {
}
}
static
void
bnSwapVnodeGid
(
SVnodeGid
*
pVnodeGid1
,
SVnodeGid
*
pVnodeGid2
)
{
static
void
bnSwapVnodeGid
(
SVnodeGid
*
pVnodeGid1
,
SVnodeGid
*
pVnodeGid2
)
{
//
SVnodeGid tmp = *pVnodeGid1;
SVnodeGid
tmp
=
*
pVnodeGid1
;
//
*pVnodeGid1 = *pVnodeGid2;
*
pVnodeGid1
=
*
pVnodeGid2
;
//
*pVnodeGid2 = tmp;
*
pVnodeGid2
=
tmp
;
}
}
int32_t
bnAllocVnodes
(
SVgObj
*
pVgroup
)
{
int32_t
bnAllocVnodes
(
SVgObj
*
pVgroup
)
{
static
int32_t
randIndex
=
0
;
int32_t
dnode
=
0
;
int32_t
dnode
=
0
;
int32_t
vnodes
=
0
;
int32_t
vnodes
=
0
;
...
@@ -120,8 +119,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
...
@@ -120,8 +119,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
break
;
break
;
}
else
{
}
else
{
mDebug
(
"dnode:%d, is not selected, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
mDebug
(
"dnode:%d, is not selected, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
),
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
dnodeStatus
[
pDnode
->
status
],
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
pDnode
->
alternativeRole
);
}
}
}
}
}
}
...
@@ -137,7 +135,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
...
@@ -137,7 +135,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
while
(
1
)
{
while
(
1
)
{
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
==
NULL
)
break
;
mDebug
(
"dnode:%d, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
,
mDebug
(
"dnode:%d, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
dnodeStatus
[
pDnode
->
status
]
,
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
...
@@ -149,36 +147,6 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
...
@@ -149,36 +147,6 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
}
}
}
}
/*
* make the choice more random.
* replica 1: no choice
* replica 2: there are 2 combinations
* replica 3 or larger: there are 6 combinations
*/
if
(
pVgroup
->
numOfVnodes
==
1
)
{
}
else
if
(
pVgroup
->
numOfVnodes
==
2
)
{
if
(
randIndex
++
%
2
==
0
)
{
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
,
pVgroup
->
vnodeGid
+
1
);
}
}
else
{
int32_t
randVal
=
randIndex
++
%
6
;
if
(
randVal
==
1
)
{
// 1, 0, 2
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
}
else
if
(
randVal
==
2
)
{
// 1, 2, 0
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
else
if
(
randVal
==
3
)
{
// 2, 1, 0
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
2
);
}
else
if
(
randVal
==
4
)
{
// 2, 0, 1
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
2
);
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
if
(
randVal
==
5
)
{
// 0, 2, 1
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
else
{
}
// 0, 1, 2
}
bnReleaseDnodes
();
bnReleaseDnodes
();
bnUnLock
();
bnUnLock
();
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -214,44 +182,8 @@ static bool bnCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
...
@@ -214,44 +182,8 @@ static bool bnCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
static
int32_t
bnRemoveVnode
(
SVgObj
*
pVgroup
)
{
static
int32_t
bnRemoveVnode
(
SVgObj
*
pVgroup
)
{
if
(
pVgroup
->
numOfVnodes
<=
1
)
return
-
1
;
if
(
pVgroup
->
numOfVnodes
<=
1
)
return
-
1
;
SVnodeGid
*
pRmVnode
=
NULL
;
SVnodeGid
*
pSelVnode
=
&
pVgroup
->
vnodeGid
[
pVgroup
->
numOfVnodes
-
1
];
SVnodeGid
*
pSelVnode
=
NULL
;
mDebug
(
"vgId:%d, vnode in dnode:%d will be dropped"
,
pVgroup
->
vgId
,
pSelVnode
->
dnodeId
);
int32_t
maxScore
=
0
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
pVnode
=
&
(
pVgroup
->
vnodeGid
[
i
]);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pVnode
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"vgId:%d, dnode:%d not exist, remove it"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
break
;
}
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
)
{
mDebug
(
"vgId:%d, dnode:%d in dropping state"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
}
else
if
(
pVnode
->
dnodeId
==
pVgroup
->
lbDnodeId
)
{
mDebug
(
"vgId:%d, dnode:%d in updating state"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
}
else
{
if
(
pSelVnode
==
NULL
)
{
pSelVnode
=
pVnode
;
maxScore
=
pDnode
->
score
;
}
else
{
if
(
maxScore
<
pDnode
->
score
)
{
pSelVnode
=
pVnode
;
maxScore
=
pDnode
->
score
;
}
}
}
mnodeDecDnodeRef
(
pDnode
);
}
if
(
pRmVnode
!=
NULL
)
{
pSelVnode
=
pRmVnode
;
}
if
(
!
bnCheckVgroupReady
(
pVgroup
,
pSelVnode
))
{
if
(
!
bnCheckVgroupReady
(
pVgroup
,
pSelVnode
))
{
mDebug
(
"vgId:%d, is not ready"
,
pVgroup
->
vgId
);
mDebug
(
"vgId:%d, is not ready"
,
pVgroup
->
vgId
);
...
@@ -275,36 +207,42 @@ static bool bnCheckDnodeInVgroup(SDnodeObj *pDnode, SVgObj *pVgroup) {
...
@@ -275,36 +207,42 @@ static bool bnCheckDnodeInVgroup(SDnodeObj *pDnode, SVgObj *pVgroup) {
return
false
;
return
false
;
}
}
/**
static
SDnodeObj
*
bnGetAvailDnode
(
SVgObj
*
pVgroup
)
{
* desc: add vnode to vgroup, find a new one if dest dnode is null
**/
static
int32_t
bnAddVnode
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pSrcDnode
,
SDnodeObj
*
pDestDnode
)
{
if
(
pDestDnode
==
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
tsBnDnodes
.
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsBnDnodes
.
size
;
++
i
)
{
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
i
];
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
i
];
if
(
pDnode
==
pSrcDnode
)
continue
;
if
(
bnCheckDnodeInVgroup
(
pDnode
,
pVgroup
))
continue
;
if
(
bnCheckDnodeInVgroup
(
pDnode
,
pVgroup
))
continue
;
if
(
!
bnCheckFree
(
pDnode
))
continue
;
if
(
!
bnCheckFree
(
pDnode
))
continue
;
pDestDnode
=
pDnode
;
mDebug
(
"vgId:%d, add vnode to dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
mDebug
(
"vgId:%d, add vnode to dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
break
;
return
pDnode
;
}
}
}
if
(
pDestDnode
==
NULL
)
{
return
NULL
;
}
static
int32_t
bnAddVnode
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pSrcDnode
,
SDnodeObj
*
pDestDnode
)
{
if
(
pDestDnode
==
NULL
||
pSrcDnode
==
pDestDnode
)
{
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
}
SVnodeGid
*
pVnodeGid
=
pVgroup
->
vnodeGid
+
pVgroup
->
numOfVnodes
;
SVnodeGid
vnodeGids
[
TSDB_MAX_REPLICA
];
pVnodeGid
->
dnodeId
=
pDestDnode
->
dnodeId
;
memcpy
(
&
vnodeGids
,
&
pVgroup
->
vnodeGid
,
sizeof
(
SVnodeGid
)
*
TSDB_MAX_REPLICA
);
pVnodeGid
->
pDnode
=
pDestDnode
;
pVgroup
->
numOfVnodes
++
;
if
(
pSrcDnode
!=
NULL
)
{
int32_t
numOfVnodes
=
pVgroup
->
numOfVnodes
;
vnodeGids
[
numOfVnodes
].
dnodeId
=
pDestDnode
->
dnodeId
;
vnodeGids
[
numOfVnodes
].
pDnode
=
pDestDnode
;
numOfVnodes
++
;
for
(
int32_t
v
=
0
;
v
<
numOfVnodes
;
++
v
)
{
if
(
pSrcDnode
!=
NULL
&&
pSrcDnode
->
dnodeId
==
vnodeGids
[
v
].
dnodeId
)
{
bnSwapVnodeGid
(
&
vnodeGids
[
v
],
&
vnodeGids
[
numOfVnodes
-
1
]);
pVgroup
->
lbDnodeId
=
pSrcDnode
->
dnodeId
;
pVgroup
->
lbDnodeId
=
pSrcDnode
->
dnodeId
;
break
;
}
}
}
memcpy
(
&
pVgroup
->
vnodeGid
,
&
vnodeGids
,
sizeof
(
SVnodeGid
)
*
TSDB_MAX_REPLICA
);
pVgroup
->
numOfVnodes
=
numOfVnodes
;
atomic_add_fetch_32
(
&
pDestDnode
->
openVnodes
,
1
);
atomic_add_fetch_32
(
&
pDestDnode
->
openVnodes
,
1
);
mnodeUpdateVgroup
(
pVgroup
);
mnodeUpdateVgroup
(
pVgroup
);
...
@@ -315,16 +253,16 @@ static int32_t bnAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDes
...
@@ -315,16 +253,16 @@ static int32_t bnAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDes
static
bool
bnMonitorBalance
()
{
static
bool
bnMonitorBalance
()
{
if
(
tsBnDnodes
.
size
<
2
)
return
false
;
if
(
tsBnDnodes
.
size
<
2
)
return
false
;
mDebug
(
"monitor dnodes for balance, avail:%d"
,
tsBnDnodes
.
size
);
for
(
int32_t
src
=
tsBnDnodes
.
size
-
1
;
src
>=
0
;
--
src
)
{
for
(
int32_t
src
=
tsBnDnodes
.
size
-
1
;
src
>=
0
;
--
src
)
{
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
src
];
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
src
];
mDebug
(
"%d-dnode:%d, state:%s, score:%.1f, numOfCores:%d, openVnodes:%d"
,
tsBnDnodes
.
size
-
src
-
1
,
mDebug
(
"%d-dnode:%d, state:%s, score:%.1f, cores:%d, vnodes:%d"
,
tsBnDnodes
.
size
-
src
-
1
,
pDnode
->
dnodeId
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
),
pDnode
->
score
,
pDnode
->
numOfCores
,
dnodeStatus
[
pDnode
->
status
],
pDnode
->
score
,
pDnode
->
numOfCores
,
pDnode
->
openVnodes
);
pDnode
->
openVnodes
);
}
}
float
scoresDiff
=
tsBnDnodes
.
list
[
tsBnDnodes
.
size
-
1
]
->
score
-
tsBnDnodes
.
list
[
0
]
->
score
;
float
scoresDiff
=
tsBnDnodes
.
list
[
tsBnDnodes
.
size
-
1
]
->
score
-
tsBnDnodes
.
list
[
0
]
->
score
;
if
(
scoresDiff
<
0
.
01
)
{
if
(
scoresDiff
<
0
.
01
)
{
mDebug
(
"all dnodes:%d is already balanced, score
sDiff:%
f"
,
tsBnDnodes
.
size
,
scoresDiff
);
mDebug
(
"all dnodes:%d is already balanced, score
Diff:%.1
f"
,
tsBnDnodes
.
size
,
scoresDiff
);
return
false
;
return
false
;
}
}
...
@@ -392,7 +330,7 @@ void bnReset() {
...
@@ -392,7 +330,7 @@ void bnReset() {
tsAccessSquence
=
0
;
tsAccessSquence
=
0
;
}
}
static
int32_t
bnMonitorVgroups
()
{
static
bool
bnMonitorVgroups
()
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
bool
hasUpdatingVgroup
=
false
;
bool
hasUpdatingVgroup
=
false
;
...
@@ -412,7 +350,13 @@ static int32_t bnMonitorVgroups() {
...
@@ -412,7 +350,13 @@ static int32_t bnMonitorVgroups() {
}
else
if
(
vgReplica
<
dbReplica
)
{
}
else
if
(
vgReplica
<
dbReplica
)
{
mInfo
(
"vgId:%d, replica:%d numOfVnodes:%d, try add one vnode"
,
pVgroup
->
vgId
,
dbReplica
,
vgReplica
);
mInfo
(
"vgId:%d, replica:%d numOfVnodes:%d, try add one vnode"
,
pVgroup
->
vgId
,
dbReplica
,
vgReplica
);
hasUpdatingVgroup
=
true
;
hasUpdatingVgroup
=
true
;
code
=
bnAddVnode
(
pVgroup
,
NULL
,
NULL
);
SDnodeObj
*
pAvailDnode
=
bnGetAvailDnode
(
pVgroup
);
if
(
pAvailDnode
==
NULL
)
{
code
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
else
{
code
=
bnAddVnode
(
pVgroup
,
NULL
,
pAvailDnode
);
}
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
...
@@ -545,6 +489,7 @@ void bnCheckStatus() {
...
@@ -545,6 +489,7 @@ void bnCheckStatus() {
mInfo
(
"dnode:%d, set to offline state, access seq:%d last seq:%d laststat:%d"
,
pDnode
->
dnodeId
,
tsAccessSquence
,
mInfo
(
"dnode:%d, set to offline state, access seq:%d last seq:%d laststat:%d"
,
pDnode
->
dnodeId
,
tsAccessSquence
,
pDnode
->
lastAccess
,
pDnode
->
status
);
pDnode
->
lastAccess
,
pDnode
->
status
);
bnSetVgroupOffline
(
pDnode
);
bnSetVgroupOffline
(
pDnode
);
bnStartTimer
(
3000
);
}
}
}
}
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
...
...
src/balance/src/bnScore.c
浏览文件 @
a7c6e73f
...
@@ -299,7 +299,7 @@ static int32_t bnRetrieveScores(SShowObj *pShow, char *data, int32_t rows, void
...
@@ -299,7 +299,7 @@ static int32_t bnRetrieveScores(SShowObj *pShow, char *data, int32_t rows, void
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
);
STR_TO_VARSTR
(
pWrite
,
dnodeStatus
[
pDnode
->
status
]
);
cols
++
;
cols
++
;
numOfRows
++
;
numOfRows
++
;
...
...
src/balance/src/bnThread.c
浏览文件 @
a7c6e73f
...
@@ -31,7 +31,10 @@ static void *bnThreadFunc(void *arg) {
...
@@ -31,7 +31,10 @@ static void *bnThreadFunc(void *arg) {
}
}
pthread_cond_wait
(
&
tsBnThread
.
cond
,
&
tsBnThread
.
mutex
);
pthread_cond_wait
(
&
tsBnThread
.
cond
,
&
tsBnThread
.
mutex
);
mDebug
(
"balance thread wakes up to work"
);
bool
updateSoon
=
bnStart
();
bool
updateSoon
=
bnStart
();
mDebug
(
"balance thread finished this poll, updateSoon:%d"
,
updateSoon
);
bnStartTimer
(
updateSoon
?
1000
:
-
1
);
bnStartTimer
(
updateSoon
?
1000
:
-
1
);
pthread_mutex_unlock
(
&
(
tsBnThread
.
mutex
));
pthread_mutex_unlock
(
&
(
tsBnThread
.
mutex
));
}
}
...
@@ -101,8 +104,8 @@ static void bnProcessTimer(void *handle, void *tmrId) {
...
@@ -101,8 +104,8 @@ static void bnProcessTimer(void *handle, void *tmrId) {
tsBnThread
.
timer
=
NULL
;
tsBnThread
.
timer
=
NULL
;
tsAccessSquence
++
;
tsAccessSquence
++
;
bnCheckStatus
();
bnStartTimer
(
-
1
);
bnStartTimer
(
-
1
);
bnCheckStatus
();
if
(
handle
==
NULL
)
{
if
(
handle
==
NULL
)
{
if
(
tsAccessSquence
%
tsBalanceInterval
==
0
)
{
if
(
tsAccessSquence
%
tsBalanceInterval
==
0
)
{
...
@@ -121,6 +124,7 @@ void bnStartTimer(int64_t mseconds) {
...
@@ -121,6 +124,7 @@ void bnStartTimer(int64_t mseconds) {
bool
updateSoon
=
(
mseconds
!=
-
1
);
bool
updateSoon
=
(
mseconds
!=
-
1
);
if
(
updateSoon
)
{
if
(
updateSoon
)
{
mTrace
(
"balance function will be called after %"
PRId64
" ms"
,
mseconds
);
taosTmrReset
(
bnProcessTimer
,
mseconds
,
(
void
*
)
mseconds
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
taosTmrReset
(
bnProcessTimer
,
mseconds
,
(
void
*
)
mseconds
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
}
else
{
}
else
{
taosTmrReset
(
bnProcessTimer
,
tsStatusInterval
*
1000
,
NULL
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
taosTmrReset
(
bnProcessTimer
,
tsStatusInterval
*
1000
,
NULL
,
tsMnodeTmr
,
&
tsBnThread
.
timer
);
...
...
src/client/inc/tscLocalMerge.h
浏览文件 @
a7c6e73f
...
@@ -38,12 +38,6 @@ typedef struct SLocalDataSource {
...
@@ -38,12 +38,6 @@ typedef struct SLocalDataSource {
tFilePage
filePage
;
tFilePage
filePage
;
}
SLocalDataSource
;
}
SLocalDataSource
;
enum
{
TSC_LOCALREDUCE_READY
=
0x0
,
TSC_LOCALREDUCE_IN_PROGRESS
=
0x1
,
TSC_LOCALREDUCE_TOBE_FREED
=
0x2
,
};
typedef
struct
SLocalReducer
{
typedef
struct
SLocalReducer
{
SLocalDataSource
**
pLocalDataSrc
;
SLocalDataSource
**
pLocalDataSrc
;
int32_t
numOfBuffer
;
int32_t
numOfBuffer
;
...
@@ -56,7 +50,6 @@ typedef struct SLocalReducer {
...
@@ -56,7 +50,6 @@ typedef struct SLocalReducer {
tFilePage
*
pTempBuffer
;
tFilePage
*
pTempBuffer
;
struct
SQLFunctionCtx
*
pCtx
;
struct
SQLFunctionCtx
*
pCtx
;
int32_t
rowSize
;
// size of each intermediate result.
int32_t
rowSize
;
// size of each intermediate result.
int32_t
status
;
// denote it is in reduce process, in reduce process, it
bool
hasPrevRow
;
// cannot be released
bool
hasPrevRow
;
// cannot be released
bool
hasUnprocessedRow
;
bool
hasUnprocessedRow
;
tOrderDescriptor
*
pDesc
;
tOrderDescriptor
*
pDesc
;
...
...
src/client/inc/tscLog.h
浏览文件 @
a7c6e73f
...
@@ -22,8 +22,8 @@ extern "C" {
...
@@ -22,8 +22,8 @@ extern "C" {
#include "tlog.h"
#include "tlog.h"
extern
u
int32_t
cDebugFlag
;
extern
int32_t
cDebugFlag
;
extern
uint32_t
tscEmbedded
;
extern
int8_t
tscEmbedded
;
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
...
...
src/client/inc/tsclient.h
浏览文件 @
a7c6e73f
...
@@ -69,9 +69,10 @@ typedef struct STableMeta {
...
@@ -69,9 +69,10 @@ typedef struct STableMeta {
int16_t
sversion
;
int16_t
sversion
;
int16_t
tversion
;
int16_t
tversion
;
char
sTableId
[
TSDB_TABLE_FNAME_LEN
];
char
sTableId
[
TSDB_TABLE_FNAME_LEN
];
SVgroupInfo
vgroupInfo
;
int32_t
vgId
;
SCorVgroupInfo
corVgroupInfo
;
SCorVgroupInfo
corVgroupInfo
;
STableId
id
;
STableId
id
;
// union {int64_t stableUid; SSchema* schema;};
SSchema
schema
[];
// if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
SSchema
schema
[];
// if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
}
STableMeta
;
}
STableMeta
;
...
@@ -307,7 +308,7 @@ typedef struct STscObj {
...
@@ -307,7 +308,7 @@ typedef struct STscObj {
SRpcCorEpSet
*
tscCorMgmtEpSet
;
SRpcCorEpSet
*
tscCorMgmtEpSet
;
void
*
pDnodeConn
;
void
*
pDnodeConn
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
T_REF_DECLARE
()
int32_t
numOfObj
;
// number of sqlObj from this tscObj
}
STscObj
;
}
STscObj
;
typedef
struct
SSubqueryState
{
typedef
struct
SSubqueryState
{
...
@@ -420,7 +421,7 @@ void tscCloseTscObj(void *pObj);
...
@@ -420,7 +421,7 @@ void tscCloseTscObj(void *pObj);
// todo move to taos? or create a new file: taos_internal.h
// todo move to taos? or create a new file: taos_internal.h
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
TAOS
**
taos
);
void
*
param
,
TAOS
**
taos
);
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
TAOS_RES
*
*
res
);
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
int64_t
*
res
);
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
);
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
__async_cb_func_t
fp
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
__async_cb_func_t
fp
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
...
@@ -478,15 +479,14 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
...
@@ -478,15 +479,14 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
}
}
}
}
extern
SCacheObj
*
tscMetaCache
;
extern
SCacheObj
*
tscMetaCache
;
extern
int
tscObjRef
;
extern
int
tscObjRef
;
extern
void
*
tscTmr
;
extern
void
*
tscTmr
;
extern
void
*
tscQhandle
;
extern
void
*
tscQhandle
;
extern
int
tscKeepConn
[];
extern
int
tscKeepConn
[];
extern
int
tsInsertHeadSize
;
extern
int
tscNumOfThreads
;
extern
int
tscRefId
;
extern
int
tscRefId
;
extern
int
tscNumOfObj
;
// number of existed sqlObj in current process.
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
...
...
src/client/src/tscAsync.c
浏览文件 @
a7c6e73f
...
@@ -388,10 +388,10 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
...
@@ -388,10 +388,10 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
return
;
return
;
}
}
assert
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
);
tscError
(
"%p add into queued async res, code:%s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
));
tscError
(
"%p add into queued async res, code:%s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
));
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pSql
->
fp
==
NULL
||
pSql
->
fetchFp
==
NULL
){
if
(
pSql
->
fp
==
NULL
||
pSql
->
fetchFp
==
NULL
){
return
;
return
;
}
}
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
a7c6e73f
...
@@ -2597,14 +2597,23 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) {
...
@@ -2597,14 +2597,23 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) {
}
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
static
void
buildHistogramInfo
(
SAPercentileInfo
*
pInfo
)
{
pInfo
->
pHisto
=
(
SHistogramInfo
*
)
((
char
*
)
pInfo
+
sizeof
(
SAPercentileInfo
));
pInfo
->
pHisto
->
elems
=
(
SHistBin
*
)
((
char
*
)
pInfo
->
pHisto
+
sizeof
(
SHistogramInfo
));
}
static
SAPercentileInfo
*
getAPerctInfo
(
SQLFunctionCtx
*
pCtx
)
{
static
SAPercentileInfo
*
getAPerctInfo
(
SQLFunctionCtx
*
pCtx
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SAPercentileInfo
*
pInfo
=
NULL
;
if
(
pCtx
->
stableQuery
&&
pCtx
->
currentStage
!=
SECONDARY_STAGE_MERGE
)
{
if
(
pCtx
->
stableQuery
&&
pCtx
->
currentStage
!=
SECONDARY_STAGE_MERGE
)
{
return
(
SAPercentileInfo
*
)
pCtx
->
aOutputBuf
;
pInfo
=
(
SAPercentileInfo
*
)
pCtx
->
aOutputBuf
;
}
else
{
}
else
{
return
GET_ROWCELL_INTERBUF
(
pResInfo
);
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
}
}
buildHistogramInfo
(
pInfo
);
return
pInfo
;
}
}
static
bool
apercentile_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
static
bool
apercentile_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
...
@@ -2625,6 +2634,8 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
...
@@ -2625,6 +2634,8 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SAPercentileInfo
*
pInfo
=
getAPerctInfo
(
pCtx
);
SAPercentileInfo
*
pInfo
=
getAPerctInfo
(
pCtx
);
assert
(
pInfo
->
pHisto
->
elems
!=
NULL
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
char
*
data
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
i
);
char
*
data
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
i
);
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
))
{
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
))
{
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
a7c6e73f
...
@@ -93,7 +93,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
...
@@ -93,7 +93,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
// for top/bottom function, the output of timestamp is the first column
// for top/bottom function, the output of timestamp is the first column
int32_t
functionId
=
pExpr
->
functionId
;
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
)
{
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
pCtx
->
ptsOutputBuf
=
pReducer
->
pCtx
[
0
].
aOutputBuf
;
pCtx
->
ptsOutputBuf
=
pReducer
->
pCtx
[
0
].
aOutputBuf
;
pCtx
->
param
[
2
].
i64Key
=
pQueryInfo
->
order
.
order
;
pCtx
->
param
[
2
].
i64Key
=
pQueryInfo
->
order
.
order
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
...
@@ -493,13 +493,6 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
...
@@ -493,13 +493,6 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
// there is no more result, so we release all allocated resource
// there is no more result, so we release all allocated resource
SLocalReducer
*
pLocalReducer
=
(
SLocalReducer
*
)
atomic_exchange_ptr
(
&
pRes
->
pLocalReducer
,
NULL
);
SLocalReducer
*
pLocalReducer
=
(
SLocalReducer
*
)
atomic_exchange_ptr
(
&
pRes
->
pLocalReducer
,
NULL
);
if
(
pLocalReducer
!=
NULL
)
{
if
(
pLocalReducer
!=
NULL
)
{
int32_t
status
=
0
;
while
((
status
=
atomic_val_compare_exchange_32
(
&
pLocalReducer
->
status
,
TSC_LOCALREDUCE_READY
,
TSC_LOCALREDUCE_TOBE_FREED
))
==
TSC_LOCALREDUCE_IN_PROGRESS
)
{
taosMsleep
(
100
);
tscDebug
(
"%p waiting for delete procedure, status: %d"
,
pSql
,
status
);
}
pLocalReducer
->
pFillInfo
=
taosDestroyFillInfo
(
pLocalReducer
->
pFillInfo
);
pLocalReducer
->
pFillInfo
=
taosDestroyFillInfo
(
pLocalReducer
->
pFillInfo
);
if
(
pLocalReducer
->
pCtx
!=
NULL
)
{
if
(
pLocalReducer
->
pCtx
!=
NULL
)
{
...
@@ -911,6 +904,13 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
...
@@ -911,6 +904,13 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
}
}
}
}
if
(
pRes
->
numOfRowsGroup
>=
pQueryInfo
->
limit
.
limit
&&
pQueryInfo
->
limit
.
limit
>
0
)
{
pRes
->
numOfRows
=
0
;
pBeforeFillData
->
num
=
0
;
pLocalReducer
->
discard
=
true
;
return
;
}
pRes
->
numOfRowsGroup
+=
pRes
->
numOfRows
;
pRes
->
numOfRowsGroup
+=
pRes
->
numOfRows
;
// impose the limitation of output rows on the final result
// impose the limitation of output rows on the final result
...
@@ -1296,6 +1296,10 @@ void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {// re
...
@@ -1296,6 +1296,10 @@ void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {// re
for
(
int32_t
i
=
0
;
i
<
t
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
t
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
pLocalReducer
->
pCtx
[
i
].
aOutputBuf
=
pLocalReducer
->
pResultBuf
->
data
+
pExpr
->
offset
*
pLocalReducer
->
resColModel
->
capacity
;
pLocalReducer
->
pCtx
[
i
].
aOutputBuf
=
pLocalReducer
->
pResultBuf
->
data
+
pExpr
->
offset
*
pLocalReducer
->
resColModel
->
capacity
;
if
(
pExpr
->
functionId
==
TSDB_FUNC_TOP
||
pExpr
->
functionId
==
TSDB_FUNC_BOTTOM
||
pExpr
->
functionId
==
TSDB_FUNC_DIFF
)
{
pLocalReducer
->
pCtx
[
i
].
ptsOutputBuf
=
pLocalReducer
->
pCtx
[
0
].
aOutputBuf
;
}
}
}
memset
(
pLocalReducer
->
pResultBuf
,
0
,
pLocalReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
memset
(
pLocalReducer
->
pResultBuf
,
0
,
pLocalReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
...
@@ -1430,24 +1434,13 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1430,24 +1434,13 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
// set the data merge in progress
int32_t
prevStatus
=
atomic_val_compare_exchange_32
(
&
pLocalReducer
->
status
,
TSC_LOCALREDUCE_READY
,
TSC_LOCALREDUCE_IN_PROGRESS
);
if
(
prevStatus
!=
TSC_LOCALREDUCE_READY
)
{
assert
(
prevStatus
==
TSC_LOCALREDUCE_TOBE_FREED
);
// it is in tscDestroyLocalReducer function already
return
TSDB_CODE_SUCCESS
;
}
tFilePage
*
tmpBuffer
=
pLocalReducer
->
pTempBuffer
;
tFilePage
*
tmpBuffer
=
pLocalReducer
->
pTempBuffer
;
if
(
doHandleLastRemainData
(
pSql
))
{
if
(
doHandleLastRemainData
(
pSql
))
{
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
// set the flag, taos_free_result can release this result.
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
doBuildFilledResultForGroup
(
pSql
))
{
if
(
doBuildFilledResultForGroup
(
pSql
))
{
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
// set the flag, taos_free_result can release this result.
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1503,7 +1496,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1503,7 +1496,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
pLocalReducer
->
discardData
->
num
=
0
;
pLocalReducer
->
discardData
->
num
=
0
;
if
(
saveGroupResultInfo
(
pSql
))
{
if
(
saveGroupResultInfo
(
pSql
))
{
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1549,7 +1541,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1549,7 +1541,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
// here we do not check the return value
// here we do not check the return value
adjustLoserTreeFromNewData
(
pLocalReducer
,
pOneDataSrc
,
pTree
);
adjustLoserTreeFromNewData
(
pLocalReducer
,
pOneDataSrc
,
pTree
);
assert
(
pLocalReducer
->
status
==
TSC_LOCALREDUCE_IN_PROGRESS
);
if
(
pRes
->
numOfRows
==
0
)
{
if
(
pRes
->
numOfRows
==
0
)
{
handleUnprocessedRow
(
pCmd
,
pLocalReducer
,
tmpBuffer
);
handleUnprocessedRow
(
pCmd
,
pLocalReducer
,
tmpBuffer
);
...
@@ -1560,7 +1551,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1560,7 +1551,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
* If previous group is not skipped, keep it in pRes->numOfGroups
* If previous group is not skipped, keep it in pRes->numOfGroups
*/
*/
if
(
notSkipped
&&
saveGroupResultInfo
(
pSql
))
{
if
(
notSkipped
&&
saveGroupResultInfo
(
pSql
))
{
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1580,7 +1570,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1580,7 +1570,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
if
(
pRes
->
numOfRows
==
0
)
{
if
(
pRes
->
numOfRows
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
// set the flag, taos_free_result can release this result.
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
else
{
// result buffer is not full
}
else
{
// result buffer is not full
...
@@ -1605,9 +1594,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1605,9 +1594,6 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
genFinalResults
(
pSql
,
pLocalReducer
,
true
);
genFinalResults
(
pSql
,
pLocalReducer
,
true
);
}
}
assert
(
pLocalReducer
->
status
==
TSC_LOCALREDUCE_IN_PROGRESS
&&
pRes
->
row
==
0
);
pLocalReducer
->
status
=
TSC_LOCALREDUCE_READY
;
// set the flag, taos_free_result can release this result.
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/client/src/tscParseInsert.c
浏览文件 @
a7c6e73f
...
@@ -731,7 +731,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI
...
@@ -731,7 +731,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI
return
code
;
return
code
;
}
}
dataBuf
->
vgId
=
pTableMeta
->
vg
roupInfo
.
vg
Id
;
dataBuf
->
vgId
=
pTableMeta
->
vgId
;
dataBuf
->
numOfTables
=
1
;
dataBuf
->
numOfTables
=
1
;
*
totalNum
+=
numOfRows
;
*
totalNum
+=
numOfRows
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
a7c6e73f
...
@@ -666,6 +666,7 @@ int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQ
...
@@ -666,6 +666,7 @@ int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQ
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
const
char
*
msg3
=
"sliding cannot be used without interval"
;
const
char
*
msg3
=
"sliding cannot be used without interval"
;
const
char
*
msg4
=
"top/bottom query does not support order by value in interval query"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
@@ -712,6 +713,11 @@ int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQ
...
@@ -712,6 +713,11 @@ int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQ
return
TSDB_CODE_TSC_INVALID_SQL
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
int32_t
colId
=
pQueryInfo
->
order
.
orderColId
;
if
(
pQueryInfo
->
interval
.
interval
>
0
&&
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -996,59 +1002,59 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
...
@@ -996,59 +1002,59 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
return
false
;
return
false
;
}
}
int32_t
nLen
=
0
;
/* timestamp in tag is not allowed */
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
if
(
p
->
bytes
==
0
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
if
(
p
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
false
;
return
false
;
}
}
nLen
+=
p
->
bytes
;
if
(
p
->
type
<
TSDB_DATA_TYPE_BOOL
||
p
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
return
false
;
}
}
// max tag row length must be less than TSDB_MAX_TAGS_LEN
if
((
p
->
type
==
TSDB_DATA_TYPE_BINARY
&&
p
->
bytes
<=
0
)
||
if
(
nLen
>
TSDB_MAX_TAGS_LEN
)
{
(
p
->
type
==
TSDB_DATA_TYPE_NCHAR
&&
p
->
bytes
<=
0
)
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
return
false
;
return
false
;
}
}
// field name must be unique
if
(
validateColumnName
(
p
->
name
)
!=
TSDB_CODE_SUCCESS
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
return
false
;
}
if
(
has
(
p
FieldList
,
0
,
p
->
name
)
==
true
)
{
if
(
has
(
p
TagsList
,
i
+
1
,
p
->
name
)
==
true
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
false
;
return
false
;
}
}
}
}
/* timestamp in tag is not allowed */
int32_t
nLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
if
(
p
->
bytes
==
0
)
{
if
(
p
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
false
;
return
false
;
}
}
if
(
p
->
type
<
TSDB_DATA_TYPE_BOOL
||
p
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
nLen
+=
p
->
bytes
;
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
return
false
;
}
}
if
((
p
->
type
==
TSDB_DATA_TYPE_BINARY
&&
p
->
bytes
<=
0
)
||
// max tag row length must be less than TSDB_MAX_TAGS_LEN
(
p
->
type
==
TSDB_DATA_TYPE_NCHAR
&&
p
->
bytes
<=
0
)
)
{
if
(
nLen
>
TSDB_MAX_TAGS_LEN
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
false
;
return
false
;
}
}
if
(
validateColumnName
(
p
->
name
)
!=
TSDB_CODE_SUCCESS
)
{
// field name must be unique
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
return
false
;
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
}
if
(
has
(
p
TagsList
,
i
+
1
,
p
->
name
)
==
true
)
{
if
(
has
(
p
FieldList
,
0
,
p
->
name
)
==
true
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
false
;
return
false
;
}
}
...
@@ -4646,7 +4652,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
...
@@ -4646,7 +4652,7 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
if
(
!
(
orderByTags
||
orderByTS
)
&&
!
isTopBottomQuery
(
pQueryInfo
))
{
if
(
!
(
orderByTags
||
orderByTS
)
&&
!
isTopBottomQuery
(
pQueryInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
else
{
}
else
{
// order by top/bottom result value column is not supported in case of interval query.
assert
(
!
(
orderByTags
&&
orderByTS
));
assert
(
!
(
orderByTags
&&
orderByTS
));
}
}
...
@@ -4936,7 +4942,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4936,7 +4942,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
SUpdateTableTagValMsg
*
pUpdateMsg
=
(
SUpdateTableTagValMsg
*
)
pCmd
->
payload
;
SUpdateTableTagValMsg
*
pUpdateMsg
=
(
SUpdateTableTagValMsg
*
)
pCmd
->
payload
;
pUpdateMsg
->
head
.
vgId
=
htonl
(
pTableMeta
->
vg
roupInfo
.
vg
Id
);
pUpdateMsg
->
head
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pUpdateMsg
->
tid
=
htonl
(
pTableMeta
->
id
.
tid
);
pUpdateMsg
->
tid
=
htonl
(
pTableMeta
->
id
.
tid
);
pUpdateMsg
->
uid
=
htobe64
(
pTableMeta
->
id
.
uid
);
pUpdateMsg
->
uid
=
htobe64
(
pTableMeta
->
id
.
uid
);
pUpdateMsg
->
colId
=
htons
(
pTagsSchema
->
colId
);
pUpdateMsg
->
colId
=
htons
(
pTagsSchema
->
colId
);
...
@@ -5442,6 +5448,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
...
@@ -5442,6 +5448,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
pMsg
->
quorum
=
pCreateDb
->
quorum
;
pMsg
->
quorum
=
pCreateDb
->
quorum
;
pMsg
->
ignoreExist
=
pCreateDb
->
ignoreExists
;
pMsg
->
ignoreExist
=
pCreateDb
->
ignoreExists
;
pMsg
->
update
=
pCreateDb
->
update
;
pMsg
->
update
=
pCreateDb
->
update
;
pMsg
->
cacheLastRow
=
pCreateDb
->
cachelast
;
}
}
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDBInfo
*
pCreateDbSql
)
{
int32_t
parseCreateDBOptions
(
SSqlCmd
*
pCmd
,
SCreateDBInfo
*
pCreateDbSql
)
{
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
a7c6e73f
...
@@ -130,13 +130,14 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) {
...
@@ -130,13 +130,14 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) {
return
NULL
;
return
NULL
;
}
}
static
void
tscInitCorVgroupInfo
(
SCorVgroupInfo
*
corVgroupInfo
,
SVgroup
Info
*
vgroupInfo
)
{
static
void
tscInitCorVgroupInfo
(
SCorVgroupInfo
*
corVgroupInfo
,
SVgroup
Msg
*
pVgroupMsg
)
{
corVgroupInfo
->
version
=
0
;
corVgroupInfo
->
version
=
0
;
corVgroupInfo
->
inUse
=
0
;
corVgroupInfo
->
inUse
=
0
;
corVgroupInfo
->
numOfEps
=
vgroupInfo
->
numOfEps
;
corVgroupInfo
->
numOfEps
=
pVgroupMsg
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
corVgroupInfo
->
numOfEps
;
i
++
)
{
corVgroupInfo
->
epAddr
[
i
].
fqdn
=
strdup
(
vgroupInfo
->
epAddr
[
i
].
fqdn
);
for
(
int32_t
i
=
0
;
i
<
pVgroupMsg
->
numOfEps
;
i
++
)
{
corVgroupInfo
->
epAddr
[
i
].
port
=
vgroupInfo
->
epAddr
[
i
].
port
;
corVgroupInfo
->
epAddr
[
i
].
fqdn
=
strndup
(
pVgroupMsg
->
epAddr
[
i
].
fqdn
,
tListLen
(
pVgroupMsg
->
epAddr
[
0
].
fqdn
));
corVgroupInfo
->
epAddr
[
i
].
port
=
pVgroupMsg
->
epAddr
[
i
].
port
;
}
}
}
}
...
@@ -145,7 +146,9 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
...
@@ -145,7 +146,9 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
int32_t
schemaSize
=
(
pTableMetaMsg
->
numOfColumns
+
pTableMetaMsg
->
numOfTags
)
*
sizeof
(
SSchema
);
int32_t
schemaSize
=
(
pTableMetaMsg
->
numOfColumns
+
pTableMetaMsg
->
numOfTags
)
*
sizeof
(
SSchema
);
STableMeta
*
pTableMeta
=
calloc
(
1
,
sizeof
(
STableMeta
)
+
schemaSize
);
STableMeta
*
pTableMeta
=
calloc
(
1
,
sizeof
(
STableMeta
)
+
schemaSize
);
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
vgId
=
pTableMetaMsg
->
vgroup
.
vgId
;
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
...
@@ -156,18 +159,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
...
@@ -156,18 +159,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
id
.
tid
=
pTableMetaMsg
->
tid
;
pTableMeta
->
id
.
tid
=
pTableMetaMsg
->
tid
;
pTableMeta
->
id
.
uid
=
pTableMetaMsg
->
uid
;
pTableMeta
->
id
.
uid
=
pTableMetaMsg
->
uid
;
SVgroupInfo
*
pVgroupInfo
=
&
pTableMeta
->
vgroupInfo
;
tscInitCorVgroupInfo
(
&
pTableMeta
->
corVgroupInfo
,
&
pTableMetaMsg
->
vgroup
);
pVgroupInfo
->
numOfEps
=
pTableMetaMsg
->
vgroup
.
numOfEps
;
pVgroupInfo
->
vgId
=
pTableMetaMsg
->
vgroup
.
vgId
;
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
++
i
)
{
SEpAddrMsg
*
pEpMsg
=
&
pTableMetaMsg
->
vgroup
.
epAddr
[
i
];
pVgroupInfo
->
epAddr
[
i
].
fqdn
=
strndup
(
pEpMsg
->
fqdn
,
tListLen
(
pEpMsg
->
fqdn
));
pVgroupInfo
->
epAddr
[
i
].
port
=
pEpMsg
->
port
;
}
tscInitCorVgroupInfo
(
&
pTableMeta
->
corVgroupInfo
,
pVgroupInfo
);
pTableMeta
->
sversion
=
pTableMetaMsg
->
sversion
;
pTableMeta
->
sversion
=
pTableMetaMsg
->
sversion
;
pTableMeta
->
tversion
=
pTableMetaMsg
->
tversion
;
pTableMeta
->
tversion
=
pTableMetaMsg
->
tversion
;
...
...
src/client/src/tscServer.c
浏览文件 @
a7c6e73f
...
@@ -45,32 +45,30 @@ static int32_t getWaitingTimeInterval(int32_t count) {
...
@@ -45,32 +45,30 @@ static int32_t getWaitingTimeInterval(int32_t count) {
return
0
;
return
0
;
}
}
return
initial
*
(
2
<<
(
count
-
2
));
return
initial
*
(
(
2u
)
<<
(
count
-
2
));
}
}
static
void
tscSetDnodeEpSet
(
SSqlObj
*
pSql
,
SVgroupInfo
*
pVgroupInfo
)
{
static
void
tscSetDnodeEpSet
(
SRpcEpSet
*
pEpSet
,
SVgroupInfo
*
pVgroupInfo
)
{
assert
(
pSql
!=
NULL
&&
pVgroupInfo
!=
NULL
&&
pVgroupInfo
->
numOfEps
>
0
);
assert
(
pEpSet
!=
NULL
&&
pVgroupInfo
!=
NULL
&&
pVgroupInfo
->
numOfEps
>
0
);
SRpcEpSet
*
pEpSet
=
&
pSql
->
epSet
;
// Issue the query to one of the vnode among a vgroup randomly.
// Issue the query to one of the vnode among a vgroup randomly.
// change the inUse property would not affect the isUse attribute of STableMeta
// change the inUse property would not affect the isUse attribute of STableMeta
pEpSet
->
inUse
=
rand
()
%
pVgroupInfo
->
numOfEps
;
pEpSet
->
inUse
=
rand
()
%
pVgroupInfo
->
numOfEps
;
// apply the FQDN string length check here
// apply the FQDN string length check here
bool
hasFqdn
=
false
;
bool
existed
=
false
;
pEpSet
->
numOfEps
=
pVgroupInfo
->
numOfEps
;
pEpSet
->
numOfEps
=
pVgroupInfo
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
++
i
)
{
tstrncpy
(
pEpSet
->
fqdn
[
i
],
pVgroupInfo
->
epAddr
[
i
].
fqdn
,
tListLen
(
pEpSet
->
fqdn
[
i
]));
pEpSet
->
port
[
i
]
=
pVgroupInfo
->
epAddr
[
i
].
port
;
pEpSet
->
port
[
i
]
=
pVgroupInfo
->
epAddr
[
i
].
port
;
if
(
!
hasFqdn
)
{
int32_t
len
=
(
int32_t
)
strnlen
(
pVgroupInfo
->
epAddr
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
hasFqdn
=
(
strlen
(
pEpSet
->
fqdn
[
i
])
>
0
);
if
(
len
>
0
)
{
tstrncpy
(
pEpSet
->
fqdn
[
i
],
pVgroupInfo
->
epAddr
[
i
].
fqdn
,
tListLen
(
pEpSet
->
fqdn
[
i
]));
existed
=
true
;
}
}
}
}
assert
(
existed
);
assert
(
hasFqdn
);
}
}
static
void
tscDumpMgmtEpSet
(
SSqlObj
*
pSql
)
{
static
void
tscDumpMgmtEpSet
(
SSqlObj
*
pSql
)
{
...
@@ -102,7 +100,8 @@ void tscUpdateMgmtEpSet(SSqlObj *pSql, SRpcEpSet *pEpSet) {
...
@@ -102,7 +100,8 @@ void tscUpdateMgmtEpSet(SSqlObj *pSql, SRpcEpSet *pEpSet) {
pCorEpSet
->
epSet
=
*
pEpSet
;
pCorEpSet
->
epSet
=
*
pEpSet
;
taosCorEndWrite
(
&
pCorEpSet
->
version
);
taosCorEndWrite
(
&
pCorEpSet
->
version
);
}
}
static
void
tscDumpEpSetFromVgroupInfo
(
SCorVgroupInfo
*
pVgroupInfo
,
SRpcEpSet
*
pEpSet
)
{
static
void
tscDumpEpSetFromVgroupInfo
(
SRpcEpSet
*
pEpSet
,
SCorVgroupInfo
*
pVgroupInfo
)
{
if
(
pVgroupInfo
==
NULL
)
{
return
;}
if
(
pVgroupInfo
==
NULL
)
{
return
;}
taosCorBeginRead
(
&
pVgroupInfo
->
version
);
taosCorBeginRead
(
&
pVgroupInfo
->
version
);
int8_t
inUse
=
pVgroupInfo
->
inUse
;
int8_t
inUse
=
pVgroupInfo
->
inUse
;
...
@@ -515,8 +514,8 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -515,8 +514,8 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
}
else
{
}
else
{
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vg
roupInfo
.
vg
Id
);
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
tscDebug
(
"%p build fetch msg from only one vgroup, vgId:%d"
,
pSql
,
pTableMeta
->
vg
roupInfo
.
vg
Id
);
tscDebug
(
"%p build fetch msg from only one vgroup, vgId:%d"
,
pSql
,
pTableMeta
->
vgId
);
}
}
pSql
->
cmd
.
payloadLen
=
sizeof
(
SRetrieveTableMsg
);
pSql
->
cmd
.
payloadLen
=
sizeof
(
SRetrieveTableMsg
);
...
@@ -535,7 +534,6 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -535,7 +534,6 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// NOTE: shell message size should not include SMsgDesc
// NOTE: shell message size should not include SMsgDesc
int32_t
size
=
pSql
->
cmd
.
payloadLen
-
sizeof
(
SMsgDesc
);
int32_t
size
=
pSql
->
cmd
.
payloadLen
-
sizeof
(
SMsgDesc
);
int32_t
vgId
=
pTableMeta
->
vgroupInfo
.
vgId
;
SMsgDesc
*
pMsgDesc
=
(
SMsgDesc
*
)
pMsg
;
SMsgDesc
*
pMsgDesc
=
(
SMsgDesc
*
)
pMsg
;
pMsgDesc
->
numOfVnodes
=
htonl
(
1
);
// always one vnode
pMsgDesc
->
numOfVnodes
=
htonl
(
1
);
// always one vnode
...
@@ -543,7 +541,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -543,7 +541,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
sizeof
(
SMsgDesc
);
pMsg
+=
sizeof
(
SMsgDesc
);
SSubmitMsg
*
pShellMsg
=
(
SSubmitMsg
*
)
pMsg
;
SSubmitMsg
*
pShellMsg
=
(
SSubmitMsg
*
)
pMsg
;
pShellMsg
->
header
.
vgId
=
htonl
(
vgId
);
pShellMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pShellMsg
->
header
.
contLen
=
htonl
(
size
);
// the length not includes the size of SMsgDesc
pShellMsg
->
header
.
contLen
=
htonl
(
size
);
// the length not includes the size of SMsgDesc
pShellMsg
->
length
=
pShellMsg
->
header
.
contLen
;
pShellMsg
->
length
=
pShellMsg
->
header
.
contLen
;
...
@@ -551,9 +549,9 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -551,9 +549,9 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// pSql->cmd.payloadLen is set during copying data into payload
// pSql->cmd.payloadLen is set during copying data into payload
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
tscDumpEpSetFromVgroupInfo
(
&
p
TableMeta
->
corVgroupInfo
,
&
pSql
->
epSet
);
tscDumpEpSetFromVgroupInfo
(
&
p
Sql
->
epSet
,
&
pTableMeta
->
corVgroupInfo
);
tscDebug
(
"%p build submit msg, vgId:%d numOfTables:%d numberOfEP:%d"
,
pSql
,
vgId
,
pSql
->
cmd
.
numOfTablesInSubmit
,
tscDebug
(
"%p build submit msg, vgId:%d numOfTables:%d numberOfEP:%d"
,
pSql
,
pTableMeta
->
vgId
,
pSql
->
cmd
.
numOfTablesInSubmit
,
pSql
->
epSet
.
numOfEps
);
pSql
->
epSet
.
numOfEps
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -597,24 +595,28 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
...
@@ -597,24 +595,28 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
)
||
pTableMetaInfo
->
pVgroupTables
==
NULL
)
{
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
)
||
pTableMetaInfo
->
pVgroupTables
==
NULL
)
{
SVgroupInfo
*
pVgroupInfo
=
NULL
;
int32_t
vgId
=
-
1
;
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
int32_t
index
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
index
=
pTableMetaInfo
->
vgroupIndex
;
assert
(
index
>=
0
);
assert
(
index
>=
0
);
SVgroupInfo
*
pVgroupInfo
=
NULL
;
if
(
pTableMetaInfo
->
vgroupList
->
numOfVgroups
>
0
)
{
if
(
pTableMetaInfo
->
vgroupList
->
numOfVgroups
>
0
)
{
assert
(
index
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
assert
(
index
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
index
];
pVgroupInfo
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
index
];
}
}
vgId
=
pVgroupInfo
->
vgId
;
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
pVgroupInfo
);
tscDebug
(
"%p query on stable, vgIndex:%d, numOfVgroups:%d"
,
pSql
,
index
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
tscDebug
(
"%p query on stable, vgIndex:%d, numOfVgroups:%d"
,
pSql
,
index
,
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
}
else
{
}
else
{
pVgroupInfo
=
&
pTableMeta
->
vgroupInfo
;
vgId
=
pTableMeta
->
vgId
;
tscDumpEpSetFromVgroupInfo
(
&
pSql
->
epSet
,
&
pTableMeta
->
corVgroupInfo
);
}
}
assert
(
pVgroupInfo
!=
NULL
)
;
pSql
->
epSet
.
inUse
=
rand
()
%
pSql
->
epSet
.
numOfEps
;
tscSetDnodeEpSet
(
pSql
,
pVgroupInfo
);
pQueryMsg
->
head
.
vgId
=
htonl
(
vgId
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pVgroupInfo
->
vgId
);
STableIdInfo
*
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
STableIdInfo
*
pTableIdInfo
=
(
STableIdInfo
*
)
pMsg
;
pTableIdInfo
->
tid
=
htonl
(
pTableMeta
->
id
.
tid
);
pTableIdInfo
->
tid
=
htonl
(
pTableMeta
->
id
.
tid
);
...
@@ -633,7 +635,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
...
@@ -633,7 +635,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
index
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
index
);
// set the vgroup info
// set the vgroup info
tscSetDnodeEpSet
(
pSql
,
&
pTableIdList
->
vgInfo
);
tscSetDnodeEpSet
(
&
pSql
->
epSet
,
&
pTableIdList
->
vgInfo
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pTableIdList
->
vgInfo
.
vgId
);
pQueryMsg
->
head
.
vgId
=
htonl
(
pTableIdList
->
vgInfo
.
vgId
);
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pTableIdList
->
itemList
);
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pTableIdList
->
itemList
);
...
@@ -1247,7 +1249,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1247,7 +1249,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pShowMsg
->
payloadLen
=
htons
(
pEpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pEpAddr
->
n
);
}
}
pCmd
->
payloadLen
=
sizeof
(
SShowMsg
)
+
pShowMsg
->
payloadLen
;
pCmd
->
payloadLen
=
sizeof
(
SShowMsg
)
+
htons
(
pShowMsg
->
payloadLen
)
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1448,48 +1450,11 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
...
@@ -1448,48 +1450,11 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
tscDumpEpSetFromVgroupInfo
(
&
p
TableMetaInfo
->
pTableMeta
->
corVgroupInfo
,
&
pSql
->
epSet
);
tscDumpEpSetFromVgroupInfo
(
&
p
Sql
->
epSet
,
&
pTableMetaInfo
->
pTableMeta
->
corVgroupInfo
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
//int tscBuildCancelQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// SCancelQueryMsg *pCancelMsg = (SCancelQueryMsg*) pSql->cmd.payload;
// pCancelMsg->qhandle = htobe64(pSql->res.qhandle);
//
// SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
//
// if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
// int32_t vgIndex = pTableMetaInfo->vgroupIndex;
// if (pTableMetaInfo->pVgroupTables == NULL) {
// SVgroupsInfo *pVgroupInfo = pTableMetaInfo->vgroupList;
// assert(pVgroupInfo->vgroups[vgIndex].vgId > 0 && vgIndex < pTableMetaInfo->vgroupList->numOfVgroups);
//
// pCancelMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId);
// tscDebug("%p build cancel query msg from vgId:%d, vgIndex:%d", pSql, pVgroupInfo->vgroups[vgIndex].vgId, vgIndex);
// } else {
// int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables);
// assert(vgIndex >= 0 && vgIndex < numOfVgroups);
//
// SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, vgIndex);
//
// pCancelMsg->header.vgId = htonl(pTableIdList->vgInfo.vgId);
// tscDebug("%p build cancel query msg from vgId:%d, vgIndex:%d", pSql, pTableIdList->vgInfo.vgId, vgIndex);
// }
// } else {
// STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
// pCancelMsg->header.vgId = htonl(pTableMeta->vgroupInfo.vgId);
// tscDebug("%p build cancel query msg from only one vgroup, vgId:%d", pSql, pTableMeta->vgroupInfo.vgId);
// }
//
// pSql->cmd.payloadLen = sizeof(SCancelQueryMsg);
// pSql->cmd.msgType = TSDB_MSG_TYPE_CANCEL_QUERY;
//
// pCancelMsg->header.contLen = htonl(sizeof(SCancelQueryMsg));
// return TSDB_CODE_SUCCESS;
//}
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SAlterDbMsg
);
pCmd
->
payloadLen
=
sizeof
(
SAlterDbMsg
);
...
...
src/client/src/tscSql.c
浏览文件 @
a7c6e73f
...
@@ -115,8 +115,6 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -115,8 +115,6 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
pObj
->
signature
=
pObj
;
pObj
->
signature
=
pObj
;
pObj
->
pDnodeConn
=
pDnodeConn
;
pObj
->
pDnodeConn
=
pDnodeConn
;
T_REF_INIT_VAL
(
pObj
,
1
);
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
secretEncryptLen
=
MIN
(
secretEncryptLen
,
sizeof
(
pObj
->
pass
));
secretEncryptLen
=
MIN
(
secretEncryptLen
,
sizeof
(
pObj
->
pass
));
...
@@ -172,11 +170,9 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -172,11 +170,9 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
if
(
taos
!=
NULL
)
{
if
(
taos
!=
NULL
)
{
*
taos
=
pObj
;
*
taos
=
pObj
;
}
}
pObj
->
rid
=
taosAddRef
(
tscRefId
,
pObj
);
registerSqlObj
(
pSql
);
registerSqlObj
(
pSql
);
tsInsertHeadSize
=
sizeof
(
SMsgDesc
)
+
sizeof
(
SSubmitMsg
);
pObj
->
rid
=
taosAddRef
(
tscRefId
,
pObj
);
return
pSql
;
return
pSql
;
}
}
...
@@ -288,34 +284,21 @@ void taos_close(TAOS *taos) {
...
@@ -288,34 +284,21 @@ void taos_close(TAOS *taos) {
return
;
return
;
}
}
// make sure that the close connection can only be executed once.
if
(
RID_VALID
(
pObj
->
hbrid
))
{
pObj
->
signature
=
NULL
;
taosTmrStopA
(
&
(
pObj
->
pTimer
));
if
(
pObj
->
hbrid
>
0
)
{
SSqlObj
*
pHb
=
(
SSqlObj
*
)
taosAcquireRef
(
tscObjRef
,
pObj
->
hbrid
);
SSqlObj
*
pHb
=
(
SSqlObj
*
)
taosAcquireRef
(
tscObjRef
,
pObj
->
hbrid
);
if
(
pHb
!=
NULL
)
{
if
(
pHb
!=
NULL
)
{
if
(
pHb
->
rpcRid
>
0
)
{
// wait for rsp from dnode
if
(
RID_VALID
(
pHb
->
rpcRid
)
)
{
// wait for rsp from dnode
rpcCancelRequest
(
pHb
->
rpcRid
);
rpcCancelRequest
(
pHb
->
rpcRid
);
pHb
->
rpcRid
=
-
1
;
pHb
->
rpcRid
=
-
1
;
}
}
tscDebug
(
"%p HB is freed"
,
pHb
);
tscDebug
(
"%p HB is freed"
,
pHb
);
taos_free_result
(
pHb
);
taosReleaseRef
(
tscObjRef
,
pHb
->
self
);
taosReleaseRef
(
tscObjRef
,
pHb
->
self
);
taos_free_result
(
pHb
);
}
}
}
}
int32_t
ref
=
T_REF_DEC
(
pObj
);
assert
(
ref
>=
0
);
if
(
ref
>
0
)
{
tscDebug
(
"%p %d remain sqlObjs, not free tscObj and dnodeConn:%p"
,
pObj
,
ref
,
pObj
->
pDnodeConn
);
return
;
}
tscDebug
(
"%p all sqlObj are freed, free tscObj and close dnodeConn:%p"
,
pObj
,
pObj
->
pDnodeConn
);
tscDebug
(
"%p all sqlObj are freed, free tscObj and close dnodeConn:%p"
,
pObj
,
pObj
->
pDnodeConn
);
taosRemoveRef
(
tscRefId
,
pObj
->
rid
);
taosRemoveRef
(
tscRefId
,
pObj
->
rid
);
}
}
...
@@ -331,7 +314,7 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
...
@@ -331,7 +314,7 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
tsem_post
(
&
pSql
->
rspSem
);
tsem_post
(
&
pSql
->
rspSem
);
}
}
TAOS_RES
*
taos_query_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
,
TAOS_RES
*
*
res
)
{
TAOS_RES
*
taos_query_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
,
int64_t
*
res
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
...
@@ -357,7 +340,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
...
@@ -357,7 +340,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
if
(
res
!=
NULL
)
{
if
(
res
!=
NULL
)
{
*
res
=
pSql
;
atomic_store_64
(
res
,
pSql
->
self
)
;
}
}
tsem_wait
(
&
pSql
->
rspSem
);
tsem_wait
(
&
pSql
->
rspSem
);
...
@@ -368,7 +351,7 @@ TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) {
...
@@ -368,7 +351,7 @@ TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) {
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
NULL
);
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
NULL
);
}
}
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
TAOS_RES
*
*
res
)
{
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
int64_t
*
res
)
{
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
res
);
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
res
);
}
}
...
...
src/client/src/tscSystem.c
浏览文件 @
a7c6e73f
...
@@ -30,18 +30,16 @@
...
@@ -30,18 +30,16 @@
#include "tlocale.h"
#include "tlocale.h"
// global, not configurable
// global, not configurable
SCacheObj
*
tscMetaCache
;
SCacheObj
*
tscMetaCache
;
// table meta cache
SHashObj
*
tscHashMap
;
// hash map to keep the global vgroup info
int
tscObjRef
=
-
1
;
int
tscObjRef
=
-
1
;
void
*
tscTmr
;
void
*
tscTmr
;
void
*
tscQhandle
;
void
*
tscQhandle
;
void
*
tscCheckDiskUsageTmr
;
void
*
tscCheckDiskUsageTmr
;
int
tsInsertHeadSize
;
int
tscRefId
=
-
1
;
int
tscRefId
=
-
1
;
int
tscNumOfObj
=
0
;
// number of sqlObj in current process.
int
tscNumOfThreads
;
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
//void tscUpdateEpSet(void *ahandle, SRpcEpSet *pEpSet);
void
tscCheckDiskUsage
(
void
*
UNUSED_PARAM
(
para
),
void
*
UNUSED_PARAM
(
param
))
{
void
tscCheckDiskUsage
(
void
*
UNUSED_PARAM
(
para
),
void
*
UNUSED_PARAM
(
param
))
{
taosGetDisk
();
taosGetDisk
();
...
@@ -114,7 +112,7 @@ void taos_init_imp(void) {
...
@@ -114,7 +112,7 @@ void taos_init_imp(void) {
int
queueSize
=
tsMaxConnections
*
2
;
int
queueSize
=
tsMaxConnections
*
2
;
double
factor
=
(
tscEmbedded
==
0
)
?
2
.
0
:
4
.
0
;
double
factor
=
(
tscEmbedded
==
0
)
?
2
.
0
:
4
.
0
;
tscNumOfThreads
=
(
int
)(
tsNumOfCores
*
tsNumOfThreadsPerCore
/
factor
);
int32_t
tscNumOfThreads
=
(
int
)(
tsNumOfCores
*
tsNumOfThreadsPerCore
/
factor
);
if
(
tscNumOfThreads
<
2
)
{
if
(
tscNumOfThreads
<
2
)
{
tscNumOfThreads
=
2
;
tscNumOfThreads
=
2
;
}
}
...
@@ -134,6 +132,7 @@ void taos_init_imp(void) {
...
@@ -134,6 +132,7 @@ void taos_init_imp(void) {
if
(
tscMetaCache
==
NULL
)
{
if
(
tscMetaCache
==
NULL
)
{
tscMetaCache
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
tscFreeTableMetaHelper
,
"tableMeta"
);
tscMetaCache
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
tscFreeTableMetaHelper
,
"tableMeta"
);
tscObjRef
=
taosOpenRef
(
40960
,
tscFreeRegisteredSqlObj
);
tscObjRef
=
taosOpenRef
(
40960
,
tscFreeRegisteredSqlObj
);
tscHashMap
=
taosHashInit
(
1024
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
}
}
tscRefId
=
taosOpenRef
(
200
,
tscCloseTscObj
);
tscRefId
=
taosOpenRef
(
200
,
tscCloseTscObj
);
...
...
src/client/src/tscUtil.c
浏览文件 @
a7c6e73f
...
@@ -458,29 +458,19 @@ void tscFreeRegisteredSqlObj(void *pSql) {
...
@@ -458,29 +458,19 @@ void tscFreeRegisteredSqlObj(void *pSql) {
SSqlObj
*
p
=
*
(
SSqlObj
**
)
pSql
;
SSqlObj
*
p
=
*
(
SSqlObj
**
)
pSql
;
STscObj
*
pTscObj
=
p
->
pTscObj
;
STscObj
*
pTscObj
=
p
->
pTscObj
;
assert
(
p
->
self
!=
0
);
assert
(
RID_VALID
(
p
->
self
));
tscFreeSqlObj
(
p
);
int32_t
ref
=
T_REF_DEC
(
pTscObj
);
tscFreeSqlObj
(
p
);
assert
(
ref
>=
0
);
taosReleaseRef
(
tscRefId
,
pTscObj
->
rid
);
tscDebug
(
"%p free sqlObj completed, tscObj:%p ref:%d"
,
p
,
pTscObj
,
ref
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfObj
,
1
);
if
(
ref
==
0
)
{
int32_t
total
=
atomic_sub_fetch_32
(
&
tscNumOfObj
,
1
);
tscDebug
(
"%p all sqlObj freed, free tscObj:%p"
,
p
,
pTscObj
);
tscDebug
(
"%p free SqlObj, total in tscObj:%d, total:%d"
,
pSql
,
num
,
total
);
taosRemoveRef
(
tscRefId
,
pTscObj
->
rid
);
}
}
}
void
tscFreeTableMetaHelper
(
void
*
pTableMeta
)
{
void
tscFreeTableMetaHelper
(
void
*
pTableMeta
)
{
STableMeta
*
p
=
(
STableMeta
*
)
pTableMeta
;
STableMeta
*
p
=
(
STableMeta
*
)
pTableMeta
;
int32_t
numOfEps
=
p
->
vgroupInfo
.
numOfEps
;
assert
(
numOfEps
>=
0
&&
numOfEps
<=
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
++
i
)
{
tfree
(
p
->
vgroupInfo
.
epAddr
[
i
].
fqdn
);
}
int32_t
numOfEps1
=
p
->
corVgroupInfo
.
numOfEps
;
int32_t
numOfEps1
=
p
->
corVgroupInfo
.
numOfEps
;
assert
(
numOfEps1
>=
0
&&
numOfEps1
<=
TSDB_MAX_REPLICA
);
assert
(
numOfEps1
>=
0
&&
numOfEps1
<=
TSDB_MAX_REPLICA
);
...
@@ -810,6 +800,7 @@ static void extractTableMeta(SSqlCmd* pCmd) {
...
@@ -810,6 +800,7 @@ static void extractTableMeta(SSqlCmd* pCmd) {
}
}
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
)
{
int32_t
tscMergeTableDataBlocks
(
SSqlObj
*
pSql
)
{
const
int
INSERT_HEAD_SIZE
=
sizeof
(
SMsgDesc
)
+
sizeof
(
SSubmitMsg
);
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
void
*
pVnodeDataBlockHashList
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
);
void
*
pVnodeDataBlockHashList
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
);
...
@@ -824,7 +815,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql) {
...
@@ -824,7 +815,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql) {
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
*
dataBuf
=
NULL
;
int32_t
ret
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pOneTableBlock
->
vgId
,
TSDB_PAYLOAD_SIZE
,
int32_t
ret
=
tscGetDataBlockFromList
(
pVnodeDataBlockHashList
,
pOneTableBlock
->
vgId
,
TSDB_PAYLOAD_SIZE
,
tsInsertHeadSize
,
0
,
pOneTableBlock
->
tableId
,
pOneTableBlock
->
pTableMeta
,
&
dataBuf
,
pVnodeDataBlockList
);
INSERT_HEAD_SIZE
,
0
,
pOneTableBlock
->
tableId
,
pOneTableBlock
->
pTableMeta
,
&
dataBuf
,
pVnodeDataBlockList
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p failed to prepare the data block buffer for merging table data, code:%d"
,
pSql
,
ret
);
tscError
(
"%p failed to prepare the data block buffer for merging table data, code:%d"
,
pSql
,
ret
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
...
@@ -1917,10 +1908,12 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
...
@@ -1917,10 +1908,12 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
}
}
void
registerSqlObj
(
SSqlObj
*
pSql
)
{
void
registerSqlObj
(
SSqlObj
*
pSql
)
{
int32_t
ref
=
T_REF_INC
(
pSql
->
pTscObj
);
taosAcquireRef
(
tscRefId
,
pSql
->
pTscObj
->
rid
);
tscDebug
(
"%p add to tscObj:%p, ref:%d"
,
pSql
,
pSql
->
pTscObj
,
ref
);
pSql
->
self
=
taosAddRef
(
tscObjRef
,
pSql
);
pSql
->
self
=
taosAddRef
(
tscObjRef
,
pSql
);
int32_t
num
=
atomic_add_fetch_32
(
&
pSql
->
pTscObj
->
numOfObj
,
1
);
int32_t
total
=
atomic_add_fetch_32
(
&
tscNumOfObj
,
1
);
tscDebug
(
"%p new SqlObj from %p, total in tscObj:%d, total:%d"
,
pSql
,
pSql
->
pTscObj
,
num
,
total
);
}
}
SSqlObj
*
createSimpleSubObj
(
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
int32_t
cmd
)
{
SSqlObj
*
createSimpleSubObj
(
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
int32_t
cmd
)
{
...
@@ -1953,27 +1946,21 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
...
@@ -1953,27 +1946,21 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
pNew
->
fp
=
fp
;
pNew
->
fp
=
fp
;
pNew
->
fetchFp
=
fp
;
pNew
->
fetchFp
=
fp
;
pNew
->
param
=
param
;
pNew
->
param
=
param
;
pNew
->
sqlstr
=
NULL
;
pNew
->
maxRetry
=
TSDB_MAX_REPLICA
;
pNew
->
maxRetry
=
TSDB_MAX_REPLICA
;
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
if
(
pNew
->
sqlstr
==
NULL
)
{
tscError
(
"%p new subquery failed"
,
pSql
);
tscFreeSqlObj
(
pNew
);
return
NULL
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
0
);
assert
(
pSql
->
cmd
.
clauseIndex
==
0
);
assert
(
pSql
->
cmd
.
clauseIndex
==
0
);
STableMetaInfo
*
pMasterTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
STableMetaInfo
*
pMasterTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
tscAddTableMetaInfo
(
pQueryInfo
,
pMasterTableMetaInfo
->
name
,
NULL
,
NULL
,
NULL
,
NULL
);
tscAddTableMetaInfo
(
pQueryInfo
,
pMasterTableMetaInfo
->
name
,
NULL
,
NULL
,
NULL
,
NULL
);
registerSqlObj
(
pNew
);
registerSqlObj
(
pNew
);
return
pNew
;
return
pNew
;
}
}
static
void
doSetSqlExprAndResultFieldInfo
(
SQueryInfo
*
p
QueryInfo
,
SQueryInfo
*
p
NewQueryInfo
,
int64_t
uid
)
{
static
void
doSetSqlExprAndResultFieldInfo
(
SQueryInfo
*
pNewQueryInfo
,
int64_t
uid
)
{
int32_t
numOfOutput
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
int32_t
numOfOutput
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pNewQueryInfo
);
if
(
numOfOutput
==
0
)
{
if
(
numOfOutput
==
0
)
{
return
;
return
;
...
@@ -2028,13 +2015,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -2028,13 +2015,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNew
->
pTscObj
=
pSql
->
pTscObj
;
pNew
->
pTscObj
=
pSql
->
pTscObj
;
pNew
->
signature
=
pNew
;
pNew
->
signature
=
pNew
;
pNew
->
sqlstr
=
NULL
;
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
if
(
pNew
->
sqlstr
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vgroupIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
SSqlCmd
*
pnCmd
=
&
pNew
->
cmd
;
SSqlCmd
*
pnCmd
=
&
pNew
->
cmd
;
memcpy
(
pnCmd
,
pCmd
,
sizeof
(
SSqlCmd
));
memcpy
(
pnCmd
,
pCmd
,
sizeof
(
SSqlCmd
));
...
@@ -2122,19 +2103,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -2122,19 +2103,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
goto
_error
;
goto
_error
;
}
}
doSetSqlExprAndResultFieldInfo
(
p
QueryInfo
,
p
NewQueryInfo
,
uid
);
doSetSqlExprAndResultFieldInfo
(
pNewQueryInfo
,
uid
);
pNew
->
fp
=
fp
;
pNew
->
fp
=
fp
;
pNew
->
fetchFp
=
fp
;
pNew
->
fetchFp
=
fp
;
pNew
->
param
=
param
;
pNew
->
param
=
param
;
pNew
->
maxRetry
=
TSDB_MAX_REPLICA
;
pNew
->
maxRetry
=
TSDB_MAX_REPLICA
;
char
*
name
=
pTableMetaInfo
->
name
;
char
*
name
=
pTableMetaInfo
->
name
;
STableMetaInfo
*
pFinalInfo
=
NULL
;
STableMetaInfo
*
pFinalInfo
=
NULL
;
if
(
pPrevSql
==
NULL
)
{
if
(
pPrevSql
==
NULL
)
{
// get by name may failed due to the cache cleanup
STableMeta
*
pTableMeta
=
taosCacheAcquireByData
(
tscMetaCache
,
pTableMetaInfo
->
pTableMeta
);
// get by name may failed due to the cache cleanup
STableMeta
*
pTableMeta
=
taosCacheAcquireByData
(
tscMetaCache
,
pTableMetaInfo
->
pTableMeta
);
assert
(
pTableMeta
!=
NULL
);
assert
(
pTableMeta
!=
NULL
);
pFinalInfo
=
tscAddTableMetaInfo
(
pNewQueryInfo
,
name
,
pTableMeta
,
pTableMetaInfo
->
vgroupList
,
pFinalInfo
=
tscAddTableMetaInfo
(
pNewQueryInfo
,
name
,
pTableMeta
,
pTableMetaInfo
->
vgroupList
,
...
...
src/common/inc/tglobal.h
浏览文件 @
a7c6e73f
...
@@ -32,8 +32,8 @@ extern uint16_t tsSyncPort;
...
@@ -32,8 +32,8 @@ extern uint16_t tsSyncPort;
extern
uint16_t
tsArbitratorPort
;
extern
uint16_t
tsArbitratorPort
;
extern
int32_t
tsStatusInterval
;
extern
int32_t
tsStatusInterval
;
extern
int32_t
tsNumOfMnodes
;
extern
int32_t
tsNumOfMnodes
;
extern
int
32_t
tsEnableVnodeBak
;
extern
int
8_t
tsEnableVnodeBak
;
extern
int
32_t
tsEnableTelemetryReporting
;
extern
int
8_t
tsEnableTelemetryReporting
;
extern
char
tsEmail
[];
extern
char
tsEmail
[];
extern
char
tsArbitrator
[];
extern
char
tsArbitrator
[];
...
@@ -51,7 +51,7 @@ extern int8_t tsDaylight;
...
@@ -51,7 +51,7 @@ extern int8_t tsDaylight;
extern
char
tsTimezone
[];
extern
char
tsTimezone
[];
extern
char
tsLocale
[];
extern
char
tsLocale
[];
extern
char
tsCharset
[];
// default encode string
extern
char
tsCharset
[];
// default encode string
extern
int
32_t
tsEnableCoreFile
;
extern
int
8_t
tsEnableCoreFile
;
extern
int32_t
tsCompressMsgSize
;
extern
int32_t
tsCompressMsgSize
;
extern
char
tsTempDir
[];
extern
char
tsTempDir
[];
...
@@ -59,12 +59,12 @@ extern char tsTempDir[];
...
@@ -59,12 +59,12 @@ extern char tsTempDir[];
extern
int32_t
tsQueryBufferSize
;
// maximum allowed usage buffer for each data node during query processing
extern
int32_t
tsQueryBufferSize
;
// maximum allowed usage buffer for each data node during query processing
extern
int32_t
tsRetrieveBlockingModel
;
// retrieve threads will be blocked
extern
int32_t
tsRetrieveBlockingModel
;
// retrieve threads will be blocked
extern
int
32_t
tsKeepOriginalColumnName
;
extern
int
8_t
tsKeepOriginalColumnName
;
// client
// client
extern
int32_t
tsTableMetaKeepTimer
;
extern
int32_t
tsTableMetaKeepTimer
;
extern
int32_t
tsMaxSQLStringLen
;
extern
int32_t
tsMaxSQLStringLen
;
extern
int
32_t
tsTscEnableRecordSql
;
extern
int
8_t
tsTscEnableRecordSql
;
extern
int32_t
tsMaxNumOfOrderedResults
;
extern
int32_t
tsMaxNumOfOrderedResults
;
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinIntervalTime
;
extern
int32_t
tsMinIntervalTime
;
...
@@ -93,29 +93,32 @@ extern int16_t tsWAL;
...
@@ -93,29 +93,32 @@ extern int16_t tsWAL;
extern
int32_t
tsFsyncPeriod
;
extern
int32_t
tsFsyncPeriod
;
extern
int32_t
tsReplications
;
extern
int32_t
tsReplications
;
extern
int32_t
tsQuorum
;
extern
int32_t
tsQuorum
;
extern
int32_t
tsUpdate
;
extern
int8_t
tsUpdate
;
extern
int8_t
tsCacheLastRow
;
// balance
// balance
extern
int
32_t
tsEnableBalance
;
extern
int
8_t
tsEnableBalance
;
extern
int
32_t
tsAlternativeRole
;
extern
int
8_t
tsAlternativeRole
;
extern
int32_t
tsBalanceInterval
;
extern
int32_t
tsBalanceInterval
;
extern
int32_t
tsOfflineThreshold
;
extern
int32_t
tsOfflineThreshold
;
extern
int32_t
tsMnodeEqualVnodeNum
;
extern
int32_t
tsMnodeEqualVnodeNum
;
extern
int32_t
tsFlowCtrl
;
extern
int8_t
tsEnableFlowCtrl
;
extern
int8_t
tsEnableSlaveQuery
;
extern
int8_t
tsEnableAdjustMaster
;
// restful
// restful
extern
int
32_t
tsEnableHttpModule
;
extern
int
8_t
tsEnableHttpModule
;
extern
int32_t
tsRestRowLimit
;
extern
int32_t
tsRestRowLimit
;
extern
uint16_t
tsHttpPort
;
extern
uint16_t
tsHttpPort
;
extern
int32_t
tsHttpCacheSessions
;
extern
int32_t
tsHttpCacheSessions
;
extern
int32_t
tsHttpSessionExpire
;
extern
int32_t
tsHttpSessionExpire
;
extern
int32_t
tsHttpMaxThreads
;
extern
int32_t
tsHttpMaxThreads
;
extern
int
32_t
tsHttpEnableCompress
;
extern
int
8_t
tsHttpEnableCompress
;
extern
int
32_t
tsHttpEnableRecordSql
;
extern
int
8_t
tsHttpEnableRecordSql
;
extern
int
32_t
tsTelegrafUseFieldNum
;
extern
int
8_t
tsTelegrafUseFieldNum
;
// mqtt
// mqtt
extern
int
32
_t
tsEnableMqttModule
;
extern
int
8
_t
tsEnableMqttModule
;
extern
char
tsMqttHostName
[];
extern
char
tsMqttHostName
[];
extern
char
tsMqttPort
[];
extern
char
tsMqttPort
[];
extern
char
tsMqttUser
[];
extern
char
tsMqttUser
[];
...
@@ -124,17 +127,17 @@ extern char tsMqttClientId[];
...
@@ -124,17 +127,17 @@ extern char tsMqttClientId[];
extern
char
tsMqttTopic
[];
extern
char
tsMqttTopic
[];
// monitor
// monitor
extern
int
32_t
tsEnableMonitorModule
;
extern
int
8_t
tsEnableMonitorModule
;
extern
char
tsMonitorDbName
[];
extern
char
tsMonitorDbName
[];
extern
char
tsInternalPass
[];
extern
char
tsInternalPass
[];
extern
int32_t
tsMonitorInterval
;
extern
int32_t
tsMonitorInterval
;
// stream
// stream
extern
int
32
_t
tsEnableStream
;
extern
int
8
_t
tsEnableStream
;
// internal
// internal
extern
int
32_t
tsPrintAuth
;
extern
int
8_t
tsPrintAuth
;
extern
uint32_t
tscEmbedded
;
extern
int8_t
tscEmbedded
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsVnodeDir
[];
extern
char
tsVnodeDir
[];
extern
char
tsDnodeDir
[];
extern
char
tsDnodeDir
[];
...
@@ -170,13 +173,13 @@ extern char gitinfoOfInternal[];
...
@@ -170,13 +173,13 @@ extern char gitinfoOfInternal[];
extern
char
buildinfo
[];
extern
char
buildinfo
[];
// log
// log
extern
int
32_t
tsAsyncLog
;
extern
int
8_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsLogKeepDays
;
extern
int32_t
tsLogKeepDays
;
extern
int32_t
dDebugFlag
;
extern
int32_t
dDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
mDebugFlag
;
extern
int32_t
mDebugFlag
;
extern
u
int32_t
cDebugFlag
;
extern
int32_t
cDebugFlag
;
extern
int32_t
jniDebugFlag
;
extern
int32_t
jniDebugFlag
;
extern
int32_t
tmrDebugFlag
;
extern
int32_t
tmrDebugFlag
;
extern
int32_t
sdbDebugFlag
;
extern
int32_t
sdbDebugFlag
;
...
@@ -186,7 +189,7 @@ extern int32_t monDebugFlag;
...
@@ -186,7 +189,7 @@ extern int32_t monDebugFlag;
extern
int32_t
uDebugFlag
;
extern
int32_t
uDebugFlag
;
extern
int32_t
rpcDebugFlag
;
extern
int32_t
rpcDebugFlag
;
extern
int32_t
odbcDebugFlag
;
extern
int32_t
odbcDebugFlag
;
extern
u
int32_t
qDebugFlag
;
extern
int32_t
qDebugFlag
;
extern
int32_t
wDebugFlag
;
extern
int32_t
wDebugFlag
;
extern
int32_t
cqDebugFlag
;
extern
int32_t
cqDebugFlag
;
extern
int32_t
debugFlag
;
extern
int32_t
debugFlag
;
...
...
src/common/inc/tulog.h
浏览文件 @
a7c6e73f
...
@@ -23,7 +23,7 @@ extern "C" {
...
@@ -23,7 +23,7 @@ extern "C" {
#include "tlog.h"
#include "tlog.h"
extern
int32_t
uDebugFlag
;
extern
int32_t
uDebugFlag
;
extern
uint32_t
tscEmbedded
;
extern
int8_t
tscEmbedded
;
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
...
...
src/common/src/tglobal.c
浏览文件 @
a7c6e73f
...
@@ -39,8 +39,8 @@ uint16_t tsSyncPort = 6040;
...
@@ -39,8 +39,8 @@ uint16_t tsSyncPort = 6040;
uint16_t
tsArbitratorPort
=
6042
;
uint16_t
tsArbitratorPort
=
6042
;
int32_t
tsStatusInterval
=
1
;
// second
int32_t
tsStatusInterval
=
1
;
// second
int32_t
tsNumOfMnodes
=
3
;
int32_t
tsNumOfMnodes
=
3
;
int
32_t
tsEnableVnodeBak
=
1
;
int
8_t
tsEnableVnodeBak
=
1
;
int
32_t
tsEnableTelemetryReporting
=
1
;
int
8_t
tsEnableTelemetryReporting
=
1
;
char
tsEmail
[
TSDB_FQDN_LEN
]
=
{
0
};
char
tsEmail
[
TSDB_FQDN_LEN
]
=
{
0
};
// common
// common
...
@@ -56,7 +56,7 @@ int8_t tsDaylight = 0;
...
@@ -56,7 +56,7 @@ int8_t tsDaylight = 0;
char
tsTimezone
[
TSDB_TIMEZONE_LEN
]
=
{
0
};
char
tsTimezone
[
TSDB_TIMEZONE_LEN
]
=
{
0
};
char
tsLocale
[
TSDB_LOCALE_LEN
]
=
{
0
};
char
tsLocale
[
TSDB_LOCALE_LEN
]
=
{
0
};
char
tsCharset
[
TSDB_LOCALE_LEN
]
=
{
0
};
// default encode string
char
tsCharset
[
TSDB_LOCALE_LEN
]
=
{
0
};
// default encode string
int
32_t
tsEnableCoreFile
=
0
;
int
8_t
tsEnableCoreFile
=
0
;
int32_t
tsMaxBinaryDisplayWidth
=
30
;
int32_t
tsMaxBinaryDisplayWidth
=
30
;
char
tsTempDir
[
TSDB_FILENAME_LEN
]
=
"/tmp/"
;
char
tsTempDir
[
TSDB_FILENAME_LEN
]
=
"/tmp/"
;
...
@@ -73,7 +73,7 @@ int32_t tsCompressMsgSize = -1;
...
@@ -73,7 +73,7 @@ int32_t tsCompressMsgSize = -1;
// client
// client
int32_t
tsTableMetaKeepTimer
=
7200
;
// second
int32_t
tsTableMetaKeepTimer
=
7200
;
// second
int32_t
tsMaxSQLStringLen
=
TSDB_MAX_SQL_LEN
;
int32_t
tsMaxSQLStringLen
=
TSDB_MAX_SQL_LEN
;
int
32_t
tsTscEnableRecordSql
=
0
;
int
8_t
tsTscEnableRecordSql
=
0
;
// the maximum number of results for projection query on super table that are returned from
// the maximum number of results for projection query on super table that are returned from
// one virtual node, to order according to timestamp
// one virtual node, to order according to timestamp
...
@@ -110,7 +110,7 @@ int32_t tsQueryBufferSize = -1;
...
@@ -110,7 +110,7 @@ int32_t tsQueryBufferSize = -1;
int32_t
tsRetrieveBlockingModel
=
0
;
int32_t
tsRetrieveBlockingModel
=
0
;
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
// last_row(*), first(*), last_row(ts, col1, col2) query, the result fields will be the original column name
int
32_t
tsKeepOriginalColumnName
=
0
;
int
8_t
tsKeepOriginalColumnName
=
0
;
// db parameters
// db parameters
int32_t
tsCacheBlockSize
=
TSDB_DEFAULT_CACHE_BLOCK_SIZE
;
int32_t
tsCacheBlockSize
=
TSDB_DEFAULT_CACHE_BLOCK_SIZE
;
...
@@ -126,33 +126,36 @@ int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
...
@@ -126,33 +126,36 @@ int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
int32_t
tsFsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
int32_t
tsFsyncPeriod
=
TSDB_DEFAULT_FSYNC_PERIOD
;
int32_t
tsReplications
=
TSDB_DEFAULT_DB_REPLICA_OPTION
;
int32_t
tsReplications
=
TSDB_DEFAULT_DB_REPLICA_OPTION
;
int32_t
tsQuorum
=
TSDB_DEFAULT_DB_QUORUM_OPTION
;
int32_t
tsQuorum
=
TSDB_DEFAULT_DB_QUORUM_OPTION
;
int32_t
tsUpdate
=
TSDB_DEFAULT_DB_UPDATE_OPTION
;
int8_t
tsUpdate
=
TSDB_DEFAULT_DB_UPDATE_OPTION
;
int8_t
tsCacheLastRow
=
TSDB_DEFAULT_CACHE_BLOCK_SIZE
;
int32_t
tsMaxVgroupsPerDb
=
0
;
int32_t
tsMaxVgroupsPerDb
=
0
;
int32_t
tsMinTablePerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsMinTablePerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsMaxTablePerVnode
=
TSDB_DEFAULT_TABLES
;
int32_t
tsMaxTablePerVnode
=
TSDB_DEFAULT_TABLES
;
int32_t
tsTableIncStepPerVnode
=
TSDB_TABLES_STEP
;
int32_t
tsTableIncStepPerVnode
=
TSDB_TABLES_STEP
;
// balance
// balance
int
32_t
tsEnableBalance
=
1
;
int
8_t
tsEnableBalance
=
1
;
int
32_t
tsAlternativeRole
=
0
;
int
8_t
tsAlternativeRole
=
0
;
int32_t
tsBalanceInterval
=
300
;
// seconds
int32_t
tsBalanceInterval
=
300
;
// seconds
int32_t
tsOfflineThreshold
=
86400
*
100
;
// seconds 10days
int32_t
tsOfflineThreshold
=
86400
*
100
;
// seconds 10days
int32_t
tsMnodeEqualVnodeNum
=
4
;
int32_t
tsMnodeEqualVnodeNum
=
4
;
int32_t
tsFlowCtrl
=
1
;
int8_t
tsEnableFlowCtrl
=
1
;
int8_t
tsEnableSlaveQuery
=
1
;
int8_t
tsEnableAdjustMaster
=
1
;
// restful
// restful
int
32_t
tsEnableHttpModule
=
1
;
int
8_t
tsEnableHttpModule
=
1
;
int32_t
tsRestRowLimit
=
10240
;
int32_t
tsRestRowLimit
=
10240
;
uint16_t
tsHttpPort
=
6041
;
// only tcp, range tcp[6041]
uint16_t
tsHttpPort
=
6041
;
// only tcp, range tcp[6041]
int32_t
tsHttpCacheSessions
=
1000
;
int32_t
tsHttpCacheSessions
=
1000
;
int32_t
tsHttpSessionExpire
=
36000
;
int32_t
tsHttpSessionExpire
=
36000
;
int32_t
tsHttpMaxThreads
=
2
;
int32_t
tsHttpMaxThreads
=
2
;
int
32_t
tsHttpEnableCompress
=
1
;
int
8_t
tsHttpEnableCompress
=
1
;
int
32_t
tsHttpEnableRecordSql
=
0
;
int
8_t
tsHttpEnableRecordSql
=
0
;
int
32_t
tsTelegrafUseFieldNum
=
0
;
int
8_t
tsTelegrafUseFieldNum
=
0
;
// mqtt
// mqtt
int
32
_t
tsEnableMqttModule
=
0
;
// not finished yet, not started it by default
int
8
_t
tsEnableMqttModule
=
0
;
// not finished yet, not started it by default
char
tsMqttHostName
[
TSDB_MQTT_HOSTNAME_LEN
]
=
"test.mosquitto.org"
;
char
tsMqttHostName
[
TSDB_MQTT_HOSTNAME_LEN
]
=
"test.mosquitto.org"
;
char
tsMqttPort
[
TSDB_MQTT_PORT_LEN
]
=
"1883"
;
char
tsMqttPort
[
TSDB_MQTT_PORT_LEN
]
=
"1883"
;
char
tsMqttUser
[
TSDB_MQTT_USER_LEN
]
=
{
0
};
char
tsMqttUser
[
TSDB_MQTT_USER_LEN
]
=
{
0
};
...
@@ -161,23 +164,24 @@ char tsMqttClientId[TSDB_MQTT_CLIENT_ID_LEN] = "TDengineMqttSubscriber";
...
@@ -161,23 +164,24 @@ char tsMqttClientId[TSDB_MQTT_CLIENT_ID_LEN] = "TDengineMqttSubscriber";
char
tsMqttTopic
[
TSDB_MQTT_TOPIC_LEN
]
=
"/test"
;
// #
char
tsMqttTopic
[
TSDB_MQTT_TOPIC_LEN
]
=
"/test"
;
// #
// monitor
// monitor
int
32_t
tsEnableMonitorModule
=
1
;
int
8_t
tsEnableMonitorModule
=
1
;
char
tsMonitorDbName
[
TSDB_DB_NAME_LEN
]
=
"log"
;
char
tsMonitorDbName
[
TSDB_DB_NAME_LEN
]
=
"log"
;
char
tsInternalPass
[]
=
"secretkey"
;
char
tsInternalPass
[]
=
"secretkey"
;
int32_t
tsMonitorInterval
=
30
;
// seconds
int32_t
tsMonitorInterval
=
30
;
// seconds
// stream
// stream
int
32_t
tsEnableStream
=
1
;
int
8_t
tsEnableStream
=
1
;
// internal
// internal
int
32_t
tsPrintAuth
=
0
;
int
8_t
tsPrintAuth
=
0
;
uint32
_t
tscEmbedded
=
0
;
int8
_t
tscEmbedded
=
0
;
char
configDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
configDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
tsDiskCfgNum
=
0
;
int32_t
tsDiskCfgNum
=
0
;
#ifndef _STORAGE
#ifndef _STORAGE
...
@@ -204,8 +208,8 @@ float tsTotalTmpDirGB = 0;
...
@@ -204,8 +208,8 @@ float tsTotalTmpDirGB = 0;
float
tsTotalDataDirGB
=
0
;
float
tsTotalDataDirGB
=
0
;
float
tsAvailTmpDirectorySpace
=
0
;
float
tsAvailTmpDirectorySpace
=
0
;
float
tsAvailDataDirGB
=
0
;
float
tsAvailDataDirGB
=
0
;
float
tsReservedTmpDirectorySpace
=
0
.
1
f
;
float
tsReservedTmpDirectorySpace
=
1
.
0
f
;
float
tsMinimalDataDirGB
=
0
.
5
f
;
float
tsMinimalDataDirGB
=
1
.
0
f
;
int32_t
tsTotalMemoryMB
=
0
;
int32_t
tsTotalMemoryMB
=
0
;
int32_t
tsVersion
=
0
;
int32_t
tsVersion
=
0
;
...
@@ -215,13 +219,13 @@ int32_t mDebugFlag = 131;
...
@@ -215,13 +219,13 @@ int32_t mDebugFlag = 131;
int32_t
sdbDebugFlag
=
131
;
int32_t
sdbDebugFlag
=
131
;
int32_t
dDebugFlag
=
135
;
int32_t
dDebugFlag
=
135
;
int32_t
vDebugFlag
=
135
;
int32_t
vDebugFlag
=
135
;
u
int32_t
cDebugFlag
=
131
;
int32_t
cDebugFlag
=
131
;
int32_t
jniDebugFlag
=
131
;
int32_t
jniDebugFlag
=
131
;
int32_t
odbcDebugFlag
=
131
;
int32_t
odbcDebugFlag
=
131
;
int32_t
httpDebugFlag
=
131
;
int32_t
httpDebugFlag
=
131
;
int32_t
mqttDebugFlag
=
131
;
int32_t
mqttDebugFlag
=
131
;
int32_t
monDebugFlag
=
131
;
int32_t
monDebugFlag
=
131
;
u
int32_t
qDebugFlag
=
131
;
int32_t
qDebugFlag
=
131
;
int32_t
rpcDebugFlag
=
131
;
int32_t
rpcDebugFlag
=
131
;
int32_t
uDebugFlag
=
131
;
int32_t
uDebugFlag
=
131
;
int32_t
debugFlag
=
0
;
int32_t
debugFlag
=
0
;
...
@@ -282,12 +286,16 @@ bool taosCfgDynamicOptions(char *msg) {
...
@@ -282,12 +286,16 @@ bool taosCfgDynamicOptions(char *msg) {
for
(
int32_t
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
//if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
//if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
)
continue
;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
&&
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT8
)
continue
;
int32_t
cfgLen
=
(
int32_t
)
strlen
(
cfg
->
option
);
int32_t
cfgLen
=
(
int32_t
)
strlen
(
cfg
->
option
);
if
(
cfgLen
!=
olen
)
continue
;
if
(
cfgLen
!=
olen
)
continue
;
if
(
strncasecmp
(
option
,
cfg
->
option
,
olen
)
!=
0
)
continue
;
if
(
strncasecmp
(
option
,
cfg
->
option
,
olen
)
!=
0
)
continue
;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
)
{
*
((
int32_t
*
)
cfg
->
ptr
)
=
vint
;
*
((
int32_t
*
)
cfg
->
ptr
)
=
vint
;
}
else
{
*
((
int8_t
*
)
cfg
->
ptr
)
=
(
int8_t
)
vint
;
}
if
(
strncasecmp
(
cfg
->
option
,
"monitor"
,
olen
)
==
0
)
{
if
(
strncasecmp
(
cfg
->
option
,
"monitor"
,
olen
)
==
0
)
{
if
(
1
==
vint
)
{
if
(
1
==
vint
)
{
...
@@ -508,7 +516,7 @@ static void doInitGlobalConfig(void) {
...
@@ -508,7 +516,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"vnodeBak"
;
cfg
.
option
=
"vnodeBak"
;
cfg
.
ptr
=
&
tsEnableVnodeBak
;
cfg
.
ptr
=
&
tsEnableVnodeBak
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -518,7 +526,7 @@ static void doInitGlobalConfig(void) {
...
@@ -518,7 +526,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"telemetryReporting"
;
cfg
.
option
=
"telemetryReporting"
;
cfg
.
ptr
=
&
tsEnableTelemetryReporting
;
cfg
.
ptr
=
&
tsEnableTelemetryReporting
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -528,7 +536,7 @@ static void doInitGlobalConfig(void) {
...
@@ -528,7 +536,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"balance"
;
cfg
.
option
=
"balance"
;
cfg
.
ptr
=
&
tsEnableBalance
;
cfg
.
ptr
=
&
tsEnableBalance
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -549,7 +557,7 @@ static void doInitGlobalConfig(void) {
...
@@ -549,7 +557,7 @@ static void doInitGlobalConfig(void) {
// 0-any; 1-mnode; 2-vnode
// 0-any; 1-mnode; 2-vnode
cfg
.
option
=
"role"
;
cfg
.
option
=
"role"
;
cfg
.
ptr
=
&
tsAlternativeRole
;
cfg
.
ptr
=
&
tsAlternativeRole
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
2
;
cfg
.
maxValue
=
2
;
...
@@ -582,7 +590,7 @@ static void doInitGlobalConfig(void) {
...
@@ -582,7 +590,7 @@ static void doInitGlobalConfig(void) {
cfg
.
ptr
=
&
tsOfflineThreshold
;
cfg
.
ptr
=
&
tsOfflineThreshold
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
5
;
cfg
.
minValue
=
3
;
cfg
.
maxValue
=
7200000
;
cfg
.
maxValue
=
7200000
;
cfg
.
ptrLength
=
0
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_SECOND
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_SECOND
;
...
@@ -851,7 +859,7 @@ static void doInitGlobalConfig(void) {
...
@@ -851,7 +859,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"update"
;
cfg
.
option
=
"update"
;
cfg
.
ptr
=
&
tsUpdate
;
cfg
.
ptr
=
&
tsUpdate
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_DB_UPDATE
;
cfg
.
minValue
=
TSDB_MIN_DB_UPDATE
;
cfg
.
maxValue
=
TSDB_MAX_DB_UPDATE
;
cfg
.
maxValue
=
TSDB_MAX_DB_UPDATE
;
...
@@ -941,7 +949,7 @@ static void doInitGlobalConfig(void) {
...
@@ -941,7 +949,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"keepColumnName"
;
cfg
.
option
=
"keepColumnName"
;
cfg
.
ptr
=
&
tsKeepOriginalColumnName
;
cfg
.
ptr
=
&
tsKeepOriginalColumnName
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1044,8 +1052,28 @@ static void doInitGlobalConfig(void) {
...
@@ -1044,8 +1052,28 @@ static void doInitGlobalConfig(void) {
// module configs
// module configs
cfg
.
option
=
"flowctrl"
;
cfg
.
option
=
"flowctrl"
;
cfg
.
ptr
=
&
tsFlowCtrl
;
cfg
.
ptr
=
&
tsEnableFlowCtrl
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"slaveQuery"
;
cfg
.
ptr
=
&
tsEnableSlaveQuery
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"adjustMaster"
;
cfg
.
ptr
=
&
tsEnableAdjustMaster
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1055,7 +1083,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1055,7 +1083,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"http"
;
cfg
.
option
=
"http"
;
cfg
.
ptr
=
&
tsEnableHttpModule
;
cfg
.
ptr
=
&
tsEnableHttpModule
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1065,7 +1093,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1065,7 +1093,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"mqtt"
;
cfg
.
option
=
"mqtt"
;
cfg
.
ptr
=
&
tsEnableMqttModule
;
cfg
.
ptr
=
&
tsEnableMqttModule
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1075,7 +1103,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1075,7 +1103,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"monitor"
;
cfg
.
option
=
"monitor"
;
cfg
.
ptr
=
&
tsEnableMonitorModule
;
cfg
.
ptr
=
&
tsEnableMonitorModule
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1085,7 +1113,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1085,7 +1113,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"stream"
;
cfg
.
option
=
"stream"
;
cfg
.
ptr
=
&
tsEnableStream
;
cfg
.
ptr
=
&
tsEnableStream
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1095,7 +1123,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1095,7 +1123,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"httpEnableRecordSql"
;
cfg
.
option
=
"httpEnableRecordSql"
;
cfg
.
ptr
=
&
tsHttpEnableRecordSql
;
cfg
.
ptr
=
&
tsHttpEnableRecordSql
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1105,7 +1133,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1105,7 +1133,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"telegrafUseFieldNum"
;
cfg
.
option
=
"telegrafUseFieldNum"
;
cfg
.
ptr
=
&
tsTelegrafUseFieldNum
;
cfg
.
ptr
=
&
tsTelegrafUseFieldNum
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1156,7 +1184,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1156,7 +1184,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"asyncLog"
;
cfg
.
option
=
"asyncLog"
;
cfg
.
ptr
=
&
tsAsyncLog
;
cfg
.
ptr
=
&
tsAsyncLog
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
16
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1357,7 +1385,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1357,7 +1385,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"enableRecordSql"
;
cfg
.
option
=
"enableRecordSql"
;
cfg
.
ptr
=
&
tsTscEnableRecordSql
;
cfg
.
ptr
=
&
tsTscEnableRecordSql
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1367,7 +1395,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1367,7 +1395,7 @@ static void doInitGlobalConfig(void) {
cfg
.
option
=
"enableCoreFile"
;
cfg
.
option
=
"enableCoreFile"
;
cfg
.
ptr
=
&
tsEnableCoreFile
;
cfg
.
ptr
=
&
tsEnableCoreFile
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT
8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
;
cfg
.
minValue
=
0
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
maxValue
=
1
;
...
@@ -1484,6 +1512,12 @@ int32_t taosCheckGlobalCfg() {
...
@@ -1484,6 +1512,12 @@ int32_t taosCheckGlobalCfg() {
tsNumOfCores
=
1
;
tsNumOfCores
=
1
;
}
}
if
(
tsMaxTablePerVnode
<
tsMinTablePerVnode
)
{
uError
(
"maxTablesPerVnode(%d) < minTablesPerVnode(%d), reset to minTablesPerVnode(%d)"
,
tsMaxTablePerVnode
,
tsMinTablePerVnode
,
tsMinTablePerVnode
);
tsMaxTablePerVnode
=
tsMinTablePerVnode
;
}
// todo refactor
// todo refactor
tsVersion
=
0
;
tsVersion
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
...
...
src/connector/nodejs/nodetaos/cinterface.js
浏览文件 @
a7c6e73f
...
@@ -349,11 +349,12 @@ CTaosInterface.prototype.useResult = function useResult(result) {
...
@@ -349,11 +349,12 @@ CTaosInterface.prototype.useResult = function useResult(result) {
return
fields
;
return
fields
;
}
}
CTaosInterface
.
prototype
.
fetchBlock
=
function
fetchBlock
(
result
,
fields
)
{
CTaosInterface
.
prototype
.
fetchBlock
=
function
fetchBlock
(
result
,
fields
)
{
let
pblock
=
ref
.
ref
(
ref
.
ref
(
ref
.
NULL
));
// equal to our raw data
//
let pblock = ref.ref(ref.ref(ref.NULL)); // equal to our raw data
let
num_of_rows
=
this
.
libtaos
.
taos_fetch_block
(
result
,
pblock
)
let
pblock
=
this
.
libtaos
.
taos_fetch_row
(
result
);
if
(
num_of_rows
==
0
)
{
if
(
pblock
==
null
)
{
return
{
block
:
null
,
num_of_rows
:
0
};
return
{
block
:
null
,
num_of_rows
:
0
};
}
}
var
fieldL
=
this
.
libtaos
.
taos_fetch_lengths
(
result
);
var
fieldL
=
this
.
libtaos
.
taos_fetch_lengths
(
result
);
let
isMicro
=
(
this
.
libtaos
.
taos_result_precision
(
result
)
==
FieldTypes
.
C_TIMESTAMP_MICRO
);
let
isMicro
=
(
this
.
libtaos
.
taos_result_precision
(
result
)
==
FieldTypes
.
C_TIMESTAMP_MICRO
);
...
@@ -361,7 +362,6 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
...
@@ -361,7 +362,6 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
var
fieldlens
=
[];
var
fieldlens
=
[];
if
(
ref
.
isNull
(
fieldL
)
==
false
)
{
if
(
ref
.
isNull
(
fieldL
)
==
false
)
{
for
(
let
i
=
0
;
i
<
fields
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
fields
.
length
;
i
++
)
{
let
plen
=
ref
.
reinterpret
(
fieldL
,
4
,
i
*
4
);
let
plen
=
ref
.
reinterpret
(
fieldL
,
4
,
i
*
4
);
let
len
=
plen
.
readInt32LE
(
0
);
let
len
=
plen
.
readInt32LE
(
0
);
...
...
src/dnode/inc/dnodeCfg.h
浏览文件 @
a7c6e73f
...
@@ -25,6 +25,7 @@ int32_t dnodeInitCfg();
...
@@ -25,6 +25,7 @@ int32_t dnodeInitCfg();
void
dnodeCleanupCfg
();
void
dnodeCleanupCfg
();
void
dnodeUpdateCfg
(
SDnodeCfg
*
cfg
);
void
dnodeUpdateCfg
(
SDnodeCfg
*
cfg
);
int32_t
dnodeGetDnodeId
();
int32_t
dnodeGetDnodeId
();
void
dnodeGetClusterId
(
char
*
clusterId
);
void
dnodeGetCfg
(
int32_t
*
dnodeId
,
char
*
clusterId
);
void
dnodeGetCfg
(
int32_t
*
dnodeId
,
char
*
clusterId
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/dnode/src/dnodeCfg.c
浏览文件 @
a7c6e73f
...
@@ -51,6 +51,12 @@ int32_t dnodeGetDnodeId() {
...
@@ -51,6 +51,12 @@ int32_t dnodeGetDnodeId() {
return
dnodeId
;
return
dnodeId
;
}
}
void
dnodeGetClusterId
(
char
*
clusterId
)
{
pthread_mutex_lock
(
&
tsCfgMutex
);
tstrncpy
(
clusterId
,
tsCfg
.
clusterId
,
TSDB_CLUSTER_ID_LEN
);
pthread_mutex_unlock
(
&
tsCfgMutex
);
}
void
dnodeGetCfg
(
int32_t
*
dnodeId
,
char
*
clusterId
)
{
void
dnodeGetCfg
(
int32_t
*
dnodeId
,
char
*
clusterId
)
{
pthread_mutex_lock
(
&
tsCfgMutex
);
pthread_mutex_lock
(
&
tsCfgMutex
);
*
dnodeId
=
tsCfg
.
dnodeId
;
*
dnodeId
=
tsCfg
.
dnodeId
;
...
...
src/dnode/src/dnodeMRead.c
浏览文件 @
a7c6e73f
...
@@ -16,9 +16,7 @@
...
@@ -16,9 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tqueue.h"
#include "tqueue.h"
#include "twal.h"
#include "mnode.h"
#include "mnode.h"
#include "dnodeVMgmt.h"
#include "dnodeMInfos.h"
#include "dnodeMInfos.h"
#include "dnodeMRead.h"
#include "dnodeMRead.h"
...
...
src/dnode/src/dnodeMWrite.c
浏览文件 @
a7c6e73f
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
#include "ttimer.h"
#include "ttimer.h"
#include "tqueue.h"
#include "tqueue.h"
#include "mnode.h"
#include "mnode.h"
#include "dnodeVMgmt.h"
#include "dnodeMInfos.h"
#include "dnodeMInfos.h"
#include "dnodeMWrite.h"
#include "dnodeMWrite.h"
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
a7c6e73f
...
@@ -113,6 +113,7 @@ static void dnodeCleanupTmr() {
...
@@ -113,6 +113,7 @@ static void dnodeCleanupTmr() {
int32_t
dnodeInitSystem
()
{
int32_t
dnodeInitSystem
()
{
dnodeSetRunStatus
(
TSDB_RUN_STATUS_INITIALIZE
);
dnodeSetRunStatus
(
TSDB_RUN_STATUS_INITIALIZE
);
tscEmbedded
=
1
;
tscEmbedded
=
1
;
taosIgnSIGPIPE
();
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
taosResolveCRC
();
taosResolveCRC
();
taosInitGlobalCfg
();
taosInitGlobalCfg
();
...
@@ -120,7 +121,6 @@ int32_t dnodeInitSystem() {
...
@@ -120,7 +121,6 @@ int32_t dnodeInitSystem() {
taosSetCoreDump
();
taosSetCoreDump
();
taosInitNotes
();
taosInitNotes
();
dnodeInitTmr
();
dnodeInitTmr
();
signal
(
SIGPIPE
,
SIG_IGN
);
if
(
dnodeCreateDir
(
tsLogDir
)
<
0
)
{
if
(
dnodeCreateDir
(
tsLogDir
)
<
0
)
{
printf
(
"failed to create dir: %s, reason: %s
\n
"
,
tsLogDir
,
strerror
(
errno
));
printf
(
"failed to create dir: %s, reason: %s
\n
"
,
tsLogDir
,
strerror
(
errno
));
...
...
src/dnode/src/dnodeTelemetry.c
浏览文件 @
a7c6e73f
...
@@ -195,7 +195,7 @@ static void addRuntimeInfo(SBufferWriter* bw) {
...
@@ -195,7 +195,7 @@ static void addRuntimeInfo(SBufferWriter* bw) {
static
void
sendTelemetryReport
()
{
static
void
sendTelemetryReport
()
{
char
buf
[
128
];
char
buf
[
128
];
uint32_t
ip
=
taosGetIpFromFqdn
(
TELEMETRY_SERVER
);
uint32_t
ip
=
taosGetIp
v4
FromFqdn
(
TELEMETRY_SERVER
);
if
(
ip
==
0xffffffff
)
{
if
(
ip
==
0xffffffff
)
{
dTrace
(
"failed to get IP address of "
TELEMETRY_SERVER
", reason:%s"
,
strerror
(
errno
));
dTrace
(
"failed to get IP address of "
TELEMETRY_SERVER
", reason:%s"
,
strerror
(
errno
));
return
;
return
;
...
...
src/dnode/src/dnodeVMgmt.c
浏览文件 @
a7c6e73f
...
@@ -129,7 +129,8 @@ static void *dnodeProcessMgmtQueue(void *wparam) {
...
@@ -129,7 +129,8 @@ static void *dnodeProcessMgmtQueue(void *wparam) {
static
SCreateVnodeMsg
*
dnodeParseVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
static
SCreateVnodeMsg
*
dnodeParseVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
SCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
SCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
cfgVersion
=
htonl
(
pCreate
->
cfg
.
cfgVersion
);
pCreate
->
cfg
.
dbCfgVersion
=
htonl
(
pCreate
->
cfg
.
dbCfgVersion
);
pCreate
->
cfg
.
vgCfgVersion
=
htonl
(
pCreate
->
cfg
.
vgCfgVersion
);
pCreate
->
cfg
.
maxTables
=
htonl
(
pCreate
->
cfg
.
maxTables
);
pCreate
->
cfg
.
maxTables
=
htonl
(
pCreate
->
cfg
.
maxTables
);
pCreate
->
cfg
.
cacheBlockSize
=
htonl
(
pCreate
->
cfg
.
cacheBlockSize
);
pCreate
->
cfg
.
cacheBlockSize
=
htonl
(
pCreate
->
cfg
.
cacheBlockSize
);
pCreate
->
cfg
.
totalBlocks
=
htonl
(
pCreate
->
cfg
.
totalBlocks
);
pCreate
->
cfg
.
totalBlocks
=
htonl
(
pCreate
->
cfg
.
totalBlocks
);
...
...
src/dnode/src/dnodeVRead.c
浏览文件 @
a7c6e73f
...
@@ -54,6 +54,7 @@ void dnodeCleanupVRead() {
...
@@ -54,6 +54,7 @@ void dnodeCleanupVRead() {
void
dnodeDispatchToVReadQueue
(
SRpcMsg
*
pMsg
)
{
void
dnodeDispatchToVReadQueue
(
SRpcMsg
*
pMsg
)
{
int32_t
queuedMsgNum
=
0
;
int32_t
queuedMsgNum
=
0
;
int32_t
leftLen
=
pMsg
->
contLen
;
int32_t
leftLen
=
pMsg
->
contLen
;
int32_t
code
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
char
*
pCont
=
pMsg
->
pCont
;
char
*
pCont
=
pMsg
->
pCont
;
while
(
leftLen
>
0
)
{
while
(
leftLen
>
0
)
{
...
@@ -64,7 +65,7 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
...
@@ -64,7 +65,7 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
assert
(
pHead
->
contLen
>
0
);
assert
(
pHead
->
contLen
>
0
);
void
*
pVnode
=
vnodeAcquire
(
pHead
->
vgId
);
void
*
pVnode
=
vnodeAcquire
(
pHead
->
vgId
);
if
(
pVnode
!=
NULL
)
{
if
(
pVnode
!=
NULL
)
{
int32_t
code
=
vnodeWriteToRQueue
(
pVnode
,
pCont
,
pHead
->
contLen
,
TAOS_QTYPE_RPC
,
pMsg
);
code
=
vnodeWriteToRQueue
(
pVnode
,
pCont
,
pHead
->
contLen
,
TAOS_QTYPE_RPC
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
queuedMsgNum
++
;
if
(
code
==
TSDB_CODE_SUCCESS
)
queuedMsgNum
++
;
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
}
}
...
@@ -74,7 +75,7 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
...
@@ -74,7 +75,7 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
}
}
if
(
queuedMsgNum
==
0
)
{
if
(
queuedMsgNum
==
0
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
TSDB_CODE_VND_INVALID_VGROUP_ID
};
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
code
};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
...
...
src/dnode/src/dnodeVWrite.c
浏览文件 @
a7c6e73f
...
@@ -188,6 +188,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
...
@@ -188,6 +188,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
int32_t
numOfMsgs
;
int32_t
numOfMsgs
;
int32_t
qtype
;
int32_t
qtype
;
taosBlockSIGPIPE
();
dDebug
(
"dnode vwrite worker:%d is running"
,
pWorker
->
workerId
);
dDebug
(
"dnode vwrite worker:%d is running"
,
pWorker
->
workerId
);
while
(
1
)
{
while
(
1
)
{
...
...
src/dnode/src/dnodeVnodes.c
浏览文件 @
a7c6e73f
...
@@ -245,12 +245,11 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
...
@@ -245,12 +245,11 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
pStatus
->
lastReboot
=
htonl
(
tsRebootTime
);
pStatus
->
lastReboot
=
htonl
(
tsRebootTime
);
pStatus
->
numOfCores
=
htons
((
uint16_t
)
tsNumOfCores
);
pStatus
->
numOfCores
=
htons
((
uint16_t
)
tsNumOfCores
);
pStatus
->
diskAvailable
=
tsAvailDataDirGB
;
pStatus
->
diskAvailable
=
tsAvailDataDirGB
;
pStatus
->
alternativeRole
=
(
uint8_t
)
tsAlternativeRole
;
pStatus
->
alternativeRole
=
tsAlternativeRole
;
tstrncpy
(
pStatus
->
dnodeEp
,
tsLocalEp
,
TSDB_EP_LEN
);
tstrncpy
(
pStatus
->
dnodeEp
,
tsLocalEp
,
TSDB_EP_LEN
);
// fill cluster cfg parameters
// fill cluster cfg parameters
pStatus
->
clusterCfg
.
numOfMnodes
=
htonl
(
tsNumOfMnodes
);
pStatus
->
clusterCfg
.
numOfMnodes
=
htonl
(
tsNumOfMnodes
);
pStatus
->
clusterCfg
.
enableBalance
=
htonl
(
tsEnableBalance
);
pStatus
->
clusterCfg
.
mnodeEqualVnodeNum
=
htonl
(
tsMnodeEqualVnodeNum
);
pStatus
->
clusterCfg
.
mnodeEqualVnodeNum
=
htonl
(
tsMnodeEqualVnodeNum
);
pStatus
->
clusterCfg
.
offlineThreshold
=
htonl
(
tsOfflineThreshold
);
pStatus
->
clusterCfg
.
offlineThreshold
=
htonl
(
tsOfflineThreshold
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
tsStatusInterval
);
pStatus
->
clusterCfg
.
statusInterval
=
htonl
(
tsStatusInterval
);
...
@@ -264,6 +263,11 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
...
@@ -264,6 +263,11 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
tstrncpy
(
pStatus
->
clusterCfg
.
locale
,
tsLocale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
locale
,
tsLocale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
charset
,
tsCharset
,
TSDB_LOCALE_LEN
);
tstrncpy
(
pStatus
->
clusterCfg
.
charset
,
tsCharset
,
TSDB_LOCALE_LEN
);
pStatus
->
clusterCfg
.
enableBalance
=
tsEnableBalance
;
pStatus
->
clusterCfg
.
flowCtrl
=
tsEnableFlowCtrl
;
pStatus
->
clusterCfg
.
slaveQuery
=
tsEnableSlaveQuery
;
pStatus
->
clusterCfg
.
adjustMaster
=
tsEnableAdjustMaster
;
vnodeBuildStatusMsg
(
pStatus
);
vnodeBuildStatusMsg
(
pStatus
);
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
openVnodes
*
sizeof
(
SVnodeLoad
);
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
openVnodes
*
sizeof
(
SVnodeLoad
);
pStatus
->
openVnodes
=
htons
(
pStatus
->
openVnodes
);
pStatus
->
openVnodes
=
htons
(
pStatus
->
openVnodes
);
...
...
src/inc/dnode.h
浏览文件 @
a7c6e73f
...
@@ -36,6 +36,8 @@ bool dnodeIsMasterEp(char *ep);
...
@@ -36,6 +36,8 @@ bool dnodeIsMasterEp(char *ep);
void
dnodeGetEpSetForPeer
(
SRpcEpSet
*
epSet
);
void
dnodeGetEpSetForPeer
(
SRpcEpSet
*
epSet
);
void
dnodeGetEpSetForShell
(
SRpcEpSet
*
epSet
);
void
dnodeGetEpSetForShell
(
SRpcEpSet
*
epSet
);
int32_t
dnodeGetDnodeId
();
int32_t
dnodeGetDnodeId
();
void
dnodeGetClusterId
(
char
*
clusterId
);
void
dnodeUpdateEp
(
int32_t
dnodeId
,
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
void
dnodeUpdateEp
(
int32_t
dnodeId
,
char
*
ep
,
char
*
fqdn
,
uint16_t
*
port
);
bool
dnodeCheckEpChanged
(
int32_t
dnodeId
,
char
*
epstr
);
bool
dnodeCheckEpChanged
(
int32_t
dnodeId
,
char
*
epstr
);
bool
dnodeStartMnode
(
SMInfos
*
pMinfos
);
bool
dnodeStartMnode
(
SMInfos
*
pMinfos
);
...
...
src/inc/taosdef.h
浏览文件 @
a7c6e73f
...
@@ -369,6 +369,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
...
@@ -369,6 +369,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TSDB_MAX_DB_UPDATE 1
#define TSDB_MAX_DB_UPDATE 1
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
#define TSDB_MAX_DB_CACHE_LAST_ROW 1
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
...
...
src/inc/taosmsg.h
浏览文件 @
a7c6e73f
...
@@ -324,6 +324,7 @@ typedef struct {
...
@@ -324,6 +324,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
acctId
[
TSDB_ACCT_LEN
];
char
acctId
[
TSDB_ACCT_LEN
];
char
serverVersion
[
TSDB_VERSION_LEN
];
char
serverVersion
[
TSDB_VERSION_LEN
];
char
clusterId
[
TSDB_CLUSTER_ID_LEN
];
int8_t
writeAuth
;
int8_t
writeAuth
;
int8_t
superAuth
;
int8_t
superAuth
;
int8_t
reserved1
;
int8_t
reserved1
;
...
@@ -518,14 +519,15 @@ typedef struct SRetrieveTableRsp {
...
@@ -518,14 +519,15 @@ typedef struct SRetrieveTableRsp {
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
int64_t
totalStorage
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
int64_t
pointsWritten
;
uint8_t
status
;
uint8_t
status
;
uint8_t
role
;
uint8_t
role
;
uint8_t
replica
;
uint8_t
replica
;
uint8_t
reserved
[
5
];
uint8_t
reserved
;
int32_t
vgCfgVersion
;
}
SVnodeLoad
;
}
SVnodeLoad
;
typedef
struct
{
typedef
struct
{
...
@@ -548,7 +550,8 @@ typedef struct {
...
@@ -548,7 +550,8 @@ typedef struct {
int8_t
quorum
;
int8_t
quorum
;
int8_t
ignoreExist
;
int8_t
ignoreExist
;
int8_t
update
;
int8_t
update
;
int8_t
reserve
[
9
];
int8_t
cacheLastRow
;
int8_t
reserve
[
8
];
}
SCreateDbMsg
,
SAlterDbMsg
;
}
SCreateDbMsg
,
SAlterDbMsg
;
typedef
struct
{
typedef
struct
{
...
@@ -603,7 +606,6 @@ typedef struct {
...
@@ -603,7 +606,6 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
numOfMnodes
;
// tsNumOfMnodes
int32_t
numOfMnodes
;
// tsNumOfMnodes
int32_t
enableBalance
;
// tsEnableBalance
int32_t
mnodeEqualVnodeNum
;
// tsMnodeEqualVnodeNum
int32_t
mnodeEqualVnodeNum
;
// tsMnodeEqualVnodeNum
int32_t
offlineThreshold
;
// tsOfflineThreshold
int32_t
offlineThreshold
;
// tsOfflineThreshold
int32_t
statusInterval
;
// tsStatusInterval
int32_t
statusInterval
;
// tsStatusInterval
...
@@ -614,6 +616,11 @@ typedef struct {
...
@@ -614,6 +616,11 @@ typedef struct {
int64_t
checkTime
;
// 1970-01-01 00:00:00.000
int64_t
checkTime
;
// 1970-01-01 00:00:00.000
char
locale
[
TSDB_LOCALE_LEN
];
// tsLocale
char
locale
[
TSDB_LOCALE_LEN
];
// tsLocale
char
charset
[
TSDB_LOCALE_LEN
];
// tsCharset
char
charset
[
TSDB_LOCALE_LEN
];
// tsCharset
int8_t
enableBalance
;
// tsEnableBalance
int8_t
flowCtrl
;
int8_t
slaveQuery
;
int8_t
adjustMaster
;
int8_t
reserved
[
4
];
}
SClusterCfg
;
}
SClusterCfg
;
typedef
struct
{
typedef
struct
{
...
@@ -641,7 +648,7 @@ typedef struct {
...
@@ -641,7 +648,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
uint32_t
vgId
;
uint32_t
vgId
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
int32_t
maxTables
;
int32_t
maxTables
;
int32_t
cacheBlockSize
;
int32_t
cacheBlockSize
;
int32_t
totalBlocks
;
int32_t
totalBlocks
;
...
@@ -660,7 +667,9 @@ typedef struct {
...
@@ -660,7 +667,9 @@ typedef struct {
int8_t
wals
;
int8_t
wals
;
int8_t
quorum
;
int8_t
quorum
;
int8_t
update
;
int8_t
update
;
int8_t
reserved
[
15
];
int8_t
cacheLastRow
;
int32_t
vgCfgVersion
;
int8_t
reserved
[
10
];
}
SVnodeCfg
;
}
SVnodeCfg
;
typedef
struct
{
typedef
struct
{
...
...
src/inc/tsdb.h
浏览文件 @
a7c6e73f
...
@@ -66,6 +66,7 @@ typedef struct {
...
@@ -66,6 +66,7 @@ typedef struct {
int8_t
precision
;
int8_t
precision
;
int8_t
compression
;
int8_t
compression
;
int8_t
update
;
int8_t
update
;
int8_t
cacheLastRow
;
}
STsdbCfg
;
}
STsdbCfg
;
// --------- TSDB REPOSITORY USAGE STATISTICS
// --------- TSDB REPOSITORY USAGE STATISTICS
...
@@ -119,7 +120,7 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg);
...
@@ -119,7 +120,7 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg);
int
tsdbCreateTable
(
TSDB_REPO_T
*
repo
,
STableCfg
*
pCfg
);
int
tsdbCreateTable
(
TSDB_REPO_T
*
repo
,
STableCfg
*
pCfg
);
int
tsdbDropTable
(
TSDB_REPO_T
*
pRepo
,
STableId
tableId
);
int
tsdbDropTable
(
TSDB_REPO_T
*
pRepo
,
STableId
tableId
);
int
tsdbUpdateTableTagValue
(
TSDB_REPO_T
*
repo
,
SUpdateTableTagValMsg
*
pMsg
);
int
tsdbUpdateTableTagValue
(
TSDB_REPO_T
*
repo
,
SUpdateTableTagValMsg
*
pMsg
);
TSKEY
tsdbGetTableLastKey
(
TSDB_REPO_T
*
repo
,
uint64_t
uid
);
//
TSKEY tsdbGetTableLastKey(TSDB_REPO_T *repo, uint64_t uid);
uint32_t
tsdbGetFileInfo
(
TSDB_REPO_T
*
repo
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
);
uint32_t
tsdbGetFileInfo
(
TSDB_REPO_T
*
repo
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
);
...
...
src/inc/ttokendef.h
浏览文件 @
a7c6e73f
...
@@ -114,114 +114,115 @@
...
@@ -114,114 +114,115 @@
#define TK_COMP 96
#define TK_COMP 96
#define TK_PRECISION 97
#define TK_PRECISION 97
#define TK_UPDATE 98
#define TK_UPDATE 98
#define TK_LP 99
#define TK_CACHELAST 99
#define TK_RP 100
#define TK_LP 100
#define TK_TAGS 101
#define TK_RP 101
#define TK_USING 102
#define TK_TAGS 102
#define TK_AS 103
#define TK_USING 103
#define TK_COMMA 104
#define TK_AS 104
#define TK_NULL 105
#define TK_COMMA 105
#define TK_SELECT 106
#define TK_NULL 106
#define TK_UNION 107
#define TK_SELECT 107
#define TK_ALL 108
#define TK_UNION 108
#define TK_FROM 109
#define TK_ALL 109
#define TK_VARIABLE 110
#define TK_FROM 110
#define TK_INTERVAL 111
#define TK_VARIABLE 111
#define TK_FILL 112
#define TK_INTERVAL 112
#define TK_SLIDING 113
#define TK_FILL 113
#define TK_ORDER 114
#define TK_SLIDING 114
#define TK_BY 115
#define TK_ORDER 115
#define TK_ASC 116
#define TK_BY 116
#define TK_DESC 117
#define TK_ASC 117
#define TK_GROUP 118
#define TK_DESC 118
#define TK_HAVING 119
#define TK_GROUP 119
#define TK_LIMIT 120
#define TK_HAVING 120
#define TK_OFFSET 121
#define TK_LIMIT 121
#define TK_SLIMIT 122
#define TK_OFFSET 122
#define TK_SOFFSET 123
#define TK_SLIMIT 123
#define TK_WHERE 124
#define TK_SOFFSET 124
#define TK_NOW 125
#define TK_WHERE 125
#define TK_RESET 126
#define TK_NOW 126
#define TK_QUERY 127
#define TK_RESET 127
#define TK_ADD 128
#define TK_QUERY 128
#define TK_COLUMN 129
#define TK_ADD 129
#define TK_TAG 130
#define TK_COLUMN 130
#define TK_CHANGE 131
#define TK_TAG 131
#define TK_SET 132
#define TK_CHANGE 132
#define TK_KILL 133
#define TK_SET 133
#define TK_CONNECTION 134
#define TK_KILL 134
#define TK_STREAM 135
#define TK_CONNECTION 135
#define TK_COLON 136
#define TK_STREAM 136
#define TK_ABORT 137
#define TK_COLON 137
#define TK_AFTER 138
#define TK_ABORT 138
#define TK_ATTACH 139
#define TK_AFTER 139
#define TK_BEFORE 140
#define TK_ATTACH 140
#define TK_BEGIN 141
#define TK_BEFORE 141
#define TK_CASCADE 142
#define TK_BEGIN 142
#define TK_CLUSTER 143
#define TK_CASCADE 143
#define TK_CONFLICT 144
#define TK_CLUSTER 144
#define TK_COPY 145
#define TK_CONFLICT 145
#define TK_DEFERRED 146
#define TK_COPY 146
#define TK_DELIMITERS 147
#define TK_DEFERRED 147
#define TK_DETACH 148
#define TK_DELIMITERS 148
#define TK_EACH 149
#define TK_DETACH 149
#define TK_END 150
#define TK_EACH 150
#define TK_EXPLAIN 151
#define TK_END 151
#define TK_FAIL 152
#define TK_EXPLAIN 152
#define TK_FOR 153
#define TK_FAIL 153
#define TK_IGNORE 154
#define TK_FOR 154
#define TK_IMMEDIATE 155
#define TK_IGNORE 155
#define TK_INITIALLY 156
#define TK_IMMEDIATE 156
#define TK_INSTEAD 157
#define TK_INITIALLY 157
#define TK_MATCH 158
#define TK_INSTEAD 158
#define TK_KEY 159
#define TK_MATCH 159
#define TK_OF 160
#define TK_KEY 160
#define TK_RAISE 161
#define TK_OF 161
#define TK_REPLACE 162
#define TK_RAISE 162
#define TK_RESTRICT 163
#define TK_REPLACE 163
#define TK_ROW 164
#define TK_RESTRICT 164
#define TK_STATEMENT 165
#define TK_ROW 165
#define TK_TRIGGER 166
#define TK_STATEMENT 166
#define TK_VIEW 167
#define TK_TRIGGER 167
#define TK_COUNT 168
#define TK_VIEW 168
#define TK_SUM 169
#define TK_COUNT 169
#define TK_AVG 170
#define TK_SUM 170
#define TK_MIN 171
#define TK_AVG 171
#define TK_MAX 172
#define TK_MIN 172
#define TK_FIRST 173
#define TK_MAX 173
#define TK_LAST 174
#define TK_FIRST 174
#define TK_TOP 175
#define TK_LAST 175
#define TK_BOTTOM 176
#define TK_TOP 176
#define TK_STDDEV 177
#define TK_BOTTOM 177
#define TK_PERCENTILE 178
#define TK_STDDEV 178
#define TK_APERCENTILE 179
#define TK_PERCENTILE 179
#define TK_LEASTSQUARES 180
#define TK_APERCENTILE 180
#define TK_HISTOGRAM 181
#define TK_LEASTSQUARES 181
#define TK_DIFF 182
#define TK_HISTOGRAM 182
#define TK_SPREAD 183
#define TK_DIFF 183
#define TK_TWA 184
#define TK_SPREAD 184
#define TK_INTERP 185
#define TK_TWA 185
#define TK_LAST_ROW 186
#define TK_INTERP 186
#define TK_RATE 187
#define TK_LAST_ROW 187
#define TK_IRATE 188
#define TK_RATE 188
#define TK_SUM_RATE 189
#define TK_IRATE 189
#define TK_SUM_IRATE 190
#define TK_SUM_RATE 190
#define TK_AVG_RATE 191
#define TK_SUM_IRATE 191
#define TK_AVG_IRATE 192
#define TK_AVG_RATE 192
#define TK_TBID 193
#define TK_AVG_IRATE 193
#define TK_SEMI 194
#define TK_TBID 194
#define TK_NONE 195
#define TK_SEMI 195
#define TK_PREV 196
#define TK_NONE 196
#define TK_LINEAR 197
#define TK_PREV 197
#define TK_IMPORT 198
#define TK_LINEAR 198
#define TK_METRIC 199
#define TK_IMPORT 199
#define TK_TBNAME 200
#define TK_METRIC 200
#define TK_JOIN 201
#define TK_TBNAME 201
#define TK_METRICS 202
#define TK_JOIN 202
#define TK_STABLE 203
#define TK_METRICS 203
#define TK_INSERT 204
#define TK_STABLE 204
#define TK_INTO 205
#define TK_INSERT 205
#define TK_VALUES 206
#define TK_INTO 206
#define TK_VALUES 207
#define TK_SPACE 300
#define TK_SPACE 300
...
...
src/inc/ttype.h
浏览文件 @
a7c6e73f
...
@@ -28,7 +28,7 @@ extern "C" {
...
@@ -28,7 +28,7 @@ extern "C" {
default: \
default: \
(_v) = (_finalType)GET_INT32_VAL(_data); \
(_v) = (_finalType)GET_INT32_VAL(_data); \
break; \
break; \
}
;
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
a7c6e73f
...
@@ -302,14 +302,12 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
...
@@ -302,14 +302,12 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
st
=
taosGetTimestampUs
();
st
=
taosGetTimestampUs
();
TAOS_RES
*
tmpSql
=
NULL
;
TAOS_RES
*
pSql
=
taos_query_h
(
con
,
command
,
&
result
);
TAOS_RES
*
pSql
=
taos_query_h
(
con
,
command
,
&
tmpSql
);
if
(
taos_errno
(
pSql
))
{
if
(
taos_errno
(
pSql
))
{
taos_error
(
pSql
,
st
);
taos_error
(
pSql
,
st
);
return
;
return
;
}
}
atomic_store_64
(
&
result
,
((
SSqlObj
*
)
tmpSql
)
->
self
);
int64_t
oresult
=
atomic_load_64
(
&
result
);
int64_t
oresult
=
atomic_load_64
(
&
result
);
if
(
regex_match
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
if
(
regex_match
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
a7c6e73f
...
@@ -205,10 +205,10 @@ typedef struct DemoArguments {
...
@@ -205,10 +205,10 @@ typedef struct DemoArguments {
arguments
->
tb_prefix
=
arg
;
arguments
->
tb_prefix
=
arg
;
break
;
break
;
case
'M'
:
case
'M'
:
arguments
->
use_metric
=
fals
e
;
arguments
->
use_metric
=
tru
e
;
break
;
break
;
case
'x'
:
case
'x'
:
arguments
->
insert_only
=
fals
e
;
arguments
->
insert_only
=
tru
e
;
break
;
break
;
case
'c'
:
case
'c'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
...
@@ -406,9 +406,9 @@ typedef struct DemoArguments {
...
@@ -406,9 +406,9 @@ typedef struct DemoArguments {
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
arguments
->
tb_prefix
=
argv
[
++
i
];
arguments
->
tb_prefix
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-M"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-M"
)
==
0
)
{
arguments
->
use_metric
=
fals
e
;
arguments
->
use_metric
=
tru
e
;
}
else
if
(
strcmp
(
argv
[
i
],
"-x"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-x"
)
==
0
)
{
arguments
->
insert_only
=
fals
e
;
arguments
->
insert_only
=
tru
e
;
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
...
@@ -476,6 +476,14 @@ typedef struct {
...
@@ -476,6 +476,14 @@ typedef struct {
int
notFinished
;
int
notFinished
;
tsem_t
lock_sem
;
tsem_t
lock_sem
;
int
counter
;
int
counter
;
// insert delay statitics
int64_t
cntDelay
;
int64_t
totalDelay
;
int64_t
avgDelay
;
int64_t
maxDelay
;
int64_t
minDelay
;
}
info
;
}
info
;
typedef
struct
{
typedef
struct
{
...
@@ -575,7 +583,7 @@ int main(int argc, char *argv[]) {
...
@@ -575,7 +583,7 @@ int main(int argc, char *argv[]) {
arguments
.
num_of_DPT
=
100000
;
arguments
.
num_of_DPT
=
100000
;
arguments
.
num_of_RPR
=
1000
;
arguments
.
num_of_RPR
=
1000
;
arguments
.
use_metric
=
true
;
arguments
.
use_metric
=
true
;
arguments
.
insert_only
=
tru
e
;
arguments
.
insert_only
=
fals
e
;
// end change
// end change
parse_args
(
argc
,
argv
,
&
arguments
);
parse_args
(
argc
,
argv
,
&
arguments
);
...
@@ -740,6 +748,9 @@ int main(int argc, char *argv[]) {
...
@@ -740,6 +748,9 @@ int main(int argc, char *argv[]) {
pthread_t
*
pids
=
malloc
(
threads
*
sizeof
(
pthread_t
));
pthread_t
*
pids
=
malloc
(
threads
*
sizeof
(
pthread_t
));
info
*
infos
=
malloc
(
threads
*
sizeof
(
info
));
info
*
infos
=
malloc
(
threads
*
sizeof
(
info
));
memset
(
pids
,
0
,
threads
*
sizeof
(
pthread_t
));
memset
(
infos
,
0
,
threads
*
sizeof
(
info
));
int
a
=
ntables
/
threads
;
int
a
=
ntables
/
threads
;
if
(
a
<
1
)
{
if
(
a
<
1
)
{
threads
=
ntables
;
threads
=
ntables
;
...
@@ -768,6 +779,7 @@ int main(int argc, char *argv[]) {
...
@@ -768,6 +779,7 @@ int main(int argc, char *argv[]) {
t_info
->
end_table_id
=
i
<
b
?
last
+
a
:
last
+
a
-
1
;
t_info
->
end_table_id
=
i
<
b
?
last
+
a
:
last
+
a
-
1
;
last
=
t_info
->
end_table_id
+
1
;
last
=
t_info
->
end_table_id
+
1
;
t_info
->
counter
=
0
;
t_info
->
counter
=
0
;
t_info
->
minDelay
=
INT16_MAX
;
tsem_init
(
&
(
t_info
->
mutex_sem
),
0
,
1
);
tsem_init
(
&
(
t_info
->
mutex_sem
),
0
,
1
);
t_info
->
notFinished
=
t_info
->
end_table_id
-
t_info
->
start_table_id
+
1
;
t_info
->
notFinished
=
t_info
->
end_table_id
-
t_info
->
start_table_id
+
1
;
...
@@ -799,12 +811,29 @@ int main(int argc, char *argv[]) {
...
@@ -799,12 +811,29 @@ int main(int argc, char *argv[]) {
t
,
(
int64_t
)
ntables
*
nrecords_per_table
,
nrecords_per_request
,
t
,
(
int64_t
)
ntables
*
nrecords_per_table
,
nrecords_per_request
,
(
int64_t
)
ntables
*
nrecords_per_table
/
t
);
(
int64_t
)
ntables
*
nrecords_per_table
/
t
);
int64_t
totalDelay
=
0
;
int64_t
maxDelay
=
0
;
int64_t
minDelay
=
INT16_MAX
;
int64_t
cntDelay
=
0
;
double
avgDelay
=
0
;
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
threads
;
i
++
)
{
info
*
t_info
=
infos
+
i
;
info
*
t_info
=
infos
+
i
;
taos_close
(
t_info
->
taos
);
taos_close
(
t_info
->
taos
);
tsem_destroy
(
&
(
t_info
->
mutex_sem
));
tsem_destroy
(
&
(
t_info
->
mutex_sem
));
tsem_destroy
(
&
(
t_info
->
lock_sem
));
tsem_destroy
(
&
(
t_info
->
lock_sem
));
totalDelay
+=
t_info
->
totalDelay
;
cntDelay
+=
t_info
->
cntDelay
;
if
(
t_info
->
maxDelay
>
maxDelay
)
maxDelay
=
t_info
->
maxDelay
;
if
(
t_info
->
minDelay
<
minDelay
)
minDelay
=
t_info
->
minDelay
;
}
}
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
fprintf
(
fp
,
"insert delay, avg:%10.6fms, max: %10.6fms, min: %10.6fms
\n\n
"
,
avgDelay
/
1000
.
0
,
(
double
)
maxDelay
/
1000
.
0
,
(
double
)
minDelay
/
1000
.
0
);
printf
(
"insert delay, avg: %10.6fms, max: %10.6fms, min: %10.6fms
\n\n
"
,
avgDelay
/
1000
.
0
,
(
double
)
maxDelay
/
1000
.
0
,
(
double
)
minDelay
/
1000
.
0
);
free
(
pids
);
free
(
pids
);
free
(
infos
);
free
(
infos
);
...
@@ -859,7 +888,7 @@ int main(int argc, char *argv[]) {
...
@@ -859,7 +888,7 @@ int main(int argc, char *argv[]) {
}
}
if
(
!
insert_only
)
{
if
(
false
==
insert_only
)
{
// query data
// query data
pthread_t
read_id
;
pthread_t
read_id
;
info
*
rInfo
=
malloc
(
sizeof
(
info
));
info
*
rInfo
=
malloc
(
sizeof
(
info
));
...
@@ -998,7 +1027,7 @@ void * createTable(void *sarg)
...
@@ -998,7 +1027,7 @@ void * createTable(void *sarg)
/* Create all the tables; */
/* Create all the tables; */
printf
(
"Creating table from %d to %d
\n
"
,
winfo
->
start_table_id
,
winfo
->
end_table_id
);
printf
(
"Creating table from %d to %d
\n
"
,
winfo
->
start_table_id
,
winfo
->
end_table_id
);
for
(
int
i
=
winfo
->
start_table_id
;
i
<=
winfo
->
end_table_id
;
i
++
)
{
for
(
int
i
=
winfo
->
start_table_id
;
i
<=
winfo
->
end_table_id
;
i
++
)
{
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.%s%d (ts timestamp%s;"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
i
,
winfo
->
cols
);
snprintf
(
command
,
BUFFER_SIZE
,
"create table if not exists %s.%s%d (ts timestamp%s
)
;"
,
winfo
->
db_name
,
winfo
->
tb_prefix
,
i
,
winfo
->
cols
);
queryDB
(
winfo
->
taos
,
command
);
queryDB
(
winfo
->
taos
,
command
);
}
}
}
else
{
}
else
{
...
@@ -1204,6 +1233,41 @@ void *readMetric(void *sarg) {
...
@@ -1204,6 +1233,41 @@ void *readMetric(void *sarg) {
return
NULL
;
return
NULL
;
}
}
static
int
queryDbExec
(
TAOS
*
taos
,
char
*
command
,
int
type
)
{
int
i
;
TAOS_RES
*
res
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
NULL
!=
res
)
{
taos_free_result
(
res
);
res
=
NULL
;
}
res
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
res
);
if
(
0
==
code
)
{
break
;
}
}
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
res
));
taos_free_result
(
res
);
//taos_close(taos);
return
-
1
;
}
if
(
1
==
type
)
{
int
affectedRows
=
taos_affected_rows
(
res
);
taos_free_result
(
res
);
return
affectedRows
;
}
taos_free_result
(
res
);
return
0
;
}
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
;
int
i
;
TAOS_RES
*
pSql
=
NULL
;
TAOS_RES
*
pSql
=
NULL
;
...
@@ -1273,7 +1337,21 @@ void *syncWrite(void *sarg) {
...
@@ -1273,7 +1337,21 @@ void *syncWrite(void *sarg) {
}
}
/* puts(buffer); */
/* puts(buffer); */
queryDB
(
winfo
->
taos
,
buffer
);
int64_t
startTs
;
int64_t
endTs
;
startTs
=
taosGetTimestampUs
();
//queryDB(winfo->taos, buffer);
int
affectedRows
=
queryDbExec
(
winfo
->
taos
,
buffer
,
1
);
if
(
0
<=
affectedRows
){
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
if
(
delay
>
winfo
->
maxDelay
)
winfo
->
maxDelay
=
delay
;
if
(
delay
<
winfo
->
minDelay
)
winfo
->
minDelay
=
delay
;
winfo
->
cntDelay
++
;
winfo
->
totalDelay
+=
delay
;
//winfo->avgDelay = (double)winfo->totalDelay / winfo->cntDelay;
}
if
(
tID
==
winfo
->
end_table_id
)
{
if
(
tID
==
winfo
->
end_table_id
)
{
i
=
inserted
;
i
=
inserted
;
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
a7c6e73f
...
@@ -332,6 +332,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -332,6 +332,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break
;
break
;
case
'N'
:
case
'N'
:
arguments
->
data_batch
=
atoi
(
arg
);
arguments
->
data_batch
=
atoi
(
arg
);
if
(
arguments
->
data_batch
>=
INT16_MAX
)
{
arguments
->
data_batch
=
INT16_MAX
-
1
;
}
break
;
break
;
case
'L'
:
case
'L'
:
{
{
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
a7c6e73f
...
@@ -144,7 +144,8 @@ typedef struct SVgObj {
...
@@ -144,7 +144,8 @@ typedef struct SVgObj {
int8_t
status
;
int8_t
status
;
int8_t
reserved0
[
4
];
int8_t
reserved0
[
4
];
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
int8_t
reserved1
[
12
];
int32_t
vgCfgVersion
;
int8_t
reserved1
[
8
];
int8_t
updateEnd
[
4
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
refCount
;
int32_t
numOfTables
;
int32_t
numOfTables
;
...
@@ -173,7 +174,8 @@ typedef struct {
...
@@ -173,7 +174,8 @@ typedef struct {
int8_t
replications
;
int8_t
replications
;
int8_t
quorum
;
int8_t
quorum
;
int8_t
update
;
int8_t
update
;
int8_t
reserved
[
11
];
int8_t
cacheLastRow
;
int8_t
reserved
[
10
];
}
SDbCfg
;
}
SDbCfg
;
typedef
struct
SDbObj
{
typedef
struct
SDbObj
{
...
@@ -181,7 +183,7 @@ typedef struct SDbObj {
...
@@ -181,7 +183,7 @@ typedef struct SDbObj {
int8_t
reserved0
[
4
];
int8_t
reserved0
[
4
];
char
acct
[
TSDB_USER_LEN
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
createdTime
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
SDbCfg
cfg
;
SDbCfg
cfg
;
int8_t
status
;
int8_t
status
;
int8_t
reserved1
[
11
];
int8_t
reserved1
[
11
];
...
...
src/mnode/inc/mnodeDnode.h
浏览文件 @
a7c6e73f
...
@@ -52,15 +52,18 @@ typedef enum EDnodeOfflineReason {
...
@@ -52,15 +52,18 @@ typedef enum EDnodeOfflineReason {
TAOS_DN_OFF_TIME_ZONE_NOT_MATCH
,
TAOS_DN_OFF_TIME_ZONE_NOT_MATCH
,
TAOS_DN_OFF_LOCALE_NOT_MATCH
,
TAOS_DN_OFF_LOCALE_NOT_MATCH
,
TAOS_DN_OFF_CHARSET_NOT_MATCH
,
TAOS_DN_OFF_CHARSET_NOT_MATCH
,
TAOS_DN_OFF_FLOW_CTRL_NOT_MATCH
,
TAOS_DN_OFF_SLAVE_QUERY_NOT_MATCH
,
TAOS_DN_OFF_ADJUST_MASTER_NOT_MATCH
,
TAOS_DN_OFF_OTHERS
TAOS_DN_OFF_OTHERS
}
EDnodeOfflineReason
;
}
EDnodeOfflineReason
;
extern
char
*
dnodeStatus
[];
extern
char
*
dnodeRoles
[];
int32_t
mnodeInitDnodes
();
int32_t
mnodeInitDnodes
();
void
mnodeCleanupDnodes
();
void
mnodeCleanupDnodes
();
char
*
mnodeGetDnodeStatusStr
(
int32_t
dnodeStatus
);
void
mgmtMonitorDnodeModule
();
int32_t
mnodeGetDnodesNum
();
int32_t
mnodeGetDnodesNum
();
int32_t
mnodeGetOnlinDnodesCpuCoreNum
();
int32_t
mnodeGetOnlinDnodesCpuCoreNum
();
int32_t
mnodeGetOnlineDnodesNum
();
int32_t
mnodeGetOnlineDnodesNum
();
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
a7c6e73f
...
@@ -322,6 +322,11 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
...
@@ -322,6 +322,11 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
}
if
(
pCfg
->
cacheLastRow
<
TSDB_MIN_DB_CACHE_LAST_ROW
||
pCfg
->
cacheLastRow
>
TSDB_MAX_DB_CACHE_LAST_ROW
)
{
mError
(
"invalid db option cacheLastRow:%d valid range: [%d, %d]"
,
pCfg
->
cacheLastRow
,
TSDB_MIN_DB_CACHE_LAST_ROW
,
TSDB_MAX_DB_CACHE_LAST_ROW
);
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -343,6 +348,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
...
@@ -343,6 +348,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
replications
<
0
)
pCfg
->
replications
=
tsReplications
;
if
(
pCfg
->
replications
<
0
)
pCfg
->
replications
=
tsReplications
;
if
(
pCfg
->
quorum
<
0
)
pCfg
->
quorum
=
tsQuorum
;
if
(
pCfg
->
quorum
<
0
)
pCfg
->
quorum
=
tsQuorum
;
if
(
pCfg
->
update
<
0
)
pCfg
->
update
=
tsUpdate
;
if
(
pCfg
->
update
<
0
)
pCfg
->
update
=
tsUpdate
;
if
(
pCfg
->
cacheLastRow
<
0
)
pCfg
->
cacheLastRow
=
tsCacheLastRow
;
}
}
static
int32_t
mnodeCreateDbCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeCreateDbCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
...
@@ -396,7 +402,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
...
@@ -396,7 +402,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
.
walLevel
=
pCreate
->
walLevel
,
.
walLevel
=
pCreate
->
walLevel
,
.
replications
=
pCreate
->
replications
,
.
replications
=
pCreate
->
replications
,
.
quorum
=
pCreate
->
quorum
,
.
quorum
=
pCreate
->
quorum
,
.
update
=
pCreate
->
update
.
update
=
pCreate
->
update
,
.
cacheLastRow
=
pCreate
->
cacheLastRow
};
};
mnodeSetDefaultDbCfg
(
&
pDb
->
cfg
);
mnodeSetDefaultDbCfg
(
&
pDb
->
cfg
);
...
@@ -605,6 +612,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
...
@@ -605,6 +612,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
strcpy
(
pSchema
[
cols
].
name
,
"comp"
);
strcpy
(
pSchema
[
cols
].
name
,
"comp"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
pShow
->
bytes
[
cols
]
=
1
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TINYINT
;
strcpy
(
pSchema
[
cols
].
name
,
"cachelast"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
#ifndef __CLOUD_VERSION__
#ifndef __CLOUD_VERSION__
}
}
#endif
#endif
...
@@ -750,6 +763,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
...
@@ -750,6 +763,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
compression
;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
compression
;
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
cacheLastRow
;
cols
++
;
#ifndef __CLOUD_VERSION__
#ifndef __CLOUD_VERSION__
}
}
#endif
#endif
...
@@ -864,6 +881,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
...
@@ -864,6 +881,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
int8_t
quorum
=
pAlter
->
quorum
;
int8_t
quorum
=
pAlter
->
quorum
;
int8_t
precision
=
pAlter
->
precision
;
int8_t
precision
=
pAlter
->
precision
;
int8_t
update
=
pAlter
->
update
;
int8_t
update
=
pAlter
->
update
;
int8_t
cacheLastRow
=
pAlter
->
cacheLastRow
;
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
...
@@ -976,6 +994,11 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
...
@@ -976,6 +994,11 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
#endif
#endif
}
}
if
(
cacheLastRow
>=
0
&&
cacheLastRow
!=
pDb
->
cfg
.
cacheLastRow
)
{
mDebug
(
"db:%s, cacheLastRow:%d change to %d"
,
pDb
->
name
,
pDb
->
cfg
.
cacheLastRow
,
cacheLastRow
);
newCfg
.
cacheLastRow
=
cacheLastRow
;
}
return
newCfg
;
return
newCfg
;
}
}
...
@@ -1015,7 +1038,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
...
@@ -1015,7 +1038,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
pDb
->
cfg
=
newCfg
;
pDb
->
cfg
=
newCfg
;
pDb
->
c
fgVersion
++
;
pDb
->
dbC
fgVersion
++
;
SSdbRow
row
=
{
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
a7c6e73f
...
@@ -63,7 +63,6 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -63,7 +63,6 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
static
int32_t
mnodeRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetDnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetDnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveDnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveDnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
char
*
mnodeGetDnodeAlternativeRoleStr
(
int32_t
alternativeRole
);
static
void
mnodeUpdateDnodeEps
();
static
void
mnodeUpdateDnodeEps
();
static
char
*
offlineReason
[]
=
{
static
char
*
offlineReason
[]
=
{
...
@@ -376,10 +375,6 @@ static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
...
@@ -376,10 +375,6 @@ static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
mError
(
"
\"
numOfMnodes
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
numOfMnodes
,
htonl
(
tsNumOfMnodes
));
mError
(
"
\"
numOfMnodes
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
numOfMnodes
,
htonl
(
tsNumOfMnodes
));
return
TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH
;
return
TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH
;
}
}
if
(
clusterCfg
->
enableBalance
!=
htonl
(
tsEnableBalance
))
{
mError
(
"
\"
balance
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
enableBalance
,
htonl
(
tsEnableBalance
));
return
TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH
;
}
if
(
clusterCfg
->
mnodeEqualVnodeNum
!=
htonl
(
tsMnodeEqualVnodeNum
))
{
if
(
clusterCfg
->
mnodeEqualVnodeNum
!=
htonl
(
tsMnodeEqualVnodeNum
))
{
mError
(
"
\"
mnodeEqualVnodeNum
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
mnodeEqualVnodeNum
,
mError
(
"
\"
mnodeEqualVnodeNum
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
mnodeEqualVnodeNum
,
htonl
(
tsMnodeEqualVnodeNum
));
htonl
(
tsMnodeEqualVnodeNum
));
...
@@ -429,6 +424,23 @@ static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
...
@@ -429,6 +424,23 @@ static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
return
TAOS_DN_OFF_CHARSET_NOT_MATCH
;
return
TAOS_DN_OFF_CHARSET_NOT_MATCH
;
}
}
if
(
clusterCfg
->
enableBalance
!=
tsEnableBalance
)
{
mError
(
"
\"
balance
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
enableBalance
,
tsEnableBalance
);
return
TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH
;
}
if
(
clusterCfg
->
flowCtrl
!=
tsEnableFlowCtrl
)
{
mError
(
"
\"
flowCtrl
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
flowCtrl
,
tsEnableFlowCtrl
);
return
TAOS_DN_OFF_FLOW_CTRL_NOT_MATCH
;
}
if
(
clusterCfg
->
slaveQuery
!=
tsEnableSlaveQuery
)
{
mError
(
"
\"
slaveQuery
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
slaveQuery
,
tsEnableSlaveQuery
);
return
TAOS_DN_OFF_SLAVE_QUERY_NOT_MATCH
;
}
if
(
clusterCfg
->
adjustMaster
!=
tsEnableAdjustMaster
)
{
mError
(
"
\"
adjustMaster
\"
[%d - %d] cfg parameters inconsistent"
,
clusterCfg
->
adjustMaster
,
tsEnableAdjustMaster
);
return
TAOS_DN_OFF_ADJUST_MASTER_NOT_MATCH
;
}
return
0
;
return
0
;
}
}
...
@@ -557,7 +569,8 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
...
@@ -557,7 +569,8 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
for
(
int32_t
j
=
0
;
j
<
openVnodes
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
openVnodes
;
++
j
)
{
SVnodeLoad
*
pVload
=
&
pStatus
->
load
[
j
];
SVnodeLoad
*
pVload
=
&
pStatus
->
load
[
j
];
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
pVload
->
cfgVersion
=
htonl
(
pVload
->
cfgVersion
);
pVload
->
dbCfgVersion
=
htonl
(
pVload
->
dbCfgVersion
);
pVload
->
vgCfgVersion
=
htonl
(
pVload
->
vgCfgVersion
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pVload
->
vgId
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pVload
->
vgId
);
if
(
pVgroup
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
...
@@ -833,12 +846,12 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -833,12 +846,12 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
status
=
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
;
char
*
status
=
dnodeStatus
[
pDnode
->
status
]
;
STR_TO_VARSTR
(
pWrite
,
status
);
STR_TO_VARSTR
(
pWrite
,
status
);
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
role
=
mnodeGetDnodeAlternativeRoleStr
(
pDnode
->
alternativeRole
)
;
char
*
role
=
dnodeRoles
[
pDnode
->
alternativeRole
]
;
STR_TO_VARSTR
(
pWrite
,
role
);
STR_TO_VARSTR
(
pWrite
,
role
);
cols
++
;
cols
++
;
...
@@ -1031,6 +1044,11 @@ static int32_t mnodeRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, v
...
@@ -1031,6 +1044,11 @@ static int32_t mnodeRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, v
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
switch
(
cfg
->
valType
)
{
switch
(
cfg
->
valType
)
{
case
TAOS_CFG_VTYPE_INT8
:
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int8_t
*
)
cfg
->
ptr
));
varDataSetLen
(
pWrite
,
t
);
numOfRows
++
;
break
;
case
TAOS_CFG_VTYPE_INT16
:
case
TAOS_CFG_VTYPE_INT16
:
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int16_t
*
)
cfg
->
ptr
));
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int16_t
*
)
cfg
->
ptr
));
varDataSetLen
(
pWrite
,
t
);
varDataSetLen
(
pWrite
,
t
);
...
@@ -1154,21 +1172,17 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -1154,21 +1172,17 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
return
numOfRows
;
return
numOfRows
;
}
}
char
*
mnodeGetDnodeStatusStr
(
int32_t
dnodeStatus
)
{
char
*
dnodeStatus
[]
=
{
switch
(
dnodeStatus
)
{
"offline"
,
case
TAOS_DN_STATUS_OFFLINE
:
return
"offline"
;
"dropping"
,
case
TAOS_DN_STATUS_DROPPING
:
return
"dropping"
;
"balancing"
,
case
TAOS_DN_STATUS_BALANCING
:
return
"balancing"
;
"ready"
,
case
TAOS_DN_STATUS_READY
:
return
"ready"
;
"undefined"
default:
return
"undefined"
;
};
}
}
static
char
*
mnodeGetDnodeAlternativeRoleStr
(
int32_t
alternativeRole
)
{
char
*
dnodeRoles
[]
=
{
switch
(
alternativeRole
)
{
"any"
,
case
TAOS_DN_ALTERNATIVE_ROLE_ANY
:
return
"any"
;
"mnode"
,
case
TAOS_DN_ALTERNATIVE_ROLE_MNODE
:
return
"mnode"
;
"vnode"
,
case
TAOS_DN_ALTERNATIVE_ROLE_VNODE
:
return
"vnode"
;
"any"
default:
return
"any"
;
};
}
}
src/mnode/src/mnodeMnode.c
浏览文件 @
a7c6e73f
...
@@ -377,6 +377,24 @@ static int32_t mnodeCreateMnodeCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -377,6 +377,24 @@ static int32_t mnodeCreateMnodeCb(SMnodeMsg *pMsg, int32_t code) {
return
code
;
return
code
;
}
}
static
bool
mnodeAllOnline
()
{
void
*
pIter
=
NULL
;
bool
allOnline
=
true
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
if
(
pMnode
==
NULL
)
break
;
if
(
pMnode
->
role
!=
TAOS_SYNC_ROLE_MASTER
&&
pMnode
->
role
!=
TAOS_SYNC_ROLE_SLAVE
)
{
allOnline
=
false
;
mnodeDecMnodeRef
(
pMnode
);
}
}
mnodeCancelGetNextMnode
(
pIter
);
return
allOnline
;
}
void
mnodeCreateMnode
(
int32_t
dnodeId
,
char
*
dnodeEp
,
bool
needConfirm
)
{
void
mnodeCreateMnode
(
int32_t
dnodeId
,
char
*
dnodeEp
,
bool
needConfirm
)
{
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
pMnode
->
mnodeId
=
dnodeId
;
pMnode
->
mnodeId
=
dnodeId
;
...
@@ -389,6 +407,11 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
...
@@ -389,6 +407,11 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
.
fpRsp
=
mnodeCreateMnodeCb
.
fpRsp
=
mnodeCreateMnodeCb
};
};
if
(
needConfirm
&&
!
mnodeAllOnline
())
{
mDebug
(
"wait all mnode online then create new mnode"
);
return
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
needConfirm
)
{
if
(
needConfirm
)
{
code
=
mnodeSendCreateMnodeMsg
(
dnodeId
,
dnodeEp
);
code
=
mnodeSendCreateMnodeMsg
(
dnodeId
,
dnodeEp
);
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
a7c6e73f
...
@@ -1081,6 +1081,8 @@ static void *sdbWorkerFp(void *pWorker) {
...
@@ -1081,6 +1081,8 @@ static void *sdbWorkerFp(void *pWorker) {
int32_t
qtype
;
int32_t
qtype
;
void
*
unUsed
;
void
*
unUsed
;
taosBlockSIGPIPE
();
while
(
1
)
{
while
(
1
)
{
int32_t
numOfMsgs
=
taosReadAllQitemsFromQset
(
tsSdbWQset
,
tsSdbWQall
,
&
unUsed
);
int32_t
numOfMsgs
=
taosReadAllQitemsFromQset
(
tsSdbWQset
,
tsSdbWQall
,
&
unUsed
);
if
(
numOfMsgs
==
0
)
{
if
(
numOfMsgs
==
0
)
{
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
a7c6e73f
...
@@ -351,6 +351,8 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
...
@@ -351,6 +351,8 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
mnodeGetMnodeEpSetForShell
(
&
pConnectRsp
->
epSet
,
false
);
mnodeGetMnodeEpSetForShell
(
&
pConnectRsp
->
epSet
,
false
);
dnodeGetClusterId
(
pConnectRsp
->
clusterId
);
connect_over:
connect_over:
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pConnectRsp
)
rpcFreeCont
(
pConnectRsp
);
if
(
pConnectRsp
)
rpcFreeCont
(
pConnectRsp
);
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
a7c6e73f
...
@@ -256,6 +256,8 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
...
@@ -256,6 +256,8 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
}
}
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
pVgroup
->
vgCfgVersion
++
;
SSdbRow
row
=
{
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
...
@@ -339,10 +341,11 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl
...
@@ -339,10 +341,11 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl
pVgroup
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
pVgroup
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
}
}
if
(
pVload
->
cfgVersion
!=
pVgroup
->
pDb
->
cfgVersion
||
pVload
->
replica
!=
pVgroup
->
numOfVnodes
)
{
if
(
pVload
->
dbCfgVersion
!=
pVgroup
->
pDb
->
dbCfgVersion
||
pVload
->
replica
!=
pVgroup
->
numOfVnodes
||
mError
(
"dnode:%d, vgId:%d, vnode cfgVersion:%d repica:%d not match with mnode cfgVersion:%d replica:%d"
,
pVload
->
vgCfgVersion
!=
pVgroup
->
vgCfgVersion
)
{
pDnode
->
dnodeId
,
pVload
->
vgId
,
pVload
->
cfgVersion
,
pVload
->
replica
,
pVgroup
->
pDb
->
cfgVersion
,
mError
(
"dnode:%d, vgId:%d, vnode cfgVersion:%d:%d repica:%d not match with mnode cfgVersion:%d:%d replica:%d"
,
pVgroup
->
numOfVnodes
);
pDnode
->
dnodeId
,
pVload
->
vgId
,
pVload
->
dbCfgVersion
,
pVload
->
vgCfgVersion
,
pVload
->
replica
,
pVgroup
->
pDb
->
dbCfgVersion
,
pVgroup
->
vgCfgVersion
,
pVgroup
->
numOfVnodes
);
mnodeSendAlterVgroupMsg
(
pVgroup
);
mnodeSendAlterVgroupMsg
(
pVgroup
);
}
}
}
}
...
@@ -656,7 +659,7 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
...
@@ -656,7 +659,7 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
pShow
->
bytes
[
cols
]
=
4
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"online
Vnode
s"
);
strcpy
(
pSchema
[
cols
].
name
,
"onlines"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
...
@@ -671,13 +674,13 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
...
@@ -671,13 +674,13 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
pShow
->
bytes
[
cols
]
=
2
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d
D
node"
,
i
+
1
);
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d
_d
node"
,
i
+
1
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
pShow
->
bytes
[
cols
]
=
9
+
VARSTR_HEADER_SIZE
;
pShow
->
bytes
[
cols
]
=
9
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d
S
tatus"
,
i
+
1
);
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d
_s
tatus"
,
i
+
1
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
}
}
...
@@ -840,7 +843,8 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
...
@@ -840,7 +843,8 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
SVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
SVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
cfgVersion
=
htonl
(
pDb
->
cfgVersion
);
pCfg
->
dbCfgVersion
=
htonl
(
pDb
->
dbCfgVersion
);
pCfg
->
vgCfgVersion
=
htonl
(
pVgroup
->
vgCfgVersion
);
pCfg
->
cacheBlockSize
=
htonl
(
pDb
->
cfg
.
cacheBlockSize
);
pCfg
->
cacheBlockSize
=
htonl
(
pDb
->
cfg
.
cacheBlockSize
);
pCfg
->
totalBlocks
=
htonl
(
pDb
->
cfg
.
totalBlocks
);
pCfg
->
totalBlocks
=
htonl
(
pDb
->
cfg
.
totalBlocks
);
pCfg
->
maxTables
=
htonl
(
maxTables
+
1
);
pCfg
->
maxTables
=
htonl
(
maxTables
+
1
);
...
@@ -859,6 +863,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
...
@@ -859,6 +863,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
pCfg
->
wals
=
3
;
pCfg
->
wals
=
3
;
pCfg
->
quorum
=
pDb
->
cfg
.
quorum
;
pCfg
->
quorum
=
pDb
->
cfg
.
quorum
;
pCfg
->
update
=
pDb
->
cfg
.
update
;
pCfg
->
update
=
pDb
->
cfg
.
update
;
pCfg
->
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
SVnodeDesc
*
pNodes
=
pVnode
->
nodes
;
SVnodeDesc
*
pNodes
=
pVnode
->
nodes
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
...
...
src/os/inc/osSocket.h
浏览文件 @
a7c6e73f
...
@@ -59,6 +59,7 @@ extern "C" {
...
@@ -59,6 +59,7 @@ extern "C" {
// TAOS_OS_FUNC_SOCKET
// TAOS_OS_FUNC_SOCKET
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
);
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
);
void
taosIgnSIGPIPE
();
void
taosBlockSIGPIPE
();
void
taosBlockSIGPIPE
();
// TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
// TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
...
...
src/os/src/detail/osSocket.c
浏览文件 @
a7c6e73f
...
@@ -39,6 +39,10 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
...
@@ -39,6 +39,10 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
return
0
;
return
0
;
}
}
void
taosIgnSIGPIPE
()
{
signal
(
SIGPIPE
,
SIG_IGN
);
}
void
taosBlockSIGPIPE
()
{
void
taosBlockSIGPIPE
()
{
sigset_t
signal_mask
;
sigset_t
signal_mask
;
sigemptyset
(
&
signal_mask
);
sigemptyset
(
&
signal_mask
);
...
...
src/os/src/windows/wSocket.c
浏览文件 @
a7c6e73f
...
@@ -46,6 +46,7 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
...
@@ -46,6 +46,7 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
return
0
;
return
0
;
}
}
void
taosIgnSIGPIPE
()
{}
void
taosBlockSIGPIPE
()
{}
void
taosBlockSIGPIPE
()
{}
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
int32_t
taosSetSockOpt
(
SOCKET
socketfd
,
int32_t
level
,
int32_t
optname
,
void
*
optval
,
int32_t
optlen
)
{
...
...
src/plugins/http/src/httpResp.c
浏览文件 @
a7c6e73f
...
@@ -136,7 +136,7 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
...
@@ -136,7 +136,7 @@ void httpSendErrorResp(HttpContext *pContext, int32_t errNo) {
else
else
httpCode
=
400
;
httpCode
=
400
;
if
(
pContext
->
parser
->
httpCode
!=
0
)
{
if
(
pContext
->
parser
&&
pContext
->
parser
->
httpCode
!=
0
)
{
httpCode
=
pContext
->
parser
->
httpCode
;
httpCode
=
pContext
->
parser
->
httpCode
;
}
}
...
...
src/query/inc/qExecutor.h
浏览文件 @
a7c6e73f
...
@@ -33,13 +33,6 @@ struct SColumnFilterElem;
...
@@ -33,13 +33,6 @@ struct SColumnFilterElem;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
char
*
val1
,
char
*
val2
);
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
char
*
val1
,
char
*
val2
);
typedef
int32_t
(
*
__block_search_fn_t
)(
char
*
data
,
int32_t
num
,
int64_t
key
,
int32_t
order
);
typedef
int32_t
(
*
__block_search_fn_t
)(
char
*
data
,
int32_t
num
,
int64_t
key
,
int32_t
order
);
typedef
struct
SGroupResInfo
{
int32_t
groupId
;
int32_t
numOfDataPages
;
int32_t
pageId
;
int32_t
rowId
;
}
SGroupResInfo
;
typedef
struct
SResultRowPool
{
typedef
struct
SResultRowPool
{
int32_t
elemSize
;
int32_t
elemSize
;
int32_t
blockSize
;
int32_t
blockSize
;
...
@@ -72,6 +65,12 @@ typedef struct SResultRow {
...
@@ -72,6 +65,12 @@ typedef struct SResultRow {
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current time window
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current time window
}
SResultRow
;
}
SResultRow
;
typedef
struct
SGroupResInfo
{
int32_t
rowId
;
int32_t
index
;
SArray
*
pRows
;
// SArray<SResultRow*>
}
SGroupResInfo
;
/**
/**
* If the number of generated results is greater than this value,
* If the number of generated results is greater than this value,
* query query will be halt and return results to client immediate.
* query query will be halt and return results to client immediate.
...
@@ -89,7 +88,6 @@ typedef struct SResultRowInfo {
...
@@ -89,7 +88,6 @@ typedef struct SResultRowInfo {
int32_t
size
:
24
;
// number of result set
int32_t
size
:
24
;
// number of result set
int32_t
capacity
;
// max capacity
int32_t
capacity
;
// max capacity
int32_t
curIndex
;
// current start active index
int32_t
curIndex
;
// current start active index
int64_t
startTime
;
// start time of the first time window for sliding query
int64_t
prevSKey
;
// previous (not completed) sliding window start key
int64_t
prevSKey
;
// previous (not completed) sliding window start key
}
SResultRowInfo
;
}
SResultRowInfo
;
...
...
src/query/inc/qHistogram.h
浏览文件 @
a7c6e73f
...
@@ -67,7 +67,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto);
...
@@ -67,7 +67,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto);
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
);
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
);
int32_t
vnodeHistob
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
);
int32_t
histoB
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
);
SHeapEntry
*
tHeapCreate
(
int32_t
numOfEntries
);
SHeapEntry
*
tHeapCreate
(
int32_t
numOfEntries
);
void
tHeapSort
(
SHeapEntry
*
pEntry
,
int32_t
len
);
void
tHeapSort
(
SHeapEntry
*
pEntry
,
int32_t
len
);
...
...
src/query/inc/qSqlparser.h
浏览文件 @
a7c6e73f
...
@@ -121,6 +121,7 @@ typedef struct SCreateDBInfo {
...
@@ -121,6 +121,7 @@ typedef struct SCreateDBInfo {
SStrToken
precision
;
SStrToken
precision
;
bool
ignoreExists
;
bool
ignoreExists
;
int8_t
update
;
int8_t
update
;
int8_t
cachelast
;
SArray
*
keep
;
SArray
*
keep
;
}
SCreateDBInfo
;
}
SCreateDBInfo
;
...
...
src/query/inc/qUtil.h
浏览文件 @
a7c6e73f
...
@@ -34,17 +34,13 @@ int32_t initResultRowInfo(SResultRowInfo* pResultRowInfo, int32_t size, int16_t
...
@@ -34,17 +34,13 @@ int32_t initResultRowInfo(SResultRowInfo* pResultRowInfo, int32_t size, int16_t
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
void
resetResultRowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
);
void
resetResultRowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
);
void
popFrontResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
num
);
void
clearClosedResultRows
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
);
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
);
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
removeRedundantResultRows
(
SResultRowInfo
*
pResultRowInfo
,
TSKEY
lastKey
,
int32_t
order
);
int32_t
initResultRow
(
SResultRow
*
pResultRow
);
int32_t
initResultRow
(
SResultRow
*
pResultRow
);
void
closeResultRow
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
void
closeResultRow
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
bool
isResultRowClosed
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
bool
isResultRowClosed
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResultRow
,
int16_t
type
);
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResultRow
,
int16_t
type
);
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
,
int16_t
type
);
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
);
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
);
...
@@ -77,7 +73,6 @@ void* destroyResultRowPool(SResultRowPool* p);
...
@@ -77,7 +73,6 @@ void* destroyResultRowPool(SResultRowPool* p);
int32_t
getNumOfAllocatedResultRows
(
SResultRowPool
*
p
);
int32_t
getNumOfAllocatedResultRows
(
SResultRowPool
*
p
);
int32_t
getNumOfUsedResultRows
(
SResultRowPool
*
p
);
int32_t
getNumOfUsedResultRows
(
SResultRowPool
*
p
);
uint64_t
getResultInfoUId
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
bool
isPointInterpoQuery
(
SQuery
*
pQuery
);
bool
isPointInterpoQuery
(
SQuery
*
pQuery
);
...
...
src/query/inc/queryLog.h
浏览文件 @
a7c6e73f
...
@@ -22,8 +22,8 @@ extern "C" {
...
@@ -22,8 +22,8 @@ extern "C" {
#include "tlog.h"
#include "tlog.h"
extern
u
int32_t
qDebugFlag
;
extern
int32_t
qDebugFlag
;
extern
uint32_t
tscEmbedded
;
extern
int8_t
tscEmbedded
;
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }} while(0)
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }} while(0)
...
...
src/query/inc/sql.y
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/query/src/qExecutor.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/query/src/qHistogram.c
浏览文件 @
a7c6e73f
...
@@ -158,8 +158,8 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
...
@@ -158,8 +158,8 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
}
}
#if defined(USE_ARRAYLIST)
#if defined(USE_ARRAYLIST)
int32_t
idx
=
vnodeHistob
inarySearch
((
*
pHisto
)
->
elems
,
(
*
pHisto
)
->
numOfEntries
,
val
);
int32_t
idx
=
histoB
inarySearch
((
*
pHisto
)
->
elems
,
(
*
pHisto
)
->
numOfEntries
,
val
);
assert
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
);
assert
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
&&
(
*
pHisto
)
->
elems
!=
NULL
);
if
((
*
pHisto
)
->
elems
[
idx
].
val
==
val
&&
idx
>=
0
)
{
if
((
*
pHisto
)
->
elems
[
idx
].
val
==
val
&&
idx
>=
0
)
{
(
*
pHisto
)
->
elems
[
idx
].
num
+=
1
;
(
*
pHisto
)
->
elems
[
idx
].
num
+=
1
;
...
@@ -356,7 +356,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
...
@@ -356,7 +356,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
return
0
;
return
0
;
}
}
int32_t
vnodeHistob
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
)
{
int32_t
histoB
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
)
{
int32_t
end
=
len
-
1
;
int32_t
end
=
len
-
1
;
int32_t
start
=
0
;
int32_t
start
=
0
;
...
@@ -466,7 +466,7 @@ void tHistogramPrint(SHistogramInfo* pHisto) {
...
@@ -466,7 +466,7 @@ void tHistogramPrint(SHistogramInfo* pHisto) {
*/
*/
int64_t
tHistogramSum
(
SHistogramInfo
*
pHisto
,
double
v
)
{
int64_t
tHistogramSum
(
SHistogramInfo
*
pHisto
,
double
v
)
{
#if defined(USE_ARRAYLIST)
#if defined(USE_ARRAYLIST)
int32_t
slotIdx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
v
);
int32_t
slotIdx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
v
);
if
(
pHisto
->
elems
[
slotIdx
].
val
!=
v
)
{
if
(
pHisto
->
elems
[
slotIdx
].
val
!=
v
)
{
slotIdx
-=
1
;
slotIdx
-=
1
;
...
...
src/query/src/qParserImpl.c
浏览文件 @
a7c6e73f
...
@@ -384,7 +384,12 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType)
...
@@ -384,7 +384,12 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType)
pField
->
name
[
pName
->
n
]
=
0
;
pField
->
name
[
pName
->
n
]
=
0
;
pField
->
type
=
pType
->
type
;
pField
->
type
=
pType
->
type
;
if
(
pField
->
type
<
TSDB_DATA_TYPE_BOOL
||
pField
->
type
>
TSDB_DATA_TYPE_NCHAR
){
pField
->
bytes
=
0
;
}
else
{
pField
->
bytes
=
pType
->
bytes
;
pField
->
bytes
=
pType
->
bytes
;
}
}
}
void
tSqlSetColumnType
(
TAOS_FIELD
*
pField
,
SStrToken
*
type
)
{
void
tSqlSetColumnType
(
TAOS_FIELD
*
pField
,
SStrToken
*
type
)
{
...
@@ -841,5 +846,6 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
...
@@ -841,5 +846,6 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
pDBInfo
->
keep
=
NULL
;
pDBInfo
->
keep
=
NULL
;
pDBInfo
->
update
=
-
1
;
pDBInfo
->
update
=
-
1
;
pDBInfo
->
cachelast
=
0
;
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SStrToken
));
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SStrToken
));
}
}
src/query/src/qResultbuf.c
浏览文件 @
a7c6e73f
...
@@ -313,7 +313,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32
...
@@ -313,7 +313,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32
// allocate buf
// allocate buf
if
(
availablePage
==
NULL
)
{
if
(
availablePage
==
NULL
)
{
pi
->
pData
=
calloc
(
1
,
pResultBuf
->
pageSize
+
POINTER_BYTES
);
pi
->
pData
=
calloc
(
1
,
pResultBuf
->
pageSize
+
POINTER_BYTES
+
2
);
// add extract bytes in case of zipped buffer increased.
}
else
{
}
else
{
pi
->
pData
=
availablePage
;
pi
->
pData
=
availablePage
;
}
}
...
...
src/query/src/qTokenizer.c
浏览文件 @
a7c6e73f
...
@@ -238,6 +238,7 @@ static SKeyword keywordTable[] = {
...
@@ -238,6 +238,7 @@ static SKeyword keywordTable[] = {
{
"SUM_IRATE"
,
TK_SUM_IRATE
},
{
"SUM_IRATE"
,
TK_SUM_IRATE
},
{
"AVG_RATE"
,
TK_AVG_RATE
},
{
"AVG_RATE"
,
TK_AVG_RATE
},
{
"AVG_IRATE"
,
TK_AVG_IRATE
},
{
"AVG_IRATE"
,
TK_AVG_IRATE
},
{
"CACHELAST"
,
TK_CACHELAST
},
};
};
static
const
char
isIdChar
[]
=
{
static
const
char
isIdChar
[]
=
{
...
...
src/query/src/qUtil.c
浏览文件 @
a7c6e73f
...
@@ -20,18 +20,6 @@
...
@@ -20,18 +20,6 @@
#include "qExecutor.h"
#include "qExecutor.h"
#include "qUtil.h"
#include "qUtil.h"
static
int32_t
getResultRowKeyInfo
(
SResultRow
*
pResult
,
int16_t
type
,
char
**
key
,
int16_t
*
bytes
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
*
key
=
varDataVal
(
pResult
->
key
);
*
bytes
=
varDataLen
(
pResult
->
key
);
}
else
{
*
key
=
(
char
*
)
&
pResult
->
win
.
skey
;
*
bytes
=
tDataTypeDesc
[
type
].
nSize
;
}
return
0
;
}
int32_t
getOutputInterResultBufSize
(
SQuery
*
pQuery
)
{
int32_t
getOutputInterResultBufSize
(
SQuery
*
pQuery
)
{
int32_t
size
=
0
;
int32_t
size
=
0
;
...
@@ -96,78 +84,9 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
...
@@ -96,78 +84,9 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
pResultRowInfo
->
curIndex
=
-
1
;
pResultRowInfo
->
curIndex
=
-
1
;
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
startTime
=
TSKEY_INITIAL_VAL
;
pResultRowInfo
->
prevSKey
=
TSKEY_INITIAL_VAL
;
pResultRowInfo
->
prevSKey
=
TSKEY_INITIAL_VAL
;
}
}
void
popFrontResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
num
)
{
if
(
pResultRowInfo
==
NULL
||
pResultRowInfo
->
capacity
==
0
||
pResultRowInfo
->
size
==
0
||
num
==
0
)
{
return
;
}
int32_t
numOfClosed
=
numOfClosedResultRows
(
pResultRowInfo
);
assert
(
num
>=
0
&&
num
<=
numOfClosed
);
int16_t
type
=
pResultRowInfo
->
type
;
int64_t
uid
=
getResultInfoUId
(
pRuntimeEnv
);
char
*
key
=
NULL
;
int16_t
bytes
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SResultRow
*
pResult
=
pResultRowInfo
->
pResult
[
i
];
if
(
pResult
->
closed
)
{
// remove the window slot from hash table
getResultRowKeyInfo
(
pResult
,
type
,
&
key
,
&
bytes
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
taosHashRemove
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
}
else
{
break
;
}
}
int32_t
remain
=
pResultRowInfo
->
size
-
num
;
// clear all the closed windows from the window list
for
(
int32_t
k
=
0
;
k
<
remain
;
++
k
)
{
copyResultRow
(
pRuntimeEnv
,
pResultRowInfo
->
pResult
[
k
],
pResultRowInfo
->
pResult
[
num
+
k
],
type
);
}
// move the unclosed window in the front of the window list
for
(
int32_t
k
=
remain
;
k
<
pResultRowInfo
->
size
;
++
k
)
{
SResultRow
*
pWindowRes
=
pResultRowInfo
->
pResult
[
k
];
clearResultRow
(
pRuntimeEnv
,
pWindowRes
,
pResultRowInfo
->
type
);
}
pResultRowInfo
->
size
=
remain
;
for
(
int32_t
k
=
0
;
k
<
pResultRowInfo
->
size
;
++
k
)
{
SResultRow
*
pResult
=
pResultRowInfo
->
pResult
[
k
];
getResultRowKeyInfo
(
pResult
,
type
,
&
key
,
&
bytes
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
assert
(
p
!=
NULL
);
int32_t
v
=
(
*
p
-
num
);
assert
(
v
>=
0
&&
v
<=
pResultRowInfo
->
size
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
taosHashPut
(
pRuntimeEnv
->
pResultRowHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
v
,
sizeof
(
int32_t
));
}
pResultRowInfo
->
curIndex
=
-
1
;
}
void
clearClosedResultRows
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
)
{
if
(
pResultRowInfo
==
NULL
||
pResultRowInfo
->
capacity
==
0
||
pResultRowInfo
->
size
==
0
)
{
return
;
}
int32_t
numOfClosed
=
numOfClosedResultRows
(
pResultRowInfo
);
popFrontResultRow
(
pRuntimeEnv
,
&
pRuntimeEnv
->
windowResInfo
,
numOfClosed
);
}
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
int32_t
i
=
0
;
int32_t
i
=
0
;
while
(
i
<
pResultRowInfo
->
size
&&
pResultRowInfo
->
pResult
[
i
]
->
closed
)
{
while
(
i
<
pResultRowInfo
->
size
&&
pResultRowInfo
->
pResult
[
i
]
->
closed
)
{
...
@@ -181,45 +100,12 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) {
...
@@ -181,45 +100,12 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) {
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
if
(
pResultRowInfo
->
pResult
[
i
]
->
closed
)
{
SResultRow
*
pRow
=
pResultRowInfo
->
pResult
[
i
];
if
(
pRow
->
closed
)
{
continue
;
continue
;
}
}
pResultRowInfo
->
pResult
[
i
]
->
closed
=
true
;
pRow
->
closed
=
true
;
}
}
/*
* remove the results that are not the FIRST time window that spreads beyond the
* the last qualified time stamp in case of sliding query, which the sliding time is not equalled to the interval time.
* NOTE: remove redundant, only when the result set order equals to traverse order
*/
void
removeRedundantResultRows
(
SResultRowInfo
*
pResultRowInfo
,
TSKEY
lastKey
,
int32_t
order
)
{
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
if
(
pResultRowInfo
->
size
<=
1
)
{
return
;
}
// get the result order
int32_t
resultOrder
=
(
pResultRowInfo
->
pResult
[
0
]
->
win
.
skey
<
pResultRowInfo
->
pResult
[
1
]
->
win
.
skey
)
?
1
:-
1
;
if
(
order
!=
resultOrder
)
{
return
;
}
int32_t
i
=
0
;
if
(
order
==
QUERY_ASC_FORWARD_STEP
)
{
TSKEY
ekey
=
pResultRowInfo
->
pResult
[
i
]
->
win
.
ekey
;
while
(
i
<
pResultRowInfo
->
size
&&
(
ekey
<
lastKey
))
{
++
i
;
}
}
else
if
(
order
==
QUERY_DESC_FORWARD_STEP
)
{
while
(
i
<
pResultRowInfo
->
size
&&
(
pResultRowInfo
->
pResult
[
i
]
->
win
.
skey
>
lastKey
))
{
++
i
;
}
}
if
(
i
<
pResultRowInfo
->
size
)
{
pResultRowInfo
->
size
=
(
i
+
1
);
}
}
}
}
...
@@ -263,47 +149,6 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
...
@@ -263,47 +149,6 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
}
}
}
}
/**
* The source window result pos attribution of the source window result does not assign to the destination,
* since the attribute of "Pos" is bound to each window result when the window result is created in the
* disk-based result buffer.
*/
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
,
int16_t
type
)
{
dst
->
numOfRows
=
src
->
numOfRows
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
dst
->
key
=
realloc
(
dst
->
key
,
varDataTLen
(
src
->
key
));
varDataCopy
(
dst
->
key
,
src
->
key
);
}
else
{
dst
->
win
=
src
->
win
;
}
dst
->
closed
=
src
->
closed
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
nOutputCols
;
++
i
)
{
SResultRowCellInfo
*
pDst
=
getResultCell
(
pRuntimeEnv
,
dst
,
i
);
SResultRowCellInfo
*
pSrc
=
getResultCell
(
pRuntimeEnv
,
src
,
i
);
// char *buf = pDst->interResultBuf;
memcpy
(
pDst
,
pSrc
,
sizeof
(
SResultRowCellInfo
)
+
pRuntimeEnv
->
pCtx
[
i
].
interBufBytes
);
// pDst->interResultBuf = buf; // restore the allocated buffer
// copy the result info struct
// memcpy(pDst->interResultBuf, pSrc->interResultBuf, pRuntimeEnv->pCtx[i].interBufBytes);
// copy the output buffer data from src to dst, the position info keep unchanged
tFilePage
*
dstpage
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
dst
->
pageId
);
char
*
dstBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
dst
,
dstpage
);
tFilePage
*
srcpage
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
src
->
pageId
);
char
*
srcBuf
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
(
SResultRow
*
)
src
,
srcpage
);
size_t
s
=
pRuntimeEnv
->
pQuery
->
pExpr1
[
i
].
bytes
;
memcpy
(
dstBuf
,
srcBuf
,
s
);
}
}
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
)
{
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
)
{
assert
(
index
>=
0
&&
index
<
pRuntimeEnv
->
pQuery
->
numOfOutput
);
assert
(
index
>=
0
&&
index
<
pRuntimeEnv
->
pQuery
->
numOfOutput
);
return
(
SResultRowCellInfo
*
)((
char
*
)
pRow
->
pCellInfo
+
pRuntimeEnv
->
rowCellInfoOffset
[
index
]);
return
(
SResultRowCellInfo
*
)((
char
*
)
pRow
->
pCellInfo
+
pRuntimeEnv
->
rowCellInfoOffset
[
index
]);
...
@@ -384,17 +229,3 @@ void* destroyResultRowPool(SResultRowPool* p) {
...
@@ -384,17 +229,3 @@ void* destroyResultRowPool(SResultRowPool* p) {
tfree
(
p
);
tfree
(
p
);
return
NULL
;
return
NULL
;
}
}
\ No newline at end of file
uint64_t
getResultInfoUId
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
if
(
!
pRuntimeEnv
->
stableQuery
)
{
return
0
;
// for simple table query, the uid is always set to be 0;
}
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
pQuery
->
interval
.
interval
==
0
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyNormalCol
)
{
return
0
;
}
STableId
*
id
=
TSDB_TABLEID
(
pRuntimeEnv
->
pQuery
->
current
->
pTable
);
return
id
->
uid
;
}
\ No newline at end of file
src/query/src/sql.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/query/tests/histogramTest.cpp
浏览文件 @
a7c6e73f
...
@@ -21,19 +21,19 @@ TEST(testCase, histogram_binary_search) {
...
@@ -21,19 +21,19 @@ TEST(testCase, histogram_binary_search) {
pHisto
->
elems
[
i
].
val
=
i
;
pHisto
->
elems
[
i
].
val
=
i
;
}
}
int32_t
idx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
1
);
int32_t
idx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
1
);
assert
(
idx
==
1
);
assert
(
idx
==
1
);
idx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
9
);
idx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
9
);
assert
(
idx
==
9
);
assert
(
idx
==
9
);
idx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
20
);
idx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
20
);
assert
(
idx
==
10
);
assert
(
idx
==
10
);
idx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
-
1
);
idx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
-
1
);
assert
(
idx
==
0
);
assert
(
idx
==
0
);
idx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
3.9
);
idx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
3.9
);
assert
(
idx
==
4
);
assert
(
idx
==
4
);
free
(
pHisto
);
free
(
pHisto
);
...
...
src/rpc/inc/rpcLog.h
浏览文件 @
a7c6e73f
...
@@ -23,7 +23,7 @@ extern "C" {
...
@@ -23,7 +23,7 @@ extern "C" {
#include "tlog.h"
#include "tlog.h"
extern
int32_t
rpcDebugFlag
;
extern
int32_t
rpcDebugFlag
;
extern
uint32_t
tscEmbedded
;
extern
int8_t
tscEmbedded
;
#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("RPC ERROR ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR) { taosPrintLog("RPC ERROR ", tscEmbedded ? 255 : rpcDebugFlag, __VA_ARGS__); }}
...
...
src/rpc/src/rpcMain.c
浏览文件 @
a7c6e73f
...
@@ -576,7 +576,7 @@ static void rpcFreeMsg(void *msg) {
...
@@ -576,7 +576,7 @@ static void rpcFreeMsg(void *msg) {
static
SRpcConn
*
rpcOpenConn
(
SRpcInfo
*
pRpc
,
char
*
peerFqdn
,
uint16_t
peerPort
,
int8_t
connType
)
{
static
SRpcConn
*
rpcOpenConn
(
SRpcInfo
*
pRpc
,
char
*
peerFqdn
,
uint16_t
peerPort
,
int8_t
connType
)
{
SRpcConn
*
pConn
;
SRpcConn
*
pConn
;
uint32_t
peerIp
=
taosGetIpFromFqdn
(
peerFqdn
);
uint32_t
peerIp
=
taosGetIp
v4
FromFqdn
(
peerFqdn
);
if
(
peerIp
==
0xFFFFFFFF
)
{
if
(
peerIp
==
0xFFFFFFFF
)
{
tError
(
"%s, failed to resolve FQDN:%s"
,
pRpc
->
label
,
peerFqdn
);
tError
(
"%s, failed to resolve FQDN:%s"
,
pRpc
->
label
,
peerFqdn
);
terrno
=
TSDB_CODE_RPC_FQDN_ERROR
;
terrno
=
TSDB_CODE_RPC_FQDN_ERROR
;
...
...
src/sync/inc/syncInt.h
浏览文件 @
a7c6e73f
...
@@ -38,7 +38,7 @@ extern "C" {
...
@@ -38,7 +38,7 @@ extern "C" {
#define SYNC_MAX_FWDS 512
#define SYNC_MAX_FWDS 512
#define SYNC_FWD_TIMER 300
#define SYNC_FWD_TIMER 300
#define SYNC_ROLE_TIMER 15000 // ms
#define SYNC_ROLE_TIMER 15000 // ms
#define SYNC_CHECK_INTERVAL 1
// ms
#define SYNC_CHECK_INTERVAL 1
000
// ms
#define SYNC_WAIT_AFTER_CHOOSE_MASTER 10 // ms
#define SYNC_WAIT_AFTER_CHOOSE_MASTER 10 // ms
#define nodeRole pNode->peerInfo[pNode->selfIndex]->role
#define nodeRole pNode->peerInfo[pNode->selfIndex]->role
...
@@ -86,9 +86,10 @@ typedef struct SsyncPeer {
...
@@ -86,9 +86,10 @@ typedef struct SsyncPeer {
int32_t
peerFd
;
// forward FD
int32_t
peerFd
;
// forward FD
int32_t
numOfRetrieves
;
// number of retrieves tried
int32_t
numOfRetrieves
;
// number of retrieves tried
int32_t
fileChanged
;
// a flag to indicate file is changed during retrieving process
int32_t
fileChanged
;
// a flag to indicate file is changed during retrieving process
int32_t
refCount
;
int64_t
rid
;
void
*
timer
;
void
*
timer
;
void
*
pConn
;
void
*
pConn
;
int32_t
refCount
;
// reference count
struct
SSyncNode
*
pSyncNode
;
struct
SSyncNode
*
pSyncNode
;
}
SSyncPeer
;
}
SSyncPeer
;
...
@@ -98,6 +99,7 @@ typedef struct SSyncNode {
...
@@ -98,6 +99,7 @@ typedef struct SSyncNode {
int8_t
quorum
;
int8_t
quorum
;
int8_t
selfIndex
;
int8_t
selfIndex
;
uint32_t
vgId
;
uint32_t
vgId
;
int32_t
refCount
;
int64_t
rid
;
int64_t
rid
;
SSyncPeer
*
peerInfo
[
TAOS_SYNC_MAX_REPLICA
+
1
];
// extra one for arbitrator
SSyncPeer
*
peerInfo
[
TAOS_SYNC_MAX_REPLICA
+
1
];
// extra one for arbitrator
SSyncPeer
*
pMaster
;
SSyncPeer
*
pMaster
;
...
@@ -121,13 +123,13 @@ extern int32_t tsSyncNum;
...
@@ -121,13 +123,13 @@ extern int32_t tsSyncNum;
extern
char
tsNodeFqdn
[
TSDB_FQDN_LEN
];
extern
char
tsNodeFqdn
[
TSDB_FQDN_LEN
];
extern
char
*
syncStatus
[];
extern
char
*
syncStatus
[];
void
*
syncRetrieveData
(
void
*
param
);
void
*
syncRetrieveData
(
void
*
param
);
void
*
syncRestoreData
(
void
*
param
);
void
*
syncRestoreData
(
void
*
param
);
int32_t
syncSaveIntoBuffer
(
SSyncPeer
*
pPeer
,
SWalHead
*
pHead
);
int32_t
syncSaveIntoBuffer
(
SSyncPeer
*
pPeer
,
SWalHead
*
pHead
);
void
syncRestartConnection
(
SSyncPeer
*
pPeer
);
void
syncRestartConnection
(
SSyncPeer
*
pPeer
);
void
syncBroadcastStatus
(
SSyncNode
*
pNode
);
void
syncBroadcastStatus
(
SSyncNode
*
pNode
);
void
syncAddPeerRef
(
SSyncPeer
*
pPeer
);
SSyncPeer
*
syncAcquirePeer
(
int64_t
rid
);
int32_t
syncDecPeerRef
(
SSyncPeer
*
pPeer
);
void
syncReleasePeer
(
SSyncPeer
*
pPeer
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/sync/inc/syncTcp.h
浏览文件 @
a7c6e73f
...
@@ -25,14 +25,14 @@ typedef struct {
...
@@ -25,14 +25,14 @@ typedef struct {
uint32_t
serverIp
;
uint32_t
serverIp
;
int16_t
port
;
int16_t
port
;
int32_t
bufferSize
;
int32_t
bufferSize
;
void
(
*
processBrokenLink
)(
void
*
ahandle
);
void
(
*
processBrokenLink
)(
int64_t
handleId
);
int32_t
(
*
processIncomingMsg
)(
void
*
ahandle
,
void
*
buffer
);
int32_t
(
*
processIncomingMsg
)(
int64_t
handleId
,
void
*
buffer
);
void
(
*
processIncomingConn
)(
int32_t
fd
,
uint32_t
ip
);
void
(
*
processIncomingConn
)(
int32_t
fd
,
uint32_t
ip
);
}
SPoolInfo
;
}
SPoolInfo
;
void
*
syncOpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
*
syncOpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
syncCloseTcpThreadPool
(
void
*
);
void
syncCloseTcpThreadPool
(
void
*
);
void
*
syncAllocateTcpConn
(
void
*
,
void
*
ahandle
,
int32_t
connFd
);
void
*
syncAllocateTcpConn
(
void
*
,
int64_t
rid
,
int32_t
connFd
);
void
syncFreeTcpConn
(
void
*
);
void
syncFreeTcpConn
(
void
*
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/sync/src/syncArbitrator.c
浏览文件 @
a7c6e73f
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbProcessIncommingConnection
(
int32_t
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessIncommingConnection
(
int32_t
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessBrokenLink
(
void
*
param
);
static
void
arbProcessBrokenLink
(
int64_t
rid
);
static
int32_t
arbProcessPeerMsg
(
void
*
param
,
void
*
buffer
);
static
int32_t
arbProcessPeerMsg
(
int64_t
rid
,
void
*
buffer
);
static
tsem_t
tsArbSem
;
static
tsem_t
tsArbSem
;
static
void
*
tsArbTcpPool
;
static
void
*
tsArbTcpPool
;
...
@@ -138,20 +138,20 @@ static void arbProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
...
@@ -138,20 +138,20 @@ static void arbProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
sDebug
(
"%s, arbitrator request is accepted"
,
pNode
->
id
);
sDebug
(
"%s, arbitrator request is accepted"
,
pNode
->
id
);
pNode
->
nodeFd
=
connFd
;
pNode
->
nodeFd
=
connFd
;
pNode
->
pConn
=
syncAllocateTcpConn
(
tsArbTcpPool
,
pNode
,
connFd
);
pNode
->
pConn
=
syncAllocateTcpConn
(
tsArbTcpPool
,
(
int64_t
)
pNode
,
connFd
);
return
;
return
;
}
}
static
void
arbProcessBrokenLink
(
void
*
param
)
{
static
void
arbProcessBrokenLink
(
int64_t
rid
)
{
SNodeConn
*
pNode
=
param
;
SNodeConn
*
pNode
=
(
SNodeConn
*
)
rid
;
sDebug
(
"%s, TCP link is broken since %s, close connection"
,
pNode
->
id
,
strerror
(
errno
));
sDebug
(
"%s, TCP link is broken since %s, close connection"
,
pNode
->
id
,
strerror
(
errno
));
tfree
(
pNode
);
tfree
(
pNode
);
}
}
static
int32_t
arbProcessPeerMsg
(
void
*
param
,
void
*
buffer
)
{
static
int32_t
arbProcessPeerMsg
(
int64_t
rid
,
void
*
buffer
)
{
SNodeConn
*
pNode
=
param
;
SNodeConn
*
pNode
=
(
SNodeConn
*
)
rid
;
SSyncHead
head
;
SSyncHead
head
;
int32_t
bytes
=
0
;
int32_t
bytes
=
0
;
char
*
cont
=
(
char
*
)
buffer
;
char
*
cont
=
(
char
*
)
buffer
;
...
...
src/sync/src/syncMain.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/sync/src/syncRestore.c
浏览文件 @
a7c6e73f
...
@@ -90,15 +90,18 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
...
@@ -90,15 +90,18 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
break
;
break
;
}
}
sDebug
(
"%s, file:%s info is received from master, index:%d size:%"
PRId64
" fver:%"
PRIu64
" magic:%d"
,
pPeer
->
id
,
minfo
.
name
,
minfo
.
index
,
minfo
.
size
,
minfo
.
fversion
,
minfo
.
magic
);
// remove extra files on slave between the current and last index
// remove extra files on slave between the current and last index
syncRemoveExtraFile
(
pPeer
,
pindex
+
1
,
minfo
.
index
-
1
);
syncRemoveExtraFile
(
pPeer
,
pindex
+
1
,
minfo
.
index
-
1
);
pindex
=
minfo
.
index
;
pindex
=
minfo
.
index
;
// check the file info
// check the file info
sinfo
=
minfo
;
sinfo
=
minfo
;
s
Debug
(
"%s, get file:%s info size:%"
PRId64
,
pPeer
->
id
,
minfo
.
name
,
minfo
.
size
);
s
info
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
sinfo
.
name
,
&
sinfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
&
sinfo
.
size
,
&
sinfo
.
fversion
);
s
info
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
sinfo
.
name
,
&
sinfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
&
sinfo
.
siz
e
,
s
Debug
(
"%s, local file:%s info, index:%d size:%"
PRId64
" fver:%"
PRIu64
" magic:%d"
,
pPeer
->
id
,
sinfo
.
nam
e
,
&
sinfo
.
fversion
);
sinfo
.
index
,
sinfo
.
size
,
sinfo
.
fversion
,
sinfo
.
magic
);
// if file not there or magic is not the same, file shall be synced
// if file not there or magic is not the same, file shall be synced
memset
(
&
fileAck
,
0
,
sizeof
(
SFileAck
));
memset
(
&
fileAck
,
0
,
sizeof
(
SFileAck
));
...
@@ -116,6 +119,8 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
...
@@ -116,6 +119,8 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
if
(
fileAck
.
sync
==
0
)
{
if
(
fileAck
.
sync
==
0
)
{
sDebug
(
"%s, %s is the same"
,
pPeer
->
id
,
minfo
.
name
);
sDebug
(
"%s, %s is the same"
,
pPeer
->
id
,
minfo
.
name
);
continue
;
continue
;
}
else
{
sDebug
(
"%s, %s will be received, size:%"
PRId64
,
pPeer
->
id
,
minfo
.
name
,
minfo
.
size
);
}
}
// if sync is required, open file, receive from master, and write to file
// if sync is required, open file, receive from master, and write to file
...
@@ -155,7 +160,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
...
@@ -155,7 +160,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
return
code
;
return
code
;
}
}
static
int32_t
syncRestoreWal
(
SSyncPeer
*
pPeer
)
{
static
int32_t
syncRestoreWal
(
SSyncPeer
*
pPeer
,
uint64_t
*
wver
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
int32_t
ret
,
code
=
-
1
;
int32_t
ret
,
code
=
-
1
;
uint64_t
lastVer
=
0
;
uint64_t
lastVer
=
0
;
...
@@ -198,6 +203,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
...
@@ -198,6 +203,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
}
}
free
(
pHead
);
free
(
pHead
);
*
wver
=
lastVer
;
return
code
;
return
code
;
}
}
...
@@ -321,12 +327,19 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
...
@@ -321,12 +327,19 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
nodeVersion
=
fversion
;
nodeVersion
=
fversion
;
sInfo
(
"%s, start to restore wal"
,
pPeer
->
id
);
sInfo
(
"%s, start to restore wal, fver:%"
PRIu64
,
pPeer
->
id
,
nodeVersion
);
if
(
syncRestoreWal
(
pPeer
)
<
0
)
{
uint64_t
wver
=
0
;
sError
(
"%s, failed to restore wal"
,
pPeer
->
id
);
code
=
syncRestoreWal
(
pPeer
,
&
wver
);
// lastwar
if
(
code
<
0
)
{
sError
(
"%s, failed to restore wal, code:%d"
,
pPeer
->
id
,
code
);
return
-
1
;
return
-
1
;
}
}
if
(
wver
!=
0
)
{
nodeVersion
=
wver
;
sDebug
(
"%s, restore wal finished, set sver:%"
PRIu64
,
pPeer
->
id
,
nodeVersion
);
}
nodeSStatus
=
TAOS_SYNC_STATUS_CACHE
;
nodeSStatus
=
TAOS_SYNC_STATUS_CACHE
;
sInfo
(
"%s, start to insert buffered points, set sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
nodeSStatus
]);
sInfo
(
"%s, start to insert buffered points, set sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
nodeSStatus
]);
if
(
syncProcessBufferedFwd
(
pPeer
)
<
0
)
{
if
(
syncProcessBufferedFwd
(
pPeer
)
<
0
)
{
...
@@ -338,7 +351,10 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
...
@@ -338,7 +351,10 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
}
}
void
*
syncRestoreData
(
void
*
param
)
{
void
*
syncRestoreData
(
void
*
param
)
{
SSyncPeer
*
pPeer
=
param
;
int64_t
rid
=
(
int64_t
)
param
;
SSyncPeer
*
pPeer
=
syncAcquirePeer
(
rid
);
if
(
pPeer
==
NULL
)
return
NULL
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
...
@@ -369,7 +385,7 @@ void *syncRestoreData(void *param) {
...
@@ -369,7 +385,7 @@ void *syncRestoreData(void *param) {
taosClose
(
pPeer
->
syncFd
);
taosClose
(
pPeer
->
syncFd
);
syncCloseRecvBuffer
(
pNode
);
syncCloseRecvBuffer
(
pNode
);
__sync_fetch_and_sub
(
&
tsSyncNum
,
1
);
__sync_fetch_and_sub
(
&
tsSyncNum
,
1
);
sync
DecPeerRef
(
pPeer
);
sync
ReleasePeer
(
pPeer
);
return
NULL
;
return
NULL
;
}
}
src/sync/src/syncRetrieve.c
浏览文件 @
a7c6e73f
...
@@ -104,7 +104,8 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -104,7 +104,8 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
&
fileInfo
.
size
,
&
fileInfo
.
fversion
);
&
fileInfo
.
size
,
&
fileInfo
.
fversion
);
syncBuildFileInfo
(
&
fileInfo
,
pNode
->
vgId
);
syncBuildFileInfo
(
&
fileInfo
,
pNode
->
vgId
);
sDebug
(
"%s, file:%s info is sent, size:%"
PRId64
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
size
);
sDebug
(
"%s, file:%s info is sent, index:%d size:%"
PRId64
" fver:%"
PRIu64
" magic:%d"
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
index
,
fileInfo
.
size
,
fileInfo
.
fversion
,
fileInfo
.
magic
);
// send the file info
// send the file info
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
SFileInfo
));
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
SFileInfo
));
...
@@ -144,6 +145,8 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -144,6 +145,8 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
fileInfo
.
index
++
;
fileInfo
.
index
++
;
sDebug
(
"%s, %s is the same"
,
pPeer
->
id
,
fileInfo
.
name
);
sDebug
(
"%s, %s is the same"
,
pPeer
->
id
,
fileInfo
.
name
);
continue
;
continue
;
}
else
{
sDebug
(
"%s, %s will be sent"
,
pPeer
->
id
,
fileInfo
.
name
);
}
}
// get the full path to file
// get the full path to file
...
@@ -461,7 +464,10 @@ static int32_t syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
...
@@ -461,7 +464,10 @@ static int32_t syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
}
}
void
*
syncRetrieveData
(
void
*
param
)
{
void
*
syncRetrieveData
(
void
*
param
)
{
SSyncPeer
*
pPeer
=
(
SSyncPeer
*
)
param
;
int64_t
rid
=
(
int64_t
)
param
;
SSyncPeer
*
pPeer
=
syncAcquirePeer
(
rid
);
if
(
pPeer
==
NULL
)
return
NULL
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
...
@@ -490,7 +496,7 @@ void *syncRetrieveData(void *param) {
...
@@ -490,7 +496,7 @@ void *syncRetrieveData(void *param) {
pPeer
->
fileChanged
=
0
;
pPeer
->
fileChanged
=
0
;
taosClose
(
pPeer
->
syncFd
);
taosClose
(
pPeer
->
syncFd
);
sync
DecPeerRef
(
pPeer
);
sync
ReleasePeer
(
pPeer
);
return
NULL
;
return
NULL
;
}
}
src/sync/src/syncTcp.c
浏览文件 @
a7c6e73f
...
@@ -42,7 +42,7 @@ typedef struct SPoolObj {
...
@@ -42,7 +42,7 @@ typedef struct SPoolObj {
typedef
struct
{
typedef
struct
{
SThreadObj
*
pThread
;
SThreadObj
*
pThread
;
void
*
ahandle
;
int64_t
handleId
;
int32_t
fd
;
int32_t
fd
;
int32_t
closedByApp
;
int32_t
closedByApp
;
}
SConnObj
;
}
SConnObj
;
...
@@ -112,7 +112,7 @@ void syncCloseTcpThreadPool(void *param) {
...
@@ -112,7 +112,7 @@ void syncCloseTcpThreadPool(void *param) {
tfree
(
pPool
);
tfree
(
pPool
);
}
}
void
*
syncAllocateTcpConn
(
void
*
param
,
void
*
pPeer
,
int32_t
connFd
)
{
void
*
syncAllocateTcpConn
(
void
*
param
,
int64_t
rid
,
int32_t
connFd
)
{
struct
epoll_event
event
;
struct
epoll_event
event
;
SPoolObj
*
pPool
=
param
;
SPoolObj
*
pPool
=
param
;
...
@@ -130,7 +130,7 @@ void *syncAllocateTcpConn(void *param, void *pPeer, int32_t connFd) {
...
@@ -130,7 +130,7 @@ void *syncAllocateTcpConn(void *param, void *pPeer, int32_t connFd) {
pConn
->
fd
=
connFd
;
pConn
->
fd
=
connFd
;
pConn
->
pThread
=
pThread
;
pConn
->
pThread
=
pThread
;
pConn
->
ahandle
=
pPeer
;
pConn
->
handleId
=
rid
;
pConn
->
closedByApp
=
0
;
pConn
->
closedByApp
=
0
;
event
.
events
=
EPOLLIN
|
EPOLLRDHUP
;
event
.
events
=
EPOLLIN
|
EPOLLRDHUP
;
...
@@ -164,7 +164,7 @@ static void taosProcessBrokenLink(SConnObj *pConn) {
...
@@ -164,7 +164,7 @@ static void taosProcessBrokenLink(SConnObj *pConn) {
SPoolInfo
*
pInfo
=
&
pPool
->
info
;
SPoolInfo
*
pInfo
=
&
pPool
->
info
;
if
(
pConn
->
closedByApp
==
0
)
shutdown
(
pConn
->
fd
,
SHUT_WR
);
if
(
pConn
->
closedByApp
==
0
)
shutdown
(
pConn
->
fd
,
SHUT_WR
);
(
*
pInfo
->
processBrokenLink
)(
pConn
->
ahandle
);
(
*
pInfo
->
processBrokenLink
)(
pConn
->
handleId
);
pThread
->
numOfFds
--
;
pThread
->
numOfFds
--
;
epoll_ctl
(
pThread
->
pollFd
,
EPOLL_CTL_DEL
,
pConn
->
fd
,
NULL
);
epoll_ctl
(
pThread
->
pollFd
,
EPOLL_CTL_DEL
,
pConn
->
fd
,
NULL
);
...
@@ -221,7 +221,7 @@ static void *syncProcessTcpData(void *param) {
...
@@ -221,7 +221,7 @@ static void *syncProcessTcpData(void *param) {
}
}
if
(
pConn
->
closedByApp
==
0
)
{
if
(
pConn
->
closedByApp
==
0
)
{
if
((
*
pInfo
->
processIncomingMsg
)(
pConn
->
ahandle
,
buffer
)
<
0
)
{
if
((
*
pInfo
->
processIncomingMsg
)(
pConn
->
handleId
,
buffer
)
<
0
)
{
syncFreeTcpConn
(
pConn
);
syncFreeTcpConn
(
pConn
);
continue
;
continue
;
}
}
...
...
src/tsdb/inc/tsdbMain.h
浏览文件 @
a7c6e73f
...
@@ -32,14 +32,14 @@
...
@@ -32,14 +32,14 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
int
tsdbDebugFlag
;
extern
int
32_t
tsdbDebugFlag
;
#define tsdbFatal(...)
{ if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }}
#define tsdbFatal(...)
do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }} while(0)
#define tsdbError(...)
{ if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }}
#define tsdbError(...)
do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...)
{ if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }}
#define tsdbWarn(...)
do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...)
{ if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", 255, __VA_ARGS__); }}
#define tsdbInfo(...)
do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", 255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...)
{ if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }}
#define tsdbDebug(...)
do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...)
{ if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }}
#define tsdbTrace(...)
do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define TSDB_MAX_TABLE_SCHEMAS 16
#define TSDB_MAX_TABLE_SCHEMAS 16
#define TSDB_FILE_HEAD_SIZE 512
#define TSDB_FILE_HEAD_SIZE 512
...
@@ -67,7 +67,8 @@ typedef struct STable {
...
@@ -67,7 +67,8 @@ typedef struct STable {
SSkipList
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
SSkipList
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
void
*
eventHandler
;
// TODO
void
*
eventHandler
;
// TODO
void
*
streamHandler
;
// TODO
void
*
streamHandler
;
// TODO
TSKEY
lastKey
;
// lastkey inserted in this table, initialized as 0, TODO: make a structure
TSKEY
lastKey
;
SDataRow
lastRow
;
char
*
sql
;
char
*
sql
;
void
*
cqhandle
;
void
*
cqhandle
;
SRWLatch
latch
;
// TODO: implementa latch functions
SRWLatch
latch
;
// TODO: implementa latch functions
...
@@ -370,8 +371,11 @@ typedef struct {
...
@@ -370,8 +371,11 @@ typedef struct {
#define TABLE_UID(t) (t)->tableId.uid
#define TABLE_UID(t) (t)->tableId.uid
#define TABLE_TID(t) (t)->tableId.tid
#define TABLE_TID(t) (t)->tableId.tid
#define TABLE_SUID(t) (t)->suid
#define TABLE_SUID(t) (t)->suid
#define TABLE_LASTKEY(t) (t)->lastKey
#define TSDB_META_FILE_MAGIC(m) KVSTORE_MAGIC((m)->pStore)
#define TSDB_META_FILE_MAGIC(m) KVSTORE_MAGIC((m)->pStore)
#define TSDB_RLOCK_TABLE(t) taosRLockLatch(&((t)->latch))
#define TSDB_RUNLOCK_TABLE(t) taosRUnLockLatch(&((t)->latch))
#define TSDB_WLOCK_TABLE(t) taosWLockLatch(&((t)->latch))
#define TSDB_WUNLOCK_TABLE(t) taosWUnLockLatch(&((t)->latch))
STsdbMeta
*
tsdbNewMeta
(
STsdbCfg
*
pCfg
);
STsdbMeta
*
tsdbNewMeta
(
STsdbCfg
*
pCfg
);
void
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
void
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
...
@@ -401,7 +405,7 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
...
@@ -401,7 +405,7 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
STSchema
*
pSchema
=
NULL
;
STSchema
*
pSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
if
(
lock
)
taosRLockLatch
(
&
(
pDTable
->
latch
)
);
if
(
lock
)
TSDB_RLOCK_TABLE
(
pDTable
);
if
(
version
<
0
)
{
// get the latest version of schema
if
(
version
<
0
)
{
// get the latest version of schema
pTSchema
=
pDTable
->
schema
[
pDTable
->
numOfSchemas
-
1
];
pTSchema
=
pDTable
->
schema
[
pDTable
->
numOfSchemas
-
1
];
}
else
{
// get the schema with version
}
else
{
// get the schema with version
...
@@ -423,7 +427,7 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
...
@@ -423,7 +427,7 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
}
}
_exit:
_exit:
if
(
lock
)
taosRUnLockLatch
(
&
(
pDTable
->
latch
)
);
if
(
lock
)
TSDB_RUNLOCK_TABLE
(
pDTable
);
return
pSchema
;
return
pSchema
;
}
}
...
@@ -443,6 +447,11 @@ static FORCE_INLINE STSchema *tsdbGetTableTagSchema(STable *pTable) {
...
@@ -443,6 +447,11 @@ static FORCE_INLINE STSchema *tsdbGetTableTagSchema(STable *pTable) {
}
}
}
}
static
FORCE_INLINE
TSKEY
tsdbGetTableLastKeyImpl
(
STable
*
pTable
)
{
ASSERT
(
pTable
->
lastRow
==
NULL
||
pTable
->
lastKey
==
dataRowKey
(
pTable
->
lastRow
));
return
pTable
->
lastKey
;
}
// ------------------ tsdbBuffer.c
// ------------------ tsdbBuffer.c
#define TSDB_BUFFER_RESERVE 1024 // Reseve 1K as commit threshold
#define TSDB_BUFFER_RESERVE 1024 // Reseve 1K as commit threshold
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
a7c6e73f
...
@@ -159,6 +159,11 @@ _err:
...
@@ -159,6 +159,11 @@ _err:
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_OVER
,
eno
);
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_OVER
,
eno
);
SMemTable
*
pIMem
=
pRepo
->
imem
;
tsdbLockRepo
(
pRepo
);
pRepo
->
imem
=
NULL
;
tsdbUnlockRepo
(
pRepo
);
tsdbUnRefMemTable
(
pRepo
,
pIMem
);
sem_post
(
&
(
pRepo
->
readyToCommit
));
sem_post
(
&
(
pRepo
->
readyToCommit
));
}
}
...
@@ -216,7 +221,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
...
@@ -216,7 +221,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
SCommitIter
*
pIter
=
iters
+
tid
;
SCommitIter
*
pIter
=
iters
+
tid
;
if
(
pIter
->
pTable
==
NULL
)
continue
;
if
(
pIter
->
pTable
==
NULL
)
continue
;
taosRLockLatch
(
&
(
pIter
->
pTable
->
latch
)
);
TSDB_RLOCK_TABLE
(
pIter
->
pTable
);
if
(
tsdbSetHelperTable
(
pHelper
,
pIter
->
pTable
,
pRepo
)
<
0
)
goto
_err
;
if
(
tsdbSetHelperTable
(
pHelper
,
pIter
->
pTable
,
pRepo
)
<
0
)
goto
_err
;
...
@@ -227,7 +232,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
...
@@ -227,7 +232,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
}
}
if
(
tsdbCommitTableData
(
pHelper
,
pIter
,
pDataCols
,
maxKey
)
<
0
)
{
if
(
tsdbCommitTableData
(
pHelper
,
pIter
,
pDataCols
,
maxKey
)
<
0
)
{
taosRUnLockLatch
(
&
(
pIter
->
pTable
->
latch
)
);
TSDB_RUNLOCK_TABLE
(
pIter
->
pTable
);
tsdbError
(
"vgId:%d failed to write data of table %s tid %d uid %"
PRIu64
" since %s"
,
REPO_ID
(
pRepo
),
tsdbError
(
"vgId:%d failed to write data of table %s tid %d uid %"
PRIu64
" since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pIter
->
pTable
),
TABLE_TID
(
pIter
->
pTable
),
TABLE_UID
(
pIter
->
pTable
),
TABLE_CHAR_NAME
(
pIter
->
pTable
),
TABLE_TID
(
pIter
->
pTable
),
TABLE_UID
(
pIter
->
pTable
),
tstrerror
(
terrno
));
tstrerror
(
terrno
));
...
@@ -235,7 +240,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
...
@@ -235,7 +240,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitH *pch) {
}
}
}
}
taosRUnLockLatch
(
&
(
pIter
->
pTable
->
latch
)
);
TSDB_RUNLOCK_TABLE
(
pIter
->
pTable
);
// Move the last block to the new .l file if neccessary
// Move the last block to the new .l file if neccessary
if
(
tsdbMoveLastBlockIfNeccessary
(
pHelper
)
<
0
)
{
if
(
tsdbMoveLastBlockIfNeccessary
(
pHelper
)
<
0
)
{
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
a7c6e73f
...
@@ -74,9 +74,9 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
...
@@ -74,9 +74,9 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
tsdbDebug
(
tsdbDebug
(
"vgId:%d tsdb env create succeed! cacheBlockSize %d totalBlocks %d daysPerFile %d keep "
"vgId:%d tsdb env create succeed! cacheBlockSize %d totalBlocks %d daysPerFile %d keep "
"%d minRowsPerFileBlock %d maxRowsPerFileBlock %d precision %d compression %d"
,
"%d minRowsPerFileBlock %d maxRowsPerFileBlock %d precision %d compression %d
update %d cacheLastRow %d
"
,
pCfg
->
tsdbId
,
pCfg
->
cacheBlockSize
,
pCfg
->
totalBlocks
,
pCfg
->
daysPerFile
,
pCfg
->
keep
,
pCfg
->
minRowsPerFileBlock
,
pCfg
->
tsdbId
,
pCfg
->
cacheBlockSize
,
pCfg
->
totalBlocks
,
pCfg
->
daysPerFile
,
pCfg
->
keep
,
pCfg
->
minRowsPerFileBlock
,
pCfg
->
maxRowsPerFileBlock
,
pCfg
->
precision
,
pCfg
->
compression
);
pCfg
->
maxRowsPerFileBlock
,
pCfg
->
precision
,
pCfg
->
compression
,
pCfg
->
update
,
pCfg
->
cacheLastRow
);
return
0
;
return
0
;
}
}
...
@@ -281,6 +281,10 @@ int32_t tsdbConfigRepo(TSDB_REPO_T *repo, STsdbCfg *pCfg) {
...
@@ -281,6 +281,10 @@ int32_t tsdbConfigRepo(TSDB_REPO_T *repo, STsdbCfg *pCfg) {
config
.
totalBlocks
=
pCfg
->
totalBlocks
;
config
.
totalBlocks
=
pCfg
->
totalBlocks
;
configChanged
=
true
;
configChanged
=
true
;
}
}
if
(
pRCfg
->
cacheLastRow
!=
pCfg
->
cacheLastRow
)
{
config
.
cacheLastRow
=
pCfg
->
cacheLastRow
;
configChanged
=
true
;
}
if
(
configChanged
)
{
if
(
configChanged
)
{
if
(
tsdbSaveConfig
(
pRepo
->
rootDir
,
&
config
)
<
0
)
{
if
(
tsdbSaveConfig
(
pRepo
->
rootDir
,
&
config
)
<
0
)
{
...
@@ -475,6 +479,9 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
...
@@ -475,6 +479,9 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
// update check
// update check
if
(
pCfg
->
update
!=
0
)
pCfg
->
update
=
1
;
if
(
pCfg
->
update
!=
0
)
pCfg
->
update
=
1
;
// update cacheLastRow
if
(
pCfg
->
cacheLastRow
!=
0
)
pCfg
->
cacheLastRow
=
1
;
return
0
;
return
0
;
_err:
_err:
...
@@ -696,10 +703,12 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
...
@@ -696,10 +703,12 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
}
}
}
}
static
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
)
{
static
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
)
{
// TODO
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
SFileGroup
*
pFGroup
=
NULL
;
SFileGroup
*
pFGroup
=
NULL
;
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
SCompBlock
*
pBlock
=
NULL
;
SFileGroupIter
iter
;
SFileGroupIter
iter
;
SRWHelper
rhelper
=
{
0
};
SRWHelper
rhelper
=
{
0
};
...
@@ -717,7 +726,32 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) {
...
@@ -717,7 +726,32 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) {
if
(
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
pRepo
)
<
0
)
goto
_err
;
if
(
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
pRepo
)
<
0
)
goto
_err
;
SBlockIdx
*
pIdx
=
&
(
rhelper
.
curCompIdx
);
SBlockIdx
*
pIdx
=
&
(
rhelper
.
curCompIdx
);
if
(
pIdx
->
offset
>
0
&&
pTable
->
lastKey
<
pIdx
->
maxKey
)
pTable
->
lastKey
=
pIdx
->
maxKey
;
TSKEY
lastKey
=
tsdbGetTableLastKeyImpl
(
pTable
);
if
(
pIdx
->
offset
>
0
&&
lastKey
<
pIdx
->
maxKey
)
{
pTable
->
lastKey
=
pIdx
->
maxKey
;
if
(
pCfg
->
cacheLastRow
)
{
// load the block of data
if
(
tsdbLoadCompInfo
(
&
rhelper
,
NULL
)
<
0
)
goto
_err
;
pBlock
=
rhelper
.
pCompInfo
->
blocks
+
pIdx
->
numOfBlocks
-
1
;
if
(
tsdbLoadBlockData
(
&
rhelper
,
pBlock
,
NULL
)
<
0
)
goto
_err
;
// construct the data row
ASSERT
(
pTable
->
lastRow
==
NULL
);
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pTable
);
pTable
->
lastRow
=
taosTMalloc
(
schemaTLen
(
pSchema
));
if
(
pTable
->
lastRow
==
NULL
)
{
goto
_err
;
}
tdInitDataRow
(
pTable
->
lastRow
,
pSchema
);
for
(
int
icol
=
0
;
icol
<
schemaNCols
(
pSchema
);
icol
++
)
{
STColumn
*
pCol
=
schemaColAt
(
pSchema
,
icol
);
SDataCol
*
pDataCol
=
rhelper
.
pDataCols
[
0
]
->
cols
+
icol
;
tdAppendColVal
(
pTable
->
lastRow
,
tdGetColDataOfRow
(
pDataCol
,
pBlock
->
numOfRows
-
1
),
pCol
->
type
,
pCol
->
bytes
,
pCol
->
offset
);
}
}
}
}
}
}
}
...
@@ -804,6 +838,7 @@ static int tsdbEncodeCfg(void **buf, STsdbCfg *pCfg) {
...
@@ -804,6 +838,7 @@ static int tsdbEncodeCfg(void **buf, STsdbCfg *pCfg) {
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
precision
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
precision
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
compression
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
compression
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
update
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
update
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pCfg
->
cacheLastRow
);
return
tlen
;
return
tlen
;
}
}
...
@@ -821,6 +856,7 @@ static void *tsdbDecodeCfg(void *buf, STsdbCfg *pCfg) {
...
@@ -821,6 +856,7 @@ static void *tsdbDecodeCfg(void *buf, STsdbCfg *pCfg) {
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
precision
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
precision
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
compression
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
compression
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
update
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
update
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pCfg
->
cacheLastRow
));
return
buf
;
return
buf
;
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbMeta.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/inc/hash.h
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/inc/tconfig.h
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/inc/tref.h
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/inc/tsocket.h
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/hash.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tcache.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tconfig.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tlog.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tnettest.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tskiplist.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/tsocket.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/util/src/ttimer.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/inc/vnodeInt.h
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/src/vnodeCfg.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/src/vnodeMain.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/src/vnodeMgmt.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/src/vnodeRead.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
src/vnode/src/vnodeWrite.c
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/Jenkinsfile
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/concurrent_inquiry.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/crash_gen/crash_gen_main.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/crash_gen/db.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/crash_gen/misc.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/crash_gen_bootstrap.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/handle_crash_gen_val_log.sh
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileH.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileHO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileHPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileS.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileSub.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileT.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileTO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importCacheFileTPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataH2.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataHO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataHO2.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataHPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastH.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastHO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastHPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastS.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastSub.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastT.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastTO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataLastTPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataS.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataSub.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataT.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataTO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importDataTPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importHORestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importHPORestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importHRestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importInsertThenImport.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastH.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastHO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastHPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastS.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastSub.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastT.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastTO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importLastTPO.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importSRestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importSubRestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importTORestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importTPORestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/import_merge/importTRestart.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/insert/restfulInsert.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/pytest_1.sh
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/pytest_2.sh
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/query/query.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/pytest/table/alter_wal0.py
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/db/alter_tables_d2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/db/alter_tables_v1.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/db/alter_tables_v4.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/db/delete_reusevnode.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/db/delete_writing1.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/http/restful_full.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/parser/mixed_blocks.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/table/delete_writing.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/general/wal/sync.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/jenkins/basic_3.txt
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/jenkins/unique.txt
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/sh/deploy.sh
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/sync_replica_alterTable_background_add.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/big/balance.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/big/tcp.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/cluster/balance1.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/cluster/balance2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/cluster/balance3.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/cluster/vgroup100.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/delete.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/delete_part.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_add12.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_add13.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_add23.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_part.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_reduce21.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_reduce31.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/db/replica_reduce32.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/balance1.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/balance2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/balance3.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/offline3.sim
0 → 100644
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/reason.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/remove1.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/remove2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/dnode/vnode_clean.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/import/replica2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/import/replica3.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt20.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt22.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt23.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt33.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt34.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmtr2.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/vnode/many.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/vnode/replica2_repeat.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/vnode/replica3_basic.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/script/unique/vnode/replica3_repeat.sim
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
tests/test-all.sh
浏览文件 @
a7c6e73f
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录