Skip to content

Commit

Permalink
Fix dual-read lix switch issue
Browse files Browse the repository at this point in the history
  • Loading branch information
brycezhongqing committed Jan 3, 2024
1 parent 76fb4b6 commit a909b0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ When updating the changelog, remember to be very clear about what behavior has c
and what APIs have changed, if applicable.

## [Unreleased]
## [29.49.2] - 2024-01-02
- Fix rate limiter for dual-read mode switch

## [29.49.1] - 2023-12-21
- Use a separate indis warmup executor service
Expand Down Expand Up @@ -5597,7 +5599,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.49.1...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.49.2...master
[29.49.2]: https://github.com/linkedin/rest.li/compare/v29.49.1...v29.49.2
[29.49.1]: https://github.com/linkedin/rest.li/compare/v29.49.0...v29.49.1
[29.49.0]: https://github.com/linkedin/rest.li/compare/v29.48.9...v29.49.0
[29.48.9]: https://github.com/linkedin/rest.li/compare/v29.48.8...v29.48.9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class DualReadStateManager
private final ConcurrentMap<String, DualReadModeProvider.DualReadMode> _clusterDualReadModes;
private final DualReadModeProvider _dualReadModeProvider;
private final ScheduledExecutorService _executorService;
private final RateLimiter _rateLimiter;
private final ConcurrentMap<String, RateLimiter> _serviceToRateLimiterMap;
// Stores global dual read mode
private volatile DualReadModeProvider.DualReadMode _dualReadMode = DualReadModeProvider.DualReadMode.OLD_LB_ONLY;
private final Set<DualReadModeWatcher> _globalDualReadModeWatchers;
Expand Down Expand Up @@ -78,7 +78,7 @@ public DualReadStateManager(DualReadModeProvider dualReadModeProvider, Scheduled
_clusterDualReadModes = new ConcurrentHashMap<>();
_dualReadModeProvider = dualReadModeProvider;
_executorService = executorService;
_rateLimiter = RateLimiter.create((double) 1 / DUAL_READ_MODE_SWITCH_MIN_INTERVAL);
_serviceToRateLimiterMap = new ConcurrentHashMap<>();
_globalDualReadModeWatchers = ConcurrentHashMap.newKeySet();
_serviceDualReadModeWatchers = new ConcurrentHashMap<>();
_clusterDualReadModeWatchers = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -191,7 +191,14 @@ public void checkAndSwitchMode(String d2ServiceName)

_executorService.execute(() ->
{
boolean shouldCheck = _rateLimiter.tryAcquire();
if(d2ServiceName == null){
return;
}
RateLimiter serviceRateLimiter = _serviceToRateLimiterMap.computeIfAbsent(
d2ServiceName,
key -> RateLimiter.create((double) 1 / DUAL_READ_MODE_SWITCH_MIN_INTERVAL)
);
boolean shouldCheck = serviceRateLimiter.tryAcquire();
if (shouldCheck)
{
// Check and switch global dual read mode
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.49.1
version=29.49.2
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down

0 comments on commit a909b0b

Please sign in to comment.