#45558 [Bgs]: Memcache reads/writes are not synchronized

2008-07-19 Thread emailforalex at gmail dot com
 ID:   45558
 User updated by:  emailforalex at gmail dot com
 Reported By:  emailforalex at gmail dot com
 Status:   Bogus
 Bug Type: Feature/Change Request
 Operating System: any
 PHP Version:  5.2.6
 New Comment:

Well, the reason it's under Feature Request is that this really
should be a feature of PHP. Doing locking on a cache server (or multiple
servers) from many web servers trying to access the simultaneously is
incredibly hard to implement in PHP as the only place the servers can
share a common lock is the caching machine itself. I believe it would be
much easier for you to implement this than for developers to write it
using PHP.


Previous Comments:


[2008-07-18 23:22:22] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

This is a problem with the application design, you need to do some sort
of locking before you read and write the value.



[2008-07-18 19:14:46] emailforalex at gmail dot com

Description:

This bug is incredibly hard to track down and reproduce, but is a
major issue for high-volume sites using memcache. There is no
synchronization mechanism built in when multiple servers serving
multiple requests are all trying to read/write to a memcache machine.

A race condition occurs where one request (r1) reads from the cache,
then a second request (r2) reads from the cache, then r1 writes the same
key back to the cache and r2 proceeds to also write that key to the
cache. In effect, r2 overwrites the changes by r1.

The issue was discovered while using the symfony framework which stores
an array of all of its keys in the cache to allow for pattern-based
searching of the keys. What sometimes happened is that two writes in a
row would happen as described above, and the keys that were added to the
array during the first write disappeared.






-- 
Edit this bug report at http://bugs.php.net/?id=45558edit=1



#45558 [Bgs]: Memcache reads/writes are not synchronized

2008-07-19 Thread emailforalex at gmail dot com
 ID:   45558
 User updated by:  emailforalex at gmail dot com
 Reported By:  emailforalex at gmail dot com
 Status:   Bogus
 Bug Type: Feature/Change Request
 Operating System: any
 PHP Version:  5.2.6
 New Comment:

I wasn't suggesting doing it by default. What I would like are
functions such as Memcache::acquireLock and Memcache::releaseLock - I'm
sure this would come in handy for many more people than myself who would
have trouble writing this on their own.


Previous Comments:


[2008-07-19 13:27:16] [EMAIL PROTECTED]

There is no locking performed for any external resources in PHP by
default. It would make normal reads slow since PHP wouldn't be able to
predict that you were going to do a write to something you had read.

Implementing a locking mechanism isn't that hard by using add with
Memcache.



[2008-07-19 08:39:08] emailforalex at gmail dot com

Well, the reason it's under Feature Request is that this really
should be a feature of PHP. Doing locking on a cache server (or multiple
servers) from many web servers trying to access the simultaneously is
incredibly hard to implement in PHP as the only place the servers can
share a common lock is the caching machine itself. I believe it would be
much easier for you to implement this than for developers to write it
using PHP.



[2008-07-18 23:22:22] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

This is a problem with the application design, you need to do some sort
of locking before you read and write the value.



[2008-07-18 19:14:46] emailforalex at gmail dot com

Description:

This bug is incredibly hard to track down and reproduce, but is a
major issue for high-volume sites using memcache. There is no
synchronization mechanism built in when multiple servers serving
multiple requests are all trying to read/write to a memcache machine.

A race condition occurs where one request (r1) reads from the cache,
then a second request (r2) reads from the cache, then r1 writes the same
key back to the cache and r2 proceeds to also write that key to the
cache. In effect, r2 overwrites the changes by r1.

The issue was discovered while using the symfony framework which stores
an array of all of its keys in the cache to allow for pattern-based
searching of the keys. What sometimes happened is that two writes in a
row would happen as described above, and the keys that were added to the
array during the first write disappeared.






-- 
Edit this bug report at http://bugs.php.net/?id=45558edit=1



#45558 [NEW]: Memcache reads/writes are not synchronized

2008-07-18 Thread emailforalex at gmail dot com
From: emailforalex at gmail dot com
Operating system: any
PHP version:  5.2.6
PHP Bug Type: Feature/Change Request
Bug description:  Memcache reads/writes are not synchronized

Description:

This bug is incredibly hard to track down and reproduce, but is a major
issue for high-volume sites using memcache. There is no synchronization
mechanism built in when multiple servers serving multiple requests are all
trying to read/write to a memcache machine.

A race condition occurs where one request (r1) reads from the cache, then
a second request (r2) reads from the cache, then r1 writes the same key
back to the cache and r2 proceeds to also write that key to the cache. In
effect, r2 overwrites the changes by r1.

The issue was discovered while using the symfony framework which stores an
array of all of its keys in the cache to allow for pattern-based searching
of the keys. What sometimes happened is that two writes in a row would
happen as described above, and the keys that were added to the array during
the first write disappeared.


-- 
Edit bug report at http://bugs.php.net/?id=45558edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45558r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45558r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45558r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45558r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=45558r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=45558r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=45558r=needscript
Try newer version:http://bugs.php.net/fix.php?id=45558r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=45558r=support
Expected behavior:http://bugs.php.net/fix.php?id=45558r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=45558r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=45558r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45558r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45558r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45558r=dst
IIS Stability:http://bugs.php.net/fix.php?id=45558r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=45558r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45558r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=45558r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=45558r=mysqlcfg