Repository navigation
test(#10235): admission-gate conformance test for every surface - #10294
Conversation
…he thread that runs the statement A conformance check shared through the server test-jar (AdmissionSlotConformance) and one test per surface: HTTP command, HTTP session, bulk load, Postgres simple/extended in and out of a transaction, Bolt auto-commit and explicit transaction, Redis HSET, MongoDB insert, MCP execute_command, Gremlin traversal and script, gRPC with and without a client transaction. A census test fails when a new class admits through the gate without a conformance test. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ -4.97% coverage variation |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (1a8d72a) 241123 208852 86.62% Head commit (754b3ed) 273824 (+32701) 223555 (+14703) 81.64% (-4.97%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#10294) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Review: admission-gate conformance tests (#10235)Tests only, and the design is sound. Hooking Suggestions
No production code or security changes. No issues that block merging; 1 and 7 are the ones worth doing. |
…ot from basedir, gate settings restored in their own finally, shorter HTTP test lines Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ReviewTests-only PR, and the design is good. The listener-on-record-create hook runs on the thread that executes the statement, so one check covers every protocol with no per-module test hooks. The census test turns "a new surface was added" into a CI failure. Config restore in Suggestions (non-blocking)
I did not run the tests locally. Overall: LGTM with the minor items above. 🤖 Generated with Claude Code |
… for the client thread before resetting the gate, close the Gremlin traversal source Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ReviewTests-only PR, and the design is good. A listener on the written type runs on whichever thread runs the statement, so one check works for every protocol. The census test stops the guard from rotting. The gRPC mutation proof is the right evidence that the check can fail. No security or production-performance concerns, since nothing under I did not run the tests. This review is from reading Suggestions (non-blocking)
Overall this looks good to merge once point 7 is confirmed. |
… back, keep the interrupt flag off the writer thread, state the census limits Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Review Tests-only PR. The design is sound: a BeforeRecordCreateListener runs on the statement's own thread, so one check covers every protocol with no per-module hooks. The census test makes a new admitting surface fail CI until it has a conformance test. Teardown is careful: gate settings restored, hook released, client executor drained. I read the shared helper (AdmissionSlotConformance) and the census test closely, and only skimmed the per-module tests. Suggestions (none blocking)
Verdict: Looks good. No security or production-code risk. Items 3 and 7 are the ones worth confirming before merge. 🤖 Generated with Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10294 +/- ##
=========================================
Coverage 78.48% 78.49%
- Complexity 4672 4673 +1
=========================================
Files 2263 2263
Lines 241123 241123
Branches 52279 52279
=========================================
+ Hits 189254 189268 +14
+ Misses 32312 32285 -27
- Partials 19557 19570 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…the overlay, the BM25 drift check compares the analyzer the lengths were measured with (#10456) * fix(#10376,#10397): a deleted lightweight twin takes one twin out of the overlay, the BM25 drift check compares the analyzer the lengths were measured with #10376: the overlay of a unidirectional type kept its deletions in a set keyed by the edge identity, which for a lightweight edge is the triple (type, out, in) its twins share, so one DELETE hid every twin of the pair from the incoming side for the rest of the statement. Deletions of lightweight edges are now kept per triple as a multiset of sequences, and each lookup takes one twin out per delete (the twins the transaction created first, then the last of the scanned ones). The twins a lookup answers are numbered across the scanned and the created ones, so a DELETE that claims each relationship by occurrence deletes every twin it matched, and a statement that deletes relationships and nodes together no longer finds a twin it already deleted. #10397: the drift check compared the document count only. The sum of the lengths cannot be compared with the live data without analyzing it, so the counters are persisted with the analyzer (and the token-counting rule) they were measured with, and the first search rescans when it differs, even when the count agrees. Counters saved before the signature existed are trusted. schema:index shows measuredWith and measuredWithCurrentAnalyzer. #10399 needs no change: the cross-surface conformance test it asks for exists (AdmissionSlotConformance and AdmissionSurfaceCensusTest, #10294). * review(#10456): cheaper twin overlay when nothing twin-related changed, binary search of the tombstones, metadata-level tests of the analyzer signature, assertions that can fail The overlay of the lightweight twins is built only when the transaction deleted twins or created some into the target, and its map of created twins is allocated with the first one. The tombstones of a triple are searched by halving. The analyzer signature gets metadata-level tests (round trip, length rule mismatch, legacy trust, a save before the rescan, an inexact scan, adoption, an explicit set). Two tests counted the records of lightweight edge types, which is always 0: they now count the vertices left and the edges through their lists. * review(#10456): guards for the twin overlay lookup and the BM25 length rule Tests pin that a lookup asked again in the same statement answers the same, that hundreds of twins are counted and numbered one per relationship, that the key of a tombstone is the triple alone, and that the rule counting the tokens of a document is tied to its version. The worked example in the overlay Javadoc and the reason an adopted pair takes its signature whole are written down. * review(#10456): a randomized check of the twin overlay against a plain model, why the class names the analyzer 60 random statements over four pairs interleave creates and deletes after a read of the incoming side, and the last read has to answer a plain count per pair, each twin a relationship of its own. It fails with the drop of scanned twins disabled. * review(#10456): the counter pair and its signature are published and saved as one unit, the analyzer warning carries the document counts, a later statement of the transaction ignores earlier deletes A scan published its pair and its signature without the lock a save reads them under, so a save could record the new signature next to the pair from before the scan. Both now move under the counters lock, as the commit deltas and an adoption already do. * review(#10456): the overlay Javadoc says which of its questions consume, the order dependence at the call site, the equality the key relies on, the rule behind the length version
…the overlay, the BM25 drift check compares the analyzer the lengths were measured with (#10456) * fix(#10376,#10397): a deleted lightweight twin takes one twin out of the overlay, the BM25 drift check compares the analyzer the lengths were measured with #10376: the overlay of a unidirectional type kept its deletions in a set keyed by the edge identity, which for a lightweight edge is the triple (type, out, in) its twins share, so one DELETE hid every twin of the pair from the incoming side for the rest of the statement. Deletions of lightweight edges are now kept per triple as a multiset of sequences, and each lookup takes one twin out per delete (the twins the transaction created first, then the last of the scanned ones). The twins a lookup answers are numbered across the scanned and the created ones, so a DELETE that claims each relationship by occurrence deletes every twin it matched, and a statement that deletes relationships and nodes together no longer finds a twin it already deleted. #10397: the drift check compared the document count only. The sum of the lengths cannot be compared with the live data without analyzing it, so the counters are persisted with the analyzer (and the token-counting rule) they were measured with, and the first search rescans when it differs, even when the count agrees. Counters saved before the signature existed are trusted. schema:index shows measuredWith and measuredWithCurrentAnalyzer. #10399 needs no change: the cross-surface conformance test it asks for exists (AdmissionSlotConformance and AdmissionSurfaceCensusTest, #10294). * review(#10456): cheaper twin overlay when nothing twin-related changed, binary search of the tombstones, metadata-level tests of the analyzer signature, assertions that can fail The overlay of the lightweight twins is built only when the transaction deleted twins or created some into the target, and its map of created twins is allocated with the first one. The tombstones of a triple are searched by halving. The analyzer signature gets metadata-level tests (round trip, length rule mismatch, legacy trust, a save before the rescan, an inexact scan, adoption, an explicit set). Two tests counted the records of lightweight edge types, which is always 0: they now count the vertices left and the edges through their lists. * review(#10456): guards for the twin overlay lookup and the BM25 length rule Tests pin that a lookup asked again in the same statement answers the same, that hundreds of twins are counted and numbered one per relationship, that the key of a tombstone is the triple alone, and that the rule counting the tokens of a document is tied to its version. The worked example in the overlay Javadoc and the reason an adopted pair takes its signature whole are written down. * review(#10456): a randomized check of the twin overlay against a plain model, why the class names the analyzer 60 random statements over four pairs interleave creates and deletes after a read of the incoming side, and the last read has to answer a plain count per pair, each twin a relationship of its own. It fails with the drop of scanned twins disabled. * review(#10456): the counter pair and its signature are published and saved as one unit, the analyzer warning carries the document counts, a later statement of the transaction ignores earlier deletes A scan published its pair and its signature without the lock a save reads them under, so a save could record the new signature next to the pair from before the scan. Both now move under the counters lock, as the commit deltas and an adoption already do. * review(#10456): the overlay Javadoc says which of its questions consume, the order dependence at the call site, the equality the key relies on, the rule behind the length version (cherry picked from commit ba9ec14)
Closes #10235
Summary
Adds the regression guard #10140 asked for. If a request is admitted on one thread and its statement runs on another, that statement's
releaseCurrentSlot()must still find the slot. This PR changes tests only, no production code.AdmissionSlotConformance(server test-jar) is one shared check. It enables the gate with one slot and registers aBeforeRecordCreateListeneron the type the request writes to, then sends the request through the surface. The listener runs on the thread that runs the statement, so it works the same for every protocol: SQL, Cypher, Gremlin, RedisHSET, a MongoDB insert or a bulk load. That is why no per-module hook (test SQL function, test query engine) is needed. The listener callsreleaseCurrentSlot()and blocks. The check then asserts:getRunning()==1when the hook ran)releaseCurrentSlot()returnedtrueon that threadgetRunning()==0while the statement still waitsAdmissionSurfaceCensusTest(server) scans every module'ssrc/main/javafor classes that useQueryAdmissionGateand call.admit(. It fails if one of them is not mapped to a conformance test that calls the check. So a surface added later fails CI until it has its own test. This is the "would then fail that test instead of silently losing the release" part of the issue.Coverage
Invariant: for every surface that admits through the gate, the slot is reachable from the thread that runs the request's statement.
Census command:
git grep -nE "\.admit\(" -- '*/src/main/java/*.java', keeping files that useQueryAdmissionGate. It finds 9 classes:DatabaseAbstractHandlerAdmissionSlotConformanceHttpTestPostBatchHandlerAdmissionSlotConformanceHttpTestPostgresNetworkExecutorAdmissionSlotConformancePostgresITBoltNetworkExecutorAdmissionSlotConformanceBoltITRedisNetworkExecutorHSETAdmissionSlotConformanceRedisTestMongoDBBackendinsertOneAdmissionSlotConformanceMongoTestMCPDispatcherexecute_commandtoolAdmissionSlotConformanceMcpITArcadeGraphManagerAdmissionSlotConformanceGremlinTest(runs ingremlin-it)GrpcAdmissionInterceptorexecuteCommandwith and without a client transactionAdmissionSlotConformanceGrpcITCommits are not a row. The only production
releaseCurrentSlot()callers are statement-level:RaftReplicatedDatabase.forwardCommandToLeaderViaRaft(a follower forwarding a command) andTransactionContext.explicitLock(LOCK). A commit never releases a slot, so a commit-time hook would test nothing that production does.Known gaps: None.
Proof the check can fail
I temporarily replaced
admission.adopt()inArcadeDbGrpcService.submitToActiveTransactionwith an adoption taken on the transaction thread, which is the #10140 bug.AdmissionSlotConformanceGrpcIT.aCommandInsideAClientTransactionGivesItsSlotBackFromTheTransactionThreadthen fails:The no-transaction gRPC row stayed green. I reverted the change afterwards.
Test plan
mvn -o test -pl server -Dtest='AdmissionSurfaceCensusTest,AdmissionSlotConformanceHttpTest,HardcodedTestServerPortsTest,QueryAdmissionGateHttpIssue9518Test': 15/15mvn -o verify -pl redisw,mongodbw,grpcw,mcp,postgresw,bolt -DskipITs=falsewith the conformance classes: all greenmvn -o verify -pl gremlin,gremlin-it -Dtest='AdmissionSlotConformanceGremlinTest,QueryAdmissionGateGremlinIssue9518Test': 2/2Adversarial pass
This session had no tool for starting the independent subagent that Phase 1.5 calls for, so I did the pass myself instead. Findings:
.admit(in a class that namesQueryAdmissionGate. The otheradmit(calls in the code base (vector groups, path expansion) are in classes that never name the gate, so the census still finds exactly 9.releaseCurrentSlot()call the forward makes, on the same thread. The end-to-end gRPC+HA gap is already tracked as A gRPC statement inside a client-managed transaction holds its admission slot across a follower-to-leader forward and across an explicit LOCK wait, because the slot is taken on a thread that never runs the statement #10140's residue and is not in this issue's scope.Review cycles
c946e0c88dMap.ofEntries, reactor root frombasedir, gate restore in its ownfinally, shorter HTTP lines07d62e9d06awaitTerminationon the client thread before the gate is reset, Gremlin traversal source in try-with-resources99121eb967reset()an unchanged setting instead of writing it back, interrupt flag not restored on the server writer thread (a later FileChannel write would fail withClosedByInterruptException), census limits stated in the Javadoc, comment on the first-record-only probe754b3edd38Deferred items (cycle 4, all non-blocking)
junit.jupiter.execution.parallel.*; onlye2ehas ajunit-platform.properties, and it documents that classes run one after another. The helper also refuses to start untilgetRunning()==0.HardcodedTestServerPortsTest).QueryAdmissionGate, the Admission gate for queries: FIFO queue with memory-aware admission for every remote protocol #9518 tests).integration-testsjob runs./mvnw verify -DskipTests -Pintegration -pl !e2e,!load-tests,!e2e-ha,!ha-raft(.github/workflows/mvn-test.yml:666). The root pom wires Failsafe'sskipTeststo${skipITs}, which-Pintegrationsets to false. The existingQueryAdmissionGate*Issue9518ITclasses in the same modules run the same way. Locally all four ITs ran with-DskipITs=false. The Gremlin test runs throughgremlin-it, like every other Gremlin test.Final state
max-cycles-reached. All 4 cycles ran, and every cycle's review said nothing blocks the merge. The cycle-4 suggestions are listed above with how each was handled; none is a defect.🤖 Generated with Claude Code
Summary by CodeRabbit