Skip to content

fix(swift): carry deferred requests on the connection of the client - #5231

Open
krishvishal wants to merge 4 commits into
php-sdk-conformance-fixesfrom
swift-multiplexed-connection
Open

krishvishal wants to merge 4 commits into
php-sdk-conformance-fixesfrom
swift-multiplexed-connection

Conversation

@krishvishal

@krishvishal krishvishal commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR address?

Closes #5173

This pull request is on top of #5177, and #5177 must merge first.

Rationale

A Swift connection ran one request at a time. The server can hold a deferred poll for minutes, so the client opened one more connection for each poll that waited, up to 64. The other SDKs send a deferred poll on the connection of the client, because one of their connections carries many requests at once. The conformance suite of RFC 3 checks this in faults/lost_poll_connection.yaml, which is a known divergence of the Swift SDK in #5174.

What changed?

TCPConnection now carries up to 256 requests at once, as a link of the Rust SDK does (core/sdk/src/links/mux.rs). It keeps the callers that wait in a table by request number, so each reply finds its caller in any order. Deferred polls and fetches go over the connection of the client and overlap with its other requests. In a cluster, all requests to one primary share one data connection. The server does not change: each frame already carries its request number, and the server already runs 256 requests of one connection at once.

A request that runs out of time or is cancelled now ends alone, and the connection drops its late reply. Before, it closed the connection. On a shared connection that also ends every poll that waits. The client still notices a server that is gone, by its silence. If nothing arrived since the request was written and no other request waits, the first timeout closes the connection. If a poll waits too, the second timeout in the same silence closes it. If a request without a session ends without a reply, the connection always closes, because request numbers repeat until a session is bound.

For the polls that wait, the shared connection has three rules:

  • If a poll or fetch commits nothing and does not read from next, it goes again after a lost connection. It then has the rest of its wait, as in the Rust SDK.
  • A poll with .onRead still ends with fetch_progress_uncertain (14010), because nothing tells whether the server stored its offset.
  • disconnect() and shutdown() end every waiting poll at once. logout() ends those that commit nothing, because the server drops them without an answer.

A client of a single node now dials only the address that it was given, as the Rust SDK does. A single node can advertise an address that does not reach it, such as a bind address or a container name. After a lost connection, the client used the advertised address first, and so went past the fault proxy of the conformance suite.

One thing stays as it is. The ordinary requests of the client still go one after another, because a sign-in, a bind and a teardown must run alone on the connection. The deferred requests do not wait for them.

Tests:

  • New MultiplexingTests: 13 tests of one connection, modelled on the tests of mux.rs. They cover replies in any order, and one request that ends by a timeout or a cancellation. They also cover a silent server, an eviction, and the limit of 256 requests.
  • DeferredRequestTests has 15 new tests, on a single node and in a cluster. They cover polls that wait while the connection is lost or detached from its session. They also cover a logout, a disconnect and a shutdown.
  • Two new end-to-end tests: 20 polls wait on the connection of the client while it sends, and a logout ends a poll that waits.
  • The test of a cancelled request in flight expected a new connection and now expects the same one. The test of the pool of deferred connections left with the pool.

@krishvishal
krishvishal changed the base branch from swift-operation-fixes to php-sdk-conformance-fixes December 3, 2026 17:21
@krishvishal
krishvishal force-pushed the swift-multiplexed-connection branch from ffef54e to b1cfeb7 Compare December 3, 2026 17:24
@krishvishal
krishvishal added this pull request to stack #5234 December 3, 2026 17:25
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Dec 3, 2026
@krishvishal
krishvishal force-pushed the swift-multiplexed-connection branch from b1cfeb7 to 6ce67d3 Compare December 4, 2026 14:54
@krishvishal
krishvishal force-pushed the swift-multiplexed-connection branch from 6ce67d3 to e62a1f3 Compare December 6, 2026 00:37
@krishvishal
krishvishal force-pushed the swift-multiplexed-connection branch from e62a1f3 to ac449af Compare December 6, 2026 01:35
One connection now carries many requests at once and finds each caller by its request number, so a waiting poll needs no connection of its own.
@krishvishal
krishvishal force-pushed the swift-multiplexed-connection branch from ac449af to d7ea81e Compare December 6, 2026 07:50

This branch has not been deployed

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swift SDK: a committing deferred poll goes out on a connection of its own

4 participants