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/02/07 10:08:32 UTC

[GitHub] tillrohrmann commented on a change in pull request #7654: [FLINK-11524] Solve race condition in EmbeddedLeaderService

tillrohrmann commented on a change in pull request #7654: [FLINK-11524] Solve race condition in EmbeddedLeaderService
URL: https://github.com/apache/flink/pull/7654#discussion_r254616066
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/embedded/EmbeddedHaServicesTest.java
 ##########
 @@ -164,4 +171,70 @@ public void testResourceManagerLeaderRetrieval() throws Exception {
 
 		verify(leaderRetrievalListener).notifyLeaderAddress(eq(address), eq(leaderId));
 	}
+
+	/**
+	 * Tests that concurrent leadership operations (granting and revoking) leadership leave the
+	 * system in a sane state.
+	 */
+	@Test
+	public void testConcurrentLeadershipOperations() throws Exception {
+		final LeaderElectionService dispatcherLeaderElectionService = embeddedHaServices.getDispatcherLeaderElectionService();
+		final ArrayBlockingQueue<UUID> offeredSessionIds = new ArrayBlockingQueue<>(2);
+		final TestingLeaderContender leaderContender = new TestingLeaderContender(offeredSessionIds);
+
+		dispatcherLeaderElectionService.start(leaderContender);
+
+		final UUID oldLeaderSessionId = offeredSessionIds.take();
+
+		assertThat(dispatcherLeaderElectionService.hasLeadership(oldLeaderSessionId), is(true));
+
+		embeddedHaServices.getDispatcherLeaderService().revokeLeadership().get();
 
 Review comment:
   `dispatcherLeaderElectionService` and `embeddedHaServices.getDispatcherLeaderService()` are two different things. The latter not only revokes the leadership but also notifies all listeners about the revoked leadership.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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