普通网友 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条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效