[server] Fix follower heartbeat entries for AA stores to use local region only - #2584
Conversation
…region only Restore the !isFollower guard in HeartbeatMonitoringService.initializeEntry() that was accidentally dropped during the HeartbeatKey refactoring in a7f4d1e. Without this check, AA-enabled follower replicas got heartbeat entries for ALL regions instead of just the local region, causing unbounded delays and misleading catch_up metrics for non-local regions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Restores correct heartbeat entry initialization behavior in HeartbeatMonitoringService so that for Active/Active (AA) stores, leaders initialize heartbeat tracking for all regions while followers only initialize tracking for the local region—preventing unbounded lag growth and misleading catch-up metrics for non-local regions on follower replicas.
Changes:
- Fix regression by reintroducing the
!isFollowerguard inHeartbeatMonitoringService.initializeEntry()for AA versions. - Update
HeartbeatMonitoringServiceTestassertions to validate that AA followers only have a single (local) region entry and thatREMOTE_FABRICentries are absent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| clients/da-vinci-client/src/main/java/com/linkedin/davinci/stats/ingestion/heartbeat/HeartbeatMonitoringService.java | Restores leader-vs-follower conditional so AA followers don’t initialize heartbeat entries for all regions. |
| clients/da-vinci-client/src/test/java/com/linkedin/davinci/stats/ingestion/heartbeat/HeartbeatMonitoringServiceTest.java | Updates expectations to ensure AA follower maps only contain local-region entries (and no REMOTE_FABRIC). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
clients/da-vinci-client/src/main/java/com/linkedin/davinci/stats/ingestion/heartbeat/HeartbeatMonitoringService.java:147
- With this change, new AA follower lag monitors will only initialize the local-region entry, but any non-local follower entries that were already created by the previous regression will remain in
followerHeartbeatTimeStampsfor partitions that stay followers (sinceinitializeEntry()only doesputIfAbsent). Consider pruning/removing any existing follower entries for the same (store, version, partition) whose region != localRegionName when (re)adding a follower monitor, so the fix takes effect without requiring a process restart or a leader transition to triggerremoveEntry().
if (version.isActiveActiveReplicationEnabled() && !isFollower) {
for (String region: regionNames) {
if (Utils.isSeparateTopicRegion(region) && !version.isSeparateRealTimeTopicEnabled()) {
continue;
}
HeartbeatKey key = new HeartbeatKey(storeName, versionNum, partition, region);
heartbeatTimestamps.putIfAbsent(key, new IngestionTimestampEntry(currentTime, currentTime, false, false));
}
} else {
HeartbeatKey key = new HeartbeatKey(storeName, versionNum, partition, localRegionName);
heartbeatTimestamps.putIfAbsent(key, new IngestionTimestampEntry(currentTime, currentTime, false, false));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
heartbeat change Update validateSeparateRealtimeTopicHeartbeat to expect _sep heartbeat entries only from leaders (getNumberOfRegions()), not from both leaders and followers (getNumberOfRegions() * getReplicationFactor()), since followers now only get local region heartbeat entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gion only (linkedin#2584) Fix AA follower heartbeat initialization to track only local region Problem: Active/Active follower replicas were initializing heartbeat tracking for all regions instead of only the local region. Because followers consume only the local VT, non-local heartbeat entries were never updated, causing unbounded delay growth and misleading catch-up metrics for remote regions. Solution: Restore the leader-versus-follower initialization logic in HeartbeatMonitoringService so AA leaders still track all regions, while AA followers create heartbeat entries only for the local region. Update HeartbeatMonitoringServiceTest to verify followers keep a single local-region entry and do not create remote-region entries.
[server] Fix follower heartbeat entries for AA stores to use local region only
Commit
a7f4d1eca("Introduce record level delay with heartbeat delay") refactoredHeartbeatMonitoringServicefrom nested maps to flatHeartbeatKeymaps. During that refactoring, the!isFollowerguard was accidentally dropped frominitializeEntry().Before (correct):
After regression (current):
Impact: For AA-enabled stores, follower replicas now get heartbeat entries for ALL regions. Since followers only consume from local VT, non-local entries are never updated — their delays grow unbounded, generating misleading catch_up metrics (both Tehuti and OTel) for all regions instead of just the local region.
Solution
Restore the
!isFollowerguard ininitializeEntry()so that only leaders get heartbeat entries for all regions when AA is enabled. Followers should only get the local region entry regardless of AA configuration.Code changes
Concurrency-Specific Checks
Both reviewer and PR author to verify
synchronized,RWLock) are used where needed.ConcurrentHashMap,CopyOnWriteArrayList).How was this PR tested?
Updated two assertions in
HeartbeatMonitoringServiceTest:REMOTE_FABRICentry should benull(not present) for AA followersAll 11 tests in
HeartbeatMonitoringServiceTestpass.Does this PR introduce any user-facing or breaking changes?