Locking session with extra table (Galera cluster) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Locking session with extra table (Galera cluster) (/showthread.php?tid=62593) |
Locking session with extra table (Galera cluster) - Jammyman - 08-03-2015 Galera cluster doesn't support locking tables (MySQL, MariaDB), so the new Session library doesn't work with it (random segfaults). File driver is not an option with load balancer and at the time being there's no support for Redis and Memcahed either so I need figure out other way lock the session. I've been testing locking with extra table and it seems to work reasonably well even under tons of ajax calls (although can be little slow if lot's of stuff waiting). Because there's no "real lock", sometimes one process can create lock while other is doing it too, resulting Duplicate Entry -error in other query. I can detect the error in the code below but I'm not too happy about script making query errors to my logs etc. I tried transactions for this too but while it worked, I got same error to my logs. So this seems to work, but any ideas how to improve it? Or other ides how to do it? Table: PHP Code: CREATE TABLE `ci_sessions_lock` ( Get lock: PHP Code: if ($this->_platform === 'mysql') Release lock: PHP Code: if ($this->_platform === 'mysql') |