OAK-1406: Background operations block writes

Only acquire exclusive lock when needed. Invalidate cache in background
thread without holding lock.

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1567066 13f79535-47bb-0310-9956-ffa450edef68