GRAILS-10294: fix to avoid repeated recalculation and some sync blocks for locking