Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
affaffb0
Unverified
Commit
affaffb0
authored
3 years ago
by
Erik Johnston
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Run cache_joined_hosts_for_event in background (#9951)
parent
63fb220e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/9951.feature
+1
-0
1 addition, 0 deletions
changelog.d/9951.feature
synapse/handlers/message.py
+40
-5
40 additions, 5 deletions
synapse/handlers/message.py
with
41 additions
and
5 deletions
changelog.d/9951.feature
0 → 100644
+
1
−
0
View file @
affaffb0
Improve
performance
of
sending
events
for
worker-based
deployments
using
Redis.
This diff is collapsed.
Click to expand it.
synapse/handlers/message.py
+
40
−
5
View file @
affaffb0
...
@@ -19,6 +19,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple
...
@@ -19,6 +19,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Tuple
from
canonicaljson
import
encode_canonical_json
from
canonicaljson
import
encode_canonical_json
from
twisted.internet
import
defer
from
twisted.internet.interfaces
import
IDelayedCall
from
twisted.internet.interfaces
import
IDelayedCall
from
synapse
import
event_auth
from
synapse
import
event_auth
...
@@ -43,14 +44,14 @@ from synapse.events import EventBase
...
@@ -43,14 +44,14 @@ from synapse.events import EventBase
from
synapse.events.builder
import
EventBuilder
from
synapse.events.builder
import
EventBuilder
from
synapse.events.snapshot
import
EventContext
from
synapse.events.snapshot
import
EventContext
from
synapse.events.validator
import
EventValidator
from
synapse.events.validator
import
EventValidator
from
synapse.logging.context
import
run_in_background
from
synapse.logging.context
import
make_deferred_yieldable
,
run_in_background
from
synapse.metrics.background_process_metrics
import
run_as_background_process
from
synapse.metrics.background_process_metrics
import
run_as_background_process
from
synapse.replication.http.send_event
import
ReplicationSendEventRestServlet
from
synapse.replication.http.send_event
import
ReplicationSendEventRestServlet
from
synapse.storage.databases.main.events_worker
import
EventRedactBehaviour
from
synapse.storage.databases.main.events_worker
import
EventRedactBehaviour
from
synapse.storage.state
import
StateFilter
from
synapse.storage.state
import
StateFilter
from
synapse.types
import
Requester
,
RoomAlias
,
StreamToken
,
UserID
,
create_requester
from
synapse.types
import
Requester
,
RoomAlias
,
StreamToken
,
UserID
,
create_requester
from
synapse.util
import
json_decoder
,
json_encoder
from
synapse.util
import
json_decoder
,
json_encoder
,
log_failure
from
synapse.util.async_helpers
import
Linearizer
from
synapse.util.async_helpers
import
Linearizer
,
unwrapFirstError
from
synapse.util.caches.expiringcache
import
ExpiringCache
from
synapse.util.caches.expiringcache
import
ExpiringCache
from
synapse.util.metrics
import
measure_func
from
synapse.util.metrics
import
measure_func
from
synapse.visibility
import
filter_events_for_client
from
synapse.visibility
import
filter_events_for_client
...
@@ -979,9 +980,43 @@ class EventCreationHandler:
...
@@ -979,9 +980,43 @@ class EventCreationHandler:
logger
.
exception
(
"
Failed to encode content: %r
"
,
event
.
content
)
logger
.
exception
(
"
Failed to encode content: %r
"
,
event
.
content
)
raise
raise
await
self
.
action_generator
.
handle_push_actions_for_event
(
event
,
context
)
# We now persist the event (and update the cache in parallel, since we
# don't want to block on it).
result
=
await
make_deferred_yieldable
(
defer
.
gatherResults
(
[
run_in_background
(
self
.
_persist_event
,
requester
=
requester
,
event
=
event
,
context
=
context
,
ratelimit
=
ratelimit
,
extra_users
=
extra_users
,
),
run_in_background
(
self
.
cache_joined_hosts_for_event
,
event
,
context
).
addErrback
(
log_failure
,
"
cache_joined_hosts_for_event failed
"
),
],
consumeErrors
=
True
,
)
).
addErrback
(
unwrapFirstError
)
return
result
[
0
]
async
def
_persist_event
(
self
,
requester
:
Requester
,
event
:
EventBase
,
context
:
EventContext
,
ratelimit
:
bool
=
True
,
extra_users
:
Optional
[
List
[
UserID
]]
=
None
,
)
->
EventBase
:
"""
Actually persists the event. Should only be called by
`handle_new_client_event`, and see its docstring for documentation of
the arguments.
"""
await
self
.
c
ac
he_joined_host
s_for_event
(
event
,
context
)
await
self
.
ac
tion_generator
.
handle_push_action
s_for_event
(
event
,
context
)
try
:
try
:
# If we're a worker we need to hit out to the master.
# If we're a worker we need to hit out to the master.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment