GORM Playground Link

Reference issue - playground link to follow

Description

In finisher_api.go:

    644    defer func() {
    645    // Make sure to rollback when panic, Block error or Commit error
    646        if panicked || err != nil {
    647        tx.Rollback()
    648        }
    649    }()
    650
    651    if err = fc(tx); err == nil {
    652        panicked = false
    653        return tx.Commit().Error
    654    }

Function tx.Rollback() is not called in case of failure on line 653.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: abusizhishen

GORM Playground Link

Reference issue - playground link to follow

Description

In finisher_api.go:

go 644 defer func() { 645 // Make sure to rollback when panic, Block error or Commit error 646 if panicked || err != nil { 647 tx.Rollback() 648 } 649 }() 650 651 if err = fc(tx); err == nil { 652 panicked = false 653 return tx.Commit().Error 654 }

Function tx.Rollback() is not called in case of failure on line 653.

commit error not assigned to err if error occour

 return tx.Commit().Error 

should be

err = tx.Commit().Error 
return err

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: a631807682

PR welcome.

Comment From: a631807682

Commit are usually divided into writing commit packet and reading results. If writing fails, we not need to rollback. Failure of reading results usually comes from network errors, which means our rollback may not succeed. This does not seem to be necessary, is there any actual case?

Comment From: chenjisuan

it is a Named-Return, it will assign result to err, i think Callback will be called if Commit return error.