From d6e48505592ae900ac61b17203bc146fa7d77144 Mon Sep 17 00:00:00 2001 From: qiuyesuifeng Date: Tue, 10 Nov 2015 12:21:53 +0800 Subject: [PATCH 1/3] ddl: fix column value exist backfill bug. --- ddl/column.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddl/column.go b/ddl/column.go index df24f97617..3d14cbd25c 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -366,10 +366,13 @@ func (d *ddl) backfillColumnData(t table.Table, columnInfo *model.ColumnInfo, ha } backfillKey := t.RecordKey(handle, &column.Col{ColumnInfo: *columnInfo}) - _, err = txn.Get(backfillKey) + backfillValue, err := txn.Get(backfillKey) if err != nil && !kv.IsErrNotFound(err) { return errors.Trace(err) } + if backfillValue != nil { + return nil + } value, _, err := tables.GetColDefaultValue(nil, columnInfo) if err != nil { From 3256ce28272407a37e5f32207e41562bebbf7f1c Mon Sep 17 00:00:00 2001 From: qiuyesuifeng Date: Tue, 10 Nov 2015 13:41:41 +0800 Subject: [PATCH 2/3] ddl: address comment. --- ddl/column.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ddl/column.go b/ddl/column.go index 3d14cbd25c..c1365a6989 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -329,6 +329,12 @@ func (d *ddl) onDropColumn(t *meta.Meta, job *model.Job) error { } } +// How to backfill column data in reorganization state? +// 1, Generate a snapshot with special version. +// 2, Traverse the snapshot, get every row in the table. +// 3, For one row, if the row has been already deleted, skip to next row. +// 4, If not deleted, check whether column data has existed, if existed, skip to next row. +// 5, If column data doesn't exist, backfill the column with default value and then continue to handle next row. func (d *ddl) backfillColumn(t table.Table, columnInfo *model.ColumnInfo, version uint64, seekHandle int64) error { for { handles, err := d.getSnapshotRows(t, version, seekHandle) From c210aafc9fcb2114e92b163967f9d07a06ff28f2 Mon Sep 17 00:00:00 2001 From: qiuyesuifeng Date: Tue, 10 Nov 2015 17:21:46 +0800 Subject: [PATCH 3/3] ddl: address comment. --- ddl/column.go | 10 +++++----- ddl/index.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ddl/column.go b/ddl/column.go index 1643a5f956..276b0b08d4 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -305,11 +305,11 @@ func (d *ddl) onDropColumn(t *meta.Meta, job *model.Job) error { } // How to backfill column data in reorganization state? -// 1, Generate a snapshot with special version. -// 2, Traverse the snapshot, get every row in the table. -// 3, For one row, if the row has been already deleted, skip to next row. -// 4, If not deleted, check whether column data has existed, if existed, skip to next row. -// 5, If column data doesn't exist, backfill the column with default value and then continue to handle next row. +// 1. Generate a snapshot with special version. +// 2. Traverse the snapshot, get every row in the table. +// 3. For one row, if the row has been already deleted, skip to next row. +// 4. If not deleted, check whether column data has existed, if existed, skip to next row. +// 5. If column data doesn't exist, backfill the column with default value and then continue to handle next row. func (d *ddl) backfillColumn(t table.Table, columnInfo *model.ColumnInfo, reorgInfo *reorgInfo) error { seekHandle := reorgInfo.Handle version := reorgInfo.SnapshotVer diff --git a/ddl/index.go b/ddl/index.go index ebfc1d1d75..8c397656b9 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -332,11 +332,11 @@ func fetchRowColVals(txn kv.Transaction, t table.Table, handle int64, indexInfo const maxBatchSize = 1024 // How to add index in reorganization state? -// 1, Generate a snapshot with special version. -// 2, Traverse the snapshot, get every row in the table. -// 3, For one row, if the row has been already deleted, skip to next row. -// 4, If not deleted, check whether index has existed, if existed, skip to next row. -// 5, If index doesn't exist, create the index and then continue to handle next row. +// 1. Generate a snapshot with special version. +// 2. Traverse the snapshot, get every row in the table. +// 3. For one row, if the row has been already deleted, skip to next row. +// 4. If not deleted, check whether index has existed, if existed, skip to next row. +// 5. If index doesn't exist, create the index and then continue to handle next row. func (d *ddl) addTableIndex(t table.Table, indexInfo *model.IndexInfo, reorgInfo *reorgInfo) error { seekHandle := reorgInfo.Handle version := reorgInfo.SnapshotVer