Skip to content

0.7.0: staged db_path inputs (ext.volumes) not symlinked → head copies full DB to S3, classifier deadlocks #65

Closed as not planned

Description

@scttfrdmn

Symptom

On nf-spawn 0.7.0, an nf-core/taxprofiler run deadlocks at the profiling step: KRAKEN2_KRAKEN2 and METAPHLAN_METAPHLAN sit status=ACTIVE with their db channel (queue) OPEN and zero classifier tasks are ever submitted. Nextflow then logs:

!! executor spawn > No more task to compute -- The following nodes are still active:
[process] NFCORE_TAXPROFILER:TAXPROFILER:PROFILING:KRAKEN2_KRAKEN2
  status=ACTIVE
  port 1: (queue) OPEN  ; channel: db

All preceding stages (FETCH/fastp/FastQC) complete exit 0. ext.az (the 0.7.0 feature) works correctly — every task pinned to the requested AZ.

Root cause (what the head log shows)

The DB is delivered via ext.volumes (EBS snapshot mounted RO at /opt/databases/{kraken2,metaphlan}), and taxprofiler stages db_path as a Nextflow path input. On 0.7.0 the head's FilePorter copies the entire mounted DB dir UP to S3 instead of the staged input being symlinked to the ext.volumes mount (the #55/#56 zero-copy behavior):

FilePorter - Copying foreign file /opt/databases/kraken2 to work dir: s3://.../stage-.../kraken2
S3FileSystemProvider - S3 upload directory from=/opt/databases/kraken2 to=s3://.../kraken2
FilePorter - Staging foreign file: /opt/databases/kraken2   # and /opt/databases/metaphlan

That upload never completes for the large files — in the staged S3 prefix, all the small Kraken2 files are present but hash.k2d (the ~16 GB main DB) is missing; likewise MetaPhlAn's main .1.bt2l/.2.bt2l are missing. So the db channel never receives a complete staged input and the process deadlocks.

Why this is surprising

The symlink methods (volumeMountPaths, volumeBindMounts, parseVolumeSpecs) are present in 0.7.0, and javap shows 0.7.0's SpawnTaskHandler differs from 0.6.0 only by the added az parameter on buildLaunchCommand — the volume/symlink code is byte-identical. So either:

  1. the 0.5.0 stage-name symlink works for --db <name> (Kraken2) but not find -L <name> (MetaPhlAn) — symlink missing in task work dir #55/fix: symlink ext.volumes DB by stage-name basename, not source URI (#55) #56 staged-input→symlink path regressed in behavior despite identical-looking methods, or
  2. it never actually fired for taxprofiler's specific staging shape and a different earlier build masked it.

(Reporting observations only — not proposing a fix.)

Repro

  • nf-spawn 0.7.0, nf-core/taxprofiler 2.0.0, S3 workDir
  • process { withName: 'KRAKEN2_KRAKEN2' { ext.volumes = [[snapshot:'snap-…', mount:'/opt/databases/kraken2', readOnly:true]] } } (same for METAPHLAN)
  • databases.csv db_path = the mount path; mount basename == the input stage name
  • head also mounts the same snapshots RO (via --attach-volume) so head-side db_path existence validation passes

Expected

The staged path input whose stage-name basename matches an ext.volumes mount is symlinked to the mount (zero-copy), not copied to S3 — so the db channel resolves and classifier tasks submit. This worked on a pre-release build between 0.6.0 and 0.7.0.

Activity

  1. scttfrdmn commented on Jun 16, 2026

    @scttfrdmn
    CollaboratorAuthor

    Dug into this — your hypothesis #2 is correct, and it's not a 0.7.0 regression. Root cause locked down:

    What's actually happening

    The #55/#56 zero-copy fix is entirely instance-side: buildInputStaging (in SpawnTaskHandler) emits ln -sfn <mount> <stagename> instead of aws s3 cp on the task instance, keyed off task.getInputFilesMap(). That code is byte-identical in 0.7.0 (you're right — the only delta is the az param), and it works once a task is scheduled.

    But the deadlock happens before any task exists. The db_path input points at /opt/databases/kraken2 — a local path on the head that is foreign to the S3 work dir's filesystem. Nextflow's FilePorter therefore copies it into the S3 work area on the head as part of resolving the db channel, before KRAKEN2_KRAKEN2 ever submits. The instance-side symlink never gets a chance to run because the channel never resolves — the 16 GB hash.k2d upload stalls/never completes, so the (queue) OPEN deadlock you see.

    Why this isn't a regression

    getStageInMode / stageInMode / FilePorter have never appeared in nf-spawn's history (git log -S across --all is empty) — there was never any head-side foreign-file handling. SpawnExecutor doesn't override stage-in at all, so Nextflow's default "copy foreign path inputs into the work dir" applies. The pre-release build that "worked" almost certainly had the head mounting the same snapshot such that the copy was local→local (fast, completed) — but as soon as the work dir is S3 and the DB is large, the head→S3 copy is the bottleneck. #55 fixed the per-task download; it never addressed the head-side stage-in copy because in the validating run that copy happened to complete.

    The real fix is head-side, and it's a design choice

    The instance-side symlink can't help here. Options, roughly:

    1. Executor stage-in override — have SpawnExecutor/handler tell Nextflow not to stage a path input whose source matches an ext.volumes mount (so FilePorter skips the copy and the channel resolves to the mount path, which the instance already has bind-mounted). This is the clean fix if the 26.04 plugin API exposes the right hook (getStageInMode/foreign-file seam — needs confirming against the plugin API; I couldn't verify the exact method from the jar).
    2. Workaround available today (no code): point databases.csv db_path at a path under the S3 work dir / same filesystem (or an s3:// URI you pre-stage once), so it isn't foreign and isn't bulk-copied per run; the instance-side symlink then resolves it zero-copy. Less clean but unblocks the demo now.
    3. Document that ext.volumes-backed DBs must not also be declared as path inputs that resolve to a head-local path — pass them purely as the volume + reference them by mount path in the module.

    I'd lean option 1 as the durable fix but it needs an API spike to confirm the hook exists in the nextflow-plugin 1.0.0-beta.14 / Nextflow 26.04 surface before committing. Flagging clearly: this is a new gap (head-side stage-in), not the #55 path — re-opening #55 wouldn't be right; #65 is the correct home.

    Want me to (a) spike option 1 (confirm the stage-in hook + prototype), or (b) write up option 2 as an immediate unblock for aws-microbiome-demo while option 1 is designed?

  2. scttfrdmn commented on Jun 16, 2026

    @scttfrdmn
    CollaboratorAuthor

    Following up to correct my own framing above: this is a head-side / pipeline-config matter, not an nf-spawn defect — and I'm walking back the "option 1 (executor stage-in override)" suggestion.

    By design, nf-spawn does no work on the head. It builds the spawn launch argv and ships a staging script that runs entirely on the EC2 instance — that's the whole instance-side buildInputStaging/symlink mechanism (#55). The FilePorter copy you're seeing is Nextflow's own head-side staging, triggered by databases.csv declaring db_path as a path that resolves to a head-local directory (/opt/databases/kraken2) foreign to the S3 work dir. For nf-spawn to prevent that, it would have to intercept Nextflow's head-side file localization — which is both against its design (no head work) and a brittle fight with Nextflow internals. Not the right place to fix it.

    Resolution is on the head, in pipeline config: don't declare the ext.volumes-backed DB as a path input that resolves to a head-local foreign path. The intended ext.volumes pattern (per #45/#49) is that the DB lives on the mounted volume and is referenced by its mount path on the instance — not also staged as a Nextflow path input the head must localize. With taxprofiler specifically, that means wiring db_path so Nextflow doesn't treat it as a foreign file to copy into the S3 work area (e.g. a pre-staged s3:// location, or not routing the volume DB through the staged-path channel at all). You know your taxprofiler config best, so I'll leave the exact knob to you.

    Closing as not planned (not an nf-spawn bug) — the analysis stays here as the record. Happy to reopen if a head-side config change still leaves nf-spawn doing the wrong thing on the instance side.

    One small thing I can do on the nf-spawn side if useful: a note in the README ext.volumes section warning that a volume-backed DB must not also be declared as a head-local path input (it'll be bulk-copied to the work dir and can deadlock). Say the word and I'll add it — that's the only nf-spawn-side action that makes sense here.

  3. scttfrdmn commented on Jun 16, 2026

    @scttfrdmn
    CollaboratorAuthor

    Agreed on all counts — closing as not-planned is correct. The deadlock is the demo's pipeline config, not nf-spawn: by declaring the ext.volumes-backed DB as a taxprofiler path input that resolves to the head-local mount (/opt/databases/kraken2), we made Nextflow's FilePorter try to bulk-copy ~56 GB of foreign files into the S3 work dir on the head, which stalls before any task is scheduled — so the instance-side #55 symlink never gets a chance to run.

    The fix lives entirely on the demo side: stop routing the volume DB through a staged head-local path channel. The mounted volume is the source of truth on the instance (the whole point of ext.volumes per #45/#49); the head must not also be asked to localize it. I'll rework the demo's databases.csv/db_path wiring so Nextflow doesn't treat it as a foreign file to copy (tracking that on the demo repo, not here).

    Yes please to the README note — a one-liner in the ext.volumes section warning that a volume-backed reference must not also be declared as a head-local path input (it'll be bulk-copied to the work dir and can deadlock before any task submits) would have saved me this whole detour, and it's the right place to capture it. Thanks for the thorough root-cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions