payload: {"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/25985","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/25985/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/25985/comments","events_url":"https://api.github.com/repos/apache/spark/issues/25985/events","html_url":"https://github.com/apache/spark/pull/25985","id":500716366,"node_id":"MDExOlB1bGxSZXF1ZXN0MzIzMTI3Mjg0","number":25985,"title":"[SPARK-29310][CORE][TESTS] TestMemoryManager should implement getExecutionMemoryUsageForTask()","user":{"login":"JoshRosen","id":50748,"node_id":"MDQ6VXNlcjUwNzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/50748?v=4","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"labels":[{"id":1405801482,"node_id":"MDU6TGFiZWwxNDA1ODAxNDgy","url":"https://api.github.com/repos/apache/spark/labels/SPARK%20CORE","name":"SPARK CORE","color":"ededed","default":false},{"id":1406606402,"node_id":"MDU6TGFiZWwxNDA2NjA2NDAy","url":"https://api.github.com/repos/apache/spark/labels/TESTS","name":"TESTS","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-10-01T07:31:07Z","updated_at":"2019-10-01T18:34:00Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/25985","html_url":"https://github.com/apache/spark/pull/25985","diff_url":"https://github.com/apache/spark/pull/25985.diff","patch_url":"https://github.com/apache/spark/pull/25985.patch"},"body":"<!--\r\nThanks for sending a pull request!  Here are some tips for you:\r\n  1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html\r\n  2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html\r\n  3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.\r\n  4. Be sure to keep the PR description updated to reflect all changes.\r\n  5. Please write your PR title to summarize what this PR proposes.\r\n  6. If possible, provide a concise example to reproduce the issue for a faster review.\r\n-->\r\n\r\n### What changes were proposed in this pull request?\r\n<!--\r\nPlease clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. \r\nIf possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.\r\n  1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.\r\n  2. If you fix some SQL features, you can provide some references of other DBMSes.\r\n  3. If there is design documentation, please add the link.\r\n  4. If there is a discussion in the mailing list, please add the link.\r\n-->\r\n\r\nThis PR updates `TestMemoryManager`, a class used only in unit tests, to override the `getExecutionMemoryUsageForTask()` and `releaseAllExecutionMemoryForTask()` methods. I also `synchronized` its state-accessing methods (to make the class thread-safe) and added some additional assertions to guard against freeing memory memory than has been allocated.\r\n\r\n### Why are the changes needed?\r\n<!--\r\nPlease clarify why the changes are needed. For instance,\r\n  1. If you propose a new API, clarify the use case for a new API.\r\n  2. If you fix a bug, you can clarify why it is a bug.\r\n-->\r\n\r\nSpark uses a `TestMemoryManager` class to mock out memory manager functionality in tests, allowing test authors to exercise control over certain behaviors (e.g. to simulate OOMs).\r\n\r\nSeveral of Spark's test suites have memory-leak detection to ensure that all allocated memory is cleaned up at the end of each test case; this helps to guard against bugs that could cause production memory leaks. For example, see `testWithMemoryLeakDetection` in `UnsafeFixedWidthAggregationMapSuite`.\r\n\r\nUnfortunately, however, this leak-detection logic is broken for tests which use TestMemoryManager because it does not override the `getExecutionMemoryUsageForTask()` method that is used by the leak-detection checks.\r\n\r\nThis PR fixes that problem, thereby strengthening our existing tests. \r\n\r\nI spotted this problem while reviewing #25953: I tried introducing a change to remove a `freePage()` call (purposely inducing a memory leak) but no tests failed.\r\n\r\n### Does this PR introduce any user-facing change?\r\n<!--\r\nIf yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.\r\nIf no, write 'No'.\r\n-->\r\n\r\nNo.\r\n\r\n### How was this patch tested?\r\n<!--\r\nIf tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.\r\nIf it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.\r\nIf tests were not added, please describe why they were not added and/or why it was difficult to add.\r\n-->\r\n\r\nAdded a new `TestMemoryManagerSuite`, with tests covering `TestMemoryManager` itself.\r\n\r\nRan a subset of existing tests on my laptop and uncovered a bug in one test's `free()` calls, plus missing cleanup calls in another test suite; both of these issues are fixed in this PR.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/537170064","html_url":"https://github.com/apache/spark/pull/25985#issuecomment-537170064","issue_url":"https://api.github.com/repos/apache/spark/issues/25985","id":537170064,"node_id":"MDEyOklzc3VlQ29tbWVudDUzNzE3MDA2NA==","user":{"login":"SparkQA","id":8108735,"node_id":"MDQ6VXNlcjgxMDg3MzU=","avatar_url":"https://avatars1.githubusercontent.com/u/8108735?v=4","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2019-10-01T18:34:00Z","updated_at":"2019-10-01T18:34:00Z","author_association":"NONE","body":"**[Test build #111649 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/111649/testReport)** for PR 25985 at commit [`4e0364a`](https://github.com/apache/spark/commit/4e0364a34bb3b9cece996a284638a5e9277d3f4e).\n * This patch passes all tests.\n * This patch merges cleanly.\n * This patch adds no public classes."}}
other: {"actor":{"display_login":"SparkQA"}}