intermittent NoMethodError: undefined method `delete' for nil:NilClass on production; Active Record

I am seeing an unusual hiccup related to Active Record Session store that happens intermittently (and I am unable to reproduce locally):

NoMethodError: undefined method `delete’ for nil:NilClass

Rails: 3.2.21

(I am running Spree 2.0.13.beta)

I am using active_record_store and the stacktrace does not pass through my app. Interestingly, the stacktrace passes thruogh active_record/session_store.rb code (see full stacktrace gist:817b37e262e8247e85a2 · GitHub)

Some observations:

• I tried logging in as this user and also hijacking the user’s session by record id (moving a fake session id into the sessin id & data fields of the session where the symptom is) – I was unable to reproduce this in dev completely.

• This happening on different users on different places in my app (occurance is 1 in several thousand hits).

• It looks like it happens for the same user a couple of times in a row (makes sense if they load more than 1 page with the same session problem)

• Examining the sessions table for the sessions where the problem is happening I see that the ‘data’ field is very large for these records, for example: gist:109af1b7f1595c115c85 · GitHub

All of the records with bad sessions have a very large amount of data in them, whereas my other session records look to have just a few lines of data in them.

Any suggestions for a remedy here?