Skip to content

Add support for cancelling compression jobs. #1745

@junhaoliao

Description

@junhaoliao

Request

Add support for cancelling compression jobs. Currently, the compression scheduler does not handle job cancellation requests, meaning users cannot stop a running or pending compression job gracefully. This is essential for resource management, allowing users to terminate accidental or lower-priority jobs to free up resources for other tasks.

Possible implementation

  1. Update Database Schemas/Constants:

    • Add CANCELLING and CANCELLED states to CompressionJobStatus in constants.py.
    • Add CANCELLED state to CompressionTaskStatus.
  2. Update Task Managers:

    • Add a cancel() method to the abstract TaskManager interface.
    • Implement cancel() in CeleryTaskManager using celery_result.revoke(terminate=True).
    • Implement cancel() in SpiderTaskManager.
  3. Update Compression Scheduler:

    • Implement a fetch_cancelling_jobs function to query jobs in the CANCELLING state.
    • Implement handle_cancelling_jobs logic in the main scheduler loop:
      • Identify active jobs that are marked as CANCELLING.
      • Call job.result_handle.cancel() to revoke dispatched tasks.
      • Update status of RUNNING and PENDING tasks to CANCELLED in the database.
      • Update the job status to CANCELLED and record the final duration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions