From: Surendar Raju Date: Mon, 22 Jul 2019 07:20:44 +0000 (+0530) Subject: Close All MDSAL read transcations X-Git-Tag: release/sodium~8 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ee47f6032b80e6526121f218cc80ff500622ffef;p=netvirt.git Close All MDSAL read transcations 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 --- diff --git a/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java b/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java index aae2589601..a64b6ac1bc 100644 --- a/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java +++ b/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java @@ -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; } diff --git a/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java b/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java index c5f9159d3d..97b1dcc30b 100644 --- a/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java +++ b/dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java @@ -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()) { diff --git a/statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java b/statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java index ba84220976..e56f1ff4ef 100644 --- a/statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java +++ b/statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java @@ -400,6 +400,8 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan LOG.warn("failed to get counter request data from DB"); return RpcResultBuilder.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.failed() .withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture(); - + } finally { + tx.close(); } return RpcResultBuilder.success().buildFuture(); } @@ -1000,6 +1003,8 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan } } catch (InterruptedException | ExecutionException e) { return false; + } finally { + roTransaction.close(); } return false; } diff --git a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java index 446e81d6b7..02eb7b86cf 100755 --- a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java +++ b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java @@ -1581,6 +1581,10 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase