Hey guys,

just wanted to inform you that switching from MyISAM to InnoDB for the session
table does NOT solve the "duplicate entry" problem when using flash() :(

I really can't believe that me and 3 or 4 others are the only people
experiencing this problem! We're getting close to 400 of those errors over a
weekend with moderate traffic (2-3 million page impressions). The problem with
this error is that the user receives a 500 error page when in reality nothing
really bad happened (it's just a flash message that couldn't get inserted, you
know).

Now AFAICT we have these solutions:

a) Patch Catalyst::Plugin::Session::Store::DBIC to wrap the flash
   functionality in a transaction (of course, this must be configurable).
   Advantages:
     - Easy to implement
     - Most sensible solution.
   Disadvantages:
     - Slight performance overhead?
     - Doesn't solve the problem for non-transactional databases

b) Patch DBIx::Class's find_or_create() method and reverse its order
   (insert first, check for duplicate, then select).
   Disadvantages:
     - Not that easy to implement because every database returns
       a different error to signal a unique key constraint violation.
     - It's quite possible that this doesn't really solve the problem
       but just changes the error. If the row is deleted between insert
       and select (this race condition still exists), find_or_create()
       will return nothing and AFAICT C::P::Session::Store::DBIC's
       flash() method expects a working row object.
   Advantages:
     - find_or_create() will be faster everywhere in many cases.

Anything else? What do you propose?

There's a hint in the POD about a "soon to be developed locking solution" which
should get rid of this race condition. Please note, that this is ONLY happening
with the flash part - my sessions work 100% accurate all the time!

We really should sort this thing out because it's bugging me for ages. Again, I
can't believe that I'm almost the only person with this problem.

If we are unable to fix it, I'll remove the flash() stuff from my code and tell
everyone that it's b0rken ;-)

--Tobias

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to