clear_metadata_write_offs
Clear the metadata write-offs that split path keys left on Windows.
While a datasource root was spelled two ways (\\IMG-SERVER-01\Scans\… and
\\Img-Server-01\Scans\…), a calculation step asked the datasource for a scan's
metadata under one spelling and got its row back under the other. Finding no
row, it wrote the scan off as missing_data:metadata, a reason that is never
retried. canonicalise_windows_path_keys re-keyed those rows but did not clear
them, so the scans stay "unreadable" for good.
A scan its model made a prediction for was read for inference, so it cannot lack metadata: its write-off can only be one of these. This migration deletes each such row. A write-off for a scan with no prediction from the table's model is kept: that scan may really be unreadable.
It also deletes the scan's rows in the other tables computed from the same
model. The split wrote those under the datasource's spelling, without the
prediction: fluid and lesion as zero volumes with no error. Where that spelling
also had a prediction, canonicalise_windows_path_keys trusted the zero row and
kept it over the write-off, as a measurement that says "no fluid". The write-off
in another table is the only trace of the split left.
The scan's wave-ledger rows are set back to pending, so the scheduler sees
uncarried work at its next poll and a sweep recomputes the scan. A deleted row
would not do that: the lineage would wait for new files or the nightly rerun. A
v1 ledger has no status, so its rows are deleted.
Registered after canonicalise_windows_path_keys, so it compares folded keys.
Off Windows keys were never folded, so there is nothing to clear.
Module
Functions
apply
def apply(cache: CacheProtocol) ‑> int:Clear the metadata write-offs of scans their model read, and un-bank them.
The rows are found with a read, then changed in one write transaction, so a scan is never un-banked without its rows going too, nor the reverse. A row is deleted only while it still holds what it was read with: one another writer recomputed meanwhile is kept.
Arguments
cache: The cache backend.
Returns
The number of rows deleted or un-banked. Always 0 off Windows.