Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ To change a decision, add a new entry that supersedes it rather than editing his
| [D72](#d72-handler-registration-belongs-to-the-consumer) | Handler registration belongs to the consumer | Accepted |
| [D73](#d73-postgresql-retryable-outbox-sends-retain-durable-eligibility) | PostgreSQL retryable outbox sends retain durable eligibility | Accepted |
| [D74](#d74-portable-consumer-failure-declarations) | Portable consumer failure declarations | Accepted |
| [D75](#d75-failure-diagnostics-are-bounded) | Failure diagnostics are bounded | Accepted |

---

Expand Down Expand Up @@ -1763,3 +1764,15 @@ budget. Repair such configuration through the existing dead-letter redrive workf
Delay options are bindable arrays. `FailureOptions` retains its convenience constructor and provides a real public parameterless constructor for `OptionsFactory<T>`. Its properties use public setters as a narrow exception to the init-only options convention: the .NET configuration binding source generator skips init-only properties when binding an existing instance through `AddOptions<FailureOptions>().Bind(section)`. This preserves standard Options-pattern binding and Native AOT support; policies are captured and composed at startup, and reload does not rebuild consumers. `CopyTimeout` uses null for its 30-second default so configuration binding preserves missing settings without accepting an explicit zero timeout. Null `RetryDelays` selects D69's default sequence at composition; empty disables it. This avoids the configuration binder appending configured entries to a pre-populated default array. In-memory native redelivery retains failure headers per queued message or per log-group receiver, preventing attempt/history resets without sharing mutable consumer state across groups.

In-memory consumers use only native redelivery for retries, including manual settlement requests. Scheduled-copy and outbox redelivery fallbacks are rejected when the requested delay exceeds `MaxRedeliveryDelay`: sending another message to the source would fan out to unrelated log groups and could wait for admission credit still owned by the current delivery. Native redelivery retains both the group and that credit. Dead-letter copies to a separate configured endpoint remain supported.

## D75. Failure diagnostics are bounded

**Status:** Accepted; supersedes D10's every-attempt diagnostic retention guarantee.

**Context.** Unbounded exception history can exceed native message/header limits and prevent durable poison settlement. The history is Relayer-owned metadata (D10); native clients cannot bound its application JSON for us. Existing native settlement, copy and Pub/Sub attribute splitting remain in use.

**Decision.** Retain at most eight attempts, preserving first and latest, with 2,048-character stacks and 1,024-character diagnostic fields/native dead-letter error descriptions. Limit generated JSON to 16 KiB using its actual UTF-8 byte length including escaping. Remove intermediate attempts before shortening text. Mark incomplete history with `Truncated`; preserve total attempt counts and first/last timestamps. Incoming malformed or larger-than-16-KiB history is replaced with truncated history before deserialization.

Copies budget against the destination's declared `MaxMessageBytes`, subtracting portable body, headers and ordering key. Native settlements budget body and failure headers against the source declaration, because the lazy header SPI cannot enumerate original properties. If even the first/latest summary cannot fit, omit only the history header and retain counters. Native overhead, hidden properties, native callbacks and attribute counts remain broker-enforced; application data is never removed to make room. Native send failure still prevents settlement.

**Consequences.** Full exception diagnostics belong in application logs/traces. All new work runs on failure/manual settlement paths; the successful receive and send paths are unchanged. See the site's [failure handling contract](../website/docs/guides/failure-handling.md).
6 changes: 3 additions & 3 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ Copies preserve the original identity and creation context. Native redelivery di
`FailureHeaders` that the adapter **must persist before releasing the original**. Native dead-letter dispositions
carry the same history in `DeadLetterInfo.Headers`. Their owned metadata survives pooled-context disposal.
Adapters must not advertise native redelivery if they cannot preserve that metadata. History records the
original ID (null for a missing ID), total failed attempts, first/last failure times, and each attempt's consumer,
host, exception type, message and stack. Error metadata uses generated JSON, including under Native AOT.
original ID (null for a missing ID), total failed attempts, first/last failure times, and retained attempts' consumer,
host, exception type, message and stack. D75 bounds diagnostics while retaining total counts. Error metadata uses generated JSON, including under Native AOT.
Malformed failure counters are permanent envelope errors; corrupt history is replaced so poison messages can
still reach the dead-letter destination. History construction and exception type diagnostics run only on failure.

Expand All @@ -443,7 +443,7 @@ dead-letter requests. See [Failure handling](https://relayer.tomlonghurst.dev/do
for the call site, precedence and buffered-send contract.


- **Error metadata** goes on the dead-lettered message: the original message ID, exception type, message and stack trace for **every** attempt (Rebus #1154), attempt count, first and last failure time, consumer name, and host. SQS visibility retries preserve immutable native attributes: their final copy retains previously stored history and the current delivery’s in-process failures; earlier visibility-delivery exceptions are unavailable from SQS (D67).
- **Error metadata** goes on the dead-lettered message: the original message ID, exception type, message and stack trace for retained attempts (D75) (Rebus #1154), attempt count, first and last failure time, consumer name, and host. SQS visibility retries preserve immutable native attributes: their final copy retains previously stored history and the current delivery’s in-process failures; earlier visibility-delivery exceptions are unavailable from SQS (D67).
- **Redrive API:** `IDeadLetterManager` provides `List`, `Peek`, `Redrive(filter)`, and `Purge`, backed by native broker mechanisms. Queue redrive settles an original after an acknowledged send; Kafka redrive commits a dedicated group offset after that send and leaves the original subject to native retention. Kafka purge deletes scanned partition prefixes with native `DeleteRecords`, never arbitrary records. See the [site roadmap](../website/docs/roadmap.md) for implemented transports and optional endpoint/CLI status.
- **Circuit breaker:** when the failure rate of a consumer crosses a threshold, Relayer **pauses the consumer natively** (Kafka `Pause`, ASB processor stop, RabbitMQ consumer cancel) instead of burning messages into the DLQ (SlimMessageBus #454). It then half-opens with a probe message.
- **Retries never duplicate side effects.** Outbox rows written by a failed attempt are rolled back with the transaction. Without a transaction, sends made during a failed attempt are buffered and discarded (Rebus #1198, Rebus.PostgreSql #53).
Expand Down
4 changes: 2 additions & 2 deletions src/Relayer.GooglePubSub/GooglePubSubBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ internal static OutgoingMessage Copy(Google.Cloud.PubSub.V1.PubsubMessage messag
{
var count = 0;
foreach (var header in message.Attributes)
if (!header.Key.StartsWith("goog", StringComparison.Ordinal)) count++;
if (!header.Key.StartsWith("goog", StringComparison.Ordinal) && !GooglePubSubFailureHeaders.IsHistory(header.Key)) count++;
var headers = new KeyValuePair<string, WireString>[count];
var index = 0;
foreach (var header in message.Attributes)
if (!header.Key.StartsWith("goog", StringComparison.Ordinal))
if (!header.Key.StartsWith("goog", StringComparison.Ordinal) && !GooglePubSubFailureHeaders.IsHistory(header.Key))
headers[index++] = new(header.Key, new(header.Value));
return new("copy", message.Data.Memory, headers, message.OrderingKey.Length == 0 ? null : new WireString(message.OrderingKey));
}
Expand Down
3 changes: 3 additions & 0 deletions src/Relayer.GooglePubSub/GooglePubSubFailureHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ internal static class GooglePubSubFailureHeaders
private const int MaxAttributes = 100;
private const int MaxValueBytes = 1024;

internal static bool IsHistory(string name) => name == FailureHeaders.History || name == Parts ||
name.StartsWith(Prefix, StringComparison.Ordinal);

internal static void Write(PubsubMessage message, string history)
{
List<string>? previous = null;
Expand Down
Loading
Loading