Repository navigation
fix(store): carry opt-outs in a data move, keeping the destination's live ones - #2201
Conversation
3386eb6 to
417783f
Compare
417783f to
99be289
Compare
kanat
left a comment
There was a problem hiding this comment.
Round-1 review at 99be289, merged onto main 19da294.
CI: all 13 checks pass. On the merged tree these suites pass: store DataMoveSuite (201), the opt-out tests in StoreSuite, api DataMoveSuite (36) and the cmd/router TestReplicate* suites (74).
[Question] R1.4 (watchDataChanges, datamove.go:1841): after a rollback, the change trigger stays attached to opt_outs. A source on the previous release then serves opt_outs changes. A destination on the previous release fails the whole change batch with "opt_outs" is not a table an export carries. An export from this release into a destination on the previous release fails the same way. This fails closed, and every earlier dataTables addition has the same property. Should the rollback runbook drop the trigger? Found by reading the code; not probed.
Checked and sound:
- STOP→START→STOP replayed through the changes leaves the recipient opted out, also when the changes overlap a copy that already holds them.
- A START from the source lifts a moved copy, and leaves an opt-out recorded here alone.
- Another app's row under the same id is left alone.
orderis read only byselectRows, and the SQL for every other table is unchanged.- The trigger is attached at startup, so no migration is needed.
- Mutations: 12 checked, 5 survived. One survivor is equivalent; the other four are in R1.1.
Verdict: request changes, for R1.1 and R1.2 (Should fix).
|
On R1.4: I'd leave the runbook alone. As you say, it fails closed. The old release refuses the whole batch, so nothing is written wrong or lost; the move just can't run across mixed releases until both sides run this one. Every earlier I'm fixing R1.1 to R1.3 now and will reply on each thread once they're pushed. |
99be289 to
89c0c34
Compare
kanat
left a comment
There was a problem hiding this comment.
Delta round 2, head 89c0c34 (rebased onto main f03b4a2): NO-GO until R2.1 is fixed. R1.1 to R1.3 are fixed. One new Should fix in the new API test.
Prior findings:
- R1.1 fixed. I reran M6 (revoked rows skipped), M8 (no channel), M9 (no recipient) and M10 (no customer) on this head. Each now fails one of the new or extended tests.
- R1.2 fixed.
HoldingTableskipsopt_outs. Reverting the skip failsTestAnAppHoldingOnlyAnOptOutImportsWithoutFullwith the 409. See R2.1 for that test. - R1.3 fixed. The conflict guard keeps recipient and channel. Removing either check, applying it only to live rows, or applying it only to revoked rows fails
TestAnImportedRowUnderTheIdOfAnOptOutHereLeavesItsRecipientOptedOut. - R1.4 stays a ticket, not blocking.
10 mutations checked, 0 survived. TestDataMoveSuite (store and api) and TestReplicate pass. gofmt and vet are clean. CI at this head shows all green.
New finding: R2.1 inline. Everything else in the delta looks right.
…y keeps a new STOP
… imported row keeps an opt-out here on its recipient
…row makes it held
89c0c34 to
cb3f59f
Compare
kanat
left a comment
There was a problem hiding this comment.
Delta round 3: GO at cb3f59ff0
- R2.1 fixed.
TestAnAppHoldingOnlyAnOptOutImportsWithoutFullnow imports into a fresh app, so nocustomer_activityrow makes the app count as holding data.- It passed 30 of 30 runs (
-count=30). - With the
opt_outsskip inHoldingTablereverted (N1), it failed 5 of 5 runs, so the test pins the skip.
- It passed 30 of 30 runs (
- No other change. The other five commits are identical to the reviewed ones (
git range-diff: all=); only the rebase ontomainmoved them. - R1.1–R1.3 were fixed in round 2. R1.4 (dropping the trigger after a rollback) becomes a ticket and does not block.
- CI:
go,integration (api)andintegration (router)were still pending when I checked. Everything else passes.
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
opt_outswas not indataTables, soGET /v1/data/exportandGET /v1/data/changesleft it out. After an app moved, a recipient who had texted STOP was no longer opted out at the destination and could be reached again.Fix
opt_outsis indataTables, so the export carries it and the change-feed trigger records later STOP and START messages.importRowskips an imported live opt-out when the destination already has a live one for the same recipient and channel under another id, so the partial unique index holds and the destination's row stays.HoldingTableskipsopt_outs: the import keeps a live opt-out at the destination, so an app holding only opt-outs still imports withoutfull(POST /v1/data/import,router replicate).opt_outsis inimportedModels(from fix(store): validate imported rows and force what a request counts against #2181), so an imported opt-out is refused withOptOut.Validate's error, as the API refuses it.opt_outsrevoked rows first (orderondataTable, used byselectRows). Otherwise a second copy after a START and a new STOP could read the new live row first, skip it beside the old copy, then lift that copy. The change feed replays in sequence order and is unaffected.Tests
TestAMovedRecipientIsStillOptedOut: opted out after a move.TestAStopAndAStartAfterTheCopyArriveThroughTheChanges: both replay through the changes.TestAnImportOverALiveOptOutLeavesIt: the destination's live row stays and the import does not fail.TestAnImportedRevokedOptOutDoesNotLiftOneRecordedHere: a replayed START leaves the destination's opt-out live and the revoked copy is kept beside it; failed with the live-only condition dropped from the skip.TestASecondCopyAfterAStartAndAStopKeepsTheRecipientOptedOut: source rows stored newest first, copied twice; failed with the ordering removed.TestAnOptOutHereOnAnotherChannelDoesNotKeepOneOut,TestAnOptOutHereForAnotherRecipientDoesNotKeepOneOut,TestAnotherAppsOptOutHereDoesNotKeepOneOut: a destination opt-out on another channel, for another recipient or of another app does not keep the source's out; each failed with its predicate dropped from the skip.TestAnImportedRowUnderTheIdOfAnOptOutHereLeavesItsRecipientOptedOut: an imported row under a destination opt-out's id, for another recipient or channel, leaves it live; failed with either match dropped from the conflict guard.TestAnAppHoldingOnlyAnOptOutImportsWithoutFull(api): failed with a 409 without theHoldingTableskip.TestAnImportedOptOutWithoutARecipientIsRefused: an imported opt-out with an empty recipient is refused; it was stored without theimportedModelsentry.The first four fail without
opt_outsindataTables.Fixes AI-3489