Skip to Main Content
  • Questions
  • Nonblocking mode for the oci connection

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Georgy.

Asked: April 26, 2017 - 4:20 pm UTC

Last updated: May 02, 2017 - 8:47 am UTC

Version: 12.1.2

Viewed 1000+ times

You Asked

Hi Tom!

I can create a nonblocking OCI connection and get OCI_STILL_EXECUTING status with ORA-03123 (Operation would block) error,
but what is the way to determine which operation would block - reading or writing. I want to handle many Oracle connection (multiplexed with fibers) and need to poll fd from these connections. I can't do busy loops because there is other work to do.

Thanks!

and Chris said...

The text "operation would block" is perhaps a little misleading. As the error text indicates, this just means the statement in question can't complete right now:

"Cause: This is a status code that indicates that the operation cannot complete now.

Action: None; this is not an error. The operation should be retried again for completion."

http://docs.oracle.com/database/122/ERRMG/ORA-02140.htm#GUID-008ABD32-275E-467A-AE6B-04976F2A8462__GUID-66A2A4B8-66F2-4A13-B73D-74FFE4728C58

There's many reasons this could happen. For example, you may be trying to insert to a table locked in exclusive mode:

https://community.oracle.com/message/373286

As discussed in the OCI Programmer's Guide, you need to test this in your code:

"OCI provides the ability to establish a server connection in blocking mode or nonblocking mode. When a connection is made in blocking mode, an OCI call returns control to an OCI client application only when the call completes, either successfully or in error. With the nonblocking mode, control is immediately returned to the OCI program if the call could not complete, and the call returns a value of OCI_STILL_EXECUTING.

In nonblocking mode, an application must test the return code of each OCI function to see if it returns OCI_STILL_EXECUTING. If it does, the OCI client can continue to process program logic while waiting to retry the OCI call to the server. This mode is particularly useful in graphical user interface (GUI) applications, real-time applications, and in distributed environments."

http://docs.oracle.com/database/122/LNOCI/oci-programming-basics.htm#LNOCI16240

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Check OCINonBlockingFdGet()

Vijay, December 04, 2020 - 7:46 am UTC

Check the new API OCINonBlockingFdGet() in later releases ...