8000 Laravel 5.0 - Asyncronous AJAX Requests cause Session Variable Changes to be Overwritten · Issue #7549 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content
Laravel 5.0 - Asyncronous AJAX Requests cause Session Variable Changes to be Overwritten #7549
Closed
@loren138

Description

@loren138

If a number of AJAX requests are fired which get processed simultaneously by the webserver, the session files do not lock causing session variables to be overwritten.

On rare occasions, the session file can become corrupted if one copy reads in a half written out file. This condition, however, is difficult to reproduces.

Practically, you probably shouldn't be firing a number of AJAX requests simultaneously, but it is always possible that a user quickly clicks on several buttons that result in requests and the server happens to process those requests simultaneously which would be a reasonable design and result in session problems.

I've put together I very simple demo of this using 26 variables (a-z) which are each incremented by a separate AJAX request. The final result isn't that all 26 variables have the value of 1 (which it should be).

https://github.com/wiseloren/laravel-race

I think this is referenced in #4441 #4576 #4400 I think in these issues the problem is in file corruption due to reads and writes happening at the same time to the session file, which as I mentioned above, I can't reliably reproduce (though I do think it happened at least once during my testing because half my variables disappeared).

Though it is outdated now #6848 seems to have been intended to fix this. If someone can verify this, I'm willing to work on updating the pull request and try to get the style in line which seems to have been the only previous complaint. I'm not sure how one would write a unit test for this since unit tests are executed synchronously and this only happens in async execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0