You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When $page->increment() (or decrement) on a certain page is called in parallel, i.e. when many users are visiting a page in parallel, that executes that certain code, the value is not incremented properly.
The reason behind that is pretty clear: when the value is incremented by one process, the next parallel process does not know of that change because it has already started to read the value before the previous process incremented it.
It's not so much about hundreds of users visiting a page in parallel, it's more about that the chance that even only two parallel visitors cause this scenario is not zero. Data integrity is lost in this case.
Databases can handle such scenarios where multiple processes or threads are trying to increment a value in parallel. This is typically managed using transactions and locking mechanisms that ensure data consistency in concurrent operations.
Expected behavior
The value should be incremented properly
To reproduce
1. check out starterkit
git clone https://github.com/getkirby/starterkit.git page-increment
cd page-increment
composer install
Description
When
$page->increment()
(or decrement) on a certain page is called in parallel, i.e. when many users are visiting a page in parallel, that executes that certain code, the value is not incremented properly.The reason behind that is pretty clear: when the value is incremented by one process, the next parallel process does not know of that change because it has already started to read the value before the previous process incremented it.
It's not so much about hundreds of users visiting a page in parallel, it's more about that the chance that even only two parallel visitors cause this scenario is not zero. Data integrity is lost in this case.
Expected behavior
The value should be incremented properly
To reproduce
1. check out starterkit
git clone https://github.com/getkirby/starterkit.git page-increment cd page-increment composer install
2. Extend the
home
blueprintsite/blueprints/pages/home.yml
3. Add initial value
0
to the home pagecontent/home/home.txt
4. create a php script for the incrementing
increment-home.php
5. create a bash script that calls the incrementor script in parallel 10 times
touch increment-home-parallel.sh && chmod +x increment-home-parallel.sh
6. call the script
See that the value was not incremented properly, should be
10
but is much lowerYour setup
Kirby Version: latest, see starterkit
*Your system
The text was updated successfully, but these errors were encountered: