Fix occasional hang in COPY FROM.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 16 Sep 2021 06:44:51 +0000 (15:44 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 16 Sep 2021 06:44:51 +0000 (15:44 +0900)
commita874078de54f63f958fa622295e06508b99a4a60
treee2bf57833b03a1659b2cc5039b68446f38ca75fa
parent491075d6b91451a77715f5789a37e344d81d7300
Fix occasional hang in COPY FROM.

If an error occurs while doing COPY FROM, it was possible the
Pgpool-II waited forever for a response from backend after COPY end
marker was sent from frontend. Pgpool expected a new message arrives
to socket, but it is possible that the message (in this case an error
message) is already in the backend read buffer. The fix is, check the
buffer is empty or not before reading from the socket.
New test case (07.copy_hang) is also added.

The bug was found by Bo Peng.
src/protocol/pool_proto_modules.c
src/test/regression/tests/076.copy_hang/test.sh [new file with mode: 0755]