carlos / platform Public

Merge remote-tracking branch 'origin/main' into group-roll-dr4-lock-refusal

claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 07da35daa69fd5f24a17cf3c5877e575c8fdd10e parent eb6a313parent c208389
1 file changed, +13 −2
  • internal/lease/release_snapshot_test.go +13 −2

CI passed — run details

diff --git a/internal/lease/release_snapshot_test.go b/internal/lease/release_snapshot_test.go
index a0228bc3c..3b2cafd61 100644
--- a/internal/lease/release_snapshot_test.go
+++ b/internal/lease/release_snapshot_test.go
@@ -29,6 +29,10 @@ import (
// countingReplica is a replica client that counts the LTX files opened
// (a restore's reads, one GET each on S3) and records the levels written,
// and can refuse snapshot writes.
+// drainSnapshotOnly marks the context of the drain release's own snapshot,
+// so a refusing fake can refuse that snapshot and no other.
+type drainSnapshotOnly struct{}
+
type countingReplica struct {
litestream.ReplicaClient
mu sync.Mutex
@@ -52,7 +56,12 @@ func (c *countingReplica) WriteLTXFile(ctx context.Context, level int, minTXID,
c.mu.Lock()
c.writes = append(c.writes, level)
fail := c.failSnapshot && level == litestream.SnapshotLevel
- early := c.refuseEarly && level == litestream.SnapshotLevel
+ // Only the drain's own snapshot is refused: the test marks its context
+ // (drainSnapshotOnly). The store monitor's snapshots run on the store's
+ // context and are never refused, so litestream's DB.Snapshot, which
+ // leaves its reader and the WAL open when an upload fails (#810, #811),
+ // never runs into this fake's refusal.
+ early := c.refuseEarly && level == litestream.SnapshotLevel && ctx.Value(drainSnapshotOnly{}) != nil
if level == litestream.SnapshotLevel {
c.snapshotTXID = maxTXID
}
@@ -230,7 +239,9 @@ func TestDrainReleaseSnapshotEarlyRefusalReleasesTheWAL(t *testing.T) {
dir := t.TempDir()
rc := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(dir), refuseEarly: true}
r, path := manyL0(t, fx, "instances/h", rc, 5)
- txid, snapErr, err := r.FinishSnapshot(ctx)
+ // The refusal applies to the drain's own snapshot only (#810): its
+ // context carries drainSnapshotOnly, the store monitor's does not.
+ txid, snapErr, err := r.FinishSnapshot(context.WithValue(ctx, drainSnapshotOnly{}, true))
if err != nil || snapErr == nil {
t.Fatalf("FinishSnapshot: txid %d, snapshot %v, %v; want the snapshot's failure alone", txid, snapErr, err)
}