Github user StefanRRichter commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3859#discussion_r115719033
  
    --- Diff: 
flink-contrib/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBKeyedStateBackend.java
 ---
    @@ -911,9 +915,11 @@ void releaseResources(boolean canceled) {
                        if (canceled) {
                                List<StateObject> statesToDiscard = new 
ArrayList<>();
     
    -                           statesToDiscard.add(metaStateHandle);
    -                           statesToDiscard.addAll(miscFiles.values());
    -                           statesToDiscard.addAll(newSstFiles.values());
    +                           synchronized (this) {
    --- End diff --
    
    Having a second look at this, the suggestion from the jira is not going far 
enough. 
    
    We actually must ensure that all checkpointing efforts (e.g. writing to 
HDFS) have already come to an end, so that no new state handles can be created 
anymore at this point. Otherwise, even if we synchronize, the parallel thread 
could still create a new state handle after the getting back the lock.
    
    However, once this is ensured, also the need for synchronization goes away. 
So I suggest that we rather make sure that cleanup is only performed after all 
checkpointing ended, and that no more checkpointing through this object can run 
after the cleanup.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to