Repository navigation
feat(delivery): one stored body per content, rows point at it instead of carrying a copy CU-86akkb8f5 - #2886
Merged
Merged
Conversation
… of carrying a copy CU-86akkb8f5 machine_delivery_payload holds the payload without the row's delivery block under tenant:type:hash, written on first use with its expiry only moving forward; a row carries payloadId and the sweep stamps the row's delivery block at publish time. Rows written before this read their inline payloadJson until they expire; a re-run no longer stores a payload copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018qx6NqA97kwRxQ4hnD5jtu
Contributor
🦩 Flamingo Code ReviewNot reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened. When it is ready:
Or comment Updated 2026-10-29 17:29 UTC · workflow run |
kirill-567
previously approved these changes
Oct 29, 2026
…ave, and a body outlives its rows by ten minutes CU-86akkb8f5 Kirill's review: no hand-written update on the collection, so tenant stamping, events and locks keep working. DeliveryPayloadStore reads the body and saves it only when new or held shorter than the row needs; the recorder holds it BODY_OUTLIVES_ROW_SECONDS longer than the row, past Mongo's once-a-minute TTL reaping and the moment between two pods saving the same new body. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018qx6NqA97kwRxQ4hnD5jtu
oleksandrd-flamingo
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The body of a delivery is stored once per distinct content in a new collection,
machine_delivery_payload; a row inmachine_deliverypoints at it instead of carrying its own copy. Every type, nothing to switch on.Why: a rollout to a fleet (flags, an update) wrote the same payload into every row, and a script batch for a fleet will do the same with script bodies inside (Kirill's "payload by reference", Slack 2026-09-22 and 2026-10-30). Storage is one body per content now, and the content of a waiting delivery has one place to live.
How it works
DeliveryPayloadJson.body(payload)= the payload JSON without the row'sdeliveryblock, plus its SHA-256. Rows of one content share one hash.DeliveryPayloadStore.hold(type, body, expiresAt)keeps the body undertenant:type:hash: read, and saved only when it is new or held shorter than this row needs, through the plain repositorysave(Kirill's review: no hand-written update, so tenant stamping, events and locks on the collection keep working). The expiry only moves forward. The TTL index is onexpiresAt, like the rows.DeliveryRecorderholds the body ten minutes longer than the row it writes (BODY_OUTLIVES_ROW_SECONDS): Mongo reaps expired documents once a minute per collection, and the margin also covers two pods saving the same new body a moment apart. The row carriespayloadId;payloadJsonis no longer written.DeliverySweepServicepublishes from the body: the JSON comes from the store, thedeliveryblock (type, targetId, dispatchId, sequence) is stamped from the row at publish time. A re-run therefore needs no payload copy any more (RerunPublication.payloadJsonremoved).payloadJsonwhen a row has nopayloadId, andupsertPendingdrops the inline body when a newer dispatch replaces such a row. They are gone with their TTL (30 days at most). No migration.machine_delivery_rolloutkeeps its one copy per rollout, as before; the rows it produces all point at the same body.Cost
Per recorded row: one primary read of the body and, only for a new body or a longer hold, one save, instead of a payload copy per row. One primary read of the body per publish from the sweep; the publish right after the hand-off still uses the payload in hand.
Next
Script batches drop the per-machine
machineIdfield from the message (the agent never reads it), so one fire = one body for the whole fleet (follows in the scripts PR). Replacing the content of a waiting delivery when a script is edited is a re-dispatch of the same key from the domain; the recorder already lets the newer dispatch take the row.Tests
DeliveryPayloadJsonTest(+ body/hash),DeliveryRecorderTest(+ body held, row points at it),DeliverySweepServiceTest(+ body read and stamped, body gone),DeliveryPayloadStoreTest(new),CustomMachineDeliveryRepositoryImplTest(rerun without a copy, inline body dropped on replace).🤖 Generated with Claude Code
https://claude.ai/code/session_018qx6NqA97kwRxQ4hnD5jtu