You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "yx9o (via GitHub)" <gi...@apache.org> on 2026/04/26 15:07:59 UTC
[PR] Fix IllegalStateException when importing database configuration in Proxy [shardingsphere]
yx9o opened a new pull request, #38650:
URL: https://github.com/apache/shardingsphere/pull/38650
Fixes #38640 .
In cluster mode, IMPORT DATABASE CONFIGURATION registers storage units before importing rules. That registration triggers a metadata rebuild, which injects a default empty SingleRule because the new database still has no explicit rule configs. The import path then adds the YAML-derived SingleRule again, leaving two SingleRule instances and causing later getSingleRule(SingleRule.class) calls to fail.
---
Before committing this PR, I'm sure that I have checked the following options:
- [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) 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](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix IllegalStateException when importing database configuration in Proxy [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang merged PR #38650:
URL: https://github.com/apache/shardingsphere/pull/38650
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix IllegalStateException when importing database configuration in Proxy [shardingsphere]
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on PR #38650:
URL: https://github.com/apache/shardingsphere/pull/38650#issuecomment-4324252629
#### Decision
Merge Verdict: Mergeable
#### Reviewed Scope
- proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutor.java:134
- proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/util/YamlDatabaseConfigurationImportExecutorTest.java:205
- proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/
ImportDatabaseConfigurationExecutorTest.java:88
- proxy/backend/core/src/test/resources/conf/import/database-single.yaml:18
- Related shared-path checks: kernel/single/*, mode/core/*, mode/type/standalone/*, mode/type/cluster/*, and infra/common/* for rule-building and storage-
unit registration behavior.
#### Basis
The fix is on the root-cause path. YamlDatabaseConfigurationImportExecutor.addRule(...) now removes an existing in-memory rule with the same configuration
class before adding the imported one, which matches the failure mode for !SINGLE import into a freshly created database that already contains the default
SingleRule placeholder. The patch does not add fallback-only behavior; it changes the actual rule collection being built and persisted.
The new tests cover the important branches:
- no rules provided
- empty rules
- imported rule replaces an existing SingleRule
- imported rule is created during storage-unit registration
- import failure still drops the created database
That is enough evidence for the updated semantics, and I also checked adjacent non-target import cases. The shared import path still behaves for sharding,
readwrite-splitting, encrypt, shadow, and mask imports via the existing test matrix.
#### Pre-merge Checks
- Scoped verification run with escalation passed:
- ./mvnw -pl proxy/backend/core -am -DskipITs -Dspotless.skip=true -Dsurefire.failIfNoSpecifiedTests=false
-Dtest=YamlDatabaseConfigurationImportExecutorTest,ImportDatabaseConfigurationExecutorTest test -> exit 0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org