mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 09:23:50 +01:00
Don't fail all of an iteration of the device list retry loop on error (#7609)
Without this patch, if an error happens which isn't caught by `user_device_resync`, then `_maybe_retry_device_resync` would fail, without retrying the next users in the iteration. This patch fixes this so that it now only logs an error in this case.
This commit is contained in:
parent
2dc430d36e
commit
c1bdd4fac7
2 changed files with 22 additions and 15 deletions
1
changelog.d/7609.bugfix
Normal file
1
changelog.d/7609.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Prevent an entire iteration of the device list resync loop from failing if one server responds with a malformed result.
|
|
@ -704,22 +704,27 @@ class DeviceListUpdater(object):
|
||||||
need_resync = yield self.store.get_user_ids_requiring_device_list_resync()
|
need_resync = yield self.store.get_user_ids_requiring_device_list_resync()
|
||||||
# Iterate over the set of user IDs.
|
# Iterate over the set of user IDs.
|
||||||
for user_id in need_resync:
|
for user_id in need_resync:
|
||||||
# Try to resync the current user's devices list. Exception handling
|
try:
|
||||||
# isn't necessary here, since user_device_resync catches all instances
|
# Try to resync the current user's devices list.
|
||||||
# of "Exception" that might be raised from the federation request. This
|
result = yield self.user_device_resync(
|
||||||
# means that if an exception is raised by this function, it must be
|
user_id=user_id, mark_failed_as_stale=False,
|
||||||
# because of a database issue, which means _maybe_retry_device_resync
|
)
|
||||||
# probably won't be able to go much further anyway.
|
|
||||||
result = yield self.user_device_resync(
|
# user_device_resync only returns a result if it managed to
|
||||||
user_id=user_id, mark_failed_as_stale=False,
|
# successfully resync and update the database. Updating the table
|
||||||
)
|
# of users requiring resync isn't necessary here as
|
||||||
# user_device_resync only returns a result if it managed to successfully
|
# user_device_resync already does it (through
|
||||||
# resync and update the database. Updating the table of users requiring
|
# self.store.update_remote_device_list_cache).
|
||||||
# resync isn't necessary here as user_device_resync already does it
|
if result:
|
||||||
# (through self.store.update_remote_device_list_cache).
|
logger.debug(
|
||||||
if result:
|
"Successfully resynced the device list for %s", user_id,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
# If there was an issue resyncing this user, e.g. if the remote
|
||||||
|
# server sent a malformed result, just log the error instead of
|
||||||
|
# aborting all the subsequent resyncs.
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Successfully resynced the device list for %s" % user_id,
|
"Could not resync the device list for %s: %s", user_id, e,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
# Allow future calls to retry resyncinc out of sync device lists.
|
# Allow future calls to retry resyncinc out of sync device lists.
|
||||||
|
@ -738,6 +743,7 @@ class DeviceListUpdater(object):
|
||||||
request:
|
request:
|
||||||
https://matrix.org/docs/spec/server_server/r0.1.2#get-matrix-federation-v1-user-devices-userid
|
https://matrix.org/docs/spec/server_server/r0.1.2#get-matrix-federation-v1-user-devices-userid
|
||||||
"""
|
"""
|
||||||
|
logger.debug("Attempting to resync the device list for %s", user_id)
|
||||||
log_kv({"message": "Doing resync to update device list."})
|
log_kv({"message": "Doing resync to update device list."})
|
||||||
# Fetch all devices for the user.
|
# Fetch all devices for the user.
|
||||||
origin = get_domain_from_id(user_id)
|
origin = get_domain_from_id(user_id)
|
||||||
|
|
Loading…
Reference in a new issue