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

Function bootstrapSessionImpl

pkg/session/session.go:3464–3714  ·  view source on GitHub ↗

bootstrapSessionImpl bootstraps session and domain. the process works as follows: - if we haven't bootstrapped to the target version - create/init/start domain - bootstrap or upgrade, some variables will be initialized and stored to system table in the process, such as system time-zone - close domai

(ctx context.Context, store kv.Storage, createSessionsImpl func(store kv.Storage, cnt int) ([]*session, error))

Source from the content-addressed store, hash-verified

3462// such as system time zone
3463// - start domain and other routines.
3464func bootstrapSessionImpl(ctx context.Context, store kv.Storage, createSessionsImpl func(store kv.Storage, cnt int) ([]*session, error)) (*domain.Domain, error) {
3465 ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnBootstrap)
3466 cfg := config.GetGlobalConfig()
3467 if len(cfg.Instance.PluginLoad) > 0 {
3468 err := plugin.Load(context.Background(), plugin.Config{
3469 Plugins: strings.Split(cfg.Instance.PluginLoad, ","),
3470 PluginDir: cfg.Instance.PluginDir,
3471 })
3472 if err != nil {
3473 return nil, err
3474 }
3475 }
3476 err := InitDDLJobTables(store, meta.BaseDDLTableVersion)
3477 if err != nil {
3478 return nil, err
3479 }
3480 err = InitMDLTable(store)
3481 if err != nil {
3482 return nil, err
3483 }
3484 err = InitDDLJobTables(store, meta.BackfillTableVersion)
3485 if err != nil {
3486 return nil, err
3487 }
3488 err = InitDDLJobTables(store, meta.DDLNotifierTableVersion)
3489 if err != nil {
3490 return nil, err
3491 }
3492 err = InitTiDBSchemaCacheSize(store)
3493 if err != nil {
3494 return nil, err
3495 }
3496 ver := getStoreBootstrapVersionWithCache(store)
3497 if ver < currentBootstrapVersion {
3498 runInBootstrapSession(store, ver)
3499 } else {
3500 err = InitMDLVariable(store)
3501 if err != nil {
3502 return nil, err
3503 }
3504 }
3505
3506 // initiate disttask framework components which need a store
3507 scheduler.RegisterSchedulerFactory(
3508 proto.ImportInto,
3509 func(ctx context.Context, task *proto.Task, param scheduler.Param) scheduler.Scheduler {
3510 return importinto.NewImportScheduler(ctx, task, param, store.(kv.StorageWithPD))
3511 },
3512 )
3513 taskexecutor.RegisterTaskType(
3514 proto.ImportInto,
3515 func(ctx context.Context, task *proto.Task, param taskexecutor.Param) taskexecutor.TaskExecutor {
3516 return importinto.NewImportExecutor(ctx, task, param, store)
3517 },
3518 )
3519
3520 concurrency := config.GetGlobalConfig().Performance.StatsLoadConcurrency
3521 if concurrency == 0 {

Callers 2

BootstrapSessionFunction · 0.85

Calls 15

GetGlobalConfigFunction · 0.92
LoadFunction · 0.92
RegisterSchedulerFactoryFunction · 0.92
NewImportSchedulerFunction · 0.92
RegisterTaskTypeFunction · 0.92
NewImportExecutorFunction · 0.92
SetSystemTZFunction · 0.92
GetDomainFunction · 0.92
BootstrapFunction · 0.92
InitFunction · 0.92

Tested by

no test coverage detected