Fastcgi help!

Something really weird happened with my app recently and i’m lost on
what
exactly happened.

I have a bunch of validations setup in my models to ensure that no
records
have identical columns within a certain date range. So user x can only
post
a blog entry to blog y once a month (example).

However, i saw that this validation failed on script that posts a bunch
of
entries all by the same user. So the db showed the same user posting to
the
same blog all within a few seconds of each other.

I looked at my access log and saw that there were 2 HTTP POSTs to the
controller at the same time that these duplicate entries got saved. I
found
this weird because i had the validations in place, and when i test on my
laptop i’m not able to recreate it. This made me think about fastcgi as
the
culprit. Could it be that 2 fastcgi processes go the request at the
same
time and independently validated the data? Meaning that when either
fcgi
process did a read to validate, they both passed because neither had
committed the data yet.

Does this sound reasonable? If so, how would i go about guarding
against
this?

Please, please help. Thanks in advance.

I think I’m seeing the same thing. I have a model, Member, that has:

validates_uniqueness_of :email

Yet, I have some non-unique emails. I’ve got a test that tries to create
2
members with the same email and it fails appropriately.

Any suggestions?

Thanks,

-Kelly