- Notifications
You must be signed in to change notification settings - Fork4.9k
Commita8458f5
committed
Fix lost Windows socket EOF events.
Winsock only signals an FD_CLOSE event once if the other end of thesocket shuts down gracefully. Because each WaitLatchOrSocket() callconstructs and destroys a new event handle every time, with unluckytiming we can lose it and hang. We get away with this only if the otherend disconnects non-gracefully, because FD_CLOSE is repeatedly signaledin that case.To fix this design flaw in our Windows socket support fundamentally,we'd probably need to rearchitect it so that a single event handleexists for the lifetime of a socket, or switch to completely differentmultiplexing or async I/O APIs. That's going to be a bigger joband probably wouldn't be back-patchable.This brute force kludge closes the race by explicitly polling withMSG_PEEK before sleeping.Back-patch to all supported releases. This should hopefully clear upsome random build farm and CI hang failures reported over the years. Itmight also allow us to try using graceful shutdown in more places again(reverted in commit29992a6) to fix instability in the transmission ofFATAL error messages, but that isn't done by this commit.Reported-by: Tom Lane <tgl@sss.pgh.pa.us>Tested-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/176008.1715492071%40sss.pgh.pa.us1 parent291c420 commita8458f5
1 file changed
+32
-0
lines changedLines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1999 | 1999 |
| |
2000 | 2000 |
| |
2001 | 2001 |
| |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
2002 | 2034 |
| |
2003 | 2035 |
| |
2004 | 2036 |
| |
|
0 commit comments
Comments
(0)