Connection pool exhaustion during NetworkManager interface flapping on Fedora
0 reputation · 24 Feb 2021, 18:18 UTC
0 reputation · 24 Feb 2021, 18:18 UTC
On Fedora systems using NetworkManager, rapid transitions between Wi-Fi and Ethernet profiles may coincide with application-level connection pool exhaustion. NetworkManager manages connection profiles and state transitions over D-Bus, but the interaction between interface flapping and kernel socket cleanup is not always straightforward to isolate.
The uncertainty centers on whether stale sockets in TIME_WAIT state are an expected consequence of profile switching or a race condition in the daemon's state machine. Application-layer pool settings and kernel-level file descriptor limits can produce similar symptoms, making it difficult to determine whether the operating system's network daemon is contributing to exhaustion or merely reflecting application demand.
Does NetworkManager's handling of interface flapping on current Fedora releases create a race condition that prolongs TIME_WAIT socket accumulation? When pool exhaustion events align with NetworkManager re-initializations, should diagnosis focus on the daemon's D-Bus state transitions or on kernel socket limits first? Is the interaction between systemd-resolved and NetworkManager during profile changes a known source of masked timeouts in connection pools?
NetworkManager's handling of interface flapping does not create a race condition that directly generates TIME_WAIT sockets. TIME_WAIT is a kernel-level TCP state managed by the networking stack, not the NetworkManager daemon. However, rapid profile switching triggers route invalidations that cause application-layer connection pools to behave unpredictably, leading to the perceived exhaustion.
Confirmed Facts:
RST (Reset) packets or silent timeouts rather than a graceful FIN exchange.Likely Explanation: The "exhaustion" is typically a result of the application pool attempting to reuse sockets that are logically dead but not yet reclaimed by the kernel, or initiating a burst of new connections to replace dropped ones. When systemd-resolved is involved, DNS resolution delays during the transition can cause connection attempts to hang, keeping sockets in a pending state and accelerating pool depletion.
Diagnosis should focus on kernel socket states first, then application pool behavior, and finally D-Bus transitions. The daemon's state transitions are the trigger, but the exhaustion occurs in the kernel/application boundary.
TIME_WAIT accumulation or a surge of SYN_SENT sockets: ss -tan | awk '{print $1}' | sort | uniq -cdmesg for route changes or "martian source" logs that align with the pool exhaustion timestamps.systemd-resolved is delaying the establishment of new connections during the profile switch, which masks the actual timeout.To refine this recommendation, please provide the application's connection timeout and keep-alive settings. If the application lacks a proactive health check for pooled connections, it will continue to attempt reuse of invalidated sockets regardless of NetworkManager's state.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 24 Feb 2021, 19:13 UTC
NetworkManager reconfigures Layer 2 and Layer 3 interfaces over D-Bus, but the kernel owns the TCP state machine. TIME_WAIT sockets accumulate because the local endpoint performed an active close, not because NetworkManager mishandled a D-Bus transition. On current Fedora releases, correlate events by running ss -tan during a Wi-Fi to Ethernet flap and watching dbus-monitor "interface='org.freedesktop.NetworkManager'" for state changes. If pool exhaustion coincides with DNS re-resolution, check systemd-resolved latency separately; it can hold connections open but does not directly create TIME_WAIT entries. Verify net.ipv4.tcp_tw_reuse before assuming a daemon race condition.