neo4j-go-driver: SessionWithContext.BeginTransaction on a new session fails with error "invalid state 3, expected: [0]"

Calling SessionWithContext.BeginTransaction on a newly created session returns this error:

invalid state 3, expected: [0]

This is the assertion that fails: https://github.com/neo4j/neo4j-go-driver/blob/0f1f1e867c614b688394d50e8a9dff16c25f0569/neo4j/internal/bolt/bolt4.go#L303-L305

This session seems to be reused from the pool after previously being used to execute explicit transactions, and to have not been reset property when returned into the pool. The implementation of bolt4.TxBegin seems to deal specifically with auto-commit queries, but not with explicit transactions: https://github.com/neo4j/neo4j-go-driver/blob/0f1f1e867c614b688394d50e8a9dff16c25f0569/neo4j/internal/bolt/bolt4.go#L294-L301 I think this logic should be extended to deal with explicit transactions as well? Maybe replace:

	if b.state == bolt4_streaming {

with:

	if b.state == bolt4_streaming || b.state == bolt4_streamingtx {

???

I was previously using v5.0.0-preview where this bug didn’t occur. This is a regression.

Neo4j Version: 4.4.15-enterprise Neo4j Mode: Single instance
Driver version: Go driver 5.8.x Operating System: Ubuntu 16.10 on AWS

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks @rlenglet for the detailed analysis, we’ll work on a fix today.