Sessions table crashed the site

micks80

Joined: 2012-04-22
Posts: 71
Posted: Sun, 2012-04-29 16:26

Hi,
Our VPS server (1GB ram, 2.3 ghz speed, 40gb hdd) crashed with tons of following errors in /var/log/

2012-04-25 08:55:12 -07:00 --- error: Database_Exception [ 44 ]: #145: Table './xxxx_xxphotos/xx_sessions' is marked as crashed and should be repaired [ SELECT `data`
FROM `xx_sessions`
WHERE `session_id` = '0648eb57exxx2a2fe05a17699b230607'
LIMIT 1 ]
/home/xxxx/public_html/photos/system/libraries/Database_Mysqli_Result.php [ 27 ]
#0 /home/xxxx/public_html/photos/system/libraries/Database_Mysqli.php(79): Database_Mysqli_Result_Core->__construct(false, 'SELECT `data`?F...', Object(mysqli), true)
#1 /home/xxxx/public_html/photos/system/libraries/Database.php(272): Database_Mysqli_Core->query_execute('SELECT `data`?F...')
#2 /home/xxxx/public_html/photos/modules/gallery/libraries/MY_Database.php(45): Database_Core->query('SELECT `data`?F...')
#3 /home/xxxx/public_html/photos/system/libraries/Database_Builder.php(973): Database->query('SELECT `data`?F...')
#4 /home/xxxx/public_html/photos/system/libraries/drivers/Session/Database.php(81): Database_Builder_Core->execute('default')
#5 [internal function]: Session_Database_Driver->read('0648eb57ef5e2a2...')
#6 /home/xxxx/public_html/photos/system/libraries/Session.php(190): session_start()
#7 /home/xxxx/public_html/photos/system/libraries/Session.php(82): Session_Core->create(NULL, NULL)
#8 /home/xxxx/public_html/photos/system/libraries/Session.php(43): Session_Core->__construct(NULL)
#9 /home/xxxx/public_html/photos/modules/gallery/helpers/identity.php(114): Session_Core::instance()
#10 /home/xxxx/public_html/photos/modules/gallery/models/item.php(36): identity_Core::active_user()
#11 /home/xxxx/public_html/photos/system/libraries/ORM.php(88): Item_Model_Core->__construct(NULL)
#12 /home/xxxx/public_html/photos/modules/gallery/helpers/model_cache.php(25): ORM_Core::factory('item')
#13 /home/xxxx/public_html/photos/modules/gallery/helpers/item.php(296): model_cache_Core::get('item', 1)
#14 /home/xxxx/public_html/photos/modules/gallery/helpers/identity.php(94): item_Core::root()
#15 /home/xxxx/public_html/photos/modules/gallery/helpers/gallery_event.php(26): identity_Core::load_user()
#16 /home/xxxx/public_html/photos/modules/gallery/helpers/module.php(375): gallery_event_Core::gallery_ready()
#17 /home/xxxx/public_html/photos/modules/gallery/helpers/gallery.php(96): module_Core::event('gallery_ready')
#18 [internal function]: gallery_Core::ready(Array)
#19 /home/xxxx/public_html/photos/system/core/Event.php(208): call_user_func_array(Array, Array)
#20 /home/xxxx/public_html/photos/application/Bootstrap.php(58): Event_Core::run('system.ready')
#21 /home/xxxx/public_html/photos/index.php(102): require('/home/xxxx/...')
#22 {main}

Any ideas how to avoid this kind of error in future? We have moved our site to dedicated servers now but we want to know if it's possible to avoid this in future.Our site has about 2000 photos and when the site crashed there were about 100 live users on the site.

Thanks
mick

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Sun, 2012-04-29 16:35

Debian/Ubuntu systems always check MySQL databases at startup. You would have to come up with something similar to your setup.

To actually fix and repair:

/usr/bin/mysqlcheck -Ao --auto-repair

 
micks80

Joined: 2012-04-22
Posts: 71
Posted: Sun, 2012-04-29 16:49

Thanks,I have repaired it and I am already on Ubuntu. My sessions table is 56MB, will it be okay to delete all the entries? How are the old sessions entries used?

 
inposure
inposure's picture

Joined: 2010-04-23
Posts: 304
Posted: Sun, 2012-04-29 18:15

Tables 'caches' and 'sessions' can be emptied (truncated), they will be rebuilt as needed.

56 MB is really huge and indicates that you have a lot of users (bots, scrapers, whatever)…

My complete database with 5000+ photos is gunzipped and backuped to 1.8 MB…

Dunno about the programming, but sessions should expire. Perhaps it does not expire quickly enough. You can always clean up with cron.

 
micks80

Joined: 2012-04-22
Posts: 71
Posted: Sun, 2012-04-29 19:04

Thanks again, i am sorry I mistyped it, its 5.6 MB and not 56 MB :(