From bb04f62f467cc6e6f0922ba8957b09715707940d Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Fri, 26 Apr 2019 12:37:38 +0200 Subject: [PATCH] Harden ShardCommitCoordinator to survive EOS write retries EntityOwnershipShard can break the usual shard rule of only one 3PC running at one time, causing the retrying write attempting to modify an already sealed modification. Change-Id: Iaa56b68a30f9191f7aa14428f39d4d7524aeb09d Signed-off-by: Tomas Cere --- .../controller/cluster/datastore/CohortEntry.java | 5 +++++ .../controller/cluster/datastore/ShardCommitCoordinator.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java index 3d5238ee77..5e5d0f16cd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/CohortEntry.java @@ -32,6 +32,7 @@ final class CohortEntry { private Shard shard; private CohortEntry(final ReadWriteShardDataTreeTransaction transaction, final short clientVersion) { + this.cohort = null; this.transaction = Preconditions.checkNotNull(transaction); this.transactionId = transaction.getIdentifier(); this.clientVersion = clientVersion; @@ -122,6 +123,10 @@ final class CohortEntry { } } + boolean isSealed() { + return cohort != null; + } + Optional> getParticipatingShardNames() { return cohort != null ? cohort.getParticipatingShardNames() : Optional.empty(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java index bfb416534b..85e1345e0b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinator.java @@ -129,7 +129,7 @@ final class ShardCommitCoordinator { */ void handleBatchedModifications(final BatchedModifications batched, final ActorRef sender, final Shard shard) { CohortEntry cohortEntry = cohortCache.get(batched.getTransactionId()); - if (cohortEntry == null) { + if (cohortEntry == null || cohortEntry.isSealed()) { cohortEntry = CohortEntry.createOpen(dataTree.newReadWriteTransaction(batched.getTransactionId()), batched.getVersion()); cohortCache.put(cohortEntry.getTransactionId(), cohortEntry); -- 2.36.6