Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: change MaxBinlogSizeLimit from 8M to 32M (#11025)
Danny Xud0700a55d161
diff --git a/backend/common/util.go b/backend/common/util.goindex d7792ffc8b..d52f96bc44 100644--- a/backend/common/util.go+++ b/backend/common/util.go@@ -25,9 +25,11 @@ const (// MaxSheetSize is the maximum size (1M) of a sheet for displaying.MaxSheetSize = 1024 * 1024// MaxSheetCheckSize is the maximum size of a sheet for checking changes.- MaxSheetCheckSize = 512 * 1024+ MaxSheetCheckSize = 1024 * 1024// MaxSheetSizeForRollback is the maximum size of a sheet for rollback generator to run.MaxSheetSizeForRollback = 8 * 1024 * 1024+ // MaxBinlogSizeLimit defines the upper limit for scanning the binlog text body size in search of a transaction..+ MaxBinlogSizeLimit = 32 * 1024 * 1024// MaxChunksCount is the maximum number of chunks for a sheet.MaxSheetChunksCount = 200diff --git a/backend/plugin/db/mysql/rollback.go b/backend/plugin/db/mysql/rollback.goindex 6b5b479c91..de15b57c5d 100644--- a/backend/plugin/db/mysql/rollback.go+++ b/backend/plugin/db/mysql/rollback.go@@ -15,6 +15,7 @@ import ("github.com/pingcap/tidb/pkg/parser/ast""github.com/pkg/errors"+ "github.com/bytebase/bytebase/backend/common"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"tidbparser "github.com/bytebase/bytebase/backend/plugin/parser/tidb""github.com/bytebase/bytebase/backend/resources/mysqlutil"@@ -57,7 +58,7 @@ func (txn BinlogTransaction) GetRollbackSQL(tables map[string][]string) (string,// The binlog file names and positions are used to specify the binlog events range for rollback SQL generation.// tableCatalog is a map from table names to column names. It is used to map positional placeholders in the binlog events to the actual columns to generate valid SQL statements.// TODO(dragonly): parse/filter/generate rollback SQL in stream. Limit the generated SQL size to 8MB for now.-func (driver *Driver) GenerateRollbackSQL(ctx context.Context, binlogSizeLimit int, binlogFileNameList []string, binlogPosStart, binlogPosEnd int64, threadID string, tableCatalog map[string][]string) (string, error) {+func (driver *Driver) GenerateRollbackSQL(ctx context.Context, binlogFileNameList []string, binlogPosStart, binlogPosEnd int64, threadID string, tableCatalog map[string][]string) (string, error) {if ctx.Err() != nil {return "", ctx.Err()}@@ -100,7 +101,7 @@ func (driver *Driver) GenerateRollbackSQL(ctx context.Context, binlogSizeLimit ireturn "", errors.Wrap(err, "failed to run mysqlbinlog")}- txnList, err := ParseBinlogStream(ctx, pr, threadID, binlogSizeLimit)+ txnList, err := ParseBinlogStream(ctx, pr, threadID, common.MaxBinlogSizeLimit)if err != nil {return "", errors.WithMessage(err, "failed to parse binlog stream")}diff --git a/backend/runner/rollbackrun/runner.go b/backend/runner/rollbackrun/runner.goindex 1dc804585a..5c9b569106 100644--- a/backend/runner/rollbackrun/runner.go+++ b/backend/runner/rollbackrun/runner.go@@ -212,12 +212,11 @@ func (r *Runner) generateMySQLRollbackSQL(ctx context.Context, task *store.TaskMvar rollbackSQLStatus api.RollbackSQLStatusvar rollbackStatement, rollbackError string- const binlogSizeLimit = 8 * 1024 * 1024- rollbackSQL, err := r.generateMySQLRollbackSQLImpl(ctx, payload, binlogSizeLimit, instance)+ rollbackSQL, err := r.generateMySQLRollbackSQLImpl(ctx, payload, instance)if err != nil {rollbackSQLStatus = api.RollbackSQLStatusFailedif mysql.IsErrExceedSizeLimit(err) {- rollbackError = fmt.Sprintf("Failed to generate rollback SQL statement. Abort because read more than %vKB from binlog stream.", binlogSizeLimit/1024)+ rollbackError = fmt.Sprintf("Failed to generate rollback SQL statement. Abort because read more than %vMB from binlog stream.", common.MaxBinlogSizeLimit/1024/1024)} else if mysql.IsErrParseBinlogName(err) {rollbackError = "Failed to generate rollback SQL statement. Please check if binlog is enabled."} else {@@ -253,7 +252,7 @@ func (r *Runner) generateMySQLRollbackSQL(ctx context.Context, task *store.TaskMslog.Debug("Rollback SQL generation success", slog.Int("taskID", task.ID))}-func (r *Runner) generateMySQLRollbackSQLImpl(ctx context.Context, payload *api.TaskDatabaseDataUpdatePayload, binlogSizeLimit int, instance *store.InstanceMessage) (string, error) {+func (r *Runner) generateMySQLRollbackSQLImpl(ctx context.Context, payload *api.TaskDatabaseDataUpdatePayload, instance *store.InstanceMessage) (string, error) {if ctx.Err() != nil {return "", ctx.Err()}@@ -312,7 +311,7 @@ func (r *Runner) generateMySQLRollbackSQLImpl(ctx context.Context, payload *api.if err := mysqlDriver.CheckBinlogRowFormat(ctx); err != nil {return "", err}- rollbackSQL, err := mysqlDriver.GenerateRollbackSQL(ctx, binlogSizeLimit, binlogFileNameList, payload.BinlogPosStart, payload.BinlogPosEnd, payload.ThreadID, tableMap)+ rollbackSQL, err := mysqlDriver.GenerateRollbackSQL(ctx, binlogFileNameList, payload.BinlogPosStart, payload.BinlogPosEnd, payload.ThreadID, tableMap)if err != nil {return "", errors.WithMessage(err, "failed to generate rollback SQL statement")}