Use `Gitlab::OptimisticLocking` to avoid `StaleObjectError` when an object is updated by multiple processes
Merge Train uses
state_machine for leveraging object's state. It generally works fine, however, when
outdate_pipeline run on the same object almost simultaneously, it could cause
StaleObjectError as that either of the objects is already been updated by the other.
We should use
OptimisticLocking to retry the state update in such case.
Follow-up from "Use state machine in Merge Train to avoid race conditions"
The following discussion from !23395 (merged) should be addressed: