Repository navigation
docs: fan-out fixes an event's handlers; how to change them safely (with design proposal) - #101
Merged
Merged
Conversation
…ge them safely
Deliveries are created once, from the handler map of whichever processor
fans the event out. Document what that means for rolling deploys that add
or remove a handler, for {} handler maps, and for several services on one
store, with a Postgres back-fill for the deploy overlap.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #101 +/- ##
=======================================
Coverage 96.13% 96.13%
=======================================
Files 34 34
Lines 2355 2355
Branches 478 478
=======================================
Hits 2264 2264
Misses 74 74
Partials 17 17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 was wrong (TXOB-CONS-001, verified High)
Fan-out creates deliveries once per event, using only the handler map of the processor that leased the event, and then sets
fanned_out_at. Nothing ever fans an event out again. So:crmdelivered 2. There was no error, no dead row and no metric. Which events are hit depends on which pod wins the NOTIFY race.pendingforever.Type: {}/ several services on one store: a processor marks those events fanned out with zero deliveries, so a second service's handlers never see them.The README said "one delivery per registered handler" and "at-least-once delivery per handler" and never mentioned this.
What changed (docs only, as asked; no behavior change)
Recreatefor processors (publishers can still roll) or back-fill. A Postgres back-fill statement is included; I ran it against Postgres 17 (it inserts only the missing deliveries,pendingand due now).pendingdeliveries after the rollout.{}: give each service its own tables via the prefix options, or run one processor deployment.{}sentence in Quick Start now says what{}does to a shared store.No changeset: README only.
Design proposal: making the handler set safe to change
The goal: an event reaches every handler that is registered "eventually everywhere", with no manual back-fill, and without slowing down the common path.
Option A: reconcile within a bounded window (recommended long-term)
Record the handler set an event was fanned out with: a
fanout_handlers text[]/ array attribute, or a hash of the sorted handler names. When a processor starts, or its handler map changes, it re-fans recent events that are missing one of its handlers. "Recent" is bounded by areconcileWindowMsoption (default e.g. 1 h, which covers any rollout), and the re-fan uses the existing idempotentcompleteFanout(ON CONFLICT DO NOTHINGand equivalents).Option B: an explicit back-fill API (recommended first step)
processor.backfill({ handlers: ["UserCreated.crm"], since: Date }), or a store-levelbackfillDeliveries, which creates the missing deliveries for already fanned-out events, computingpriority/key/deferthrough the real handler config.created_at/fanned_out_atalready exist). It gives the documented manual SQL a supported, cross-store form, and it computes priority and keys correctly, which hand-written SQL can't. It is also the primitive Option A would call.Option C: per-service consumer names
Key deliveries and fan-out state by a
consumername (e.g.fanned_out_atper consumer) so several services can share one outbox, each fanning out for its own handlers.Option D: fail loudly instead
Record the handler-set hash per event (as in A), and have processors warn or emit telemetry when they see events fanned out with a different set.
Recommendation
The owner needs to decide whether to take on the schema change for A, and whether shared stores should ever be supported (C) or stay explicitly unsupported, as these docs now say.
How it was tested
prettier --check README.md: clean.migrate, with one event that already had the delivery and one that didn't. Result: 1 row inserted, both deliveriespending/due.Not in this PR
No implementation of A–D. The brief allowed an optional off-by-default draft, but I left it out so you can pick the design first.