Bug 5558 - Closing session after a large RIB is sent kills BGPCEP 41/37141/5
authorMilos Fabian <milfabia@cisco.com>
Tue, 5 Apr 2016 06:21:45 +0000 (08:21 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 13 Apr 2016 08:47:13 +0000 (08:47 +0000)
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 <milfabia@cisco.com>
Change-Id: I46ef33d49a11db8465a719af5ba4e1716da14602

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java

index f7f10bb63080274c1f3f86c26a50cc02697e1101..4f00c9af2ef3b2747af82e77eae545884998e540 100644 (file)
@@ -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;
     }
index f9c1956e1a158f8d43b1f0e5f08029bb6ae35ce6..2a238d5a168914c5b7d27c74d9a4694cc7bed570 100644 (file)
@@ -368,9 +368,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