[Solved] I need help fast. Critical Error.

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

I'll try and sum up as easily as I can.

In your database, you have a sessions table.

Every time someone logs into your site, it adds their user information into that sessions table, so that phpBB has a tally of who is logged in. It uses this information for things like the "Who's Logged In" feature and whatnot.

The error message you received was indicating that the sessions table was full, most likely because too many people were logged in at the same time, or something to that effect. That was caused by your hosting provider limiting the table.

When they increased the table limit, it increased the amount of sessions that the table can hold, and the table is no longer full, so now it's working.

Frankly, I'm surprised that you reached even the low table limit, and I'm guessing that something else caused it to fill up quickly, or not delete out old information, or something along those lines, but either way, you should be fine for awhile.

-9mm-
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

And what is supposed to do is clear it once it reaches a certain size?


Now, if I change the code, will that fix it permanantly? And if so, how should I set up the code? I know I was told above, but I dont want to do it wrong and and up making things worse.
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

It doesn't clear itself when it reaches a certain size, rather, clears itself intermittently, to keep it from being clogged.

Let me give you an example... Assuming your session duration is 5 minutes...

You log in at 3:30
I log in at 3:31
Bob logs in at 3:32.

That creates three session entries, one for you, one for me, and one for Bob, with "last updated" times reflecting 3:30, 3:31, and 3:32, respectively.

At 3:32 you get off your ass and click on a link... that will update your "last updated" time from 3:30 to 3:32.

I don't do anything at all after I log in, because I've suffered a massive coronary.

at 3:36, Bob clicks on a link. When he does that, the page seeks out any sessions older than 5 minutes. Your session was renewed at 3:32, and hence, is only 4 minutes old, so it is not deleted... meanwhile, since I'm dying in my office, my session does expire, and is deleted from the sessions table, thereby freeing up that row and memory.

As far as that code, I don't really know what it does, as I haven't looked it over that carefully. However, if you've had the max_rows bumped up as much as your hosting provider states, then you should be good to go, without needing any code modifications.

-9mm-
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

Thanks 9mm.


I understand what you are saying (thanks for explaining it so even I can understand) But my site still only has about 30 users on it. And im sure not more than 4 people when on it today, total.

I think the problem is that it is never clearing itself out. thus, its getting filled.

Can anyone else verify this?
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

What's the URL to your site? I skimmed the past posts but didn't see it.

-9mm-
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

Check PMs
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

It looks like it's currently okay.

If it were building up, you'd notice, on the main page, a whole lot of people logged into the site that weren't really there.

Given your current scenario, I'm imagining that when you were getting the "table full" error earlier, it was probably showing 100 or more people logged in total. The fact that it isn't now is a good sign.

-9mm-
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

so what do you think the chances are that this will happen again? Or do you not think it will?

Would you recommend doing those fixes anyways? Would they act as a prevent?
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

I don't think that they will. I would suggest you bring down your session length to something in the realm of 10 minutes or so (600), but other than that, I'd be surprised if something like this happened to you again.

-9mm-
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

thanks for the help
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

morpheus2matrix wrote: Ashe have post an idea on a french Forum to resolve this problem :

Code: Select all

in sessions.php, find 

message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);


remplace by :

$error = TRUE; 
if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4") 
{ 
   $sql_error = $db->sql_error($result); 
   if ($sql_error["code"] == 1114) 
   { 
      $result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"'); 
      $row = $db->sql_fetchrow($result); 
      if ($row["Type"] == "HEAP") 
      { 
         if ($row["Rows"] > 2500) 
         { 
            $delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : ""; 
            $db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50"); 
         } 
         else 
         { 
            $db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50)); 
         } 
         if ($db->sql_query($sql)) 
         { 
            $error = FALSE; 
         }                   
      } 
   } 
} 
if ($error) 
{ 
   message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql); 
}
It will increases the capacity of the table so necessary and empties it if it becomes too large



If I replace the code and upload it, that will empty it if it gets full?

This is all I need, correct?

$error = TRUE;
if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4")
{
$sql_error = $db->sql_error($result);
if ($sql_error["code"] == 1114)
{
$result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"');
$row = $db->sql_fetchrow($result);
if ($row["Type"] == "HEAP")
{
if ($row["Rows"] > 2500)
{
$delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : "";
$db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50");
}
else
{
$db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50));
}
if ($db->sql_query($sql))
{
$error = FALSE;
}
}
}
}
if ($error)
{
message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql);
}
rfournier13
Registered User
Posts: 84
Joined: Fri Oct 04, 2002 12:55 am

Post by rfournier13 »

Anyone?
issue9mm
Registered User
Posts: 22
Joined: Mon Dec 24, 2001 5:11 am

Post by issue9mm »

That code looks to be solid. I haven't bothered to test it or anything, so I can't say for certain that it is in fact going to work, but long story short, if it encounters that error message again, it will try and clear 50 sessions from the table, and if it's not able to do that, it will increase the size of the table to accomodate.

It's actually pretty well-thought out, from all appearances.

-9mm-
Locked

Return to “2.0.x Support Forum”