普通网友 2010-07-19 15:56
浏览 46
已采纳

一个PHP /应用程序会话是否对应一个Oracle /数据库会话?

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.

  • 写回答

2条回答 默认 最新

  • dpbz14739 2010-07-19 19:39
    关注

    Okay, so this is not a database issue at all. It seems instead that Firefox 3.6.6 queued my simultaneous requests and it wasn't a PHP or DB session issue after all. See this question for an exploration of that issue: Does Firefox synchronize requests for the same page?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?