Sitelet https://github.com/npgsql/npgsql/pull/6457
Skip to content

Remove multiplexing - #6457

Merged
roji merged 1 commit into
npgsql:mainfrom
roji:KillMultiplexing
Feb 28, 2026
Merged

roji merged 1 commit into
npgsql:mainfrom
roji:KillMultiplexing

Conversation

@roji

@roji roji commented Feb 19, 2026

Copy link
Copy Markdown
Member

Merge only after #6314.

Closes #6449

@roji
roji requested review from Brar, NinoFloris and vonzshik February 19, 2026 10:45
@roji
roji marked this pull request as ready for review February 19, 2026 17:30
Copilot AI review requested due to automatic review settings February 19, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the multiplexing feature from Npgsql and simplifies the implementation and test suite accordingly (per #6449, intended to merge after #6314).

Changes:

  • Removes multiplexing implementation, configuration surface area, and related infrastructure (data source, connector I/O loops, binding scopes, counters, logging).
  • Updates tests to run without MultiplexingTestBase/MultiplexingMode and deletes multiplexing-only test cases/workarounds.
  • Updates public API tracking to reflect the removal of NpgsqlConnectionStringBuilder.Multiplexing and WriteCoalescingBufferThresholdBytes.

Reviewed changes

Copilot reviewed 67 out of 67 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Npgsql.Tests/Types/TextTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/RecordTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/RangeTests.cs Removes multiplexing workarounds; switches to TestBase.
test/Npgsql.Tests/Types/NumericTypeTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/NumericTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/NetworkTypeTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/MultirangeTests.cs Removes multiplexing deadlock workaround (Task.Yield).
test/Npgsql.Tests/Types/MiscTypeTests.cs Removes multiplexing skip/branching in tests; switches to TestBase.
test/Npgsql.Tests/Types/LegacyDateTimeTests.cs Removes multiplexing-specific comment/import; remains non-parallelizable.
test/Npgsql.Tests/Types/LTreeTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/JsonTests.cs Removes multiplexing fixtures and constructor parameter; keeps json/jsonb fixtures.
test/Npgsql.Tests/Types/JsonPathTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/JsonDynamicTests.cs Removes multiplexing fixtures and constructor parameter; keeps json/jsonb fixtures.
test/Npgsql.Tests/Types/InternalTypeTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/HstoreTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/GeometricTypeTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/FullTextSearchTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/EnumTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/DomainTests.cs Removes multiplexing ignore and switches to TestBase.
test/Npgsql.Tests/Types/DateTimeTests.cs Removes multiplexing-specific comment.
test/Npgsql.Tests/Types/CubeTests.cs Switches to TestBase and removes multiplexing ctor.
test/Npgsql.Tests/Types/CompositeTests.cs Removes multiplexing-specific transaction workaround; updates comments.
test/Npgsql.Tests/Types/ByteaTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/BitStringTests.cs Switches from multiplexing fixtures/base class to TestBase.
test/Npgsql.Tests/Types/ArrayTests.cs Removes multiplexing ignores and switches to TestBase.
test/Npgsql.Tests/TransactionTests.cs Removes multiplexing branches/ignores; switches to TestBase.
test/Npgsql.Tests/TracingTests.cs Removes multiplexing fixture dimension; simplifies activity assertions to single mode.
test/Npgsql.Tests/TestUtil.cs Removes Multiplexing=False from default test connection string.
test/Npgsql.Tests/Support/TestBase.cs Removes multiplexing mentions and multiplexing-specific tx usage in type assertion helpers.
test/Npgsql.Tests/Support/MultiplexingTestBase.cs Deleted multiplexing test base and MultiplexingMode enum.
test/Npgsql.Tests/Support/AssemblySetUp.cs Removes Multiplexing=false from admin connection settings.
test/Npgsql.Tests/SecurityTests.cs Removes multiplexing parameter dimension and related branching.
test/Npgsql.Tests/ReaderTests.cs Removes multiplexing fixtures/branches/workarounds; simplifies ctor.
test/Npgsql.Tests/ReaderOldSchemaTests.cs Removes commented multiplexing-specific guard.
test/Npgsql.Tests/ReaderNewSchemaTests.cs Removes commented multiplexing ignore.
test/Npgsql.Tests/PrepareTests.cs Removes multiplexing-not-supported test now that feature is removed.
test/Npgsql.Tests/PoolTests.cs Removes multiplexing-only ignored test.
test/Npgsql.Tests/LoggingTests.cs Removes multiplexing branching in logging assertions; switches to TestBase.
test/Npgsql.Tests/DataSourceTests.cs Removes multiplexing dimension; removes multiplexing-specific regression test.
test/Npgsql.Tests/CopyTests.cs Removes multiplexing ignores and updates comments; switches to TestBase.
test/Npgsql.Tests/ConnectionTests.cs Removes multiplexing branches/ignores; switches to TestBase.
test/Npgsql.Tests/CommandTests.cs Removes multiplexing branches/ignores; switches to TestBase.
test/Npgsql.Tests/CommandParameterTests.cs Removes multiplexing branch for prepared parameter test; switches to TestBase.
test/Npgsql.Tests/BugTests.cs Removes multiplexing-only regression test.
test/Npgsql.Tests/BatchTests.cs Removes multiplexing fixture dimension; switches to TestBase.
test/Npgsql.Tests/AuthenticationTests.cs Removes multiplexing-specific connection retry comment; switches to TestBase.
test/Npgsql.PluginTests/NodaTimeTests.cs Switches from multiplexing test base to TestBase; removes multiplexing ctor.
src/Npgsql/Util/ManualResetValueTaskSource.cs Deleted helper type used by multiplexing paths.
src/Npgsql/Replication/ReplicationConnection.cs Removes multiplexing references and disables it implicitly by removal.
src/Npgsql/PublicAPI.Unshipped.txt Marks multiplexing-related connection string builder properties as removed.
src/Npgsql/PoolingDataSource.cs Removes multiplexing-specific asserts/comments around idle connectors and return path.
src/Npgsql/NpgsqlTransaction.cs Removes transaction binding-scope unbinding (multiplexing-related).
src/Npgsql/NpgsqlSlimDataSourceBuilder.cs Removes construction and validation logic for multiplexing data source.
src/Npgsql/NpgsqlSchema.cs Removes temporary binding scope; uses bound connector directly for DataTypes schema.
src/Npgsql/NpgsqlRawCopyStream.cs Removes binding-scope teardown (multiplexing-related).
src/Npgsql/NpgsqlMultiHostDataSource.cs Removes multiplexing assertion in multi-host setup.
src/Npgsql/NpgsqlEventSource.cs Removes multiplexing-specific counters and tracking.
src/Npgsql/NpgsqlEventId.cs Leaves multiplexing-related event IDs but annotates them as removed feature.
src/Npgsql/NpgsqlDataReader.cs Removes multiplexing-specific cleanup/unbinding behavior; simplifies send-task comment.
src/Npgsql/NpgsqlConnectionStringBuilder.cs Removes Multiplexing and WriteCoalescingBufferThresholdBytes settings and validation.
src/Npgsql/NpgsqlConnection.cs Removes connector binding scope infrastructure and multiplexing open/close paths.
src/Npgsql/NpgsqlCommand.cs Removes multiplexing execution branch and related channel/value-task plumbing; simplifies query parsing.
src/Npgsql/NpgsqlBinaryImporter.cs Removes binding-scope teardown (multiplexing-related).
src/Npgsql/NpgsqlBinaryExporter.cs Removes binding-scope teardown (multiplexing-related).
src/Npgsql/MultiplexingDataSource.cs Deleted multiplexing data source implementation.
src/Npgsql/LogMessages.cs Removes multiplexing-specific log messages and event usage.
src/Npgsql/Internal/NpgsqlConnector.cs Removes multiplexing I/O loops, command-in-flight tracking, and multiplexing-only restrictions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Npgsql/NpgsqlSchema.cs

@NinoFloris NinoFloris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all looks good to me. Always possible the PR left some traces behind, but that's not really important to one shot either.

Copilot AI review requested due to automatic review settings February 28, 2026 07:11
@roji
roji enabled auto-merge (squash) February 28, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 67 out of 67 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 520 to 525
[Test]
[IssueLink("https://github.com/npgsql/npgsql/issues/3248")]
// More at #3254
public async Task Bug3248_Dispose_transaction_Rollback()
{
if (!IsMultiplexing)
return;

using var conn = await OpenConnectionAsync();
await using (var tx = await conn.BeginTransactionAsync())
{
Assert.That(conn.Connector, Is.Not.Null);
Assert.That(async () => await conn.ExecuteScalarAsync("SELECT * FROM \"unknown_table\"", tx: tx),
Throws.Exception.TypeOf<PostgresException>());
Assert.That(conn.Connector, Is.Not.Null);
}

Assert.That(conn.Connector, Is.Null);
}

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug3248_Dispose_transaction_Rollback is now an empty async test method, so it will always pass without exercising anything. Either remove this test entirely (if the scenario was multiplexing-only) or reintroduce a non-multiplexing assertion that reproduces #3248 so the regression remains covered.

Copilot uses AI. Check for mistakes.
Comment on lines 527 to 532
[Test]
[IssueLink("https://github.com/npgsql/npgsql/issues/3248")]
// More at #3254
public async Task Bug3248_Dispose_connection_Rollback()
{
if (!IsMultiplexing)
return;

var conn = await OpenConnectionAsync();
var tx = conn.BeginTransaction();
Assert.That(conn.Connector, Is.Not.Null);
Assert.That(async () => await conn.ExecuteScalarAsync("SELECT * FROM \"unknown_table\"", tx: tx),
Throws.Exception.TypeOf<PostgresException>());
Assert.That(conn.Connector, Is.Not.Null);

await conn.DisposeAsync();
Assert.That(conn.Connector, Is.Null);
}

Copilot AI Feb 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug3248_Dispose_connection_Rollback is now an empty async test method, so it will always pass and no longer protects against regressions. Please delete it or rewrite it to validate the intended rollback/dispose behavior in the non-multiplexing code path.

Copilot uses AI. Check for mistakes.
@roji
roji merged commit 2fea281 into npgsql:main Feb 28, 2026
16 checks passed
@roji
roji deleted the KillMultiplexing branch February 28, 2026 07:17
roji added a commit that referenced this pull request Apr 4, 2026
Move API changes from commits after v10.0.0 back to Unshipped,
as they represent 11.0 work, not 10.0:

- Remove multiplexing (#6457): 4 *REMOVED* entries
- Remove large object API (#6493): 37 *REMOVED* entries
- Add back parameterless ReloadTypesAsync (#6522): undo the
  v10.0 addition of CancellationToken overload and re-add
  the parameterless overload

Also adjusts Shipped to correctly reflect the v10.0.0 public API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roji added a commit that referenced this pull request Apr 4, 2026
Move API changes from commits after v10.0.0 back to Unshipped,
as they represent 11.0 work, not 10.0:

- Remove multiplexing (#6457): 4 *REMOVED* entries
- Remove large object API (#6493): 37 *REMOVED* entries
- Add back parameterless ReloadTypesAsync (#6522): undo the
  v10.0 addition of CancellationToken overload and re-add
  the parameterless overload

Also adjusts Shipped to correctly reflect the v10.0.0 public API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@zotanmew

Copy link
Copy Markdown

Since this has been merged, I don't think there's a point in opening an issue about this, but I just wanted to mention that I ran into a regular-ish (every 2-14 days) presumed race condition with multiplexing enabled where all database operations time out and a collected dotnet trace shows the multiplexer spinwait. So maybe there's more than just performance considerations for removing this after all ;)

image

Fixed by adding a PGBouncer in transaction mode and disabling multiplexing. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove multiplexing

4 participants