Skip to content

fix: preserve int map entries during resize - #3341

Merged
imbajin merged 1 commit into
apache:masterfrom
hugegraph:fix/intmap-table-generation
Oct 14, 2026
Merged

imbajin merged 1 commit into
apache:masterfrom
hugegraph:fix/intmap-table-generation

Conversation

@imbajin

@imbajin imbajin commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Purpose of the PR

Concurrent table growth could hash a key using one generation and access another, losing entries. A competing chain update could also make removal report an existing key as absent.

Main Changes

Hash against the captured table's length and retry a failed compare-and-set while the key is still present. Add parallel growth checks for reads, removals, retained values and final size.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests.
  • Need tests and can be verified as follows:
    • Native regressions fail the original implementation and the first partial fix; the final candidate passes the IntMap suite.
    • Java 17 clean compilation, EditorConfig formatting and three independent reviews passed.
    • Current org/ASF CI is checked separately after delivery.

Does this PR potentially affect the following parts?

  • Dependencies
  • Modify configurations
  • The public API
  • Other affects: internal concurrent collection correctness
  • Nope

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

Documentation files in this PR or paired hugegraph-doc PR:

Paired source PR: hugegraph#312

Conceptual overview

Conceptual illustration of generation-consistent hashing and removal retry after contention.

Conceptual illustration; not test or release-acceptance evidence.

Capture a table before hashing with its length, access the same generation, and re-read the chain after a failed removal CAS.

- hash keys against the captured table generation
- retry removal after a competing chain update
- verify parallel growth reads removals and size
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.10%. Comparing base (92af2f8) to head (fe041d0).

Files with missing lines Patch % Lines
...hugegraph/util/collection/IntMapByDynamicHash.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3341      +/-   ##
============================================
- Coverage     54.31%   53.10%   -1.21%     
+ Complexity     2250        3    -2247     
============================================
  Files           770      503     -267     
  Lines         67952    48399   -19553     
  Branches       9213     6963    -2250     
============================================
- Hits          36905    25704   -11201     
+ Misses        27470    20082    -7388     
+ Partials       3577     2613     -964     

☔ 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.

@imbajin
imbajin merged commit 76ca3df into apache:master Oct 14, 2026
15 of 16 checks passed
@imbajin
imbajin deleted the fix/intmap-table-generation branch October 14, 2026 20:16
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.

2 participants