Can’t Log In using HyperDB? Here’s how to fix it

I recently had an issue where a high availability server I was running with HyberDB and a master/slave relationship wasn’t letting me log in. I spent a lot of time digging around, and couldn’t see any issues. SHOW SLAVE STATUS on my MySQL replication server showed no errors either.

It turns out, the big issue was latency. WordPress seeks to verify your session after you’ve logged in. If you are verifying on a different server than the one from which you’re inserting, there is a chance that you may not actually get the data on time.

The solution? Add this to your db-config.php file:

 * Add a sleep setting, to ensure that setting
 * cookies and all verification happens after
 * replication has already taken place.
 * If you replication is taking more than
 * 1 second, you may have a server latency issue.
add_action('set_logged_in_cookie', function() {
}, 10, 0);

That should fix your issues.

Leave a Reply