MCPcopy
hub / github.com/pingcap/tidb / NewRestoreRegistry

Function NewRestoreRegistry

br/pkg/registry/registration.go:213–239  ·  view source on GitHub ↗

NewRestoreRegistry creates a new registry using TiDB's session

(ctx context.Context, g glue.Glue, dom *domain.Domain)

Source from the content-addressed store, hash-verified

211
212// NewRestoreRegistry creates a new registry using TiDB's session
213func NewRestoreRegistry(ctx context.Context, g glue.Glue, dom *domain.Domain) (*Registry, error) {
214 se, err := g.CreateSession(dom.Store())
215 if err != nil {
216 return nil, errors.Trace(err)
217 }
218 heartbeatSession, err := g.CreateSession(dom.Store())
219 if err != nil {
220 return nil, errors.Trace(err)
221 }
222 tableExists := true
223 _, err = dom.InfoSchema().TableByName(ctx,
224 pmodel.NewCIStr(RestoreRegistryDBName),
225 pmodel.NewCIStr(RestoreRegistryTableName),
226 )
227 if err != nil {
228 if !infoschema.ErrTableNotExists.Equal(err) {
229 return nil, errors.Trace(err)
230 }
231 tableExists = false
232 }
233
234 return &Registry{
235 se: se,
236 heartbeatSession: heartbeatSession,
237 tableExists: tableExists,
238 }, nil
239}
240
241func (r *Registry) Close() {
242 log.Info("closing registry")

Callers 6

RunRestoreFunction · 0.92
RunRestoreAbortFunction · 0.92

Calls 5

InfoSchemaMethod · 0.80
CreateSessionMethod · 0.65
StoreMethod · 0.65
TableByNameMethod · 0.65
EqualMethod · 0.65