Skip to content

Stage-out follows the #55 stage-in symlink → republishes the whole shared reference DB per task (6.51 TB of a 12 TB work dir) #99

Closed

Description

@scttfrdmn

Summary

Stage-out follows the symlinks stage-in created for #55, so a shared read-only reference database gets re-uploaded into every task's S3 work dir as if the task had produced it. The zero-copy win is real on the read path and silently undone on the write path.

Measured on a real N=30 metagenomics fan-out (nf-core/taxprofiler 2.0.0, Kraken2 + MetaPhlAn on a shared FSx Lustre filesystem, nf-spawn 0.8.0): 6.51 TB of a 12.00 TB work dir was reference database — ~1.45 TB per run. Nothing failed and nothing was slow, which is why it went unnoticed for three months. The only evidence was an S3 line item.

Evidence (measured, not inferred)

One classify task's work dir in S3. kraken2/ is the staged db_path input, symlinked to /fsx/kraken2 by #55:

work/microbiome-demo/classify/2a/c9a321a55d70d58167e4f69638f408/
  .command.sh                                           424 B
  SRR059373_stool_…_1.fastp.fastq.gz                    2.84 GB   ← the task's input
  SRR059373_stool_…_2.fastp.fastq.gz                    2.82 GB   ← the task's input
  SRR059373_stool_…_k2_pluspf_16gb.kraken2.report.txt   0.48 MB   ← the task's ONLY real output
  kraken2/hash.k2d                                     16.00 GB   ← the database
  kraken2/names.dmp                                     0.28 GB   ← the database
  kraken2/library_report.tsv                            0.06 GB
  kraken2/database{50,75,100,…,300}mers.kmer_distrib    0.04 GB
  kraken2/{inspect.txt,ktaxonomy.tsv,…}

A 0.48 MB report cost 16.4 GB of upload.

Aggregated across the June benchmark legs in one bucket:

task dirs avg per dir total
full Kraken2 DB copies 153 16.4 GB 2.51 TB
full MetaPhlAn DB copies 125 32.0 GB 4.00 TB
combined 6.51 TB (54% of the work dir)

At N=30 that is 30 × 16.4 GB + 30 × 32.0 GB ≈ 1.45 TB per run.

Root cause

Both halves work as designed; the seam between them does not. Both sites are in src/main/groovy/io/nextflow/spawn/SpawnTaskHandler.groovy:

  1. Stage-in (0.5.0 stage-name symlink works for --db <name> (Kraken2) but not find -L <name> (MetaPhlAn) — symlink missing in task work dir #55) — when a declared input's stage name matches an attached mount basename, symlink the stage name at the mount and skip the copy:

    final String mountForStage = mountByBase[baseName(stageName)]
    if (mountForStage) { /* ln -s the mount, skip the copy */ }

    Correct, and the reason a wide fan-out scales — 56 concurrent readers, no per-task DB copy.

  2. Stage-out — sync the whole work dir back:

    sb << 'if ! aws s3 sync "${LOCAL_DIR}/" "${WORKDIR_S3}" --region "${AWS_REGION}" --exclude ".exitcode" --quiet; then\n'

    aws s3 sync follows symlinks by default, and 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 symlink lives inside ${LOCAL_DIR}. So the sync walks into the shared mount and uploads the database. --no-follow-symlinks does not appear anywhere in the repo, so this is present on main, not only on 0.8.0 where it was observed.

The mechanism is the symlink, so this affects both symlink-based reference delivery paths — ext.volumes (#51/#55) and ext.fsx (#67) alike.

Why it stayed invisible

  • Stage-out happens after the billed classifier work, so no task waits on it and no timing regresses.
  • S3 ingress is free, so nothing appears on a per-run cost estimate.
  • Nobody reads the work dir — dashboards and analyses read results/.
  • -resume keeps the work dir alive, so it is never obviously garbage.

The cost lands as storage, a month later, detached from the run that caused it: ~$33/month of new S3 storage per run, against $17.01 of compute per run. Within a month the unmeasured cost exceeds the measured one.

Requested fix

Stage-out should contain what the task wrote. A read-only shared mount is by construction not that.

Either would do it:

  1. --no-follow-symlinks on the output sync. One flag, matches the intent, and symlinks nf-spawn did not create are not something a task's outputs should smuggle out either. Worth checking it doesn't break a pipeline that legitimately emits a symlinked output — if it does, option 2.
  2. Exclude the paths 0.5.0 stage-name symlink works for --db <name> (Kraken2) but not find -L <name> (MetaPhlAn) — symlink missing in task work dir #55 symlinked. Stage-in already knows exactly which stage names were substituted (it logs them per [audit] Medium/Low findings tracker (2026-06 suite audit) #59). Emit --exclude for each, so only the deliberately-symlinked reference paths are skipped and ordinary symlinks behave as now.

Option 2 is more surgical and reuses information already computed; option 1 is one flag.

A regression test would assert the generated stage-out command skips a stage name that stage-in symlinked to a mount — the existing SpawnTaskHandlerTest already asserts on the sync line, so it is a natural extension.

Related

Downstream write-up with the full analysis: docs/decisions/0005 in scttfrdmn/aws-microbiome-demo.

Activity

  1. added
    bug
    on Sep 26, 2026
  2. added this to the Hardening milestone on Nov 8, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions