Skip to content

[WIP] feat: query-level load balancer plugin#1739

Open
sergiyvamz wants to merge 2 commits into
mainfrom
feat-query-load-balancing
Open

[WIP] feat: query-level load balancer plugin#1739
sergiyvamz wants to merge 2 commits into
mainfrom
feat-query-load-balancing

Conversation

@sergiyvamz

@sergiyvamz sergiyvamz commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces a new qlb plugin. The main purpose of the new plugin is to provide a query-level load balancing among reader nodes.

  • New plugin is based on readWriteSplitting plugin and handle setReadOnly() calls similar to original readWriteSplitting plugin.
  • When a connection is read-only (i.e. after calling setReadOnly(true)), the new plugin switches reader connections on every call to createStatement(), preapreStatement(), or prepareCall().
  • Connection transaction boundaries are respected and no reader connection switches are occurred while in transaction.
final Properties props = new Properties();
props.setProperty("user", "test_user");
props.setProperty("password", "test_password");
props.setProperty("wrapperDialect", "mysql");
props.setProperty("wrapperPlugins", "qlb");
props.setProperty("readerHostSelectorStrategy", "roundRobin"); // "random"
props.setProperty("singleWriterConnectionString", "true");

String url = "jdbc:aws-wrapper:mysql://test-instance.XYZ.us-west-2.rds.amazonaws.com,test-instance-2.XYZ.us-west-2.rds.amazonaws.com,test-instance-3.XYZ.us-east-1.rds.amazonaws.com/";

try (final Connection conn = DriverManager.getConnection(url, props)) {

  conn.setReadOnly(true);

  while (true) {
	try (final Statement myStmt = conn.createStatement();
		final ResultSet rs = myStmt.executeQuery("SELECT @@hostname")) {
	  if (rs.next()) {
		String id = rs.getString(1);
		LOGGER.info("host id: " + rs.getString(1));
	  }
	}
  }
}

Description

Additional Reviewers

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sergiyvamz sergiyvamz changed the title feat: query-level load balancer plugin [WIP] feat: query-level load balancer plugin Feb 24, 2026
@sergiyvamz sergiyvamz added the wip Pull request that is a work in progress label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Pull request that is a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant