Close All MDSAL read transcations 89/83189/4
authorSurendar Raju <surendar.raju@ericsson.com>
Mon, 22 Jul 2019 07:20:44 +0000 (12:50 +0530)
committerSurendar Raju <sureendarvettri@yahoo.com>
Tue, 6 Aug 2019 07:57:33 +0000 (07:57 +0000)
Always Close all the MDSAL
Read Transactions after use Transaction has not been
closed for ReadOnlyTransaction which leads to
unnecessary delay in destroying the shard
traction actors (in case of remote reads). This would
lead to memory leak and can also cause delay in creating
data tree snapshots for reads/writes. As a solution
tx.close() is been added to all ReadOnlyTransaction.

Change-Id: I3977f708ae3427d2f371c228d6ba4d773e9d74cd
Signed-off-by: Surendar Raju <surendar.raju@ericsson.com>
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java
statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java
vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java

index aae2589601cb3120d57c13bbc45f2ffdd40796b7..a64b6ac1bc3e565dd9ff38b2689167dff505238b 100644 (file)
@@ -843,6 +843,8 @@ public class DhcpExternalTunnelManager implements IDhcpExternalTunnelManager {
             return new RemoteMcastMacsBuilder(remoteMcastMacs).setLocatorSet(new ArrayList<>(locators)).build();
         } catch (ReadFailedException e) {
             LOG.error("Failed to read the macs {}", iid);
+        } finally {
+            transaction.close();
         }
         return null;
     }
index c5f9159d3dd92d277d46291cefe2a5ecd8ba7cd6..97b1dcc30bb12670e43c1960b24a3a7e2b05abe4 100644 (file)
@@ -241,6 +241,8 @@ public class DhcpSubnetListener extends AsyncClusteredDataTreeChangeListenerBase
             sn = tx.read(LogicalDatastoreType.CONFIGURATION, id).get();
         } catch (InterruptedException | ExecutionException e) {
             throw new RuntimeException(e);
+        } finally {
+            tx.close();
         }
 
         if (sn.isPresent()) {
index ba84220976fd18d601cd49117c9c669dcc874444..e56f1ff4efd96dce60d11627a47113240a18842c 100644 (file)
@@ -400,6 +400,8 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
             LOG.warn("failed to get counter request data from DB");
             return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed()
                     .withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
+        } finally {
+            tx.close();
         }
 
         GetElementCountersByHandlerOutputBuilder gecbhob = new GetElementCountersByHandlerOutputBuilder();
@@ -470,7 +472,8 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
             LOG.warn("failed to get counter request data from DB");
             return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>failed()
                     .withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
-
+        } finally {
+            tx.close();
         }
         return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>success().buildFuture();
     }
@@ -1000,6 +1003,8 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
             }
         } catch (InterruptedException | ExecutionException e) {
             return false;
+        } finally {
+            roTransaction.close();
         }
         return false;
     }
index 446e81d6b77be58cf20f13bc29cc070b02b1ecd4..02eb7b86cf48f3691142725db0ab41fa9274ba8e 100755 (executable)
@@ -1581,6 +1581,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         LOG.trace("Received VpnInterface update event: original={}, update={}", original, update);
         LOG.info("update: VPN Interface update event - intfName {} on dpn {} oldVpn {} newVpn {}", update.getName(),
                 update.getDpnId(), original.getVpnInstanceNames(), update.getVpnInstanceNames());
+        if (original.equals(update)) {
+            LOG.info("update: original {} update {} are same. No update required.", original, update);
+            return;
+        }
         final String vpnInterfaceName = update.getName();
         final BigInteger dpnId = InterfaceUtils.getDpnForInterface(ifaceMgrRpcService, vpnInterfaceName);
         LOG.info("VPN Interface update event - intfName {}", vpnInterfaceName);