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.