[ https://issues.apache.org/jira/browse/FLINK-8790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493578#comment-16493578 ]
ASF GitHub Bot commented on FLINK-8790: --------------------------------------- Github user StefanRRichter commented on a diff in the pull request: https://github.com/apache/flink/pull/5582#discussion_r191446316 --- Diff: flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBKeyedStateBackend.java --- @@ -718,70 +718,63 @@ void restore(Collection<KeyedStateHandle> restoreStateHandles) throws Exception boolean hasExtraKeys = (restoreStateHandles.size() > 1 || !Objects.equals(restoreStateHandles.iterator().next().getKeyGroupRange(), stateBackend.keyGroupRange)); - if (hasExtraKeys) { - stateBackend.createDB(); - } - - for (KeyedStateHandle rawStateHandle : restoreStateHandles) { - - if (rawStateHandle instanceof IncrementalKeyedStateHandle) { - restoreInstance((IncrementalKeyedStateHandle) rawStateHandle, hasExtraKeys); - } else if (rawStateHandle instanceof IncrementalLocalKeyedStateHandle) { - Preconditions.checkState(!hasExtraKeys, "Cannot recover from local state after rescaling."); - restoreInstance((IncrementalLocalKeyedStateHandle) rawStateHandle); - } else { - throw new IllegalStateException("Unexpected state handle type, " + - "expected " + IncrementalKeyedStateHandle.class + - ", but found " + rawStateHandle.getClass()); - } + if (!hasExtraKeys) { + restoreFromSingleHandle(restoreStateHandles.iterator().next()); --- End diff -- This new (and also the old code before) look like there could be a potential bug: if `restoreStateHandles.size() > 1` is false, how can we be sure that `restoreStateHandles.iterator().next()` exists? Even if it works from some hidden assumption, it does not look so clean. > Improve performance for recovery from incremental checkpoint > ------------------------------------------------------------ > > Key: FLINK-8790 > URL: https://issues.apache.org/jira/browse/FLINK-8790 > Project: Flink > Issue Type: Improvement > Components: State Backends, Checkpointing > Affects Versions: 1.5.0 > Reporter: Sihua Zhou > Assignee: Sihua Zhou > Priority: Major > Fix For: 1.6.0 > > > When there are multi state handle to be restored, we can improve the > performance as follow: > 1. Choose the best state handle to init the target db > 2. Use the other state handles to create temp db, and clip the db according > to the target key group range (via rocksdb.deleteRange()), this can help use > get rid of the `key group check` in > `data insertion loop` and also help us get rid of traversing the useless > record. -- This message was sent by Atlassian JIRA (v7.6.3#76005)