Zakelly commented on a change in pull request #15420:
URL: https://github.com/apache/flink/pull/15420#discussion_r656768464



##########
File path: 
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogKeyedStateBackend.java
##########
@@ -358,7 +461,23 @@ public void notifyCheckpointAborted(long checkpointId) 
throws Exception {
                         keyedStateBackend.getKeyContext(),
                         stateChangelogWriter,
                         meta);
-        return stateFactory.create(state, kvStateChangeLogger);
+        return stateFactory.create(
+                state,
+                kvStateChangeLogger,
+                keyedStateBackend /* pass the nested backend as key context so 
that it get key updates on recovery*/);
+    }
+
+    private void completeRestore(Collection<ChangelogStateBackendHandle> 
stateHandles) {
+        if (!stateHandles.isEmpty()) {
+            synchronized (materialized) { // ensure visibility

Review comment:
       IIUC, the ```buildSnapshotResult ``` runs in synchronized stage of a 
checkpoint, which is already protected by the checkpoint lock.
   However, since the ```materialized``` may change later upon materialization, 
I do agree we add some protection here. According to the JLS 
(https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.5):
   
   > An unlock on a monitor happens-before every subsequent lock on that 
monitor.
   
   I think we should do ```synchronized (materialized)``` in 
```buildSnapshotResult ``` as well to ensure the _happens-before_ relationship.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to