'Check for if-match constraints and raise exception if violated.
We determine the collection being modified and look for any
objects of the collection type in the dirty/deleted items in
the session. If they don\'t match the revision_number constraint
supplied, we throw an exception.
We are protected from a concurrent update because if we match
revision number here and another update commits to the database
first, the compare and swap of revision_number will fail and a
StaleDataError (or deadlock in galera multi-writer) will be raised,
at which point this will be retried and fail to match.'

def _enforce_if_match_constraints(self, session):

    (instance, match) = self._get_constrained_instance_match(session)
    if ((not instance) or getattr(instance, '_rev_bumped', False)):
        return
    if (instance.revision_number != match):
        raise RevisionNumberConstraintFailed(match, instance.revision_number)
