msgbartop
Tips de administración de servidores y herramientas Web
msgbarbottom

Bug Php ZendFrameWork – Memcached  

septiembre 30, 2010 Publicado en Admin-tips, Escalabilidad, InfraEstructura con 39 Comentarios



Tengo varias aplicaciones que hacen uso del aplicativo memcached y las cuales se estaban comportando de manera extraña, donde al hacer una modificación de información e invalidar la llave de memcached, la información parecia no ser actualizada.

Lo primero que hice fue aislar el aplicativo para que solo utilizara un servidor de BackEnd, y que este a su vez utilizara unicamente un servidor de Memcached, para poder monitorear de manera controlada el comportamiento de la aplicación.

Una vez aislada la aplicación, ingrese mensajes de debug en el error_log del apache, donde imprimia en la primer linea la operación que estaba realizando, en la segunda linea el valor devuelto por el servidor de memcached y por ultimo el MD5 del key que se almacena en memcached, este era el resultado:

[Thu Sep 30 11:25:09 2010] [error] [client X.X.X.X] REMOVE CACHE, referer: http://myhost.com/somepath/to/my/app
[Thu Sep 30 11:25:09 2010] [error] [client X.X.X.X] 0, referer: http://myhost.com/somepath/to/my/app
[Thu Sep 30 11:25:09 2010] [error] [client X.X.X.X] e81afd654486c19cb137475a687c7f5e

Despues de ver esto se puede evidenciar que el valor devuelto por el aplicativo era cero (0) o false, lo cual indicaba que no estaba realizando la operación de borrado de la información.

Para verificar la información en el servidor de memcached, me conecte por consola y solicite el valor del key antes y despues de modificar un dato en la aplicación web, evidenciando que el dato permanecia intacto en memcached y no era actualizado, por lo tanto el efecto en la aplicación web era que no se estaba actualizando la información, aun cuando en la BD estaba de manera correcta. Para verificar por consola en memcached nos debemos conectar por telnet al puerto definido en la instalación:

[user@webserver ~]$ telnet 192.168.1.XXX 22522
Trying 192.168.1.XXX…
Connected to 192.168.1.XXX (192.168.1.XXX).
Escape character is ‘^]’.
get e81afd654486c19cb137475a687c7f5e
VALUE e81afd654486c19cb137475a687c7f5e 1 49
a:3:{i:0;s:5:”i:11;”;i:1;i:1285880685;i:2;i:300;}
END

Al ver este comportamiento investigue primero en el framework de Zend, en la libreria para trabajar con Memcache, en la funcion “remove” que era la que estaba fallando, alli pude ver que ZendFramework lo que realiza es un llamado a la función “delete” de la clase memcache de PHP.

Investigando en el sitio web de php, http://www.php.net/manual/es/memcache.delete.php, encontre que se trata de un Bug que se presenta en esta función donde recibe un segundo parametro “Opcional” especificando el tiempo en el cual se debe borrar el key, al parecer no resulto ser tan “Opcional” y para que funcione debe especificarse siempre.

Por tal motivo, tuve que editar el archivo de ZendFramework, ZendFramework-1.7.8/library/Zend/Cache/Backend/Memcached.php

ANTES

public function remove($id)
{
return $this->_memcache->delete($id);
}

DESPUES

public function remove($id)
{
return $this->_memcache->delete($id, 0);
}

adicionando ese segundo paramétro en cero (0), se soluciona el inconveniente y vuelve a trabajar de manera adecuada el servidor de memcached.

NOTA: Esto sucede con ZendFramework inferior a la versión 1.10.X + pecl-memcache 3.0.4 + memcached 1.4.4

Tags: , , ,

Comentarios

  1. |

    Que buen post…. se nota que le trabaja bastante al Zend

  2. |

    I seen your internet site. Quite cool. Will arrive again.

  3. |

    Wow, this was a really quality post. In theory I’d like to write like this too – taking time and actual effort to make a good post… but what can I say… I procrastinate alot and never appear to get something done.

  4. |

    makeup brushes is good is excellent

  5. |

    Hi webmaster, commenters and everybody else !!! The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!b Keep ‘em coming… you all do such a great job at such Concepts… can’t tell you how much I, for one appreciate all you do!

  6. |

    Thankful i ran across this site, will be sure to save it, Another good site is Dbol so i can pay a visit to frequently.

  7. |

    I liked reading this, i’ve been wondering about this subject for a while.

  8. |

    Thankful i discovered , this website, Another good site is Dbolwill be sure to take a note of it so i can check-out regularly.

  9. |

    makeup brushes is good is excellent

  10. |

    It’s always refreshing reading intresting post, Well with your permission allow me to grab your rss feed to keep up to date with any new incoming post. Thanks a million and please keep up the delightful work.

  11. |

    I am looking for a good interior design software, i found a couple but i am not sure what to get. What do you recommend?

  12. |

    This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

    Lessie@Marlen-mail.com

  13. |

    Outstanding read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I discovered it for him smile So let me rephrase that: Thanks for lunch!

  14. |

    As a Newbie, I am always searching online for articles that can help me. Thank you

  15. |

    Have you thought about including some social bookmarking buttons to these blogs. At least for twitter.

  16. |

    Please, can you PM me and tell me few more thinks about this, I am really fan of your blog…

  17. |

    I think one of your commercials caused my internet browser to resize, you might want to put that on your blacklist.

  18. |

    Great stuff from you, man. Ive read your stuff before and youre just too awesome. I love what youve got here, love what youre saying and the way you say it. You make it entertaining and you still manage to keep it smart. I cant wait to read more from you. This is really a great blog.

  19. |

    Well, I do not know if that is going to work for me, but definitely worked for you! :) Excellent post!

  20. |

    Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well – resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case

  21. |

    Valuable information and excellent design you got here! I wish to thank you for sharing your ideas and putting the time into the stuff you post! Great work!

  22. |

    So not really on the same topic as your post, but I found this today and I just can’t resist sharing. Mrs. Agathe’s dishwasher quit working so she called a repairman. Since she had to go to work the next day, she told him, “I’ll leave the key under the mat. Fix the dishwasher, leave the bill on the counter, and I’ll mail you the check. Oh, and by the way…don’t worry about my Doberman. He won’t bother you. But, whatever you do, do NOT under ANY circumstances talk to my parrot!” When the repairman arrived at Mrs. Agathe’s apartment the next day, he discovered the biggest and meanest looking Doberman he had ever seen. But just as she had said, the dog simply laid there on the carpet, watching the repairman go about his business. However, the whole time the parrot drove him nuts with his incessant cursing, yelling and name-calling. Finally the repairman couldn’t contain himself any longer and yelled, “Shut up, you stupid ugly bird!” To which the parrot replied, “Get him, Spike!”

  23. |

    Fantastic post, I’ve saved as a favorite this site so hopefully I’ll discover more on this topic in the future!

  24. |

    Wow, this was a really quality post. In theory I’d like to write like this too – taking time and actual effort to make a good post… but what can I say… I procrastinate alot and never appear to get something done. wajadud555

  25. |

    Wonderful write-up, I’ve saved this web page so ideally I will discover a lot more on this subject in the future!

  26. |

    oh cool, this information is really useful and definately is comment worthy! hehe. I’ll see if I can try to use some of this information for my own blog. Thanks!

  27. |

    Good write-up, I have saved as a favorite this web-site so with any luck , I’ll see a lot more on this subject in the future!

  28. |

    Thanks, I’ve recently been searching for details about this subject matter for ages and yours is the best I’ve discovered so far.

  29. |

    naklejki ścienne to wspaniałe dekoracje do mieszkania naklejki na ściany ornamenty architektura naklejki scienne

  30. |

    Thanks for one more nice post. I would like to thank you for the effort you have made in writing this post Bug Php ZendFrameWork – Memcached | Infraestructura y Servicios. I hope for more from you in the future as well.

  31. |

    With all the doggone snow we have gotten recently I am stuck inside , fortunately there is the internet, thanks for giving me something to do. :)

  32. |

    Grand poteau ! Merci pour prendre le temps d’écrire quelque chose qui est réellement en valeur la lecture. Trop souvent je trouve l’information inutile et pas quelque chose qui sont réellement appropriées. Merci pour votre dur labeur.

  33. |

    It is a really good read for me, must admit that you’re among the best bloggers I have seen. Thanks for publishing this informative article Bug Php ZendFrameWork – Memcached | Infraestructura y Servicios. Keep up the great work, I have added you to my blogroll.

  34. |

    Bug Php ZendFrameWork – Memcached | Infraestructura y Servicios is a nice post, thanks for sharing this educational news. It is always nice when you cannot solely be informed, but also be entertained! I’ll visit your blog often for the newest articles.

  35. |

    Please, can you PM me and tell me few more thinks about this, I am really fan of your blog…gets solved properly asap.

  36. |

    You are a very smart person! :)

  37. |

    Good day, i have just added this specific document on my facebook account and obtained a good deal of great responses! I think you are definitely doing a good job with your site. I have one question though, this is a blogengine blog site correct?

  38. |

    Many thanks for making the effort to talk about this, I feel strongly about this and enjoy learning a great deal more on this topic. If possible, as you gain expertise, would you mind updating your webpage with a great deal more info? It’s very helpful for me.

  39. |

    Add lady bug princess party supplies and ladybug stencils. Hide Http Referer