diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2023-04-06 10:32:40 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2023-04-17 17:25:32 +0300 |
commit | b7492443beb518d87a30ad0bd49a7df92e17c152 (patch) | |
tree | 7e8fef0e2218a24ae2334a43169a908323830cfc | |
parent | 2dc7597fff9f51ba570dc5fc52dd86c477a328db (diff) |
Return an error from Rollback
Rollback will soon have logic to clean up after the Transaction.
Change the signature to return an error as well so we can return
any clean up errors to the caller.
-rw-r--r-- | internal/gitaly/transaction_manager.go | 4 | ||||
-rw-r--r-- | internal/gitaly/transaction_manager_test.go | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/internal/gitaly/transaction_manager.go b/internal/gitaly/transaction_manager.go index fbb7ea616..a05d1a7a2 100644 --- a/internal/gitaly/transaction_manager.go +++ b/internal/gitaly/transaction_manager.go @@ -179,7 +179,9 @@ func (txn *Transaction) Commit(ctx context.Context) error { } // Rollback releases resources associated with the transaction without performing any changes. -func (txn *Transaction) Rollback() {} +func (txn *Transaction) Rollback() error { + return nil +} // Snapshot returns the details of the Transaction's read snapshot. func (txn *Transaction) Snapshot() Snapshot { diff --git a/internal/gitaly/transaction_manager_test.go b/internal/gitaly/transaction_manager_test.go index 08635067c..86186948f 100644 --- a/internal/gitaly/transaction_manager_test.go +++ b/internal/gitaly/transaction_manager_test.go @@ -2018,7 +2018,7 @@ func TestTransactionManager(t *testing.T) { require.ErrorIs(t, transaction.Commit(commitCtx), step.ExpectedError) case Rollback: require.Contains(t, openTransactions, step.TransactionID, "test error: transaction rollbacked before beginning it") - openTransactions[step.TransactionID].Rollback() + require.NoError(t, openTransactions[step.TransactionID].Rollback()) default: t.Fatalf("unhandled step type: %T", step) } |