fredia commented on code in PR #24768:
URL: https://github.com/apache/flink/pull/24768#discussion_r1597330403


##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStKeyedStateBackend.java:
##########
@@ -147,15 +160,30 @@ public <SV, S extends State> S createState(@Nonnull 
StateDescriptor<SV> stateDes
     @Override
     @Nonnull
     public StateExecutor createStateExecutor() {
-        // TODO: Make io parallelism configurable
-        return new ForStStateExecutor(4, db, 
optionsContainer.getWriteOptions());
+        synchronized (lock) {
+            if (disposed) {
+                throw new FlinkRuntimeException(
+                        "Attempt to create StateExecutor after 
ForStKeyedStateBackend is disposed.");
+            }
+            // TODO: Make io parallelism configurable
+            StateExecutor stateExecutor =
+                    new ForStStateExecutor(4, db, 
optionsContainer.getWriteOptions());
+            managedStateExecutors.add(stateExecutor);
+            return stateExecutor;
+        }
     }
 
     /** Should only be called by one thread, and only after all accesses to 
the DB happened. */
     @Override
     public void dispose() {
-        if (this.disposed) {
-            return;
+        synchronized (lock) {
+            if (disposed) {
+                return;
+            }
+            disposed = true;
+            for (StateExecutor executor : managedStateExecutors) {

Review Comment:
   Can this `for-loop` be placed outside the lock?



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to