Issues with the feeds are now resolved

This is just a quick notice that during the last five days there was a problem with the website feeds. The web server returned a 500 Internal Server Error to almost all requests for /feed/ URLs. Also, there was a big increase of the server’s CPU load behind the scenes, which was caused by php-cgi processes. It turned out that a custom plugin (unpublished) I had written for WordPress in the past was the cause of all the trouble, but, before coming to that conclusion, the fact that the problems had started without me doing anything on the blog during the last weeks together with a series of other random observations led me do a thorough examination of the whole server just in case.

So, after spending two days in front of a Linux terminal, I came to the conclusion that the following code had been problematic from the beginning and it was like a time-bomb for which the time had come to cause issues to the web site and the server that hosted it.

function rsse_add_related_posts($PostBody) {
  if (!rsse_verify_feed()) { return $PostBody; }
  if (function_exists('yarpp_related')) {
    $PostBody .= yarpp_related(array('post'),array(),false,false,'rss');
  }
  return $PostBody;
}
 
add_filter('the_content', 'rsse_add_related_posts', 252);

This code used a function of another plugin to attach a ‘related posts‘ section at the end of the full content of each feed entry. As soon as I commented out the above filter and started attaching the related-posts section to the feed content through the YARPP plugin’s administration interface, everything was normal again. No more php-cgi processes timing-out or over-consuming the CPU cycles.

The following graph shows clearly the problematic period:

php-cgi processes consuming the CPU

php-cgi processes consuming the CPU

The httpd error_log included many errors like the following:

[...]
Allowed memory size of 33554432 bytes exhausted (tried to allocate 18893 bytes)
[...]
mod_fcgid: process ... exit(communication error), terminated by calling exit(), return code: 1
[...]
[warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[...]
[warn] mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 4864 bytes)
[...]
Premature end of script headers: index.php
[...]

Note that these errors might appear in several occasions.

In my case, finding that faulty piece of code was a huge relief, I can tell you.

Issues with the feeds are now resolved by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2010 - Some Rights Reserved