mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-20 22:38:08 -04:00
Wait for streams to catch up when processing HTTP replication. (#14820)
This should hopefully mitigate a class of races where data gets out of sync due a HTTP replication request racing with the replication streams.
This commit is contained in:
parent
e8f2bf5c40
commit
9187fd940e
21 changed files with 225 additions and 144 deletions
|
@ -349,8 +349,8 @@ class MultiWriterIdGeneratorTestCase(HomeserverTestCase):
|
|||
|
||||
# The first ID gen will notice that it can advance its token to 7 as it
|
||||
# has no in progress writes...
|
||||
self.assertEqual(first_id_gen.get_positions(), {"first": 7, "second": 7})
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("first"), 7)
|
||||
self.assertEqual(first_id_gen.get_positions(), {"first": 3, "second": 7})
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("first"), 3)
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("second"), 7)
|
||||
|
||||
# ... but the second ID gen doesn't know that.
|
||||
|
@ -366,8 +366,9 @@ class MultiWriterIdGeneratorTestCase(HomeserverTestCase):
|
|||
self.assertEqual(stream_id, 8)
|
||||
|
||||
self.assertEqual(
|
||||
first_id_gen.get_positions(), {"first": 7, "second": 7}
|
||||
first_id_gen.get_positions(), {"first": 3, "second": 7}
|
||||
)
|
||||
self.assertEqual(first_id_gen.get_persisted_upto_position(), 7)
|
||||
|
||||
self.get_success(_get_next_async())
|
||||
|
||||
|
@ -473,7 +474,7 @@ class MultiWriterIdGeneratorTestCase(HomeserverTestCase):
|
|||
|
||||
id_gen = self._create_id_generator("first", writers=["first", "second"])
|
||||
|
||||
self.assertEqual(id_gen.get_positions(), {"first": 5, "second": 5})
|
||||
self.assertEqual(id_gen.get_positions(), {"first": 3, "second": 5})
|
||||
|
||||
self.assertEqual(id_gen.get_persisted_upto_position(), 5)
|
||||
|
||||
|
@ -720,7 +721,7 @@ class BackwardsMultiWriterIdGeneratorTestCase(HomeserverTestCase):
|
|||
|
||||
self.get_success(_get_next_async2())
|
||||
|
||||
self.assertEqual(id_gen_1.get_positions(), {"first": -2, "second": -2})
|
||||
self.assertEqual(id_gen_1.get_positions(), {"first": -1, "second": -2})
|
||||
self.assertEqual(id_gen_2.get_positions(), {"first": -1, "second": -2})
|
||||
self.assertEqual(id_gen_1.get_persisted_upto_position(), -2)
|
||||
self.assertEqual(id_gen_2.get_persisted_upto_position(), -2)
|
||||
|
@ -816,15 +817,12 @@ class MultiTableMultiWriterIdGeneratorTestCase(HomeserverTestCase):
|
|||
first_id_gen = self._create_id_generator("first", writers=["first", "second"])
|
||||
second_id_gen = self._create_id_generator("second", writers=["first", "second"])
|
||||
|
||||
# The first ID gen will notice that it can advance its token to 7 as it
|
||||
# has no in progress writes...
|
||||
self.assertEqual(first_id_gen.get_positions(), {"first": 7, "second": 6})
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("first"), 7)
|
||||
self.assertEqual(first_id_gen.get_positions(), {"first": 3, "second": 6})
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("first"), 3)
|
||||
self.assertEqual(first_id_gen.get_current_token_for_writer("second"), 6)
|
||||
self.assertEqual(first_id_gen.get_persisted_upto_position(), 7)
|
||||
|
||||
# ... but the second ID gen doesn't know that.
|
||||
self.assertEqual(second_id_gen.get_positions(), {"first": 3, "second": 7})
|
||||
self.assertEqual(second_id_gen.get_current_token_for_writer("first"), 3)
|
||||
self.assertEqual(second_id_gen.get_current_token_for_writer("second"), 7)
|
||||
self.assertEqual(first_id_gen.get_persisted_upto_position(), 7)
|
||||
self.assertEqual(second_id_gen.get_persisted_upto_position(), 7)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue