Code Monkey home page Code Monkey logo

Comments (1)

aricc avatar aricc commented on May 29, 2024 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.