Skip to content

Claim burst products before upload so concurrent runs can't mix files - #227

Open
chris-thomas-ga wants to merge 5 commits into
GeoscienceAustralia:mainfrom
chris-thomas-ga:fix/s3-upload-claim
Open

chris-thomas-ga wants to merge 5 commits into
GeoscienceAustralia:mainfrom
chris-thomas-ga:fix/s3-upload-claim

Conversation

@chris-thomas-ga

Copy link
Copy Markdown
Contributor

Builds on #226, so please merge that first (this branch includes its commit).

Description

Two runs writing the same burst at the same time can interleave their uploads and leave a folder with the STAC and .h5 from one run and the tifs from the other. This can happen with a duplicate SQS delivery, or with static layers for two scenes that share a burst. Nothing verifies the checksum file, so it would go unnoticed.

Before uploading, each run now writes a small claim object under {project}/monitoring/upload_claims/ using IfNoneMatch="*". If another run holds the claim, the burst is skipped the same way an existing product is. Claims older than --upload-claim-stale-after-mins (default 120) can be taken over with IfMatch, so a run that crashed doesn't block the burst forever. The claim is released once the upload finishes.

Jobs will need PutObject, HeadObject and DeleteObject on the claims prefix.

Testing

Tests in tests/sar_pipeline/test_s3_upload_claim.py use botocore's Stubber. They check what we send to S3 and how we handle each response, but not that S3 really enforces the conditions when two writers race. Worth a quick check against a dev bucket before merging.

Type of change

  • Bug fix

chris-thomas-ga and others added 5 commits November 24, 2026 07:36
Burst products were uploaded in os.walk order and "exists" meant "any .h5
in the prefix", so a job killed mid-upload could leave a partial product
that every later run skipped. Upload the .h5 and then the stac-item.json
last, and make the existence checks (before processing and before upload)
look for the stac-item.json, so a partial upload is re-made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Concurrent runs for the same burst product (e.g. a duplicate delivery of the
same scene, or static layers from two scenes sharing a burst) could pass the
pre-upload existence check together and interleave their file-by-file
uploads, leaving a product mixed from two runs. Before uploading, write a
claim object under {s3_project_folder}/monitoring/upload_claims/ with
If-None-Match, skip the upload if another run holds it, take over claims
older than --upload-claim-stale-after-mins (default 120) with If-Match, and
re-check the commit marker once the claim is held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant