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, Store store, BackupStrategy backupStrategy, int minNumberOfStoreVersionsToPreserve, 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 rollback). Preserve count is N-1 for DELETE_ON_NEW_PUSH_START, N otherwise. Clamps to 1 because Store.retrieveVersionsToDelete(int) rejects values below 1.
    • checkRollbackOriginVersionCapacityForNewPush

      public static void checkRollbackOriginVersionCapacityForNewPush(String clusterName, String storeName, Store store, long rolledBackVersionRetentionMs, long currentTimeMs)
      Throws if starting a new push would violate the retention window for a rollback-origin version. Blocks when a ROLLED_BACK or PARTIALLY_ONLINE version sits strictly above the current version — the rollback-origin invariant, since rollback decrements currentVersion below the rolled-back-from version's number on both parent and child controllers. Stale entries lingering below currentVersion (e.g., after a subsequent push promoted higher) are skipped. The block also lifts once latestVersionPromoteToCurrentTimestamp + rolledBackVersionRetentionMs elapses; past that point, the version will be swept on the next SOP deletion pass.
    • 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).