Class HistoryCleanupCmd

  • All Implemented Interfaces:
    Command<Job>

    public class HistoryCleanupCmd
    extends java.lang.Object
    implements Command<Job>
    Author:
    Svetlana Dorokhova
    • Field Detail

      • HISTORY_CLEANUP_JOB_DECLARATION

        public static final JobDeclaration HISTORY_CLEANUP_JOB_DECLARATION
    • Constructor Detail

      • HistoryCleanupCmd

        public HistoryCleanupCmd​(boolean immediatelyDue)
    • Method Detail

      • getHistoryCleanupJobs

        protected java.util.List<Job> getHistoryCleanupJobs()
      • shouldCreateJobs

        protected boolean shouldCreateJobs​(java.util.List<Job> jobs)
      • shouldReconfigureJobs

        protected boolean shouldReconfigureJobs​(java.util.List<Job> jobs)
      • shouldSuspendJobs

        protected boolean shouldSuspendJobs​(java.util.List<Job> jobs)
      • willBeScheduled

        protected boolean willBeScheduled()
      • createJobs

        protected java.util.List<Job> createJobs​(int[][] minuteChunks)
      • reconfigureJobs

        protected java.util.List<Job> reconfigureJobs​(java.util.List<Job> historyCleanupJobs,
                                                      int degreeOfParallelism,
                                                      int[][] minuteChunks)
      • suspendJobs

        protected void suspendJobs​(java.util.List<Job> jobs)
      • createJob

        protected JobEntity createJob​(int[] minuteChunk,
                                      int maxRetries)
      • createCleanupContext

        protected HistoryCleanupContext createCleanupContext​(int[] minuteChunk,
                                                             int maxRetries)
      • writeUserOperationLog

        protected void writeUserOperationLog​(CommandContext commandContext)
      • acquireExclusiveLock

        protected void acquireExclusiveLock​(CommandContext commandContext)
      • isRetryable

        public boolean isRetryable()
        When CockroachDB is used, this command may be retried multiple times until it is successful, or the retries are exhausted. CockroachDB uses a stricter, SERIALIZABLE transaction isolation which ensures a serialized manner of transaction execution. A concurrent transaction that attempts to modify the same data as another transaction is required to abort, rollback and retry. This also makes our use-case of pessimistic locks redundant since we only use them as synchronization barriers, and not to lock actual data which would protect it from concurrent modifications. The History Cleanup command only executes internal code, so we are certain that a retry of a failed reconfiguraton will not impact user data, and may be performed multiple times.
        Specified by:
        isRetryable in interface Command<Job>
        Returns:
        true if the CrdbTransactionRetryInterceptor can make a transparent retry of this command upon failure with a CrdbTransactionRetryException (only used when running on CockroachDB).