Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
imbajin merged PR #3184: URL: https://github.com/apache/hugegraph/pull/3184 -- 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] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
imbajin commented on PR #3184: URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-5701198188 +1, agreed with the scope and merge order. @SebastianGruza @contrueCT @bitflicker64 this PR can go in ahead of #2994. The range guard is appropriately scoped, and the review threads are now resolved. After merging, please rebase #2994 and post the HStore/RocksDB regression results for the new head there, as planned. Keep #3090 open for the codec and remaining scan-path follow-ups, and update both threads to distinguish what #3184 fixes from what remains outstanding. -- 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] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on PR #3184: URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-5694248322 @contrueCT thanks, agreed on the order. Once #2994 is rebased on a master that contains this PR, I will run the same HStore/RocksDB matrix (the same queries on both backends, compared as id sets, 170+ shapes) on the new head and post the result under #2994. @bitflicker64 the `queryAll()` point is handled in 89bb0ec (a comment line) and recorded in #3090 (https://github.com/apache/hugegraph/issues/3090#issuecomment-5694243559); details and the measurement are in the inline thread. -- 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] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
bitflicker64 commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r4023288079
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -640,21 +647,20 @@ protected BackendColumnIterator queryByRange(Session
session,
if (query.paging() && !query.page().isEmpty()) {
position = PageState.fromString(query.page()).position();
}
+byte[] queryBytes = null;
if (origin instanceof ConditionQuery &&
(query.resultType().isEdge() || query.resultType().isVertex())) {
-cq = (ConditionQuery) query.originQuery();
-
-// LOG.debug("query {} with ownerKeyFrom: {}, ownerKeyTo: {}, " +
-// "keyFrom: {}, keyTo: {}, " +
-// "scanType: {}, conditionQuery: {}",
-// this.table(), bytes2String(ownerStart),
-// bytes2String(ownerEnd), bytes2String(start),
-// bytes2String(end), type, cq.bytes());
-return session.scan(this.table(), ownerStart,
-ownerEnd, start, end, type, cq.bytes(),
position);
-}
-return session.scan(this.table(), ownerStart,
-ownerEnd, start, end, type, null, position);
+// Same guard as queryByPrefix(): only push the query down to the
+// store when user-prop conditions remain. A sort-key prefix/range
+// query keeps sysprop conditions only (owner vertex, direction,
+// label, sort values), which are already enforced by the key
+// range, and the store-side row decoder cannot parse the raw
+// property layout written by the server (see issue #3090).
+ConditionQuery cq = prepareConditionQuery((ConditionQuery) origin);
Review Comment:
⚠️ The guard lands here, but the same unguarded pushdown survives in
`queryAll()` (lines 448-469), which pushes `((ConditionQuery) query).bytes()`
on both exits with no guard at all. Unlike the `prepareConditionQueryList()`
path discussed earlier on this PR, that one has a live caller: `queryBy()`
(line 405) -> `queryByCond()` (line 707) -> `queryAll()`.
Reachability for a sysprop-only condition query such as
`g.V().hasLabel('person')` or `g.E().hasLabel('flow')`:
`BinarySerializer.writeQueryEdgePrefixCondition()`
(`BinarySerializer.java:721-763`) returns `null` when `OWNER_VERTEX` is absent
(the loop breaks on the first key, `count == 0`), and `writeQueryCondition()`
(line 765-769) returns the query unchanged for non-index types, so a plain
`ConditionQuery` arrives at `queryBy()` with conditions but no id, prefix or
range and falls through to `queryAll()`. `HstoreSessionsImpl` then hands those
bytes straight to the store (`scan(String, byte[])` at line 582-588, paging
overload at 710-729), i.e. the same `FilterIterator` ->
`parseEdge`/`parseVertex` decoder this PR is avoiding. The shard scan
`queryByRange(Session, Shard, ConditionQuery)` (line 710-728) calls
`query.bytes()` unconditionally too.
Worth noting that `prepareConditionQuery()` cannot simply be copied to
`queryAll()`: nothing else enforces the label there, since
`GraphTransaction.rightResultFromIndexQuery()` returns `true` early for a
label-only edge `ConditionQuery` (`GraphTransaction.java:1914-1918`), so
dropping the pushdown would return unfiltered rows.
Requested change: record `queryAll()` and the shard overload explicitly in
the #3090 follow-up, and add a line to the comment above saying the guard
applies to the range path because the key range already covers its sysprops,
while the full-scan path still needs the pushdown to filter.
Confidence: the reachability trace is confirmed statically on this head. I
could not reproduce the decode failure on a live PD + HStore cluster, so the
size of the residual gap is taken from the root cause in the PR description
rather than measured.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r4023880205
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -640,21 +647,20 @@ protected BackendColumnIterator queryByRange(Session
session,
if (query.paging() && !query.page().isEmpty()) {
position = PageState.fromString(query.page()).position();
}
+byte[] queryBytes = null;
if (origin instanceof ConditionQuery &&
(query.resultType().isEdge() || query.resultType().isVertex())) {
-cq = (ConditionQuery) query.originQuery();
-
-// LOG.debug("query {} with ownerKeyFrom: {}, ownerKeyTo: {}, " +
-// "keyFrom: {}, keyTo: {}, " +
-// "scanType: {}, conditionQuery: {}",
-// this.table(), bytes2String(ownerStart),
-// bytes2String(ownerEnd), bytes2String(start),
-// bytes2String(end), type, cq.bytes());
-return session.scan(this.table(), ownerStart,
-ownerEnd, start, end, type, cq.bytes(),
position);
-}
-return session.scan(this.table(), ownerStart,
-ownerEnd, start, end, type, null, position);
+// Same guard as queryByPrefix(): only push the query down to the
+// store when user-prop conditions remain. A sort-key prefix/range
+// query keeps sysprop conditions only (owner vertex, direction,
+// label, sort values), which are already enforced by the key
+// range, and the store-side row decoder cannot parse the raw
+// property layout written by the server (see issue #3090).
+ConditionQuery cq = prepareConditionQuery((ConditionQuery) origin);
Review Comment:
Done in 89bb0ec: four lines above the guard now say it applies to the range
path only, because the key range already covers its sysprops, while the
full-scan path (`queryAll()` and the shard overload of `queryByRange`) still
needs the pushdown to filter. `queryAll()` and the shard overload are recorded
in the #3090 follow-up:
https://github.com/apache/hugegraph/issues/3090#issuecomment-5694243559.
Two things from the lab on the reachability itself, master `36811483`, the
same cluster as in the PR description:
- The `g.E().hasLabel('flow')` example does not reach `queryAll()` on
hstore. `HstoreFeatures.supportsQueryByLabel()` returns `false`, so for a
label-only query `GraphTransaction.optimizeQuery` (line 1655) does not hand the
query to the backend; `GraphIndexTransaction.queryByLabel` goes to the label
index table and fetches the edges by id. Measured: a label with the label index
enabled and 3 edges → 3 rows, also with `valueMap(true)`; a label with the
label index disabled → 400 "label index is disabled", raised in core. The same
3 rows through `g.V(x).outE(l).has('asset','ETC')` → `Can't construct
Cardinality from code 0`, so the rows do trip the decoder. `g.E()` without
`has()` sends a plain `Query` (`HugeGraphStep.makeQuery`), so `queryAll()`
pushes `null`.
- Two paths really do push an unguarded `ConditionQuery`: the paged full
scan `g.E().has('~page','').limit(2).valueMap(true)` (paging branch of
`queryAll()`) and REST `/traversers/edges/scan?page=&page_limit=2` (shard
overload). Both returned rows on master, on the same owner's edges on which the
range path fails. I did not trace why the decoder is not tripped there, so I
leave both open in #3090 rather than call them safe.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
contrueCT commented on PR #3184: URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-5692551993 @SebastianGruza @imbajin I think it makes sense to merge #3184 before #2994. The change here is relatively isolated: it avoids pushing sysprop-only range conditions to HStore when those constraints are already covered by the key range, while user-property residual conditions are still pushed down. Also, copying the `ConditionQuery` before trimming it avoids mutating the query still used by the core layer. More importantly, #3184 removes an existing HStore failure unrelated to #2994. Without it, the HStore regression for #2994 is partially blocked by #3090, which makes failures harder to attribute. So I suggest merging #3184 first, then rebasing #2994 on the latest master and rerunning the HStore/RocksDB regression matrix. #3090 should still remain open since #3184 is only a mitigation for the underlying codec issue. -- 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] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r4014836275
##
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreTableTest.java:
##
@@ -124,6 +134,101 @@ public void
testRangeScanBudgetIncludesOneLookaheadRecord() {
Assert.assertEquals(14L, HstoreTable.rangeScanBudget(query));
}
+@Test
+public void testRangeQueryWithoutUserpropsDoesNotPushConditions() {
+// Sort-key prefix/range queries keep sysprop conditions only (owner
+// vertex, direction, label, sort values); those are enforced by the
+// key range already and must not be pushed to the store, whose row
+// decoder cannot parse the server's raw property layout (issue #3090)
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.eq(HugeKeys.DIRECTION, Directions.OUT);
+origin.eq(HugeKeys.LABEL, IdGenerator.of(1L));
+origin.gte(HugeKeys.SORT_VALUES, "ETC!");
+origin.lt(HugeKeys.SORT_VALUES, "ETC~");
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNull(session.lastQueryBytes);
+Assert.assertEquals(before, origin.conditions().size());
+}
+
+@Test
+public void testRangeQueryWithUserpropsPushesCopyAndKeepsOrigin() {
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.query(Condition.eq(IdGenerator.of(7L), 100));
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNotNull(session.lastQueryBytes);
+// the pushed-down query is a copy: the origin query keeps all its
+// conditions for core-side filtering after the scan returns
+Assert.assertEquals(before, origin.conditions().size());
+// pushed payload: user-prop condition survives, owner-vertex is
+// dropped, and the back reference to the origin query is cleared
+ConditionQuery pushed =
ConditionQuery.fromBytes(session.lastQueryBytes);
+Assert.assertNull(pushed.condition(HugeKeys.OWNER_VERTEX));
+Assert.assertFalse(pushed.userpropConditions().isEmpty());
+Assert.assertNull(pushed.originQuery());
+}
+
+@Test
+public void testPrefixListQueryPushesCopyAndKeepsOrigin() {
+// prepareConditionQueryList() is reached from queryByPrefixList() and
Review Comment:
Done in eb5e05a — the comment now says the method is called from
`queryByPrefixList()` and the streaming `query(Session, Iterator, String)`,
that neither has a live caller in the server today, and that the test pins the
method contract. Comment-only change, no code touched.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-5652968688
@imbajin @contrueCT, a request for a decision on this PR. It is a 12-line
guard in `HstoreTable.queryByRange()`, the same one `queryByPrefix()` has had
for a long time; CI has been green since Sep 7 and @bitflicker64 went through
three rounds without finding a regression ("blocking: no" three times, unit
tests 8/8, checkstyle clean). There has been no reaction since, so I am asking
directly: can it go in ahead of #2994?
The reason I ask about the order: without this guard #2994 cannot be
verified on HStore. Our backend axis for #2994 (the same queries on hstore and
rocksdb, compared as id sets) gave 38 TARGET-ERR failures from #3090 before
#3184 was on the branch, and OK=170 with it. Anyone reviewing #2994 on hstore
will hit the same wall; @contrueCT noted this in #3090 on Sep 3.
### Codecov
The only red check is `codecov/patch`. It is an artifact: the surefire run
of the `hugegraph-hstore` module is not part of the coverage upload, so the
report shows 0 % for the changed lines even though `HstoreTableTest` (8 tests)
covers them; @bitflicker64's review ran that module locally. I have added this
sentence to the PR description so nobody has to work it out.
### What this bug blocks on 1.7.0 with HStore
The reproducer in the description has 3 edges. Below is the same failure on
5 M edges, on a schema with four sort keys (`xfer[btc_addr, seq, height,
asset]`, vertex ids are BTC/ETH-style addresses), 13 query shapes from one
vertex, master `36811483` vs PR head `0ecc10a3`, hstore vs rocksdb on the same
data. The servers were swapped in place without reloading the data.
| shape, from `g.V(v)` | master hstore | master rocksdb | #3184 hstore | id
sets #3184 hstore = rocksdb |
|---|---|---|---|---|
| `outE('xfer')`, no condition | 57 | 57 | 57 | same |
| `.has('btc_addr',A)` prefix 1 | **500 `Can't construct Cardinality from
code 0`** | 2 | 2 | same |
| `.has('btc_addr',A).has('seq',S)` prefix 2 | **500** | 1 | 1 | same |
| prefix 1 + `has('seq',gte(1))` | **500** | 2 | 2 | same |
| prefix 2 + `has('height',between(..))` | **500** | 1 | 1 | same |
| all four keys `eq` | 1 | 1 | 1 | same |
| prefix 3 + `has('asset',gte('a'))` | 1 | 1 | 1 | same |
| `.has('seq',S)` alone (not a prefix, filter) | 1 | 1 | 1 | same |
| `.has('amount',gte(0))` (not a sort key) | 57 | 57 | 57 | same |
| prefix 1 + `has('amount',gte(0))` | **500** | 2 | 2 | same |
| `bothE('xfer').has('btc_addr',A)` | **500** | 2 | 2 | same |
| `...inV().inE('xfer').has('btc_addr',A)` | **500** | 1 | 1 | same |
| prefix 1 + `valueMap()` | **500** | 2 | 2 | same |
On master with HStore **every partial sort-key prefix and every range on a
key other than the last one fails**, including `bothE`, `inE` and reading the
properties; only "no condition", "all keys equal" and non-prefix filters work.
So the whole use case sort keys exist for (the vertex-centric index) is
unavailable on 1.7.0 with HStore. With #3184 all 13 shapes pass and return the
same ids as RocksDB.
Script, raw results and log:
[`results/pr-3184-sortkeys/`](https://github.com/SebastianGruza/hugegraph-validation/tree/master/results/pr-3184-sortkeys).
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
codecov[bot] commented on PR #3184: URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-964343 ## [Codecov](https://app.codecov.io/gh/apache/hugegraph/pull/3184?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 93.25%. Comparing base ([`98477f0`](https://app.codecov.io/gh/apache/hugegraph/commit/98477f0f56a3ad49593ec7632f2f0ee13e72f0dd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0ecc10a`](https://app.codecov.io/gh/apache/hugegraph/commit/0ecc10a3d03c8227e755c1f59841d98a7ead2a0d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). :warning: Report is 1 commits behind head on master. Additional details and impacted files ```diff @@ Coverage Diff @@ ## master#3184 +/- ## = + Coverage 37.78% 93.25% +55.47% + Complexity 6556 65 -6491 = Files 8009 -791 Lines 68929 267-68662 Branches 9157 22 -9135 = - Hits 26046 249-25797 + Misses398248-39816 + Partials 3059 10 -3049 ``` [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/hugegraph/pull/3184?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :rocket: New features to boost your workflow: - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. -- 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] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
bitflicker64 commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r3928440003
##
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreTableTest.java:
##
@@ -124,6 +134,101 @@ public void
testRangeScanBudgetIncludesOneLookaheadRecord() {
Assert.assertEquals(14L, HstoreTable.rangeScanBudget(query));
}
+@Test
+public void testRangeQueryWithoutUserpropsDoesNotPushConditions() {
+// Sort-key prefix/range queries keep sysprop conditions only (owner
+// vertex, direction, label, sort values); those are enforced by the
+// key range already and must not be pushed to the store, whose row
+// decoder cannot parse the server's raw property layout (issue #3090)
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.eq(HugeKeys.DIRECTION, Directions.OUT);
+origin.eq(HugeKeys.LABEL, IdGenerator.of(1L));
+origin.gte(HugeKeys.SORT_VALUES, "ETC!");
+origin.lt(HugeKeys.SORT_VALUES, "ETC~");
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNull(session.lastQueryBytes);
+Assert.assertEquals(before, origin.conditions().size());
+}
+
+@Test
+public void testRangeQueryWithUserpropsPushesCopyAndKeepsOrigin() {
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.query(Condition.eq(IdGenerator.of(7L), 100));
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNotNull(session.lastQueryBytes);
+// the pushed-down query is a copy: the origin query keeps all its
+// conditions for core-side filtering after the scan returns
+Assert.assertEquals(before, origin.conditions().size());
+// pushed payload: user-prop condition survives, owner-vertex is
+// dropped, and the back reference to the origin query is cleared
+ConditionQuery pushed =
ConditionQuery.fromBytes(session.lastQueryBytes);
+Assert.assertNull(pushed.condition(HugeKeys.OWNER_VERTEX));
+Assert.assertFalse(pushed.userpropConditions().isEmpty());
+Assert.assertNull(pushed.originQuery());
+}
+
+@Test
+public void testPrefixListQueryPushesCopyAndKeepsOrigin() {
+// prepareConditionQueryList() is reached from queryByPrefixList() and
Review Comment:
🧹 Worth stating what sits above these two call sites: nothing calls either
of them in a live server, so `prepareConditionQueryList()` does not run today.
As written, lines 184-186 read as a description of a live path.
`queryByPrefixList` (`HstoreTable.java:526`) has one production caller,
`HstoreTable.query(Session, List, String)` (line 331), whose
only caller is `HstoreStore.query(List, List)`
(`HstoreStore.java:506`), and that overload is never called:
`HstoreStore.java:492` passes a `QueryWrapper implements
Iterator` and so binds to the `Iterator` overload at line 540.
The streaming `query(Session, Iterator, String)`
(`HstoreTable.java:348`, called from `HstoreStore.java:557`) is reachable only
through `BackendStore.query(Iterator, Function, HugeGraph)`
(`BackendStore.java:75-78`), which carries the comment `// TODO: unused now`;
nothing in the repository supplies its `queryWriter` argument.
This withdraws the reachability half of my earlier comments (`3916985809`,
`3921393173`), which called these call sites live and are where the wording
here came from. The guard mismatch itself still stands, but it cannot reach the
store row decoder as things are, which is worth recording in the #3090
follow-up.
Requested change, optional and not worth a repush on its own: reword lines
184-186 to say the method is called from those two sites and that neither has a
live caller today.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r3926342194
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -642,16 +650,16 @@ protected BackendColumnIterator queryByRange(Session
session,
}
if (origin instanceof ConditionQuery &&
(query.resultType().isEdge() || query.resultType().isVertex())) {
-cq = (ConditionQuery) query.originQuery();
-
-// LOG.debug("query {} with ownerKeyFrom: {}, ownerKeyTo: {}, " +
-// "keyFrom: {}, keyTo: {}, " +
-// "scanType: {}, conditionQuery: {}",
-// this.table(), bytes2String(ownerStart),
-// bytes2String(ownerEnd), bytes2String(start),
-// bytes2String(end), type, cq.bytes());
+// Same guard as queryByPrefix(): only push the query down to the
+// store when user-prop conditions remain. A sort-key prefix/range
+// query keeps sysprop conditions only (owner vertex, direction,
+// label, sort values), which are already enforced by the key
+// range, and the store-side row decoder cannot parse the raw
+// property layout written by the server (see issue #3090).
+cq = prepareConditionQuery((ConditionQuery) origin);
+byte[] queryBytes = cq == null ? null : cq.bytes();
Review Comment:
Done in 0ecc10a — `queryBytes` is initialised before the `if`, assigned
inside it, and the method ends with a single `session.scan(...)`; `cq` is
block-local now.
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -594,8 +599,11 @@ private ConditionQuery
prepareConditionQueryList(ConditionQuery conditionQuery)
}
}
if (newConditions.size() > 0) {
-conditionQuery.resetConditions(newConditions);
-return conditionQuery;
+// NOTE: copy before reset, see prepareConditionQuery()
+ConditionQuery pushdown = conditionQuery.copy();
+pushdown.resetConditions(newConditions);
+pushdown.setOriginQuery(null);
Review Comment:
Done in 0ecc10a — `ScanRecordingSession.scan(String, List, int,
long, byte[])` now records (query bytes, owner keys, one iterator per key)
instead of throwing, and `testPrefixListQueryPushesCopyAndKeepsOrigin` drives
`prepareConditionQueryList()` through `queryByPrefixList()` with one origin
shared by two prefix queries: the origin keeps all of its conditions including
`OWNER_VERTEX`, the decoded pushed payload has no `OWNER_VERTEX`, keeps `LABEL`
and the user-prop condition, and `originQuery` is null. 8/8 with `mvn -pl
hugegraph-server/hugegraph-hstore -am -Dtest=HstoreTableTest test` on Temurin
17.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
bitflicker64 commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r3921393173
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -594,8 +599,11 @@ private ConditionQuery
prepareConditionQueryList(ConditionQuery conditionQuery)
}
}
if (newConditions.size() > 0) {
-conditionQuery.resetConditions(newConditions);
-return conditionQuery;
+// NOTE: copy before reset, see prepareConditionQuery()
+ConditionQuery pushdown = conditionQuery.copy();
+pushdown.resetConditions(newConditions);
+pushdown.setOriginQuery(null);
Review Comment:
🧹 The copy-not-mutate change lands in both prepare methods, but the new
tests cover only `prepareConditionQuery()`, and only through `queryByRange()`.
`prepareConditionQueryList()` has two live call sites, `queryByPrefixList()`
(line 542) and the streaming `query(Session, Iterator, String)`
(line 360), and neither is exercised: `HstoreTableTest` has 7 tests and none
reach the prefix or list paths. Its entry guard
`containsLabelOrUserpropRelation()` (line 590) admits label-only edge queries,
so both call sites do reach line 603.
Requested change: make `ScanRecordingSession.scan(String, List,
int, long, byte[])` record instead of throw, and add a `queryByPrefixList()`
case asserting the shared origin query keeps its `OWNER_VERTEX` condition after
the scan.
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -642,16 +650,16 @@ protected BackendColumnIterator queryByRange(Session
session,
}
if (origin instanceof ConditionQuery &&
(query.resultType().isEdge() || query.resultType().isVertex())) {
-cq = (ConditionQuery) query.originQuery();
-
-// LOG.debug("query {} with ownerKeyFrom: {}, ownerKeyTo: {}, " +
-// "keyFrom: {}, keyTo: {}, " +
-// "scanType: {}, conditionQuery: {}",
-// this.table(), bytes2String(ownerStart),
-// bytes2String(ownerEnd), bytes2String(start),
-// bytes2String(end), type, cq.bytes());
+// Same guard as queryByPrefix(): only push the query down to the
+// store when user-prop conditions remain. A sort-key prefix/range
+// query keeps sysprop conditions only (owner vertex, direction,
+// label, sort values), which are already enforced by the key
+// range, and the store-side row decoder cannot parse the raw
+// property layout written by the server (see issue #3090).
+cq = prepareConditionQuery((ConditionQuery) origin);
+byte[] queryBytes = cq == null ? null : cq.bytes();
Review Comment:
🧹 With the guard in place both exits are the same
`session.scan(this.table(), ownerStart, ownerEnd, start, end, type, ...,
position)` call, differing only in the query bytes (lines 661-662 vs 664-665).
Requested change: initialise `byte[] queryBytes = null;` before the `if`,
assign it inside the branch, and end the method with a single `return
session.scan(...)`. While there, the method-scoped `ConditionQuery cq;` at line
634 can become a block-local; that declaration predates this PR, so treat it as
optional.
--
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]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r3917443081
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -568,8 +568,11 @@ private ConditionQuery
prepareConditionQuery(ConditionQuery conditionQuery) {
}
}
if (newConditions.size() > 0) {
-conditionQuery.resetConditions(newConditions);
-return conditionQuery;
+// NOTE: copy before reset, the origin query is still used by core
+// for result filtering after the backend scan returns
+ConditionQuery pushdown = conditionQuery.copy();
Review Comment:
Done in 1072872 — `setOriginQuery(null)` on the pushdown copy in both
prepare methods. Thanks for measuring the payload; the nesting predating this
PR (origin already being a copy from `GraphTransaction.java:1591`) was a good
catch I had missed entirely.
##
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreTableTest.java:
##
@@ -124,6 +132,59 @@ public void
testRangeScanBudgetIncludesOneLookaheadRecord() {
Assert.assertEquals(14L, HstoreTable.rangeScanBudget(query));
}
+@Test
+public void testRangeQueryWithoutUserpropsDoesNotPushConditions() {
+// Sort-key prefix/range queries keep sysprop conditions only (owner
+// vertex, direction, label, sort values); those are enforced by the
+// key range already and must not be pushed to the store, whose row
+// decoder cannot parse the server's raw property layout (issue #3090)
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.eq(HugeKeys.DIRECTION, Directions.OUT);
+origin.eq(HugeKeys.LABEL, IdGenerator.of(1L));
+origin.gte(HugeKeys.SORT_VALUES, "ETC!");
+origin.lt(HugeKeys.SORT_VALUES, "ETC~");
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNull(session.lastQueryBytes);
+Assert.assertEquals(before, origin.conditions().size());
+}
+
+@Test
+public void testRangeQueryWithUserpropsPushesCopyAndKeepsOrigin() {
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.query(Condition.eq(IdGenerator.of(7L), 100));
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNotNull(session.lastQueryBytes);
Review Comment:
Done in 1072872 — the test now decodes with `ConditionQuery.fromBytes` and
asserts the user-prop survives, `OWNER_VERTEX` is gone and `originQuery` is
null.
On reachability: agreed — for EDGE sort-key traversals core resets user
props before the backend sees the query (that is exactly why suppressing the
pushdown is safe), so on current server paths `prepareConditionQuery()` should
return null here in practice. The test deliberately pins the method contract
rather than a live traversal shape: `queryByRange` also serves VERTEX result
types and any future caller, and if core ever stops stripping user props, this
is the behavior we want locked. Happy to add a comment in the test saying the
shape is synthetic.
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -594,8 +597,10 @@ private ConditionQuery
prepareConditionQueryList(ConditionQuery conditionQuery)
}
}
if (newConditions.size() > 0) {
-conditionQuery.resetConditions(newConditions);
-return conditionQuery;
+// NOTE: copy before reset, see prepareConditionQuery()
+ConditionQuery pushdown = conditionQuery.copy();
Review Comment:
Agreed, and thanks for confirming the guard mismatch. Leaving the list path
untouched here to keep the diff minimal — will flag
`containsLabelOrUserpropRelation()` vs `userpropConditions()` (and the related
question of whether label-only pushes can hit the same decode path, plus the
cross-module `Id` equality concern for LABEL/SUB_LABEL) as a follow-up under
#3090.
--
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:
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
bitflicker64 commented on code in PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#discussion_r3916985818
##
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreTable.java:
##
@@ -568,8 +568,11 @@ private ConditionQuery
prepareConditionQuery(ConditionQuery conditionQuery) {
}
}
if (newConditions.size() > 0) {
-conditionQuery.resetConditions(newConditions);
-return conditionQuery;
+// NOTE: copy before reset, the origin query is still used by core
+// for result filtering after the backend scan returns
+ConditionQuery pushdown = conditionQuery.copy();
Review Comment:
🧹 The copy keeps a link back to the query it came from, so the payload grows
by one nesting level. `ConditionQuery.copy()` ends with
`query.originQuery(this)` (hugegraph-core
`backend/query/ConditionQuery.java:577`), `Query.originQuery` is non-transient
(`backend/query/Query.java:78`), and `bytes()` serializes with a `Gson` that
registers type adapters but no exclusion strategy (`ConditionQuery.java:81-85,
980-983`).
Measured on a build of this head, for an edge query with owner vertex,
direction, label and one user-prop condition, using the shape the pipeline
produces (the origin is itself a copy from `GraphTransaction.java:1591`, so one
level of nesting predates this PR):
- before: 1466 bytes
- after: 2275 bytes
- after, with the back reference cleared: 657 bytes
No behaviour change: store-side consumers read only the top-level query
(`hg-store-core/.../business/FilterIterator.java:53-85`,
`hg-store-node/.../query/stages/FilterStage.java:36-52`) and nothing in
`hugegraph-store` reads `originQuery`.
Requested change: `pushdown.setOriginQuery(null);` after the reset, in both
this method and `prepareConditionQueryList()`. `Query.setOriginQuery(Query)` is
public (`backend/query/Query.java:142-144`), and the pushdown is discarded
right after `bytes()`, so nothing else observes the link.
##
hugegraph-server/hugegraph-hstore/src/test/java/org/apache/hugegraph/backend/store/hstore/HstoreTableTest.java:
##
@@ -124,6 +132,59 @@ public void
testRangeScanBudgetIncludesOneLookaheadRecord() {
Assert.assertEquals(14L, HstoreTable.rangeScanBudget(query));
}
+@Test
+public void testRangeQueryWithoutUserpropsDoesNotPushConditions() {
+// Sort-key prefix/range queries keep sysprop conditions only (owner
+// vertex, direction, label, sort values); those are enforced by the
+// key range already and must not be pushed to the store, whose row
+// decoder cannot parse the server's raw property layout (issue #3090)
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.eq(HugeKeys.DIRECTION, Directions.OUT);
+origin.eq(HugeKeys.LABEL, IdGenerator.of(1L));
+origin.gte(HugeKeys.SORT_VALUES, "ETC!");
+origin.lt(HugeKeys.SORT_VALUES, "ETC~");
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNull(session.lastQueryBytes);
+Assert.assertEquals(before, origin.conditions().size());
+}
+
+@Test
+public void testRangeQueryWithUserpropsPushesCopyAndKeepsOrigin() {
+ConditionQuery origin = new ConditionQuery(HugeType.EDGE);
+origin.eq(HugeKeys.OWNER_VERTEX, IdGenerator.of("v1"));
+origin.query(Condition.eq(IdGenerator.of(7L), 100));
+int before = origin.conditions().size();
+
+ScanRecordingSession session = new ScanRecordingSession();
+this.newTestTable().queryByRange(session, edgeRangeQuery(origin));
+
+Assert.assertTrue(session.scanCalled);
+Assert.assertNotNull(session.lastQueryBytes);
Review Comment:
🧹 This asserts only that some bytes were pushed. What is worth pinning down
is which conditions survive `prepareConditionQuery()`, and that is unchecked:
the test still passes if the code pushes the untrimmed origin, or keeps the
owner-vertex condition the method drops. The size assertion on line 171 does
guard the copy-not-mutate change, so only the payload content is unverified.
Requested change: decode with
`ConditionQuery.fromBytes(session.lastQueryBytes)` (hugegraph-core
`backend/query/ConditionQuery.java:763-773`) and assert that the user-prop
condition survives and `condition(HugeKeys.OWNER_VERTEX)` is null. I checked
the round trip works on this head.
Separately, a question rather than a change: is this shape reachable? An
`IdRangeQuery` with an edge result type seems to come only from
`BinarySerializer.writeQueryEdgeRangeCondition()`
Re: [PR] fix(hstore): don't push sysprop-only range queries down to the store [hugegraph]
SebastianGruza commented on PR #3184:
URL: https://github.com/apache/hugegraph/pull/3184#issuecomment-5512809788
**Live A/B validation** — single-node PD + Store + Server cluster built from
source (Temurin 17), fresh graph, schema/data/queries from the reproducer
linked in the PR description. Same running cluster, `hugegraph-hstore` jar
swapped in both directions between runs.
**Before — `master` (98477f0):** both sort-key queries crash in store-side
row decoding, reached from `HstoreTable.queryByRange:653`:
master: full responses with stack traces (2 queries, 2
crashes)
```
=== master (98477f0), hugegraph-hstore jar without the patch ===
### GET
/graph/edges?vertex_id=a&direction=OUT&label=flow&properties={"asset":"ETC"}
{"exception":"class
org.apache.hugegraph.store.client.type.HgStoreClientException","message":"io.grpc.StatusRuntimeException:
INTERNAL: an exception occurred while scanning data:Can't construct
Cardinality from code 0,java.lang.IllegalArgumentException: Can't construct
Cardinality from code 0\n\tat
com.google.common.base.Preconditions.checkArgument(Preconditions.java:165)\n\tat
org.apache.hugegraph.util.E.checkArgument(E.java:52)\n\tat
org.apache.hugegraph.type.define.SerialEnum.fromCode(SerialEnum.java:50)\n\tat
org.apache.hugegraph.serializer.BytesBuffer.readProperty(BytesBuffer.java:589)\n\tat
org.apache.hugegraph.serializer.BinaryElementSerializer.parseProperty(BinaryElementSerializer.java:116)\n\tat
org.apache.hugegraph.serializer.BinaryElementSerializer.parseProperties(BinaryElementSerializer.java:135)\n\tat
org.apache.hugegraph.serializer.BinaryElementSerializer.parseEdge(BinaryElementSerializer.java:296)\n\tat
org.apache.hugegraph.store.business.FilterIterator.hasNext(Filt
erIterator.java:67)\n\tat
org.apache.hugegraph.store.business.SelectIterator.hasNext(SelectIterator.java:74)\n\tat
org.apache.hugegraph.store.node.grpc.ScanStreamResponse.lambda$initIterator$0(ScanStreamResponse.java:146)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat
java.base/java.lang.Thread.run(Thread.java:840)\n","cause":"io.grpc.StatusRuntimeException:
INTERNAL: an exception occurred while scanning data:Can't construct
Cardinality from code 0,java.lang.IllegalArgumentException: Can't construct
Cardinality from code 0\n\tat
com.google.common.base.Preconditions.checkArgument(Preconditions.java:165)\n\tat
org.apache.hugegraph.util.E.checkArgument(E.java:52)\n\tat
org.apache.hugegraph.type.define.SerialEnum.fromCode(SerialEnum.java:50)\n\tat
org.apache.hugegraph.serializer.BytesBuffer.readProperty(BytesBuffer.java:589)\n\tat
org.apa
che.hugegraph.serializer.BinaryElementSerializer.parseProperty(BinaryElementSerializer.java:116)\n\tat
org.apache.hugegraph.serializer.BinaryElementSerializer.parseProperties(BinaryElementSerializer.java:135)\n\tat
org.apache.hugegraph.serializer.BinaryElementSerializer.parseEdge(BinaryElementSerializer.java:296)\n\tat
org.apache.hugegraph.store.business.FilterIterator.hasNext(FilterIterator.java:67)\n\tat
org.apache.hugegraph.store.business.SelectIterator.hasNext(SelectIterator.java:74)\n\tat
org.apache.hugegraph.store.node.grpc.ScanStreamResponse.lambda$initIterator$0(ScanStreamResponse.java:146)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat
java.base/java.lang.Thread.run(Thread.java:840)\n","trace":["org.apache.hugegraph.store.client.type.HgStoreClientException.of(HgStoreClientException.java:46)","org.apache.hugegraph.store.client
.util.HgBufferProxy.checkErr(HgBufferProxy.java:159)","org.apache.hugegraph.store.client.util.HgBufferProxy.receive(HgBufferProxy.java:129)","org.apache.hugegraph.store.client.grpc.KvPageScanner.hasNext(KvPageScanner.java:222)","org.apache.hugegraph.store.client.grpc.GrpcKvIteratorImpl.hasNext(GrpcKvIteratorImpl.java:77)","org.apache.hugegraph.store.client.SequencedIterator.getIterator(SequencedIterator.java:64)","org.apache.hugegraph.store.client.SequencedIterator.hasNext(SequencedIterator.java:116)","org.apache.hugegraph.backend.store.hstore.HstoreSessionsImpl$ColumnIterator.(HstoreSessionsImpl.java:245)","org.apache.hugegraph.backend.store.hstore.HstoreSessionsImpl$HstoreSession.scan(HstoreSessionsImpl.java:727)","org.apache.hugegraph.backend.store.hstore.HstoreTable.queryByRange(HstoreTable.java:653)","org.apache.hugegraph.backend.store.hstore.HstoreTable.queryBy(HstoreTable.java:422)","org.apache.hugegraph.backend.store.hstore.HstoreTable.query(HstoreTable.java:319)","org
