Frederick Cheung wrote:
Perhaps it would; I've never used ActiveRecord locking at all, so I'll
defer to you here. �However, I tend to think that locking should
generally be implemented at the database level, not the application
level, which is why I suggested pessimistic here. �Am I missing
Well with optimistic locking it is ultimately the database enforcing
stuff - after all it is the only thing that can. If my memory is
correct the docs for optimistic locking have a decent explanation of
how it works.
If I understand the docs correctly, optimistic locking is *not* enforced
by the database -- rather, it's up to the app to properly handle
checking and updating the lock_version field. (The value is *stored* in
the DB, but the DB knows nothing about using it for lock enforcement.)
Pessimistic locking, by contrast, uses the DB's native locking
mechanisms. This makes it far more airtight than optimistic, I think.
Anyway, optimistic locking seems like reinventing the square wheel. Why