Fix a bug, improve and speed up pgsql RA

Hi

I fixed a bug and improved pgsql RA.

- improve error handling
  - retry some commands whose failures are critical
- fix a bug which may cause data loss when using 3 nodes or higher
- improve performance