The scenario: deletion succeeds but completion is uncertain
A background worker deletes a private object and then tells the coordinating service that the job is complete. The second operation fails before the worker receives a reliable acknowledgement. The bytes may already be gone, while the service still considers the job unfinished. Treating every error as proof that nothing happened would misdescribe this state.
The reviewed Movo-X cleanup worker explicitly separates deletion from completion acknowledgement. One isolated test exercises failed deletion, successful deletion with a lost acknowledgement, and a subsequent retry. It passed against an in-memory store and mocked coordination calls. No actual patient file, live object store or production cleanup job was accessed.
Start with a bounded leased batch
The inspected collector asks its coordinating RPC for leased objects and rejects a response that is not an array or exceeds ten entries. It processes those entries in pairs, awaiting each pair before proceeding. That keeps the worker’s immediate deletion fan-out bounded instead of launching one request for every outstanding object.
This is an implementation bound, not a measured throughput claim. The source does not establish that ten is the correct batch size for every workload. The service side still owns eligibility, lease expiry and who may request cleanup. Reviewing the worker alone cannot prove that the database selects only records whose retention and workflow requirements permit deletion.
Delete first, then acknowledge the specific lease
For each selected job, the worker checks the expected identifier, path and lease identifier representation. It awaits the store deletion before requesting completion for that job and lease. The returned completion result must explicitly indicate success before the collector increments its completed count.
The ordering matters because acknowledging first could retire a job even though its private bytes remain. The isolated test replaces deletion with a function that throws and verifies that the acknowledgement callback is never called. That gives direct evidence for this ordering in the exercised collector path; it does not validate the coordinator’s lease ownership checks or actual provider permissions.
Treat an absent object as a retryable completion state
The reviewed memory store deletes a key without requiring it to exist. The S3-compatible adapter likewise accepts a successful DELETE response or a missing-object response, while refusing other unsuccessful responses. This makes the intended worker retry compatible with an object that was already removed by the previous attempt.
The recovery test first deletes its synthetic object while the acknowledgement throws, then retries the same supplied job. The second pass can reach completion even though the object is already absent. This is useful evidence about application ordering and in-memory retry semantics. It does not establish the behaviour of a configured bucket with versioning, retention locks or another provider-specific lifecycle policy.
Do not turn uncertainty into a false success counter
A deletion failure or an unsuccessful completion acknowledgement contributes to the worker’s failed count. Only deletion followed by an accepted completion contributes to completed. In the isolated lost-acknowledgement case, the bytes are absent but the first pass still reports no completed job. That is consistent with the collector’s defined end-to-end unit of work.
An operator should interpret the counters using that definition. Failed does not necessarily mean the private bytes still exist; completed is not a statement about every historical object version. A useful runbook names the stage being measured and explains how a leased job returns for retry rather than asking a summary counter to reconstruct all intermediate events.
Separate worker retry from authoritative lease enforcement
The worker includes the lease identifier when it requests completion. That preserves the context needed by the coordinating service to reject an outdated worker. It does not by itself prove that the server enforces that context, renews leases correctly or handles two workers racing on the same job.
A separate integration acceptance should exercise lease expiry, competing workers and stale completion against an authorized synthetic environment. Inspect the resulting job state as well as the worker’s return value. No such database operation was run for this chapter. Keeping this boundary visible prevents a passing in-memory retry test from becoming an unsupported claim of distributed exactly-once execution.
Keep routine cleanup diagnostics free of private paths
The inspected entry point emits an event name with aggregate completed and failed counts. Its failure path uses a generic message instead of printing object paths, credentials, payloads or provider diagnostics. That reduces the private material ordinary cleanup logs are designed to carry.
There is a tradeoff: an aggregate alone may not explain an operational backlog. An approved diagnostic workflow can correlate opaque job identifiers and stage outcomes without exposing medical files. The public case does not publish real keys or internal job values. Logging design and retention need their own review; a source-level logging choice is not a complete audit of every monitoring destination.
A practical cleanup acceptance package
Deliver the deletion eligibility rule, lease contract, bounded concurrency setting, delete-before-complete sequence and recovery matrix. Include the failed-delete and lost-acknowledgement fixtures, then separately list provider deletion semantics, coordinator authority and retention requirements that still need integration evidence.
For a CTO, the useful result is a cleanup process whose uncertainty is explicit. A successful object deletion and a recorded completion are separate facts, and retry can reconcile them without pretending they were one transaction. This case demonstrates that narrow engineering property from pinned source and a synthetic test; it does not claim that production storage has been purged or that all retained copies are gone.
Illustrative control flow
Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.
jobs = coordinator.lease_bounded_batch()
for pair in bounded_pairs(jobs):
for job in pair_concurrently:
try:
await store.delete_if_present(job.path)
await coordinator.complete(job.id, job.lease_id)
count_completed()
except:
count_failed_without_claiming_bytes_remain()About this engineering series
Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.
Explore the Movo-X engineering series → · Related implementation experience →
Discuss a similar engineering problem
Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.
Discuss your project on WhatsApp ↗