You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/08 06:09:03 UTC

[GitHub] [flink] Myasuka commented on a diff in pull request #19399: [FLINK-26852][state] Avoid RocksDBMapState#clear swallowing related e…

Myasuka commented on code in PR #19399:
URL: https://github.com/apache/flink/pull/19399#discussion_r845764781


##########
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/EmbeddedRocksDBStateBackendTest.java:
##########
@@ -619,6 +623,25 @@ public void testSharedIncrementalStateDeRegistration() throws Exception {
         }
     }
 
+    @Test(expected = FlinkRuntimeException.class)
+    public void testMapStateClear() throws Exception {
+        setupRocksKeyedStateBackend();
+        keyedStateBackend = spy(keyedStateBackend);
+        MapStateDescriptor<Integer, String> kvId =
+                new MapStateDescriptor<>("id", Integer.class, String.class);
+        MapState<Integer, String> state =
+                keyedStateBackend.getPartitionedState(
+                        VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
+
+        doAnswer(
+                        invocationOnMock -> {
+                            throw new RocksDBException("Artificial failure");
+                        })
+                .when(keyedStateBackend)
+                .getWriteOptions();

Review Comment:
   We could change the implementation of state#clear in the future, and we might not call `keyedStateBackend`, however, we would not change the kernel logic of mapState#clear that we would always create a rocksdb iterator.
   
   I think the logic of spying on creating a iterator could be referred:
   ~~~ java
           doAnswer(
                           new Answer<Object>() {
   
                               @Override
                               public Object answer(InvocationOnMock invocationOnMock)
                                       throws Throwable {
                                   RocksIterator rocksIterator =
                                           spy((RocksIterator) invocationOnMock.callRealMethod());
                                   allCreatedCloseables.add(rocksIterator);
                                   return rocksIterator;
                               }
                           })
                   .when(keyedStateBackend.db)
                   .newIterator(any(ColumnFamilyHandle.class), any(ReadOptions.class));
   ~~~



##########
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/EmbeddedRocksDBStateBackendTest.java:
##########
@@ -89,9 +93,9 @@
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.internal.verification.VerificationModeFactory.times;
-import static org.powermock.api.mockito.PowerMockito.spy;

Review Comment:
   Why we have to change the `spy` implementation here?



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org