func (do *Domain) loadInfoSchema(handle *infoschema.Handle, usedSchemaVersion int64, startTS uint64) (int64, error) {
	snapshot, err := do.store.GetSnapshot(kv.NewVersion(startTS))
	if err != nil {
		return 0, errors.Trace(err)
	}
	m := meta.NewSnapshotMeta(snapshot)
	latestSchemaVersion, err := m.GetSchemaVersion()
	if err != nil {
		return 0, errors.Trace(err)
	}
	if usedSchemaVersion != 0 && usedSchemaVersion == latestSchemaVersion {
		return latestSchemaVersion, nil
	}
	startTime := time.Now()
	ok, err := do.tryLoadSchemaDiffs(m, usedSchemaVersion, latestSchemaVersion)
	if err != nil {
		// We can fall back to full load, don't need to return the error.
		log.Errorf("[ddl] failed to load schema diff err %v", err)
	}
	if ok {
		log.Infof("[ddl] diff load InfoSchema from version %d to %d, in %v",
			usedSchemaVersion, latestSchemaVersion, time.Since(startTime))
		return latestSchemaVersion, nil
	}

	schemas, err := do.fetchAllSchemasWithTables(m)
	if err != nil {
		return 0, errors.Trace(err)
	}

	newISBuilder, err := infoschema.NewBuilder(handle).InitWithDBInfos(schemas, latestSchemaVersion)
	if err != nil {
		return 0, errors.Trace(err)
	}
	log.Infof("[ddl] full load InfoSchema from version %d to %d, in %v",
		usedSchemaVersion, latestSchemaVersion, time.Since(startTime))
	newISBuilder.Build()
	return latestSchemaVersion, nil
}
// loadInfoSchema loads infoschema at startTS into handle, usedSchemaVersion is the currently used
// infoschema version, if it is the same as the schema version at startTS, we don't need to reload again.
// It returns the latest schema version and an error.
loadInfoSchema loads infoschema at startTS into handle, usedSchemaVersion is the currently used
infoschema version, if it is the same as the schema version at startTS, we don't need to reload again.
It returns the latest schema version and an error.
// loadInfoSchema loads infoschema at startTS into handle usedSchemaVersion is the currently used // infoschema version if it is the same as the schema version at startTS we don ' t need to reload again . // It returns the latest schema version and an error .
func (do *Domain) loadInfoSchema(handle *infoschema.Handle, usedSchemaVersion int64, startTS uint64) (int64, error) {
	snapshot, err := do.store.GetSnapshot(kv.NewVersion(startTS))
	if err != nil {
		return 0, errors.Trace(err)
	}
	m := meta.NewSnapshotMeta(snapshot)
	latestSchemaVersion, err := m.GetSchemaVersion()
	if err != nil {
		return 0, errors.Trace(err)
	}
	if usedSchemaVersion != 0 && usedSchemaVersion == latestSchemaVersion {
		return latestSchemaVersion, nil
	}
	startTime := time.Now()
	ok, err := do.tryLoadSchemaDiffs(m, usedSchemaVersion, latestSchemaVersion)
	if err != nil {
		log.Errorf("[ddl] failed to load schema diff err %v", err)
	}
	if ok {
		log.Infof("[ddl] diff load InfoSchema from version %d to %d, in %v",
			usedSchemaVersion, latestSchemaVersion, time.Since(startTime))
		return latestSchemaVersion, nil
	}
	schemas, err := do.fetchAllSchemasWithTables(m)
	if err != nil {
		return 0, errors.Trace(err)
	}
	newISBuilder, err := infoschema.NewBuilder(handle).InitWithDBInfos(schemas, latestSchemaVersion)
	if err != nil {
		return 0, errors.Trace(err)
	}
	log.Infof("[ddl] full load InfoSchema from version %d to %d, in %v",
		usedSchemaVersion, latestSchemaVersion, time.Since(startTime))
	newISBuilder.Build()
	return latestSchemaVersion, nil
}
func ( do * Domain ) loadInfoSchema ( handle * infoschema . Handle , usedSchemaVersion int64 , startTS uint64 ) ( int64 , error ) { snapshot , err := do . store . GetSnapshot ( kv . NewVersion ( startTS ) ) if err != nil { return 0 , errors . Trace ( err ) } m := meta . NewSnapshotMeta ( snapshot ) latestSchemaVersion , err := m . GetSchemaVersion ( ) if err != nil { return 0 , errors . Trace ( err ) } if usedSchemaVersion != 0 && usedSchemaVersion == latestSchemaVersion { return latestSchemaVersion , nil } startTime := time . Now ( ) ok , err := do . tryLoadSchemaDiffs ( m , usedSchemaVersion , latestSchemaVersion ) if err != nil { log . Errorf ( " " , err ) } if ok { log . Infof ( " " , usedSchemaVersion , latestSchemaVersion , time . Since ( startTime ) ) return latestSchemaVersion , nil } schemas , err := do . fetchAllSchemasWithTables ( m ) if err != nil { return 0 , errors . Trace ( err ) } newISBuilder , err := infoschema . NewBuilder ( handle ) . InitWithDBInfos ( schemas , latestSchemaVersion ) if err != nil { return 0 , errors . Trace ( err ) } log . Infof ( " " , usedSchemaVersion , latestSchemaVersion , time . Since ( startTime ) ) newISBuilder . Build ( ) return latestSchemaVersion , nil }
loadInfoSchema loads infoschema at startTS into handle, usedSchemaVersion is the currently used
infoschema version, if it is the same as the schema version at startTS, we don't need to reload again.
loadInfoSchema loads infoschema at startTS into handle usedSchemaVersion is the currently used infoschema version if it is the same as the schema version at startTS we don ' t need to reload again .
// We can fall back to full load, don't need to return the error.