Repository navigation
IGNITE-28907 Disallow mixing query entity configuration APIs and use last-call-wins semantics - #13583
Conversation
|
Ignite PR Checker verdict · RunAll build 9344108 · 147 suites ran, 0 reused
Everything below is what it did manage to say.
🔍 1 suite(s) ran fewer tests than on master (tests that never ran can't fail):
❌ 8 blocker(s) in 5 suite(s):
|
c4ff85d to
2527db4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds QueryEntity metadata merging across CacheConfiguration calls, including fields, indexes, and type conflicts.
Changes:
- Introduces
QueryEntityMerger. - Updates configuration merging behavior and conflict validation.
- Adds comprehensive tests and adjusts indexing tests.
File summaries
| File | Description |
|---|---|
| modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java | Updated as part of this pull request. |
| modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsIndexingDefragmentationTest.java | Updated as part of this pull request. |
| modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DuplicateKeyValueClassesSelfTest.java | Updated as part of this pull request. |
| modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationQueryEntityMergeTest.java | Updated as part of this pull request. |
| modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedIndexTest.java | Updated as part of this pull request. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityMerger.java | Updated as part of this pull request. |
| modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java | Updated as part of this pull request. |
Review details
Suppressed comments (3)
modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityMerger.java:73
- With the default
sqlEscapeAll=false,QueryUtils.normalizeObjectNameuppercases table names before schema creation. Comparing the raw values here makes otherwise compatible fragments usingPersonandPERSONconflict even though they resolve to the same SQL table, so configuration fails before normalization; use the cache's SQL escaping/normalization policy when comparing this property.
res.setTableName(mergeProperty("tableName", ex.getTableName(), in.getTableName()));
modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityMerger.java:245
- The map is keyed by the effective name from
QueryUtils.indexName, butQueryIndex.equalsalso compares the rawnamefield. Consequently, an unnamed index and an explicitly named index whose name equals the generated name hit the same map entry and are always reported as conflicting, although normalization produces the same index. Compare canonical index definitions rather than the raw object equality here.
if (!existingIdx.equals(incomingIdx))
throw mergeConflict("index[" + idxName + ']', existingIdx, incomingIdx);
modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityMerger.java:97
- This compares raw key type names, so a supported primitive declaration such as
QueryEntity.setKeyType("int")conflicts withsetIndexedTypes(Integer.class, ...), even thoughsetIndexedTypesboxes primitive classes andQueryUtilsexplicitly resolves/boxes primitive key types. Canonicalize resolved key types before deciding they conflict, while retaining support for non-loadable binary type names.
if (exKeyType != null && inKeyType != null && !Objects.equals(exKeyType, inKeyType)) {
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| /** Query entities with different value types must not be merged. */ | ||
| @Test | ||
| public void testDifferentValueTypesAreNotMerged() throws Exception { |
There was a problem hiding this comment.
naming confusing, i see test for public API - this test - how it need\plan to work. I mean - one cache can contain numerous of different QueryEntitys, isnt it ? This test need to work perfectly well without your changes i suppose, if i`m right - you need to rename it.
There was a problem hiding this comment.
Correct, we can have entities with the same key type, but with different value type. You’re right, this was working correctly before my changes. This is actually a regression test: I think it’s important to make sure that QueryEntityMerger doesn’t try to merge such entities and doesn’t view them as a conflict. I changed the name and javadoc to make it more obvious.
|
Ignite PR Checker verdict · RunAll build 9382694 · 147 suites ran, 0 reused 👀 489 test(s) started failing on this code — not proven blockers yet: too few runs of this revision to tell a break from a flake, so a re-run of the suite decides it.
❌ 3 blocker(s) in 3 suite(s):
|
84f14de to
0e6d39d
Compare
|
Ignite PR Checker verdict · RunAll build 9384769 · 147 suites ran, 0 reused
Everything below is what it did manage to say.
🔎 No blockers found — but the run above can't prove the PR is clean. 0 pre-existing/flaky tests filtered out. Re-run once the above is sorted out. |
|
Ignite PR Checker verdict · RunAll build 9385078 · 147 suites ran, 0 reused
Everything below is what it did manage to say.
🔎 No blockers found — but the run above can't prove the PR is clean. 0 pre-existing/flaky tests filtered out. Re-run once the above is sorted out. |
|
Ignite PR Checker verdict · RunAll build 9385276 · 147 suites ran, 0 reused 👀 1 test(s) started failing on this code — not proven blockers yet: too few runs of this revision to tell a break from a flake, so a re-run of the suite decides it.
|
|
Ignite PR Checker verdict · RunAll build 9386823 · 147 suites ran, 0 reused
Everything below is what it did manage to say.
👀 4 test(s) started failing on this code — not proven blockers yet: too few runs of this revision to tell a break from a flake, so a re-run of the suite decides it.
|
|
Ignite PR Checker verdict · RunAll build 9387293 · 147 suites ran, 0 reused 👀 21 test(s) started failing on this code — not proven blockers yet: too few runs of this revision to tell a break from a flake, so a re-run of the suite decides it.
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
This copy always turns the merged object into a plainQueryEntity. However,setQueryEntitiesis…setQueryEntitieswill throw aNullPointerExceptionif called withnullbecause of `new… · New Ifnamehasn’t been set yet, the thrown message will containcacheName=null, which is not very… · New This introduces a newpublictype in a public API package (org.apache.ignite.configuration)… · New Using a hard-coded relative path for test resources can make the test sensitive to the JVM working… · New This call relies on ajcache(...)overload taking(Ignite, CacheConfiguration, String). In this… · New
Review effort: Lite
| public CacheConfiguration<K, V> setQueryEntities(Collection<QueryEntity> qryEntities) { | ||
| if (this.qryEntities == null) { | ||
| this.qryEntities = new ArrayList<>(qryEntities); | ||
|
|
||
| return this; | ||
| } | ||
| checkQueryEntityConfigurationSource(QueryEntityConfigurationSource.QUERY_ENTITIES); | ||
|
|
||
| for (QueryEntity entity : qryEntities) { | ||
| boolean found = false; | ||
| this.qryEntities = new ArrayList<>(qryEntities); | ||
|
|
||
| for (QueryEntity existing : this.qryEntities) { | ||
| if (Objects.equals(entity.findValueType(), existing.findValueType())) { | ||
| found = true; | ||
|
|
||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!found) | ||
| this.qryEntities.add(entity); | ||
| } | ||
| qryEntityCfgSrc = QueryEntityConfigurationSource.QUERY_ENTITIES; | ||
|
|
||
| return this; | ||
| } |
There was a problem hiding this comment.
Added fallback to an empty collection for the null argument + coverage in CacheConfigurationQueryEntityTest#testEmptySetQueryEntitiesClearsPreviousEntities.
| private void checkQueryEntityConfigurationSource(QueryEntityConfigurationSource src) { | ||
| if (qryEntityCfgSrc != null && qryEntityCfgSrc != src) | ||
| throw new CacheException(String.format(MIXED_QUERY_ENTITIES_API_ERROR_TEMPLATE, name)); |
There was a problem hiding this comment.
Added fallback to <unnamed>.
| public final class CacheConfigurationInternalAccessor { | ||
| /** */ | ||
| private CacheConfigurationInternalAccessor() { | ||
| // No-op. | ||
| } | ||
|
|
||
| /** | ||
| * Replaces query entities without changing the query-entity configuration source. | ||
| * | ||
| * @param cfg Cache configuration. | ||
| * @param qryEntities Query entities. | ||
| */ | ||
| public static void replaceQueryEntities(CacheConfiguration<?, ?> cfg, Collection<QueryEntity> qryEntities) { | ||
| cfg.replaceQueryEntities(qryEntities); | ||
| } | ||
| } |
| /** Tests that Spring XML configuration cannot mix indexed types and explicit query entities. */ | ||
| public class CacheConfigurationQueryEntityXmlTest extends GridCommonAbstractTest { | ||
| /** */ | ||
| private static final String CONFIG_DIR = "modules/spring/src/test/config/query-entities/"; |
There was a problem hiding this comment.
Added path resolution via resolveIgnitePath().
| )); | ||
|
|
||
| IgniteCache<Object, Object> c = jcache(ignite(), conf, Object.class, Object.class); | ||
| IgniteCache<Object, Object> c = jcache(ignite(), conf, "Object-Object"); |
There was a problem hiding this comment.
The existing jcache(Ignite, CacheConfiguration, String) overload only copies the configuration, sets the cache name, and gets or creates the cache. It does NOT modify query entities.
jcacheWithSpecifiedName(...) additionally adds a query entity for the supplied key/value types if one is missing. Using it with Object.class here would add an unnecessary entity, so I would keep the existing call. Overload resolution is unambiguous with these three arguments.
…ePdsIndexingDefragmentationTest
… to existing tests due to contract changes
|
@oleg-vlsk Ignite PR Checker verdict · RunAll build 9460568 · tested 15bd16d · 149 suites ran, 0 reused
Everything below is what it did manage to say.
🔍 13 suites ran fewer tests than on master (tests that never ran can't fail):
❌ 1 blocker in 1 suite, all on 1 run:
1 run: the test ran once on this code and failed; a re-run of its suite confirms or clears it. What each label means and what to do: verdict glossary. ➡️ Next: fix the blockers, push, and run RunAll again — a |
15bd16d to
5a01b47
Compare



Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see tabPR Checkat TC.Bot - Instance 1 or TC.Bot - Instance 2)Notes
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.