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

Don't pull out the full state when storing state #13274

Merged
merged 14 commits into from
Jul 15, 2022
Prev Previous commit
Next Next commit
Fix test
erikjohnston committed Jul 14, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit f4866ce531e16e64dac9f1e1828c045254680910
4 changes: 2 additions & 2 deletions tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
@@ -709,7 +709,7 @@ def test_post_room_no_keys(self) -> None:
self.assertEqual(200, channel.code, channel.result)
self.assertTrue("room_id" in channel.json_body)
assert channel.resource_usage is not None
self.assertEqual(32, channel.resource_usage.db_txn_count)
self.assertEqual(36, channel.resource_usage.db_txn_count)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit surprised these transaction counts increase. AFAICT the only reason we would end up doing more transactions is if we start doing an insert_delta_group_txn but abort that because the delta chain is too long. Any ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think its where we add the replaces_state to the unsigned section:

https://github.com/matrix-org/synapse/pull/13274/files#diff-d05c474c9fe45057f52616f38e54f6cdb3fa80a5a596ecb9c8fec3026ff8d68eR343-R346

So in the test we pull out some partial state for the group there, and then when we come to create the next event we pull out some other partial state for the group


def test_post_room_initial_state(self) -> None:
# POST with initial_state config key, expect new room id
@@ -722,7 +722,7 @@ def test_post_room_initial_state(self) -> None:
self.assertEqual(200, channel.code, channel.result)
self.assertTrue("room_id" in channel.json_body)
assert channel.resource_usage is not None
self.assertEqual(35, channel.resource_usage.db_txn_count)
self.assertEqual(40, channel.resource_usage.db_txn_count)

def test_post_room_visibility_key(self) -> None:
# POST with visibility config key, expect new room id
4 changes: 4 additions & 0 deletions tests/test_state.py
Original file line number Diff line number Diff line change
@@ -99,6 +99,10 @@ async def store_state_group(
state_group = self._next_group
self._next_group += 1

if current_state_ids is None:
current_state_ids = dict(self._group_to_state[prev_group])
current_state_ids.update(delta_ids)

self._group_to_state[state_group] = dict(current_state_ids)

return state_group