Skip to content

RS - Remove orphan attachments from db after a record is updated#7294

Merged
issammani merged 3 commits intomainfrom
fix/remove-orphan-attachments-on-record-update
Mar 31, 2026
Merged

RS - Remove orphan attachments from db after a record is updated#7294
issammani merged 3 commits intomainfrom
fix/remove-orphan-attachments-on-record-update

Conversation

@issammani
Copy link
Copy Markdown
Contributor

We got a user report that Firefox on iOS is taking a lot of space ( also confirmed this is happening on Android too ). We managed to narrow it down to the quicksuggest-amp.sql db in remote settings being 1GB+ in some cases. See Slack thread for more context.

This happens because whenever we update a record's attachment or tombstone a record we never clean up the orphan attachments. This should happen for all collections. I am assuming this manifested itself in quicksuggest-amp because we update it frequently.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@issammani issammani requested a review from bendk March 27, 2026 13:56
/// When the data refreshes (schema timestamp changes), the record keeps its ID but gets
/// a new attachment with a different hash/location. The old cached blob was never cleaned up.
#[test]
fn test_storage_orphaned_attachments_cleaned_up_on_update() -> Result<()> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bendk I made the tests specific to suggest just for context but let me know if it's better to just have dummy names instead.

Copy link
Copy Markdown
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

This seems good to me, but I think someone on the DISCO team should review.

@ncloudioj what do you think?

@ncloudioj
Copy link
Copy Markdown
Member

Thanks for the tag, Ben! Will defer to @gruberb for r? as he has more context on the RS client than i do. Bastian, can you take a look at this? TIA

Copy link
Copy Markdown
Member

@gruberb gruberb left a comment

Choose a reason for hiding this comment

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

Looks correct to me!

@issammani issammani added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit 7c67b3c Mar 31, 2026
14 checks passed
@issammani issammani deleted the fix/remove-orphan-attachments-on-record-update branch March 31, 2026 10:16
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.

4 participants