dongtanliefang8765 2019-02-18 16:46
浏览 83

Session变量中的值随机而非所有实例都会更改

My environment uses Laravel framework with a single MSSQL Database is used as the Session and Application database driver. A single database driver (connection) is used by the application.

The web server and the database server are on different virtual machines. Both the server runs on CentOS (Linux variant) operating system.

A master web page has a list or IDs. Clicking an ID opens the 2nd detail web page which makes an AJAX request to a REST API. The REST API invokes an external Web Service that is hosted on a different network. The AJAX call sometimes completes faster and provides the response to the caller function, but in few cases takes more time to complete.

The web page and the REST API are part of the same application and hosted in the same server instance. The application is not load-balanced.

When the user visits the master web page and click the record having ID as 1, the ID session variable is first programmatically assigned a value of 1 and then the AJAX call is made. When the user moves back to the master web page and click the record having ID as 2, the ID session variable is programmatically reassigned a value of 2. When we retrieve the value of the ID session variable, we get 2, as expected.

However, only in the cases when the AJAX call takes more time to complete, even though we programmatically reassigned a value of 2 to the ID session variable, on retrieving it, we in occasions get a value of 2 (expected value) and in other occasions we get a value of 1 (unexpected, previous value).

We are not sure whether the reassignment of the session variable was not committed or rolled back for any reason.

We are also not sure whether it is to do with any specific version of PHP, Laravel, MS SQL Server, etc, which we don’t think so.

Can anyone throw some pointers on why the value after the session reassignment is not the new value, but still the old value?

  • 写回答

1条回答 默认 最新

  • dongliao2241 2019-02-18 18:27
    关注

    I think your 'commit' thought is the right line to go down. Try with autocommit switched on from your sql:

    SET IMPLICIT_TRANSACTIONS OFF
    

    If it works that way, switch autocommit off again and make sure your code does all the right commits.

    This is discussed in detail in this popular SO question: How do you set autocommit in an SQL Server session?

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line