bug fix: stop replication before close
readd transaction