Fix prefer_lower_delay_standby bug.
When client connects to pgpool, one of standbys are chosen as the load
balancing node. If standby delay exceeds delay_threshold while the
session continues, prefer_lower_delay_standby will choose the least
delay standby node as the new load balancing node and set the target
backend to the node. Unfortunately the decision was made *before* the
checking that SELECT query includes writing function etc., pgpool
happily sends SELECT which cannot be executed on standby. To fix
this, prefer_lower_delay_standby treatment is moved after the writing
function etc. check.
033.prefer_lower_standby_delay regression test is modified to include
the case above. Also I have done some refactoring:
- Remove unnecessary while loop for each clustering mode because the
test is only useful for streaming replication mode.
- Add checking wal_replay_pause is actually executed.
Bug reported by: https://www.pgpool.net/mantisbt/view.php?id=798
along with suggested fix.