{"record":{"id":"94526fe72993162a","repo":"bytebase/bytebase","slug":"statement-size-d-exceeds-the-limit-d-please-dis","errorCode":null,"errorMessage":"statement size %d exceeds the limit %d, please disable data backup","messagePattern":"statement size (.+?) exceeds the limit (.+?), please disable data backup","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/runner/taskrun/database_migrate_executor.go","lineNumber":846,"sourceCode":"\n\ttc := parserbase.TransformContext{\n\t\tInstanceID:              instance.ResourceID,\n\t\tGetDatabaseMetadataFunc: buildGetDatabaseMetadataFunc(exec.store, instance.Workspace),\n\t\tListDatabaseNamesFunc:   buildListDatabaseNamesFunc(exec.store),\n\t\tIsCaseSensitive:         store.IsObjectCaseSensitive(instance),\n\t\tDatabaseName:            database.DatabaseName,\n\t}\n\tif database.Engine == storepb.Engine_ORACLE {\n\t\toracleDriver, ok := driver.(*oracle.Driver)\n\t\tif ok {\n\t\t\tif version, err := oracleDriver.GetVersion(); err == nil {\n\t\t\t\ttc.Version = version\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(originStatement) > common.MaxSheetCheckSize {\n\t\treturn nil, errors.Errorf(\"statement size %d exceeds the limit %d, please disable data backup\", len(originStatement), common.MaxSheetCheckSize)\n\t}\n\n\tprefix := \"_\" + time.Now().Format(\"20060102150405\")\n\tstatements, err := parserbase.TransformDMLToSelect(ctx, database.Engine, tc, originStatement, database.DatabaseName, backupDatabaseName, prefix)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to transform DML to select\")\n\t}\n\tif len(statements) == 0 {\n\t\treturn &storepb.PriorBackupDetail{}, nil\n\t}\n\n\tprependStatements, err := getPrependStatements(database.Engine, originStatement)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get prepend statements\")\n\t}\n\n\tpriorBackupDetail := &storepb.PriorBackupDetail{}\n\tbbSource := fmt.Sprintf(\"task %d\", task.ID)","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/runner/taskrun/database_migrate_executor.go#L828-L864","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Disable prior backup (data backup) for this task if a pre-migration snapshot is not needed — as the message suggests.","Split the large DML into multiple smaller migration tasks/statements, each under MaxSheetCheckSize.","Use Bytebase's dedicated backup feature for the affected tables instead of statement-level prior backup.","If the script is generated, cap generated batch sizes so each migration sheet stays within the limit."],"exampleFix":"// before: one giant DML sheet with prior backup on\n// statement size 5242880 exceeds the limit 1048576, please disable data backup\n// after: chunk the DML before submitting\nconst chunk = 500\nfor i := 0; i < len(dmlStatements); i += chunk {\n\tend := min(i+chunk, len(dmlStatements))\n\tsubmitMigration(strings.Join(dmlStatements[i:end], \";\\n\"), enablePriorBackup=true)\n}","handlingStrategy":"validation","validationCode":"// check size before enabling prior backup on a task\nif payload.GetEnablePriorBackup() && len(originStatement) > common.MaxSheetCheckSize {\n\treturn fmt.Errorf(\"statement too large (%d bytes) for prior backup; split the migration or disable data backup\", len(originStatement))\n}","typeGuard":null,"tryCatchPattern":"if len(originStatement) > common.MaxSheetCheckSize {\n\treturn nil, errors.Errorf(\"statement size %d exceeds the limit %d, please disable data backup\", len(originStatement), common.MaxSheetCheckSize)\n}","preventionTips":["Cap generated batch DML sizes below MaxSheetCheckSize","Split bulk backfills into multiple migration tasks","Only enable prior backup on tasks expected to be small; use table backups for bulk loads"],"tags":["backup","payload-too-large","limit","migration"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}