I'm trying to understand Aurora fast failover implementation of Mariadb Connetor J. Although I am not java apps engineer, my prime work is jobs as DBA. I think I have little knowledge about OOP languages and have read the source code of mariadb connector J focusing related Aurora implementation. But it was difficult and cannot have confidence about my guess.
I really appreciate if share your knowledge about it or just any few comments.
In the latest version, we just register cluster endpoint of Aurora cluster and driver automatically find out every instance endpoint.
My guess how this logic work is
Driver generates every endpoint connect string from information_schema.REPLICA_HOST_STATUS that knows all instance identifiers on Sever_id column. There is a pattern about endpoint string. So once driver succeeded to connect any instance from cluster endpoint, driver can generate every instance endpoint.
After git every instance endpoints, driver throws a query "SHOW GLOBAL STATUS LIKE 'innodb_read_only'. If return value is 0(false), it set as Writer, otherwise set as Reader.
Driver push the connect string into "blacklist" if health check fails.( I cannnot find where health check is written though)
Driver tries to connect from not black-listed connect string, but if it fails, it tries black-listed connect string.
My guess is mainly from below java files.
- mariadb-connector-j/src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java
- mariadb-connector-j/src/main/java/org/mariadb/jdbc/internal/protocol/AuroraProtocol.java