Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dbb9f26
agent, clients: prevent hangs while a server or event processing is slow
evgeny-simplex Nov 17, 2026
e930913
agent: write acknowledgement event without waiting only in the API call
evgeny-simplex Nov 17, 2026
7632a07
tests: qualify agent INTERNAL error
evgeny-simplex Nov 17, 2026
76079ee
tests: acknowledge message when event and message queues are full
evgeny-simplex Nov 17, 2026
39a30e1
tests: exchange greetings before polling a message after restart
evgeny-simplex Nov 17, 2026
259167a
agent: write SUSPENDED once for each suspension
evgeny-simplex Nov 17, 2026
284a4d7
agent, clients: prevent leaked reply queues and stale HTTP/2 requests
evgeny-simplex Nov 17, 2026
de387b6
Merge remote-tracking branch 'upstream/stable' into ep/agent-no-blocking
evgeny-simplex Nov 20, 2026
1b3798d
tests: name the test proxy that holds connections until resumed withP…
evgeny-simplex Nov 20, 2026
277c0f4
agent: inline the connection lock checks of builds without conn_lock_…
evgeny-simplex Nov 20, 2026
b97a8b3
Merge remote-tracking branch 'upstream/master' into ep/agent-no-block…
evgeny-simplex Nov 21, 2026
5658cbd
docs: plan for the agent without waits on slow servers
evgeny-simplex Nov 21, 2026
a411c28
agent, xftp: move SUSPENDED and HTTP/2 changes to separate pull requests
evgeny-simplex Nov 21, 2026
a33da6b
agent: validate, request and commit queue changes in one helper
evgeny-simplex Nov 21, 2026
2a06cc1
agent: prevent the Secured queue status from replacing Active
evgeny-simplex Nov 21, 2026
425d53c
agent: accept a repeated acknowledgement, read queue status after ACK
evgeny-simplex Nov 21, 2026
158f566
agent: record or delete a created queue in one helper
evgeny-simplex Nov 21, 2026
de68382
agent: abort the earlier switch when a switch is aborted and restarted
evgeny-simplex Nov 21, 2026
8d86e19
agent: prevent waits for the notification command queue in deletion
evgeny-simplex Nov 21, 2026
99cb1c6
clients: assign the creation time of a request once
evgeny-simplex Nov 21, 2026
33c9bbf
agent: write DEL_USER and DEL_CONNS with the event helpers
evgeny-simplex Nov 21, 2026
4b38cca
docs: state that a new switch start replaces the switch identifier
evgeny-simplex Nov 21, 2026
128d856
agent: delete the new queue when deletion waits for delivery
evgeny-simplex Nov 21, 2026
d44ca73
agent: read the connection once in each step of acknowledgement
evgeny-simplex Nov 21, 2026
81dfcdd
docs: add the deletion rule, state that commands are not queued late
evgeny-simplex Nov 21, 2026
8aa2ed0
agent: prevent repeated processing of switch commands in ratchet sync
evgeny-simplex Nov 21, 2026
1efa2fb
docs: state that postponed switch commands follow other commands
evgeny-simplex Nov 21, 2026
cd3f7a7
tests: read the QKEY delivery event in the two-way switch test
evgeny-simplex Nov 21, 2026
9a33fd4
agent: prevent a switch queue left on the server by synchronous deletion
evgeny-simplex Nov 21, 2026
f620a6b
agent: prevent waits for the notification command queue in a switch
evgeny-simplex Nov 21, 2026
de119c4
agent: prevent an error event when an asynchronous switch is aborted
evgeny-simplex Nov 21, 2026
b4e3329
tests: time out the switch with a full notification command queue
evgeny-simplex Nov 21, 2026
f8890ac
plans: lock holders never wait for notification command queue space
evgeny-simplex Nov 21, 2026
36d3207
clients: simplify command sending; request time in system seconds
evgeny-simplex Nov 23, 2026
4c2ee39
clients: fail commands of a disconnected client without queueing them
evgeny-simplex Nov 23, 2026
953dac4
clients: revert command sending to f8890ac3
evgeny-simplex Nov 23, 2026
f0bdba6
clients: send a block only while connected, with one dispatch on msgQ
evgeny-simplex Nov 23, 2026
c9ae815
clients: request creation time in system seconds
evgeny-simplex Nov 23, 2026
c55ef71
clients: write a message received in a response to msgQ in its order …
evgeny-simplex Nov 23, 2026
2eb02bb
clients: check the entity of a response once
evgeny-simplex Nov 23, 2026
9c6121e
agent: simplify acknowledgement, new queue recording and command post…
evgeny-simplex Nov 23, 2026
3398bac
tests: remove duplicate switch tests, share full queue helpers
evgeny-simplex Nov 23, 2026
4a42ac9
plans: correct the agent no-blocking plan to the code
evgeny-simplex Nov 23, 2026
2989063
tests: import the full notification queue helper
evgeny-simplex Nov 23, 2026
9b08382
clients: keep requests for late responses until disconnection
evgeny-simplex Nov 24, 2026
6826cf6
agent: plan requests without contested connection locks
evgeny-simplex Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ jobs:
chmod -fR 777 ~/.cabal ./dist-client-postgres || :; git config --global --add safe.directory '*'
scripts/ci/prune-old-builds.sh dist-client-postgres
cabal update
cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers ${{ env.ghc_options }} simplexmq-test
cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers -fconn_lock_checks ${{ env.ghc_options }} simplexmq-test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PostgreSQL agent store tests are built with conn_lock_checks, also in the reduced build (L554).

mkdir -p /out
bin=$(find /project/dist-client-postgres -name simplexmq-test -type f -executable)
cp "$bin" /out/simplexmq-test-client-postgres
Expand Down Expand Up @@ -503,7 +503,7 @@ jobs:
run: |
scripts/ci/prune-old-builds.sh dist-newstyle dist-postgres dist-client-postgres
if [ "${{ matrix.client_postgres }}" = true ]; then
cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers --ghc-options=-O0 simplexmq-test
cabal build --builddir=dist-client-postgres --jobs=$(nproc) --enable-tests -fserver_postgres -fclient_postgres -fslow_servers -fconn_lock_checks --ghc-options=-O0 simplexmq-test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same flags as L302, so that the -O0 cache of master and stable pushes matches pull request builds.

else
cabal build --builddir=dist-postgres --jobs=$(nproc) --enable-tests -fserver_postgres --ghc-options=-O0
cabal build --jobs=$(nproc) --ghc-options=-O0
Expand Down
191 changes: 191 additions & 0 deletions plans/2026-11-21-agent-no-blocking.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| a push to a draft pull request<br>a manual run (workflow_dispatch)<br>a push to master or stable in a fork | reduced | build-reduced: 2 entries, ubuntu-24.04 x86-64, GHC 9.6.3, at -O0 (-O2 on pushes), without the standard build |
| a pull request marked ready for review, and later pushes to it<br>a push to master or stable in simplex-chat/simplexmq<br>a push of a v* tag | full | build: 6 entries (GHC 8.10.7 and 9.6.3, x86-64 and aarch64), at -O0 on pull requests and -O2 on pushes |

Both builds also run maybe-release and resolver (python). Tests run on the x86-64 entries, after xftp-web is built with Node.js 22 (`npm install`, `npm run build`) for the XFTP Web Client tests. In both builds, the ubuntu-24.04 x86-64 entry named "PostgreSQL agent store" builds and runs only the tests built with `-fclient_postgres -fslow_servers` (agent with the PostgreSQL store, and XFTP servers that delay responses for the slow-server test, which the other builds skip), in the build directory dist-client-postgres, in step "Test with PostgreSQL agent store", in parallel with the other entries; its build directory has its own cache key. After the tests, step "Check generated files" fails if a test changed a tracked file: the schema dump and query plan tests overwrite their files, so a stale file fails here even when the test passes on retry. The reduced build restores the -O0 build caches saved by master pushes; the Docker image cache is tagged by ISO week, so the first run of a week rebuilds the image.
Both builds also run maybe-release and resolver (python). Tests run on the x86-64 entries, after xftp-web is built with Node.js 22 (`npm install`, `npm run build`) for the XFTP Web Client tests. In both builds, the ubuntu-24.04 x86-64 entry named "PostgreSQL agent store" builds and runs only the tests built with `-fclient_postgres -fslow_servers -fconn_lock_checks` (agent with the PostgreSQL store, XFTP servers that delay responses for the slow-server test, and an agent that fails server requests made inside a connection lock, which the other builds skip), in the build directory dist-client-postgres, in step "Test with PostgreSQL agent store", in parallel with the other entries; its build directory has its own cache key. After the tests, step "Check generated files" fails if a test changed a tracked file: the schema dump and query plan tests overwrite their files, so a stale file fails here even when the test passes on retry. The reduced build restores the -O0 build caches saved by master pushes; the Docker image cache is tagged by ISO week, so the first run of a week rebuilds the image.

## Test selection

Expand Down
9 changes: 9 additions & 0 deletions simplexmq.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ flag slow_servers
manual: True
default: False

flag conn_lock_checks
description: Fail agent server requests made inside a connection lock, for tests.
manual: True
default: False

Comment on lines +97 to +101

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only for tests, off by default: the check and its test are compiled with it.

flag server_postgres
description: Build server with support of PostgreSQL.
manual: True
Expand Down Expand Up @@ -429,6 +434,8 @@ library
cpp-options: -DswiftJSON
if flag(slow_servers)
cpp-options: -Dslow_servers
if flag(conn_lock_checks)
cpp-options: -Dconn_lock_checks
if !flag(client_library)
build-depends:
case-insensitive ==1.2.*
Expand Down Expand Up @@ -683,6 +690,8 @@ test-suite simplexmq-test
cpp-options: -DdbServerPostgres
if flag(slow_servers)
cpp-options: -Dslow_servers
if flag(conn_lock_checks)
cpp-options: -Dconn_lock_checks
if flag(client_postgres)
cpp-options: -DdbPostgres
else
Expand Down
2 changes: 1 addition & 1 deletion src/Simplex/FileTransfer/Agent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ deleteSndFileRemote c userId sndFileEntityId sfd = deleteSndFilesRemote c userId

deleteSndFilesRemote :: AgentClient -> UserId -> [(SndFileId, ValidFileDescription 'FSender)] -> AM' ()
deleteSndFilesRemote c userId sndFileIdsDescrs = do
deleteSndFilesInternal c (map fst sndFileIdsDescrs) `E.catchAny` (notify c "" . SFERR . INTERNAL . show)
deleteSndFilesInternal c (map fst sndFileIdsDescrs) `E.catchAny` (notifySub' c "" . SFERR . INTERNAL . show)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Written without waiting for subQ space: called in the API thread of xftpDeleteSndFilesRemote (rule 4); no test.

let rs = concatMap (mapMaybe chunkReplica . fdChunks . snd) sndFileIdsDescrs
void $ withStoreBatch' c (\db -> map (uncurry $ createDeletedSndChunkReplica db userId) rs)
let servers = S.fromList $ map (\(FileChunkReplica {server}, _) -> server) rs
Expand Down
Loading
Loading