DBD::Oracle9 and non-blocking mode

I’m about ready to make available an early copy of my library, but first
I have some questions regarding non-blocking mode. I’ve never actually
used this feature, so I’d like to hear from those that do how they use
it. Do you need more support for it beyond simply setting/resetting the
mode? What is the most convenient way for you to be notified that an OCI
call is still executing? When a call is still running, would you like to
call Statement#execute again to see if it’s finished, or would you like
some other method?

Thanks for the input.

Cheers,
Jim

Out of curiosity, will binaries (for Win32, specifically), be distributed?

···

-----Original Message-----
From: Jim Cain [mailto:list@jimcain.us]
Sent: Tuesday, July 01, 2003 11:04 AM
To: ruby-talk ML
Subject: DBD::Oracle9 and non-blocking mode

I’m about ready to make available an early copy of my library, but first
I have some questions regarding non-blocking mode. I’ve never actually
used this feature, so I’d like to hear from those that do how they use
it. Do you need more support for it beyond simply setting/resetting the
mode? What is the most convenient way for you to be notified that an OCI
call is still executing? When a call is still running, would you like to
call Statement#execute again to see if it’s finished, or would you like
some other method?

Thanks for the input.

Cheers,
Jim

I have used it briefly: setting non-blocking mode on Takehiro’s ruby-oci8
library, I was able to get several threads to run concurrent slow Oracle
queries. It didn’t need any special support for notification; I just let
each thread block until its particular query had finished. (ruby-oci8 deals
with this by polling the OCI library at increasing intervals until OCI says
the query has completed, and then fetches the results)

However, I wasn’t particularly happy with this approach, so in the end I
changed my application to run as multiple processes (in fact running under
FastCGI, so Apache controls the number of processes which are spawned), each
of which is a single thread so I don’t care if OCI blocks.

Regards,

Brian.

···

On Wed, Jul 02, 2003 at 01:04:00AM +0900, Jim Cain wrote:

I’m about ready to make available an early copy of my library, but first
I have some questions regarding non-blocking mode. I’ve never actually
used this feature, so I’d like to hear from those that do how they use
it. Do you need more support for it beyond simply setting/resetting the
mode? What is the most convenient way for you to be notified that an OCI
call is still executing? When a call is still running, would you like to
call Statement#execute again to see if it’s finished, or would you like
some other method?

Michael Campbell wrote:

Out of curiosity, will binaries (for Win32, specifically), be distributed?

From: Jim Cain [mailto:list@jimcain.us]
Sent: Tuesday, July 01, 2003 11:04 AM
To: ruby-talk ML
Subject: DBD::Oracle9 and non-blocking mode

I’m about ready to make available an early copy of my library, but first
I have some questions regarding non-blocking mode. I’ve never actually
used this feature, so I’d like to hear from those that do how they use
it. Do you need more support for it beyond simply setting/resetting the
mode? What is the most convenient way for you to be notified that an OCI
call is still executing? When a call is still running, would you like to
call Statement#execute again to see if it’s finished, or would you like
some other method?

Thanks for the input.

Cheers,
Jim

No, I won’t be making Win32 binaries myself. I’ve never developed native
Win32 apps, and I don’t have a Win32 development environment. All my
coding is on Linux.

···

-----Original Message-----

Brian Candler B.Candler@pobox.com writes:

I’m about ready to make available an early copy of my library, but first
I have some questions regarding non-blocking mode. I’ve never actually
used this feature, so I’d like to hear from those that do how they use
it. Do you need more support for it beyond simply setting/resetting the
mode? What is the most convenient way for you to be notified that an OCI
call is still executing? When a call is still running, would you like to
call Statement#execute again to see if it’s finished, or would you like
some other method?

I have used it briefly: setting non-blocking mode on Takehiro’s ruby-oci8
library, I was able to get several threads to run concurrent slow Oracle
queries. It didn’t need any special support for notification; I just let
each thread block until its particular query had finished. (ruby-oci8 deals
with this by polling the OCI library at increasing intervals until OCI says
the query has completed, and then fetches the results)

I implemented it in the ruby layer.
In the next release I do it in the C API layer.
See the macro oci_rc2 in the following URL.
http://www.jiubao.org/ruby-oci8/ruby-oci8-v0.2-unusable-2003-0626/oci8.h
Its license is same with ruby. So you can freely use its code fragment
in your library or application.

However, I wasn’t particularly happy with this approach, so in the end I
changed my application to run as multiple processes (in fact running under
FastCGI, so Apache controls the number of processes which are spawned), each
of which is a single thread so I don’t care if OCI blocks.

Hmm. What approach you prefer?

···

On Wed, Jul 02, 2003 at 01:04:00AM +0900, Jim Cain wrote:


KUBO Takehiro

“Jim Cain” list@jimcain.us wrote in message

Michael Campbell wrote:

Out of curiosity, will binaries (for Win32, specifically), be
distributed?

[snip]

No, I won’t be making Win32 binaries myself. I’ve never developed native
Win32 apps, and I don’t have a Win32 development environment. All my
coding is on Linux.

I will volunteer to generate Win32 binaries (using VC++ 6.0) … if that is
OK by y’all !

It just seemed to work faster when I had five separate processes doing
Oracle queries, than one process with five threads. Also, using
Apache/Fastcgi gave me a ready-made mechanism for creating a pool of
processes and automatically restarting them if one fails. Using threads I’d
have to write my own thread manager to do that.

Cheers,

Brian.

···

On Wed, Jul 02, 2003 at 01:03:12PM +0900, KUBO Takehiro wrote:

However, I wasn’t particularly happy with this approach, so in the end I
changed my application to run as multiple processes (in fact running under
FastCGI, so Apache controls the number of processes which are spawned), each
of which is a single thread so I don’t care if OCI blocks.

Hmm. What approach you prefer?

Brian Candler B.Candler@pobox.com writes:

However, I wasn’t particularly happy with this approach, so in the end I
changed my application to run as multiple processes (in fact running under
FastCGI, so Apache controls the number of processes which are spawned), each
of which is a single thread so I don’t care if OCI blocks.

Hmm. What approach you prefer?

It just seemed to work faster when I had five separate processes doing
Oracle queries, than one process with five threads.

My approach wastes time. Undoubtedly your prospect is correct in
theory. OCI lacks any notification method whether the OCI call is
finished or not. So I use polling as a last resort.

I have one idea:

  1. create a native thread per one connection by using OCI thread APIs.
  2. when executing a OCI call which may be blocked, request the
    associated native thread to execute it, then stop its ruby thread
    by calling rb_thread_stop().
  3. after OCI call is finished, the associated native thread wakes up
    the ruby thread by calling rb_thread_wakeup().
    But I hadn’t tested it. I don’t know whether it works.

Also, using
Apache/Fastcgi gave me a ready-made mechanism for creating a pool of
processes and automatically restarting them if one fails. Using threads I’d
have to write my own thread manager to do that.

Thanks.

···

On Wed, Jul 02, 2003 at 01:03:12PM +0900, KUBO Takehiro wrote:


KUBO Takehiro

And I forgot to add: even if non-blocking mode works in Oracle, it doesn’t
work in Mysql. So my code is more portable if I don’t rely on this feature.

Regards,

Brian.

···

On Thu, Jul 03, 2003 at 01:00:00PM +0900, KUBO Takehiro wrote:

Also, using
Apache/Fastcgi gave me a ready-made mechanism for creating a pool of
processes and automatically restarting them if one fails. Using threads I’d
have to write my own thread manager to do that.

Thanks.