From: Robert Varga Date: Wed, 20 Feb 2019 13:47:12 +0000 (+0100) Subject: Improve aborted transaction logging X-Git-Tag: release/sodium~141 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=21eed79684671b9a44e34edbd589419cb9bb6087;hp=7ad6a27e9b98861d9286977320198375a44a38f1 Improve aborted transaction logging The fact that a snapshot is recorded does not mean it has not been closed -- in fact write-aspect transactions do not actively remove themselves. When we prune recorded snapshots on transaction chain close, we need to pay attention to the return value of abort(), as that is indicating whether we should in fact warn about an unclosed transaction. This means that the actual set of transactions we warn about cannot be determined until we have traversed all recorded snapshots, hence modify the logic to record the identifiers that were in fact aborted and report all of them in a single message along with a stack trace so the offender may be identifier. Change-Id: I8b176f1990c9aa9c056cd03203ea50fb9b9549a0 JIRA: CONTROLLER-1886 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedTransactionChain.java index 677610c848..6ae7e51c54 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedTransactionChain.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedTransactionChain.java @@ -8,9 +8,12 @@ package org.opendaylight.controller.cluster.databroker; import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.WeakHashMap; import javax.annotation.concurrent.GuardedBy; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientHandle; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot; @@ -58,12 +61,19 @@ final class ClientBackedTransactionChain implements DOMStoreTransactionChain { @Override public synchronized void close() { + final List abortedSnapshots = new ArrayList<>(); for (AbstractClientHandle snap : openSnapshots.keySet()) { - LOG.warn("Aborting unclosed transaction {}", snap.getIdentifier()); - snap.abort(); + final TransactionIdentifier id = snap.getIdentifier(); + LOG.debug("Aborting recorded transaction {}", id); + if (snap.abort()) { + abortedSnapshots.add(id); + } } openSnapshots.clear(); + if (!abortedSnapshots.isEmpty()) { + LOG.warn("Aborted unclosed transactions {}", abortedSnapshots, new Throwable("at")); + } history.close(); }