masteryhx commented on code in PR #19679:
URL: https://github.com/apache/flink/pull/19679#discussion_r939789230


##########
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogKeyedStateBackend.java:
##########
@@ -782,21 +847,57 @@ public KeyGroupRange getKeyGroupRange() {
             }
 
             @Override
+            @SuppressWarnings("unchecked")
             public <N, S extends State, V> S createKeyedState(
                     TypeSerializer<N> namespaceSerializer, StateDescriptor<S, 
V> stateDescriptor)
                     throws Exception {
-                return ChangelogKeyedStateBackend.this.getOrCreateKeyedState(
-                        namespaceSerializer, stateDescriptor);
+                InternalKvState<K, N, V> kvState =
+                        keyedStateBackend.createOrUpdateInternalState(
+                                namespaceSerializer, stateDescriptor, 
noTransform(), true);
+                ChangelogState changelogState =
+                        changelogStateFactory.getExistingState(
+                                stateDescriptor.getName(),
+                                
StateMetaInfoSnapshot.BackendStateType.KEY_VALUE);
+                if (changelogState == null) {
+                    changelogState =
+                            changelogStateFactory.create(
+                                    stateDescriptor,
+                                    kvState,
+                                    getKvStateChangeLogger(kvState, 
stateDescriptor, noTransform()),
+                                    keyedStateBackend /* pass the nested 
backend as key context so that it get key updates on recovery*/);
+                } else {
+                    updateChangelogState(changelogState, kvState, 
stateDescriptor, noTransform());
+                }

Review Comment:
   Sorry for the late reply.
   I think current implementation should have covered the case you pointed out, 
because the `create` would be called when changelog recovery, and the `update` 
would be called when user access.
   You could debug `testKeyedValueStateMigration` for changelog state backend 
and see the branch has been accessed.



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