Interface MigrationTask

All Known Implementing Classes:
ColumnFamilyPrefixCorrectionMigration, DecisionMigration, DecisionRequirementsMigration, JobBackoffCleanupMigration, JobBackoffRestoreMigration, JobTimeoutCleanupMigration, MessageSubscriptionSentTimeMigration, MultiTenancyDecisionStateMigration, MultiTenancyJobStateMigration, MultiTenancyMessageStartEventSubscriptionStateMigration, MultiTenancyMessageStateMigration, MultiTenancyMessageSubscriptionStateMigration, MultiTenancyProcessMessageSubscriptionStateMigration, MultiTenancyProcessStateMigration, MultiTenancySignalSubscriptionStateMigration, ProcessInstanceByProcessDefinitionMigration, ProcessMessageSubscriptionSentTimeMigration, TemporaryVariableMigration

public interface MigrationTask
Interface for migration tasks.

Implementations of this class can/must assume the following contract:

  • Implementation will be called before any processing is performed
  • Implementation will be called with an open database and open transaction
  • Implementation may be called more than once throughout the lifetime of the deployment of a given version of software in production
  • The method runMigration(...) will only be called after needsToRun(...) was called and did return true
  • All methods should be implemented with the context in mind, that they will be called synchronously during recovery.
  • Migrations that are expected to potentially take a long time, should only be implemented after https://github.com/camunda/zeebe/issues/7248 has been solved
  • None of the methods must commit or roll back the transaction. The transaction is handled outside
  • Methods may throw exceptions to indicate a critical error during migration
    • Any exception thrown will cancel all subsequent migrations and will prevent the stream processor from starting
    • Therefore, great care shall be taken to handle exceptions and recoverable situations internally
  • Method Details

    • getIdentifier

      String getIdentifier()
      Returns identifier for the migration task.

      The identifier is used for logging.

      In the future, it might also be used to store the migrations that were run in persistent state

      Returns:
      identifier for the migration task
    • needsToRun

      boolean needsToRun(ProcessingState processingState)
      Returns whether the migration needs to run.
      Parameters:
      processingState - the immutable Zeebe state
      Returns:
      whether the migration needs to run
    • runMigration

      void runMigration(MutableProcessingState processingState)
      Implementations of this method perform the actual migration
      Parameters:
      processingState - the mutable Zeebe state