Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indis dual-read lix switch issue #964

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3] - 2024-01-03
- Fix rate limiter for dual-read mode switch

## [29.49.2] - 2024-01-02
- add back publish original cluster for symlink cluster
Expand Down Expand Up @@ -5600,7 +5602,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.2...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.49.3...master
[29.49.3]: https://github.com/linkedin/rest.li/compare/v29.49.2...v29.49.3
[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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class DualReadStateManager
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 @@ -79,6 +80,7 @@ public DualReadStateManager(DualReadModeProvider dualReadModeProvider, Scheduled
_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,15 +193,21 @@ public void checkAndSwitchMode(String d2ServiceName)

_executorService.execute(() ->
{
boolean shouldCheck = _rateLimiter.tryAcquire();
if (shouldCheck)
if (d2ServiceName == null)
{
// Check and switch global dual read mode
updateGlobal(_dualReadModeProvider.getDualReadMode());

// Check and switch service-level dual read mode
if (d2ServiceName != null)
if (_rateLimiter.tryAcquire())
{
// Check and switch global dual read mode
updateGlobal(_dualReadModeProvider.getDualReadMode());
}
}
else
{
RateLimiter serviceRateLimiter = _serviceToRateLimiterMap.computeIfAbsent(d2ServiceName,
key -> RateLimiter.create((double) 1 / DUAL_READ_MODE_SWITCH_MIN_INTERVAL));
if (serviceRateLimiter.tryAcquire())
{
// Check and switch service-level dual read mode
updateService(d2ServiceName, _dualReadModeProvider.getDualReadMode(d2ServiceName));
}
}
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.2
version=29.49.3
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Loading