Repository navigation
SQLRDD: refresh the lock table on a connection of its own - #2135
Merged
RobertvanderHulst merged 1 commit intoOct 28, 2026
Merged
Conversation
Every connection starts a System.Timers.Timer that refreshes its entries in the lock table every 120 seconds. The timer runs on a thread pool thread but used the connection of the application, and an ADO.NET connection must not be used by two threads at once. With short statements this rarely collided; importing a large dataset it did reliably: a refresh during a CREATE INDEX on a 1.1 million row table made the index fail with "ExecuteNonQuery requires an open and available Connection", and a following metadata query returned nothing. The refresh now opens a connection of its own (pooled), and it is skipped when UseLocks is off, as nothing is written to the lock table then. Errors of the refresh no longer escape the timer thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The RDD refreshes its rows in the lock table on a
System.Timers.Timer. The timer event runs on a thread pool thread, but it used the connection of the application, which may be executing a statement on the main thread at the same moment. An ADO.NET connection must not be used by two threads at once: when the timer met a running statement, either side could fail at random.We saw it while importing a large customer dataset into SQL Server. Two statements of the import failed for no visible reason:
ExecuteNonQuery erfordert eine geöffnete und verfügbare Connection(requires an open and available connection) on aCREATE INDEX,Der angegebene Schlüssel war nicht im Wörterbuch angegeben(the given key was not present in the dictionary) while reading the column list.What changed
UseLocksoff, the timer does nothing: no locks are written, so there is nothing to refresh.Testing
UseLocksoff, where the timer now does nothing. WithUseLockson, a record lock, a write and the unlock on one connection work as before. Locks of other users and the refresh after the timer interval were not tested separately.🤖 Generated with Claude Code