Re: [phplib] Garbage Collection/Sessions From: Maurice Jumelet (maurice <email protected>)
Date: 10/02/00

Why does this happen?
the only reasson I could imagine that sessions would not be deleted is that
the database query somehow times out, but
from ct_sql (i quess you use sql containers):
the function to delete expired sessions from the session table is:

$this->db->query(sprintf("DELETE FROM %s WHERE changed < '%s' AND name =
'%s'",
                    $this->database_table,
                    $sqldate,
                    addslashes($name)))

it's not likely that this would somehow timeout, it's only one query for a
complete cleanup.
If you'd set $gc_probability to 100 on every page_view the session table
should be cleaned out, for debugging purpose you could print the query
produced by the ct_sql?

Maurice
NOXX.COM

----- Original Message -----
From: "Michael Chaney" <mdchaney <email protected>>
To: <phplib <email protected>>
Sent: Monday, October 02, 2000 9:55 PM
Subject: Re: [phplib] Garbage Collection/Sessions

> > I'm running a site with Phplib and MySQL. I have garbage collection
> > probability set to 2 and and time set to 40 minutes. I also have my
> > $lifetime set to 40.
> >
> > I've noticed that some sessions seem to avoid being deleted by garbage
> > collection. It's not _that_ many, but it adds up over a period of a week
> or
> > two. (We're talking maybe a hundred or two a day on a site that gets
4000+
> > visits a day). The only way to remove them is to manually delete them. I
> was
> > wondering if anyone has had a similar occurance and knows a) why this is
> > happening b) is it a serious problem if there are older sessions in the
db
> > and c) how to prevent it?
>
> I have the same thing. I've seen the active_sessions table get up in the
> 20,000's, even though most were old. I'm set for 2 hour collection with a
> 1% probability.
>
> The proper way to clean it out, especially for a large site, is to write a
> [gasp] Perl script that runs as a cron job every 15 or 30 minutes. It'll
> only be a few lines. Actually, you can do it with a single MySQL
statement,
> but it will differ for other RDBMS products since the date functions tend
to
> differ among them.
>
> The *proper* way to do it under Oracle, Sybase, Informix, or any other db
> that has stored procedure functionality is to do it via a stored
procedure.
> Most of the sessioning interface to those db's should be stored procedures
&
> views, anyway. It would then be a matter of running a stored procedure
from
> a cron job periodically.
>
> The point of this whole post, if there can be one, is that garbage
> collection should take place outside the context of page generation.
>
> Michael
> --
> Michael Darrin Chaney
> mdchaney <email protected>
> http://www.michaelchaney.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>