Lock profile sync using a variable as a flag.
Using lock acquire.
Fix locking.
Merge pull request #5432 from openscholar/lock-sync

Lock profile sync