linkedin / venice

Venice, Derived Data Platform for Planet-Scale Workloads.
https://venicedb.org
BSD 2-Clause "Simplified" License
488 stars 86 forks source link

[BUG] Reset Customized View status in Helix when a server node joins the cluster #655

Open ZacAttack opened 1 year ago

ZacAttack commented 1 year ago

Willingness to contribute

No. I cannot contribute a bug fix at this time.

Venice version

0.4.139

System information

Describe the problem

Background

Helix implemented a Customized-View feature for Venice specific requirements. In this feature, each instance within Helix Cluster updates their instance specific view and Helix controller aggregates view across all the cluster instances and presents at Cluster level. This information is used by Venice controllers to determine the health of their resources.

Problem Statement

When the instance/node in the cluster shuts down ungracefully, the instance has no way to update its own customized state. When the instance recovers, Helix aggregation logic reads the “stale” customized-state and updates the aggregated customized view, which results in the Venice router redirecting traffic to not-yet-recovered instance. Instances maintain connection with ZK and create an Ephemeral node (LIVEInstance/) when it is up and running. When this ephemeral node disappears, Helix thinks that instance is down. Helix cannot distinguish - temporary disconnect, graceful shutdown and ungraceful shutdown. Ideally in temporary disconnect - neither participant nor controller needs to do any changes to Customized-state or customized-view. In case of graceful shutdown, the participant instance will update its customized state. But in case of an ungraceful shutdown, we do not have any hooks today. This RFC is addressing this particular case.

Solution

Helix Participant can use the pre-existing callback provided by Helix-Manager. In Venice, SafeHelixManager.java - there is a method to addPrecallback(). This can be used by Venice to add the required logic to reset the customized-state. This callbacks are executed prior to creating the live instance ephemeral node. In file: [HelixParticipationService.java]

helixManager.setLiveInstanceInfoProvider(liveInstanceInfoProvider); HelixStatusMessageChannel messageChannel =new    
HelixStatusMessageChannel(helixManager, new HelixMessageChannelStats(metricsRepository, clusterName)); messageChannel.registerHandler(KillOfflinePushMessage.class, this); 
...
asyncStart() <---- this is the one which does connection.

Interface to override:

  @Override
  public void onPreConnect() { ... }

The Helix will do the callback which the user has provided before creating the live-instance. So in that code-path, Venice can add the logic to reset the customized-state for that instance.

Tracking information

No response

Code to reproduce bug

No response

What component(s) does this bug affect?

kvargha commented 1 month ago

I think this is implemented here.