code: func (s *session) loadCommonGlobalVariablesIfNeeded() error {
  	initLoadCommonGlobalVarsSQL()
  	vars := s.sessionVars
  	if vars.CommonGlobalLoaded {
  		return nil
  	}
  	if s.Value(sessionctx.Initing) != nil {
  		// When running bootstrap or upgrade, we should not access global storage.
  		return nil
  	}
  
  	var err error
  	// Use GlobalVariableCache if TiDB just loaded global variables within 2 second ago.
  	// When a lot of connections connect to TiDB simultaneously, it can protect TiKV meta region from overload.
  	gvc := domain.GetDomain(s).GetGlobalVarsCache()
  	succ, rows, fields := gvc.Get()
  	if !succ {
  		// Set the variable to true to prevent cyclic recursive call.
  		vars.CommonGlobalLoaded = true
  		rows, fields, err = s.ExecRestrictedSQL(s, loadCommonGlobalVarsSQL)
  		if err != nil {
  			vars.CommonGlobalLoaded = false
  			logutil.Logger(context.Background()).Error("failed to load common global variables.")
  			return err
  		}
  		gvc.Update(rows, fields)
  	}
  
  	for _, row := range rows {
  		varName := row.GetString(0)
  		varVal := row.GetDatum(1, &fields[1].Column.FieldType)
  		if _, ok := vars.GetSystemVar(varName); !ok {
  			err = variable.SetSessionSystemVar(s.sessionVars, varName, varVal)
  			if err != nil {
  				return err
  			}
  		}
  	}
  
  	// when client set Capability Flags CLIENT_INTERACTIVE, init wait_timeout with interactive_timeout
  	if vars.ClientCapability&mysql.ClientInteractive > 0 {
  		if varVal, ok := vars.GetSystemVar(variable.InteractiveTimeout); ok {
  			if err := vars.SetSystemVar(variable.WaitTimeout, varVal); err != nil {
  				return err
  			}
  		}
  	}
  
  	vars.CommonGlobalLoaded = true
  	return nil
  }
docs: // loadCommonGlobalVariablesIfNeeded loads and applies commonly used global variables for the session.