From e493711524db827f5c62d10411e29f681e23c3f1 Mon Sep 17 00:00:00 2001 From: daviszhen <60595215+daviszhen@users.noreply.github.com> Date: Mon, 29 Aug 2022 19:38:57 +0800 Subject: [PATCH] fix booting sys check failure (#4763) Revise the check failure bug when the mo boots with previous databases and tables. Approved by: @yingfeng --- pkg/frontend/authenticate.go | 45 +++++++++--------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/pkg/frontend/authenticate.go b/pkg/frontend/authenticate.go index ea36f5748..b1f3eb816 100644 --- a/pkg/frontend/authenticate.go +++ b/pkg/frontend/authenticate.go @@ -459,16 +459,12 @@ var ( "system_metrics": 0, } sysWantedTables = map[string]int8{ - "mo_database": 0, - "mo_tables": 0, - "mo_columns": 0, - "mo_user": 0, - "mo_account": 0, - "mo_role": 0, - "mo_user_grant": 0, - "mo_role_grant": 0, - "mo_role_priv": 0, - "mo_global_variables": 0, + "mo_user": 0, + "mo_account": 0, + "mo_role": 0, + "mo_user_grant": 0, + "mo_role_grant": 0, + "mo_role_priv": 0, } //the sqls creating many tables for the tenant. //Wrap them in a transaction @@ -527,10 +523,6 @@ var ( granted_time timestamp, with_grant_option bool );`, - `create table mo_global_variables( - gv_variable_name varchar(256), - gv_variable_value varchar(1024) - );`, } initMoAccountFormat = `insert into mo_catalog.mo_account( @@ -724,23 +716,11 @@ func checkSysExistsOrNot(ctx context.Context, pu *config.ParameterUnit) (bool, e return false, err } - dbNames := []string{} for i := uint64(0); i < rsset[0].GetRowCount(); i++ { - dbName, err := rsset[0].GetString(i, 0) + _, err := rsset[0].GetString(i, 0) if err != nil { return false, err } - dbNames = append(dbNames, dbName) - } - - for _, name := range dbNames { - if _, ok := sysWantedDatabases[name]; !ok { - return false, moerr.NewInternalError(fmt.Sprintf("sys tenant does not have the database %s", name)) - } - } - - if len(dbNames) != len(sysWantedDatabases) { - return false, nil } bh.ClearExecResultSet() @@ -770,17 +750,14 @@ func checkSysExistsOrNot(ctx context.Context, pu *config.ParameterUnit) (bool, e tableNames = append(tableNames, tableName) } + //if there is at least one catalog table, it denotes the sys tenant exists. for _, name := range tableNames { - if _, ok := sysWantedTables[name]; !ok { - return false, moerr.NewInternalError(fmt.Sprintf("sys tenant does not have the table %s", name)) + if _, ok := sysWantedTables[name]; ok { + return true, nil } } - if len(tableNames) != len(sysWantedTables) { - return false, nil - } - - return true, nil + return false, nil } // InitSysTenant initializes the tenant SYS before any tenants and accepting any requests -- GitLab