Short answer: publish a browser download link only after the exact object key is committed and independently visible through the same read path the browser will use. An export worker saying "done" is not that proof. For large per-tenant property backups, the reliable unit of delivery is a small manifest that binds tenant, snapshot, object key, size, and generation; the link is derived from that committed record, never reconstructed from a prefix.

This is a state-transition problem disguised as a storage 404. Treating it as an eventual-consistency problem too early sends the investigation toward retries while a key mismatch, premature job transition, or stale link can sit untouched.

I've been paged by missed jobs and duplicate deliveries. The useful reflex from those incidents is plain: establish the invariant before tuning the retry loop. Here, the invariant is that PUBLISHED implies one immutable object exists at the manifest's exact key and is eligible for download.

No guesswork.

The publication workflow assigns ownership of the 404

Use three externally meaningful states: WRITING, COMMITTED, and PUBLISHED. WRITING covers data extraction and every part of a multipart upload. COMMITTED means the storage write has completed and the application has verified metadata for the final key. PUBLISHED means a manifest has been durably recorded and a download link may be issued from it. A failed attempt may move to a terminal failure state, but it must never advance by inference from elapsed time.

The ordering matters more than the labels. Amazon S3's multipart upload flow separates part uploads from the complete operation; the object is assembled when the multipart upload is completed. That is a good model for any large artifact: parts are implementation details, while only the completed object can satisfy the publication contract. Don't expose a link to a temporary key, an upload identifier, or a prefix that merely looks finished.

For a property-management system, make the final key deterministic per export attempt but immutable once committed. One reasonable shape is tenants/{tenantID}/snapshots/{snapshotID}/{attemptID}/backup.tar.zst. The database stores that full string. The browser handler reads it. A cleanup worker reads it. None of them independently joins tenantID, a date, and a filename, because two perfectly reasonable formatting functions can disagree over a slash, time zone, escaping rule, or renamed prefix.

There is an important distinction between deterministic and reusable. Retrying an interrupted build can reuse an idempotency key at the job layer, yet a fresh upload attempt should have a distinct object key unless the system can prove that overwriting is safe. Keeping attempts separate prevents a late worker from replacing the artifact referenced by a newer manifest.

The manifest chooses the winner.

The timeline gives the on-call engineer a useful first split. Before commit, the worker owns progress. Between commit and publication, the manifest writer owns progress. After publication, the read path owns delivery. This framing avoids a broad "storage is slow" alert that sends three teams into the same incident without a falsifiable question.

How should an export job publish a browser download link without a 404?

The browser route should perform this sequence:

  1. Authorize the caller for the tenant and snapshot.
  2. Read the published manifest by snapshot identifier.
  3. Ask storage for metadata at the manifest's exact object key.
  4. Compare expected size and, when the backend exposes one with suitable semantics, object generation or version.
  5. Mint a short-lived download URL or stream the object through an authorized gateway.

If step 3 reports absence, return a domain result that preserves the difference between "snapshot is still building," "snapshot is not published," and "published invariant was violated." The public response may still be a 404 where disclosure would leak tenant data, but the internal metric and log event must retain the actual state. Otherwise the on-call engineer sees one bucket of browser failures and cannot tell whether to inspect scheduling, metadata, or object naming.

The failure race is usually above the storage layer

The dangerous race happens when the export job updates its database row before the storage client has finished committing the artifact. A notification consumer observes done, renders a download link, and wins the race to storage. Sleeping for a second reduces the symptom on one day and makes the contract probabilistic forever.

The preventative code path is a transaction boundary around publication, not around the multi-gigabyte upload. Holding a database transaction open while bytes cross the network would increase contention and make recovery harder. Upload first, verify the final object, then write the manifest and publication state together in a short transaction.

package snapshots import ( "context" "errors" "fmt" ) type ObjectMeta struct { Key string Size int64 Generation string } type ObjectStore interface { Put(ctx context.Context, key string, body Artifact) (ObjectMeta, error) Head(ctx context.Context, key string) (ObjectMeta, error) } type Artifact interface { Read([]byte) (int, error) } type Manifest struct { TenantID string SnapshotID string AttemptID string Object ObjectMeta } type Repository interface { Publish(ctx context.Context, manifest Manifest) error } func BuildAndPublish( ctx context.Context, store ObjectStore, repo Repository, manifest Manifest, body Artifact, ) error { written, err := store.Put(ctx, manifest.Object.Key, body) if err != nil { return fmt.Errorf("write snapshot object: %w", err) } visible, err := store.Head(ctx, written.Key) if err != nil { return fmt.Errorf("verify committed snapshot object: %w", err) } if visible.Key != written.Key || visible.Size != written.Size { return errors.New("committed object metadata did not match upload result") } manifest.Object = visible if err := repo.Publish(ctx, manifest); err != nil { return fmt.Errorf("publish snapshot manifest: %w", err) } return nil } 

This interface deliberately keeps URL signing out of the worker. A signed URL is a presentation artifact with an expiry; the manifest is the durable delivery record. Generate the URL on demand from the manifest so a queue delay or an email retry doesn't consume most of its useful lifetime. It's also easier to revoke access when authorization remains in the request path.

Idempotency belongs on both sides of that boundary. The scheduler should deduplicate the logical snapshot request, and Publish should reject a conflicting manifest for an already published snapshot while accepting an exact replay. Those are different protections. One controls duplicate work; the other prevents duplicate delivery from changing what a previously issued link means.

Evaluate the 404 as evidence, not a diagnosis

A browser 404 narrows very little by itself. Capture the snapshot identifier and a correlation identifier in the client-visible response, then join those to structured events from the job, manifest repository, and download handler. Never put a signed URL or credential-bearing query string in logs.

The first comparison should be exact values, not screenshots of dashboards:

Check Evidence to compare Likely boundary
Job state commit time versus publish time premature state transition
Object identity manifest key versus storage metadata key wrong prefix, escaping, or stale reconstruction
Attempt identity manifest attempt versus worker attempt late or duplicate worker
Artifact metadata expected size and generation versus observed values incomplete or replaced artifact
Read path direct metadata check versus browser-facing path signer, gateway, cache, or authorization layer

Start at the manifest and work outward. If no published manifest exists, object-store consistency isn't the current question. If the manifest exists but contains a different prefix than the worker recorded, retrying HEAD cannot repair it. If metadata succeeds at the exact key while the browser-facing request fails, investigate URL expiry, request signing, gateway routing, cache behavior, and tenant authorization. Only when the same exact read operation changes from absent to present without an intervening write does a visibility delay become a credible explanation.

I'm not sure how much a cache or gateway contributes in an unfamiliar deployment until its request logs and cache policy are available. Your mileage may vary there. The test that resolves the uncertainty is controlled: record the committed key and timestamp, probe the direct metadata path, then probe the browser path with the same object identity while preserving correlation IDs.

Avoid logging only the key prefix. Prefixes are useful for inventory, but they erase the evidence needed to find case differences, doubled separators, percent encoding, or an attempt identifier from the wrong worker. Log a one-way digest of the full key when object names are sensitive, alongside safe structured fields such as tenant ID, snapshot ID, attempt ID, job state, expected bytes, and observed bytes.

Large-file throughput benchmarks drive the recovery plan

A backup for one tenant may contain lease documents, inspection media, accounting exports, and database records. Large-file throughput makes "just retry the export" an expensive operational answer even when no pricing claim is involved: it repeats database reads, compression, network transfer, and multipart work. Preserve a completed but unpublished artifact long enough for the publication step to retry idempotently. Do not automatically rebuild bytes merely because writing the manifest failed. Bound concurrency by measured bottlenecks. More parallel parts can raise transfer throughput, but they also consume memory, sockets, request capacity, and checksum work. The right part size and worker count depend on artifact distribution, network path, storage limits, and recovery objectives. Benchmark with representative tenant snapshots, including the large tail, rather than a single synthetic file. I wouldn't set a universal part count from the information available; load tests showing throughput, memory, and retry amplification are what would settle it.

Backpressure must reach the scheduler.

When upload capacity is saturated, leave new jobs queued rather than allowing every worker to open another large stream. Record queue age separately from upload duration and publication latency. That split answers three different questions: whether scheduling is starved, whether bytes move slowly, and whether committed objects wait too long for exposure.

Cancellation deserves equal care. Abandon incomplete multipart work according to a lifecycle policy, retain committed artifacts according to the backup retention policy, and delete an object only after proving that no live manifest references its exact identity. A prefix-wide cleanup during an active retry is an invitation to manufacture a 404.

Retention rules and mutable-object counterexamples

The manifest pattern is not suitable when the product contract is a live, mutable object at a stable URL. In that case, readers may intentionally observe replacement, and generation-aware conditional reads or an indirection layer are more honest than pretending each download is a snapshot. Stick with direct streaming when exports are small, must not persist after the request, and can be regenerated within the request's latency budget.

It also won't remove every 404. Authorization systems may deliberately hide existence, expired links must fail, and retention can delete a snapshot on schedule. The goal is narrower: a successful publication transition should never point at an object identity that was guessed, was still being assembled, or belonged to another attempt.

For a multi-region design, the same invariant needs a declared scope. If publication occurs in one region while downloads immediately begin in another, verify through the intended regional read path or delay that region's publication marker until its read contract is satisfied. Don't label an unexplained delay "eventual consistency" and move on; name the component, measure the interval, and encode the state transition that contains it.

The runbook decision is compact. No manifest means inspect orchestration. A manifest with the wrong identity means repair the producer contract. Correct metadata with a failing browser path means inspect delivery and authorization. A reproducible visibility interval at the exact key means measure that storage or cache boundary and design publication around its documented behavior.

References