@@ -27,9 +27,12 @@ import (
27
27
"github.com/pingcap/tidb/pkg/parser/ast"
28
28
)
29
29
30
+ // SnapshotMetaManagerT is a type alias for MetaManager interface specialized for snapshot restoration
30
31
type SnapshotMetaManagerT = MetaManager [
31
32
RestoreKeyType , RestoreValueType , RestoreValueType , CheckpointMetadataForSnapshotRestore ,
32
33
]
34
+
35
+ // LogMetaManagerT is a type alias for LogMetaManager interface specialized for log restoration
33
36
type LogMetaManagerT = LogMetaManager [
34
37
LogRestoreKeyType , LogRestoreValueType , LogRestoreValueMarshaled , CheckpointMetadataForLogRestore ,
35
38
]
@@ -48,6 +51,8 @@ func DefaultTickDurationConfig() tickDurationConfig {
48
51
}
49
52
}
50
53
54
+ // MetaManager defines the interface for checkpoint metadata operations
55
+ // It handles loading, saving, and checking the existence of checkpoint data
51
56
type MetaManager [K KeyType , SV , LV ValueType , M any ] interface {
52
57
fmt.Stringer
53
58
@@ -67,6 +72,8 @@ type MetaManager[K KeyType, SV, LV ValueType, M any] interface {
67
72
Close ()
68
73
}
69
74
75
+ // LogMetaManager extends MetaManager with additional operations specific to log restoration
76
+ // This includes handling checkpoint progress and ingest index repair SQLs
70
77
type LogMetaManager [K KeyType , SV , LV ValueType , M any ] interface {
71
78
MetaManager [K , SV , LV , M ]
72
79
@@ -79,6 +86,8 @@ type LogMetaManager[K KeyType, SV, LV ValueType, M any] interface {
79
86
ExistsCheckpointIngestIndexRepairSQLs (context.Context ) (bool , error )
80
87
}
81
88
89
+ // TableMetaManager implements the MetaManager interface using database tables for storage
90
+ // It stores checkpoint data in tables within the TiDB database
82
91
type TableMetaManager [K KeyType , SV , LV ValueType , M any ] struct {
83
92
se glue.Session
84
93
runnerSe glue.Session
@@ -90,6 +99,7 @@ func NewLogTableMetaManager(
90
99
g glue.Glue ,
91
100
dom * domain.Domain ,
92
101
dbName string ,
102
+ id uint64 ,
93
103
) (LogMetaManagerT , error ) {
94
104
se , err := g .CreateSession (dom .Store ())
95
105
if err != nil {
@@ -105,14 +115,15 @@ func NewLogTableMetaManager(
105
115
se : se ,
106
116
runnerSe : runnerSe ,
107
117
dom : dom ,
108
- dbName : dbName ,
118
+ dbName : fmt . Sprintf ( "%s_%d" , dbName , id ) ,
109
119
}, nil
110
120
}
111
121
112
122
func NewSnapshotTableMetaManager (
113
123
g glue.Glue ,
114
124
dom * domain.Domain ,
115
125
dbName string ,
126
+ id uint64 ,
116
127
) (SnapshotMetaManagerT , error ) {
117
128
se , err := g .CreateSession (dom .Store ())
118
129
if err != nil {
@@ -128,7 +139,7 @@ func NewSnapshotTableMetaManager(
128
139
se : se ,
129
140
runnerSe : runnerSe ,
130
141
dom : dom ,
131
- dbName : dbName ,
142
+ dbName : fmt . Sprintf ( "%s_%d" , dbName , id ) ,
132
143
}, nil
133
144
}
134
145
@@ -145,7 +156,7 @@ func (manager *TableMetaManager[K, SV, LV, M]) Close() {
145
156
}
146
157
}
147
158
148
- // load the whole checkpoint range data and retrieve the metadata of restored ranges
159
+ // LoadCheckpointData loads the whole checkpoint range data and retrieve the metadata of restored ranges
149
160
// and return the total time cost in the past executions
150
161
func (manager * TableMetaManager [K , SV , LV , M ]) LoadCheckpointData (
151
162
ctx context.Context ,
@@ -281,14 +292,15 @@ func NewSnapshotStorageMetaManager(
281
292
cipher * backuppb.CipherInfo ,
282
293
clusterID uint64 ,
283
294
prefix string ,
295
+ id uint64 ,
284
296
) SnapshotMetaManagerT {
285
297
return & StorageMetaManager [
286
298
RestoreKeyType , RestoreValueType , RestoreValueType , CheckpointMetadataForSnapshotRestore ,
287
299
]{
288
300
storage : storage ,
289
301
cipher : cipher ,
290
302
clusterID : fmt .Sprintf ("%d" , clusterID ),
291
- taskName : fmt .Sprintf ("%d/%s " , clusterID , prefix ),
303
+ taskName : fmt .Sprintf ("%d/%s_%d " , clusterID , prefix , id ),
292
304
}
293
305
}
294
306
@@ -297,14 +309,15 @@ func NewLogStorageMetaManager(
297
309
cipher * backuppb.CipherInfo ,
298
310
clusterID uint64 ,
299
311
prefix string ,
312
+ id uint64 ,
300
313
) LogMetaManagerT {
301
314
return & StorageMetaManager [
302
315
LogRestoreKeyType , LogRestoreValueType , LogRestoreValueMarshaled , CheckpointMetadataForLogRestore ,
303
316
]{
304
317
storage : storage ,
305
318
cipher : cipher ,
306
319
clusterID : fmt .Sprintf ("%d" , clusterID ),
307
- taskName : fmt .Sprintf ("%d/%s " , clusterID , prefix ),
320
+ taskName : fmt .Sprintf ("%d/%s_%d " , clusterID , prefix , id ),
308
321
}
309
322
}
310
323
0 commit comments