Repository navigation
Index Seq on the NServiceBus PostgreSQL queue table - #3205
Merged
Merged
Conversation
The destructive receive orders by Seq, so a Wolverine-provisioned NServiceBus queue table needs an index on Seq or the ORDER BY degrades to a full sort once a backlog builds. An unthrottled 5-minute soak against an un-indexed table saw receiver throughput collapse (5.2M enqueued, only ~71k delivered as the table grew); with this index the same soak delivered 4.5M with zero loss. Use a non-unique index, not a unique one: NServiceBus puts a UNIQUE constraint on seq, and Weasel can only model a unique index, so a unique index makes Weasel try to DROP the constraint-backed index (which PostgreSQL refuses) when reconciling against an NServiceBus-owned table. The non-unique index sidesteps that — the NSB PostgreSQL interop suite stays green (4/4) against a real NServiceBus host. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 23, 2026
Closed
This was referenced Jul 24, 2026
This was referenced Jul 31, 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
Adds a non-unique index on
Seqto the NServiceBus PostgreSQL interop queue table (NServiceBusQueueTable). Follow-up to #3201.Why
The destructive receive orders by
Seq(... ORDER BY Seq LIMIT :count FOR UPDATE SKIP LOCKED). When Wolverine provisions/owns the queue table (e.g. its own listening queue), there was no index onSeq, so theORDER BYdegraded to a full sort as a backlog built up.A soak that let the table grow made this concrete: with an un-indexed table, an unthrottled 5-minute run enqueued ~5.2M messages but the receiver only drained ~71k as throughput collapsed. With this index the same run delivered 4.5M with zero loss (receiver keeps pace) — a ~60× difference.
Why non-unique
Earlier I had a unique index here and removed it: NServiceBus puts a UNIQUE constraint on
seq, Weasel can only model a unique index, and the two don't reconcile — Weasel tries toDROPthe constraint-backed index (which PostgreSQL refuses) when diffing against an NServiceBus-owned table, breaking startup. A non-unique index avoids that: it has a different name and uniqueness fromnsb_seq_key, so Weasel just adds it and leaves NServiceBus's constraint alone. The transport never needs to enforcesequniqueness itself.Validation
NServiceBus.Transport.PostgreSqlhost (provisioning against the NServiceBus-owned table is unaffected).dotnet build wolverine.slnx -c Releaseclean (0 warnings, 0 errors).🤖 Generated with Claude Code