WIP: fix: Perform state resolution when converging multiple DAG branches #2372
Draft
nex
wants to merge 1 commit from
nex/fix/local-event-current-state into main
pull from: nex/fix/local-event-current-state
merge into: continuwuation:main
continuwuation:main
continuwuation:ginger/msc4198
continuwuation:jade/search-pdu-count
continuwuation:ginger/msc4322-2media2redaction
continuwuation:ginger/client-credentials
continuwuation:aranje/illegal-car-mods
continuwuation:ginger/track-push-failures
continuwuation:nex/feat/selective-ignores
continuwuation:renovate/opentelemetry-instrumentation-tower-digest
continuwuation:nex/feat/per-room-txn-queue
continuwuation:renovate/axum-server-0.x
continuwuation:ginger/oauth-idempotency
continuwuation:nex/feat/notary-server
continuwuation:nex/fix/modernise-knocking
continuwuation:jade/rendevous-channel-fixes
continuwuation:jade/soundness-issues
continuwuation:jade/jemalloc-issues
continuwuation:nex/feat/mimimimimalloc
continuwuation:aranje/delete-unauthenticated-profile-media
continuwuation:release/26.9.4
continuwuation:nex/refactor/ruma-state-res
continuwuation:pulls/2398
continuwuation:release/v26.9.2
continuwuation:nex/feat/reorganise-commands
continuwuation:nex/feat/lockfree-event-builder
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
Continuwuity/Web Interface
Features pertaining to the Continuwuity web interface.
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
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
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Depends on
#2356 feat: Only track appended extremities
continuwuation/continuwuity
#2371 WIP: perf: Allow building events without locking the room
continuwuation/continuwuity
Reference
continuwuation/continuwuity!2372
Loading…
Reference in a new issue
No description provided.
Delete branch "nex/fix/local-event-current-state"
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 pull request fixes a bug where the local state may drift in complex rooms when creating local events (which was exacerbated by the introduction of dummy event squashes).
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
I don't know if we can merge this as is. Using this, paired with #2356, I've noticed the server is now as resilient to state resets as one would expect, but only when operating with new data. However, it has highlighted a separate problem: it would appear that many of the state snapshots in my database is storing incorrectly resolved state, mostly due to now resolved bugs. The problem is, there's no easy way to fix this from what I can tell - while it would technically be possible to re-calculate the state before each event in the database and quietly fix all of the existing records, that stops being feasible when you have potentially seven figures of events in your database, and is also questionable in integrity anyway. My database is from before we even had rejection support, so successfully migrating my db would require not only scanning all 20 gigabytes of PDUs, but also re-calculating the rejection status of every event in the database; this would also mean un-soft-failing every single event in the database, as that check is one that cannot be replayed offline as it requires point-in-time knowledge of room extremities during evaluation.
I suspect adding a command to delete rooms is the correct course of action here, as the only safe way to properly correct corrupted data in this scenario is to do a complete recalculation, which deletion would enforce. However, my concern is more user-facing: we're going to have to tell users, for possibly months, to just delete rooms if they encounter a reset like I frequently run into with this patch. This is, in my eyes, unacceptable, as this causes a loss of history, and may even mean some rooms become permanently inaccessible.
Can't fully reply to this now, but reminders for later:
My concern is more-so that this means there's memberships and such that are soft-failed that shouldn't be as a result of this drift, and as far as I can tell there's no way to heal that without the affected users updating their profiles or something
How many entries do you have in your
shortstatehash_statedifftable? I have about 900k, which is certainly not a small number, but is not entirely out of the realm of reasonability either.Soft-failed state can still be sent down sync AFAIK, it just can't have context grabbed on it because it's not in the timeline
@ginger wrote in #2372 (comment):
You have more than me 🤨 I've only got 43k (3.5GiB) and 197k PDUs (
pduid_pdu)!admin query raw raw-count shortstatehash_statediff
Query completed in 207.227145286s:
5,176,701
idk how you are counting though
@nex wrote in #2372 (comment):
43k seems pretty reasonable for a long-running migration. I dunno about aranje's five million, though.
Just checked, continuwuity.rocks also has 300k rows. I don't know why my 3-4 year old homeserver has a fraction of the rows of a homeserver about half as old as the project, but I'm sure that's fine and not indicative of my database being boned or anything
Okay nevermind, the database stats command is just lying
if I run !admin debug database-stats -m shortstatehash_statediff
my sum is 5.86GB and 1935K sum key-in column
Fednex:
!admin query raw raw-count shortstatehash_statediff->2939311So 2.9 million here.
demilestoning since the migration needs to be worked out
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.