dlq

package
v0.3.0-20261114050809-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

DLQ Reconciliation Controllers

This package reconciles dead-lettered SubmitQueue work. The orchestrator stage table defines the primary/DLQ bindings; the host constructs them through the shared pipeline framework.

Design principles

Terminal reconciliation, not workflow recovery. Idempotent primary controllers own normal processing under their primary retry policy. By default, a DLQ handler must not resume a partially completed normal workflow or repeat its business action. Repairing state, membership, and status/log outputs needed to express a justified terminal outcome is reconciliation.

The implementation is deliberately the simplest and most reliable thing that can work. The default is to decode the affected identity, load its state, and reconcile unfinished work to RequestStateError or BatchStateFailed, preserving existing terminal winners and valid downstream ownership. An optimistic-locking CAS prevents lost concurrent writes; it does not prove that the failed stage still owns the outcome.

Do not bind a normal orchestration controller to a DLQ, create a missing request in Started, or publish validate/build/merge work to resume the dead-lettered request. Idempotency, a missing row, or possession of the full original payload does not authorize that recovery. Likewise, final retries must not trigger or poll a failed build, rerun a merge, invoke a fixer, or automatically retry a dropped hook side effect.

Final retry policy

Dead letters have exhausted the primary retry budget or returned a non-retryable error. Final consumers use errs.AlwaysRetryableProcessor, unlimited attempts (Retry.MaxAttempts = 0), and DLQ.Enabled = false. Every non-nil error returned by a DLQ controller, including a version mismatch or publish failure, is redelivered until reconciliation succeeds or an operator intervenes. Unlimited retries protect reconciliation and permitted outputs, not another business retry budget.

Disposition remains handler-specific: the generic request/batch reconcilers acknowledge missing entities; buildsignal also acknowledges a missing build or empty batch ID. Decode errors returned by these handlers remain retryable and may need operator removal. Payload/tenant mismatches are acknowledged, while invalid envelope tenant metadata is rejected before controller error processing. The shared hook handler reports and acknowledges even undecodable events. Final retry policy therefore does not promise retention of every poison message or recreation of every missing entity.

Terminal outputs and ownership

  • An already-Error request skips the state CAS but republishes its terminal status log. A different terminal request outcome is left unchanged. This repairs status delivery, not the original diagnostic content or timestamp.
  • An already-Failed batch repairs terminal membership and repeats Error fan-out to its member requests. Succeeded and Cancelled batches are left unchanged by the generic batch reconciler; it does not rerun Conclude.
  • The generic request reconciler leaves a request owned by a live batch to that batch's completion path. A Creating batch counts as owner only when the request is Batched; an association alone can outlive an unsuccessful claim.
  • Without such an owner, a Cancelling request is reconciled to Error: dead-lettering cannot confirm that cancellation completed.

Request logs are published to log; the gateway alone materializes them into its request log and public projections. A publish failure returns an error so redelivery can retry terminal status delivery. Replaying an existing event into gateway-owned read models is projection repair, not restarting SubmitQueue orchestration, and is not an orchestrator pipeline stage.

Bindings and named limits

The stage table is the source of truth rather than a second topology table here:

  • start, cancel, validate, and batch use generic request reconciliation. Their decoders read LandRequest, CancelRequest, or the topic's request-ID payload.
  • dependency-analysis, build, submitqueue-land, and conclude use generic batch reconciliation.
  • buildsignal carries a build-ID payload, not a full Build. Its handler loads the build to find the batch and leaves build status untouched. The two Runway signal handlers read a request or batch correlation ID from MergeResult.
  • Speculation queue-isolation nudge: after failing attributed culprit work (or the labelled payload fallback), a delivery that transitioned a batch may nudge speculate with another live batch. The primary re-derives current queue state; the failed batch is not reopened. This narrow protection for other work does not authorize replay of the dead-lettered command or guarantee a nudge after every partial reconciliation failure.
  • Hook report-and-stop: the shared hook DLQ logs the raw event, counts it as dropped, and acknowledges it. A person decides whether to republish; the DLQ does not invoke hooks.

Runway resolves its own inbound dead letters by publishing a terminal FAILED result, not retrying merge execution. Stovepipe's record, build analysis, issue tracking, and fix handlers have their own bounded fact/history, abandonment, and cursor-fencing obligations. Those domain-specific rules are not permission to resume SubmitQueue work.

Agents must not choose recovery exceptions on their own; implement a new exception only when explicitly requested by the user or approved by the owning maintainer. State which durable terminal fact or abandonment authorizes each output and inspect its downstream effects: publishing to a normal stage can restart business work even if the DLQ handler itself calls no provider.

See also

Documentation

Overview

Package dlq contains controllers that consume messages from per-topic dead-letter queues and reconcile the affected request and batch entities into a terminal failed state.

Background. The consumer framework moves a message to its DLQ after the controller for the original topic returns a non-retryable error or exhausts retries on a retryable error. Without DLQ reconciliation the affected request would remain stuck in a non-terminal state (e.g. Validated, Batched, Processing) forever — the gateway would still report it as "in progress" even though no pipeline stage is going to advance it.

Reconciliation strategy. Each DLQ topic carries the same payload as its originating topic (the queue framework preserves the bytes verbatim under a new `{topic}_dlq` name). The DLQ controllers decode that payload to recover the affected request or batch, then transition it to a terminal failed state — Error for requests, Failed for batches — with an idempotent optimistic-locking write so concurrent activity (a late land, a cancel race) wins cleanly. Batch failures also fan out to the member requests so the gateway no longer reports them as in-progress.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCancelRequestID

func DecodeCancelRequestID(payload []byte) (entity.RequestID, error)

DecodeCancelRequestID extracts the request ID from a CancelRequest payload (the shape used by the cancel topic).

func DecodeLandRequestID

func DecodeLandRequestID(payload []byte) (entity.RequestID, error)

DecodeLandRequestID extracts the request ID from a LandRequest payload (the shape used by the start topic).

func NewDLQBatchController

func NewDLQBatchController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQBatchController builds a DLQ controller for a batch-scoped topic. topicKey must be the DLQ topic key (typically TopicKey(primary)).

func NewDLQBuildSignalController

func NewDLQBuildSignalController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQBuildSignalController builds a DLQ controller for the buildsignal topic.

func NewDLQLandConflictSignalController

func NewDLQLandConflictSignalController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQLandConflictSignalController builds a DLQ controller for the landconflictsignal topic.

func NewDLQLandSignalController

func NewDLQLandSignalController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQLandSignalController builds a DLQ controller for the landsignal topic.

func NewDLQLogController

func NewDLQLogController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQLogController builds a DLQ controller for the log topic.

func NewDLQRequestController

func NewDLQRequestController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	decode RequestIDDecoder,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQRequestController builds a DLQ controller for a request-scoped topic. topicKey must be the DLQ topic key (typically TopicKey(primary)); decode must match the payload shape of the primary topic this DLQ drains.

func NewDLQSpeculateController

func NewDLQSpeculateController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores orchstorage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) consumer.Controller

NewDLQSpeculateController builds the DLQ controller for the speculate topic. topicKey must be the DLQ topic key (typically TopicKey(primary)).

func TopicKey

func TopicKey(main consumer.TopicKey) consumer.TopicKey

TopicKey returns the DLQ topic key for the given primary pipeline topic. The returned key is meant to be used both when registering the DLQ topic with the topic registry and when the corresponding DLQ controller advertises its TopicKey(). It is exported so the orchestrator wiring layer can build matching pairs without duplicating the suffix literal.

Types

type RequestIDDecoder

type RequestIDDecoder func(payload []byte) (entity.RequestID, error)

RequestIDDecoder extracts the affected request's identity — its ID and its queue — from the raw payload bytes of a DLQ message. Different primary topics carry different payload shapes (LandRequest on start, CancelRequest on cancel, RequestID on validate / batch), so the caller injects the right decoder for the topic being reconciled. Returning an empty ID is treated as a decode failure.

func DecodeRequestID

func DecodeRequestID(primary consumer.TopicKey) RequestIDDecoder

DecodeRequestID extracts the request ID from a validate or batch payload. primary is the originating topic (TopicKeyValidate or TopicKeyBatch), not the DLQ key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL