diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index 7940822fdfd0c..379449037d59d 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -1259,7 +1259,16 @@ func (d *ddl) getModifiableColumnJob(ctx context.Context, ident ast.Ident, origi } newCol := table.ToColumn(&model.ColumnInfo{ - ID: col.ID, + ID: col.ID, + // We use this PR(https://github.com/pingcap/tidb/pull/6274) as the dividing line to define whether it is a new version or an old version TiDB. + // The old version TiDB initializes the column's offset and state here. + // The new version TiDB doesn't initialize the column's offset and state, and it will do the initialization in run DDL function. + // When we do the rolling upgrade the following may happen: + // a new version TiDB builds the DDL job that doesn't be set the column's offset and state, + // and the old version TiDB is the DDL owner, it doesn't get offset and state from the store. Then it will encounter errors. + // So here we set offset and state to support the rolling upgrade. + Offset: col.Offset, + State: col.State, OriginDefaultValue: col.OriginDefaultValue, FieldType: *spec.NewColumn.Tp, Name: spec.NewColumn.Name.Name,