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

add debug log to dual read caches #952

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.48.5] - 2023-12-12
- add debug log to dual read caches

## [29.48.4] - 2023-12-06
- correct where to increment the clusterNotFound count and adjust quarantine log level

Expand Down Expand Up @@ -5575,7 +5578,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.4...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.5...master
[29.48.5]: https://github.com/linkedin/rest.li/compare/v29.48.4...v29.48.5
[29.48.4]: https://github.com/linkedin/rest.li/compare/v29.48.3...v29.48.4
[29.48.3]: https://github.com/linkedin/rest.li/compare/v29.48.2...v29.48.3
[29.48.2]: https://github.com/linkedin/rest.li/compare/v29.48.1...v29.48.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,37 @@ public void reportData(String propertyName, T property, String propertyVersion,
Cache<String, CacheEntry<T>> cacheToAdd = fromNewLb ? _newLbPropertyCache : _oldLbPropertyCache;
Cache<String, CacheEntry<T>> cacheToCompare = fromNewLb ? _oldLbPropertyCache : _newLbPropertyCache;

CacheEntry<T> entry = cacheToCompare.getIfPresent(propertyName);
CacheEntry<T> entryToCompare = cacheToCompare.getIfPresent(propertyName);
CacheEntry<T> newEntry = new CacheEntry<>(propertyVersion, getTimestamp(), property);

if (entry != null && Objects.equals(entry._version, propertyVersion))
if (entryToCompare != null && Objects.equals(entryToCompare._version, propertyVersion))
{
CacheEntry<T> newEntry = new CacheEntry<>(propertyVersion, getTimestamp(), property);
if (!isEqual(entry, newEntry))
if (!isEqual(entryToCompare, newEntry))
{
_rateLimitedLogger.warn("Received mismatched properties from dual read. Old LB: {}, New LB: {}",
fromNewLb ? entry : newEntry, fromNewLb ? newEntry : entry);
fromNewLb ? entryToCompare : newEntry, fromNewLb ? newEntry : entryToCompare);
bohhyang marked this conversation as resolved.
Show resolved Hide resolved
incrementEntryOutOfSyncCount(); // increment the out-of-sync count for the entry received later
}
else
{ // entries are in-sync, decrement the out-of-sync count for the entry received earlier
decrementEntryOutOfSyncCount();
_rateLimitedLogger.debug("Matched properties from dual read. Old LB: {}, New LB: {}.",
fromNewLb ? entryToCompare : newEntry, fromNewLb ? newEntry : entryToCompare);
}
cacheToCompare.invalidate(propertyName);
}
else
{
cacheToAdd.put(propertyName, new CacheEntry<>(propertyVersion, getTimestamp(), property));
cacheToAdd.put(propertyName, newEntry);
// if version is different, entries of both the old version and the new version will increment the out-of-sync count
incrementEntryOutOfSyncCount();
_rateLimitedLogger.debug("Added new entry to dual read cache for {} LB.",
fromNewLb ? "New" : "Old");
}
entryToCompare = cacheToCompare.getIfPresent(propertyName);
newEntry = cacheToAdd.getIfPresent(propertyName);
_rateLimitedLogger.debug("Current entries on dual read caches: Old LB {}, New LB {}",
fromNewLb ? entryToCompare : newEntry, fromNewLb ? newEntry : entryToCompare);
}

abstract void incrementEntryOutOfSyncCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ private void reportUriPropertiesData(String propertyName, UriProperties property
*/
public void checkAndSwitchMode(String d2ServiceName)
{
if (_executorService.isShutdown())
{
return;
bohhyang marked this conversation as resolved.
Show resolved Hide resolved
}

_executorService.execute(() ->
{
boolean shouldCheck = _rateLimiter.tryAcquire();
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.48.4
version=29.48.5
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Loading