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 2019/07/10 12:23:02 UTC

[GitHub] [flink] StephanEwen commented on a change in pull request #8925: [FLINK-12852][network] Fix the deadlock occured when requesting exclusive buffers

StephanEwen commented on a change in pull request #8925: [FLINK-12852][network] Fix the deadlock occured when requesting exclusive buffers
URL: https://github.com/apache/flink/pull/8925#discussion_r302035513
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
 ##########
 @@ -477,4 +477,46 @@ public void go() throws Exception {
 			globalPool.destroy();
 		}
 	}
+
+	/**
+	 * Tests {@link NetworkBufferPool#requestMemorySegments()} and verifies it will end exceptionally
+	 * when failing to acquire all the segments in the specific timeout.
+	 */
+	@Test
+	public void testRequestMemorySegmentsTimeout() throws Exception {
+		final int numBuffers = 10;
+		final int numberOfSegmentsToRequest = 2;
+		final long requestSegmentsTimeoutInMillis = 1000L;
+
+		NetworkBufferPool globalPool = new NetworkBufferPool(
+				numBuffers,
+				128,
+				numberOfSegmentsToRequest,
+				requestSegmentsTimeoutInMillis);
+
+		BufferPool localBufferPool = globalPool.createBufferPool(0, numBuffers);
+		for (int i = 0; i < numBuffers; ++i) {
+			localBufferPool.requestBuffer();
+		}
+
+		assertEquals(0, globalPool.getNumberOfAvailableMemorySegments());
+
+		CheckedThread asyncRequest = new CheckedThread() {
+			@Override
+			public void go() throws Exception {
+				globalPool.requestMemorySegments();
+			}
+		};
+
+		asyncRequest.start();
+
+		try {
+			asyncRequest.trySync(requestSegmentsTimeoutInMillis * 10);
 
 Review comment:
   This probably leads to a flaky test. It should be okay to sync "forever" because if the feature is broken, the test will deadlock.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services