[GitHub] [flink] Myasuka commented on a diff in pull request #21362: [FLINK-29430] Add sanity check when setCurrentKeyGroupIndex
Myasuka commented on code in PR #21362: URL: https://github.com/apache/flink/pull/21362#discussion_r1034731440 ## flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/InternalKeyContextImpl.java: ## @@ -72,6 +73,10 @@ public void setCurrentKey(@Nonnull K currentKey) { @Override public void setCurrentKeyGroupIndex(int currentKeyGroupIndex) { +if (!keyGroupRange.contains(currentKeyGroupIndex)) { +throw KeyGroupRangeOffsets.newIllegalKeyGroupException( +currentKeyGroupIndex, keyGroupRange); +} Review Comment: I think Roman's suggestion is fine for developers, and for general users, as FLINK-23908 talked about, the current check would be fine during snapshotting. Maybe we can keep this implementation as current Zakelly did in this PR considering the performance impact is so small. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] Myasuka commented on a diff in pull request #21362: [FLINK-29430] Add sanity check when setCurrentKeyGroupIndex
Myasuka commented on code in PR #21362: URL: https://github.com/apache/flink/pull/21362#discussion_r1033444859 ## flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/InternalKeyContextImpl.java: ## @@ -72,6 +73,10 @@ public void setCurrentKey(@Nonnull K currentKey) { @Override public void setCurrentKeyGroupIndex(int currentKeyGroupIndex) { +if (!keyGroupRange.contains(currentKeyGroupIndex)) { +throw KeyGroupRangeOffsets.newIllegalKeyGroupException( +currentKeyGroupIndex, keyGroupRange); +} Review Comment: Maybe we can take a look at FLINK-23908, from which Flink community introduced the key group check. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] Myasuka commented on a diff in pull request #21362: [FLINK-29430] Add sanity check when setCurrentKeyGroupIndex
Myasuka commented on code in PR #21362: URL: https://github.com/apache/flink/pull/21362#discussion_r1033158877 ## flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/InternalKeyContextImpl.java: ## @@ -72,6 +73,10 @@ public void setCurrentKey(@Nonnull K currentKey) { @Override public void setCurrentKeyGroupIndex(int currentKeyGroupIndex) { +if (!keyGroupRange.contains(currentKeyGroupIndex)) { +throw KeyGroupRangeOffsets.newIllegalKeyGroupException( +currentKeyGroupIndex, keyGroupRange); +} Review Comment: I'm afraid that we cannot avoid the check on accessing state as users might provide a non-deterministic hashCode for the current key. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] Myasuka commented on a diff in pull request #21362: [FLINK-29430] Add sanity check when setCurrentKeyGroupIndex
Myasuka commented on code in PR #21362: URL: https://github.com/apache/flink/pull/21362#discussion_r1032801916 ## flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/InternalKeyContextImpl.java: ## @@ -72,6 +73,10 @@ public void setCurrentKey(@Nonnull K currentKey) { @Override public void setCurrentKeyGroupIndex(int currentKeyGroupIndex) { +if (!keyGroupRange.contains(currentKeyGroupIndex)) { +throw KeyGroupRangeOffsets.newIllegalKeyGroupException( +currentKeyGroupIndex, keyGroupRange); +} Review Comment: BTW, apart from changing the base class, we can also only change the `RocksDBKeyedStateBackend#setCurrentKey` to avoid the impact on HashMapStateBackend, as the HashMapStateBackend will always check the key group when accessing state tables. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org