Skip to content

Commit b30386a

Browse files
committed
crosscluster/physical: always destroy reader tenant on cutover
Previously, a reader tenant would only get automatically destroyed if a user specified an explicit cutover time. This UX is confusing. Now, the reader tenant will always get destroyed on cutover. Fixes #149684 Release note (ops change): the PCR reader tenant is always destroyed on cutover
1 parent 7b270fe commit b30386a

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

pkg/crosscluster/physical/standby_read_ts_poller_job_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"fmt"
1111
"net/url"
1212
"testing"
13-
"time"
1413

1514
apd "github.com/cockroachdb/apd/v3"
1615
"github.com/cockroachdb/cockroach/pkg/crosscluster/replicationtestutils"
@@ -217,16 +216,9 @@ INSERT INTO a VALUES (1);
217216
`)
218217

219218
waitForPollerJobToStartDest(t, c, ingestionJobID)
220-
if cutoverToLatest {
221-
observeValueInReaderTenant(t, c.ReaderTenantSQL)
222-
c.Cutover(ctx, producerJobID, ingestionJobID, time.Time{}, false)
223-
jobutils.WaitForJobToSucceed(t, c.DestSysSQL, jobspb.JobID(ingestionJobID))
224-
observeValueInReaderTenant(t, c.ReaderTenantSQL)
225-
} else {
226-
c.Cutover(ctx, producerJobID, ingestionJobID, c.SrcCluster.Server(0).Clock().Now().GoTime(), false)
227-
waitToRemoveTenant(t, c.DestSysSQL, readerTenantName)
228-
jobutils.WaitForJobToSucceed(t, c.DestSysSQL, jobspb.JobID(ingestionJobID))
229-
}
219+
c.Cutover(ctx, producerJobID, ingestionJobID, c.SrcCluster.Server(0).Clock().Now().GoTime(), false)
220+
waitToRemoveTenant(t, c.DestSysSQL, readerTenantName)
221+
jobutils.WaitForJobToSucceed(t, c.DestSysSQL, jobspb.JobID(ingestionJobID))
230222
})
231223
}
232224

pkg/crosscluster/physical/stream_ingestion_job.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,11 @@ func maybeRevertToCutoverTimestamp(
456456
// existed in the record at the point of the update rather the
457457
// value that may be in the job record before the update.
458458
var (
459-
shouldRevertToCutover bool
460-
cutoverTimestamp hlc.Timestamp
461-
originalSpanToRevert roachpb.Span
462-
remainingSpansToRevert roachpb.Spans
463-
replicatedTimeAtCutover hlc.Timestamp
464-
readerTenantID roachpb.TenantID
459+
shouldRevertToCutover bool
460+
cutoverTimestamp hlc.Timestamp
461+
originalSpanToRevert roachpb.Span
462+
remainingSpansToRevert roachpb.Spans
463+
readerTenantID roachpb.TenantID
465464
)
466465
if err := ingestionJob.NoTxn().Update(ctx,
467466
func(txn isql.Txn, md jobs.JobMetadata, ju *jobs.JobUpdater) error {
@@ -478,7 +477,6 @@ func maybeRevertToCutoverTimestamp(
478477
}
479478

480479
cutoverTimestamp = streamIngestionProgress.CutoverTime
481-
replicatedTimeAtCutover = streamIngestionProgress.ReplicatedTimeAtCutover
482480
readerTenantID = streamIngestionDetails.ReadTenantID
483481
originalSpanToRevert = streamIngestionDetails.Span
484482
remainingSpansToRevert = streamIngestionProgress.RemainingCutoverSpans
@@ -500,9 +498,7 @@ func maybeRevertToCutoverTimestamp(
500498
if !shouldRevertToCutover {
501499
return cutoverTimestamp, false, nil
502500
}
503-
// Identical cutoverTimestamp and replicatedTimeAtCutover implies that
504-
// CUTOVER TO LATEST command was run. Destroy reader tenant if not CUTOVER TO LATEST.
505-
if !cutoverTimestamp.Equal(replicatedTimeAtCutover) && readerTenantID.IsSet() {
501+
if readerTenantID.IsSet() {
506502
if err := stopTenant(ctx, p.ExecCfg(), readerTenantID); err != nil {
507503
return cutoverTimestamp, false, errors.Wrapf(err, "failed to stop reader tenant")
508504
}

0 commit comments

Comments
 (0)