The page fires during a user avatar upload because deletion_eligible_oldest_age has crossed the team's limit. A marketplace seller used a signed object storage write, replaced the avatar, and abandoned another large media transfer; the on-call sees three keys and one uncomfortable question: which bytes can be deleted without breaking a live page or a recovery promise?
Short answer: let browsers send large files to object storage with narrowly scoped signed URLs, keep retention decisions in the Node.js SaaS database, and delete only from durable evidence that an object is no longer referenced and its recovery deadline has passed. Proxy uploads through the application only when the application must inspect or transform every byte before accepting it. The transfer path changes capacity. It does not settle ownership.
That distinction is the runbook. A direct upload keeps large media off the application's request path, but a completed transfer can outlive the tab that started it. A proxy gives the server one request to authorize and receive, yet couples Node.js request duration and application capacity to file size. Neither design makes deletion safe by itself.
Incident response starts by establishing deletion authority
At 02:13, the worst dashboard is a count of "old objects." Age is not intent. An old avatar may still be the current avatar; a recent video may already be abandoned; a replaced image may be inside a promised recovery window. The first action is to trace an object key back to an authenticated marketplace owner, a live database reference, and a recorded deletion deadline. If any link is absent, stop automated deletion for that object class and investigate the evidence producer. Then follow one candidate all the way through the system: find the deletion record, confirm its tenant, identify the domain row that last referenced the key, compare the current state with the state captured when cleanup was scheduled, and inspect the deadline that represents the recovery promise. If the seller restored the listing after the job was queued, the live reference wins. If the avatar was replaced twice, only the keys with no current attachment continue. If an abandoned direct upload never gained a domain reference, its separate cleanup deadline governs. This trace is slower than pressing a delete button, but it turns the incident from storage archaeology into a set of falsifiable checks, and those checks tell the team which missing field or transition to instrument next.
I've been paged by missed jobs and duplicate deliveries. The durable lesson is blunt: queue age tells you that work is late, not whether replaying the work is safe. A deletion worker must assume that its message can arrive twice and that the database may have changed since the message was scheduled. It reloads current state before acting.
No shortcuts.
The object store cannot infer the marketplace contract from a key and a timestamp. It does not know that a seller restored a listing, that a new avatar became current, or that a moderation process still holds a file. Object lifecycle management can expire objects and transition storage classes, so it is useful for data whose prefix and age encode a valid policy. It remains a backstop to an application decision, not a substitute for one.
Age is ambiguous.
Work backward from what the on-call needs. A useful deletion record contains an opaque object key, tenant ownership, the domain resource that referenced it, the time deletion became eligible, the recovery deadline, and the final outcome. The record is not a copy of the storage inventory. It is evidence for a business transition.
Telemetry for the gap between ownership records and an aging backlog
The earlier signal is a growing gap between deletion eligibility and confirmed deletion. Measure both the age of the oldest eligible record and the number of eligible records that remain unfinished. Age alone pages during low-volume maintenance or one deliberately retained object. Count alone pages after a normal burst even when workers are catching up. Together, and observed across more than one evaluation window, they tell the operator whether a queue is merely busy or no longer advancing.
Instrument transitions, not just requests. Emit a counter when a file becomes eligible, when a worker claims the record, when current references block deletion, when the object is removed, and when completion is durably recorded. A histogram from eligibility to confirmation exposes slow progress before the oldest-item alert fires. Structured logs should carry an intent or deletion ID, tenant ID, media class, prior state, next state, and a bounded reason code. Don't log a signed URL because it is a temporary capability.
The dashboard then answers a short sequence of operational questions: Is new work becoming eligible? Are workers claiming it? Are reference checks blocking a particular media class? Are completions keeping pace? The page should link to that sequence, not to a storage console with millions of unrelated keys.
The threshold is local policy. I'm not sure there is a defensible universal number, because the right delay depends on the stated recovery window, worker schedule, expected upload volume, and the time an operator needs to intervene. Resolve it with a replay of production-shaped records and a written error budget for deletion delay. A concrete invariant is stronger than a fashionable duration: alert before delayed deletion can violate the user-facing retention promise, while leaving enough time for normal scheduling jitter.
How should a beginner Node.js SaaS choose signed object storage or a server proxy?
Choose by where byte-level trust must be established. For routine marketplace avatars and large listing media, the least complex capacity model is a control plane in Node.js and a data plane in object storage. The application authenticates the seller, allocates an opaque key, records the expected ownership and media policy, and issues a short-lived signed write. The browser uploads to that exact destination, then asks the application to finalize. Before attaching the object to an avatar or listing, the application checks the storage attributes promised by its own record.
Do not treat the browser's success callback as proof of durable application state. The tab can close after bytes arrive but before finalization, or retry finalization after a response is lost. Finalization therefore needs an idempotent result: repeating the same valid request returns the already established attachment rather than creating another one. An issued signed URL is authority to attempt one storage operation within its scope; it is not permission to attach an arbitrary key to a different tenant.
A server proxy is still the cleaner choice when every accepted file must be decoded, scanned, or transformed synchronously before storage, or when the product only accepts small files and the team values a single request boundary over independent data-plane scaling. The catch is operational: slow clients, large request bodies, ingress limits, and application autoscaling become part of the upload system. It is not suitable for the stated marketplace job when large media should avoid the app server.
Signed direct upload has its own cost. It introduces an interval in which storage and application state may disagree, so the design needs reconciliation and explicit cleanup. Your mileage may vary across runtimes and storage implementations; test the largest permitted file, an interrupted transfer, an expired signature, a repeated finalization, and a deletion racing with restore. A 40 KB avatar on localhost proves almost nothing about the large-media path.
Delivery is a separate decision. If a download response is meant to display an avatar inline or save an attachment with a filename, Content-Disposition defines those response semantics. It should not be overloaded into the retention model. How a browser presents bytes and when the system may destroy them are different contracts.
Security boundary: verify current references before deletion
The deletion worker should consume a stable record ID, not "delete this key" as an unconditional command. On every attempt it reloads the record, confirms that the deadline is in the past, and asks the domain database whether any live attachment still points at the key. If the object became current again, the correct result is a recorded skip, not a delete followed by repair.
This Go sketch shows the guard around a generic storage interface. The Node.js service can own the records and scheduling; the worker contract stays independent of a vendor SDK.
package retention
import (
"context"
"errors"
"time"
)
var ErrNotEligible = errors.New("object is not eligible for deletion")
type Candidate struct {
ID string
ObjectKey string
DeleteAt time.Time
DeletedAt *time.Time
}
type Records interface {
Load(ctx context.Context, id string) (Candidate, error)
HasLiveReference(ctx context.Context, key string) (bool, error)
MarkDeleted(ctx context.Context, id string, at time.Time) error
}
type Objects interface {
Delete(ctx context.Context, key string) error
}
func DeleteEligible(ctx context.Context, db Records, store Objects, id string, now time.Time) error {
candidate, err := db.Load(ctx, id)
if err != nil {
return err
}
if candidate.DeletedAt != nil {
return nil // A replay observes the completed outcome.
}
if now.Before(candidate.DeleteAt) {
return ErrNotEligible
}
referenced, err := db.HasLiveReference(ctx, candidate.ObjectKey)
if err != nil {
return err
}
if referenced {
return ErrNotEligible
}
if err := store.Delete(ctx, candidate.ObjectKey); err != nil {
return err
}
return db.MarkDeleted(ctx, candidate.ID, now)
}
The interface makes the critical review question visible: what happens if the process stops after object deletion but before MarkDeleted? The next delivery must be able to repeat the storage deletion and then record completion. That requires idempotent delete semantics in the chosen adapter and a test that exercises this exact boundary. The code also leaves room for the database implementation to serialize a restore against a deletion claim; the precise transaction mechanism belongs to that database, not to the queue message.
Keep retention classes explicit rather than applying one age rule to everything:
| Object class | Evidence before deletion | Why age alone fails |
|---|---|---|
| Unfinalized upload | No live attachment and its cleanup deadline passed | A slow or interrupted finalization may still reconcile |
| Replaced avatar | A newer avatar is current and the recovery deadline passed | The previous image can be part of a restore promise |
| Deleted listing media | The listing remains deleted and any hold is clear | Domain state can change after the job was scheduled |
Bucket lifecycle rules can enforce expiration for a deliberately isolated class of abandoned data. Align the key layout, lifecycle timing, and application cleanup deadline so two independent mechanisms do not encode conflicting promises. If the business offers a recovery period, a shorter storage expiry makes that promise false; if nothing ever expires, abandoned direct uploads accumulate without a bound.
Alert economics includes the cost of false positives
Ship the instrumentation before tightening the page. During deployment, compare eligible, claimed, blocked, deleted, and recorded totals, then inspect the oldest records from each state. Exercise a duplicate queue delivery, a restore just before eligibility, an upload that never finalizes, and a worker restart between storage deletion and database completion. The acceptance criterion is not that every job runs once. It is that every valid object reaches one explainable terminal outcome despite retries.
False positives have a real cost. An alert set below routine queue jitter trains the on-call to ignore age; an alert based only on count fires during healthy bursts; a page for reference-blocked candidates may punish the worker for correctly protecting live media. Use a lower-urgency ticket for accumulating cleanup that remains inside the retention promise, and reserve a page for sustained lack of progress that threatens that promise.
The decision rule is compact: direct signed upload for large marketplace media, application-owned evidence for attachment and retention, and guarded idempotent deletion after the deadline. Stick with a proxy when synchronous byte inspection is the actual requirement. Whichever path carries the upload, make the deletion claim provable before allowing automation to act.
Top comments (0)