Skip to content

fix(persistence): count only bulk-submit runs without progress toward the attempt cap - #3373

Open
angela-helios wants to merge 3 commits into
mainfrom
fix/3083-bulk-submit-attempt-cap-progress
Open

angela-helios wants to merge 3 commits into
mainfrom
fix/3083-bulk-submit-attempt-cap-progress

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Closes #3083

This branch is stacked on the PR for #3084 (PR #3363). Until #3363 merges, the diff of this PR includes that commit as well.

Behaviour change to review

HFS_BULK_SUBMIT_MAX_ATTEMPTS used to bound every claim of a manifest that did not end in a graceful release, over the manifest's whole life. It now bounds consecutive claims that made no progress.

  • A manifest that advances on each run is no longer abandoned, however many times it is interrupted.
  • A manifest that advances a little and then crashes the process on every run is retried more often than before: once per step of progress, then up to the cap. Progress is finite (lines of a file, files of a manifest), so it is still abandoned in the end.
  • On the S3 backend only a finished input file counts as progress, because S3 keeps no line watermark inside a file. A single large file interrupted three times in a row is still abandoned there.

Bulk export has the same cap (#1041) and is not changed here.

Summary

The attempt cap counted claims and never went back down, so a manifest was abandoned after three unrelated interruptions, and a manifest that shared a process with a crashing one lost an attempt each time the process died.

The stored attempt count is now cleared whenever a run records durable progress:

  • when an input file is walked to its end (record_output_file_done), on SQLite, PostgreSQL, MongoDB and S3;
  • when a committed batch charges lines beyond the file's recorded line watermark, on SQLite, PostgreSQL and MongoDB. The clear rides the counter update the batch already makes, in the same transaction or the same document update.

A batch that only re-walks lines an earlier run already counted clears nothing. Recording a file that was already recorded clears nothing on S3.

There is no schema change, no new setting and no new storage trait method: the fix reuses the attempts field and the progress writes that already exist. The cap check in the worker is unchanged.

The HFS_BULK_SUBMIT_MAX_ATTEMPTS row in crates/rest/README.md and in the bulk-data-submit skill (both mirrors) describes the new meaning.

Tests

New:

  • test_only_the_manifest_without_progress_is_abandoned (SQLite): two manifests in two tenants are claimed and left to lapse together three times with a cap of 2. The one that finishes a file in each run is claimed at attempt 1 every time and is still processing; the other is failed with the abandoned message.
  • test_a_batch_past_the_file_watermark_clears_the_attempt_count (SQLite): a batch with new lines clears the count; a batch that re-walks counted lines, and a batch with no file URL, leave the claim charged.
  • a_finished_file_clears_the_attempt_count (S3, mock client): a finished file clears the count; recording the same file again does not.

Changed:

  • file_charge_guards_on_the_progress_that_was_read (MongoDB unit test) now also asserts that both charge updates set attempts to 0.

Not added: a PostgreSQL or MongoDB integration test for the new behaviour. The existing test_completed_output_files_survive_a_reclaim in both suites runs the changed statements.

Existing attempt-cap tests (test_a_manifest_past_its_attempt_cap_fails_without_running, test_a_manifest_past_its_attempt_cap_fails_when_its_error_artifact_cannot_be_written, test_a_released_claim_is_not_an_attempt).

Results:

  • cargo test -p helios-persistence --lib with all backend features (sqlite, postgres, mongodb, s3, elasticsearch), filtered to the modules the pending fixes touch (among them bulk_submit, error::, composite::, backends::s3): 1081 passed.
  • cargo test -p helios-persistence --test postgres_tests bulk_submit against a PostgreSQL container: 65 passed, 1 ignored. test_completed_output_files_survive_a_reclaim: 1 passed.
  • I did not run the MongoDB integration suite or clippy locally; CI runs them.

These ran on a branch that also carried other pending fixes, so the suites were verified in combination, not on this branch alone.

…ifact cannot be written

A manifest past its attempt cap, or one whose manifest could not be
fetched, was failed only after its error artifact reached the output
store. When that write failed the manifest stayed processing and was
claimed again on every lease lapse, without limit.

The error artifact is now best effort: a write failure is logged and the
manifest is published as failed with no artifact. The abandoned message
reports the configured cap instead of the claim count.

Closes #3084
… the attempt cap

The cap counted every claim that did not end in a graceful release and
never went back down. A long import was abandoned after three unrelated
interruptions, and a manifest sharing a process with a crashing one lost
an attempt on every crash, other tenants' manifests included.

The stored attempt count is now cleared when a run records progress: a
file walked to its end on every backend, and a committed batch that
moves a file's line watermark on SQLite, PostgreSQL and MongoDB. Only
consecutive runs that advance nothing reach the cap. S3 keeps no line
watermark, so there only a finished file counts.

Closes #3083
@claude

claude Bot commented Dec 1, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk-submit attempt cap abandons manifests that were making progress, including other tenants' manifests running beside a crashing one

1 participant