Skip to content

[controller] Make controller leader transition timeout configurable - #3005

Open
KaiSernLim wants to merge 1 commit into
linkedin:mainfrom
KaiSernLim:kailim/controller-transition-timeout-upstream
Open

[controller] Make controller leader transition timeout configurable#3005
KaiSernLim wants to merge 1 commit into
linkedin:mainfrom
KaiSernLim:kailim/controller-transition-timeout-upstream

Conversation

@KaiSernLim

Copy link
Copy Markdown
Contributor

Problem Statement

VENG-12819 addresses controller STANDBY-to-LEADER transitions that can outlive Helix's wait and leave an initialized manager behind. The existing five-minute timeout is hard-coded, and retrying leadership with stale manager state could let Helix mark the controller leader without fully initialized cluster resources.

Solution

Make the transition timeout configurable per cluster with controller.standby.to.leader.transition.timeout.ms, defaulting to 600000 ms (10 minutes). Keep initialization and reset serialized on the existing single worker architecture: timed-out work is interrupted, reset waits for initialization that ignores interruption before cleaning resources and disconnecting the manager, and a stale connected manager rejects re-election until reset. Interrupted transition callers retain their interrupt status.

Code changes

  • Added new code behind a config. Config: controller.standby.to.leader.transition.timeout.ms; default: 600000 ms (10 minutes).
  • Introduced new log lines.
    • Confirmed logs do not need to be rate limited because failures are emitted only on Helix state-transition failure paths.

Concurrency-Specific Checks

Both reviewer and PR author verified:

  • Code has no race conditions or thread safety issues.
  • Proper synchronization mechanisms are used: initialization and reset remain serialized.
  • Blocking initialization under synchronization is intentional so reset is a cleanup barrier rather than racing third-party connect/refresh calls.
  • No new shared collections are introduced.
  • Transition exceptions and interrupts are propagated without silently terminating lifecycle work.

How was this PR tested?

  • New unit tests added.
  • New integration tests added.
  • Modified or extended existing tests.
  • Verified backward compatibility through the default configuration.
  • Local high-confidence code review completed.

Validation:

  • ./gradlew --no-daemon spotlessCheck :services:venice-controller:test --tests com.linkedin.venice.controller.TestVeniceControllerStateModel --tests com.linkedin.venice.controller.TestVeniceControllerClusterConfig
  • git diff --check

Focused tests cover the 10-minute default and override, timeout cancellation/interruption, reset with a connected manager and null resources, reset waiting for interruption-ignoring initialization, stale-manager rejection and post-reset re-election, and caller interrupt preservation.

Does this PR introduce any user-facing or breaking changes?

  • No. You can skip the rest of this section.
  • Yes. Clearly explain the behavior change and its impact.

🤖 Generated with GitHub Copilot CLI

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 1, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A negative configured timeout can currently escape the existing exception handling and may leave the background transition task running without cancellation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR makes the controller STANDBY→LEADER transition timeout configurable per cluster via controller.standby.to.leader.transition.timeout.ms (defaulting to 10 minutes), addressing cases where initialization can outlive Helix’s wait and leave stale/partially-initialized leader state behind.

Changes:

  • Replaced the previously hard-coded (and test-only override) STANDBY→LEADER transition timeout with a VeniceControllerClusterConfig-backed value.
  • Hardened leader transition behavior by failing fast if a connected Helix manager already exists, and improved interrupt handling (restoring interrupt status).
  • Added/updated unit tests covering default/override timeout behavior, cancellation/interrupt behavior, reset semantics, and stale-manager re-election behavior.
File summaries
File Description
services/venice-controller/src/main/java/com/linkedin/venice/controller/VeniceControllerStateModel.java Uses cluster-configured timeout for STANDBY→LEADER and adjusts interrupt/error handling; tweaks reset ordering.
services/venice-controller/src/main/java/com/linkedin/venice/controller/VeniceControllerClusterConfig.java Adds new cluster config field + getter for standby→leader transition timeout with 10-minute default.
internal/venice-common/src/main/java/com/linkedin/venice/ConfigKeys.java Introduces the new config key constant and documentation comment.
services/venice-controller/src/test/java/com/linkedin/venice/controller/TestVeniceControllerStateModel.java Reworks/extends unit tests for timeout/interrupt/reset/stale-manager transition behavior.
services/venice-controller/src/test/java/com/linkedin/venice/controller/TestVeniceControllerClusterConfig.java Adds tests validating the new config’s default and override.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +218 to +222
stateTransitionFuture.get(clusterConfig.getControllerStandbyToLeaderTransitionTimeoutMs(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.error("Failed to execute the controller state transition from STANDBY to LEADER for {}", clusterName, e);
if (stateTransitionFuture != null && !stateTransitionFuture.isDone()) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants