Skip to content

Commit ded4059

Browse files
committed
sql: move BackupRestoreTestingKnobs to exec_util_backup.go
`BackupRestoreTestingKnobs` has been moved to a new file, `exec_util_backup.go` and `CODEOWNERS` has been updated. Release note: None
1 parent cf3fcec commit ded4059

File tree

4 files changed

+82
-65
lines changed

4 files changed

+82
-65
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
/pkg/sql/control_job* @cockroachdb/sql-queries-prs @cockroachdb/jobs-prs
7474
/pkg/sql/job_exec_context* @cockroachdb/sql-queries-prs @cockroachdb/jobs-prs
7575
/pkg/sql/delegate/*job*.go @cockroachdb/jobs-prs @cockroachdb/disaster-recovery
76+
#!/pkg/sql/BUILD.bazel @cockroachdb/sql-queries-noreview
7677

7778
/pkg/sql/importer/ @cockroachdb/sql-queries-prs
7879
/pkg/sql/importer/export* @cockroachdb/cdc-prs
@@ -258,8 +259,9 @@
258259
/pkg/ccl/changefeedccl/ @cockroachdb/cdc-prs
259260

260261
/pkg/crosscluster/ @cockroachdb/disaster-recovery
261-
/pkg/backup/ @cockroachdb/disaster-recovery
262-
/pkg//backup/*_job.go @cockroachdb/disaster-recovery @cockroachdb/jobs-prs
262+
/pkg/backup/ @cockroachdb/disaster-recovery
263+
/pkg//backup/*_job.go @cockroachdb/disaster-recovery @cockroachdb/jobs-prs
264+
/pkg/sql/exec_util_backup.go @cockroachdb/disaster-recovery
263265
/pkg/revert/ @cockroachdb/disaster-recovery
264266
/pkg/ccl/storageccl/ @cockroachdb/disaster-recovery
265267
/pkg/ccl/cloudccl/ @cockroachdb/disaster-recovery

pkg/sql/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ go_library(
113113
"exec_factory_util.go",
114114
"exec_log.go",
115115
"exec_util.go",
116+
"exec_util_backup.go",
116117
"execute.go",
117118
"executor_statement_metrics.go",
118119
"explain_bundle.go",

pkg/sql/exec_util.go

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"time"
2222

2323
apd "github.com/cockroachdb/apd/v3"
24-
"github.com/cockroachdb/cockroach/pkg/backup/backuppb"
2524
"github.com/cockroachdb/cockroach/pkg/base"
2625
"github.com/cockroachdb/cockroach/pkg/cloud/externalconn"
2726
"github.com/cockroachdb/cockroach/pkg/clusterversion"
@@ -41,7 +40,6 @@ import (
4140
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangecache"
4241
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
4342
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed/rangefeedcache"
44-
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
4543
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
4644
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts"
4745
"github.com/cockroachdb/cockroach/pkg/multitenant"
@@ -1863,67 +1861,6 @@ type SchemaTelemetryTestingKnobs struct {
18631861
// ModuleTestingKnobs implements the base.ModuleTestingKnobs interface.
18641862
func (*SchemaTelemetryTestingKnobs) ModuleTestingKnobs() {}
18651863

1866-
// BackupRestoreTestingKnobs contains knobs for backup and restore behavior.
1867-
//
1868-
// TODO (msbutler): move these to backup
1869-
type BackupRestoreTestingKnobs struct {
1870-
// AfterBackupChunk is called after each chunk of a backup is completed.
1871-
AfterBackupChunk func()
1872-
1873-
// AfterBackupCheckpoint if set will be called after a BACKUP-CHECKPOINT
1874-
// is written.
1875-
AfterBackupCheckpoint func()
1876-
1877-
// AfterLoadingCompactionManifestOnResume is run once the backup manifest has been
1878-
// loaded/created on the resumption of a compaction job.
1879-
AfterLoadingCompactionManifestOnResume func(manifest *backuppb.BackupManifest)
1880-
1881-
// CaptureResolvedTableDescSpans allows for intercepting the spans which are
1882-
// resolved during backup planning, and will eventually be backed up during
1883-
// execution.
1884-
CaptureResolvedTableDescSpans func([]roachpb.Span)
1885-
1886-
// RunAfterSplitAndScatteringEntry allows blocking the RESTORE job after a
1887-
// single RestoreSpanEntry has been split and scattered.
1888-
RunAfterSplitAndScatteringEntry func(ctx context.Context)
1889-
1890-
// RunAfterProcessingRestoreSpanEntry allows blocking the RESTORE job after a
1891-
// single RestoreSpanEntry has been processed and added to the SSTBatcher.
1892-
RunAfterProcessingRestoreSpanEntry func(ctx context.Context, entry *execinfrapb.RestoreSpanEntry) error
1893-
1894-
// RunAfterExportingSpanEntry allows blocking the BACKUP job after a single
1895-
// span has been exported.
1896-
RunAfterExportingSpanEntry func(ctx context.Context, response *kvpb.ExportResponse)
1897-
1898-
// BackupMonitor is used to overwrite the monitor used by backup during
1899-
// testing. This is typically the bulk mem monitor if not
1900-
// specified here.
1901-
BackupMemMonitor *mon.BytesMonitor
1902-
1903-
RestoreDistSQLRetryPolicy *retry.Options
1904-
1905-
RunBeforeRestoreFlow func() error
1906-
1907-
RunAfterRestoreFlow func() error
1908-
1909-
BackupDistSQLRetryPolicy *retry.Options
1910-
1911-
RunBeforeBackupFlow func() error
1912-
1913-
RunAfterBackupFlow func() error
1914-
1915-
RunAfterRetryIteration func(err error) error
1916-
1917-
RunAfterRestoreProcDrains func()
1918-
1919-
RunBeforeResolvingCompactionDest func() error
1920-
}
1921-
1922-
var _ base.ModuleTestingKnobs = &BackupRestoreTestingKnobs{}
1923-
1924-
// ModuleTestingKnobs implements the base.ModuleTestingKnobs interface.
1925-
func (*BackupRestoreTestingKnobs) ModuleTestingKnobs() {}
1926-
19271864
// StreamingTestingKnobs contains knobs for streaming behavior.
19281865
type StreamingTestingKnobs struct {
19291866
// RunAfterReceivingEvent allows blocking the stream ingestion processor after

pkg/sql/exec_util_backup.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2015 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the CockroachDB Software License
4+
// included in the /LICENSE file.
5+
6+
package sql
7+
8+
import (
9+
"context"
10+
11+
"github.com/cockroachdb/cockroach/pkg/backup/backuppb"
12+
"github.com/cockroachdb/cockroach/pkg/base"
13+
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
14+
"github.com/cockroachdb/cockroach/pkg/roachpb"
15+
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
16+
"github.com/cockroachdb/cockroach/pkg/util/mon"
17+
"github.com/cockroachdb/cockroach/pkg/util/retry"
18+
)
19+
20+
// BackupRestoreTestingKnobs contains knobs for backup and restore behavior.
21+
type BackupRestoreTestingKnobs struct {
22+
// AfterBackupChunk is called after each chunk of a backup is completed.
23+
AfterBackupChunk func()
24+
25+
// AfterBackupCheckpoint if set will be called after a BACKUP-CHECKPOINT
26+
// is written.
27+
AfterBackupCheckpoint func()
28+
29+
// AfterLoadingCompactionManifestOnResume is run once the backup manifest has been
30+
// loaded/created on the resumption of a compaction job.
31+
AfterLoadingCompactionManifestOnResume func(manifest *backuppb.BackupManifest)
32+
33+
// CaptureResolvedTableDescSpans allows for intercepting the spans which are
34+
// resolved during backup planning, and will eventually be backed up during
35+
// execution.
36+
CaptureResolvedTableDescSpans func([]roachpb.Span)
37+
38+
// RunAfterSplitAndScatteringEntry allows blocking the RESTORE job after a
39+
// single RestoreSpanEntry has been split and scattered.
40+
RunAfterSplitAndScatteringEntry func(ctx context.Context)
41+
42+
// RunAfterProcessingRestoreSpanEntry allows blocking the RESTORE job after a
43+
// single RestoreSpanEntry has been processed and added to the SSTBatcher.
44+
RunAfterProcessingRestoreSpanEntry func(ctx context.Context, entry *execinfrapb.RestoreSpanEntry) error
45+
46+
// RunAfterExportingSpanEntry allows blocking the BACKUP job after a single
47+
// span has been exported.
48+
RunAfterExportingSpanEntry func(ctx context.Context, response *kvpb.ExportResponse)
49+
50+
// BackupMonitor is used to overwrite the monitor used by backup during
51+
// testing. This is typically the bulk mem monitor if not
52+
// specified here.
53+
BackupMemMonitor *mon.BytesMonitor
54+
55+
RestoreDistSQLRetryPolicy *retry.Options
56+
57+
RunBeforeRestoreFlow func() error
58+
59+
RunAfterRestoreFlow func() error
60+
61+
BackupDistSQLRetryPolicy *retry.Options
62+
63+
RunBeforeBackupFlow func() error
64+
65+
RunAfterBackupFlow func() error
66+
67+
RunAfterRetryIteration func(err error) error
68+
69+
RunAfterRestoreProcDrains func()
70+
71+
RunBeforeResolvingCompactionDest func() error
72+
}
73+
74+
var _ base.ModuleTestingKnobs = &BackupRestoreTestingKnobs{}
75+
76+
// ModuleTestingKnobs implements the base.ModuleTestingKnobs interface.
77+
func (*BackupRestoreTestingKnobs) ModuleTestingKnobs() {}

0 commit comments

Comments
 (0)