feat: Only track appended extremities #2356
No reviewers
Labels
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Compliance
Continuwuity/Web Interface
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Merge
Merge/Manual
Merge/Squash
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
bob the builder
No assignees
3 participants
Notifications
Due date
No due date set.
Blocks
#2371 WIP: perf: Allow building events without locking the room
continuwuation/continuwuity
#2372 WIP: fix: Perform state resolution when converging multiple DAG branches
continuwuation/continuwuity
Reference
continuwuation/continuwuity!2356
Loading…
Reference in a new issue
No description provided.
Delete branch "nex/feat/intuitive-extremity-tracking"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously, it was possible for any arbitrary event to be added to our extremity table. Now, it is only possible while appending events. This PR replaces extremity tracking in the following ways:
Basically, this PR just makes us do it right. Again.
We also get a free perf boost with lock-free timeline events, due to the non-atomicity of extremities!
TODO write a migration that drops
referencedeventsPull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
9ae7ed4db34b65a412a8@ -454,3 +454,3 @@sender_user,replacement_room_id.as_deref(),&new_room_state_lock,Some(&new_room_state_lock),I feel like you can deal with the TODO above this comment now
@ -1208,2 +1207,13 @@}pub(super) async fn room_extremities(&self, room_id: OwnedRoomId) -> Result {let mut extremities = self.services.rooms.state.get_forward_extremities(&room_id).broad_filter_map(|event_id| async move {self.services.rooms.timeline.get_pdu(&event_id).await.ok()}).collect::<Vec<_>>().await;Why not show
<failed to load PDU>or something idk, seems like a good idea in admin commands rather than filtering. Might be a later thingI originally did, but then
sort_by_keybecame complicated so I figured it was a bit pointless. Plus, the migration drops any unaccepted/unknown PDUs, and now the only way to become an extremity is to become a non-outlier, so I don't really see this being a problem anymoreFair
@ -980,0 +1048,4 @@.for_each(|(_, pdu)| {let room_id = &room_id;async move {if pdu.origin_server_ts < epoch_ts {This seems like a bad idea, given this is untrusted data and gapfill exists.
It's trusted data - incoming PDUs before this epoch have to be backfilled, and we set that epoch when joining a room. It's not possible for an event before this timestamp to be an extremity as it will be backfilled
Using the timestamp at all for a Boundary like this is ass but 1. I don't see a better solution and 2. a better solution would be out of scope
@ -431,0 +429,4 @@for event_id in event_ids {let key = (room_id, event_id);self.db.roomid_pduleaves.put_raw(key, event_id);You're writing different values in different places to this table
@ -173,3 +142,1 @@self.derive_new_state(incoming_pdu, room_version_rules, state_before, state_lock).await?;}pub async fn progress_extremities(&self, incoming_pdu: &PduEvent) -> Result<()> {Why not call this inside append_pdu to avoid events?
@ -215,0 +159,4 @@// referenced extremities that we can now remove. Doing the walk// from the prev events also means they will all automatically be// removed from the extremity set.let mut ancestors_todo = VecDeque::from_iter(incoming_pdu.prev_events.clone());This might visit the same event multiple times if the DAG is, like, diamond shaped or something.
Uhhh the only solution I can think to that is to track every event ID we walk? Or maybe
@ -238,2 +188,3 @@self.services.pdu_metadata.is_event_accepted(&prev_id),);(exists && !referenced && (is_outlier || is_soft_failed || is_rejected))(exists && !matches!(count, PduCount::Backfilled(_)) && !is_accepted)Surely this means accepted events can't get through this, so they're never removed when superseded by a soft-failed event?
Soft-failed events don't become extremities themselves, and consequently aren't supposed to be referenced either, but since soft-fails can differ between servers following a soft-fail/rejection chain can lead to accepted events that we did not mark as referenced because the ancestors were soft-failed, so this is intentional unless I'm misunderstanding?
c5dd81fc4c411114fe1e(force-push was to drop the commits now included in #2371, it does not address any review comments)
411114fe1ee894a71b85d89e4f7972cb27a2082d