Loading
feat(handlers): record subject_digest and plumb through store
What
Records the OCI subject digest on push and threads subject_digest through the datastore, so
the manifest triggers (added in !2930 (merged), now in master) can link a referrer's subject_id
regardless of the order in which the referrer and its subject are pushed (#2376, the handling
half of the split-out from !2929 (closed)). Until this lands, subject_digest is never written, so those
triggers are inert; this MR is what activates them.
- Write path (
registry/handlers/manifests.go): setsubject_digestfrom the manifest'ssubjecton every push. It only ends up stored with a nullsubject_idwhenREGISTRY_FF_TOLERATE_MISSING_SUBJECTis enabled (tolerance landed in !2927 (merged); the flag is still off by default in production). - Plumbing:
subject_digestthroughmodels.Manifest, the manifest INSERTs, the row scanners, and the manifest SELECT column lists. Read paths (referrers listing, GCIsDangling) are unchanged; they keep usingsubject_id, now kept correct by the triggers. - Tests: datastore integration tests covering both push orderings.
TestManifestStore_SubjectIDBackfilledOnSubjectCreate: a referrer created before its subject (nullsubject_id, recordedsubject_digest) is linked by theAFTER INSERTtrigger when the subject is created.TestManifestStore_SubjectIDResolvedWhenSubjectExists: a referrer created after its subject, with a nullsubject_id, is linked by theBEFORE INSERTtrigger at insert time (the deterministic ordering theAFTER INSERTbackfill alone does not cover).- Both also assert online GC
IsDangling: a linked subject is protected from collection, while an untagged, otherwise-unreferenced referrer is collectable.
Notes
- Last of the split-out MRs. The column (!2928 (merged)), the triggers and index (!2930 (merged)), and the
tolerance flag (!2927 (merged)) are all merged; this targets
masterdirectly. - After this merges, the remaining work in #2376 is operational, not code: flip
REGISTRY_FF_TOLERATE_MISSING_SUBJECTon (a separate rollout), then eventually remove it. - Known residual: a truly simultaneous referrer-and-subject push, where both transactions are
still uncommitted when each runs its trigger, can leave a referrer with a null
subject_id. It is acceptable while the flag is off and needs read-time resolution or a reconciliation sweep before the flag is enabled. Tracked in #2376.
Part of #2376.
Edited by Stan Hu