-
-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Writing two different keys simultaneously into the session cache, can lead to a sql deadlock (when using a PDO backend for the Flow_Session_Storage cache).
Expected Behavior
The cache writing should be in such a way, that the possibility of deadlocks is as small as possible.
Steps To Reproduce
It is hard to reproduce reliably, since it depends on the current cache contents.
Environment
- Flow: 8.4
- PHP: 8.3Anything else?
This is happening because the keys used for Session cache entries are in large parts not unique enough.
See
| $this->storageCache->set($this->storageIdentifier . md5($key), $data, [$this->storageIdentifier], 0); |
For the key $this->storageIdentifier . md5($key) is used. The first part ($this->storageIdentifier) is always the same for the same Session. This can lead to deadlocks, while the database is trying to insert the index for the new entry (since the probability that the index needs to be placed in the same open spot is really high, with this not very well distributed key naming strategy).
A possible fix might be to md5 the whole combined string, not just the $key variable: md5($this->storageIdentifier . $key)
The same might be true for Flow 9.0:
flow-development-collection/Neos.Flow/Classes/Session/Data/SessionKeyValueStore.php
Line 95 in 7d1c46b
| return $storageIdentifier->value . md5($key); |