From 972e9bac71550ffedd255facfdcb8d58788b4768 Mon Sep 17 00:00:00 2001 From: Kanat Date: Mon, 23 Nov 2026 17:09:14 +0100 Subject: [PATCH] Pin the source usage id of a request moved on twice A request sent home after a third hop (A to B to C to A) must be one row where it was recorded. Taking source_usage_id from the sent usage_id instead of the origin left this uncovered. Co-Authored-By: Claude Opus 5.5 --- acceleration/internal/store/datamove_test.go | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/acceleration/internal/store/datamove_test.go b/acceleration/internal/store/datamove_test.go index 26b1e6b99f..658db8a352 100644 --- a/acceleration/internal/store/datamove_test.go +++ b/acceleration/internal/store/datamove_test.go @@ -4,11 +4,13 @@ package store import ( "context" + cryptorand "crypto/rand" "database/sql" "encoding/hex" "encoding/json" "fmt" "maps" + "math/big" "math/rand/v2" "net/url" "os" @@ -3695,6 +3697,29 @@ func (s *DataMoveSuite) TestARequestMovedOnFromACopyIsOneRowWhereverItLands() { s.Len(s.requestsByUsage(), 1, "a copy of a copy is the copy already here") } +func (s *DataMoveSuite) TestARequestMovedOnTwiceAndBackIsOneRowWhereItWasRecorded() { + id, err := cryptorand.Int(cryptorand.Reader, big.NewInt(1_000_000_000_000)) + s.Require().NoError(err) + home := s.takenRequest(s.source, id.Int64()) + s.move("acme", "acme") + + // A third holder: the destination's copy, sent on to another customer there. + for _, row := range s.exportFrom(s.destination, "acme").of("requests") { + encoded, err := json.Marshal(row) + s.Require().NoError(err) + s.Require().NoError(s.destination.ImportRow(s.ctx, "globex", "requests", encoded)) + } + for _, row := range s.exportFrom(s.destination, "globex").of("requests") { + encoded, err := json.Marshal(row) + s.Require().NoError(err) + s.Require().NoError(s.source.ImportRow(s.ctx, "acme", "requests", encoded)) + } + + rows := s.exportFrom(s.source, "acme").of("requests") + s.Require().Len(rows, 1, "a copy of a copy of a copy is the row it was copied from") + s.Equal(home.UsageID.String(), rows[0]["usage_id"]) +} + // drewNothing restarts the sequence behind a column, so the store has drawn nothing from it yet. // A truncate leaves sequences where they were, and the databases outlive a run. func (s *DataMoveSuite) drewNothing(store *Store, table, column string) {