Commit e8c2dcd
committed
fix(qwp): cancel in-flight connect during close, with a bounded backstop
CursorWebSocketSendLoop.close() did an untimed shutdownLatch.await() while the I/O
thread could be blocked in an in-flight foreground connect (connect_timeout=0 =>
OS SYN-retry ~60-130s). The connecting WebSocketClient is a walk-local in
QwpWebSocketSender.connectWalk, invisible to close() (the `client` field is null on
async-initial connect / stale on reconnect), so closeTraffic() could not reach it
and close() hung -- risking Sender.close() exceeding the sidecar's 120s deadline.
Publish a race-safe per-loop cancellation handle (ConnectCancellation) through the
transport seam: connectWalk publishes the client it is about to block on before
connect(); close() calls closeTraffic() on it to unwind a black-holed connect. The
ReconnectFactory seam gains a Java-8 `default reconnect(ConnectCancellation)`, so
every existing implementor stays source/binary compatible.
Add a bounded backstop: close() awaits the shutdown latch for at most
DEFAULT_CLOSE_SHUTDOWN_AWAIT_MILLIS (30s, ~4x under the sidecar deadline) and, on
timeout, runs the same loud failed-stop protocol as the interrupt branch
(delegates final teardown to the I/O thread's exit path, frees nothing under the
live worker) -- so close() returns bounded even in the rare TOCTOU window where
cancellation is a no-op. Also clear the in-flight handle on connect-failure paths
so it never dangles at a disposed client.
Adds CursorWebSocketSendLoopConnectPhaseCloseTest (async-initial + mid-flight
cancellation, plus bounded-backstop-without-cancellation).1 parent 79eb13c commit e8c2dcd
3 files changed
Lines changed: 715 additions & 7 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass/qwp/client
- sf/cursor
- test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor
Lines changed: 53 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2768 | 2768 | | |
2769 | 2769 | | |
2770 | 2770 | | |
2771 | | - | |
| 2771 | + | |
2772 | 2772 | | |
2773 | 2773 | | |
2774 | 2774 | | |
2775 | 2775 | | |
2776 | | - | |
| 2776 | + | |
2777 | 2777 | | |
2778 | 2778 | | |
2779 | 2779 | | |
2780 | | - | |
| 2780 | + | |
2781 | 2781 | | |
2782 | 2782 | | |
2783 | 2783 | | |
2784 | 2784 | | |
2785 | 2785 | | |
2786 | | - | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
2787 | 2802 | | |
2788 | 2803 | | |
2789 | 2804 | | |
| |||
2871 | 2886 | | |
2872 | 2887 | | |
2873 | 2888 | | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
2874 | 2906 | | |
2875 | 2907 | | |
2876 | 2908 | | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
2877 | 2917 | | |
2878 | 2918 | | |
2879 | 2919 | | |
| |||
2883 | 2923 | | |
2884 | 2924 | | |
2885 | 2925 | | |
| 2926 | + | |
2886 | 2927 | | |
2887 | 2928 | | |
2888 | 2929 | | |
| |||
2929 | 2970 | | |
2930 | 2971 | | |
2931 | 2972 | | |
| 2973 | + | |
2932 | 2974 | | |
2933 | 2975 | | |
2934 | 2976 | | |
| |||
2951 | 2993 | | |
2952 | 2994 | | |
2953 | 2995 | | |
| 2996 | + | |
2954 | 2997 | | |
2955 | 2998 | | |
2956 | 2999 | | |
| |||
4008 | 4051 | | |
4009 | 4052 | | |
4010 | 4053 | | |
4011 | | - | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
4012 | 4060 | | |
4013 | 4061 | | |
4014 | 4062 | | |
0 commit comments