PhoenixKit. Modules. Storage. Workers. LocationBackfillJob
(phoenix_kit v2.41.0)
Copy Markdown
View Source
Records where the objects stored before location-truth are (V204).
Every writer records a phoenix_kit_file_locations row for each bucket it
stores an object in, and marks its instances checked. Instances stored
earlier by writers that did not (Tessera tiles, comment attachments) are
unchecked. This job walks them in @batch_size batches, in uuid order,
checks each enabled bucket for the instance's key once, records every
bucket that has it (Storage.Locations.record/2), and marks the instance
checked with how many held it (Locations.mark_checked/2) — a miss too,
so it is not work again and the Health count reaches zero.
"Unchecked", not "has no location row": a read that finds a key in a bucket records that one bucket, which must not retire the instance from this walk while its other copies are unrecorded.
Throttled. One batch per run, and the next run is scheduled
@pause_seconds later, on the file_processing queue, so a large or
remote bucket is walked at a steady pace instead of all at once.
Queued by itself (the maintainer's decision, plan §"Next: V204"):
PhoenixKit.Supervisor calls maybe_enqueue/0 shortly after boot, and
the daily trash prune does too, whenever any instance has no row. Only one
pending run exists at a time (unique over [:worker, :queue], ignoring
the cursor). Reads keep working meanwhile: the manager checks the other
buckets for a key with no rows, and records what it finds.
run_pass/1 runs a whole pass in the calling process.
Summary
Functions
Queues a pass when any instance is unchecked. Never raises.
Whether any instance is unchecked.
How many instances are unchecked (for the Health page).
Runs a whole pass in the calling process, batch after batch, and returns
how many instances were :recorded and how many were :missing (in no
enabled bucket). progress is called with the running totals.
Functions
@spec maybe_enqueue() :: :queued | :nothing_to_do | :unavailable
Queues a pass when any instance is unchecked. Never raises.
@spec pending?() :: boolean()
Whether any instance is unchecked.
@spec pending_count() :: non_neg_integer()
How many instances are unchecked (for the Health page).
@spec run_pass((map() -> any())) :: %{required(atom()) => non_neg_integer()}
Runs a whole pass in the calling process, batch after batch, and returns
how many instances were :recorded and how many were :missing (in no
enabled bucket). progress is called with the running totals.