Skip to content

Fix TinkerTransactionGraph vertex index lookup and rollback bugs - #3705

Merged
spmallette merged 3 commits into
apache:3.7-devfrom
sshmendez:tinkertransaction-index-fixes
Oct 21, 2026
Merged

spmallette merged 3 commits into
apache:3.7-devfrom
sshmendez:tinkertransaction-index-fixes

Conversation

@sshmendez

@sshmendez sshmendez commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Two bugs in TinkerTransactionGraph when a vertex index exists.

1. Indexed lookup misses a vertex modified in the current transaction

TinkerTransactionalIndex.getNotModifiedElements drops every element whose container isChanged(). Adding an edge touches both endpoint vertices, but they never enter the transaction-local index (only property writes do), so they disappear from the lookup until commit.

graph.createIndex('name', Vertex.class)
g.addV().property('name', 'hub').iterate(); g.tx().commit()
g.addV().addE('e').to(__.V().has('name', 'hub')).iterate()
g.V().has('name', 'hub').count()   // 0, expected 1

Fix: keep a changed element if its current value still holds the indexed key/value.

2. NullPointerException on rollback with a vertex index but no edge index

TinkerTransaction.doRollback checks vertexIndex before calling edgeIndex.rollback(). The NPE skips the rest of the cleanup, so the thread's transaction is never closed. Under Gremlin Server this leaves a worker thread whose later requests never get a response.

Fix: check edgeIndex.

Tests for both are in TinkerTransactionGraphTest; they fail before the fix. The full tinkergraph-gremlin suite passes.

Assisted-by: Claude Code:claude-opus-5-5

@Cole-Greer

Copy link
Copy Markdown
Contributor

Thanks for submitting the PR @sshmendez, I'll try to give it a proper review soon.

@codecov-commenter

codecov-commenter commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.97%. Comparing base (4722890) to head (9897585).
⚠️ Report is 135 commits behind head on 3.7-dev.

Files with missing lines Patch % Lines
...emlin/tinkergraph/structure/TinkerTransaction.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             3.7-dev    #3705      +/-   ##
=============================================
+ Coverage      75.49%   75.97%   +0.47%     
- Complexity     13161    13324     +163     
=============================================
  Files           1092     1095       +3     
  Lines          67208    67564     +356     
  Branches        7391     7456      +65     
=============================================
+ Hits           50742    51330     +588     
+ Misses         13837    13577     -260     
- Partials        2629     2657      +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@spmallette

Copy link
Copy Markdown
Contributor

For committers - Created PR root bead: tp-wfn

🤖 Agent assisted comment.

@spmallette

Copy link
Copy Markdown
Contributor

Created: https://issues.apache.org/jira/browse/TINKERPOP-3292 and https://issues.apache.org/jira/browse/TINKERPOP-3293

}

@Test
public void shouldFindIndexedVertexAfterAddingEdgeToItInSameTransaction() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add an analogous test for this for the Edge index? i think the bug is the same there - seems like we may as well have both cases covered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spmallette

Copy link
Copy Markdown
Contributor

Thanks for submitting this. I'd actually ran into these problems elsewhere recently but noted you had the fix handy. Hate to nit-pick but could you amend your commit messages to align to our form for agent signoff. So instead of:

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

do:

Assisted-by: Claude Code:claude-opus-5-5

For further details on our preferences, see https://github.com/apache/tinkerpop/blob/master/AGENTS.md#licensing-and-provenance

}

@Test
public void shouldRollbackWithVertexIndexAndNoEdgeIndex() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adding a regression test for rollback with an edge index but no vertex index. Before this fix, the incorrect vertexIndex guard also skipped edgeIndex.rollback() in that configuration, leaving the thread-local edge-index entries available to later transactions on the same thread. The test should add an indexed edge, roll back, then verify a subsequent indexed lookup does not return it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in f4c0b69: shouldRollbackWithEdgeIndexAndNoVertexIndex (https://github.com/sshmendez/tinkerpop/blob/f4c0b69f722789850c78827207ac9f1d6d704029/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerTransactionGraphTest.java#L1911-L1922). It adds an indexed edge, rolls back, and checks that the indexed lookup returns nothing. It fails without the fix.

@kenhuuu

kenhuuu commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

VOTE +1 pending resolution to the small changes requested in the above comments.

@Cole-Greer

Copy link
Copy Markdown
Contributor

VOTE +1 pending the test additions requested above.

Assisted-by: Claude Code:claude-opus-5-5
… transaction, and rollback NPE without an edge index

Assisted-by: Claude Code:claude-opus-5-5
…f an edge modified in the transaction, and rollback with an edge index but no vertex index

Assisted-by: Claude Code:claude-opus-5-5
@sshmendez
sshmendez force-pushed the tinkertransaction-index-fixes branch from 9897585 to f4c0b69 Compare October 14, 2026 23:54
@sshmendez

Copy link
Copy Markdown
Contributor Author

Changed the commit trailers to Assisted-by: Claude Code:claude-opus-5-5 (eb5e991, c7b6b4b, f4c0b69). Thanks!

@sshmendez

Copy link
Copy Markdown
Contributor Author

anything else?

@spmallette
spmallette merged commit 6bd5e16 into apache:3.7-dev Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants