0

我有一个多线程 Pro*C 程序,它在单独的连接和运行时上下文的每个线程中调用匿名存储过程。

我的匿名过程调用需要不同的时间框架才能从过程中返回,有时它甚至会无限期挂起。正如 AWR 日志中所示,我的 Oracle 过程只需 0.05 秒即可返回,但令人惊讶的是,Pro*C 调用需要 5 秒才能从过程中返回。

Pro*C 过程调用和实际 Oracle 过程执行之间涉及的处理活动是什么?是否有任何锁或其他阻塞问题?

4

2 回答 2

0

您可以尝试 Oracle 跟踪 (DBMS_MONITOR) 并查看跟踪文件中的最后一个活动。我能想到的唯一可能正确考虑时间的事情是,如果过程返回一个大值(BLOB、CLOB、XML),这需要时间通过网络返回给客户端(或者客户端阻塞在接收数据的大小)。

于 2011-06-09T23:05:29.140 回答
0

如果它无限期地挂起,那么是的,涉及某种类型的阻塞(或轮询等......函数中发生了一些事情导致它不返回)。

根据您在此问题上发布的其他问题,如果您只想杀死已挂起的特定线程,那么您可以查看的是将线程 ID 设置为其中包含“已完成”标志的结构。

#include <pthread.h>
#include <signal.h>

struct thread_id
{
    pthread_t thread;
    sig_atomic_t thread_flag;
};

void init_thread_id(struct thread_id* id)
{
    id->thread_flag = 0;
}

thread_id threads[NUMBER_OF_THREADS];

void* thread_function(void* arg)
{
    thread_id* my_id = (thread_id*)arg;

    //do something in your thread

    //when you finish, set the flag for that thread
    my_id->thread_flag = 1;
}

现在,当您设置超时警报时,只需滚动浏览数组thread_id,然后查看哪些已完成。完成的那些,你可以调用,否则你可以使用或停止线程向pthread_join线程发送信号。pthread_killpthread_cancel

于 2011-06-09T13:06:50.953 回答