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

Account Purger Improvements #25120

Merged
merged 3 commits into from
Sep 29, 2018
Merged

Account Purger Improvements #25120

merged 3 commits into from
Sep 29, 2018

Conversation

islemaster
Copy link
Contributor

@islemaster islemaster commented Sep 28, 2018

We had an automated account purge fail today, so I took a look and came up with some improvements for the process.

Delete orphaned CensusSubmissionFormMap records
This caused an automated account purge to fail today with the following error:

Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails
(
  `dashboard_production`.`census_submission_form_maps`, CONSTRAINT `fk_rails_...`
  FOREIGN KEY (`census_submission_id`) REFERENCES `census_submissions` (`id`)
):
DELETE FROM `census_submissions`
WHERE `census_submissions`.`type` IN ('Census::CensusHoc2017v3')
AND `census_submissions`.`id` = <redacted>

This is a simple join table and there's no reason to keep these rows around if the CensusSubmission is actually being deleted, so I'm updating the account purger to also delete these rows.

Fix QueuedAccountPurge::resolve! for soft-deleted user
When I tried to use QueuedAccountPurge.resolve! to re-run the purge after manually addressing the particular situation, something about paranoia caued the user association to come back nil for QueuedAccountPurge when the user is soft-deleted... which is a fairly common scenario, and one we should handle. Fixes that code up to be resilient against this case.

Delete multiple EmailPreference in a single query
This was nextdoor to a previous change, is well covered by tests, and is a small performance improvement.

Something about paranoia caued the user association to come back `nil` for QueuedAccountPurge when the user is soft-deleted... which is a fairly common scenario, and one we should handle.
This caused an automated account purge to fail today with the following error:

```
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`dashboard_production`.`census_submission_form_maps`, CONSTRAINT `fk_rails_...` FOREIGN KEY (`census_submission_id`) REFERENCES `census_submissions` (`id`)): DELETE FROM `census_submissions` WHERE `census_submissions`.`type` IN ('Census::CensusHoc2017v3') AND `census_submissions`.`id` = <redacted>
```

This is a simple join table and there's no reason to keep these rows around if the CensusSubmission is actually being deleted, so I'm updating the account purger to also delete these rows.
@islemaster islemaster merged commit d30252f into staging Sep 29, 2018
@islemaster islemaster deleted the account-purge-fixes branch September 29, 2018 00:33
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.

None yet

2 participants