Ferenc Engard wrote:
> I have met with an error when instead of the (nadmin) page I have
> received some error msg that mysql have had not enough memory. There
> were approx. 8-10 mysqld running, each of them taking 9-10MB's of
> mem,
> and there was free mem available, so it was some kind of internal
> mysql
> problem... Maybe because of similar holes?
It could be, but I'm not in any way sure. The issue was that midgard
list fetches would clear the query handle only when the first
unsuccesful fetch was executed (the fetch after the last entry in the
list). If you don't do
while ($list->fetch()) { ... }
but something like:
for ($i=0; $i<5 && $list->fetch(); $i++) { ... }
and you have more than 5 entries in the result list it would leave
the query handle that fetch uses internally dangling.
And since there was no destructor for it, it would leave these until
mysql decides to terminate them for being idle too long, or when the
handler child is terminated (not at request end, but when the handler
child dies. This could be tens or hundreds of requests). At this time
they would just simply be abandoned, and it would be up to mysql to
look after cleaning up its side.
I cannot say whether or not this poses a problem for MySQL. This same
'mechanism' was used in 1.2.5, and the midgard site ran on that for
ages without issue. It did however pose a problem for me, since I just
don't like the thought of orphaned memory and db connections; this
was my main reason to get this fixed.
The fix correctly cleans up the dangling query handles at request end.
It was my intention to have the handles cleaned up at fetch end,
request end or when the list object goes out of scope, whichever
happens first, but I haven't been able to find a way[0] of doing
destructors, and given the nature of PHP, destructors might not
be called until request end anyway, in which case your win is exactly 0.
Emile
[0] that is documented and likely to be in the next subrelease of PHP
with at least a superficially similar API[1]
[1] PHP is not as well-documented as you'd think it would be.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]