Skip to content

AWS Batch job stuck as RUNNABLE #546

Closed

Description

@victorlin

Background

In AWS Batch, jobs are sent to a job queue before running. The job queue only allows certain instance sizes. This is specified in the associated compute environment (CE), and often not configured by the user, but instead someone who has set up the Batch runtime for them to use (following docs).

Problem

Jobs that request resources beyond the limits of the largest instance size available for the compute environment will be stuck as RUNNABLE indefinitely. This is documented behavior by AWS Batch.

The problem is that it's not clear to users why the job is stuck as RUNNABLE, and what can be done to address it.

Possible solutions

  1. Nextstrain CLI: Detect when a job requests resources beyond the limits of the largest instance size available for the compute environment and exit with an error instead of submitting the job.
    • This would be the best user experience, but I'm not sure about feasibility. At the very least, users will need additional permissions to batch:DescribeComputeEnvironments and/or ec2:DescribeInstanceTypes. Job queues / compute environments can also be set up in a way where it is difficult to infer limits of the largest instance size.
  2. Nextstrain CLI: Detect when a job is stuck in RUNNABLE and display a warning message or automatically cancel.
    • This only applies if the user is attached to the job.
  3. Job queue config: set jobStateTimeLimitActions to automatically cancel a job stuck as RUNNABLE due to requesting resources beyond CE limits.
    • This relies on external configuration. Should be added to AWS Batch setup docs.

Additional context

This issue arose during debugging in @blab.

Activity

  1. jameshadfield commented on Oct 8, 2026

    @jameshadfield
    Member

    While a technological solution like (1) would be nice (I've run into this before!), I think writing a docs page summarising the causes and how to troubleshoot is good enough if it's flagged up by the CLI when (a) re-attatching to a job which is runnable and was submitted over an hour ago or (b) when the CLI is attached and the job's been runnable for more than an hour.

  2. joverlee521 commented on Oct 8, 2026

    @joverlee521
    Contributor

    Looks like there's a jobStateTimeLimitActions parameter that we can set to automatically cancel jobs stuck in the RUNNABLE state. I wonder if we can then surface the statusReason for the automatically cancelled job to the user when they reattach?

  3. victorlin commented on Oct 9, 2026

    @victorlin
    MemberAuthor

    @joverlee521 nice, I've added that as solution 3. Nextstrain CLI already surfaces statusReason for completed jobs:

    Job now SUBMITTED
    Job now RUNNABLE
    Job FAILED after 10.2 minutes (Canceled by JobStateTimeLimit action due to reason: MISCONFIGURATION:JOB_RESOURCE_REQUIREMENT)
    

    Note that it's an external solution and the minimum is 10 minutes.

    Solution 2 can still be used to immediately cancel any stuck jobs if the user is attached, regardless of whether their job queue has been configured with jobStateTimeLimitActions.

  4. linked a pull request that will close this issueAuto-cancel jobs stuck as RUNNABLE #547on Oct 9, 2026
  5. self-assigned this
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions