Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expire channel when its remote address not valid after remote DNS update #1821

Open
russellyou opened this issue Jul 12, 2022 · 0 comments
Open

Comments

@russellyou
Copy link

At the moment a channel will expire when either

1 idleTimeoutExpired
2 channel closed by remote end
3 channel TTL expired

But there is one special case making channel not usable. We use AHC to connect to a service behind AWS ALB. When a new deployment happens, the DNS of service will be changed targeting new deployed vesion . But for a period of time(say 1 hour), old version and new version services co-exist. During the hour, the channel of old version service can still be used . But that's not as expected.

Could we update the DefaultChannelPool.IdleChannelDetector to add check
if channel's remoteAddess is not in list of DNS resolve result , we will mark this channel as expired.

Happy to raise a PR for this.

code in DefaultChannelPool.IdleChannelDetector

    private List<IdleChannel> expiredChannels(ConcurrentLinkedDeque<IdleChannel> partition, long now) {
      // lazy create
      List<IdleChannel> idleTimeoutChannels = null;
      for (IdleChannel idleChannel : partition) {
        boolean isIdleTimeoutExpired = isIdleTimeoutExpired(idleChannel, now);
        boolean isRemotelyClosed = !Channels.isChannelActive(idleChannel.channel);
        boolean isTtlExpired = isTtlExpired(idleChannel.channel, now);
        if (isIdleTimeoutExpired || isRemotelyClosed || isTtlExpired) {
          LOGGER.debug("Adding Candidate expired Channel {} isIdleTimeoutExpired={} isRemotelyClosed={} isTtlExpired={}", idleChannel.channel, isIdleTimeoutExpired, isRemotelyClosed, isTtlExpired);
          if (idleTimeoutChannels == null)
            idleTimeoutChannels = new ArrayList<>(1);
          idleTimeoutChannels.add(idleChannel);
        }
      }

      return idleTimeoutChannels != null ? idleTimeoutChannels : Collections.emptyList();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant