Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.1] Use read-write lock to protect concurrent pool accesses (#26658) #26697

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

roji
Copy link
Member

@roji roji commented Nov 15, 2021

Resubmit of #26658 which was accidentally merged before tactics approval and reverted in #26696. This is identical to #26658 and has already been approved by the team.

As this is being considered for servicing, I went with the least invasive/risky option, and introduced read/write locking. Using a ConcurrentDictionary is definitely possible, but would require other changes - specifically in how pruning is implemented. We can clean this up and improve for 7.0. I couldn't repro this in some quick testing efforts (tricky concurrency issue), if we think it's really worth it I can spend more time on it.

Fixes #26612

Description

Locking is missing when looking up a pool group in a Dictionary in SQLite's pooling implementation.

Customer impact

If code happens to look up a pool group at the same time as a modification of the pool group dictionary is happening (e.g. opening a connection with a new connection string), an exception may be thrown (or in theory, possibly undefined behavior).

How found

Reported by @sebastienros

Regression

No, SQLite connection pooling is new in 6.0.

Testing

Testing this is somewhat tricky, and would not be completely reliable as this is a concurrency condition relying on a race condition.

Risk

Low, the current (partial) locking scheme has been augmented with read-write locking, changes are very localized. Added a quirk mode.

@AndriySvyryd AndriySvyryd added this to the 6.0.1 milestone Nov 15, 2021
@AndriySvyryd AndriySvyryd changed the title Use read-write lock to protect concurrent pool accesses (#26658) [6.0.1] Use read-write lock to protect concurrent pool accesses (#26658) Nov 15, 2021
@roji roji merged commit e5fb2fe into dotnet:release/6.0 Nov 15, 2021
@roji roji deleted the SqlitePoolingConcurrencyAgain branch November 15, 2021 22:00
@ajcvickers ajcvickers removed this from the 6.0.1 milestone Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants