Fix race condition found in T0 replay test. YG
Better exception handle for IntegrityError. YG
Merge pull request #278 from yuyiguo/To-replay2

To replay2