Skip to content

Commit d6875ff

Browse files
committed
first version
Signed-off-by: Wenqi Mou <[email protected]>
1 parent def3d2d commit d6875ff

File tree

14 files changed

+907
-38
lines changed

14 files changed

+907
-38
lines changed

br/pkg/checkpoint/log_restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ type TaskInfoForLogRestore struct {
187187
Progress RestoreProgress
188188
}
189189

190-
func TryToGetCheckpointTaskInfo(
190+
func GetCheckpointTaskInfo(
191191
ctx context.Context,
192192
snapshotManager SnapshotMetaManagerT,
193193
logManager LogMetaManagerT,

br/pkg/checkpoint/manager.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func NewLogTableMetaManager(
9090
g glue.Glue,
9191
dom *domain.Domain,
9292
dbName string,
93+
id uint64,
9394
) (LogMetaManagerT, error) {
9495
se, err := g.CreateSession(dom.Store())
9596
if err != nil {
@@ -105,14 +106,15 @@ func NewLogTableMetaManager(
105106
se: se,
106107
runnerSe: runnerSe,
107108
dom: dom,
108-
dbName: dbName,
109+
dbName: fmt.Sprintf("%s_%d", dbName, id),
109110
}, nil
110111
}
111112

112113
func NewSnapshotTableMetaManager(
113114
g glue.Glue,
114115
dom *domain.Domain,
115116
dbName string,
117+
id uint64,
116118
) (SnapshotMetaManagerT, error) {
117119
se, err := g.CreateSession(dom.Store())
118120
if err != nil {
@@ -128,7 +130,7 @@ func NewSnapshotTableMetaManager(
128130
se: se,
129131
runnerSe: runnerSe,
130132
dom: dom,
131-
dbName: dbName,
133+
dbName: fmt.Sprintf("%s_%d", dbName, id),
132134
}, nil
133135
}
134136

@@ -145,7 +147,7 @@ func (manager *TableMetaManager[K, SV, LV, M]) Close() {
145147
}
146148
}
147149

148-
// load the whole checkpoint range data and retrieve the metadata of restored ranges
150+
// LoadCheckpointData loads the whole checkpoint range data and retrieve the metadata of restored ranges
149151
// and return the total time cost in the past executions
150152
func (manager *TableMetaManager[K, SV, LV, M]) LoadCheckpointData(
151153
ctx context.Context,
@@ -281,14 +283,15 @@ func NewSnapshotStorageMetaManager(
281283
cipher *backuppb.CipherInfo,
282284
clusterID uint64,
283285
prefix string,
286+
id uint64,
284287
) SnapshotMetaManagerT {
285288
return &StorageMetaManager[
286289
RestoreKeyType, RestoreValueType, RestoreValueType, CheckpointMetadataForSnapshotRestore,
287290
]{
288291
storage: storage,
289292
cipher: cipher,
290293
clusterID: fmt.Sprintf("%d", clusterID),
291-
taskName: fmt.Sprintf("%d/%s", clusterID, prefix),
294+
taskName: fmt.Sprintf("%d/%s_%d", clusterID, prefix, id),
292295
}
293296
}
294297

@@ -297,14 +300,15 @@ func NewLogStorageMetaManager(
297300
cipher *backuppb.CipherInfo,
298301
clusterID uint64,
299302
prefix string,
303+
id uint64,
300304
) LogMetaManagerT {
301305
return &StorageMetaManager[
302306
LogRestoreKeyType, LogRestoreValueType, LogRestoreValueMarshaled, CheckpointMetadataForLogRestore,
303307
]{
304308
storage: storage,
305309
cipher: cipher,
306310
clusterID: fmt.Sprintf("%d", clusterID),
307-
taskName: fmt.Sprintf("%d/%s", clusterID, prefix),
311+
taskName: fmt.Sprintf("%d/%s_%d", clusterID, prefix, id),
308312
}
309313
}
310314

br/pkg/checkpoint/storage.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"encoding/json"
2121
"fmt"
22+
"strings"
2223
"time"
2324

2425
"github.com/google/uuid"
@@ -90,9 +91,10 @@ const (
9091

9192
// IsCheckpointDB checks whether the dbname is checkpoint database.
9293
func IsCheckpointDB(dbname ast.CIStr) bool {
93-
return dbname.O == LogRestoreCheckpointDatabaseName ||
94-
dbname.O == SnapshotRestoreCheckpointDatabaseName ||
95-
dbname.O == CustomSSTRestoreCheckpointDatabaseName
94+
// Check if the database name starts with any of the checkpoint database name prefixes
95+
return strings.HasPrefix(dbname.O, LogRestoreCheckpointDatabaseName) ||
96+
strings.HasPrefix(dbname.O, SnapshotRestoreCheckpointDatabaseName) ||
97+
strings.HasPrefix(dbname.O, CustomSSTRestoreCheckpointDatabaseName)
9698
}
9799

98100
const CheckpointIdMapBlockSize int = 524288

br/pkg/registry/BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "registry",
5+
srcs = ["registration.go"],
6+
importpath = "github.com/pingcap/tidb/br/pkg/registry",
7+
visibility = ["//visibility:public"],
8+
deps = [
9+
"//br/pkg/errors",
10+
"//br/pkg/glue",
11+
"//br/pkg/metautil",
12+
"//br/pkg/utils",
13+
"//pkg/domain",
14+
"//pkg/kv",
15+
"//pkg/util/table-filter",
16+
"@com_github_google_uuid//:uuid",
17+
"@com_github_pingcap_errors//:errors",
18+
"@com_github_pingcap_log//:log",
19+
"@org_uber_go_zap//:zap",
20+
],
21+
)

0 commit comments

Comments
 (0)