Skip to content

Transactions created with TxContext don't rollback (at least using the mysql driver) #731

Description

@acwest

I am creating a transaction with:

session.TxContext(ctx, func(txSession db.Session) error {
  err := DoSomething(txSession)
  return err
}, nil)

DoSomething internally uses InsertReturning to insert a number of rows into a table.

If I cancel the transaction while it is running, an InsertReturning call returns an error: "context canceled", so DoSomething returns the same error. The TxContext call then returns an error: "context canceled: context canceled", which is somewhat expected behaviour, but the transaction is not rolled back and all of the rows added to the table are still there.
The expected behaviour would be for the transaction to roll back and the rows to not be commited to the table.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions