0

I have a multithreaded Pro*C program which calls anonymous stored procedures in each thread on separate connections and runtime contexts.

My anonymous procedure calls takes different time frames to return from the procedure and sometimes it even hangs indefinitely. My Oracle procedure takes just 0.05 seconds to return as it is shown in AWR logs but surprisingly the Pro*C call takes 5 seconds to return from procedure.

What is the processing activity involved between the Pro*C procedure call and actual Oracle procedure execution? Are any locks or other blocking issues?

Mat
  • 202,337
  • 40
  • 393
  • 406
Sal
  • 11
  • 1
  • 6
  • for blocking, see my answer: http://stackoverflow.com/questions/6046502/oracle-materialized-view-alter-structure-so-slow – tbone Jun 09 '11 at 12:58
  • Mathew, the case you specified here is different from what i am currently facing, my actual oracle procedure call is completing within 0.3 secs and but my pro*c call to the same procedure is taking around 5 secs to return. – Sal Jun 09 '11 at 15:53
  • i'm tbone, not Mathew ;-) My (tbone) answer has the SQL needed to find blocking session info (if any)...you mentioned "hanging" indefinitely, that sounds like a blocking issue maybe – tbone Jun 09 '11 at 16:13
  • Tbone , its not problem with stored procedure (SQL) but it seems to be problem with interface between pro*c and oracle stored procedure. wanted to know what exactly happens when anonymous PL/SQL statement is called from pro*c – Sal Jun 09 '11 at 20:00
  • does each thread have its own connection, or are you trying to share? – EvilTeach Sep 15 '12 at 17:04

2 Answers2

0

If it's hanging indefinitely, then yes, there is some type of blocking involved (or polling, etc. ... something is happening in the function causing it not to return).

From your other question you posted on this matter, if you want to just kill a specific thread that has hanged, then on thing you can look at is to setup your thread ID's as a struct that has a "finished" flag in it.

#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;
}

Now when you set your timeout alarm, simply scroll through the array of thread_id, and see which ones are finished. The ones that are finsihed, you can call pthread_join on, otherwise you can send a signal to the thread using pthread_kill or pthread_cancel to stop the thread.

Jason
  • 31,834
  • 7
  • 59
  • 78
  • jason, Thanks for your concern and detailed explaination , My greatest worry is pro*c anonymous procedure call is not returning (hanging indefinately) while actual procedure in oracle has returned . i am trying to understand activities involved between procedure call in pro*c and actual procedure in oracle. so that we can tune it if possible !!! – Sal Jun 09 '11 at 15:41
0

You could try an Oracle trace (DBMS_MONITOR) and see what the last activity is in the trace file. The only thing I can think of that might properly account for the time is if the procedure returns a large value (BLOB, CLOB, XML) which is taking time to return back to the client over the network (or where the client chokes on the size of received data).

Gary Myers
  • 34,963
  • 3
  • 49
  • 74
  • ok, but its multithreaded client , where around 200 threads (clients) will calling same procedure again and again for around 800 transactions per thread(client). procedure will not hang always but some random times it hangs and never returns at all. – Sal Jun 11 '11 at 13:43