Closed (won't fix)
Project:
Hosting queue runner
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2012 at 16:50 UTC
Updated:
23 Sep 2015 at 14:21 UTC
Jump to comment: Most recent
Comments
Comment #1
steven jones commentedSee: http://gnuvince.wordpress.com/2008/10/28/php-wrong-for-long-running-proc...
Comment #2
steven jones commentedSadly this PHP bug is still not fixed.
https://bugs.php.net/bug.php?id=47396
Comment #3
anarcat commentedWait, so this happens even if the process re-execs itself? How can PHP resources (which I understand to be different from file descriptors) be inherited between system calls? That seems rather odd... It seems to me the exec should fix the problem, maybe this is happening because within an hour we run out of descriptors on busy task lists?
In this case a workaround could be #1191154: reload after N task instead of timeout... a proper solution would be to inspect the current resource ID, maybe based on the last fork or something...
See: http://www.php.net/manual/en/language.types.resource.php
Comment #4
steven jones commentedWell, I've not been able to confirm that this is exactly what was going on here, but I just stopped and restarted the daemon and all was well.
I've seen this on two different servers, but not on another, it seems really weird!
Comment #5
anarcat commentedI confirm this bug. I have written the following loop:
It runs out of file descriptors after 2147480111 iterations on Ubuntu Lucid 64 bits. Running pcntl_exec() on the process fixes the issue, so I believe that restarting the daemon after X tasks should fix this problem.
Comment #6
anarcat commentedNotice how 2147480111 is just thousands away from 2147483648, which is the MAX_INT for signed integers (2^31). Amazing that PHP doesn't bother to use 64bit counters there...
Comment #7
j0nathan commentedComment #8
anarcat commentedworkaround: restart the hosting queue runner, of course.
Comment #9
anarcat commentedintersetingly enough: exec() is not *supposed* to fix that bug necessarily, unless file descriptors are marked as "close on exec" (FD_CLOEXEC) with fcntl:
http://stackoverflow.com/questions/1643304/how-to-set-close-on-exec-by-d...
also, to clarify here: the issue is not necessarily that the file descriptors are *actually* opened! as well documented by the first link steven posted above, it's that FD indexes are not being reused, even if closed. the site was deleted now, an archive is available here:
https://web.archive.org/web/20140719023355/http://gnuvince.wordpress.com...
the gist of it is this:
this is just beyond. but it explains why pcntl_exec() actually fixes the issue.
i am at a loss for words. get me out of the PHP nightmare please.
Comment #10
ergonlogicNothing we can do about this here. The hosting_queued now restarts itself after a while, but that still sucks. I've re-implemented the queue daemon in Python here: https://github.com/GetValkyrie/skynet