Scope clear_search_records to the account being destroyed#2847
Merged
flavorjones merged 1 commit intomainfrom Apr 16, 2026
Merged
Scope clear_search_records to the account being destroyed#2847flavorjones merged 1 commit intomainfrom
flavorjones merged 1 commit intomainfrom
Conversation
Account::Searchable#clear_search_records called Search::Record.for(id).destroy_all which deleted every row in the shard's table, wiping search records belonging to every other account that happened to hash to the same shard. ref: https://3.basecamp.com/2914079/buckets/27/card_tables/cards/9782824728
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes account incineration so clearing sharded Search::Record entries only deletes records belonging to the account being destroyed, preventing cross-account data loss when multiple accounts hash to the same shard.
Changes:
- Scope
Account::Searchable#clear_search_recordstowhere(account_id: id)beforedestroy_all. - Add a regression test that simulates a shard collision and asserts only the doomed account’s search records are removed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/models/account/incineratable_test.rb | Adds coverage ensuring incineration only clears the account’s own sharded search records while preserving others on the same shard. |
| app/models/account/searchable.rb | Fixes the deletion query to be account-scoped within the shard to avoid wiping other accounts’ search records. |
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Account::Searchable#clear_search_records called
Search::Record.for(id).destroy_all which deleted every row in the shard's table, wiping search records belonging to every other account that happened to hash to the same shard.
ref: #2804
ref: https://3.basecamp.com/2914079/buckets/27/card_tables/cards/9782824728