HY-love-sleep opened a new pull request, #7210:
URL: https://github.com/apache/shenyu/pull/7210
## What
`meta_data.pathExistedExclude` (used when updating a meta_data) filters only
by
`path` and the excluded ids, while its sibling `pathExisted` (used when
creating)
filters by `path AND namespace_id`. As a result an update was rejected with
`DATA_PATH_IS_EXIST` whenever the path existed in *another* namespace, even
though
the path is unique inside the namespace being updated.
The query now scopes by namespace too:
```diff
<select id="pathExistedExclude" resultType="java.lang.Boolean">
SElECT true
FROM meta_data
WHERE path = #{path}
+ AND namespace_id = #{namespaceId}
AND id NOT IN
```
`MetaDataMapper#pathExistedExclude` takes the `namespaceId` right after
`path`, mirroring
`pathExisted(path, namespaceId)`, and `MetaDataServiceImpl#update` passes
`metaDataDTO.getNamespaceId()` — the same value the create path already uses.
## Why
Closes #6689.
## Verified
`MetaDataMapperTest#pathExistedExcludeIsScopedByNamespace` (new, runs on H2
through
`AbstractSpringIntegrationTest`) inserts `/namespace-scoped-path` in
`namespace-a` and asserts:
* the same path in `namespace-b` no longer counts as an existing path (the
reported bug),
* a duplicate in the *same* namespace is still rejected,
* the row being updated is still excluded from its own check.
* `./mvnw -pl shenyu-admin test
-Dtest='MetaDataMapperTest,MetaDataServiceTest'` → Tests run: 32, Failures: 0,
Errors: 0
* the new test fails on the unfixed query (checked by reverting the mapper
change), so it guards the behaviour
* checkstyle: 0 violations
## Note
#6809 reports the same query from a performance angle (cross-namespace scan,
`NOT IN`,
unindexed `path`). The namespace filter removes the cross-namespace scan
here; the
suggested `(namespace_id, path)` index needs a schema change across all
supported
databases, so I deliberately kept it out of this PR and left it as a
follow-up.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]