← Back to team overview

maria-discuss team mailing list archive

ODBC picking nearby connections?

 

Hi.

I have the following setup:

Two data centres which I shall label North and South for the following 
explanation.

Four virtual machines, Whiskey and Xray in data centre North, and Yankee and 
Zulu in data centre South, which have the Debian package unixodbc installed, 
together with libmaodbc.

Four other virtual machines, Alfa and Bravo in North and Charlie and Delta in 
South, all running MariaDB with Galera replication.

A single hostname DB.example.com which resolves to the four IP addresses of 
the four database servers Alfa, Bravo, Charlie and Delta.

Every instance of /etc/odbc.ini on machines Whiskey, Xray, Yankee and Zulu has 
the setting "SERVER=DB.example.com" in it.


When I start an application which uses ODBC (in my case this is Asterisk), I 
find that each application server manages to connect to a database server in 
its own data centre.  Given a 50% chance of this happening for machine 
Whiskey, a 50% chance for machine Xray, etc., this comes out as a 1 in 16 
combined probability of happening by chance.

Therefore I think it is not by chance :)

I've done some packet captures, and I see each machine Whiskey, Xray, Yankee 
and Zulu doing a single DNS query for DB.example.com and getting the four IP 
addresses of Alfa, Bravo, Chalie and Delta returned.  As expected, the order 
the addresses is returned in is randomised for different queries.  Each machine 
then makes a single connection to MariaDB on port 3306 on one of the IP 
addresses in the list.  This address can be the first in the list returned from 
the DNS resolver, or it can the the last one, or it can be on in the middle.

There is no attempt to ping the four addresses and compare round-trip times, 
or to connect to MariaDB on more than one server and measure the query 
response times.  Each applicaton server connects to one database server, and 
they always manage to connect to a machine in their own data centre.

My question is: how do they do this?

How does machine Whiskey manage to select one of the two IP addresses for 
database servers Alfa and Bravo, and connect to it, ignoring the addresses for 
Charlie and Delta?


If I can supply any further information to help with answering this question, 
please let me know.


Thanks,


Antony.

-- 
"Have you been drinking brake fluid again?  I think you're addicted to the 
stuff."

"No, no, it's alright - I can stop any time I want to."

                                                   Please reply to the list;
                                                         please *don't* CC me.