Solved: 1 Year, 10 Months, 2 Weeks ago 'mybb_sessions' in database is increasing rapidly after the update to 1.8.22
#1
Solved: 1 Year, 10 Months, 2 Weeks ago
I noticed that our forum's database size is increasing rapidly. Even though there were no activity at all. So, I did some digging. And found that 'mybb_sessions' is increasing rapidly. With a 150mb database and with the activity like in our forum its evident it will increase 0.5-1 mb on a regular day. But its a sign of concern if its increases 5-10mb per day even though there is no activity except bots.

I have been suggested in reddit that this might be the problem https://github.com/mybb/mybb/issues/3762

So what should I do here? Should I request for a plugin. Or, there are any other paths to follow?

Frankly, I don't think that I should leave it to be. Because at this rate within just one week. Our database will become double the size. I hope you guys can understand my problem here.
Reply
#2
Solved: 1 Year, 10 Months, 2 Weeks ago
If most records in the table have a random value in the sid field, rather than bot=..., those would be sessions of guests and unidentified bots.

More records may be stored after the recent update, but those older than 24 hours are deleted by the Daily Cleanup task - you can verify that it's enabled in the ACP's Tools & Maintenance → Task Manager and check past runs in → View Task Logs.
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#3
Solved: 1 Year, 10 Months, 2 Weeks ago
Okay, so its like this. I am putting here the first part of the first line(I have more than four lines in it). All look like this.

Quote:INSERT INTO mybb_sessions (sid, uid, ip, time, location, useragent, anonymous, nopermission, location1, location2) VALUES ('fe4cffc2601ce472ea622695519acc9a',0,'LC',1577949159,'/showthread.php?tid=6673','Mozilla/5.0 (Windows NT 10.0; Win64; x64; trendictionbot0.5.0; trendiction search; http://www.trendiction.de/bot; please let us know of any problems; web at trendiction.com) Gecko/20170101 Firefox/67.',0,0,24,6673),

And I also looked into tasks they all seem to be running. Can't I just add a task specifically to clean this?
Reply
#4
Solved: 1 Year, 10 Months, 2 Weeks ago
If you can identify repetitive records for specific bots, try adding them in Configuration → Spiders / Bots → Add New Bot - e.g. User Agent String set to trendictionbot should match the one from your example.
These sessions should be limited to one record.

Otherwise, to make MyBB purge session records faster, you can create a custom task inc/tasks/clearsessions.php:
<?php

function task_clearsessions($task)
{
    global $db;

    $timeHours = 3;

    $cutoff = TIME_NOW - ($timeHours * 3600);

    $db->delete_query("sessions", "time < " . $cutoff);

	add_task_log($task, "The custom clear sessions task successfully ran.");
}

This would delete sessions that haven't been active for more than 3 hours. Once saved, you should be able to select the new file in Tools & Maintenance → Task Manager → Add New Task; with Time: Minutes set to 0 and the settings below unchanged, it would run every hour.
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#5
Solved: 1 Year, 10 Months, 2 Weeks ago
Okay, if I have to delete session those were not alive more one hour or 30 minutes or so. Then just changing the $timehours value to 1, will do, right?

And also I need to ask, deleting these session will have any drawback or such sort?
Reply
#6
Solved: 1 Year, 10 Months, 2 Weeks ago
(2020-01-03, 12:07 PM)vk_knight Wrote: Okay, if I have to delete session those were not alive more one hour or 30 minutes or so. Then just changing the $timehours value to 1, will do, right?
Yes, that would make the cut-off time one hour.

Quote:And also I need to ask, deleting these session will have any drawback or such sort?

Short times may result in Authorization code mismatch errors for guests that load a page, leave it for some time (1 hour or longer, after your change) and then try to perform some action, like logging in.

If a limited number of identifiable spiders visit the board, adding their user agent strings might be the safest way to go.
devilshakerz.com/pgp (DF3A 34D9 A627 42E5 BC6A 6750 1F2F B8AA 28FF E1BC) ▪ keybase.io/devilshakerz
Reply
#7
Solved: 1 Year, 10 Months, 2 Weeks ago
Quote:If a limited number of identifiable spiders visit the board, adding their user agent strings might be the safest way to go.

I don't have any limited number. So, I put 0 on Minutes. It shall run every hour, right?!

Thanks for the help.Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)