Re: [External] : callTimeout takes no effect (cx_Oracle 8.1; Oracle client 18.3)

Christopher Jones <[email protected]> Mon, 26 Apr 2021 16:34:00 +1000
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <[email protected]>
--===============2292819431725574436==
Content-Type: multipart/alternative;
 boundary="------------423D3A74D61A4AE810071ACF"
Content-Language: en-US

--------------423D3A74D61A4AE810071ACF
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit


On 23/4/21 2:28 pm, Zongheng Yang wrote:
> Found the issue: The Linux user "oracle" for some reason is not able to receive any signals.  Switching to root makes everything work now.

The OCI developers tell me that the timeout will not work with IPC connections.

Maybe that was what you were seeing?

I've filed a doc bug to improve the doc.

Chris

>
> On Thu, Apr 22, 2021 at 8:02 PM Zongheng Yang <[email protected] <mailto:[email protected]>> wrote:
>
>     Tried out upgrading Oracle 19c, and optionally adding to the script (the dir in which the modified sqlnet.ora lives):
>
>     cx_Oracle.init_oracle_client(config_dir="/u01/app/oracle/product/19.0.0/dbhome_1/network/admin")
>
>     Same issue still persists.  OS is Oracle Linux 7.7.
>
>     $ python test.py
>     8.1.0 (19, 3, 0, 0, 0)
>     Call timeout set at 500 milliseconds...
>     Fetch of current date before timeout: 2021-04-23 03:01:27
>     Sleeping...should time out...
>     Fetch of current date after timeout: 2021-04-23 03:01:37
>
>
>
>     On Thu, Apr 22, 2021 at 3:59 PM Zongheng Yang <[email protected] <mailto:[email protected]>> wrote:
>
>         Thanks for the quick response!
>
>         (base) [oracle@oracle-test18 ~]$ grep disable_oob $ORACLE_HOME/network/admin/sqlnet.ora
>         #disable_oob = ON
>         disable_oob = ON
>
>         With this change, and running SHUTDOWN then STARTUP, the same issue persists.  No timeout effect.
>
>
>         On Thu, Apr 22, 2021 at 3:51 PM Christopher Jones <[email protected] <mailto:[email protected]>> wrote:
>
>
>             On 23/4/21 8:44 am, ConcreteVitamin wrote:
>>             Hi,
>>
>>             I'm using the following script, modified from samples/CallTimeout.py (changing into cx_Oracle.connect(mode=cx_Oracle.SYSDBA) & using a
>>             500ms timeout), and *callTimeout is not taking effects*:
>>
>>                 import cx_Oracle
>>                 print(cx_Oracle.version, cx_Oracle.clientversion())
>>
>>                 connection = cx_Oracle.connect(mode=cx_Oracle.SYSDBA)
>>
>>                 connection.callTimeout = 500
>>                 print("Call timeout set at", connection.callTimeout, "milliseconds...")
>>
>>                 cursor = connection.cursor()
>>                 cursor.execute("select sysdate from dual")
>>                 today, = cursor.fetchone()
>>                 print("Fetch of current date before timeout:", today)
>>
>>                 # dbms_session.sleep() replaces dbms_lock.sleep() from Oracle Database 18c
>>                 sleep_proc_name = "dbms_session.sleep" \
>>                         if int(connection.version.split(".")[0]) >= 18 \
>>                         else "dbms_lock.sleep"
>>
>>                 print("Sleeping...should time out...")
>>                 try:
>>                 cursor.callproc(sleep_proc_name, (3,))
>>                 except cx_Oracle.DatabaseError as e:
>>                 print("ERROR:", e)
>>
>>                 cursor.execute("select sysdate from dual")
>>                 today, = cursor.fetchone()
>>                 print("Fetch of current date after timeout:", today)
>>
>>
>>             The output is:
>>
>>                 $ python test.py
>>                 8.1.0 (18, 3, 0, 0, 0)
>>                 Call timeout set at 500 milliseconds...
>>                 Fetch of current date before timeout: 2021-04-22 22:39:30
>>                 Sleeping...should time out...
>>                 Fetch of current date after timeout: 2021-04-22 22:39:33
>>
>>
>>             Note that (from the output), I'm using *cx_Oracle 8.1 and Oracle client library 18.3* --- both satisfy this feature's requirements. 
>>             The DB is freshly installed on an Oracle Linux box.
>>
>>             Is there a pointer on how to resolve this? *Is it possible something about connect(mode=cx_Oracle.SYSDBA) made the timeout a no-op?
>>             *Or, should I upgrade to Oracle 19 and retry?
>>
>             Start by setting disable_oob=on in a sqlnet.ora file on your Python machine. The OOB setting is a common gotcha. See
>             https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-client-configuration-files
>             <https://urldefense.com/v3/__https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html*optional-oracle-client-configuration-files__;Iw!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEF8g1JnqA$>
>
>             Or upgrade to 19c Oracle client libraries, which auto-detect the necessary OOB setting.
>
>             -- 
>             https://twitter.com/ghrd  <https://urldefense.com/v3/__https://twitter.com/ghrd__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEEaQbHzxQ$>
>
>             _______________________________________________
>             cx-oracle-users mailing list
>             cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org <mailto:cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
>             https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>             <https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/cx-oracle-users__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEHrRgsP-w$>
>
>
>
> _______________________________________________
> cx-oracle-users mailing list
> cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/cx-oracle-users__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEHrRgsP-w$

-- 
https://twitter.com/ghrd


--------------423D3A74D61A4AE810071ACF
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 23/4/21 2:28 pm, Zongheng Yang
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAG2+eoiDr9BUSdY93zeZxBvS_3aurWLpS2KDD_ud1csApECSQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org">
      
      <div dir="ltr">Found the issue: The Linux user &quot;oracle&quot; for some
        reason is not able to receive any signals.&nbsp; Switching to root
        makes everything work now.</div>
    </blockquote>
    <p>The OCI developers tell me that the timeout will not work with
      IPC connections. <br>
    </p>
    <p>Maybe that was what you were seeing?</p>
    <p>I've filed a doc bug to improve the doc.<br>
    </p>
    <p>Chris<br>
    </p>
    <span class="s1"></span>
    <p class="MsoNormal"><span style="font-size:8.5pt;font-family:Menlo;color:black"></span></p>
    <blockquote type="cite" cite="mid:CAG2+eoiDr9BUSdY93zeZxBvS_3aurWLpS2KDD_ud1csApECSQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org"><br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021 at 8:02
          PM Zongheng Yang &lt;<a href="mailto:[email protected]" moz-do-not-send="true">[email protected]</a>&gt; wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Tried out upgrading Oracle 19c, and optionally
            adding to the script (the dir in which the modified
            sqlnet.ora lives):
            <div><br>
              <div>&nbsp; &nbsp;
cx_Oracle.init_oracle_client(config_dir=&quot;/u01/app/oracle/product/19.0.0/dbhome_1/network/admin&quot;)<br>
              </div>
              <div><br>
              </div>
              <div>Same issue still persists.&nbsp; OS is Oracle Linux 7.7.</div>
              <div><br>
              </div>
              <div>$ python test.py<br>
                8.1.0 (19, 3, 0, 0, 0)<br>
                Call timeout set at 500 milliseconds...<br>
                Fetch of current date before timeout: 2021-04-23
                03:01:27<br>
                Sleeping...should time out...<br>
                Fetch of current date after timeout: 2021-04-23 03:01:37<br>
              </div>
              <div><br>
              </div>
              <div><br>
              </div>
            </div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021 at
              3:59 PM Zongheng Yang &lt;<a href="mailto:[email protected]" target="_blank" moz-do-not-send="true">[email protected]</a>&gt;
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">
                <div>Thanks for the quick response!</div>
                <div><br>
                </div>
                (base) [oracle@oracle-test18 ~]$ grep disable_oob
                $ORACLE_HOME/network/admin/sqlnet.ora<br>
                #disable_oob = ON<br>
                disable_oob = ON<br>
                <div><br>
                </div>
                <div>With this change, and running SHUTDOWN then
                  STARTUP, the same issue persists.&nbsp; No timeout effect.</div>
                <div><br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Thu, Apr 22, 2021
                  at 3:51 PM Christopher Jones &lt;<a href="mailto:[email protected]" target="_blank" moz-do-not-send="true">[email protected]</a>&gt;
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px
                  0px 0.8ex;border-left:1px solid
                  rgb(204,204,204);padding-left:1ex">
                  <div>
                    <p><br>
                    </p>
                    <div>On 23/4/21 8:44 am, ConcreteVitamin wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hi,
                        <div><br>
                        </div>
                        <div>I'm using the following script, modified
                          from samples/CallTimeout.py (changing into
                          cx_Oracle.connect(mode=cx_Oracle.SYSDBA) &amp;
                          using a 500ms timeout), and <b>callTimeout is
                            not taking effects</b>:</div>
                        <div><br>
                        </div>
                        <blockquote style="margin:0px 0px 0px
                          40px;border:none;padding:0px">
                          <div><font face="monospace">import cx_Oracle</font></div>
                          <div><font face="monospace">print(cx_Oracle.version,
                              cx_Oracle.clientversion())</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">connection =
                              cx_Oracle.connect(mode=cx_Oracle.SYSDBA)</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">connection.callTimeout
                              = 500</font></div>
                          <div><font face="monospace">print(&quot;Call
                              timeout set at&quot;, connection.callTimeout,
                              &quot;milliseconds...&quot;)</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">cursor =
                              connection.cursor()</font></div>
                          <div><font face="monospace">cursor.execute(&quot;select
                              sysdate from dual&quot;)</font></div>
                          <div><font face="monospace">today, =
                              cursor.fetchone()</font></div>
                          <div><font face="monospace">print(&quot;Fetch of
                              current date before timeout:&quot;, today)</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">#
                              dbms_session.sleep() replaces
                              dbms_lock.sleep() from Oracle Database 18c</font></div>
                          <div><font face="monospace">sleep_proc_name =
                              &quot;dbms_session.sleep&quot; \</font></div>
                          <div><font face="monospace">&nbsp; &nbsp; &nbsp; &nbsp; if
                              int(connection.version.split(&quot;.&quot;)[0])
                              &gt;= 18 \</font></div>
                          <div><font face="monospace">&nbsp; &nbsp; &nbsp; &nbsp; else
                              &quot;dbms_lock.sleep&quot;</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">print(&quot;Sleeping...should
                              time out...&quot;)</font></div>
                          <div><font face="monospace">try:</font></div>
                          <div><font face="monospace">&nbsp; &nbsp;
                              cursor.callproc(sleep_proc_name, (3,))</font></div>
                          <div><font face="monospace">except
                              cx_Oracle.DatabaseError as e:</font></div>
                          <div><font face="monospace">&nbsp; &nbsp;
                              print(&quot;ERROR:&quot;, e)</font></div>
                          <div><font face="monospace"><br>
                            </font></div>
                          <div><font face="monospace">cursor.execute(&quot;select
                              sysdate from dual&quot;)</font></div>
                          <div><font face="monospace">today, =
                              cursor.fetchone()</font></div>
                          <div><font face="monospace">print(&quot;Fetch of
                              current date after timeout:&quot;, today)</font></div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>The output is:</div>
                        <div><br>
                        </div>
                        <blockquote style="margin:0px 0px 0px
                          40px;border:none;padding:0px">
                          <div><font face="monospace">$ python test.py</font></div>
                          <div><font face="monospace">8.1.0 (18, 3, 0,
                              0, 0)</font></div>
                          <div><font face="monospace">Call timeout set
                              at 500 milliseconds...</font></div>
                          <div><font face="monospace">Fetch of current
                              date before timeout: 2021-04-22 22:39:30</font></div>
                          <div><font face="monospace">Sleeping...should
                              time out...</font></div>
                          <div><font face="monospace">Fetch of current
                              date after timeout: 2021-04-22 22:39:33</font></div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>Note that (from the output), I'm using <b>cx_Oracle
                            8.1 and Oracle client library 18.3</b> ---
                          both satisfy this feature's&nbsp;requirements.&nbsp; The
                          DB is freshly installed on an Oracle Linux
                          box.</div>
                        <div><br>
                        </div>
                        <div>Is there a pointer on how to resolve this?&nbsp;
                          <b>Is it possible something
                            about&nbsp;connect(mode=cx_Oracle.SYSDBA) made
                            the timeout a no-op?&nbsp; </b>Or, should I
                          upgrade to Oracle 19 and retry?</div>
                        <div><br>
                        </div>
                      </div>
                    </blockquote>
                    <p>Start by setting <font face="monospace">disable_oob=on</font>
                      in a sqlnet.ora file on your Python machine. The
                      OOB setting is a common gotcha. See
                      <a href="https://urldefense.com/v3/__https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html*optional-oracle-client-configuration-files__;Iw!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEF8g1JnqA$" target="_blank" moz-do-not-send="true">https://cx-oracle.readthedocs.io/en/latest/user_guide/initialization.html#optional-oracle-client-configuration-files</a></p>
                    <p> Or upgrade to 19c Oracle client libraries, which
                      auto-detect the necessary OOB setting.<br>
                    </p>
                    <pre cols="150">-- 
<a href="https://urldefense.com/v3/__https://twitter.com/ghrd__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEEaQbHzxQ$" target="_blank" moz-do-not-send="true">https://twitter.com/ghrd</a>
</pre>
                  </div>
                  _______________________________________________<br>
                  cx-oracle-users mailing list<br>
                  <a href="mailto:cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org" target="_blank" moz-do-not-send="true">cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org</a><br>
                  <a href="https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/cx-oracle-users__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEHrRgsP-w$" rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.sourceforge.net/lists/listinfo/cx-oracle-users</a><br>
                </blockquote>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
cx-oracle-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org">cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org</a>
<a class="moz-txt-link-freetext" href="https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/cx-oracle-users__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEHrRgsP-w$">https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/cx-oracle-users__;!!GqivPVa7Brio!Kb_TVgD-GWb7ulMD08oAAZbaHHV7FcmYklsKvmI_s8mYy0EscWj7vJ2TONtEdEHrRgsP-w$</a> 
</pre>
    </blockquote>
    <pre class="moz-signature" cols="150">-- 
<a class="moz-txt-link-freetext" href="https://twitter.com/ghrd">https://twitter.com/ghrd</a>
</pre>
  </body>
</html>

--------------423D3A74D61A4AE810071ACF--


--===============2292819431725574436==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============2292819431725574436==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users

--===============2292819431725574436==--