Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add background job to clear unreferenced state groups #18154

Merged
merged 46 commits into from
Feb 25, 2025

Conversation

devonh
Copy link
Member

@devonh devonh commented Feb 12, 2025

Fixes #18150

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

Sorry, something went wrong.

devonh and others added 3 commits February 11, 2025 18:30

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@devonh
Copy link
Member Author

devonh commented Feb 12, 2025

I still need to add tests, but otherwise this is currently working.

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
devonh and others added 4 commits February 12, 2025 14:24

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@devonh devonh marked this pull request as ready for review February 12, 2025 23:31
@devonh devonh requested a review from a team as a code owner February 12, 2025 23:31
devonh and others added 7 commits February 13, 2025 14:56

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 13, 2025 22:06 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@devonh devonh requested a review from erikjohnston February 13, 2025 22:10
@github-actions github-actions bot deployed to PR Documentation Preview February 13, 2025 22:10 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 13, 2025 23:38 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 14, 2025 00:11 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 14, 2025 00:18 Active
@github-actions github-actions bot deployed to PR Documentation Preview February 19, 2025 20:55 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 19, 2025 21:05 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@github-actions github-actions bot deployed to PR Documentation Preview February 19, 2025 21:13 Active
Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor tweaks, otherwise I think the approach is good

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>
@github-actions github-actions bot deployed to PR Documentation Preview February 24, 2025 17:47 Active

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson

Verified

This commit was signed with the committer’s verified signature.
devonh Devon Hudson
@devonh
Copy link
Member Author

devonh commented Feb 24, 2025

Should be good to go now!

@devonh devonh requested a review from erikjohnston February 24, 2025 20:56
@github-actions github-actions bot deployed to PR Documentation Preview February 24, 2025 20:57 Active
@erikjohnston
Copy link
Member

Woop, thanks! Sorry for it going round in circles a bit

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Erik Johnston <[email protected]>
@github-actions github-actions bot deployed to PR Documentation Preview February 25, 2025 14:49 Active
@devonh devonh merged commit 5121f92 into develop Feb 25, 2025
41 checks passed
@devonh devonh deleted the devon/unreferenced-bg branch February 25, 2025 16:25
reivilibre added a commit that referenced this pull request Mar 7, 2025
This mechanism is suspected of inserting large numbers of rows into `state_groups_state`,
thus unreasonably increasing disk usage.

See: #18217

This reverts commit 5121f92.
reivilibre added a commit that referenced this pull request Mar 7, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…s introduced in v1.126.0rc1), due to a suspected issue that causes increased disk usage. (#18222)

Revert "Add background job to clear unreferenced state groups (#18154)"

This mechanism is suspected of inserting large numbers of rows into
`state_groups_state`,
thus unreasonably increasing disk usage.

See: #18217

This reverts commit 5121f92 (#18154).

---------

Signed-off-by: Olivier 'reivilibre <[email protected]>
@n-peugnet
Copy link

So, now that this has been reverted because of #18217, is there a plan to rewrite this feature? Smaller instances like ours desperately need this to continue operating. Maybe it is just a matter of doing it in batches of limited size?

@devonh
Copy link
Member Author

devonh commented Mar 17, 2025

So, now that this has been reverted because of #18217, is there a plan to rewrite this feature? Smaller instances like ours desperately need this to continue operating. Maybe it is just a matter of doing it in batches of limited size?

This feature will be fixed to avoid the issue with increasing state group state rows.

@devonh
Copy link
Member Author

devonh commented Mar 18, 2025

New PR: #18254

devonh added a commit that referenced this pull request Mar 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This PR fixes #18154 to avoid de-deltaing state groups which resulted in
DB size temporarily increasing until the DB was `VACUUM`'ed. As a
result, less state groups will get deleted now.
It also attempts to improve performance by not duplicating work when
processing state groups it has already processed in previous iterations.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [X] Pull request is based on the develop branch
* [X] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [X] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct
(run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Erik Johnston <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add background job to clear unreferenced state groups
5 participants