fix: clear every actor-owned table in reset_actors! - #31
Merged
Conversation
The helper deleted instances and processes and left the other seven tables to the database cascade. That cascade is not enforced everywhere: SQLite has to be asked for foreign keys, MySQL has to be on InnoDB, and a host application may have stripped the constraints out of the copied migration. Where it does not fire, rows survive a reset with an instance_id pointing at nothing and the next test reads them as its own. Reported as reminders leaking, and reminders are where it surfaces first because they outlive the message that created them, but the same reset left messages, ready and claimed mailbox rows, effects, broadcasts, and dead letters behind too. Deleting each table explicitly costs nothing and removes the dependency on referential integrity. Order is children before parents so it is correct whether or not the cascade fires. The existing test asserted only that instances and processes were empty, which is the same blind spot one level up. It now populates every actor-owned table, resets with foreign keys switched off so the cascade cannot cover for an incomplete list, and separately asserts the list covers every Solid Objects table so a table added later cannot be omitted silently.
Greptile SummaryThe PR makes
Confidence Score: 5/5The PR appears safe to merge; the explicit cleanup order matches the current foreign-key relationships and covers every actor-owned table. The reset helper deletes dependent rows before their parents, handles process rows after all restrictive references are removed, and includes regression coverage for databases where cascades are not enforced. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[reset_actors!] --> B[Reset caller process]
B --> C[Delete dead letters]
C --> D[Delete claimed and ready messages]
D --> E[Delete broadcasts, effects, and reminders]
E --> F[Delete messages]
F --> G[Delete instances]
G --> H[Delete processes]
Reviews (1): Last reviewed commit: "fix: clear every actor-owned table in re..." | Re-trigger Greptile |
Merged
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.
Fixes the reported test-isolation gap. Confirmed, and it is wider than reminders.
What the helper did
Two tables deleted, seven left to the database cascade. Every actor-owned table has an
on_delete: :cascadeforeign key tosolid_objects_instances, so on a database that enforces it the cascade removes the rest and the helper looks complete.It is only complete where referential integrity is enforced. SQLite has to be asked for foreign keys, MySQL has to be on InnoDB, and a host application may have stripped the constraints out of the copied migration, which is standing policy in some shops. Where the cascade does not fire, rows survive a reset with an
instance_idpointing at nothing, and the next test that reads them sees another test's data.Reproduced
With
PRAGMA foreign_keys = OFF, matching a host application whose database does not enforce the cascade:That is exactly the described state: a reminder whose
instance_idpoints at nothing.It was not only reminders
Restoring the old two-line body with the new test in place shows what actually survived:
Reminders are simply where it surfaces first, because they outlive the message that created them and a suite is likely to assert on them directly. Leftover dead letters or claimed mailbox rows would have been just as capable of failing a test by order.
The fix
reset_actors!deletes each actor-owned table itself, children before parents so the order is correct whether or not the cascade fires. A test helper has no reason to depend on referential integrity.Tests
The existing test asserted only that instances and processes were empty, which is the same blind spot one level up: it could not have caught this. Two new tests:
Validation
bundle exec rake(SQLite)The foreign-key test skips on MySQL and PostgreSQL, which is the extra skip in those columns. Disabling enforcement there needs either a session-wide switch or superuser rights, and the fix is adapter independent, so the SQLite run carries it.
No version bump. The changelog entry sits under
Unreleased, matching the separate release-prep workflow. Note that PR #30 is also open with anUnreleasedentry, so whichever merges second will want a trivial changelog merge.