Open breezewish opened 2 years ago
We could have two stages to improve this behavior:
Stage 1. Use atomic. This avoids the memory data race, but parallel calls to this function will lead to multiple parallel PD requests.
Stage 2. To be discussed. May be a typical "Single Flight" scenario. We can use similar patterns so that parallel calls (when cache is expired) will not cause multiple PD requests, but wait for the first request instead.
Enhancement
Currently there is a race condition in
getGCSafePointWithRetry
which makes it buggy. ThegetGCSafePointWithRetry
are now called in a least 3 kind of threads: