Conversation
Summary of ChangesHello @robfrank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly revises the transaction handling mechanism within the gRPC service. The primary goal is to ensure that ArcadeDB's thread-local transactions are managed correctly in a multi-threaded gRPC environment. This is achieved by associating each active transaction with a dedicated single-thread executor, guaranteeing that all operations pertaining to that transaction are executed sequentially on its designated thread. This change enhances the reliability and correctness of transactional operations exposed via the gRPC API. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🧪 CI InsightsHere's what we observed from your CI run for 45ddfe5. 🟢 All jobs passed!But CI Insights is watching 👀 |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-thought-out revision of the transaction handling logic to ensure thread affinity, which is critical for ArcadeDB's thread-local transactions. The use of a TransactionContext with a single-threaded executor for each transaction is a robust solution. The changes are consistently applied across beginTransaction, commitTransaction, rollbackTransaction, and executeCommand. The refactoring of result set processing logic and removal of convertResultToGrpcRecord also improves clarity. I've identified a few areas for improvement, including a potential resource leak and opportunities to reduce code duplication, which are detailed in the comments. Overall, this is a high-quality change that improves the stability and correctness of the gRPC service.
| } catch (Throwable t) { | ||
| Throwable cause = (t instanceof ExecutionException && t.getCause() != null) ? t.getCause() : t; | ||
| LogManager.instance() | ||
| .log(this, Level.FINE, "beginTransaction(): FAILED db=%s user=%s err=%s", reqDb, (user != null ? user : "<none>"), | ||
| t.toString(), t); | ||
| LogManager.instance().log(this, Level.SEVERE, "Error beginning transaction: %s", t, t.getMessage()); | ||
| responseObserver.onError(Status.INTERNAL.withDescription("Failed to begin transaction: " + t.getMessage()).asException()); | ||
| cause.toString(), cause); | ||
| LogManager.instance().log(this, Level.SEVERE, "Error beginning transaction: %s", cause, cause.getMessage()); | ||
| responseObserver.onError(Status.INTERNAL.withDescription("Failed to begin transaction: " + cause.getMessage()).asException()); | ||
| } |
There was a problem hiding this comment.
The catch block for beginTransaction does not shut down the ExecutorService inside the TransactionContext if an error occurs after its creation. This will cause a thread leak. To fix this, you should ensure txCtx.shutdown() is called on failure. This can be achieved by declaring TransactionContext txCtx = null; before the try block, and then in this catch block, adding a check if (txCtx != null) { txCtx.shutdown(); }.
| try { | ||
| txCtx.db.rollback(); | ||
| } catch (Exception ignore) { | ||
| } |
There was a problem hiding this comment.
In the close() method, an exception during txCtx.db.rollback() is silently ignored. This can hide underlying problems during shutdown. It's better to log such failures, even if the shutdown process must continue.
try {
txCtx.db.rollback();
} catch (Exception e) {
LogManager.instance().log(this, Level.WARNING, "Failed to rollback transaction %s during shutdown", e, txCtx.txId);
}
grpcw/src/main/java/com/arcadedb/server/grpc/ArcadeDbGrpcService.java
Outdated
Show resolved
Hide resolved
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Address three issues identified by Gemini Code Assist in PR #3074: 1. HIGH: Fix thread leak in beginTransaction() - Move TransactionContext declaration outside try block - Add txCtx.shutdown() in catch block to clean up executor on failure 2. MEDIUM: Add logging for rollback exceptions in close() - Replace silent catch with WARNING-level log message - Helps diagnose shutdown issues instead of hiding them 3. MEDIUM: Merge duplicate catch blocks in executeCommand() - Consolidate ExecutionException and Exception handlers - Single block handles cause unwrapping for both cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
| <protobuf-maven-plugin.version>4.1.1</protobuf-maven-plugin.version> | ||
| <grpc.version>1.77.0</grpc.version> | ||
| <protoc.version>4.32.0</protoc.version> | ||
| <protoc.version>4.33.0</protoc.version> |
There was a problem hiding this comment.
We should have versions as properties, to easily manage upgrades
There was a problem hiding this comment.
my fault on rebasing. These are properties, btw :)
add configuration of netty on gRPC server
Co-authored-by: Oleg Cohen <[email protected]> (cherry picked from commit 8ee158d)
copy of #3073