Outbound group sessions are invalidated upon reception of a duplicate state event
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với update_state() trong mautrix/client/state_store/abstract.py và phần đăng ký của nó trong mautrix/client/client.py, sau đó lần theo handle_member_event() trong mautrix/crypto/machine.py và phần đăng ký của nó ở đó. So sánh các đường dẫn tải và so sánh đồng thời với các commit được tham chiếu. Được xem là hoàn tất khi các sự kiện Membership trùng lặp không còn làm mất hiệu lực các phiên nhóm gửi đi, trong khi các thay đổi trạng thái thực sự vẫn làm như vậy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Mautrix uses lazy membership loading, which causes synapse to oftentimes send state events to the client, that the client has already received. Upon reception of a state event, mautrix invalidates all outbound group sessions. This is the correct thing to do, but because synapse frequently sends duplicate state events, mautrix invalidates outbound group sessions all the time.
A fix for this has first been implemented in 72fb0f61f2a8cf8f062ddb8bacaa98ef4cbd0aa5. This fix relies on storing the most recent membership event as an attribute of the event and then later comparing this stored event to the received event and ignoring the received event if they are equal:
https://github.com/mautrix/python/blob/3e22e6192e2a9d208b9e7ea159b2169daa60a1ce/mautrix/client/state_store/abstract.py#L146-L148
https://github.com/mautrix/python/blob/3e22e6192e2a9d208b9e7ea159b2169daa60a1ce/mautrix/crypto/machine.py#L193-L200
The problem is, that loading the most recent membership event and comparing the stored membership event happens in different event handlers, which are executed concurrently.
The most recent membership event is loaded in the update_state() event handler, which is registered here:
https://github.com/mautrix/python/blob/3e22e6192e2a9d208b9e7ea159b2169daa60a1ce/mautrix/client/client.py#L31
Comparing the received membership event against the most recent one happens in handle_member_event(), which is registered here:
https://github.com/mautrix/python/blob/3e22e6192e2a9d208b9e7ea159b2169daa60a1ce/mautrix/crypto/machine.py#L109
While the update_state() handler is executed first, execution is interrupted once the most recent membership event is loaded via await self.get_member(), as this loads the event from the database, which takes some time. In the meantime, handle_member_event() becomes active and attempts to compare the received membership event against the most recent one, which hasn't yet been loaded from the database. As a result, the comparison fails and the outbound session is invalidated.
I implemented a hacky fix for this in https://github.com/jkhsjdhjs/mautrix-python/commit/e7c1921fb8f52549baf09ed2784fe46573964911, as I don't know a good way to fix this properly.
- Ngôn ngữ chính
- Python
- Star
- 249
- Fork
- 84
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mautrix/python
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Tất cả issue của mautrix/python
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100