Skip to content

Commit

Permalink
ddl: roll back txn before handling ErrEntryTooLarge (pingcap#43867)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored and ti-chi-bot committed May 16, 2023
1 parent 04aef00 commit f2f0190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ func TestDDLJobErrorCount(t *testing.T) {
require.NotNil(t, historyJob)
require.Equal(t, int64(1), historyJob.ErrorCount)
require.True(t, kv.ErrEntryTooLarge.Equal(historyJob.Error))
tk.MustQuery("select * from ddl_error_table;").Check(testkit.Rows())
}

func TestCommitTxnWithIndexChange(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ func (w *worker) handleUpdateJobError(t *meta.Meta, job *model.Job, err error) e
}
if kv.ErrEntryTooLarge.Equal(err) {
logutil.Logger(w.logCtx).Warn("[ddl] update DDL job failed", zap.String("job", job.String()), zap.Error(err))
w.sess.Rollback()
err1 := w.sess.Begin()
if err1 != nil {
return errors.Trace(err1)
}
// Reduce this txn entry size.
job.BinlogInfo.Clean()
job.Error = toTError(err)
Expand Down

0 comments on commit f2f0190

Please sign in to comment.