DBD::Oracle9 and non-blocking mode

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default 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


    Jim Cain Guest

  2. Similar Questions and Discussions

    1. #20745 [Com]: socket_accept() in blocking mode doesn't handle signal interrupts
      ID: 20745 Comment by: antoine dot bajolet at tdf dot fr Reported By: polone at townnews dot com Status: No...
    2. #25309 [Opn->Bgs]: stream_set_blocking() doesn't set non-blocking mode
      ID: 25309 Updated by: wez@php.net Reported By: flugelaar at pandora dot be -Status: Open +Status: ...
    3. #25309 [NEW]: stream_set_blocking() doesn't set non-blocking mode
      From: flugelaar at pandora dot be Operating system: Linux Slackware 9.0 PHP version: 5CVS-2003-08-29 (dev) PHP Bug Type: ...
    4. Will Thread blocking in read() leads to process blocking?
      Hi! Yes, the outcome depends on the threads implementation. However, it is incorrect to believe that a POSIX conformant implementation won't...
    5. :Oracle9 and non-blocking mode
      Hi Jim, I use it to timeout connect calls when a database is either down and/or unreachable for some reason. This is rare, but it does happen,...
  3. #2

    Default Re: DBD::Oracle9 and non-blocking mode

    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?
    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.

    Brian Candler Guest

  4. #3

    Default Re: DBD::Oracle9 and non-blocking mode

    Brian Candler <B.Candler@pobox.com> writes:
    > 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?
    >
    > 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.
    [url]http://www.jiubao.org/ruby-oci8/ruby-oci8-v0.2-unusable-2003-0626/oci8.h[/url]
    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?

    --
    KUBO Takehiro



    KUBO Takehiro Guest

  5. #4

    Default Re: DBD::Oracle9 and non-blocking mode

    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?
    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.

    Brian Candler Guest

  6. #5

    Default Re: DBD::Oracle9 and non-blocking mode

    Brian Candler <B.Candler@pobox.com> writes:
    > 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?
    >
    > 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.

    --
    KUBO Takehiro



    KUBO Takehiro Guest

  7. #6

    Default Re: DBD::Oracle9 and non-blocking mode

    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.
    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.

    Brian Candler Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139