BDE多线程错误:遇到ora-12560时,无法重启TDatabase

发布于 2024-07-26 08:40:51 字数 810 浏览 3 评论 0原文

我们有一个很大的程序,使用BDE+oracle,由delphi开发, 我们使用3个线程来执行数据库操作,它们使用单​​独的TSession。 (1个守护线程,1个数据收集线程,1个检查线程)

我们使用这个结构:

T查询-> T数据库-> TSession

我们用这个方法来做查询:

try
  qu.close;  //TQuery
  qu.sql.clear;
  qu.sql.add('select foo from db_foos');
  qu.open;
except
  on e:Exception do
  begin
    db.close; // db is TDatabase, We use this to auto restart connection when network fail.
    error(e.message);
  end;
end;

问题是,当我们的程序运行超过24小时时, ora-12560 出现,我们的程序无法重新启动连接,并且在执行查询时不断报告此错误。

我们检查了代码,调试了一个星期,仍然无法解决, 你们遇到同样的问题吗?

编辑:

我们有这个测试用例:

3 个程序,每个程序运行一个线程(睡眠 1 秒),并且在 0.5 - 1 小时之间,它们都同时失败。 (3个DB操作,和1个Indy9 ftp客户端...)

所以我认为BDE或Windows套接字有问题... 目前我正在研究自动重启程序机制作为解决方法。

We have a big program, using BDE + oracle, developed by delphi,
We use 3 threads to do DB operations, they are using separated TSession.
(1 deamon thread, 1 data collect thread, 1 checking thread)

We use this structure:

TQuery -> TDatabase -> TSession

We use this method to do query:

try
  qu.close;  //TQuery
  qu.sql.clear;
  qu.sql.add('select foo from db_foos');
  qu.open;
except
  on e:Exception do
  begin
    db.close; // db is TDatabase, We use this to auto restart connection when network fail.
    error(e.message);
  end;
end;

the problem is, when our program run more than 24 hours,
ora-12560 arise, and our program cannot restart connection, and keep report this error when execute queries.

We had reviewed code, debugged all week long, and still cannot solve it,
do you guys encounter the same problem?

edit:

We have this test case:

3 program, each run one thread(with 1 second sleep), and between 0.5 - 1 hour, They all failed at the same time.
(3 DB operation, and 1 Indy9 ftp client...)

So I think there is something wrong in BDE or Windows socket...
Current I am working on a auto restart program machanism as a workaround.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江挽川 2024-08-02 08:40:51

显然,Oracle 客户端忘记它应该连接的位置是一个常见问题。 也许其中之一会有所帮助:

http://www.cryer.co.uk /brian/oracle/ORA12560.htm

http://www.dba-oracle. com/t_ora_12560_tns_protocol_adapter_error.htm

Apparently it's a common problem where the Oracle client forgets where it's supposed to be connecting. Perhaps one of these will help:

http://www.cryer.co.uk/brian/oracle/ORA12560.htm

http://www.dba-oracle.com/t_ora_12560_tns_protocol_adapter_error.htm

十二 2024-08-02 08:40:51

有一个单独的基于计时器的例程来保持数据库始终打开 - 这就是我们根据上面的评论所做的。 IE 当数据库断开连接时,立即重新打开它,不要依赖查询来自动打开它。 使用计时器定期检查数据库是否仍然(真正)打开。 通过这种方式,我们不使用单独的线程并避免跨线程问题,但在我们的例子中,每个客户端都有一个连接。 每台客户端 PC 都会收集数据,并且工厂中有许多客户端 PC。

在您的情况下,您可能需要在每个线程中都有数据库检查例程。

Have a seperate timer-based routine to keep the DB open at all times - that's what we do per my comment above. IE when the Database disconnects, then re-open it immediately, do not rely on the query to auto-open it for you. Use a timer to check periodically if the database is still (really) open. In this way we do not use a seperate thread and avoid cross-thread problems, but in our case we have one connection per client. Each client PC collects data and there are many client PC's in the factory.

In your case you may need to have the DB checking routine within every thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文