neo4j-php / neo4j-php-client

Php client and driver for neo4j database
https://neo4j.com/developer/php/
MIT License
160 stars 40 forks source link

fixed few tests. moved reset to better place. #202

Closed stefanak-michal closed 6 months ago

stefanak-michal commented 6 months ago

Most important change is: I've removed calling reset in runStatement and I've added it into assertNoFailure. So for any call which ends in failure is automatically called. I believe that is desired, so the client would be able to recover by itself.

stefanak-michal commented 6 months ago

I wrote you a message, here is a copy, which is a reason why I commented two tests.

I've discovered something interesting. When you try to call COMMIT on server in READY state (without opening transaction), it will generate FAILURE response. Which is correct. But RESET can't be send. On older neo4j versions it just does nothing and bolt get stuck on trying to read from empty buffer from db. on newer neo4j version (>=5.12) you get disconnected immediately by neo4j after that failure. You can't even reset, you just have to reconnect. same with rollback

stefanak-michal commented 6 months ago

It was confirmed by Neo4j. I will update reading from Bolt on https://github.com/neo4j-php/Bolt/issues/137 but it was suggested to follow server state. Therefore I'm thinking about checking server state in bolt methods in src/Bolt/BoltUnmanagedTransaction.php.

Don't merge this yet.

stefanak-michal commented 6 months ago

okay @transistive , now it's ready. I had to upgrade something in bolt to properly handle server state. https://github.com/neo4j-php/Bolt/pull/139

It's keeping track of open "streams". When you do multiple RUN in open transaction, each one has qid and you have to pull/discard by this qid. But while your transaction is open and you have some not consumed "streams", server state stays in TX_STREAMING. It's explained here https://www.neo4j.com/docs/bolt/current/bolt/message/#transaction in that second example.

Now it is ready for merge.