Wrap sync in a transaction to avoid pg transaction errors on updates