neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
490 stars 69 forks source link

Session is still usable even after explicitly closing it #569

Closed oleriajm closed 7 months ago

oleriajm commented 7 months ago

Guidelines

https://github.com/neo4j/neo4j-go-driver/pull/568

The Session must not be usable after the caller closed it explicitly.

Following pattern works just fine at the moment

session := driver.NewSession(ctx, sessionConfig)
    session.Close()

    session.ExecuteRead(...)
    // and keep using session with more operations...

This is because Closing session cleans up pool/router etc, but all the references are still preserved.

As a good practice, the behavior should be fail-fast/fail-hard once you called Close on it

see here https://github.com/neo4j/neo4j-go-driver/pull/568

Example bug report

Steps to reproduce

see https://github.com/neo4j/neo4j-go-driver/pull/568

Expected behavior

Actual behavior

StephenCathcart commented 7 months ago

@oleriajm thank you very much for bringing this to our attention. I'm able to reproduce the bug on my end. I'll review the attached PR asap.

StephenCathcart commented 7 months ago

Fixed by PR https://github.com/neo4j/neo4j-go-driver/pull/570, attempting to use a closed session now returns a usage error. Thank you @oleriajm for bringing this to our attention 👍.