{"record":{"id":"c4d9ea3eb7b94369","repo":"vitessio/vitess","slug":"copyschemashard-failed-because-schemas-could-not-b-c4d9ea","errorCode":null,"errorMessage":"CopySchemaShard failed because schemas could not be compared finally: %v","messagePattern":"CopySchemaShard failed because schemas could not be compared finally: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/schema.go","lineNumber":258,"sourceCode":"\t\t\t\t\" Full error: %v\", err)\n\t\t}\n\t}\n\n\t// Remember the replication position after all the above were applied.\n\tdestPrimaryPos, err := wr.tmc.PrimaryPosition(ctx, destTabletInfo.Tablet)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CopySchemaShard: can't get replication position after schema applied: %v\", err)\n\t}\n\n\t// Although the copy was successful, we have to verify it to catch the case\n\t// where the database already existed on the destination, but with different\n\t// options e.g. a different character set.\n\t// In that case, MySQL would have skipped our CREATE DATABASE IF NOT EXISTS\n\t// statement.\n\tif !skipVerify {\n\t\tdiffs, err = schematools.CompareSchemas(ctx, wr.ts, wr.tmc, sourceTabletAlias, destShardInfo.PrimaryAlias, tables, excludeTables, includeViews)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"CopySchemaShard failed because schemas could not be compared finally: %v\", err)\n\t\t}\n\t\tif diffs != nil {\n\t\t\treturn fmt.Errorf(\"CopySchemaShard was not successful because the schemas between the two tablets %v and %v differ: %v\", sourceTabletAlias, destShardInfo.PrimaryAlias, diffs)\n\t\t}\n\t}\n\n\t// Notify Replicas to reload schema. This is best-effort.\n\treloadCtx, cancel := context.WithTimeout(ctx, waitReplicasTimeout)\n\tdefer cancel()\n\tresp, err := wr.VtctldServer().ReloadSchemaShard(reloadCtx, &vtctldatapb.ReloadSchemaShardRequest{\n\t\tKeyspace:       destKeyspace,\n\t\tShard:          destShard,\n\t\tWaitPosition:   destPrimaryPos,\n\t\tConcurrency:    10,\n\t\tIncludePrimary: true,\n\t})\n\tif resp != nil {\n\t\tfor _, e := range resp.Events {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/schema.go#L240-L276","documentation":"With verification enabled (skipVerify false), CopySchemaShard calls schematools.CompareSchemas between source and destination tablets after copying. If the comparison RPC itself errors (rather than returning diffs), this error is thrown - the copy status is unknown because final validation could not run.","triggerScenarios":"CompareSchemas fails because the source or destination tablet's GetSchema RPC fails during verification, or the destination primary was unreachable immediately after the copy phase.","commonSituations":"Network blip right after schema application; destination tablet restarted; topo/tabletmanager timeouts during long schema copies.","solutions":["Retry CopySchemaShard; the copy is idempotent aside from the table-exists conflict case.","Run GetSchema on both tablets and diff manually to confirm state.","Rerun with skipVerify only as a last resort after manual verification."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"_, err := schematools.CompareSchemas(ctx, ts, tmc, src, dst, tables, excl, incl)\nif err != nil {\n    return fmt.Errorf(\"pre-check comparison failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"err := wr.CopySchemaShard(ctx, src, dst, tables, excl, false)\nif err != nil && strings.Contains(err.Error(), \"could not be compared\") {\n    // verify tablets reachable, retry\n}","preventionTips":["Pre-check that both tablets answer GetSchema before copying.","Run schema copies during low-load windows.","Retry transient RPC failures automatically."],"tags":["go","schema","verification","rpc"],"backgroundTag":"schema-compare-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}