Comments (1)
问题确实已经解决了,原因如下:
问题解决前,我的做法是,用一个单例对象在程序启动时连接TDengine,并一直持有Connection,在需要写入数据时,直接从这个单例对象获取数据库连接,并写入数据。
后来实在没办法,我在服务器上安装了抓包工具,发现每次提交数据时,数据包中都包含了大量很早时间前的已经写入的数据。我就想到是不是因为没有一个“提交”动作,TDengine客户端认为之前发送的数据没有执行成功,导致其每次都是把累积的insert语句全部执行一遍,这才导致了带宽的迅速上升?同时也在看官方连接器相关文档中的示例代码,Insert之后有一个Close动作,还有一个CleanUp动作。
我就修改了代码,不再在程序启动时连接TDengine了,每次需要操作TDengine的时候创建数据库连接,写入或查询数据,然后立即关闭连接,并CleanUp。
但观察发现只能写入一次,后面就写入不了了。
我就把最后的CleanUp去掉,只保留Close。
然后就可以正常的写入数据了,随后跟踪观察了2个小时,带宽一直在几十Kb/s的正常水平,问题解决。
另外 ,上面的问题,不只是带宽被占满,还有以下的并发症:
1、CPU使用率也会在一定时间内(比带宽占满用的时间长一点,大约是3、4个小时)达到95%以上。
2、TDengine客户端安装目录下的log目录会以极高的速度打印在短时间内打印出超大的日志,每个日志文件可达800~900M左右。日志内容清一色的是“QRY WARN Acquire sch job failed,may be dropped jobid:0x0”
代码调整后,以上问题也都不存在了。
总结:
我觉得在数据库的使用说明上还不够详细。包括Connector的示例代码。不需要Commit就可以成功写入数据 ,就导致我认为TDengine是自动提交的。但没想到客户端并没有这么认为。
今天我对比了官网的示例代码与Github的示例代码,Github上的对CleanUp和FreeResult操作是有注释解释的,但官网没有。
如果像Github的示例代码一样,在每一步操作上作一个简短的说明,解释一下每一步这么做的目的、不做的后果,也就不会这样的事了。
疑问:
1、为什么一定要Close?或者是否有其它的操作可以替代Close,从而不用每次操作数据库都要创建连接,关闭连接?
2、如果确实就是要每次都Close,那这样高频的创建连接、关闭连接,不会影响性能和写入效率吗?
from taos-connector-dotnet.
Related Issues (20)
- 建议增加 .Net Standard 2.0 支持 HOT 1
- 连接多次开关报错Attempted to read or write protected memory. This is often an indication that other memory is corrupt. HOT 2
- 升级3.0.0后无法连接3.0版本的tdengine HOT 8
- 内存占用会不断的升高(Memory Leak) HOT 2
- 找不到指定模块taosdata.dll HOT 8
- 使用3.0版本的c#驱动可以连接旧版本的TDengine吗? HOT 8
- 释放连接后重新创建连接失败 HOT 9
- 批量绑定插入的时候,C#代码和JAVA的不一样的方式,导致大数量插入无法方便使用。 HOT 9
- 请问什么时候实现ADO.NET的驱动 ,人家QuestDB都有
- 请问客户端支持 Windows x86 吗 HOT 2
- bug: show tables 返回垃圾字符
- error:some vnode/qnode/mnode(s) out of service HOT 1
- linux
- linux下调用共享库报错:unable to load shared library 'taos' or one of its dependencies HOT 1
- bug:TMQ的ConsumerConfig的TDConnectUser属性与ip地址重复 HOT 1
- 新类型varbinary支持
- 没有支持使用配置文件进行连接 直接获取连接的方法吗。
- ws连接模式下 tag字段是 nchar类型的时候,返回乱码
- 3.1.0、3.1.1版本下使用stmt写入内存不断增长
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from taos-connector-dotnet.