Hi, Thanks for the feedback.
> During COPY input, DoingCommandRead is false. The read-wait path in > ProcessClientReadInterrupt() then handles ProcDiePending, but not > TransactionTimeoutPending. Could the fix cover this path too? Thanks, Andrey. Yes. I initially thought the DoingCommandRead branch already covered ClientRead. I reproduced the issue by leaving COPY FROM STDIN waiting for input past the transaction timeout. It looks like the same approach as for ClientWrite should work in ProcessClientReadInterrupt(). I've attached v2 with that change. > It works if the timer fires while the backend is already blocked in > the write, but if the client has already stopped reading and the timer > fires while the backend is still doing something else, > ProcessInterrupts() clears TransactionTimeoutPending and raises the > FATAL, then pq_flush() blocks. At that point nothing is pending for > ProcessClientWriteInterrupt() to act on, so we wait forever, and the > transaction is only aborted later in proc_exit(). Thanks, Zsolt. Oh, yes, I see what you mean. But I think this goes a bit beyond transaction_timeout. The same thing can happen with SIGTERM when ProcessInterrupts() handles ProcDiePending. So I plan to address this in a separate patch in v2. Once the backend has decided to terminate the connection, sending the error to the client should be best-effort. The patch changes send_message_to_frontend() to send FATAL reports to client sockets without waiting for the socket to become writable. That lets the backend exit after either a transaction timeout or SIGTERM, even if the client has stopped reading. Does that approach sound reasonable? I've attached v2 as two separate patches. --- Regards, Jingtang
v2-0001-Honor-transaction-timeout-during-blocked-client-reads-and-writes.patch
Description: Binary data
v2-0002-Avoid-blocking-on-client-output-when-reporting-FATAL-errors.patch
Description: Binary data
