fix(pd): Ensure range attribute thread safety by haohao0103 · Pull Request #2641 · apache/hugegraph

@haohao0103

close #2634
Added a custom SynchronizedRangeMap that provides thread safe put/get and other methods to ensure thread safety of GraphCache range attr

@haohao0103

@dosubot dosubot bot added size:M

This PR changes 30-99 lines, ignoring generated files.

pd

PD module

labels

Aug 14, 2024

@codecov

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 34.98%. Comparing base (1c577de) to head (dfc9ce6).
Report is 231 commits behind head on master.

Files with missing lines Patch % Lines
...ava/org/apache/hugegraph/pd/common/GraphCache.java 0.00% 22 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (1c577de) and HEAD (dfc9ce6). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (1c577de) HEAD (dfc9ce6)
4 1
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #2641       +/-   ##
=============================================
- Coverage     45.35%   34.98%   -10.37%     
+ Complexity      496      383      -113     
=============================================
  Files           719      719               
  Lines         58465    58486       +21     
  Branches       7495     7495               
=============================================
- Hits          26514    20464     -6050     
- Misses        29230    35763     +6533     
+ Partials       2721     2259      -462     

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

javeme

private Map<Integer, AtomicBoolean> state = new ConcurrentHashMap<>();
private Map<Integer, Partition> partitions = new ConcurrentHashMap<>();
private RangeMap<Long, Integer> range = TreeRangeMap.create();
private RangeMap<Long, Integer> range = new SynchronizedRangeMap<Long, Integer>().rangeMap;

Choose a reason for hiding this comment

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

nice catch

@@ -39,7 +41,7 @@ public class GraphCache {
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

Choose a reason for hiding this comment

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

@imbajin Can we improve and avoid this lombok.Data programming style in the future, which will cause internal members to be modified arbitrarily by external class?

@github-actions

Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label

imbajin

@dosubot dosubot bot added the lgtm

This PR has been approved by a maintainer

label

Sep 24, 2024

@imbajin

VGalaxies

@VGalaxies VGalaxies changed the title fix(pd):Ensure range attribute thread safety fix(pd): Ensure range attribute thread safety

Sep 25, 2024