rbCAS / CASino

CASino is a Ruby-based Single Sign-On solution supporting the CAS standard
MIT License
331 stars 189 forks source link

Running Casino in a master master setup setup causes casino_login_tickets discrepency #100

Closed barttenbrinke closed 9 years ago

barttenbrinke commented 9 years ago

I currently have the following setup:

 CasinoServer1                   CasinoServer2
  ||                              ||
  \/                              \/
 DB1  <----- master/master -->   DB2

DB1 inserts with EVEN ids and DB2 inserts with ODD ids. What happens is that replication stops because there are differences between the casino_login_tickets table on DB1 and the casino_login_tickets table on DB2.

Last_SQL_Errno: 1032
Last_SQL_Error: Could not execute Update_rows event on table casino_production.casino_login_tickets; Can't find record in 'casino_login_tickets', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000177, end_log_pos 96120580

The only explanation for this I can think of is that Casino uses something like row level locking for the login_tickets and that that causes some soft of racing? Only the login_tickets table is affected, all other tables are fine.

I've currently worked around the issue by letting CasinoServer1 point to DB2, but I was hoping to solve this in a nicer way.

pencil commented 9 years ago

Could it be the cleanup cronjob for the login_tickets table that causes the problem? Maybe deactivating the cleanup task on one of the instances would help.

barttenbrinke commented 9 years ago

That was my first guess as wel, but Mysql replication does a fine job of replicating range queries. As far as I can tell the UPDATE seems to be replicated BEFORE the insert or something?! I was hoping you might be able to point me to the code creating the tickets, so I could look around :)

pencil commented 9 years ago

There is nothing more to it than a single LoginTicket.create call. Maybe you can track down what causes the Update_rows event using the timestamps and the web log.

pencil commented 9 years ago

Closing this for now. Please post an update once you find the time to look into it.