-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pg-cursor lib does not work against Pgpool-II since version 4.1.0 #59
Comments
I don't know why pgpool-II 4.0 accepted this but I think the client ought to send "Sync" message after the last flush message. |
I forgot to say that this code works when targeting PostgreSQL directly :) In brianc/node-postgres#2140 (comment) :
|
Hmm. If you enable statement_level_load_balance, can you try again with statement_level_load_balance disabled? |
I was just copying a message on the issue opened on the node client :) Docs says it's off by default, and I've tried with both on an off values, it does not change anything. |
Can you share pgpool log with "log_min_messages = debug5"? |
Here you go (from a test case with only the issue) Logs
|
Thanks. I see it now. It seems pg-cursor uses "Portal Suspended" message to implement a cursor: it sends an execute message with upper limit for the number of rows returned parameter. Every time the number of rows returned reachs the number, backend sends a Portal suspended message ('s'). It should have been forwarded to frontend but unfortunately pgpool buffered it even after a flush message sent from frontend. Thus the frontend waits for the message and pgpool also waits fro next message frontend: deadlock. |
I'll try building dokku from source to check the patch. Thanks :) |
I'm still having the same issue, here's new logs: Logs
|
My bad. I was checking the read buffer. I should have checked write buffer. The write buffer checking will be done in pool_flush and unconditional calling to pool_flush is ok. New patch attached. |
Nice ! This does fix the issue :) Thanks :) |
Glad to hear that! |
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Previously pgpool could hang after a flush message arrives. Consider following scenario: (1) backend sends a portal suspend message. (2) pgool write it in the frontend write buffer. But not flush it. (3) The frontend sends a flush message to pgpool. (4) pgpool fowards the flush message to backend. (5) Since there's no pending message in backend, nothing happen. (6) The frontend waits for the portal suspend message from pgpool in vain. To fix this, at (4) pgpool flushes data in the frontend write buffer if some data remains (in this case the portal suspend message). Then the frontend will send next request message to pgpool. Discussion: #59 Backpatch-through: master, 4.5, 4.4, 4.3, 4.2 and 4.1.
Hello !
I'm using pg-cursor (node lib, see https://node-postgres.com/apis/cursor) which worked with Pgpool-II up to version 4.0.25, however version 4.1.0 leads to a timeout.
I've replied to an issue over there too brianc/node-postgres#2140 (comment), but I'm not sure where the problem is located.
Reproducing js code is:
logs with
log_client_messages = on
Source code of pg-cursor: https://github.com/brianc/node-postgres/blob/master/packages/pg-cursor/index.js#L42
The text was updated successfully, but these errors were encountered: