From 0361c584fdd8028a3516f674255d7af427455a90 Mon Sep 17 00:00:00 2001 From: Dana Kutenicsova Date: Wed, 29 Jul 2015 14:35:10 +0200 Subject: [PATCH] Fix PingPong transaction race in EffectiveRibWriter. To avoid race conditions between transactions, create one only when we need one. Change-Id: I1052adb326db68aeaac700a0f0169bba3f0b8999 Signed-off-by: Dana Kutenicsova --- .../protocol/bgp/rib/impl/EffectiveRibInWriter.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java index 0b1a8d92e3..dfaaeea77f 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java @@ -184,7 +184,10 @@ final class EffectiveRibInWriter implements AutoCloseable { @Override public void onDataTreeChanged(final Collection changes) { LOG.trace("Data changed called to effective RIB. Change : {}", changes); - final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); + + // we have a lot of transactions created for 'nothing' because a lot of changes + // are skipped, so ensure we only create one transaction when we really need it + DOMDataWriteTransaction tx = null; for (final DataTreeCandidate tc : changes) { final YangInstanceIdentifier rootPath = tc.getRootPath(); @@ -210,10 +213,15 @@ final class EffectiveRibInWriter implements AutoCloseable { continue; } for (final DataTreeCandidateNode table : tables.getChildNodes()) { + if (tx == null) { + tx = this.chain.newWriteOnlyTransaction(); + } changeDataTree(tx, rootPath, root, peerKey, table); } } - tx.submit(); + if (tx != null) { + tx.submit(); + } } private void changeDataTree(final DOMDataWriteTransaction tx, final YangInstanceIdentifier rootPath, -- 2.36.6