forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf3a4d7e
committed
Distinguish wait-for-connection from wait-for-write-ready on Windows.
The API for WaitLatch and friends followed the Unix convention in whichwaiting for a socket connection to complete is identical to waiting forthe socket to accept a write. While Windows provides a select(2)emulation that agrees with that, the native WaitForMultipleObjects APItreats them as quite different --- and for some bizarre reason, it willreport a not-yet-connected socket as write-ready. libpq itself has sofar escaped dealing with this because it waits with select(), but inlibpqwalreceiver.c we want to wait using WaitLatchOrSocket. The semanticsmismatch resulted in replication connection failures on Windows, but onlyfor remote connections (apparently, localhost connections completeimmediately, or at least too fast for anyone to have noticed the problemin single-machine testing).To fix, introduce an additional WL_SOCKET_CONNECTED wait flag forWaitLatchOrSocket, which is identical to WL_SOCKET_WRITEABLE onnon-Windows, but results in waiting for FD_CONNECT events on Windows.Ideally, we would also distinguish the two conditions in the API forPQconnectPoll(), but changing that API at this point seems infeasible.Instead, cheat by checking for PQstatus() == CONNECTION_STARTED todetermine that we're still waiting for the connection to complete.(This is a cheat mainly because CONNECTION_STARTED is documented as aninternal state rather than something callers should rely on. Perhapswe ought to change the documentation ... but this patch doesn't.)Per reports from Jobin Augustine and Igor Neyman. Back-patch to v10where commit1e8a850 exposed this longstanding shortcoming.Andres Freund, minor fix and some code review/beautification by meDiscussion:https://postgr.es/m/CAHBggj8g2T+ZDcACZ2FmzX9CTxkWjKBsHd6NkYB4i9Ojf6K1Fw@mail.gmail.com1 parent480f1f4 commitf3a4d7e
File tree
3 files changed
+47
-26
lines changed- src
- backend
- replication/libpqwalreceiver
- storage/ipc
- include/storage
3 files changed
+47
-26
lines changedLines changed: 9 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
168 | 168 |
| |
169 | 169 |
| |
170 | 170 |
| |
171 |
| - | |
172 | 171 |
| |
173 | 172 |
| |
174 | 173 |
| |
175 |
| - | |
176 |
| - | |
177 |
| - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
178 | 183 |
| |
179 | 184 |
| |
180 | 185 |
| |
|
Lines changed: 28 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
344 | 344 |
| |
345 | 345 |
| |
346 | 346 |
| |
347 |
| - | |
348 |
| - | |
349 |
| - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
350 | 350 |
| |
351 | 351 |
| |
352 | 352 |
| |
| |||
374 | 374 |
| |
375 | 375 |
| |
376 | 376 |
| |
377 |
| - | |
| 377 | + | |
378 | 378 |
| |
379 | 379 |
| |
380 | 380 |
| |
381 |
| - | |
| 381 | + | |
382 | 382 |
| |
383 | 383 |
| |
384 | 384 |
| |
| |||
390 | 390 |
| |
391 | 391 |
| |
392 | 392 |
| |
393 |
| - | |
394 |
| - | |
| 393 | + | |
395 | 394 |
| |
396 | 395 |
| |
397 | 396 |
| |
| |||
640 | 639 |
| |
641 | 640 |
| |
642 | 641 |
| |
643 |
| - | |
644 |
| - | |
645 |
| - | |
646 |
| - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
647 | 649 |
| |
648 | 650 |
| |
649 | 651 |
| |
| |||
652 | 654 |
| |
653 | 655 |
| |
654 | 656 |
| |
655 |
| - | |
656 |
| - | |
657 |
| - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
658 | 660 |
| |
659 | 661 |
| |
660 | 662 |
| |
| |||
685 | 687 |
| |
686 | 688 |
| |
687 | 689 |
| |
688 |
| - | |
689 |
| - | |
| 690 | + | |
690 | 691 |
| |
691 | 692 |
| |
692 | 693 |
| |
| |||
885 | 886 |
| |
886 | 887 |
| |
887 | 888 |
| |
| 889 | + | |
| 890 | + | |
888 | 891 |
| |
889 | 892 |
| |
890 | 893 |
| |
| |||
1395 | 1398 |
| |
1396 | 1399 |
| |
1397 | 1400 |
| |
1398 |
| - | |
| 1401 | + | |
1399 | 1402 |
| |
1400 | 1403 |
| |
1401 | 1404 |
| |
| |||
1432 | 1435 |
| |
1433 | 1436 |
| |
1434 | 1437 |
| |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
1435 | 1444 |
| |
1436 | 1445 |
| |
1437 |
| - | |
1438 |
| - | |
1439 |
| - | |
1440 |
| - | |
1441 |
| - | |
| 1446 | + | |
| 1447 | + | |
1442 | 1448 |
| |
1443 | 1449 |
| |
1444 | 1450 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
129 | 139 |
| |
130 | 140 |
| |
131 | 141 |
| |
|
0 commit comments
Comments
(0)