Skip to content

Commit

Permalink
Do not commit read-only transactions
Browse files Browse the repository at this point in the history
This a marginal improvement which follows the C API documentation:
> It is not necessary to commit a read-only transaction – you can simply call fdb_transaction_destroy().
  • Loading branch information
gm42 committed May 6, 2024
1 parent 8183224 commit f40de3c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bindings/go/src/fdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (d Database) Transact(f func(Transaction) (interface{}, error)) (interface{
//
// The transaction is retried if the error is or wraps a retryable Error.
// The error is unwrapped.
// Read transactions are never committed and destroyed upon garbage collection.
//
// Do not return Future objects from the function provided to ReadTransact. The
// Transaction created by ReadTransact may be finalized at any point after
Expand All @@ -230,9 +231,7 @@ func (d Database) ReadTransact(f func(ReadTransaction) (interface{}, error)) (in

ret, e = f(tr)

if e == nil {
e = tr.Commit().Get()
}
// read-only transactions are not committed and destroyed automatically on Go garbage collection

return
}
Expand Down

0 comments on commit f40de3c

Please sign in to comment.