From 8ed5603b4f3503559f2f85137c42d7605ebfd3e9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 13 Jun 2017 12:13:58 +0200 Subject: [PATCH 1/1] BUG-8665: fix memory leak around RangeSets This is a thinko on my part, where I was thinking in terms of a discrete set (UnsignedLong) and assumed RangeSets will coalesce individual items. Unfortunately TreeRangeSet has no way of knowing that that the domain it operates on is discrete and hence will not merge invididual ranges. This patch fixes the problem by using [N,N+1) ranges to address the problem. A follow-up patch should address this in a more efficient manner. Change-Id: Iecc313e09ae0cdd51a42f7d39281f7634f0358a7 Signed-off-by: Robert Varga --- .../cluster/datastore/AbstractFrontendHistory.java | 6 +++--- .../cluster/datastore/FrontendClientMetadataBuilder.java | 3 ++- .../cluster/datastore/FrontendHistoryMetadataBuilder.java | 2 +- .../controller/cluster/datastore/LeaderFrontendState.java | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java index 88c2a7d361..8563c3e913 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractFrontendHistory.java @@ -94,7 +94,7 @@ abstract class AbstractFrontendHistory implements Identifiable { - purgedTransactions.add(Range.singleton(ul)); + purgedTransactions.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul))); transactions.remove(id); LOG.debug("{}: finished purging transaction {}", persistenceId(), id); envelope.sendSuccess(new TransactionPurgeResponse(id, request.getSequence()), readTime() - now); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java index e4ab4b5cef..519a360b06 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java @@ -110,7 +110,8 @@ final class FrontendClientMetadataBuilder implements Builder { } LOG.debug("{}: purging history {}", persistenceId, id); - purgedHistories.add(Range.singleton(UnsignedLong.fromLongBits(id.getHistoryId()))); + final UnsignedLong ul = UnsignedLong.fromLongBits(id.getHistoryId()); + purgedHistories.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul))); existing.purge(request.getSequence(), envelope, now); return null; } -- 2.36.6