Closed ws-spring closed 1 year ago
Hello @ws-spring, thanks for the report. This difference of behavior between drivers in 4.4 has already been identified.
The bad news is that the behavior cannot be changed in 4.4, as that would be a breaking change for some.
The good news is that the implementation has been much improved in 5.x so I would recommend upgrading as the best way forward.
If upgrading is not an option, you will have to work around 4.4 transaction unideal behavior and do something like this:
tx, err := session.BeginTransaction()
if err != nil {
handle(err)
return
}
result, err := tx.Run("<cypher query>", params)
if err != nil {
_ = tx.Rollback()
handle(err)
return
}
// will cause most query errors to show up here
if _, err := result.Consume(); err != nil {
_ = tx.Rollback()
handle(err)
return
}
// only at this point rollback-specific errors will show up (or commit-specific errors)
if err = tx.Rollback(); err != nil { // or call tx.Commit()
handle(err)
return
}
Guidelines
The same link is under a manual transaction, after encountering an error, the transaction rollback operation cannot be performed (manual), and the prompt information is the error prompt before the rollback. java-driver can roll back in the same situation.
Example bug report
I got connection reset by peer errors.
Neo4j Version: 4.4 Community
Neo4j Mode: Single instance
Driver version: Go driver 4.4.5 Operating System: window 11
Steps to reproduce
Execute an illegal statement
Expected behavior
Actual behavior