Class VersionLifecyclePolicy

java.lang.Object
com.linkedin.venice.controller.versionlifecycle.VersionLifecyclePolicy

public final class VersionLifecyclePolicy extends Object
Pure-decision helpers governing the store-version lifecycle: capacity guards run before starting a new push, version selection over a store's version history, status aggregation across child regions, and the small bookkeeping flags (ttlRepushEnabled) self-managed via the push id. All methods are deterministic given their inputs and perform no I/O against the controller's own state (PushMonitor and ReadWriteStoreRepository are passed in explicitly).
  • Method Details

    • checkBackupVersionCleanupCapacityForNewPush

      public static void checkBackupVersionCleanupCapacityForNewPush(String clusterName, String storeName, String regionName, List<Version> versions, int currentVersion, int storeNumVersionsToPreserve, boolean isMigrating, BackupStrategy backupStrategy, int minNumberOfStoreVersionsToPreserve, long latestVersionPromoteToCurrentTimestamp, long minBackupVersionCleanupDelay, long currentTimeMs)
      Throws if starting a new push would exceed the store's version budget because existing backup versions are pending deletion but still within the min cleanup delay (e.g. after a killed push). Preserve count is N-1 for DELETE_ON_NEW_PUSH_START, N otherwise, clamped to 1 because AbstractStore.computeVersionsToDelete(java.util.List<com.linkedin.venice.meta.Version>, int, int, int, boolean) rejects values below 1.

      The parent drives this from LIVE child snapshots (see VeniceParentHelixAdmin.checkNewPushCapacityFromChildren), not its own metadata which can go stale. It runs only on the parent — a throw during child admin-message consumption (VeniceHelixAdmin.addVersion) would wedge the admin channel.

      Takes raw fields so callers can pass a child StoreInfo (not a Store) directly. regionName enriches the rejection message; pass null to omit it.

    • checkRollbackOriginVersionCapacityForNewPush

      public static void checkRollbackOriginVersionCapacityForNewPush(String clusterName, String storeName, String regionName, List<Version> versions, int currentVersion, long latestVersionPromoteToCurrentTimestamp, long rolledBackVersionRetentionMs, long currentTimeMs)
      Throws if a new push would violate the retention window for a rolled-back version in a single child region. Blocks a ROLLED_BACK version above currentVersion (rollback decrements currentVersion, so number > currentVersion is the rollback-origin invariant); entries below currentVersion are stale and skipped. The block lifts once latestVersionPromoteToCurrentTimestamp + rolledBackVersionRetentionMs elapses.

      The parent drives this from LIVE child snapshots, not its own metadata (see VeniceParentHelixAdmin.checkNewPushCapacityFromChildren), which can go stale and falsely block for the whole window. It runs only on the parent — a throw during child admin-message consumption would wedge the admin channel.

      Only ROLLED_BACK counts: a per-region rollback is binary, so a child is never rollback-PARTIALLY_ONLINE (that is a parent-only aggregate). A child PARTIALLY_ONLINE is a degraded-mode forward push and must not block.

      Takes raw fields so callers can pass a child StoreInfo (not a Store) directly. regionName enriches the rejection message; pass null to omit it.

    • getBackupVersionNumber

      public static int getBackupVersionNumber(List<Version> versions, int currentVersion)
      Largest ONLINE version number strictly less than currentVersion, or Store.NON_EXISTING_VERSION if none. Mutates versions (sort by number desc).
    • getFinalReturnStatus

      public static ExecutionStatus getFinalReturnStatus(Map<String,ExecutionStatus> statuses, Set<String> childRegions, int numChildRegionsFailedToFetchStatus, StringBuilder currentReturnStatusDetails)
      Aggregate per-region statuses into one return status using STATUS_PRIORITIES. If fewer than a strict majority of childRegions reported successfully, downgrades to PROGRESS so the caller keeps polling. If the aggregate is terminal but any region failed to report, downgrades to ERROR and appends a "{n}/{total} DCs unreachable" note to currentReturnStatusDetails so VPJ reports failure even when the push succeeds asynchronously in the reachable DCs.
    • getOverallPushStatus

      public static ExecutionStatus getOverallPushStatus(ExecutionStatus veniceStatus, ExecutionStatus daVinciStatus)
      Merge the Venice-server status and the Da Vinci status into a single overall status using STATUS_PRIORITIES. Used to roll up the two replica families into the push status a client polls.
    • hasFatalDataValidationError

      public static boolean hasFatalDataValidationError(PushMonitor pushMonitor, String topicName)
      Read the offline push status from pushMonitor and return whether the push reported a fatal Data Integrity Validation error. Returns false when the push entry no longer exists (logged at WARN).
    • updateStoreTTLRepushFlag

      public static void updateStoreTTLRepushFlag(String pushJobId, Store store, ReadWriteStoreRepository repository)
      Self-manages the store's ttlRepushEnabled property based on push job id prefix.
      • TTL repush (venice_ttl_re_push_*) sets the flag to true.
      • Regular push with TTL repush (venice_regular_push_with_ttl_re_push_*) sets the flag to false.
      • Other push types (including compliance push) do not affect this flag.
      Persists via ReadWriteStoreRepository.updateStore(Store) only when the flag is actually changing.
    • isRealTimeTopicRequired

      public static boolean isRealTimeTopicRequired(Store store, Version version, boolean isParent)
      Whether a real-time topic should exist for version of store. True iff both the store and the version are hybrid and this controller is not a parent — only child regions host RT topics; parent regions route writes through them via the child fabrics.
    • checkPreConditionForSingleVersionDeletion

      public static void checkPreConditionForSingleVersionDeletion(String clusterName, String storeName, Store store, int versionNum)
      Validate that versionNum can be individually deleted from store. Throws VeniceNoStoreException if the store is missing, or VeniceUnsupportedOperationException if versionNum is the current version of a non-system store (system stores are exempt because their current-version delete is part of the tear-down path).