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

Optimize logs #16647

Merged
merged 5 commits into from
Jun 5, 2024
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
3 changes: 0 additions & 3 deletions pkg/bootstrap/versions/upgrade_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func (u *UpgradeEntry) Upgrade(txn executor.TxnExecutor, accountId uint32) error
return err
}
res.Close()
getLogger().Info("execute upgrade pre-sql completed", zap.String("upgrade entry", u.String()))
}

// 2. Second, Execute upgrade sql
Expand All @@ -157,7 +156,6 @@ func (u *UpgradeEntry) Upgrade(txn executor.TxnExecutor, accountId uint32) error
return err
}
res.Close()
getLogger().Info("execute upgrade sql completed", zap.String("upgrade entry", u.String()))

// 2. Third, after the upgrade is completed, judge whether there is post-sql
if u.PostSql != "" {
Expand All @@ -167,7 +165,6 @@ func (u *UpgradeEntry) Upgrade(txn executor.TxnExecutor, accountId uint32) error
return err
}
res.Close()
getLogger().Info("execute upgrade post-sql completed", zap.String("upgrade entry", u.String()))
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/versions/upgrade_tenant_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func UpdateUpgradeTenantTaskState(
taskID uint64,
state int32,
txn executor.TxnExecutor) error {
sql := fmt.Sprintf("update %s set ready = %d where id = %d",
sql := fmt.Sprintf("update %s set ready = %d, update_at = current_timestamp() where id = %d",
catalog.MOUpgradeTenantTable,
state,
taskID)
Expand Down
18 changes: 18 additions & 0 deletions pkg/bootstrap/versions/v1_2_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package v1_2_0

import (
"context"
"time"

"go.uber.org/zap"

Expand Down Expand Up @@ -66,11 +67,20 @@ func (v *versionHandle) HandleTenantUpgrade(
txn executor.TxnExecutor) error {

for _, upgEntry := range tenantUpgEntries {
start := time.Now()

err := upgEntry.Upgrade(txn, uint32(tenantID))
if err != nil {
getLogger().Error("tenant upgrade entry execute error", zap.Error(err), zap.Int32("tenantId", tenantID), zap.String("version", v.Metadata().Version), zap.String("upgrade entry", upgEntry.String()))
return err
}

duration := time.Since(start)
getLogger().Info("tenant upgrade entry complete",
zap.String("upgrade entry", upgEntry.String()),
zap.Int64("time cost(ms)", duration.Milliseconds()),
zap.Int32("tenantId", tenantID),
zap.String("toVersion", v.Metadata().Version))
}

return nil
Expand All @@ -81,11 +91,19 @@ func (v *versionHandle) HandleClusterUpgrade(
txn executor.TxnExecutor) error {
txn.Use(catalog.MO_CATALOG)
for _, upgEntry := range clusterUpgEntries {
start := time.Now()

err := upgEntry.Upgrade(txn, catalog.System_Account)
if err != nil {
getLogger().Error("cluster upgrade entry execute error", zap.Error(err), zap.String("version", v.Metadata().Version), zap.String("upgrade entry", upgEntry.String()))
return err
}

duration := time.Since(start)
getLogger().Info("cluster upgrade entry complete",
zap.String("upgrade entry", upgEntry.String()),
zap.Int64("time cost(ms)", duration.Milliseconds()),
zap.String("toVersion", v.Metadata().Version))
}
return nil
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/sql/compile/sql_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,6 @@ func (exec *txnExecutor) Exec(
//-----------------------------------------------------------------------------------------

receiveAt := time.Now()

logutil.Info("Received SQL execute request",
zap.String("sql", sql),
zap.String("txn-id", hex.EncodeToString(exec.opts.Txn().Txn().ID)))

stmts, err := parsers.Parse(exec.ctx, dialect.MYSQL, sql, 1, 0)
defer func() {
for _, stmt := range stmts {
Expand Down
Loading