You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "thswlsqls (via GitHub)" <gi...@apache.org> on 2026/08/07 09:36:11 UTC
[PR] Fix CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
thswlsqls opened a new pull request, #39371:
URL: https://github.com/apache/shardingsphere/pull/39371
Fixes #39368.
Changes proposed in this pull request:
- Exclude `ReadwriteSplittingRule` itself from `ReadwriteSplittingRuleStatementChecker.getLogicDataSources()`, so an existing group name no longer collides with itself.
- `checkDuplicateRuleNamesWithExistsDataSources()` runs outside the `if (!ifNotExists)` guard, and the readwrite-splitting data source mapper is keyed by group name. So `CREATE READWRITE_SPLITTING RULE IF NOT EXISTS <existing_group>` threw `InvalidRuleConfigurationException` with `[<existing_group>] already exists in storage unit` instead of being a no-op.
- Mirrors the self-rule exclusion already used by `DropReadwriteSplittingRuleExecutor.getInUsedResources()` in the same module.
- Behavior change: without `IF NOT EXISTS`, creating an existing group name now throws `DuplicateRuleException` from `checkDuplicateRuleNamesWithRuleConfiguration()`. This is the contract the existing test `assertCheckCreationWithDuplicateRuleNameInCurrentRuleConfig` already expected.
- The relaxation covers only logic data source names exposed by the readwrite-splitting rule itself; collisions with storage unit names and with other rules' logic data source names are still rejected.
- Reworked `assertCheckCreationWithDuplicateRuleNameInLogicDataSources` onto `RuleMetaData#getRules`, keeping the negative case for another rule exposing the same name, and added `assertCheckCreationWithIfNotExistsWhenRuleNameExistsInOwnLogicDataSources`.
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] 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.
- [x] I have added corresponding unit tests for my changes.
- [x] 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 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
Posted by "thswlsqls (via GitHub)" <gi...@apache.org>.
thswlsqls commented on PR #39371:
URL: https://github.com/apache/shardingsphere/pull/39371#issuecomment-5549823687
@terrymanu Thanks for the review. You're right — skipping every `ReadwriteSplittingRule` mapper key also removes collision protection against expanded names, so creating literal `rw_0` while `rw_${0..1}` exists passes both duplicate checks and the rebuild then merges two definitions under one key. I'll exempt only the exact existing configurations discarded for `IF NOT EXISTS` and keep validating genuinely new segments against all expanded logical names, with a regression using an inline-expression group and its expanded literal name.
--
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 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
Posted by "thswlsqls (via GitHub)" <gi...@apache.org>.
thswlsqls commented on PR #39371:
URL: https://github.com/apache/shardingsphere/pull/39371#issuecomment-5552085441
@terrymanu `getLogicDataSources` is back to the full mapper-key set, and the exemption moved into `checkDuplicateRuleNamesWithExistsDataSources`, which now sees only the segments `getNotExistedSegments` keeps. `assertCheckCreationWithIfNotExistsWhenRuleNameExistsInExpandedLogicDataSources` creates literal `rw_0` against an existing `rw_${0..1}` and passes silently on the previous code (22 tests).
--
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 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
Posted by "thswlsqls (via GitHub)" <gi...@apache.org>.
thswlsqls commented on PR #39371:
URL: https://github.com/apache/shardingsphere/pull/39371#issuecomment-5349151969
@terrymanu Done — `checkCreation` now excludes segments whose rule name already exists from the remaining creation validations when `IF NOT EXISTS` is set, and genuinely new segments are still validated. `assertCheckCreationWithIfNotExistsWhenActualDataSourcesUnchanged` repeats the issue configuration with the same rule name and the same write and read storage units, and throws `DuplicateReadwriteSplittingActualDataSourceException` on the previous code; `assertCheckCreationWithIfNotExistsWhenNewSegmentDuplicatesExistedDataSource` keeps a new segment that reuses an existing write data source failing (21 tests).
--
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 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu merged PR #39371:
URL: https://github.com/apache/shardingsphere/pull/39371
--
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 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS for existing rule [shardingsphere]
Posted by "thswlsqls (via GitHub)" <gi...@apache.org>.
thswlsqls commented on PR #39371:
URL: https://github.com/apache/shardingsphere/pull/39371#issuecomment-5340425111
@terrymanu Thanks for the review. Confirmed — `checkCreation` runs `checkDuplicatedDataSourceNames` with `isCreating` true, so the existing group's own storage units seed the duplicate sets and the unchanged segment collides before the executor removes it. I'll skip existing-name segments for the remaining creation checks when `IF NOT EXISTS` is set, and add a case reusing the same rule name and storage units.
--
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