线程在调用存储过程时阻塞,再也不会返回. [英] thread blocks upon calling a stored procedure and never come back.

查看:125
本文介绍了线程在调用存储过程时阻塞,再也不会返回.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个大问题.我在互联网上搜索了很多东西,但找不到任何东西,这回答了我的问题.

纪要:
1-该应用程序是用C ++编写的.
2-应用程序是多线程的.
3-应用程序使用otlv4库与oracle 10g DB引擎通信.
4-在包含otlv4.h之前使用的预处理器是:
"#define OTL_ORA10G_R2//编译OTL 4.0/OCI10gR2"
"#define OTL_STL"

5-平台是Unix,Solaris10.

问题是:
-一个工作线程在调用存储过程时阻塞,并且永远不会回来.
-这是在不同时间随机发生的.
-即使经过长时间的调用,也不会引发任何异常.

目标:
1-我需要知道为什么会这样,还有什么可能的原因呢?
2-除了监视线程之外,我还对如何处理此问题表示赞赏和建议.

在此先感谢您.

Hi everybody,

I have a big issue. I searched a lot in internet, but could''t find anything, that answered my question.

Givens:
1- The application is written in C++.
2- The application is multithreaded.
3- The application communicates with oracle 10g DB engine using otlv4 library.
4- The preprocessors used before including otlv4.h are:
"#define OTL_ORA10G_R2 // Compile OTL 4.0/OCI10gR2"
"#define OTL_STL"

5- The platform is Unix, Solaris 10.

The problem is:
- One of the working threads block upon invoking a stored procedure and never come back.
- This happens randomly on different times.
- There are no exceptions thrown even after a long time of invocation.

Objective:
1- I need to know why this occurs and what are the possible reasons beyond this.
2- I also appreciate and advice on how to handle this problem other than monitoring threads.

Thanks in advance.

推荐答案

您在每个线程使用一个连接/会话吗?

根据您的问题"描述,我怀疑您有并发问题.

我个人更喜欢使用 Oracle C ++调用接口 [ http://download.oracle.com/docs/cd/B28359_01/appdev. 111/b28395/toc.htm [ ^ ]

>>其中一个工作线程块
>>一旦调用存储过程,再也不会回来.
>>这是在不同时间随机发生的.
>>即使经过长时间的调用也不会引发异常.

从您的描述中,我觉得症状"与一个细微的并发错误是一致的,但这只是我的感觉...

大约五年前,我在OTL和Oracle上工作了一段时间,最终使用了C ++ Builder和Allround Automations的Direct Oracle Access.显然,该选项对您不可用.当我最初在基于OTL的方法上投入大量工作时,我从未对结果感到非常满意,感觉到很多事情都无法控制.

恕我直言:OTL竭尽全力为用户提供C ++的api,我觉得它不如基于Oracle C ++调用接口的代码易读. OCCI看起来有点像Javaish,但是很清楚代码中发生了什么.我猜想OCCI比OTL还要用在更多的生产场景中,但这是一个无条件的猜测.

我已经使用Oracle作为RDBMS开发了许多多线程服务器应用程序.我直接与OCI合作,而我使用OCCI,事实证明,一旦我使用它们,基于这两种方法的解决方案将非常稳定.这些应用程序严重依赖 ACE [
You are using one connection/session per thread?

Based on your "problem" description, I suspect that you have concurrency issues.

Personally I prefer using Oracle C++ Call Interface[^]

For more info on OCI (used by OTL) see
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28395/toc.htm[^]

>>One of the working threads block
>>upon invoking a stored procedure and never come back.
>>This happens randomly on different times.
>>There are no exceptions thrown even after a long time of invocation.

From your description I feel that "the symptoms" are consistent with a subtle concurrency bug, but that''s just my feeling...

About five years ago I played a bit around with OTL and Oracle, I ended up using C++ Builder with Direct Oracle Access from Allround Automations. Obviously that option isn''t available to you. While I initially invested a lot of work in the OTL based approach I never became really happy with the result, feeling that to much was out of my control.

IMHO: OTL tries far to hard to present the user with a C++ish api, which I feel isn''t quite as readable as code based on Oracle C++ Call Interface. OCCI may seem a bit javaish, but it''s quite clear what''s going on in your code. I would guess OCCI is also used in a lot more production scenarios than OTL, but that''s an unqualified guess.

I''ve developed a number of multithreaded server applications using Oracle as the RDBMS. I''ve worked directly with OCI and I''ve used OCCI, solutions based on both approaches has proven to be very stable once I have them working. Those applications relied heavily on ACE[^], and ACE has pretty serious error handling and logging features, that has enabled me to detect errors, find their location and fix them pretty fast.

I haven''t a clue about what''s wrong with your application, but gave it a best shot based on very little information from your side.

Best of luck
Espen Harlinn


这篇关于线程在调用存储过程时阻塞,再也不会返回.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆