Design and approach
Replacement cannot start when outbound capacity is full (src/net.cpp:2856, head)
The replacement path requires an extra full-relay connection before eviction, but ThreadOpenConnections acquires semOutbound at line 2689 before reaching this branch. If target full-relay peers hold all outbound grants, the thread waits for a grant and cannot initiate replacement; EvictExtraOutboundPeers only evicts when an extra full-outbound peer already exists. This approach therefore cannot replace non-tx-relaying peers when outbound capacity is fully occupied. Handle the no-spare-capacity case, for example by freeing a selected slot for the normal connection loop to refill, and test that a peer is replaced under that configuration. Evidence that replacement can proceed and refill capacity without an existing spare connection would change this recommendation.
🟡 Minor
Isolate the blocksonly replacement check (test/functional/p2p_blocksonly.py:104, head)
With -maxconnections=1 and one outbound peer, the singleton-network guard prevents a replacement request regardless of the blocksonly exemption, so this case cannot detect a regression in that exemption. Use two eligible peers with -maxconnections=2 and assert that the replacement-request log is absent after the scheduler check. This would isolate the blocksonly guard, as the preceding normal-mode case does for the request path.
Preserve protection for non-tx-relaying peers during IBD (src/net_processing.cpp:3209, head)
This condition removes m_protect from non-tx-relaying full outbound peers in normal mode even during IBD. The replacement logic disables tx-relay-based replacement during IBD (replace_no_tx_relay is false), but chain-sync eviction can still use m_protect. As a result, the bad/lagging-chain logic can disconnect such a peer without the replacement behavior that motivates removing its protection. Preserve the prior protection during IBD, or otherwise ensure this change does not alter IBD chain-sync eviction.
Request replacement only when a peer can be evicted (src/net_processing.cpp:5688, head)
This scan sets the replacement flag for any matching peer, even when every no-tx-relay candidate is protected, too recently connected, or has blocks in flight. The eviction scan skips protected peers, and the disconnect step retains a selected peer if it is too young or has blocks in flight. If no other eligible extra-outbound candidate exists, the request can remain set and trigger recurring extra connection attempts without removing a peer. Base the request on an actually evictable candidate, or defer or clear it until one can be removed.