Repository navigation
fix(store): forgetting a user leaves nothing of theirs in the recorded changes, and an import naming another customer's row is refused - #2221
Conversation
b3f63d6 to
49da1e5
Compare
kanat
left a comment
There was a problem hiding this comment.
Reviewed 49da1e5 merged onto main 1c87c73. CI on the head is green, but it ran before #2189 merged. On the merged tree, TestDataMoveSuite/TestAnImportedRequestWhoseUsageIDAnotherCustomerHoldsIsRefused fails (R1.1). The merges with #2201 and #2208 are clean and add no other failure.
Checked and sound: the copies' changes are deleted on every shard, in the same statement as the rows. The campaigns' changes are deleted in the forget's transaction. Another user's changes, the replacement's changes and the delete changes stay. Re-importing the importer's own rows (including requests under derived usage ids, and logs moved back) is not refused. Mutations: 17 checked, 7 survived (R1.4), 2 equivalent.
Verdict: request changes, for R1.1 (the merged tree fails a test) and the Should fix items R1.2 (forgetting a user of one app expires another app's move cursor), R1.3 (a late request of the forgotten user loses its change) and R1.4 (surviving mutants).
49da1e5 to
9da9a43
Compare
kanat
left a comment
There was a problem hiding this comment.
Reviewed 9da9a43, merged onto main 1c87c73 (the branch is rebased on it, so no merge was needed). CI is green. Verdict: not yet. One new Should fix, R2.1, in code this round added. Everything from round 1 is fixed or ticketed.
Prior findings
- R1.1 fixed.
TestARequestWhoseIDsAnotherCustomerHoldsHereLandsBesideTheirspasses on the merged tree and the body no longer claims requests are refused. - R1.2 fixed. Nothing is deleted from
data_changesany more. Probe: another app's follower, current at its export cursor, still reads its change after the forget (Store and Sharded suites). - R1.3 fixed. Probe: a request inserted between
RenameUserand the forget keeps its row and its change. - R1.4 fixed. The 7 mutants are killed (F2, B1, S1, D3, D4, D5; F5's table set no longer exists, and the same mutation on its table check is equivalent).
- R1.5 and R1.6 are in AI-3602 (Marcelo's replies). They do not block.
Redaction, not deletion. Confirmed: renamedChanges and forgottenCopies are UPDATEs of data_changes, the sequence numbers stay, and a copy's insert and update become payload-free deletes. datamove.go is unchanged since round 1. Of the other mutants I added (CTE not attached in RenameUser, Sessions.Delete and DeleteUser; the user id set to itself; payload not emptied; op not set; the session filter dropped), all were killed.
Suites. The store, sharded and data-move suites pass on the head. Only TestEveryHotTableIsReadByIndex fails here (5 subtests, planner choice on this machine). The same 5 fail on main 1c87c73, and CI's integration (store) passes.
…d changes, and an import naming another customer's row is refused - Requests.RenameUser and ForgetUserSettings rename the user in every recorded change of the app's requests and campaigns that names them, deleted rows' included, in the same statement as the rewrite. A request recorded after the statement keeps its change. - BranchMessages.DeleteUser and Sessions.Delete turn the recorded inserts and updates of the copies they delete into deletes that carry nothing. The copy's own delete change stays. - Every change keeps its number, so no follower of any app is told to export again. - importRow returns ErrAnotherCustomersRow when it wrote nothing because another customer holds the row's key here, instead of dropping the row. A re-import of the importer's own row is still a no-op.
9da9a43 to
4a52396
Compare
kanat
left a comment
There was a problem hiding this comment.
Verdict: GO. Reviewed 4a52396 (merged onto current main 31fd2dd, clean).
Prior findings
- R2.1 fixed. Both
key->>'id' IN (...)clauses are gone (forget.go:134,request.go:724), so a campaign or request deleted before the forget orRenameUserkeeps no change naming the user. The two new tests,TestForgettingAUserRenamesThemInTheChangesOfACampaignDeletedBeforeandTestRenamingAUserRenamesThemInTheChangesOfARequestDeletedBefore, pass. I put each clause back in a scratch copy and the matching test failed. The request test skips on the sharded suite, as it should. Dropping the customer, table or user filter fromrenamedChangesfails a test each. - R1.1 to R1.4 stay fixed. The earlier probes for P1, P2, B1, S1, F2, D3, D4 and D5 all pass on this head.
- R1.5 and R1.6 stay with ticket AI-3602 and do not block.
What changed since round 2. I compared the PR patch of 9da9a43 with that of 4a52396, line by line. They differ only by the two removed clauses, the two new tests and reworded comments. The rest is identical.
Tests. I ran the Store, ShardedStore and DataMove suites on this head merged onto main. Only TestEveryHotTableIsReadByIndex fails (five subtests, the planner picks another index on my machine). The same five failed on main in round 2, and CI integration (store) passes. gofmt and go vet are clean. CI is green on all checks.
Mutations. 5 checked, 0 survived.
One nit, inline, does not block.
kanat
left a comment
There was a problem hiding this comment.
Approving on the reviewer's GO (findings in the review comments above).
…copes' policies, and forget cached rows a move wrote (#2227) **Problem** `deleteRow` matched a replayed delete on every primary key column, the customer column included, so for `users`, `scheduled_tasks`, `customer_activity` and the app's `policies` a delete replayed under another app id matched nothing. A policy change is recorded under its scope id whatever its scope, so the change feed listed an organization's policy sharing the app's id, and the replay wrote it as the app's. `ImportRow` and `ApplyChanges` dropped no cached rows, so configs, skills, voices and policies they wrote were served stale until the cache TTL. **Fix** - `deleteRow` leaves the customer column out of the key conditions; the destination's customer condition still scopes the delete. - `Changes` lists a `policies` change only when its key's scope is `app`, filtered before the limit so a page stays full and `caught_up` holds. `applyChanges` replays only those too, for changes from a source without the filter. - `importRow` and `deleteRow` collect the cache keys of the row as it reads after and before the write, so a rename drops the old name too. Only a delete from a cached table returns its row. `ImportRow` forgets the keys after its statement, `ApplyChanges` after its transaction commits, using the existing key functions and `forget`. - The second expiry check in `Changes` is left for a separate change. - Conflicts with #2221 and #2201 near the end of `importRow`; either merge order needs only a small rebase. **Tests** Each failed before its fix, except `TestAnAppsPolicyChangeIsReplayed`, which guards the scope filter. - `TestADeletedTaskIsReplayedUnderTheIDTheAppMovedTo`: a delete replayed under another app id removes that task and keeps its sibling. - `TestChangesCarryNoOrganizationsPolicyOfTheAppsID`: the feed leaves the organization's policy out and still fills the page. - `TestAnOrganizationsPolicyIsNotReplayedOverTheAppsOfTheSameID`: an organization's policy change leaves the app's as it was. - `TestAPolicyChangeNamingNoScopeIsNotReplayed`: a change with no scope in its key is not replayed. - `TestAnAppsPolicyChangeIsReplayed`: an app's own policy change still lands. - `TestAnImportedConfigIsServedRightAfterTheImport`: a cached missing config is dropped by an import. - `TestAConfigImportedWithANumericNameIsServedRightAfterTheImport`: the same for an id sent as a number. - `TestARouterConfigImportedIsServedRightAfterTheImport`: the same for a router config. - `TestAVoiceImportedIsServedRightAfterTheImport`: the same for a voice. - `TestAnImportedPolicyIsServedRightAfterTheImport`: the same for an app policy. - `TestAnImportedPolicyDecidesTheAppsRequestsRightAfterTheImport`: the app's merged policies are dropped too. - `TestAReplayedConfigChangeIsServedRightAfterIt`: a replayed update is served at once. - `TestAReplayedRouterConfigChangeIsServedRightAfterIt`: the same for a router config by id. - `TestAReplayedVoiceChangeIsServedRightAfterIt`: the same for a voice by id. - `TestAReplayedSkillChangeIsServedRightAfterIt`: the same for a skill. - `TestAConfigRenamedByAReplayIsNoLongerServedByItsOldName`: a replayed rename drops the old name. - `TestAConfigDeletedByAReplayIsNoLongerServed`: a replayed delete drops the config. - `TestAPolicyDeletedByAReplayIsNoLongerServed`: a replayed delete drops the app's policy. - `TestACursorPastAnOrganizationsPolicyLeftOutIsNotExpiredByItsPruning`: a page that leaves out an organization's policy still moves the cursor past it, so pruning that change does not expire the follower. - `TestAFullPageOfChangesResumesAfterItsLastChange`: a full page ends at its last change and skips nothing. - `TestARunWhosePageCarriesNoChangeStillMovesItsCursor`: `follow` saves the newer cursor from an empty page. - `TestASkillMovedByAReplayLeavesItsOldConfig`: a skill moved to another config is no longer served from the old one. - `TestAVoiceRenamedByAReplayIsNoLongerServedByItsOldName`: a replayed voice rename drops the old name. Part of AI-3495
Problem
Forgetting an end user rewrote or deleted their rows but left the changes
data_changeshad recorded of those rows, soGET /v1/data/changesstill served the user's id and the words of their hidden messages until the retention prune. Separately,importRowresolved a conflict on a table's key with an update guarded by who holds the row, so an imported row whoseidanother customer already held here was dropped without an error.Fix
Requests.RenameUserandForgetUserSettingsreplace the user's id with the replacement in every recorded change of the app's requests and campaigns that names them, deleted rows' included, in the same statement as the rewrite. A request recorded after the statement, which a later forget-user run rewrites, keeps its change.BranchMessages.DeleteUserandSessions.Deleteturn the recorded inserts and updates of the copies of hidden messages they delete into deletes that carry nothing. The copy's own delete change stays, so a move still removes it.Changesrefuses a cursor below the oldest change kept of any customer, so deleting one would send other apps' followers back to a full copy.importRowreturnsErrAnotherCustomersRowwhen it wrote nothing and another customer holds the row's key. An import or an applied change stops there with a 400 where it used to skip the row. Re-importing the importer's own row still succeeds. A request is not refused this way: since fix(store): give an imported request a usage id of the importing deployment's #2189 an imported request takes a usage id of this deployment's, so it lands beside the other customer's row.Tests
Each failed before its fix:
TestForgettingAUserRenamesThemInTheChangesRecordedOfTheirCampaigns: another app's change under the same campaign id and user id stays.TestForgettingAUserRenamesThemInTheChangesOfTheRequestsRewrittenAlone: a late request and a session keep their changes.TestForgettingAUserRenamesThemInTheChangesOfACampaignDeletedBeforeandTestRenamingAUserRenamesThemInTheChangesOfARequestDeletedBeforeTestForgettingAUserOfOneAppLeavesAnotherAppsFollowerWhereItWas: another app's follower is not expired.TestForgettingAUserEmptiesTheChangesRecordedOfTheirCopies: covers the copy's delete change, change numbers and a call of the session.TestForgettingAUserAfterTheirSessionWasDeletedLeavesNoChangeOfItsCopiesTestAnImportCannotOverwriteAnotherCustomersRow, andTestAReplayedChangeCannotDeleteAnotherCustomersRowfor a replayed insert.These fail under a broken check rather than before the fix:
TestARequestWhoseIDsAnotherCustomerHoldsHereLandsBesideTheirsTestALogTakenBackWhereItCameFromIsNotRefusedOverAnotherAppsLogWithItsCopysIDTestReimportingTheImportersOwnRowsIsTheSameAsImportingThemOncePart of AI-3485