We have a multi threaded process.
It happens sometimes (not safely reproduceable, but 1 out of 10 tries fails everytime).
We store database schema information within memcached (which keys in a table exists).
We encounter the issue, that if a too fast parallel execution occures, the readout of key: b returns previously stored a (b was not stored yet).
Here are some debug logs where we track down the issue.
The second thread is indented for better readable.
the Memcached->save and Memcached->load are calling the direct library methods.
Before each test, i restart the memcached server completely.
As you can see, within the first thread. it tries to readout key c1272279f5014ed7894b5c379879c568 which is correctly: false
It detects that cache missed, and readout the info from the database. before storing the data into memcached, the second thread also tries to readout the same cache key, which also correctly is still false and it also will load and save it.
but after that, the first thread tries to readout key 57621df1f1be7a77a7033f217865bc4a which never got stored, but it returns the data from first stored key c1272279f5014ed7894b5c379879c568, while the second thread returns correctly false, while getting the data for cache key 57621df1f1be7a77a7033f217865bc4a.
I have stripped down the information which get's stored within the memcached, for better readable and security reasons.
We use
ii php8.0-memcached 3.1.5+2.2.0-9+ubuntu20.04.1+deb.sury.org+1 amd64 memcached extension module for PHP, uses libmemcached
and memcached server:
ii memcached 1.5.22-2ubuntu0.2
Hello,
We have a multi threaded process. It happens sometimes (not safely reproduceable, but 1 out of 10 tries fails everytime).
We store database schema information within memcached (which keys in a table exists). We encounter the issue, that if a too fast parallel execution occures, the readout of key: b returns previously stored a (b was not stored yet).
Here are some debug logs where we track down the issue.
The second thread is indented for better readable. the Memcached->save and Memcached->load are calling the direct library methods. Before each test, i restart the memcached server completely. As you can see, within the first thread. it tries to readout key
c1272279f5014ed7894b5c379879c568
which is correctly:false
It detects that cache missed, and readout the info from the database. before storing the data into memcached, the second thread also tries to readout the same cache key, which also correctly is still false and it also will load and save it.but after that, the first thread tries to readout key
57621df1f1be7a77a7033f217865bc4a
which never got stored, but it returns the data from first stored keyc1272279f5014ed7894b5c379879c568
, while the second thread returns correctly false, while getting the data for cache key57621df1f1be7a77a7033f217865bc4a
.I have stripped down the information which get's stored within the memcached, for better readable and security reasons.
We use
ii php8.0-memcached 3.1.5+2.2.0-9+ubuntu20.04.1+deb.sury.org+1 amd64 memcached extension module for PHP, uses libmemcached
and memcached server:ii memcached 1.5.22-2ubuntu0.2