bytebase/bytebase · error

statement size %d exceeds the limit %d, please disable data

Error message

statement size %d exceeds the limit %d, please disable data backup

What it means

Raised when the DML statement to be migrated (with prior backup enabled) exceeds common.MaxSheetCheckSize in bytes. Before performing a prior backup, backupData must transform the DML into SELECT statements to snapshot affected rows; statements beyond the size limit are refused because the transform/sheet pipeline cannot handle them, and the error explicitly suggests disabling data backup.

Source

Thrown at backend/runner/taskrun/database_migrate_executor.go:846

	tc := parserbase.TransformContext{
		InstanceID:              instance.ResourceID,
		GetDatabaseMetadataFunc: buildGetDatabaseMetadataFunc(exec.store, instance.Workspace),
		ListDatabaseNamesFunc:   buildListDatabaseNamesFunc(exec.store),
		IsCaseSensitive:         store.IsObjectCaseSensitive(instance),
		DatabaseName:            database.DatabaseName,
	}
	if database.Engine == storepb.Engine_ORACLE {
		oracleDriver, ok := driver.(*oracle.Driver)
		if ok {
			if version, err := oracleDriver.GetVersion(); err == nil {
				tc.Version = version
			}
		}
	}

	if len(originStatement) > common.MaxSheetCheckSize {
		return nil, errors.Errorf("statement size %d exceeds the limit %d, please disable data backup", len(originStatement), common.MaxSheetCheckSize)
	}

	prefix := "_" + time.Now().Format("20060102150405")
	statements, err := parserbase.TransformDMLToSelect(ctx, database.Engine, tc, originStatement, database.DatabaseName, backupDatabaseName, prefix)
	if err != nil {
		return nil, errors.Wrap(err, "failed to transform DML to select")
	}
	if len(statements) == 0 {
		return &storepb.PriorBackupDetail{}, nil
	}

	prependStatements, err := getPrependStatements(database.Engine, originStatement)
	if err != nil {
		return nil, errors.Wrap(err, "failed to get prepend statements")
	}

	priorBackupDetail := &storepb.PriorBackupDetail{}
	bbSource := fmt.Sprintf("task %d", task.ID)

View on GitHub (pinned to 1870550677)

Solutions

  1. Disable prior backup (data backup) for this task if a pre-migration snapshot is not needed — as the message suggests.
  2. Split the large DML into multiple smaller migration tasks/statements, each under MaxSheetCheckSize.
  3. Use Bytebase's dedicated backup feature for the affected tables instead of statement-level prior backup.
  4. If the script is generated, cap generated batch sizes so each migration sheet stays within the limit.

Example fix

// before: one giant DML sheet with prior backup on
// statement size 5242880 exceeds the limit 1048576, please disable data backup
// after: chunk the DML before submitting
const chunk = 500
for i := 0; i < len(dmlStatements); i += chunk {
	end := min(i+chunk, len(dmlStatements))
	submitMigration(strings.Join(dmlStatements[i:end], ";\n"), enablePriorBackup=true)
}
Defensive patterns

Strategy: validation

Validate before calling

// check size before enabling prior backup on a task
if payload.GetEnablePriorBackup() && len(originStatement) > common.MaxSheetCheckSize {
	return fmt.Errorf("statement too large (%d bytes) for prior backup; split the migration or disable data backup", len(originStatement))
}

Try / catch

if len(originStatement) > common.MaxSheetCheckSize {
	return nil, errors.Errorf("statement size %d exceeds the limit %d, please disable data backup", len(originStatement), common.MaxSheetCheckSize)
}

Prevention

When it happens

Trigger: A standard migration task with enablePriorBackup=true submits an originStatement whose len() > common.MaxSheetCheckSize (a very large batched INSERT/UPDATE/DELETE or generated migration script).

Common situations: Bulk data-backfill migrations with thousands of statements concatenated into one sheet; machine-generated SQL dumps applied as a single migration; teams enabling prior backup by default on projects that also run bulk data loads.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/94526fe72993162a. Report an issue: GitHub.