Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1207

New HaMode: sequential write, loadbalance read

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • 3.5.1
    • Failover, galera
    • None

    Description

      This is a proposal / feature request for a new HA mode (sequential write, loadbalance read) in the MariaDb Connector/J.

      When running a multi-master cluster (i.e. Galera), writing to more than one node can lead to optimistic locking errors (weirdly called "deadlocks"), see https://galeracluster.com/library/kb/deadlock-found.html.
      Writing concurrently to multiple nodes also doesn't bring a whole lot of performance, due to having to (synchronously) replicate to all 3 nodes anyway.

      The recommended workaround is to use a read-write splitter (e.g. MaxScale) which would redirect writes to one node, but allow reading from multiple.

      Such read-write splitting looks like something that can be easily done client-side by the MariaDB Connector/J, by adding a new HaMode.java enum value that will:

      • pick the single write node sequentially (to ensure high-availability), but
      • load-balance multiple read nodes

      An example implementation could be as simple as:

        SEQUENTIAL_WRITE_LOADBALANCE_READ("sequential-write-load-balance-read") {
          @Override
          public Optional<HostAddress> getAvailableHost(
                  List<HostAddress> hostAddresses,
                  ConcurrentMap<HostAddress, Long> denyList,
                  boolean primary) {
            if (primary) {
              return SEQUENTIAL.getAvailableHost(hostAddresses, denyList, true);
            } else {
              return LOADBALANCE.getAvailableHost(hostAddresses, denyList, false);
            }
          }
        },
      

      Note: the implementation is not final/tested, but is rather meant to gauge interest for a potential PR and as a starting point for a discussion.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            Bragolgirith Bragolgirith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.