Skip to content

Consolidate transport, XFTP, SMP and PostgreSQL fixes - #2102

Open
adayhans8-debug wants to merge 160 commits into
simplex-chat:masterfrom
adayhans8-debug:consolidated/windows-transport
Open

adayhans8-debug wants to merge 160 commits into
simplex-chat:masterfrom
adayhans8-debug:consolidated/windows-transport

Conversation

@adayhans8-debug

Copy link
Copy Markdown

SimpleXMQ consolidation review and validation

I reviewed the open SimpleXMQ PRs and consolidated the non-overlapping bug fixes into consolidated/windows-transport, currently at cbfb1f4b35.

The related SimpleX Chat compatibility change is 816bb2d4a0b6f97c2b13e6b49a4bb61724ab1b8a.

Integration decisions

  • Integrated: transport shutdown, cancellation, slow-server handling, queue lifecycle, relay, notification, XFTP and PostgreSQL fixes. Where PRs overlapped, I kept the newest complete implementation rather than stacking superseded models.
  • Already covered / superseded: changes whose behavior is already present in the current implementation were not duplicated.
  • Excluded: obsolete or incompatible changes, independent protocol features, WebPush chains, clustering/RFC work, benchmarks, OpenBSD and research/diagnostic branches.
  • Reverted the old Docker entrypoint change from Docker entrypoint functions #762 because it regressed existing behavior.
  • Added CLIENT_SUPPORT _ handling in SimpleX Chat's no-connection event dispatcher. The new agent event otherwise breaks SimpleX Chat 7.1.4 with -Werror=incomplete-patterns; it is currently ignored because this client has no corresponding UI event.

Additional integration fixes

The consolidation exposed several issues that are now fixed:

  • Started sendDelayed in runClientThreads; AUTH responses were otherwise left in delayedQ indefinitely (117afec831).
  • Completed PostgreSQL migration, statistics and service-association integration.
  • Fixed XFTP replaced-upload cancellation, self-cancel deadlocks, commit races and expiration cleanup.
  • Restored fair SMP message delivery to prevent sustained command traffic from starving message delivery.
  • Preserved connection and ratchet state across invitation/contact retries while deleting only the failed new sender queue.
  • Fixed notification push-worker head-of-line blocking and service NMSG handling.
  • Corrected test fixtures for temporary uploads, encoded frame sizes, token responses and deterministic expiration timing.

Verification

  • Default test suite: 1,449 examples, 0 failures, 7 pending.
  • PostgreSQL/slow-server tests: serial regression completed without failures; XFTP Web Client, XRCP, Web, timing and PostgreSQL schema-dump groups also pass.
  • All 45 XFTP chunk-delivery tests pass.
  • The 200-subscription batching test and all invitation/contact retry tests pass.
  • Consolidated XFTP server and client completed a real 2 MiB upload/download round trip with identical received bytes.
  • Windows native libsimplex.dll built with +client_library; Windows CLI completed private SMP messaging and 1 MiB XFTP transfers through both the consolidated local server and the private endpoint.
  • Ubuntu SimpleX Chat 7.1.4 CLI builds against the consolidated SimpleXMQ library.
  • Android arm64 libsimplex.so and a signed APK built successfully. The app accepted a private short-link invitation, completed messaging and downloaded a 1 MiB XFTP file with matching SHA-256: 386fb8e174f297a52146c8a387315a0b3c78904f345c5eff57b0ffa5ccb52502.

I also rejected invalid validation evidence: an earlier all-pending PostgreSQL run caused by loopback authentication, a parallel run that exhausted database connections, and initial GUI artifacts built against ../simplexmq instead of ../simplexmq-consolidated.

Remaining limitation

Only Android arm64 was packaged and signed. Armv7 is not included because its legacy GHC toolchain did not complete within one hour.

evgeny-simplex and others added 30 commits November 21, 2026 02:15
Prevent Windows XFTP server tests from hanging during TLS and HTTP/2 teardown.
Cancel HTTP/2 workers asynchronously, allow client finalizers to be interrupted, and close TLS contexts without waiting for peer close notifications.
Consolidated from PR simplex-chat#2064, preserving the cancellation semantics of PR simplex-chat#2088.
Consolidated from PR simplex-chat#2082 while preserving cancellation and file-count semantics.
Consolidated from PR simplex-chat#2038, retaining deadlock retries and file-count fixes.
adayhans8-debug and others added 21 commits November 21, 2026 05:01
Restore notification grouping and batched subscription results.
Initialize delayed AUTH and unacked-data settings.
Remove duplicate client send block definitions.
Reset replacement subscription state.
Deduplicate unsubscription events.
Recompute service END counts from the store.
Use dynamic SOCKS ports and current stats fixtures.
Start sendDelayed alongside send, command processing and receive threads.
Without this thread, AUTH responses remain in delayedQ indefinitely when authErrorDelay is enabled.
Verified: queue key SEd25519 / used key SEd25519 passes in 1.6138s.
Complete PostgreSQL migration, stats and service-association integration.
Cancel replaced XFTP uploads without self-cancel deadlocks; drain unstarted uploads after commit.
Delete expired files using paths returned at record deletion and cancel active uploads.
Allow retrying unconfirmed sender queues and restore notification push call.
Update test fixtures for temporary uploads, encoded frame size and deterministic expiration timing.
Focused AUTH, short-link, async retry, SQLite schema, static-file and all 45 XFTP chunk tests pass.
Delete only the newly created connection when securing it fails, so a later invitation retry does not conflict with the stale sender queue.
Keep cross-connection sender queue protection intact.
Verified async second-attempt connection and should-not-add-SndQueue-of-another-connection tests.
Use separate response and message senders under the fair transport lock, preventing sustained command traffic from starving message delivery.
Share the test deadline helper and raise the integration-suite limit to 180 seconds for multi-restart workloads.
Verified the 200-subscription batching test and all focused connection regressions.
Delete only the new sender queue after secureConfirmQueue fails, preserving the connection and ratchet for retries.
Verified all invitation/contact user-retry tests, async second attempt and cross-connection sender queue protection.
Use non-blocking writes for push workers so one full queue cannot delay notifications from other servers.
Accept NMSG responses from service subscriptions and correct second-token test entity matching.
Verified both memory and PostgreSQL full-push-queue tests.
Include generated schema updates from the completed migration set.
Allow up to 360 seconds for heavily contended multi-restart integration tests.
Verified: default suite 1449 examples, 0 failures, 7 pending.
Schema dumps produced and verified by the PostgreSQL schema tests.
…to consolidated/windows-transport

# Conflicts:
#	.github/workflows/build.yml
#	scripts/ci/README.md
#	scripts/resolver/README.md
#	scripts/resolver/docker-compose.yml
#	scripts/resolver/service/snrc-resolve.py
#	scripts/resolver/service/test_snrc_resolve.py
#	src/Simplex/FileTransfer/Server/Store/Postgres.hs
#	src/Simplex/Messaging/Agent.hs
#	src/Simplex/Messaging/Agent/Store/Postgres/Common.hs
#	src/Simplex/Messaging/Server/QueueStore/Postgres.hs
#	src/Simplex/Messaging/Transport.hs
#	tests/CoreTests/MsgStoreTests.hs
#	tests/CoreTests/XFTPStoreTests.hs
#	tests/NtfServerTests.hs
#	tests/XFTPServerTests.hs
Attempt TLS bye before closing the context without uninterruptible masking.
Use non-blocking notification writes for ACK events when the agent event queue is full.
Both focused regression tests pass.
Race TLS bye with a one-second timeout and close the context directly afterward.
Avoid nested timeout and withAsync cleanup deadlocks under uninterruptible masks.
Both TLS close regression tests pass.
Close TLS context after 50ms and finish cancellation after another 150ms.
This preserves timeout semantics while ensuring the context is already closed when the outer timeout fires.
TLS close, blocked-peer close and 1000-cancellation tests pass.
Pass shard ID 0 to getPushClient and look up pushClients by (provider, shard).
Push worker kill and periodic-server-stop tests pass with PostgreSQL enabled.
@adayhans8-debug

Copy link
Copy Markdown
Author

Merged current master (b0310ce0) and resolved all conflicts while retaining the consolidated fixes.

Verification after the merge:

  • Default suite: 1,458 examples, 0 failures, 7 pending.
  • PostgreSQL/slow-server serial regression and remaining XFTP Web Client, XRCP, Web, timing and schema-dump groups pass.
  • Resolver: 166 tests pass.
  • TLS close, blocked-peer close and 1000-cancellation regressions pass.
  • Notification push-worker lifecycle, 200-subscription batching and invitation/contact retry tests pass.
  • PR is now mergeable=true.

GitHub created the build and resolver-mainnet workflows, but both are action_required. A repository administrator must approve them before CI can run.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.