postgresql-simple icon indicating copy to clipboard operation
postgresql-simple copied to clipboard

Drop lock during getCopyData?

Open ryantrinkle opened this issue 7 years ago • 2 comments

Would it be reasonable to drop the connection lock here? https://github.com/lpsmith/postgresql-simple/blob/14d00c22713aab7d55a81a81b47cc5bb7280398f/src/Database/PostgreSQL/Simple/Copy.hs#L135

I'm working on some code that needs to interleave (blocking) getCopyData and putCopyData. It seems to work for me when I manually break through the lock for putCopyData and flush, but I'm not sure whether that's actually OK.

ryantrinkle avatar Aug 01 '18 23:08 ryantrinkle

Maybe? It's been a long time since I've worked or thought about this bit of code. Though we would need to adopt some of the techniques in the Notification module in order to avoid some race conditions.

I'm not yet familiar with such use cases. Do you have a pointer to some documentation I could look at?

lpsmith avatar Aug 13 '18 17:08 lpsmith

I guess an alternative would be to explicitly support PGRES_COPY_BOTH mode. My specific use case is a replication connection, which requires the client to periodically send heartbeats to the server while continuing to (blockingly) wait on downstream content.

The documentation I'm following is here.

ryantrinkle avatar Aug 13 '18 19:08 ryantrinkle