feat(relations): Index relation types and build thread aggregations at serve-time #2519
Open
Henry-Hiles
wants to merge 10 commits from
Henry-Hiles/continuwuity:quad/feat/better-relations into main
pull from: Henry-Hiles/continuwuity:quad/feat/better-relations
merge into: continuwuation:main
continuwuation:main
continuwuation:renovate/opentelemetry-instrumentation-tower-digest
continuwuation:aranje/illegal-car-mods
continuwuation:renovate/ruma-digest
continuwuation:nex/fix/modernise-knocking
continuwuation:jade/rendevous-channel-fixes
continuwuation:nex/feat/notary-server
continuwuation:ginger/oauth-idempotency
continuwuation:renovate/nix-0.x
continuwuation:renovate/axum-server-0.x
continuwuation:renovate/built-0.x
continuwuation:jade/soundness-issues
continuwuation:jade/jemalloc-issues
continuwuation:nex/feat/mimimimimalloc
continuwuation:aranje/delete-unauthenticated-profile-media
continuwuation:nex/feat/per-room-txn-queue
continuwuation:release/26.9.4
continuwuation:nex/refactor/ruma-state-res
continuwuation:pulls/2398
continuwuation:release/v26.9.2
continuwuation:ginger/client-credentials
continuwuation:ginger/msc4322-2media2redaction
continuwuation:nex/feat/reorganise-commands
continuwuation:nex/feat/lockfree-event-builder
continuwuation:nex/fix/local-event-current-state
continuwuation:nex/feat/admin-api
continuwuation:jade/mass-rename
continuwuation:nex/feat/msc-fed-bidi-ping
continuwuation:nex/feat/centralise-remote-memberships
continuwuation:morgan/arm64-runner
continuwuation:renovate/argon2-0.x
continuwuation:next/meta/disable-ci-build-cache
continuwuation:fix/26.7.3
continuwuation:1235-add-arm-deb
continuwuation:nex/meta/release-schedule
continuwuation:nex/feat/pdu-versions
continuwuation:ginger/revert-direct-tls
continuwuation:nex/fix/federated-invite-revoke
continuwuation:nex/fix/plunger
continuwuation:jade/perf/gme-rebased
continuwuation:nex/perf/get-missing-events2
continuwuation:nex/backport/v0.5.11
continuwuation:nex/backport/v0.5.10-backport
continuwuation:nex/feat/msc4491-invite-reasons-in-room-creation
continuwuation:nex/feat/deprecated-room-versions
continuwuation:release/v0.5.9
continuwuation:nex/feat/enable-debug-log-release-builds
continuwuation:nex/feat/room-purging
continuwuation:nex/feat/room-shutdown
continuwuation:ginger/ruma-upstreaming
continuwuation:jade/tls-backends
continuwuation:ginger/email-fixes
continuwuation:jade/changelog-labels
continuwuation:nex/fix/v12-publishing
continuwuation:jade/build-info
continuwuation:jade/purge-sync-tokens
continuwuation:ginger/terms-and-conditions
continuwuation:ginger/remove-sliding-sync-proxy
continuwuation:nex/fix/pusher-association
continuwuation:ginger/email-support
continuwuation:jade/community-guidelines
continuwuation:nex/fix/federation-format
continuwuation:jade/git-deps-updates
continuwuation:jade/changelog-check
continuwuation:jade/rust-1-92
continuwuation:ginger/password-reset
continuwuation:nex/experiment/push-gateway-logs
continuwuation:ginger/msc3575-obliteration
continuwuation:nex/feat/block-busted-rooms
continuwuation:nex/fix/informative-startup-errs
continuwuation:ginger/no-left-room-initial-sync
continuwuation:jade/docker-entrypoint
continuwuation:jade/dehydrated-devices
continuwuation:ginger/complement-fixes
continuwuation:nex/fix/stale-destination-cache
continuwuation:nex/experiment/sync-mutex
continuwuation:tcpipuk/docker-docs
continuwuation:jade/snafu
continuwuation:jade/rand-update
continuwuation:nex/stateres-refactor
continuwuation:ginger/779-in-troubleshooting
continuwuation:jade/liveit-guide
continuwuation:jade/http3
continuwuation:nex/feat/admin-hide-empty-rooms
continuwuation:ginger/oobe
continuwuation:nex/fix/debian-thingy
continuwuation:jade/ldap-admin-check
continuwuation:nex/fix/remote-restricted-joins
continuwuation:nex/feat/msc4406-sender-ignored
continuwuation:jade/deadlock-detection
continuwuation:jade/get-started
continuwuation:jade/docs-guide
continuwuation:ginger/fix-local-invites
continuwuation:nex/fix/tpi
continuwuation:nex/feat/room-deletion
continuwuation:nex/feat/msc4322-media-redaction
continuwuation:ginger/stitched-order
continuwuation:ginger/deps/update-rspress
continuwuation:jade/admin-announce-improvements
continuwuation:ginger/xtask-improvements
continuwuation:jade/improve-admin-config-display
continuwuation:nex/fix/better-stateres-error-logs
continuwuation:jade/sender-timeouts
continuwuation:nex/feat/custom-v12-room-ids
continuwuation:ginger/update-metadata
continuwuation:nex/feat/admin-force-logout
continuwuation:tom/max-perf-docs
continuwuation:nex/fix/invalid-appservice-reg
continuwuation:nex/feat/antispam
continuwuation:nex/feat/account-locking
continuwuation:jade/logging-cleanup
continuwuation:jade/remove-legacy-appservice-auth
continuwuation:nex/fix/key-query
continuwuation:jade/update-prek
continuwuation:nex/fix/room-summaries
continuwuation:ginger/restrict-admin-commands
continuwuation:ginger/enable-console-by-default
continuwuation:jade/tag-fixes
continuwuation:jade/otlp
continuwuation:nex/meta/pull-req-template
continuwuation:nex/fix/fed-invite-compliance
continuwuation:nex/feat/build-commit
continuwuation:nex/feat/join-logging
continuwuation:jade/mailmap-updates
continuwuation:jade/hack-ci-tmp
continuwuation:jade/v12-stable
continuwuation:jade/relations
continuwuation:ginger/database-refactor
continuwuation:jade/fix-ldap-uiaa
continuwuation:nex/fix/validation
continuwuation:ginger/nuke-invalid-msc4133-fields-in-migration
continuwuation:ginger/downgrade-artifact-actions
continuwuation:oddlid/reload-fix
continuwuation:jade/fix-assert
continuwuation:ginger/sync-v3-cleanup
continuwuation:ginger/remove-absolute-action-urls
continuwuation:jade/website
continuwuation:nex/fix/backoff
continuwuation:ginger/fix-mdbook-for-0.5
continuwuation:ginger/no-docker-on-prs
continuwuation:backport/v0.5.0-rc.8-1
continuwuation:nex/fed-improvements
continuwuation:jade/rust-1.90
continuwuation:jade/mirror-dockerhub
continuwuation:jade/clippy-fixes
continuwuation:jade/fix-support
continuwuation:jade/clean-images
continuwuation:jade/wal-compression-type
continuwuation:jade/flake-clone
continuwuation:ginger/upload-rpms-on-schedule
continuwuation:nex/fix/incoming-fetch
continuwuation:nex/fix/upgrade
continuwuation:tom/ci-fedora-rpm
continuwuation:jade/ci-release-fix
continuwuation:jade/rocksdb-10-5
continuwuation:ginger/fix-msc4133-migration
continuwuation:ginger/migrate-busted-tz
continuwuation:hydra/public
continuwuation:nex/feat/manual-extremities
continuwuation:nex/feat/async-media
continuwuation:nex/feat/fast-joins-hack-do-not-use-DO-NOT-USE
continuwuation:nex/feat/better-logging
continuwuation:trigger-ci-so-latest-isnt-on-illegal-car-mods
continuwuation:nex/feat/pins-backfill
continuwuation:jade/tuwunel-2025-06-old
continuwuation:jade/ai-slop-db-docs
continuwuation:nex/fix-create-auth
continuwuation:jade/version-stats
continuwuation:jade/read-receipts
continuwuation:jade/rust-toolchain-no-targets
continuwuation:jade/logging-features
continuwuation:jade/syncv5-typing
continuwuation:jade/msc2815
continuwuation:morguldir/see-eye
continuwuation:jade/css-small-screen
continuwuation:nex/wip-751
continuwuation:tuwunel-rebase
continuwuation:test
continuwuation:oddlid/rename-admin-room-bot
continuwuation:strawberry/nix-ci-stuff
continuwuation:strawberry/valgrind
continuwuation:phonemain
continuwuation:strawberry/morgs-snake-sync-jason-main
continuwuation:newer-media-endpoints
continuwuation:folly-coroutines-async-io
continuwuation:federation-retry-timer-port
continuwuation:bad-attempt-at-extracting-homeserver-signing-key
continuwuation:room-deletion-attempt-do-not-use
No reviewers
Labels
Clear labels
Abandoned
This pull request appears to be abandoned by its author.
Blocked
This pull request or issue is currently blocked from being merged/closed
Bug
Something isn't working as intended
Changelog
Added
Changelog entry added
Changelog
Missing
No changelog when one is needed
Changelog
None
Changelog is unnecesary for this change
Cherry-picking
Commits picked from other conduit projects
Compliance
This item pertains to spec compliance
Database
This requires or includes changes to the database
Dependencies
Something dependency related
Dependencies/Renovate
Automatic dependency upgrades by Renovate
Difficulty
Easy
Low difficulty to implement - touches few parts of the codebase, low complexity
Difficulty
Hard
High difficulty to implement - touches many parts of the codebase, high complexity
Difficulty
Medium
Medium difficulty to implement - touches more parts of the codebase, higher complexity
Documentation
Improvements or additions to documentation
Enhancement
New feature or request
Good first issue
Good for newcomers
Help wanted
Additional eyes and keyboards are required for this one
Inherited
Issues that have been inhereted from the project pre-fork
Matrix/Administration
Features pertaining to homeserver administration
Matrix/Appservices
Features pertaining to the appservice API
Matrix/Auth
Features pertaining to authentication
Matrix/Client
Features pertaining to client-to-server interactions
Matrix/Core
Issues relating to core matrix functionality, such as state resolution and PDU formats
Matrix/E2EE
Issues related to end to end encryption
Matrix/Federation
Features pertaining to server-to-server interactions
Matrix/Hydra
Issues related to room version 12 and related changes (temporary label)
Matrix/MSC
Features pertaining to unstable matrix features
Matrix/Media
Features pertaining to media interactions
Matrix/T&S
Changes or issues related to trust & safety tooling
Merge
This PR is ready to be merged
Merge/Manual
This PR should be manually merged
Merge/Squash
This PR should be squashed when it is merged
Meta
Related to housekeeping, maintenance, or other repo-meta.
Meta/CI
Issues related to CI changes
Meta/Packaging
Packaging
Priority
Blocking
This issue is blocking the next release
Priority
High
This issue is very important
Priority
Low
This issue is of a rather low priority
Security
This item is related to general security
Status
Confirmed
This issue has enough information and is confirmed
Status
Duplicate
This issue or pull request already exists
Status
Invalid
This issue doesn't seem right
Status
Needs Investigation
This issue needs further investigation
Support
Questions or support requests
bob the builder
pdu logic rewrite starring nexus nicholson
Archived
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Compliance
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
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
continuwuation/continuwuity!2519
Loading…
Reference in a new issue
No description provided.
Delete branch "Henry-Hiles/continuwuity:quad/feat/better-relations"
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?
This should improve performance, and also will remove the unsigned aggregation data from DBs.
With this, plain replies are no longer returned by /relations and current_user_participated is now real. This is correct according to spec.
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
bd131220b460ff0c9caaNow running this on https://federated.nexus, will get back here with updates on if everything went well in the morning.
would be nice to have a test on the recursive path with a filter, and a note in the description that plain replies are no longer returned by /relations and current_user_participated is now real
@ -956,0 +1037,4 @@let mut pdus = std::pin::pin!(timeline.all_pdus(&room_id));while let Some((_, pdu)) = pdus.next().await {if purged_unsigned(&pdu).is_some() {if let Ok(pdu_id) = timeline.get_pdu_id(pdu.event_id()).await {nit: all_pdus already gives the count, so the id can be built from it instead of a lookup per candidate
@ -85,0 +132,4 @@room_id: ShortRoomId,replies: &[u64],) -> Option<BundledThread> {let mut latest = None;no user_can_see_event check here unlike the m.replace path, so latest_event can be one the user can't see. not a regression, but cheap to do now that it's built per user
@ -114,0 +206,4 @@target,PduCount::min(),Direction::Forward,rel_type,Filtering here prunes the walk, so recurse=true + rel_type no longer finds e.g. reactions on thread replies . same thing for the event_type filter at L222. i think we should walk unfiltered and filter once at the end
@ -220,6 +102,45 @@ impl Service {self.update_participants(&root_id, &users)this pushes without dedup so the list grows by one per reply, and is_participant now reads it every time a root is served. can we dedup here? line 100
@ -75,0 +70,4 @@if let Some(relation) = &relation {self.services.pdu_metadata.deindex_relation(relation, &pdu_id)if replace_pdu fails below, the event stays unredacted but is gone from the index. maybe deindex after it?
I haven't added a test, I haven't done those in Rust before so I don't know how it'll look like, but I will try to make one.
I've done the rest of the feedback.
Oops i pushed a version where I had started the test, its not compiling. One moment.
31583714b3346eed8a4d346eed8a4d1356ecc1b2Okay, should now be good for re-review :)
Test has been added, hopefully it's good.
bea9c5afa58c75cb6bac@ -0,0 +16,4 @@#[tokio::test]async fn recursive_relations_find_nested_annotation_through_filter() {let (services, _path) = test_services().await;nit: the temp db dir is never removed here, the other test does remove_dir_all(path) at the end
8c75cb6bac9380a7ce7a9380a7ce7a806fa956f8806fa956f8037a829df7037a829df7d9d6ccee4dd9d6ccee4dd75a73870bView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.