{"action":"created","issue":{"url":"https://api.github.com/repos/Alluxio/alluxio/issues/3445","repository_url":"https://api.github.com/repos/Alluxio/alluxio","labels_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3445/labels{/name}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3445/comments","events_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3445/events","html_url":"https://github.com/Alluxio/alluxio/pull/3445","id":158279311,"number":3445,"title":"[ALLUXIO-1975] Fix issue with manual heartbeat scheduling","user":{"login":"aaudiber","id":3455177,"avatar_url":"https://avatars.githubusercontent.com/u/3455177?v=3","gravatar_id":"","url":"https://api.github.com/users/aaudiber","html_url":"https://github.com/aaudiber","followers_url":"https://api.github.com/users/aaudiber/followers","following_url":"https://api.github.com/users/aaudiber/following{/other_user}","gists_url":"https://api.github.com/users/aaudiber/gists{/gist_id}","starred_url":"https://api.github.com/users/aaudiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaudiber/subscriptions","organizations_url":"https://api.github.com/users/aaudiber/orgs","repos_url":"https://api.github.com/users/aaudiber/repos","events_url":"https://api.github.com/users/aaudiber/events{/privacy}","received_events_url":"https://api.github.com/users/aaudiber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-03T02:32:33Z","updated_at":"2016-06-03T02:54:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/3445","html_url":"https://github.com/Alluxio/alluxio/pull/3445","diff_url":"https://github.com/Alluxio/alluxio/pull/3445.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/3445.patch"},"body":"https://alluxio.atlassian.net/browse/ALLUXIO-1975\r\n\r\nPreviously we had flakiness due to the following flow:\r\n\r\n1. Unit test 1 creates a Master, e.g. FileSystemMaster, which uses a heartbeat thread. The heartbeat thread X is initialized to use the scheduled timer.\r\n2. The scheduled timer becomes ready to schedule and adds itself to the `sTimers` map in `HeartbeatScheduler`. This creates a mapping from the string \"X\" to the timer object.\r\n3. The test calls schedule, removing the timer from `sTimers` and executing a heartbeat. After the heartbeat has executed, the timer adds itself back to `sTimers`.\r\n4. Unit test 1 ends and the Master is stopped. `sTimers` is static and doesn't care (it still holds the mapping from \"X\" to the timer).\r\n5. Unit test 2 begins and creates a new Master and new timer named \"X\"\r\n6. Unit test 2 calls `HeartbeatScheduler.await()` to wait for the timer to become ready to schedule. This call immediately returns because the key \"X\" exists in the `sTimers` map. This indicates to the test that it's safe to call `schedule` even though the timer is not actually ready to schedule.\r\n7. The test fails because it relied on the heartbeat happening, but it never actually happened.\r\n\r\nThis issue is resolved by having timers clear their name from `sTimers` when they are constructed so that their past incarnations can't make it look like they are ready to schedule.\r\n\r\nThis pattern probably applies to more unit tests than just the one in ALLUXIO-1975."},"comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/issues/comments/223478873","html_url":"https://github.com/Alluxio/alluxio/pull/3445#issuecomment-223478873","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/3445","id":223478873,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T02:54:56Z","updated_at":"2016-06-03T02:54:56Z","body":"Test PASSed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/Alluxio-Pull-Request-Builder/10222/\nTest PASSed."}}
{"actor":{"display_login":"AmplabJenkins"}}