SQL replication consistency fixes