Skip to content

Async database and mail clients on turnloop-io - #6

Merged
proggeramlug merged 9 commits into
mainfrom
lane/adapters-db
Sep 15, 2026
Merged

proggeramlug merged 9 commits into
mainfrom
lane/adapters-db

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Async clients on turnloop-io for PostgreSQL, MySQL, Redis, SMTP and MongoDB: TLS, auth, pools, pub/sub and cluster routing, SDAM/CMAP, cursors. Also WASI 0.2 ip-name-lookup DNS through an additive Backend::resolve default method (native backends keep the blocking-pool fallback), executor Blocking/Close futures, per-crate examples and CI wiring. Lane reports: LANE_REPORT.md (adapters-db, adb-fix1, adb-fix2).

Follow-ups found by running the real SQL servers outside the Codex sandbox

  • 9862322 (SCRAM-PLUS): a real PostgreSQL 16 with ssl=on offers SCRAM-SHA-256-PLUS, and every TLS login failed.
    • The client now derives tls-server-end-point from the verified leaf (RFC 5929; bounded DER reader for RSA, ECDSA and RSASSA-PSS), with a SCRAM-SHA-256 fallback (libpq prefer).
    • channel_binding_required is enforced at mechanism selection and again at AuthenticationOk.
  • 8d2865a (FATAL/PANIC): a FATAL/PANIC ErrorResponse followed by close (for example 57P01 from pg_terminate_backend) now surfaces as ErrorKind::ConnectionAborted carrying the server diagnostic, and the client is no longer reusable. Error/Outcome become Clone, not Copy.
  • Parallel no-spin flake in native_surface: it was test interference. Every owned child subscribes to process-wide SIGCHLD, so unrelated child exits in parallel tests woke the quiet loop.
    • The unchanged services_no_spin contract now runs in a fresh fixture process, and the test asserts its exact success line.
    • The two SIGUSR1 fan-out fixtures are serialized.

Verification

Merge order: #5 first, then this PR updated with main, so ci-gate is green without bypassing it.

Known unrelated flake

backend::unix::udp_tests::cancelled_udp_with_cached_events_survives_exact_fd_and_port_reuse failed once under the default parallel workspace run (bind returned -1). The test rebinds an ephemeral port after dup2 closes it, and a parallel test can take the port in between. Tracked separately.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 101 files, which is 1 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Check out review usage here.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 248f0ab8-26a0-4806-9881-718acf5a7230

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1274d and d264141.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (101)
  • .github/workflows/ci.yml
  • LANE_REPORT.md
  • crates/turnloop-contract/src/bin/native_child.rs
  • crates/turnloop-contract/tests/native_surface.rs
  • crates/turnloop-io/Cargo.toml
  • crates/turnloop-io/README.md
  • crates/turnloop-io/src/dns.rs
  • crates/turnloop-io/src/lib.rs
  • crates/turnloop-io/src/pool.rs
  • crates/turnloop-io/tests/streams.rs
  • crates/turnloop-io/tests/support/count.rs
  • crates/turnloop/src/backend/mod.rs
  • crates/turnloop/src/backend/wasi_p2.rs
  • crates/turnloop/src/driver.rs
  • crates/turnloop/src/executor.rs
  • crates/turnloop/src/lib.rs
  • docs/adapters-db-commands.md
  • docs/adb-fix1-commands.md
  • docs/adb-fix2-commands.md
  • protocols/turnloop-mongodb/Cargo.toml
  • protocols/turnloop-mongodb/README.md
  • protocols/turnloop-mongodb/examples/turnloop.rs
  • protocols/turnloop-mongodb/src/async_connection.rs
  • protocols/turnloop-mongodb/src/async_pool.rs
  • protocols/turnloop-mongodb/src/asynchronous.rs
  • protocols/turnloop-mongodb/src/client.rs
  • protocols/turnloop-mongodb/src/operation.rs
  • protocols/turnloop-mongodb/src/pool.rs
  • protocols/turnloop-mongodb/src/topology.rs
  • protocols/turnloop-mongodb/tests/async_server.rs
  • protocols/turnloop-mongodb/tests/asynchronous.rs
  • protocols/turnloop-mongodb/tests/protocol.rs
  • protocols/turnloop-mongodb/tests/spec_selection.rs
  • protocols/turnloop-mysql/Cargo.toml
  • protocols/turnloop-mysql/README.md
  • protocols/turnloop-mysql/examples/turnloop.rs
  • protocols/turnloop-mysql/src/async_pool.rs
  • protocols/turnloop-mysql/src/asynchronous.rs
  • protocols/turnloop-mysql/src/client.rs
  • protocols/turnloop-mysql/src/pool.rs
  • protocols/turnloop-mysql/tests/async_server.rs
  • protocols/turnloop-mysql/tests/asynchronous.rs
  • protocols/turnloop-postgres/Cargo.toml
  • protocols/turnloop-postgres/README.md
  • protocols/turnloop-postgres/examples/turnloop.rs
  • protocols/turnloop-postgres/src/async_pool.rs
  • protocols/turnloop-postgres/src/asynchronous.rs
  • protocols/turnloop-postgres/src/client.rs
  • protocols/turnloop-postgres/src/lib.rs
  • protocols/turnloop-postgres/src/pool.rs
  • protocols/turnloop-postgres/src/wire.rs
  • protocols/turnloop-postgres/tests/allocations.rs
  • protocols/turnloop-postgres/tests/async_server.rs
  • protocols/turnloop-postgres/tests/asynchronous.rs
  • protocols/turnloop-postgres/tests/protocol.rs
  • protocols/turnloop-postgres/tests/server.rs
  • protocols/turnloop-postgres/tests/support/mod.rs
  • protocols/turnloop-postgres/tests/support/scram.rs
  • protocols/turnloop-redis/Cargo.toml
  • protocols/turnloop-redis/README.md
  • protocols/turnloop-redis/examples/turnloop.rs
  • protocols/turnloop-redis/src/asynchronous.rs
  • protocols/turnloop-redis/src/client.rs
  • protocols/turnloop-redis/src/cluster.rs
  • protocols/turnloop-redis/tests/async_server.rs
  • protocols/turnloop-redis/tests/asynchronous.rs
  • protocols/turnloop-smtp/Cargo.toml
  • protocols/turnloop-smtp/README.md
  • protocols/turnloop-smtp/examples/turnloop.rs
  • protocols/turnloop-smtp/src/asynchronous.rs
  • protocols/turnloop-smtp/src/transport.rs
  • protocols/turnloop-smtp/tests/async_server.rs
  • protocols/turnloop-smtp/tests/asynchronous.rs
  • protocols/turnloop-tls/Cargo.toml
  • protocols/turnloop-tls/README.md
  • protocols/turnloop-tls/src/asynchronous.rs
  • protocols/turnloop-tls/src/channel_binding.rs
  • protocols/turnloop-tls/src/lib.rs
  • protocols/turnloop-tls/tests/async_allocations.rs
  • protocols/turnloop-tls/tests/certificates/README.md
  • protocols/turnloop-tls/tests/certificates/digests.txt
  • protocols/turnloop-tls/tests/certificates/ecdsa-sha256.der
  • protocols/turnloop-tls/tests/certificates/ecdsa-sha384.der
  • protocols/turnloop-tls/tests/certificates/ecdsa-sha512.der
  • protocols/turnloop-tls/tests/certificates/ed25519.der
  • protocols/turnloop-tls/tests/certificates/generate.py
  • protocols/turnloop-tls/tests/certificates/pss-sha1.der
  • protocols/turnloop-tls/tests/certificates/pss-sha256.der
  • protocols/turnloop-tls/tests/certificates/pss-sha384-mgf256.der
  • protocols/turnloop-tls/tests/certificates/pss-sha384.der
  • protocols/turnloop-tls/tests/certificates/pss-sha512.der
  • protocols/turnloop-tls/tests/certificates/rsa-md5.der
  • protocols/turnloop-tls/tests/certificates/rsa-sha1.der
  • protocols/turnloop-tls/tests/certificates/rsa-sha256.der
  • protocols/turnloop-tls/tests/certificates/rsa-sha384.der
  • protocols/turnloop-tls/tests/certificates/rsa-sha512.der
  • protocols/turnloop-tls/tests/channel_binding.rs
  • scripts/ci/run-tests.py
  • scripts/ci/test_protocol_runner.py
  • scripts/ci/wasmtime-runner.sh
  • scripts/test-servers.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Review on demand using usage pricing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Ralph Küpper added 2 commits September 15, 2026 00:52
A real PostgreSQL 16 with ssl=on offers SCRAM-SHA-256-PLUS, and the async
client selected it without tls-server-end-point data, so every TLS login
failed. turnloop-tls now exposes the peer chain and an RFC 5929 hash of the
leaf (bounded DER reader for the signature AlgorithmIdentifier: RSA, ECDSA,
RSASSA-PSS; MD5/SHA-1 map to SHA-256). The sans-IO core prefers PLUS only when
binding data is available and falls back to SCRAM-SHA-256 otherwise (libpq
channel_binding=prefer); channel_binding_required still demands PLUS and is
checked again at AuthenticationOk. Verified against a real PostgreSQL 16:
real_async_required_channel_binding_authenticates_over_ssl passes.
…in fixtures

A terminated backend (57P01 then EOF) reached the async client as a completed
query because the core replaced the diagnostic with Transport and async
completion accepted Outcome::Aborted. The core now returns
Error::ConnectionAborted with the full server error, discards unsent output,
rejects reuse and completes each pending token once before Closed; async
readers return io::ErrorKind::ConnectionAborted carrying the typed error.
Ordinary ERROR still becomes Outcome::ServerError after ReadyForQuery.
Error/Outcome are Clone instead of Copy.

The parallel no-spin failure was test interference: every owned child
subscribes to process-wide SIGCHLD, so unrelated children exiting in parallel
tests woke the quiet loop. The unchanged services_no_spin contract now runs in
a fresh native_child process (exact success line asserted), and the two
SIGUSR1 fan-out fixtures are serialized so one cannot release the other's
waiters after SIG_DFL is restored.

Verified against real PostgreSQL 16 and MySQL (native and WASI 0.2): the full
real_async_tls_queries_copy_cancel_pool_and_connection_kill now runs to the
end, including max_uses, pool.end and the cancel-future timeout.
@proggeramlug
proggeramlug marked this pull request as ready for review September 14, 2026 23:29
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Windows validation: the trial branch integrate/windows-db (#5 at 28a49c8 merged with this PR at 8d2865a, no conflicts) passed CI run 34908513489 in full: every job including ci-gate, lint-native (windows-2025) and all three test-native (windows-2025, *) modes. Once #5 is merged, this PR needs only a main update and a normal green merge.

Ralph Küpper and others added 3 commits September 15, 2026 02:35
…e failover

protocol (WASI 0.2 real servers) failed at assert_ne!(before_primary,
after_primary). The server logs show rs1 stepped down at 00:41:29 with
replSetStepDown 5, no election handoff, and rs1 itself winning the next
election at 00:41:39 once its 5 s ineligibility had expired, so the same node
legitimately became primary again. real_mongodb.rs already uses 60 s; the
async test now does too, so a different primary is guaranteed and the
assertion is unchanged.
@proggeramlug
proggeramlug merged commit 7827f02 into main Sep 15, 2026
39 checks passed
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.

1 participant