Repository navigation
Add DbDataSource Multiplexing support, add MySql DbDataSource support - #286
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change has unresolved API-baseline, target-framework/documentation, and dependency-lock issues that can break release tracking or restore verification.
3 open issues
What changed in this PR
This PR adds DbDataSource support to connection multiplexing. Lock pools are now generic and can be keyed by a DbDataSource instance (by reference) as well as by connection string. It also adds DbDataSource constructors for MySQL, and the Postgres DbDataSource path now multiplexes instead of throwing. This addresses issue #238.
Changes:
- Make
MultiplexedConnectionLockPoolandOptimisticConnectionMultiplexingDbDistributedLockgeneric over the connection source, so they work with a connection string or aDbDataSource. - Pool Postgres and MySQL
DbDataSourceconnections by reference, using a separate pool instance per source type. - Add MySQL
DbDataSourceconstructors for the lock and the synchronization provider, and add anet8.0target with public API baselines. - Update the Postgres and MySQL docs and tests to cover the new behavior.
| File | Description |
|---|---|
| src/DistributedLock.Tests/Tests/Postgres/PostgresDistributedLockTest.cs | Replaces the old "not supported" test with tests for shared multiplexing, reference keying, and handle-lost behavior. |
| src/DistributedLock.Tests/Tests/MySql/MySqlDistributedSynchronizationProviderTest.cs | Adds a null-argument check for the new DbDataSource provider constructor. |
| src/DistributedLock.Tests/Tests/MySql/MySqlDistributedLockTest.cs | Adds tests for the MySQL DbDataSource lock: shared connection, reference keying, and basic behavior. |
| src/DistributedLock.SqlServer/SqlMultiplexedConnectionLockPool.cs | Updates the pool to the generic type with a string key. |
| src/DistributedLock.SqlServer/SqlDistributedLock.cs | Uses the generic multiplexing lock with a string key. |
| src/DistributedLock.Postgres/PostgresMultiplexedConnectionLockPool.cs | Adds a separate reference-keyed pool for DbDataSource connections. |
| src/DistributedLock.Postgres/PostgresDistributedSynchronizationProvider.cs | Removes the "not compatible with multiplexing" note from the DbDataSource constructor docs. |
| src/DistributedLock.Postgres/PostgresDistributedReaderWriterLock.cs | Removes the "not compatible with multiplexing" note from the DbDataSource constructor docs. |
| src/DistributedLock.Postgres/PostgresDistributedLock.cs | Enables multiplexing for DbDataSource and removes the forced opt-out. |
| src/DistributedLock.Oracle/OracleMultiplexedConnectionLockPool.cs | Updates the pool to the generic type with a string key. |
| src/DistributedLock.Oracle/OracleDistributedLock.cs | Uses the generic multiplexing lock with a string key. |
| src/DistributedLock.MySql/PublicAPI/net8.0/PublicAPI.Unshipped.txt | Added as an empty placeholder for unreleased public API entries. |
| src/DistributedLock.MySql/PublicAPI/net8.0/PublicAPI.Shipped.txt | Lists the two new DbDataSource constructors (should be in Unshipped; see review comment). |
| src/DistributedLock.MySql/MySqlMultiplexedConnectionLockPool.cs | Adds a reference-keyed pool for MySQL DbDataSource connections. |
| src/DistributedLock.MySql/MySqlDistributedSynchronizationProvider.cs | Adds a DbDataSource constructor for the MySQL provider. |
| src/DistributedLock.MySql/MySqlDistributedLock.cs | Adds a DbDataSource constructor and a lock-creation path that supports multiplexing. |
| src/DistributedLock.MySql/MySqlDatabaseConnection.cs | Adds a connection constructor that creates the connection from a DbDataSource. |
| src/DistributedLock.MySql/DistributedLock.MySql.csproj | Adds a net8.0 target and its public API files. |
| src/DistributedLock.Core/Internal/Data/OptimisticConnectionMultiplexingDbDistributedLock.cs | Makes the multiplexing lock generic over the connection source. |
| src/DistributedLock.Core/Internal/Data/MultiplexedConnectionLockPool.cs | Makes the pool generic and adds an optional equality comparer for keys. |
| docs/DistributedLock.Postgres.md | Notes that connections are multiplexed per DbDataSource instance. |
| docs/DistributedLock.MySql.md | Documents the new DbDataSource option (marked as .NET 7+; see review comment). |
Review effort: Lite
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.



We'd find this useful for some scenarios in MartenDb as we can end up with a lot of monitored locks.
I ended up making the pooling logic generic and using separate pools as it seemed more elegant than just making an
objectpuddle.Also added DbDataSource to the MySQL constructor, no other vendors have DbDataSource support yet sadly.
Closes #238