Skip to content

Commit

Permalink
ddl: roll back txn before handling ErrEntryTooLarge (#43867) (#43879)
Browse files Browse the repository at this point in the history
close #43725
  • Loading branch information
ti-chi-bot committed May 16, 2023
1 parent d6af9e9 commit 6d29491
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 @@ -974,6 +974,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())
}

// TestAddIndexFailOnCaseWhenCanExit is used to close #19325.
Expand Down
5 changes: 5 additions & 0 deletions ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,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 6d29491

Please sign in to comment.