KCINFR-979: fixing uniqueness rule, changing locking key, adding a sort order