From: Milos Fabian Date: Tue, 5 Apr 2016 06:21:45 +0000 (+0200) Subject: Bug 5558 - Closing session after a large RIB is sent kills BGPCEP X-Git-Tag: release/boron~181 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=597845a52c60d917e03ed8ba4344093f579fb009;p=bgpcep.git Bug 5558 - Closing session after a large RIB is sent kills BGPCEP Fixed peer session recovery, in a case of failed transaction chain. The AdjRibInWriter need working chain when cleaning, also it needs to be started with fresh transaction chain when session goes up again. Hence recreate AdjRibInWriter with a new tx chain, when the current failed. Fixed duplicated session avoidance. The peer's session should not be removed from registry if it was not created during this negotiation process. Otherwise, the active peer's sesion can be removed from registry, which can later lead to the duplicated session establishment. Signed-off-by: Milos Fabian Change-Id: I46ef33d49a11db8465a719af5ba4e1716da14602 (cherry picked from commit 54e12560f5b823a24da39c4f9cbe274fb88f30ca) --- diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java index f7f10bb630..4f00c9af2e 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java @@ -206,7 +206,9 @@ public abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandler // deliver the message, this method gets called with different exception (definitely not with BGPDocumentedException). sendMessage(buildErrorNotify(((BGPDocumentedException)e).getError(), ((BGPDocumentedException) e).getData())); } - this.registry.removePeerSession(getRemoteIp()); + if (this.state == State.OPEN_CONFIRM) { + this.registry.removePeerSession(getRemoteIp()); + } negotiationFailedCloseChannel(e); this.state = State.FINISHED; } diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java index 9214214a08..a40eef1ef2 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java @@ -101,8 +101,10 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer private final Map adjRibOutListenerSet = new HashMap(); private final RpcProviderRegistry rpcRegistry; private RoutedRpcRegistration rpcRegistration; + private final PeerRole peerRole; public BGPPeer(final String name, final RIB rib, final PeerRole role, final RpcProviderRegistry rpcRegistry) { + this.peerRole = role; this.rib = Preconditions.checkNotNull(rib); this.name = name; this.chain = rib.createPeerChain(this); @@ -404,9 +406,10 @@ public class BGPPeer implements BGPSessionListener, Peer, AutoCloseable, BGPPeer @Override public void onTransactionChainFailed(final TransactionChain chain, final AsyncTransaction transaction, final Throwable cause) { LOG.error("Transaction chain failed.", cause); - releaseConnection(); this.chain.close(); this.chain = this.rib.createPeerChain(this); + this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this.chain); + releaseConnection(); } @Override