Skip to content

TTL txn will not return error when rolling back #39917

Closed
@lcwangchao

Description

func (s *session) RunInTxn(ctx context.Context, fn func() error) (err error) {
tracer := metrics.PhaseTracerFromCtx(ctx)
defer tracer.EnterPhase(tracer.Phase())
tracer.EnterPhase(metrics.PhaseBeginTxn)
if _, err = s.ExecuteSQL(ctx, "BEGIN"); err != nil {
return err
}
tracer.EnterPhase(metrics.PhaseOther)
success := false
defer func() {
if !success {
_, err = s.ExecuteSQL(ctx, "ROLLBACK")
terror.Log(err)
}
}()

When rollingback, the error will be reset to nil

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions