0

I use MySQL with Galera wsrep to get synchronous replication, that part it's up and running

I need to setup a kind of proxy to handle client connections. Since any node in cluster can fail, clients will not connect nodes directly, but only via proxy.

Currently I use Galera Load Balancer which does it work, but with one exception: if one node fails, all clients connected via proxy to that node get connection error and need to reconnect.

I have no control over server applications connected to proxy and some of them can't reconnect automatically and need manual restart. So the question is how to force proxy automatically redirect already connected applications to new data node, without need to reconnect?

Matthias
  • 459
  • 1
  • 5
  • 15

1 Answers1

1

There are 2 questions actually:

  1. glbd sends most (not all) new connections to the failed node because by default it uses "least connected" balancing policy and if the node accepts TCP connections, then it will be it since connections will be short-lived and it will have least loaded from glbd point of view. So it works only if the node crashes. Use round-robin balancing policy, to ensure that eventually application will connect to a working server or use glb-1.0.0beta which can poll server status using mysql client and make more intelligent decisions.
  2. In general it is next to impossible to migrate client connections without reconnecting and reauthenticating, because even if the proxy reconnects and reauthenticates with the server on behalf of the application (which implies that the proxy can authenticate the client the same way mysqld does, or it can spy and replay client authentication handshake with the server (which is even less likely)) - even after all that it is next to impossible to recreate the same session context that the application had on the crashed server (so it does not notice the reconnect)
ayurchen
  • 386
  • 3
  • 9