Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes readwrite-splitting data sources is incorrect when tableless #34340

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JoshuaChen
Copy link
Contributor

@JoshuaChen JoshuaChen commented Jan 13, 2025

Fix #34387

When using the following configuration, the value passed to rule.findDataSourceGroupRule(logicDataSourceName) is write_ds or read_ds_0, which fails to locate the correct dataSourceGroups (e.g., joshua in the configuration). This causes the ReadwriteSplitting logic to be skipped. This PR fixes the issue by ensuring the logicDataSourceName parameter passed is set to joshua.

mode:
  type: Standalone
  repository:
    type: JDBC

dataSources:
  write_ds:
    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://127.0.0.1:5432/mydatabase
    username: myuser
    password: secret
  read_ds_0:
    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://127.0.0.1:5432/mydatabase
    username: myuser
    password: secret
    readOnly: true

rules:
  - !READWRITE_SPLITTING
    dataSourceGroups:
      "joshua":
        writeDataSourceName: write_ds
        readDataSourceNames:
          - read_ds_0
        transactionalReadQueryStrategy: PRIMARY
        loadBalancerName: baseAA
    loadBalancers:
      baseAA: # Load balance algorithm name
        type: ROUND_ROBIN
  - !SINGLE
    tables:
      - "*.*.*"

props:
  sql-show: true

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

@JoshuaChen JoshuaChen marked this pull request as ready for review January 13, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readwrite-splitting data sources is incorrect when tableless
2 participants