Pgpool2 doesn't use the slave for load balancing
-
10-10-2020 - |
Question
I've enabled streaming replication in my postgres 9.5.10 installed from ubuntu xenial repo. I want to enable load balance for pgpool-2 (3.7.0 amefuriboshi) installed from sources. So I have this pgpool.conf: https://pastebin.com/qWWgejQN
As you can see, I set both nodes, turned off replication, turned on master/slave mode and set it to stream. And also I enabled memcached caching.
Now I have very big problem that pgpool doesn't want to use slave for balancing:
postgres=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+----------------+------+--------+-----------+---------+------------+-------------------+-------------------
0 | localhost | 5433 | up | 0.500000 | primary | 0 | true | 0
1 | host2 | 5433 | unused | 0.500000 | standby | 0 | false | 0
(2 rows)
What am I do wrong?
Solution
I found this page http://lists.pgfoundry.org/pipermail/pgpool-general/2010-May/002711.html
They say that I need to remove file pgpool_status. I did it and pgpool works now with two nodes! Seems the file was created when I had not the second node and after pgpool just trusted this file all time. So removing this file solved the problem.
OTHER TIPS
Answer to a similar question : http://www.sraoss.jp/pipermail/pgpool-general/2017-May/005504.html
The relevant answer being:
Pgpool-II chooses one of DB nodes with a probability of the weight parameter when a client connects to Pgpool-II. "load_balance_node" is true if it is chosen, and false if it is not chosen. The decision is not relevant whether it is a master or a slave.