Skip to content

chore: Add capability to crash a worker if triggered from main process - #274

Open
jason-famedly wants to merge 8 commits into
masterfrom
jason/desict-redis
Open

chore: Add capability to crash a worker if triggered from main process#274
jason-famedly wants to merge 8 commits into
masterfrom
jason/desict-redis

Conversation

@jason-famedly

@jason-famedly jason-famedly commented Jul 13, 2026

Copy link
Copy Markdown
Member

SYN-53

It has been found that sometimes a worker is missed when restarting containers. This adds a new top-level setting force_crash_workers_after_main_restart(bool) to enable sending a SIGTERM signal to restart worker when triggered by redis.

An existing(although currently unused) redis "command" has been reworked for this purpose to send not only the server's instance name but also the name of the worker sending the command and when that process started. It should be received by any workers currently connected. Any worker receiving this command shall check their own start up time to compare against this received value and, if this should not be the main process, raise a SIGTERM. In theory, may not even really need to include the timestamp itself, as this command alone should only be broadcast on the start of the process.

This command needs to be sent before the redis replication process starts or it may interfere with the SUBSCRIBE and REPLICATE commands that follow since we are borrowing that connection

Note to reviewer: I included the changes into the old deprecated TCP replication system as well. It is completely unused and disconnected, but is still tested by old tests for some unknown reason. It can be safely stripped out when this is removed

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.41860% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.57%. Comparing base (b9c9b2a) to head (51464f5).

Files with missing lines Patch % Lines
synapse/replication/tcp/protocol.py 47.05% 8 Missing and 1 partial ⚠️
synapse/replication/tcp/handler.py 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
- Coverage   80.58%   80.57%   -0.01%     
==========================================
  Files         501      501              
  Lines       72107    72145      +38     
  Branches    10848    10852       +4     
==========================================
+ Hits        58105    58133      +28     
- Misses      10755    10764       +9     
- Partials     3247     3248       +1     
Files with missing lines Coverage Δ
synapse/config/server.py 69.09% <100.00%> (+0.14%) ⬆️
synapse/replication/tcp/commands.py 95.00% <100.00%> (+0.29%) ⬆️
synapse/replication/tcp/redis.py 81.36% <100.00%> (+0.23%) ⬆️
synapse/replication/tcp/handler.py 88.47% <80.00%> (-0.28%) ⬇️
synapse/replication/tcp/protocol.py 71.86% <47.05%> (-1.23%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9c9b2a...51464f5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jason-famedly
jason-famedly marked this pull request as ready for review July 13, 2026 12:03
@jason-famedly
jason-famedly requested a review from a team as a code owner July 13, 2026 12:03
@jason-famedly

Copy link
Copy Markdown
Member Author

Only test that failed on initial run was cargo-test, and that is a known failure that was determined to be false and has since been fixed upstream. It is unrelated to this change

Comment thread synapse/replication/tcp/redis.py Outdated
)
self.synapse_handler.new_connection(self)
await self._async_send_command(ReplicateCommand())
self.send_command(ReplicateCommand())

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.

why did you remove the await here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Look inside send_command(), it does the await as a background task, which feels kinda dumb. Just send the command. No real strong opinions otherwise, just seemed silly

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.

Hmm, it's just that we immediately log logger.info("REPLICATE successfully sent") although it might actually fail

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It took me a little while to think about that, but yes I agree. Good catch. Changed it back and did the SERVER command the same way as they do not need to be background tasks in 744f1c9

Comment thread synapse/config/server.py
self.max_event_delay_ms = None

force_crash_workers_after_main_restart = config.get(
"force_crash_workers_after_main_restart", False

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.

we should probably document this config option somwhere

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, good call. Forgot that

@jason-famedly jason-famedly Aug 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

728695f and 51464f5 (because I forgot you have to put it in the schema and regenerate them)

Comment thread synapse/replication/tcp/redis.py Outdated
ServerCommand(
self.server_name,
self.hs.get_instance_name(),
self.hs.get_clock().time_msec(),

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.

won't this value be the time of the redis connection (re)start? This would mean that a redis restart would crash the worker.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm. Yes probably, good catch again

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jason-famedly
jason-famedly force-pushed the jason/desict-redis branch 2 times, most recently from 200b373 to 2099a1c Compare August 4, 2026 18:53
@jason-famedly

Copy link
Copy Markdown
Member Author

I strongly recommend adding a small grace period. During testing this, each process is spawned at the same time but because of the main process having a slightly different startup routine it lagged behind. This caused each worker to restart almost immediately after the main process got it's feet under it. Probably don't need more than one second

@nico-famedly

Copy link
Copy Markdown
Member

I strongly recommend adding a small grace period. During testing this, each process is spawned at the same time but because of the main process having a slightly different startup routine it lagged behind. This caused each worker to restart almost immediately after the main process got it's feet under it. Probably don't need more than one second

So you are saying it is okay, if the workers start when the main process isn't ready yet? Or do you want to delay the startup of the workers?

@jason-famedly

jason-famedly commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Fascinating. The test failures for sytest on the updated round of commits are very different

#373: Newly left rooms appear in the leave section of gapped sync

From the synapse logs(server-0)
2026-08-04 19:03:15,452 - synapse.storage.databases.main.room - 404 - ERROR - POST-3943 - store_room with room_id=!j_LBGKLhWHQKgikaeRiDpwLz6z_zdzOPuMifLmoLQ1E failed: UNIQUE constraint failed: rooms.room_id
2026-08-04 19:03:15,452 - synapse.http.server - 132 - INFO - POST-3943 - <SynapseRequest at 0x7f139c2e4b50 method='POST' uri='/_matrix/client/v3/createRoom?access_token=<redacted>' clientproto='HTTP/1.1' site='8800'> SynapseError: 500 - Problem creating room.
2026-08-04 19:03:15,453 - synapse.access.https.8800 - 643 - INFO - POST-3943 - 127.0.0.1 - 8800 - {@anon-20260804_185940-374:127.0.0.1:8800} Processed request: 0.008sec/0.001sec ru=(0.004sec, 0.000sec) db=(0.001sec/0.001sec/2) 56B 500 "POST /_matrix/client/v3/createRoom?access_token=<redacted> HTTP/1.1" "Perl + Net::Async::HTTP/0.50" [0 dbevts]

#217: Can invite unbound 3pid over federation

from the synapse logs(server-1)
2026-08-04 19:01:04,390 - synapse.http.matrixfederationclient - 621 - ERROR - POST-112 - Invalid destination: !LdYkshyFs_s8BCvClrZH69scxWAwYnztiRV0eoKKYic.
Traceback (most recent call last):
  File "/synapse/synapse/http/matrixfederationclient.py", line 619, in _send_request
    parse_and_validate_server_name(request.destination)
  File "/synapse/synapse/util/stringutils.py", line 173, in parse_and_validate_server_name
    raise ValueError("Server name '%s' has an invalid format" % (server_name,))
ValueError: Server name '!LdYkshyFs_s8BCvClrZH69scxWAwYnztiRV0eoKKYic' has an invalid format
2026-08-04 19:01:04,391 - synapse.http.server - 132 - INFO - POST-112 - <SynapseRequest at 0x7f4c6cb5cdc0 method='POST' uri='/_matrix/federation/v1/3pid/onbind' clientproto='HTTP/1.1' site='8838'> SynapseError: 403 - Federation denied with !LdYkshyFs_s8BCvClrZH69scxWAwYnztiRV0eoKKYic.
2026-08-04 19:01:04,392 - synapse.access.https.8838 - 643 - INFO - POST-112 - 127.0.0.1 - 8838 - {None} Processed request: 0.004sec/0.000sec ru=(0.002sec, 0.000sec) db=(0.001sec/0.001sec/1) 104B 403 "POST /_matrix/federation/v1/3pid/onbind HTTP/1.1" "Perl + Net::Async::HTTP/0.50" [0 dbevts]

I'm not certain what to make of these, other than that they are using room version 12. Isn't that a bit ahead of schedule?

EDIT: Ah, I think I see. This required the associated PR on Synapse that was sent upstream to pair with sytest changes. Will wait until v1.158 is merged, that should sort it out.

EDIT 2: The complement failure appears interesting, but I am not sure how actionable it is.

From the complement logs for hs2
2026-08-04T19:12:58.7942409Z {"Time":"2026-08-04T19:12:55.212223228Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"synchrotron1 | 2026-08-04 19:12:54,267 - synapse.storage.controllers.state - 467 - INFO - GET-205 - Failed to find any events in room !fFmINbQLurymSuHrKz:hs1 at RoomStreamToken(stream: 61, topological: None, instances: {})\n"}
2026-08-04T19:12:58.7943628Z {"Time":"2026-08-04T19:12:55.212227906Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"event_persister1 | 2026-08-04 19:12:54,273 - synapse.replication.tcp.resource - 254 - INFO - replication_notifier-84 - Sending update for events: 74 -\u003e 75 (limited: False, updates: 2, max token: 75)\n"}
2026-08-04T19:12:58.7944702Z {"Time":"2026-08-04T19:12:55.212232445Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"event_persister2 | 2026-08-04 19:12:54,276 - synapse.replication.tcp.resource - 303 - INFO - replication_notifier-88 - Sending position for events: 74 -\u003e 75\n"}
2026-08-04T19:12:58.7946380Z {"Time":"2026-08-04T19:12:55.212237554Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"event_persister1 | 2026-08-04 19:12:54,281 - synapse.access.http.18009 - 643 - INFO - POST-190 - ::1 - 18009 - {None} Processed request: 0.040sec/0.006sec ru=(0.000sec, 0.000sec) db=(0.000sec/0.000sec/0) 98B 200 \"POST /_synapse/replication/fed_send_events/QHiBDgAxRt HTTP/1.1\" \"Synapse/1.157.2 (b=HEAD,9adbd98)\" [0 dbevts]\n"}
2026-08-04T19:12:58.7948264Z {"Time":"2026-08-04T19:12:55.212243155Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"federation_inbound1 | 2026-08-04 19:12:54,283 - synapse.http.client - 977 - INFO - _process_incoming_pdus_in_room_inner-4-$XNogeYybia_pTw7XENs9q-nRI7xUvRVgBKX-YNZSNzE - Received response to POST synapse-replication://event_persister1/_synapse/replication/fed_send_events/QHiBDgAxRt: 200\n"}
2026-08-04T19:12:58.7949807Z {"Time":"2026-08-04T19:12:55.212248314Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"synchrotron1 | 2026-08-04 19:12:54,296 - synapse.http.server - 148 - ERROR - GET-205 - Failed handle request via 'SyncRestServlet': \u003cSynapseRequest at 0x7f28ba82d1d0 method='GET' uri='/_matrix/client/v3/sync?timeout=1000' clientproto='HTTP/1.0' site='18018'\u003e\n"}
2026-08-04T19:12:58.7950536Z {"Time":"2026-08-04T19:12:55.212253925Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"Traceback (most recent call last):\n"}
2026-08-04T19:12:58.7951450Z {"Time":"2026-08-04T19:12:55.212258223Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/http/server.py\", line 336, in _async_render_wrapper\n"}
2026-08-04T19:12:58.7952142Z {"Time":"2026-08-04T19:12:55.212262651Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    callback_return = await self._async_render(request)\n"}
2026-08-04T19:12:58.7952786Z {"Time":"2026-08-04T19:12:55.212266678Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7953643Z {"Time":"2026-08-04T19:12:55.212270756Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/http/server.py\", line 577, in _async_render\n"}
2026-08-04T19:12:58.7954639Z {"Time":"2026-08-04T19:12:55.212274954Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    callback_return = await raw_callback_return\n"}
2026-08-04T19:12:58.7955278Z {"Time":"2026-08-04T19:12:55.212280063Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"                      ^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7956131Z {"Time":"2026-08-04T19:12:55.212284051Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/rest/client/sync.py\", line 270, in on_GET\n"}
2026-08-04T19:12:58.7956861Z {"Time":"2026-08-04T19:12:55.212288189Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    sync_result = await self.sync_handler.wait_for_sync_for_user(\n"}
2026-08-04T19:12:58.7957771Z {"Time":"2026-08-04T19:12:55.212292817Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7958468Z {"Time":"2026-08-04T19:12:55.212296584Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c6 lines\u003e...\n"}
2026-08-04T19:12:58.7958990Z {"Time":"2026-08-04T19:12:55.212300802Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.7959501Z {"Time":"2026-08-04T19:12:55.212304389Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.7960414Z {"Time":"2026-08-04T19:12:55.212308797Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 366, in wait_for_sync_for_user\n"}
2026-08-04T19:12:58.7961125Z {"Time":"2026-08-04T19:12:55.212313425Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    res = await self.response_cache.wrap(\n"}
2026-08-04T19:12:58.7961752Z {"Time":"2026-08-04T19:12:55.212318104Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7962344Z {"Time":"2026-08-04T19:12:55.212322432Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c7 lines\u003e...\n"}
2026-08-04T19:12:58.7962912Z {"Time":"2026-08-04T19:12:55.212326229Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.7963427Z {"Time":"2026-08-04T19:12:55.212331158Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.7964320Z {"Time":"2026-08-04T19:12:55.212335246Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/util/caches/response_cache.py\", line 375, in wrap\n"}
2026-08-04T19:12:58.7965047Z {"Time":"2026-08-04T19:12:55.212343702Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    return await make_deferred_yieldable(entry.result.observe())\n"}
2026-08-04T19:12:58.7965708Z {"Time":"2026-08-04T19:12:55.212347809Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7966626Z {"Time":"2026-08-04T19:12:55.212352508Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py\", line 1187, in __iter__\n"}
2026-08-04T19:12:58.7967182Z {"Time":"2026-08-04T19:12:55.212356616Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    yield self\n"}
2026-08-04T19:12:58.7968295Z {"Time":"2026-08-04T19:12:55.212360523Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py\", line 1853, in _inlineCallbacks\n"}
2026-08-04T19:12:58.7968894Z {"Time":"2026-08-04T19:12:55.212364701Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    result = context.run(\n"}
2026-08-04T19:12:58.7969614Z {"Time":"2026-08-04T19:12:55.212368428Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        cast(Failure, result).throwExceptionIntoGenerator, gen\n"}
2026-08-04T19:12:58.7970205Z {"Time":"2026-08-04T19:12:55.212372025Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.7971135Z {"Time":"2026-08-04T19:12:55.212376052Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/twisted/python/failure.py\", line 467, in throwExceptionIntoGenerator\n"}
2026-08-04T19:12:58.7971823Z {"Time":"2026-08-04T19:12:55.21238012Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    return g.throw(self.value.with_traceback(self.tb))\n"}
2026-08-04T19:12:58.7972476Z {"Time":"2026-08-04T19:12:55.212383907Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"           ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7973947Z {"Time":"2026-08-04T19:12:55.212387894Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/util/caches/response_cache.py\", line 368, in cb\n"}
2026-08-04T19:12:58.7974851Z {"Time":"2026-08-04T19:12:55.212391802Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    return await callback(*args, **kwargs)\n"}
2026-08-04T19:12:58.7975731Z {"Time":"2026-08-04T19:12:55.212395659Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7976656Z {"Time":"2026-08-04T19:12:55.212399666Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 480, in _wait_for_sync_for_user\n"}
2026-08-04T19:12:58.7977330Z {"Time":"2026-08-04T19:12:55.212403664Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    result = await self.current_sync_for_user(\n"}
2026-08-04T19:12:58.7978237Z {"Time":"2026-08-04T19:12:55.212408272Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7979118Z {"Time":"2026-08-04T19:12:55.212412189Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        sync_config, since_token, full_state=full_state\n"}
2026-08-04T19:12:58.7980300Z {"Time":"2026-08-04T19:12:55.212415967Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7981415Z {"Time":"2026-08-04T19:12:55.212419673Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.7982169Z {"Time":"2026-08-04T19:12:55.21242333Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.7983344Z {"Time":"2026-08-04T19:12:55.212427288Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 548, in current_sync_for_user\n"}
2026-08-04T19:12:58.7984179Z {"Time":"2026-08-04T19:12:55.212432016Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    sync_result = await self.generate_sync_result(\n"}
2026-08-04T19:12:58.7984833Z {"Time":"2026-08-04T19:12:55.212436154Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7985764Z {"Time":"2026-08-04T19:12:55.212440302Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        sync_config, since_token, full_state\n"}
2026-08-04T19:12:58.7986795Z {"Time":"2026-08-04T19:12:55.212444239Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7987895Z {"Time":"2026-08-04T19:12:55.212448377Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.7988774Z {"Time":"2026-08-04T19:12:55.212452094Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.7990625Z {"Time":"2026-08-04T19:12:55.212457364Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 1795, in generate_sync_result\n"}
2026-08-04T19:12:58.7991926Z {"Time":"2026-08-04T19:12:55.212461652Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ) = await self._generate_sync_entry_for_rooms(sync_result_builder)\n"}
2026-08-04T19:12:58.7993342Z {"Time":"2026-08-04T19:12:55.21246602Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.7995085Z {"Time":"2026-08-04T19:12:55.212470258Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 2346, in _generate_sync_entry_for_rooms\n"}
2026-08-04T19:12:58.7996171Z {"Time":"2026-08-04T19:12:55.212474505Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    await concurrently_execute(handle_room_entries, room_entries, 10)\n"}
2026-08-04T19:12:58.7998014Z {"Time":"2026-08-04T19:12:55.212478713Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/util/async_helpers.py\", line 300, in concurrently_execute\n"}
2026-08-04T19:12:58.7998965Z {"Time":"2026-08-04T19:12:55.212483873Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    await yieldable_gather_results(\n"}
2026-08-04T19:12:58.8000051Z {"Time":"2026-08-04T19:12:55.21248764Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c2 lines\u003e...\n"}
2026-08-04T19:12:58.8000831Z {"Time":"2026-08-04T19:12:55.212491377Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.8002372Z {"Time":"2026-08-04T19:12:55.212495284Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/util/async_helpers.py\", line 349, in yieldable_gather_results\n"}
2026-08-04T19:12:58.8003685Z {"Time":"2026-08-04T19:12:55.212499432Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    raise dfe.subFailure.value from None\n"}
2026-08-04T19:12:58.8004876Z {"Time":"2026-08-04T19:12:55.212503419Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py\", line 1857, in _inlineCallbacks\n"}
2026-08-04T19:12:58.8005551Z {"Time":"2026-08-04T19:12:55.212507607Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    result = context.run(gen.send, result)\n"}
2026-08-04T19:12:58.8006632Z {"Time":"2026-08-04T19:12:55.212512026Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/util/async_helpers.py\", line 286, in _concurrently_execute_inner\n"}
2026-08-04T19:12:58.8007788Z {"Time":"2026-08-04T19:12:55.212516033Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    await maybe_awaitable(func(value))\n"}
2026-08-04T19:12:58.8009028Z {"Time":"2026-08-04T19:12:55.21251992Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 2334, in handle_room_entries\n"}
2026-08-04T19:12:58.8009787Z {"Time":"2026-08-04T19:12:55.212524058Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    await self._generate_room_entry(\n"}
2026-08-04T19:12:58.8010407Z {"Time":"2026-08-04T19:12:55.212527684Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c7 lines\u003e...\n"}
2026-08-04T19:12:58.8010940Z {"Time":"2026-08-04T19:12:55.212531411Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.8011921Z {"Time":"2026-08-04T19:12:55.212535309Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 2796, in _generate_room_entry\n"}
2026-08-04T19:12:58.8012594Z {"Time":"2026-08-04T19:12:55.212539587Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    batch = await self._load_filtered_recents(\n"}
2026-08-04T19:12:58.8013237Z {"Time":"2026-08-04T19:12:55.212543554Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.8013842Z {"Time":"2026-08-04T19:12:55.212547331Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c7 lines\u003e...\n"}
2026-08-04T19:12:58.8014364Z {"Time":"2026-08-04T19:12:55.212551559Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.8014875Z {"Time":"2026-08-04T19:12:55.212556328Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.8015850Z {"Time":"2026-08-04T19:12:55.212560987Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/handlers/sync.py\", line 854, in _load_filtered_recents\n"}
2026-08-04T19:12:58.8016532Z {"Time":"2026-08-04T19:12:55.212565786Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ] = await filter_and_transform_events_for_client(\n"}
2026-08-04T19:12:58.8017186Z {"Time":"2026-08-04T19:12:55.212569953Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.8018088Z {"Time":"2026-08-04T19:12:55.2125736Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ...\u003c4 lines\u003e...\n"}
2026-08-04T19:12:58.8018619Z {"Time":"2026-08-04T19:12:55.212577407Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    )\n"}
2026-08-04T19:12:58.8019226Z {"Time":"2026-08-04T19:12:55.212580984Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    ^\n"}
2026-08-04T19:12:58.8020157Z {"Time":"2026-08-04T19:12:55.212584801Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/logging/opentracing.py\", line 979, in _wrapper\n"}
2026-08-04T19:12:58.8020797Z {"Time":"2026-08-04T19:12:55.212589009Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    return await func(*args, **kwargs)\n"}
2026-08-04T19:12:58.8021485Z {"Time":"2026-08-04T19:12:55.212592906Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.8022449Z {"Time":"2026-08-04T19:12:55.212596864Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/visibility.py\", line 242, in filter_and_transform_events_for_client\n"}
2026-08-04T19:12:58.8023114Z {"Time":"2026-08-04T19:12:55.212600941Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    return [ev for ev in filtered_events if ev]\n"}
2026-08-04T19:12:58.8023904Z {"Time":"2026-08-04T19:12:55.212604888Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"                         ^^^^^^^^^^^^^^^\n"}
2026-08-04T19:12:58.8024747Z {"Time":"2026-08-04T19:12:55.212609768Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"  File \"/usr/local/lib/python3.13/site-packages/synapse/visibility.py\", line 228, in allowed\n"}
2026-08-04T19:12:58.8025547Z {"Time":"2026-08-04T19:12:55.212614306Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"    raise Exception(\"Missing state for event that is not user's own membership\")\n"}
2026-08-04T19:12:58.8026296Z {"Time":"2026-08-04T19:12:55.212618324Z","Action":"output","Package":"github.com/matrix-org/complement/tests","Test":"TestFederationRoomsInvite","Output":"Exception: Missing state for event that is not user's own membership\n"}

@jason-famedly

jason-famedly commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

I strongly recommend adding a small grace period. During testing this, each process is spawned at the same time but because of the main process having a slightly different startup routine it lagged behind. This caused each worker to restart almost immediately after the main process got it's feet under it. Probably don't need more than one second

So you are saying it is okay, if the workers start when the main process isn't ready yet? Or do you want to delay the startup of the workers?

Yes, I am saying it is ok. The main process does not always bear the responsibility of every stream. The REPLICATE command that happens right after SERVER and SUBSCRIBE re-synchronize the positions held in-memory on any given process for any given stream.

(In theory, that actually implies that this work is not needed at all)

EDIT: But I am also saying that there is no need to delay startup of the workers. One second as a grace period should be acceptable

@nico-famedly

Copy link
Copy Markdown
Member

Hm, I need to look into this more, before this is merged. This inverts the control of how the restart happens, which means instead of pull it is now push with a command that could get missed. I need to see how that affects things.

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.

3 participants