You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/23 22:20:49 UTC

[GitHub] [beam] Abacn commented on a diff in pull request #22023: Fix SpannerIO flakes

Abacn commented on code in PR #22023:
URL: https://github.com/apache/beam/pull/22023#discussion_r905553948


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIOWriteExceptionHandlingTest.java:
##########
@@ -171,9 +163,21 @@ public void testExceptionHandlingForSimpleWrite() throws InterruptedException {
     try {
       pipeline.run().waitUntilFinish();
     } finally {
-      verify(SpannerIO.WriteToSpannerFn.sleeper, times(callsToSleeper)).sleep(anyLong());
-      verify(serviceFactory.mockDatabaseClient(), times(callsToWrite))
-          .writeAtLeastOnceWithOptions(any(), any(Options.ReadQueryUpdateTransactionOption.class));
+      if (exceptionErrorcode == ErrorCode.DEADLINE_EXCEEDED) {
+        // Due to randomOffset retry is done by most likely but not always 9 times.
+        int sleepCalled =
+            Mockito.mockingDetails(SpannerIO.WriteToSpannerFn.sleeper).getInvocations().size();
+        assertTrue(sleepCalled >= 8);
+        assertTrue(sleepCalled <= 10);

Review Comment:
   Ran backOff 1 milliion times and found number of retry is distributed as: {8=52661, 9=878266, 10=69073}. i.e. Originally it has a flake probability of 12%



-- 
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: github-unsubscribe@beam.apache.org

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