From 1cb411af2b8effb0b40b6a97d686d3dc83857dfd Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 27 Nov 2018 17:03:21 +0100 Subject: [PATCH] Forward CloseTransactionChain messages to the leader The frontend broadcasts this message to all shards leaders, but it may end up being misrouted. Make sure we forward the request to the current leader. JIRA: CONTROLLER-1628 Change-Id: I8b743c8ea9f4f4467878016dfed8b2ad459309f0 Signed-off-by: Robert Varga --- .../controller/cluster/datastore/Shard.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index dbcbd3d02e..c69b839bea 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -788,9 +788,16 @@ public class Shard extends RaftActor { } private void closeTransactionChain(final CloseTransactionChain closeTransactionChain) { - final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier(); - store.closeTransactionChain(id, null); - store.purgeTransactionChain(id, null); + if (isLeader()) { + final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier(); + // FIXME: CONTROLLER-1628: stage purge once no transactions are present + store.closeTransactionChain(id, null); + store.purgeTransactionChain(id, null); + } else if (getLeader() != null) { + getLeader().forward(closeTransactionChain, getContext()); + } else { + LOG.warn("{}: Could not close transaction {}", persistenceId(), closeTransactionChain.getIdentifier()); + } } @SuppressWarnings("checkstyle:IllegalCatch") -- 2.36.6