Github user StefanRRichter commented on a diff in the pull request:
https://github.com/apache/flink/pull/3859#discussion_r115721158
--- Diff:
flink-contrib/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBKeyedStateBackend.java
---
@@ -880,7 +882,9 @@ KeyedStateHandle materializeSnapshot() throws Exception
{
sstFiles.putAll(newSstFiles);
sstFiles.putAll(oldSstFiles);
- stateBackend.materializedSstFiles.put(checkpointId,
sstFiles);
+ synchronized (stateBackend.asyncSnapshotLock) {
--- End diff --
I wonder if this is enough. As soon as we assume that there can be parallel
incremental snapshots (let's say s1 and s2) what could happen is the following
race:
- s1 completes and acknowledges to checkpoint coordinator, but the
notifyCheckpointComplete did not yet arrive.
- s2 runs and checks in `materializedSstFiles`, where it can not find
anything from s1, yet.
- s2 will perceive some files as new, which s1 has already registered in
the shared state.
- notifyCheckpointComplete from s1 arrives.
- s2 acknowledges. Now, in the `SharedStateRegistry`, the handles from s2
will try to register some sst files as new, which have been registered by s1
before (without s1 noticing). On the checkpoint coordinator, the
`RocksDBIncrementalStateHandle` will fail int the precondition check
`Preconditions.checkState(referenceCount == 1);` as soon as it tries to
register it's "new" sst files with `SharedStateRegistry`.
---
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.
---