From 89a6d84b73d349157971e278b6f3d7d7f0909c0b Mon Sep 17 00:00:00 2001 From: Chen Date: Mon, 13 Jan 2025 19:28:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20resolution=20bug,=20when=20the=20new?= =?UTF-8?q?=20ip=20is=20back=20to=20udpChannel.remoteData=EF=BC=8C=20this?= =?UTF-8?q?=20can=20not=20be=20triggered=20`resolution=20changes`=20(#1711?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/aeron/driver/media/SendChannelEndpoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java b/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java index e05f49353c..74076b2aac 100644 --- a/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java +++ b/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java @@ -356,7 +356,7 @@ else if (udpChannel.hasExplicitEndpoint() && !udpChannel.isMulticast()) { timeOfLastResolutionNs = nowNs; final String endpoint = udpChannel.channelUri().get(CommonContext.ENDPOINT_PARAM_NAME); - conductorProxy.reResolveEndpoint(endpoint, this, udpChannel.remoteData()); + conductorProxy.reResolveEndpoint(endpoint, this, this.connectAddress); } } } From c5a8d3f173fbc0ddcd13acc1b38e1eb252d77b56 Mon Sep 17 00:00:00 2001 From: Dmytro Vyazelenko <696855+vyazelenko@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:30:17 +0100 Subject: [PATCH 2/3] [Java] Add a test for address re-resolution back to the initial IP address. --- .../java/io/aeron/NameReResolutionTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/aeron-system-tests/src/test/java/io/aeron/NameReResolutionTest.java b/aeron-system-tests/src/test/java/io/aeron/NameReResolutionTest.java index 443e5e53fd..926ca0ce44 100644 --- a/aeron-system-tests/src/test/java/io/aeron/NameReResolutionTest.java +++ b/aeron-system-tests/src/test/java/io/aeron/NameReResolutionTest.java @@ -189,6 +189,60 @@ void shouldReResolveEndpointOnNotConnected() any(Header.class)); } + @SlowTest + @Test + @InterruptAfter(30) + void shouldReResolveEndpointOnNotConnectedWhenNamePointsBackAtTheOriginalAddress() + { + final long initialResolutionChanges = countersReader.getCounterValue(RESOLUTION_CHANGES.id()); + + buffer.putInt(0, 1); + + subscription = client.addSubscription(FIRST_SUBSCRIPTION_URI, STREAM_ID); + publication = client.addPublication(PUBLICATION_URI, STREAM_ID); + + Tests.awaitConnected(publication); + Tests.awaitConnected(subscription); + + while (publication.offer(buffer, 0, BitUtil.SIZE_OF_INT) < 0L) + { + Tests.yieldingIdle("No message offer to first subscription"); + } + + while (subscription.poll(handler, 1) <= 0) + { + Tests.yieldingIdle("No message received on first subscription"); + } + + subscription.close(); + + // wait for disconnect to ensure we stay in lock step + while (publication.isConnected()) + { + Tests.sleep(10); + } + + subscription = client.addSubscription(SECOND_SUBSCRIPTION_URI, STREAM_ID); + + assertTrue(updateNameResolutionStatus(countersReader, ENDPOINT_NAME, USE_RE_RESOLUTION_HOST)); + Tests.awaitConnected(subscription); + Tests.awaitCounterDelta(countersReader, RESOLUTION_CHANGES.id(), initialResolutionChanges, 1); + + subscription.close(); + + // wait for disconnect to ensure we stay in lock step + while (publication.isConnected()) + { + Tests.sleep(10); + } + + subscription = client.addSubscription(FIRST_SUBSCRIPTION_URI, STREAM_ID); + + assertTrue(updateNameResolutionStatus(countersReader, ENDPOINT_NAME, USE_INITIAL_RESOLUTION_HOST)); + Tests.awaitConnected(subscription); + Tests.awaitCounterDelta(countersReader, RESOLUTION_CHANGES.id(), initialResolutionChanges, 2); + } + @SlowTest @Test @InterruptAfter(20) From 2d0f69aea5797e6e2974c3b9f4926dfaa10866de Mon Sep 17 00:00:00 2001 From: Dmytro Vyazelenko <696855+vyazelenko@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:31:01 +0100 Subject: [PATCH 3/3] [Java] Tidy up after #1711. --- .../main/java/io/aeron/driver/media/SendChannelEndpoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java b/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java index 74076b2aac..5e1a8d4b10 100644 --- a/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java +++ b/aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java @@ -356,7 +356,7 @@ else if (udpChannel.hasExplicitEndpoint() && !udpChannel.isMulticast()) { timeOfLastResolutionNs = nowNs; final String endpoint = udpChannel.channelUri().get(CommonContext.ENDPOINT_PARAM_NAME); - conductorProxy.reResolveEndpoint(endpoint, this, this.connectAddress); + conductorProxy.reResolveEndpoint(endpoint, this, connectAddress); } } }