@@ -1777,7 +1777,6 @@ async def store_partial_state_room(
1777
1777
self ,
1778
1778
room_id : str ,
1779
1779
servers : Collection [str ],
1780
- join_event_id : str ,
1781
1780
device_lists_stream_id : int ,
1782
1781
) -> None :
1783
1782
"""Mark the given room as containing events with partial state.
@@ -1786,11 +1785,12 @@ async def store_partial_state_room(
1786
1785
room, which helps us to keep other homeservers in sync when we finally fully
1787
1786
join this room.
1788
1787
1788
+ We do not include a `join_event_id` here---we need to wait for the join event
1789
+ to be persisted first.
1790
+
1789
1791
Args:
1790
1792
room_id: the ID of the room
1791
1793
servers: other servers known to be in the room
1792
- join_event_id: the event ID of the join membership event returned in the
1793
- (partial) /send_join response.
1794
1794
device_lists_stream_id: the device_lists stream ID at the time when we first
1795
1795
joined the room.
1796
1796
"""
@@ -1799,7 +1799,6 @@ async def store_partial_state_room(
1799
1799
self ._store_partial_state_room_txn ,
1800
1800
room_id ,
1801
1801
servers ,
1802
- join_event_id ,
1803
1802
device_lists_stream_id ,
1804
1803
)
1805
1804
@@ -1808,7 +1807,6 @@ def _store_partial_state_room_txn(
1808
1807
txn : LoggingTransaction ,
1809
1808
room_id : str ,
1810
1809
servers : Collection [str ],
1811
- join_event_id : str ,
1812
1810
device_lists_stream_id : int ,
1813
1811
) -> None :
1814
1812
DatabasePool .simple_insert_txn (
@@ -1817,7 +1815,8 @@ def _store_partial_state_room_txn(
1817
1815
values = {
1818
1816
"room_id" : room_id ,
1819
1817
"device_lists_stream_id" : device_lists_stream_id ,
1820
- "join_event_id" : join_event_id ,
1818
+ # To be updated later once the join event is persisted.
1819
+ "join_event_id" : None ,
1821
1820
},
1822
1821
)
1823
1822
DatabasePool .simple_insert_many_txn (
@@ -1828,6 +1827,36 @@ def _store_partial_state_room_txn(
1828
1827
)
1829
1828
self ._invalidate_cache_and_stream (txn , self .is_partial_state_room , (room_id ,))
1830
1829
1830
+ async def write_partial_state_rooms_join_event_id (
1831
+ self ,
1832
+ room_id : str ,
1833
+ join_event_id : str ,
1834
+ ) -> None :
1835
+ """Record the join event which resulted from a partial join.
1836
+
1837
+ We do this separately to `store_partial_state_room` because we need to wait for
1838
+ the join event to be persisted. Otherwise we violate a foreign key constraint.
1839
+ """
1840
+ await self .db_pool .runInteraction (
1841
+ "write_partial_state_rooms_join_event_id" ,
1842
+ self ._store_partial_state_room_txn ,
1843
+ room_id ,
1844
+ join_event_id ,
1845
+ )
1846
+
1847
+ async def _write_partial_state_rooms_join_event_id (
1848
+ self ,
1849
+ txn : LoggingTransaction ,
1850
+ room_id : str ,
1851
+ join_event_id : str ,
1852
+ ) -> None :
1853
+ DatabasePool .simple_update_txn (
1854
+ txn ,
1855
+ table = "partial_state_rooms" ,
1856
+ keyvalues = {"room_id" : room_id },
1857
+ updatevalues = {"join_event_id" : join_event_id }
1858
+ )
1859
+
1831
1860
async def maybe_store_room_on_outlier_membership (
1832
1861
self , room_id : str , room_version : RoomVersion
1833
1862
) -> None :
0 commit comments