Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Drupal 6 with Nginx 1.5.1 and PHP-FPM (PHP 5.3.26) on a 1GB single core VPS with 3GB of swap space on SSD storage. I just switched from shared hosting to this unmanaged VPS because my site was getting too heavy, so I'm still learning the ropes. I have moderately high traffic, I don't really monitor it closely but Google Adsense usually record close to 30K page views/day. I usually have 50 to 80 authenticated users logged in and a few hundred more anonymous users hitting the Boost static HTML cache at any given moment. I have a maximum of 10 PHP-FPM child processes configured. I am using the "ondemand" PHP-FPM process manager.

I'm running into an occasional error that is really hard to debug because it's seemingly random. Out of maybe 30 intentional posts by users, 1 of them gets duplicated. I configured it so the post button is disabled after the first click, so it's not the result of double clicking. In fact, it even happened to me once when I was posting. The double posts occur within a few seconds of each other. I examined the log files, and the duplicate post always seems to correspond to an nginx POST error: recv() failed (104: Connection reset by peer) while reading response header from upstream. And this event seems to relate to a PHP-FPM error of an execution timeout error of index.php and subsequent SIGTERM of the PHP-FPM worker process.

Here are links to the nginx access and error logs and the PHP-FPM error log.

pastebin.com/RDTn3NUN

pastebin.com/QmD9Qs20

pastebin.com/29U2UcHX

They are pruned and slightly obfuscated to show a duplicate post error that just happened today at 12:34 by me with an IP address of "1.2.3.4". The node on which the dupe happened is 22802.

This issue did not occur when I was running on Apache/FastCGI on my previous shared webhost. I should also mention that I am using Redis for caching and the Zend Optimizer+ opcache. But I tried disabling both of those mechanisms to avoid the dupes error, and it made no difference.

Thanks for any help you can provide!

share|improve this question
    
Why aren't you on Drupal 7 already? –  Michael Hampton Jul 2 '13 at 18:10
    
I'm still dependant on some Drupal 6 modules. Drupal 6/7 isn't the issue here, though. –  user12361 Jul 2 '13 at 18:18
    
As for the Drupal 6/7 thing, I never had problems with double posting on Drupal 6 on my previous host. It's some sort of config issue with PHP-FPM I suspect. –  user12361 Jul 2 '13 at 18:24
add comment

1 Answer 1

Well, I'm going to answer my own question. The problem apparently had something to do with the request_terminate_timeout = 30s value that I was using, possibly combined with the ondemand FPM process manager. The double post always coincided with a PHP-FPM timeout error combined with a killing of a child process immediately after. So I disabled the request_terminate_timeout, and it appears to be redundant anyway since the php.ini file already specifies a 30 second timeout. I also realized that I don't really need the ondemand process manager because I'm the only user on this box with fairly stable load, so I switched to static and set the pm.max_requests fairly low to 100. This prevents memory leaks.

One or both of these changes has effectively eliminated the duplicates posts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.