Fix threaded issue on syncing locations

This issue only really comes up in big migrations, but domain/site_code
are unique-together so creating two objects with empty domain and site
code values breaks the unique constraint.
Merge pull request #4772 from dimagi/thread-safe-location-sync

Fix threaded issue on syncing locations