demery-pivotal commented on a change in pull request #7111:
URL: https://github.com/apache/geode/pull/7111#discussion_r752681378
##########
File path:
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java
##########
@@ -413,13 +411,10 @@ public void run2() throws CacheException {
public void testDurableClientWithRegistrationHA() {
// Step 1: Start server1
+ PORT1 = this.server1VM
+ .invoke(() -> CacheServerTestUtil.createCacheServer(regionName,
Boolean.TRUE));
PORT2 = getRandomAvailableTCPPort();
- PORT1 = ((Integer) this.server1VM
- .invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new
Boolean(true))))
- .intValue();
-
-
Review comment:
So: I think your change is a reasonable workaround, but the real problem
lies elsewhere. `AvailablePortHelper` needs an immediate fix. I'll get started
on that.
##########
File path:
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java
##########
@@ -413,13 +411,10 @@ public void run2() throws CacheException {
public void testDurableClientWithRegistrationHA() {
// Step 1: Start server1
+ PORT1 = this.server1VM
+ .invoke(() -> CacheServerTestUtil.createCacheServer(regionName,
Boolean.TRUE));
PORT2 = getRandomAvailableTCPPort();
- PORT1 = ((Integer) this.server1VM
- .invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new
Boolean(true))))
- .intValue();
-
-
Review comment:
In researching this, I've discovered a serious problem in
`AvailablePortHelper`. In the test JVM, `AvailablePortHelper` behaves poorly.
It initializes itself to start at a randomly selected port. That randomly
selected port might be one of the ones that a child VM will check early.
Here's the sequence of events:
1. In the test JVM, `AvailablePortHelper` learns that the range of ports
available to it is (say) 23750–24166. It randomly selects one of those as its
"next port to check." Let's suppose it randomly picks 23854 as its starting
port.
2. In vm0, the startup code initializes `AvailablePortHelper` to a specific
"next port to check," computed based on its VM number. For the given available
port range (23750–24166), vm0 will *always* start at 23854.
3. At this point, both the test JVM and child vm0 have the exact same "next
port to check." Trouble is looming.
4. The test requests a port in the test JVM, and gets the randomly selected
one: 23854. It doesn't bind to this port yet. Later it will try to start a
server on this port in vm1. Trouble is fast approaching.
5. The test invokes `AvailablePortHelper` in vm0, and gets vm0's starting
port: 23854. The test then starts a server, which binds to that port.
6. At this point, the test JVM thinks it has reserved the port, but vm0 has
bound to it. Trouble is imminent.
7. The test tries to start a server in vm1, using the port it believes it
reserved. The operation fails because the port is already in use.
--
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]