fix: Invalidate space hierarchy cache on room join/leave events #1524

Open
javif89 wants to merge 2 commits from javif89/continuwuity:fix/invalidate-hierarchy-cache-on-room-event into main
First-time contributor

This pull request adds SpaceRoomHierarchy cache invalidation on room join/leave events.

This change should prevent potentially dead rooms from showing up in clients, and make it easier
to make decisions based on a room's member count returned from the /[room id]/hierarchy endpoint.

I moved the roomid_spacehierarchy_cache up a level to the state_cache so it could be accessed in update_joined_count.
Otherwise we would have to invalidate the cache in any other spot where the member count might change.

Closes #1522

Pull request checklist:

  • This pull request targets the main branch, and the branch is named something other than
    main.
  • I have written an appropriate pull request title and my description is clear.
  • I understand I am responsible for the contents of this pull request.
  • I have followed the contributing guidelines:
This pull request adds `SpaceRoomHierarchy` cache invalidation on room join/leave events. This change should prevent potentially dead rooms from showing up in clients, and make it easier to make decisions based on a room's member count returned from the `/[room id]/hierarchy` endpoint. I moved the `roomid_spacehierarchy_cache` up a level to the `state_cache` so it could be accessed in `update_joined_count`. Otherwise we would have to invalidate the cache in any other spot where the member count might change. Closes #1522 **Pull request checklist:** - [x] This pull request targets the `main` branch, and the branch is named something other than `main`. - [x] I have written an appropriate pull request title and my description is clear. - [x] I understand I am responsible for the contents of this pull request. - I have followed the [contributing guidelines][c1]: - [x] My contribution follows the [code style][c2], if applicable. - [x] I ran [pre-commit checks][c1pc] before opening/drafting this pull request. - [x] I have [tested my contribution][c1t] (or proof-read it for documentation-only changes) myself, if applicable. This includes ensuring code compiles. - [x] My commit messages follow the [commit message format][c1cm] and are descriptive. - [ ] I have written a [news fragment][n1] for this PR, if applicable<!--(can be done after hitting open!)-->. [c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md [c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx [c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks [c1t]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#running-tests-locally [c1cm]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#commit-messages [n1]: https://towncrier.readthedocs.io/en/stable/tutorial.html#creating-news-fragments
fix: Invalidate space hierarchy cache on room join/leave events
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
Update flake hashes / update-flake-hashes (pull_request) Has been cancelled
e5ccee1b99
ginger left a comment
Owner

a few preliminary thoughts

a few preliminary thoughts
@ -40,7 +40,7 @@ repos:
hooks:
- id: cargo-fmt
name: cargo fmt
entry: cargo +nightly fmt --
Owner

this is supposed to use nightly

this is supposed to use nightly
Author
First-time contributor

Reverted 👍

Reverted 👍
nex marked this conversation as resolved
@ -21,8 +21,28 @@
pkgs.liburing
pkgs.rust-jemalloc-sys-unprefixed
rocksdbAllFeatures
# Pre commit support
Owner

these nix changes should go in their own PR

these nix changes should go in their own PR
Author
First-time contributor

Reverted

Reverted
nex marked this conversation as resolved
chore: Restore pre-commit config and nix shell to previous state
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m56s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 16m4s
f402aaa84d
javif89 changed title from WIP: fix: Invalidate space hierarchy cache on room join/leave events to fix: Invalidate space hierarchy cache on room join/leave events 2026-03-11 21:07:14 +00:00
javif89 requested review from ginger 2026-03-12 16:10:58 +00:00
javif89 force-pushed fix/invalidate-hierarchy-cache-on-room-event from f402aaa84d
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m56s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 16m4s
to 582e2aa9a8
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m4s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 14m52s
2026-03-15 00:55:27 +00:00
Compare
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m4s
Required
Details
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 14m52s
Required
Details
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix/invalidate-hierarchy-cache-on-room-event:javif89-fix/invalidate-hierarchy-cache-on-room-event
git switch javif89-fix/invalidate-hierarchy-cache-on-room-event
Sign in to join this conversation.
No reviewers
No milestone
No project
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!1524
No description provided.