-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-4216: Fix a race condition in WatcherCleanerTest.testDeadWatcherMetrics #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c1d57e0
1052ee9
c0eb6fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,8 +17,8 @@ | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| package org.apache.zookeeper.server.watch; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import static org.hamcrest.MatcherAssert.assertThat; | ||||||||||||||||||||||||||||||||||||||
| import static org.hamcrest.number.OrderingComparison.greaterThan; | ||||||||||||||||||||||||||||||||||||||
| import static org.hamcrest.Matchers.greaterThan; | ||||||||||||||||||||||||||||||||||||||
| import static org.hamcrest.Matchers.is; | ||||||||||||||||||||||||||||||||||||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||||||||||||||||||||||||||||||||||||||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||||||||||||||||||||||||||||||||||||||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -140,7 +140,7 @@ public void testMaxInProcessingDeadWatchers() { | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||
| public void testDeadWatcherMetrics() { | ||||||||||||||||||||||||||||||||||||||
| public void testDeadWatcherMetrics() throws InterruptedException { | ||||||||||||||||||||||||||||||||||||||
| ServerMetrics.getMetrics().resetAll(); | ||||||||||||||||||||||||||||||||||||||
| MyDeadWatcherListener listener = new MyDeadWatcherListener(); | ||||||||||||||||||||||||||||||||||||||
| WatcherCleaner cleaner = new WatcherCleaner(listener, 1, 1, 1, 1); | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -156,19 +156,19 @@ public void testDeadWatcherMetrics() { | |||||||||||||||||||||||||||||||||||||
| assertTrue(listener.wait(5000)); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Map<String, Object> values = MetricsUtils.currentServerMetrics(); | ||||||||||||||||||||||||||||||||||||||
| assertThat("Adding dead watcher should be stalled twice", (Long) values.get("add_dead_watcher_stall_time"), greaterThan(0L)); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(3L, values.get("dead_watchers_queued"), "Total dead watchers added to the queue should be 3"); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(3L, values.get("dead_watchers_cleared"), "Total dead watchers cleared should be 3"); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| assertEquals(3L, values.get("cnt_dead_watchers_cleaner_latency")); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| //Each latency should be a little over 20 ms, allow 20 ms deviation | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, (Double) values.get("avg_dead_watchers_cleaner_latency"), 20); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, ((Long) values.get("min_dead_watchers_cleaner_latency")).doubleValue(), 20); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, ((Long) values.get("max_dead_watchers_cleaner_latency")).doubleValue(), 20); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, ((Long) values.get("p50_dead_watchers_cleaner_latency")).doubleValue(), 20); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, ((Long) values.get("p95_dead_watchers_cleaner_latency")).doubleValue(), 20); | ||||||||||||||||||||||||||||||||||||||
| assertEquals(20D, ((Long) values.get("p99_dead_watchers_cleaner_latency")).doubleValue(), 20); | ||||||||||||||||||||||||||||||||||||||
| // Adding dead watcher should be stalled twice | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("add_dead_watcher_stall_time", greaterThan(0L)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("dead_watchers_queued", is(3L)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("dead_watchers_cleared", is(3L)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("cnt_dead_watchers_cleaner_latency", is(3L)); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| //Each latency should be a little over 20 ms, allow 5 ms deviation | ||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems that we rollback ZOOKEEPER-4200(#1592) after zookeeper/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounter.java Lines 44 to 49 in e50a0bb
zookeeper/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounter.java Lines 65 to 76 in e50a0bb
|
||||||||||||||||||||||||||||||||||||||
| waitForMetric("avg_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("min_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("max_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("p50_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("p95_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| waitForMetric("p99_dead_watchers_cleaner_latency", closeTo(20, 5)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.