diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java index 891de418a6..6d8d5bdb00 100644 --- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java +++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseStateMachine.java @@ -89,6 +89,8 @@ public class DatabaseStateMachine implements StateMachine { @Command public List write(List requests) { + + // applicability check boolean abort = false; List validationResults = new ArrayList<>(requests.size()); for (WriteRequest request : requests) { @@ -132,8 +134,13 @@ public class DatabaseStateMachine implements StateMachine { return results; } + // apply changes for (WriteRequest request : requests) { Map table = state.getTables().get(request.tableName()); + // FIXME: If this method could be called by multiple thread, + // synchronization scope is wrong. + // Whole function including applicability check needs to be protected. + // Confirm copycat's thread safety requirement for StateMachine synchronized (table) { VersionedValue previousValue = table.put(request.key(), new VersionedValue(request.newValue(), state.nextVersion()));