celeborn/common
xinyuwang1 4f039d5f71 [CELEBORN-1453] Fix the thread safety bug in getMetrics
### What changes were proposed in this pull request?
Fix the thread safety bug in getMetrics of AbstractSource by changing the lock scope

### Why are the changes needed?
When two threads access the getMetrics method in AbstractSource at the same time, one of the threads may get fewer metrics than the actual value, because the actual execution order may be like this: Thread A gets the lock, adds the metrics of the worker source to the innerMetrics queue and releases the lock, Thread B gets the lock, adds the metrics of the worker source to the innerMetrics queue and releases the lock, Thread A gets the lock, adds the metrics of other sources to the innerMetrics queue, assembles the values of innerMetrics, clears innerMetrics and releases the lock, Thread B gets the lock, adds the metrics of other sources to the innerMetrics queue, assembles the values of innerMetrics, clears innerMetrics and releases the lock. The result of this is that Thread A gets two sets of metrics data from the worker source, while Thread B doesn't get any.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
manual test

Closes #2548 from littlexyw/get_metrics_fix.

Authored-by: xinyuwang1 <xinyuwang1@xiaohongshu.com>
Signed-off-by: zky.zhoukeyong <zky.zhoukeyong@alibaba-inc.com>
2024-06-08 11:30:11 +08:00
..
benchmarks [CELEBORN-744] Add Benchmark framework and ComputeIfAbsentBenchmark 2023-06-29 20:19:30 +08:00
src [CELEBORN-1453] Fix the thread safety bug in getMetrics 2024-06-08 11:30:11 +08:00
pom.xml [CELEBORN-1443] Remove ratis dependencies from common module 2024-06-03 10:15:51 +08:00