zmactep / hasbolt

Haskell driver for Neo4j 3+ (BOLT protocol)
BSD 3-Clause "New" or "Revised" License
82 stars 13 forks source link

Fragile Pipes Syndrome #6

Closed Tshimanga closed 7 years ago

Tshimanga commented 7 years ago

I seem to have an affliction of fragile pipes. From what I've observed anytime I try to bind records returned by a query to a variable for later use, the pipe breaks immediately thereafter. Here's an example

>>>pipe <- connect $ def {user = "neo4j", password = "neo4j"}
(0.00 secs, 397,056 bytes)

>>>run pipe $ query "create (n) return n"
[fromList [("n",S (Structure {signature = 78, fields = [I 389,L [],M (fromList [])]}))]]
(0.00 secs, 567,568 bytes)

>>>run pipe $ query "match (n) return n"
[fromList [("n",S (Structure {signature = 78, fields = [I 389,L [],M (fromList [])]}))]]
(0.00 secs, 554,896 bytes)

>>>records <- run pipe $ query "create (n) return n"
(0.00 secs, 437,872 bytes)

>>>run pipe $ query "match (n) return n"
[]
(0.00 secs, 450,728 bytes)

>>>run pipe $ query "match (n) return n"
*** Exception: user error (Unknown error)

>>>run pipe $ query "match (n) return n"
*** Exception: sendBuf: resource vanished (Broken pipe)

>>>run pipe $ query "match (n) return n"
*** Exception: writev: resource vanished (Broken pipe)

>>>

How might I fix this issue?

Thanks again, Kerim

zmactep commented 7 years ago

Hi Kerim!

I think this issue is caused by lazy IO. To fix it in your code try to use strict versions of functions like query' and queryP'.

Lazy versions are added to work with large graphs, but this imposes a limitation as you should take out all the data before the next query run.

Tshimanga commented 7 years ago

Great, that was indeed it! Thanks for the help Pavel!