Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add rollback for load data statement (#9444) #10862

Merged
merged 2 commits into from
Jun 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,21 +855,28 @@ func (cc *clientConn) handleLoadData(ctx context.Context, loadDataInfo *executor
}
}

if err = loadDataInfo.Ctx.StmtCommit(); err != nil {
return errors.Trace(err)
}
txn, err := loadDataInfo.Ctx.Txn(true)
if err != nil {
loadDataInfo.Ctx.StmtRollback()
} else {
err = loadDataInfo.Ctx.StmtCommit()
}

var txn kv.Transaction
var err1 error
txn, err1 = loadDataInfo.Ctx.Txn(true)
if err1 == nil {
if txn != nil && txn.Valid() {
if err1 := txn.Rollback(); err1 != nil {
logutil.Logger(ctx).Error("load data rollback failed", zap.Error(err1))
if err != nil {
if err1 := txn.Rollback(); err1 != nil {
logutil.Logger(ctx).Error("load data rollback failed", zap.Error(err1))
}
return errors.Trace(err)
}
return errors.Trace(cc.ctx.CommitTxn(sessionctx.SetCommitCtx(ctx, loadDataInfo.Ctx)))
}
return errors.Trace(err)
}

txn.SetOption(kv.BypassLatch, true)
return errors.Trace(cc.ctx.CommitTxn(sessionctx.SetCommitCtx(ctx, loadDataInfo.Ctx)))
// Should never reach here.
panic(err1)
}

// handleLoadStats does the additional work after processing the 'load stats' query.
Expand Down