Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dbm-services): load schema set tc_admin = 0 #7907 #7910

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ func (c *ImportSchemaFromBackendComp) migrateUseMydumper() (err error) {
}

// migrateUseMysqlDump 运行备份表结构
// nolint
func (c *ImportSchemaFromBackendComp) migrateUseMysqlDump() (err error) {
dumpOption := mysqlutil.MySQLDumpOption{
DumpSchema: true,
Expand Down Expand Up @@ -306,11 +307,21 @@ func (c *ImportSchemaFromBackendComp) migrateUseMysqlDump() (err error) {
Charset: c.charset,
MySQLDumpOption: dumpOption,
}
if err := dumper.Dump(); err != nil {
if err = dumper.Dump(); err != nil {
logger.Error("dump failed: %s", err.Error())
return err
}
logger.Info("备份表结构成功,开始导入表结构到中控")
_, err = c.tdbctlConn.Exec("set global tc_admin=0;")
if err != nil {
return err
}
defer func() {
_, err = c.tdbctlConn.Exec("set global tc_admin=1;")
if err != nil {
logger.Error("set global tc_admin=1 failed %s,请手动配置成tc_admin = 1", err.Error())
}
}()
dumpfileInfo := dumper.GetDumpFileInfo()
loader := mysqlutil.ExecuteSqlAtLocal{
IsForce: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (e ExecuteSqlAtLocal) ExecuteSqlByMySQLClient(sqlfile string, targetdbs []s
return nil
}

// ExecuteSqlWithOutReport TODO
func (e ExecuteSqlAtLocal) ExecuteSqlWithOutReport(sqlfile string, targetdbs []string) (err error) {
for _, db := range targetdbs {
if err = e.ExecuteSqlByMySQLClientOne(sqlfile, db, false); err != nil {
Expand All @@ -114,6 +115,7 @@ func (e ExecuteSqlAtLocal) ExecuteSqlByMySQLClientOne(sqlfile string, db string,
return nil
}

// TestConnectionByMySQLClient TODO
func (e ExecuteSqlAtLocal) TestConnectionByMySQLClient(db string, report bool) (err error) {
command := e.CreateLoadSQLCommand()
command = fmt.Sprintf(`echo "select version()" | %s %s`, command, db)
Expand Down Expand Up @@ -144,7 +146,7 @@ func (e ExecuteSqlAtLocal) ExecuteCommand(command string, report bool) (err erro
defer ef.Sync()
// 标准输出复制一份到错误文件中
stdout := io.MultiWriter(os.Stdout)
//stdout := io.MultiWriter(os.Stdout, ef)
// stdout := io.MultiWriter(os.Stdout, ef)
// 错误不输出控制台 去掉os.Stderr
// stderr := io.MultiWriter(os.Stderr, &stderrBuf, ef)
stderr := io.MultiWriter(&stderrBuf, ef)
Expand Down
Loading