forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2edf14f
committed
Try to read data from the socket in pqSendSome's write_failed paths.
Even when we've concluded that we have a hard write failure on thesocket, we should continue to try to read data. This gives us anopportunity to collect any final error message that the backend mighthave sent before closing the connection; moreover it is the job ofpqReadData not pqSendSome to close the socket once EOF is detected.Due to an oversight in1f39a1c, pqSendSome failed to try to collectdata in the case where we'd already set write_failed. The problem wasmasked for ordinary query operations (which really only make one writeattempt anyway), but COPY to the server would continue to send dataindefinitely after a mid-COPY connection loss.Hence, add pqReadData calls into the paths where pqSendSome drops databecause of write_failed. If we've lost the connection, this willeventually result in closing the socket and setting CONNECTION_BAD,which will cause PQputline and siblings to report failure, allowingthe application to terminate the COPY sooner. (Basically this restoreswhat happened before1f39a1c.)There are related issues that this does not solve; for example, if thebackend sends an error but doesn't drop the connection, we did andstill will keep pumping COPY data as long as the application sends it.Fixing that will require application-visible behavior changes though,and anyway it's an ancient behavior that we've had few complaints about.For now I'm just trying to fix the regression from1f39a1c.Per a complaint from Andres Freund. Back-patch into v12 where1f39a1c came in.Discussion:https://postgr.es/m/20200603201242.ofvm4jztpqytwfye@alap3.anarazel.de1 parenta00222f commit2edf14f
1 file changed
+20
-1
lines changedLines changed: 20 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
825 | 825 |
| |
826 | 826 |
| |
827 | 827 |
| |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
828 | 832 |
| |
829 | 833 |
| |
830 | 834 |
| |
| |||
844 | 848 |
| |
845 | 849 |
| |
846 | 850 |
| |
847 |
| - | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
848 | 854 |
| |
849 | 855 |
| |
850 | 856 |
| |
851 | 857 |
| |
852 | 858 |
| |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
853 | 865 |
| |
854 | 866 |
| |
855 | 867 |
| |
| |||
919 | 931 |
| |
920 | 932 |
| |
921 | 933 |
| |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
922 | 941 |
| |
923 | 942 |
| |
924 | 943 |
| |
|
0 commit comments
Comments
(0)