Repository navigation
Reuse one query plan per SQL Server ingestion statement - #6011
Open
warwickschroeder wants to merge 2 commits into
Open
warwickschroeder wants to merge 2 commits into
warwickschroeder wants to merge 2 commits into
Conversation
…stion plan reuse tests
rbev
approved these changes
Oct 16, 2026
rbev
approved these changes
Oct 16, 2026
…tion plan reuse tests
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 this fixes
SQL Server ingestion declared each parameter by its value, so nearly every failed message compiled a new query plan and filled the plan cache. Every parameter is now declared by its column, so each statement shape has one plan. It does not touch the deadlocks that concurrent multi-message batches can hit.
Evidence
Measured with
tools/testing-tool(Aspire, RabbitMQ transport, SQL Server persistence, batch size 25, 4 parallel writers). The bypass writer sentbackground-noisefailures at 2,000 msg/s for 11 minutes, more than either build could ingest, so the error queue grew throughout. One run per build, each on an empty database. Figures cover the same 9.3-minute window after a 1-minute warm-up.master)MERGE FailedMessagesplans at the endCACHESTORE_SQLCP)Audit was measured with a driver that calls the real
BatchInsert.Rowsdirectly: 10,000 audit messages, 32 a batch, 4 writers, three runs per build, each on an empty database and plan cache.Saga snapshots behave the same way. With 10% of states over 4,000 characters, the plans go from 285 to 3 and the plan cache from 211 MB to 4.4 MB.
Tests
ServiceControl.Persistence.Tests.SqlServer/IngestionPlanReuseTests(new): one cached plan across value lengths and nulls, and an over-length value refused.ServiceControl.Persistence.Tests/EFCore: the shared transaction helper moved to the base class, unchanged.