Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Merge tag 'v1.50.2' into dinsic
Browse files Browse the repository at this point in the history
Synapse 1.50.2 (2022-01-24)
===========================

Bugfixes
--------

- Fix a bug introduced in Synapse 1.40.0 that caused Synapse to fail to process incoming federation traffic after handling a large amount of events in a v1 room. ([\#11806](matrix-org/synapse#11806))
  • Loading branch information
babolivier committed Feb 7, 2022
2 parents 39e44da + 36f37ac commit fc9da2c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Synapse 1.50.2 (2022-01-24)
===========================

Bugfixes
--------

- Fix a bug introduced in Synapse 1.40.0 that caused Synapse to fail to process incoming federation traffic after handling a large amount of events in a v1 room. ([\#11806](https://github.com/matrix-org/synapse/issues/11806))


Synapse 1.50.1 (2022-01-18)
===========================

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
matrix-synapse-py3 (1.50.2) stable; urgency=medium

* New synapse release 1.50.2.

-- Synapse Packaging team <packages@matrix.org> Mon, 24 Jan 2022 13:37:11 +0000

matrix-synapse-py3 (1.50.1) stable; urgency=medium

* New synapse release 1.50.1.
Expand Down
2 changes: 1 addition & 1 deletion synapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
except ImportError:
pass

__version__ = "1.50.1"
__version__ = "1.50.2"

if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
# We import here so that we don't have to install a bunch of deps when
Expand Down
5 changes: 4 additions & 1 deletion synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,10 @@ async def prune_staged_events_in_room(

if room_version.event_format == EventFormatVersions.V1:
for prev_event_tuple in prev_events:
if not isinstance(prev_event_tuple, list) or len(prev_events) != 2:
if (
not isinstance(prev_event_tuple, list)
or len(prev_event_tuple) != 2
):
logger.info("Invalid prev_events for %s", event_id)
break

Expand Down
28 changes: 22 additions & 6 deletions tests/storage/test_event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Tuple, Union

import attr
from parameterized import parameterized

from synapse.api.room_versions import RoomVersions
from synapse.api.room_versions import (
KNOWN_ROOM_VERSIONS,
EventFormatVersions,
RoomVersion,
)
from synapse.events import _EventInternalMetadata
from synapse.util import json_encoder

Expand Down Expand Up @@ -506,11 +512,21 @@ def insert_event(txn):
)
self.assertSetEqual(difference, set())

def test_prune_inbound_federation_queue(self):
"Test that pruning of inbound federation queues work"
@parameterized.expand(
[(room_version,) for room_version in KNOWN_ROOM_VERSIONS.values()]
)
def test_prune_inbound_federation_queue(self, room_version: RoomVersion):
"""Test that pruning of inbound federation queues work"""

room_id = "some_room_id"

def prev_event_format(prev_event_id: str) -> Union[Tuple[str, dict], str]:
"""Account for differences in prev_events format across room versions"""
if room_version.event_format == EventFormatVersions.V1:
return prev_event_id, {}

return prev_event_id

# Insert a bunch of events that all reference the previous one.
self.get_success(
self.store.db_pool.simple_insert_many(
Expand All @@ -522,7 +538,7 @@ def test_prune_inbound_federation_queue(self):
"received_ts": 0,
"event_id": f"$fake_event_id_{i + 1}",
"event_json": json_encoder.encode(
{"prev_events": [f"$fake_event_id_{i}"]}
{"prev_events": [prev_event_format(f"$fake_event_id_{i}")]}
),
"internal_metadata": "{}",
}
Expand All @@ -535,12 +551,12 @@ def test_prune_inbound_federation_queue(self):
# Calling prune once should return True, i.e. a prune happen. The second
# time it shouldn't.
pruned = self.get_success(
self.store.prune_staged_events_in_room(room_id, RoomVersions.V6)
self.store.prune_staged_events_in_room(room_id, room_version)
)
self.assertTrue(pruned)

pruned = self.get_success(
self.store.prune_staged_events_in_room(room_id, RoomVersions.V6)
self.store.prune_staged_events_in_room(room_id, room_version)
)
self.assertFalse(pruned)

Expand Down

0 comments on commit fc9da2c

Please sign in to comment.