I'm experiencing some behavior I did not expect. I have a synchronous procedure that is kicked off via PHP/OCI8. At the beginning of the process there is a SELECT...FOR UPDATE NOWAIT
I do NOWAIT
because I want users notified immediately with an error message that the process is already running, rather than having their browser wait for the lock.
When I run the process from two separate computers with two separate PHP sessions, I get the expected behavior: one runs while the other gets an ORA-00054: resource busy and acquire with NOWAIT specified
.
But when I open two tabs on the same browser and run the process, the second tab waits the 30+ seconds for the first one to finish, and then runs the second one -- it's as if I did not specify NOWAIT
.
I'm not using persistent connections or connection pooling of any kind. I thought a separate HTTP request, executing separate PHP=>Oracle connections, would give me separate DB sessions. Is this not the case?
UPDATE: I found this: http://wiki.oracle.com/page/PHP+Oracle+FAQ under #6, How do I connect to Oracle with the OCI8 extension? it says:
PHP will share/re-use connections if the same user credentials are used more than once in a script or httpd server session. You can use the oci_new_connect() function to ensure a new session is used. Call the oci_pconnect() function to make a persistent connection that isn't closed at the end of the script (making the reconnection in the next script much faster).
However, when I change to oci_new_connect
it does not fix the issue. Different sessions on different computers throw the ORA-00054
, but two tabs on the same browser synchronize access but do not respect the NOWAIT
.