This is an automated email from the ASF dual-hosted git repository.

timoninmaxim pushed a commit to branch 
IGNITE-23856__thin_cln_channels_duplication
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to 
refs/heads/IGNITE-23856__thin_cln_channels_duplication by this push:
     new 562ea847dac IGNITE-23856 Fixing testFailover (#12142)
562ea847dac is described below

commit 562ea847dacdd17fbde95a23e1e4365c0219bd28
Author: Popov Aleksandr <[email protected]>
AuthorDate: Wed Jun 18 22:14:33 2025 +0300

    IGNITE-23856 Fixing testFailover (#12142)
    
    Thank you for submitting the pull request to the Apache Ignite.
    
    In order to streamline the review of the contribution
    we ask you to ensure the following steps have been taken:
    
    ### The Contribution Checklist
    - [ ] There is a single JIRA ticket related to the pull request.
    - [ ] The web-link to the pull request is attached to the JIRA ticket.
    - [ ] The JIRA ticket has the _Patch Available_ state.
    - [ ] The pull request body describes changes that have been made.
    The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
    - [ ] The pull request title is treated as the final commit message.
    The following pattern must be used: `IGNITE-XXXX Change summary` where
    `XXXX` - number of JIRA issue.
    - [ ] A reviewer has been mentioned through the JIRA comments
    (see [the Maintainers
    
list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
    - [ ] The pull request has been checked by the Teamcity Bot and
    the `green visa` attached to the JIRA ticket (see [TC.Bot: Check
    PR](https://mtcga.gridgain.com/prs.html))
    
    ### Notes
    - [How to
    
Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
    - [Coding abbreviation
    
rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
    - [Coding
    
Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
    - [Apache Ignite Teamcity
    
Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
    
    If you need any help, please email [email protected] or ask anу
    advice on http://asf.slack.com _#ignite_ channel.
---
 .../internal/client/thin/ReliableChannel.java      | 34 ++++++++++------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
index 7f13019d0ba..e7bf445c2c0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java
@@ -296,23 +296,13 @@ final class ReliableChannel implements AutoCloseable {
 
                 ClientChannelHolder hld;
 
-                try {
-                    // Will try to reinit channels if topology changed.
-                    onChannelFailure(ch, connEx, failures);
-                }
-                catch (Throwable ex) {
-                    fut.completeExceptionally(ex);
-
-                    return null;
-                }
-
                 try {
                     hld = (nodeId != null) ? nodeChannels.get(nodeId) : null;
 
                     if (hld == null)
                         throw connEx;
 
-                    retryCh = hld.getOrCreateChannel();
+                    retryCh = getRetryChannel(hld, ch);
                 }
                 catch (ClientConnectionException reconnectEx) {
                     failures.add(reconnectEx);
@@ -920,9 +910,7 @@ final class ReliableChannel implements AutoCloseable {
                 catch (ClientConnectionException e) {
                     if (c0 == c && shouldRetry(op, F.size(failures), e)) {
                         // In case of stale channel try to reconnect to the 
same channel and repeat the operation.
-                        onChannelFailure(hld, c, e, failures);
-
-                        c = hld.getOrCreateChannel();
+                        c = getRetryChannel(hld, c);
 
                         return function.apply(c);
                     }
@@ -976,14 +964,11 @@ final class ReliableChannel implements AutoCloseable {
                 return function.apply(channel);
             }
             catch (ClientConnectionException e) {
-                onChannelFailure(hld, channel, e, failures);
-
                 if (!shouldRetry(op, 0, e))
                     throw e;
 
                 try {
-                    // In case of stale channel try to reconnect to the same 
channel and repeat the operation.
-                    channel = hld.getOrCreateChannel();
+                    channel = getRetryChannel(hld, channel);
 
                     return function.apply(channel);
                 }
@@ -1004,6 +989,19 @@ final class ReliableChannel implements AutoCloseable {
         return applyOnDefaultChannel(function, op, failures);
     }
 
+    /**
+     * Returns the client channel that should be used to retry sending the 
request.
+     * Unlike onChannelFailure, invoked only for a reconnection attempt on the 
same channel without channels initialization.
+     */
+    private ClientChannel getRetryChannel(ClientChannelHolder hld, 
ClientChannel ch) {
+        if (ch != null && ch == hld.ch)
+            hld.closeChannel();
+
+        rollCurrentChannel(hld);
+
+        return hld.getOrCreateChannel();
+    }
+
     /** Get retry limit. */
     private int getRetryLimit() {
         List<ClientChannelHolder> holders = channels;

Reply via email to