Repository navigation
feat(#7326): gRPC vector, hybrid and full-text search run inside the client transaction - #7397
Conversation
…client transaction The three search RPCs added by #7306 carried `database` and `credentials` but no `TransactionContext`, so a search issued while the client held an open gRPC transaction ran on a gRPC worker thread instead of the transaction's own thread and could not observe that transaction's uncommitted writes. The HTTP routes never had the gap: `AbstractVectorSearchHandler` extends `DatabaseAbstractHandler`, which binds the session's transaction whenever the request carries `arcadedb-session-id`. Adds an optional `transaction` field to `VectorSearchRequest`, `HybridSearchRequest` and `FullTextSearchRequest`, and routes the three handlers through a shared `searchInTransaction(...)` that resolves the transaction exactly as `lookupByRid` and `updateRecord` already do: authorize it against the transaction's own database, refuse a non-blank id the server no longer knows with FAILED_PRECONDITION rather than reading outside the transaction, and dispatch the body onto the transaction's executor. `RemoteGrpcDatabase` stamps the open transaction on all three requests the way it already does for every other transaction-scoped RPC. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwTsBYjyoDn2vKXQGmt5bK
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds transaction context to gRPC vector, hybrid, and full-text searches. The server executes searches on the active transaction thread and rejects unknown transaction IDs. Integration tests verify uncommitted data visibility, rollback behavior, error handling, and HTTP equivalence. ChangesTransactional gRPC search
Estimated code review effort: 4 (Complex) | ~45 minutes Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant RemoteGrpcDatabase
participant ArcadeDbGrpcService
participant TransactionExecutor
participant TransactionDatabase
RemoteGrpcDatabase->>ArcadeDbGrpcService: send search with transaction context
ArcadeDbGrpcService->>TransactionExecutor: resolve and submit active transaction
TransactionExecutor->>TransactionDatabase: run search against transaction database
TransactionDatabase-->>RemoteGrpcDatabase: return transactional search results
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change makes gRPC vector, hybrid, and full-text searches honor the caller’s active transaction and reject unknown transaction IDs. The supplied coverage exercises transactional visibility, rollback, validation, and HTTP parity, with no concrete merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 Buf (1.72.0)grpc/src/main/proto/arcadedb-server.protofatal: unable to access 'https://github.com/ArcadeData/arcadedb.git/': Failed to connect to github.com port 443 via 127.0.0.1 after 0 ms: Could not connect to server Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 73.68% diff coverage · -6.48% coverage variation
Metric Results Coverage variation ✅ -6.48% coverage variation Diff coverage ✅ 73.68% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (6e6f2b8) 175566 144513 82.31% Head commit (4919bbc) 207998 (+32432) 157722 (+13209) 75.83% (-6.48%) 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 (#7397) 38 28 73.68% 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.
ReviewReviewed the diff (proto, Code quality / design
Correctness
Performance
Security
Test coverage
No blocking issues found. Nice work keeping the PR description's residual-risk and follow-up sections honest about what this does and doesn't fix. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7397 +/- ##
==========================================
- Coverage 73.77% 73.76% -0.01%
==========================================
Files 1932 1932
Lines 175566 175595 +29
Branches 37179 37186 +7
==========================================
+ Hits 129517 129524 +7
- Misses 31091 31140 +49
+ Partials 14958 14931 -27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #7326
Problem
The three search RPCs added by #7306 (
VectorSearch,HybridSearch,FullTextSearch) carrieddatabaseandcredentialsbut noTransactionContext, so a search issued while the client heldan open gRPC transaction ran on a gRPC worker thread instead of the transaction's own thread and
could not observe that transaction's uncommitted writes. The HTTP routes never had the gap:
AbstractVectorSearchHandlerextendsDatabaseAbstractHandler, which binds the session'stransaction whenever the request carries
arcadedb-session-id.Fix
TransactionContext transactiononVectorSearchRequest(15),HybridSearchRequest(15) and
FullTextSearchRequest(8); field numbers as the issue specifies, all inside the 1-bytetag range.
searchInTransaction(...)resolving the transaction exactly aslookupByRid/updateRecordalready do (resolveAuthorizedTransaction,isUnknownSuppliedTransaction->unknownTransactionStatus,submitToActiveTransaction),falling back to
getDatabase(...)when no transaction is named. It also unwraps theExecutionExceptionfrom the transaction executor beforetoSearchStatussees it, which is whatkeeps
requireTransactionStillActive's FAILED_PRECONDITION and the shared implementation'sINVALID_ARGUMENT from flattening to INTERNAL.
RemoteGrpcDatabasestamps the open transaction on the three search requests thesame way it already does for
executeQuery,lookupByRid,updateRecordand the rest.grpc/src/main/proto/arcadedb-server.prototransactionfieldsgrpcw/.../ArcadeDbGrpcService.javasearchInTransaction(...); the three handlers route through itgrpc-client/.../RemoteGrpcDatabase.javagrpc-client/src/test/.../Issue7326GrpcSearchInTransactionIT.javaResidual risk, measured
The dense vector index does not resolve a row created in the open transaction; the full-text
index does. Measured on both protocols, inside one transaction, before any commit (the query
vector is exactly the new row's embedding, so it would rank first if it were a candidate):
So the protocol parity this issue is about does hold: HTTP with a session id behaves identically.
The vector gap is an index-layer limit (the graph is populated at commit replay), filed as #7378,
and
httpAndGrpcAgreeOnARecordCreatedInsideTheTransactionpins the current behaviour on bothprotocols so that whichever way #7378 is resolved the test fails and names the claim to revisit.
fullTextSearchInsideATransactionFindsARecordCreatedInItasserts the issue's own proposedverification on the path where it is achievable.
Everything the search does with the candidates it gets is transactional either way: the vector
leg's
filterand thedatabase.lookupByRIDthat materializes each hit. Neither searchimplementation forks work off the calling thread (no executor, stream, future or thread use in
HybridSearch,VectorSearch,FullTextQuery,VectorLeg), so nothing escapes the transaction'sexecutor once the body is dispatched.
arcadedb-server.protois the only proto in the tree and nogenerated stubs for other languages are checked in, so the new fields need no companion regeneration.
Verification
Proof the tests can fail. With
searchInTransactiontemporarily reverted to the pre-fix body(
return body.apply(getDatabase(databaseName, credentials));) and only that changed, all six teststhat existed at that point failed:
Regression:
grpc-client150 unit tests green;grpcwandgrpc-clientIT suites green (25/25 and27/27) after re-running three classes in isolation whose only errors were
Failed to bind to address 0.0.0.0:50051from a parallel build holding the fixed gRPC test port.Issue7306GrpcVectorSearchIT, the suite this is layered on, 5/5.mvn -o -pl grpc,grpcw,grpc-client package -DskipTestsclean on the committed tree.One run errored once in teardown with
ABORTED: Rollback failed: graph(
DatabaseIsClosedException) inside that same port-contention window and did not reproduce in 10subsequent runs;
BaseGraphServerTestrestarts the server on fixed ports per method, so a startracing a previous shutdown is an exposure every IT in this module shares and
rollbackTransactionisuntouched here. Recorded so a future occurrence is not mistaken for a new symptom.
Argued, no change needed
arcadedb-session-idis documented on no route inserver/src/main/java/com/arcadedb/server/http/handler/openapi/, so documenting it on these threealone would make the spec less consistent.
Follow-ups filed
TimeSeriesQuery/TimeSeriesLatestcarry the identical missing-TransactionContextgap (found by the completeness sweep).
Process caveat
Phase 1.5's adversarial pass could not be delegated to an isolated subagent - no
Tasktool wasexposed in that environment - so it ran inline, which lacks the not-already-convinced property. It
still caught two real things: that the suite never asserted the issue's own proposed verification
(now added), and that the first residual-risk paragraph was wrong about full-text (corrected by
measurement above).
🤖 Generated with Claude Code
https://claude.ai/code/session_01GwTsBYjyoDn2vKXQGmt5bK
Summary by CodeRabbit
New Features
Bug Fixes