diff options
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java index 0b9770f..29af101 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java @@ -152,7 +152,12 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> { if (!master.tryUpdate()) {
// Master record does not exist. To ensure consistency,
// delete record from replica.
- repair(replica);
+ if (tryDeleteReplica(replica)) {
+ // Replica was inconsistent, but caller might be in a
+ // transaction and rollback the repair. Run repair
+ // again in separate thread to ensure it sticks.
+ repair(replica);
+ }
throw abortTry();
}
} else {
@@ -161,7 +166,12 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> { } catch (PersistNoneException e) {
// Master record does not exist. To ensure consistency,
// delete record from replica.
- repair(replica);
+ if (tryDeleteReplica(replica)) {
+ // Replica was inconsistent, but caller might be in a
+ // transaction and rollback the repair. Run repair
+ // again in separate thread to ensure it sticks.
+ repair(replica);
+ }
throw e;
}
}
|