Wrapped select_for_update in atomic transactions. Hopefully this works.