Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamingccl: allow CUTOVER TO LATEST before initial scan finishes #114876

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/ccl/streamingccl/streamingest/alter_replication_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ func alterTenantJobCutover(
if alterTenantStmt.Cutover.Latest {
replicatedTime := replicationutils.ReplicatedTimeFromProgress(&progress)
if replicatedTime.IsEmpty() {
return hlc.Timestamp{},
errors.Newf("replicated tenant %q has not yet recorded a safe replication time", tenantName)
cutoverTime = details.ReplicationStartTime
} else {
cutoverTime = replicatedTime
}
cutoverTime = replicatedTime
}

// TODO(ssd): We could use the replication manager here, but
Expand Down
4 changes: 4 additions & 0 deletions pkg/ccl/streamingccl/streamingest/stream_ingestion_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ func (s *streamIngestionResumer) Resume(ctx context.Context, execCtx interface{}
return s.handleResumeError(ctx, jobExecCtx, err)
}

if err := jobExecCtx.ExecCfg().JobRegistry.CheckPausepoint("stream_ingestion.before_ingestion"); err != nil {
return err
}

// Start ingesting KVs from the replication stream.
err = ingestWithRetries(ctx, jobExecCtx, s)
if err != nil {
Expand Down
28 changes: 28 additions & 0 deletions pkg/ccl/streamingccl/streamingest/testdata/add_early_cutover
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This test ensures 1) the user can set a cutover before the initial scan completes; 2) cannot set a
# cutover time before the replicatedStartTime.

create-replication-clusters
----

exec-sql as=destination-system
SET CLUSTER SETTING jobs.debug.pausepoints = 'stream_ingestion.before_ingestion';
----

let $pre as=source-system
SELECT clock_timestamp()::timestamp::string
----

start-replication-stream
----

job as=destination-system wait-for-state=paused
----

query-sql as=destination-system regex-error=(.*before earliest safe cutover.*)
ALTER TENANT "destination" COMPLETE REPLICATION TO SYSTEM TIME '$pre'
----

exec-sql as=destination-system
ALTER TENANT "destination" COMPLETE REPLICATION TO LATEST
----