andygrove commented on code in PR #2740:
URL:
https://github.com/apache/datafusion-ballista/pull/2740#discussion_r4442632404
##########
chaos-testing/src/cluster.rs:
##########
@@ -25,24 +26,37 @@ use std::sync::{Arc, OnceLock};
use std::time::{Duration, Instant};
use tokio::sync::{Mutex, OwnedMutexGuard};
-/// Reserve `N` free TCP ports by binding each to :0, releasing them only once
-/// every port has been read.
+/// Reserve `N` free TCP ports that are not in `taken`, and add them to
`taken`.
///
-/// Holding all `N` listeners is what makes the ports distinct from each other.
-/// Releasing each before taking the next lets the kernel hand the same number
-/// back, and a caller that asked for two ports then gives its child one port
-/// for two servers: the second bind fails `AddrInUse` and the child exits
-/// during startup.
+/// Each candidate is found by binding to :0, and every listener is held until
+/// all `N` ports have been read. Holding them is what makes the ports of one
+/// call distinct from each other. Releasing each before taking the next lets
+/// the kernel hand the same number back, and a caller that asked for two ports
+/// then gives its child one port for two servers: the second bind fails
+/// `AddrInUse` and the child exits during startup.
+///
+/// The same thing happens across calls. The listeners are dropped before this
+/// returns and the child binds the ports some milliseconds later, so a later
+/// call made in that window (the next executor of the same cluster) can be
+/// handed a port the previous child has not bound yet. The cluster therefore
+/// records every port it hands out in `taken`, and a candidate already in it
+/// is skipped (and kept bound, so the kernel does not offer it again while we
+/// look for a replacement).
Review Comment:
This comment seems overly verbose
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]