{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/atlasdb/pulls/comments/112554996","pull_request_review_id":33864395,"id":112554996,"diff_hunk":"@@ -0,0 +1,67 @@\n+/**\n+ * Copyright 2017 Palantir Technologies\n+ *\n+ * Licensed under the BSD-3 License (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://opensource.org/licenses/BSD-3-Clause\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.palantir.atlasdb.timelock.lock;\n+\n+import static org.assertj.core.api.Assertions.assertThat;\n+\n+import java.util.Set;\n+\n+import org.junit.Test;\n+\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.google.common.collect.ImmutableSet;\n+import com.palantir.atlasdb.timelock.config.ClusterConfiguration;\n+import com.palantir.atlasdb.timelock.config.ImmutableClusterConfiguration;\n+import com.palantir.atlasdb.timelock.config.TimeLockServerConfiguration;\n+\n+public class BlockingTimeoutsTest {\n+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();\n+\n+    private static final String ADDRESS = \"localhost:8701\";\n+    private static final ClusterConfiguration CLUSTER = ImmutableClusterConfiguration.builder()\n+            .localServer(ADDRESS)\n+            .addServers(ADDRESS)\n+            .build();\n+    private static final Set<String> CLIENTS = ImmutableSet.of(\"client1\", \"client2\");\n+\n+    private static final long ONE_MILLION = 1_000_000;\n+    private static final long FIVE_HUNDRED = 500;\n+    private static final long FIVE = 5;\n+\n+    @Test\n+    public void scaleForErrorMarginReducesTimeoutSlightly() {\n+        assertThat(BlockingTimeouts.scaleForErrorMargin(ONE_MILLION))\n+                .isLessThan(ONE_MILLION)\n+                .isEqualTo(970_000);","path":"timelock-server/src/test/java/com/palantir/atlasdb/timelock/lock/BlockingTimeoutsTest.java","position":48,"original_position":48,"commit_id":"a80e017283ba88d8854e7d6d9bf68fc14bacd253","original_commit_id":"a80e017283ba88d8854e7d6d9bf68fc14bacd253","user":{"login":"hsaraogi","id":20421615,"avatar_url":"https://avatars1.githubusercontent.com/u/20421615?v=3","gravatar_id":"","url":"https://api.github.com/users/hsaraogi","html_url":"https://github.com/hsaraogi","followers_url":"https://api.github.com/users/hsaraogi/followers","following_url":"https://api.github.com/users/hsaraogi/following{/other_user}","gists_url":"https://api.github.com/users/hsaraogi/gists{/gist_id}","starred_url":"https://api.github.com/users/hsaraogi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsaraogi/subscriptions","organizations_url":"https://api.github.com/users/hsaraogi/orgs","repos_url":"https://api.github.com/users/hsaraogi/repos","events_url":"https://api.github.com/users/hsaraogi/events{/privacy}","received_events_url":"https://api.github.com/users/hsaraogi/received_events","type":"User","site_admin":false},"body":"Calculate this from the ERROR_MARGIN constant, after making it `visibleForTesting`?","created_at":"2017-04-20T20:38:15Z","updated_at":"2017-04-20T20:41:37Z","html_url":"https://github.com/palantir/atlasdb/pull/1808#discussion_r112554996","pull_request_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1808","_links":{"self":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/comments/112554996"},"html":{"href":"https://github.com/palantir/atlasdb/pull/1808#discussion_r112554996"},"pull_request":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1808"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/atlasdb/pulls/1808","id":116149749,"html_url":"https://github.com/palantir/atlasdb/pull/1808","diff_url":"https://github.com/palantir/atlasdb/pull/1808.diff","patch_url":"https://github.com/palantir/atlasdb/pull/1808.patch","issue_url":"https://api.github.com/repos/palantir/atlasdb/issues/1808","number":1808,"state":"open","locked":false,"title":"Episode V: The Locks Strike Back (mostly done, but needs ETE test)","user":{"login":"jeremyk-91","id":5955510,"avatar_url":"https://avatars1.githubusercontent.com/u/5955510?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyk-91","html_url":"https://github.com/jeremyk-91","followers_url":"https://api.github.com/users/jeremyk-91/followers","following_url":"https://api.github.com/users/jeremyk-91/following{/other_user}","gists_url":"https://api.github.com/users/jeremyk-91/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyk-91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyk-91/subscriptions","organizations_url":"https://api.github.com/users/jeremyk-91/orgs","repos_url":"https://api.github.com/users/jeremyk-91/repos","events_url":"https://api.github.com/users/jeremyk-91/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyk-91/received_events","type":"User","site_admin":false},"body":"Note: This is in a reasonable state for review, but I would like to manual-ETE test this on a reasonably complete stack of internal products before merging.\r\n\r\nIs failing ETE tests because of #1809. We need to fix that first before merging this in (though I think this doesn't block reviewing this PR).\r\n\r\nAlso, I plan to break out the SerializableErrorDecoder to a separate PR so that we can address #1813 by itself. This PR will switch AtlasDbErrorDecoder over to use it.\r\n\r\n---\r\n\r\n**Goals (and why)**:\r\n\r\n* Solve #1680 without failing long-running lock requests, which blocks our big guy #1728 \r\n\r\n**Implementation Description (bullets)**:\r\n\r\nThis PR has three nontrivial pieces. I would have preferred to have done them separately, though I want to verify they work in concert before merging them.\r\n\r\n* `BlockingTimeLimitedLockService` actually time-limits the sensitive operations on the lock service.\r\n* `BlockingTimeouts` parses the Dropwizard configuration and extracts the minimum blocking timeout across all application connectors. It then calculates the blocking timeout, which is currently 97 percent of the idle timeout. I've documented why it's safe in terms of correctness even if we have a race between this and the idle timeout.\r\n* Changes to the exception handling logic - an exception is now returned with a body. If an old client receives a message this is fine, as it would previously have ignored the body. I made the old clients treat `BlockingTimeoutException` as non-fast-failover (no `Retry-After` header) to allow old clients to behave reasonably well with this in place.\r\n\r\nThis PR does NOT include the following (but I want to do these):\r\n\r\n* ADR for how the lock retrying works\r\n* Automated ETE test that verifies that a lock held for more than an idle timeout doesn't cause other clients to overload the server.\r\n\r\n**Concerns (what feedback would you like?)**:\r\n\r\n* I have only time-limited the LockService methods that throw `InterruptedException` as I guess they are the ones likely to be contentious. Is this reasonable and/or safe?\r\n* `BlockingTimeouts` is rather unpleasant. Is there an easier way to enforce the key invariant (blocking timeout is a smidge under the minimum idle timeout) and/or should I even bother to enforce this?\r\n\r\n**Where should we start reviewing?**:\r\n\r\n* `BlockingTimeLimitedLockService` is probably a good starting point.\r\n\r\n**Priority (whenever / two weeks / yesterday)**:\r\n\r\nNot too urgent. I'm rather busy with non-AtlasDB related work this week, so my bandwidth is somewhat limited (though nonzero).","created_at":"2017-04-17T15:26:40Z","updated_at":"2017-04-20T20:41:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"029f00826c100038dece196e08b3b79b185f2662","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1808/commits","review_comments_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1808/comments","review_comment_url":"https://api.github.com/repos/palantir/atlasdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/atlasdb/issues/1808/comments","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/a80e017283ba88d8854e7d6d9bf68fc14bacd253","head":{"label":"palantir:jkong/server-lock-with-timeouts","ref":"jkong/server-lock-with-timeouts","sha":"a80e017283ba88d8854e7d6d9bf68fc14bacd253","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars3.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":36960637,"name":"atlasdb","full_name":"palantir/atlasdb","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars3.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/atlasdb","description":"Transactional Distributed Database Layer","fork":false,"url":"https://api.github.com/repos/palantir/atlasdb","forks_url":"https://api.github.com/repos/palantir/atlasdb/forks","keys_url":"https://api.github.com/repos/palantir/atlasdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/atlasdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/atlasdb/teams","hooks_url":"https://api.github.com/repos/palantir/atlasdb/hooks","issue_events_url":"https://api.github.com/repos/palantir/atlasdb/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/atlasdb/events","assignees_url":"https://api.github.com/repos/palantir/atlasdb/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/atlasdb/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/atlasdb/tags","blobs_url":"https://api.github.com/repos/palantir/atlasdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/atlasdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/atlasdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/atlasdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/atlasdb/languages","stargazers_url":"https://api.github.com/repos/palantir/atlasdb/stargazers","contributors_url":"https://api.github.com/repos/palantir/atlasdb/contributors","subscribers_url":"https://api.github.com/repos/palantir/atlasdb/subscribers","subscription_url":"https://api.github.com/repos/palantir/atlasdb/subscription","commits_url":"https://api.github.com/repos/palantir/atlasdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/atlasdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/atlasdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/atlasdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/atlasdb/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/atlasdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/atlasdb/merges","archive_url":"https://api.github.com/repos/palantir/atlasdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/atlasdb/downloads","issues_url":"https://api.github.com/repos/palantir/atlasdb/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/atlasdb/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/atlasdb/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/atlasdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/atlasdb/labels{/name}","releases_url":"https://api.github.com/repos/palantir/atlasdb/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/atlasdb/deployments","created_at":"2015-06-05T23:42:44Z","updated_at":"2017-04-15T20:24:06Z","pushed_at":"2017-04-20T19:49:46Z","git_url":"git://github.com/palantir/atlasdb.git","ssh_url":"git@github.com:palantir/atlasdb.git","clone_url":"https://github.com/palantir/atlasdb.git","svn_url":"https://github.com/palantir/atlasdb","homepage":"http://palantir.github.io/atlasdb/","size":34352,"stargazers_count":461,"watchers_count":461,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":151,"forks":75,"open_issues":151,"watchers":461,"default_branch":"develop"}},"base":{"label":"palantir:develop","ref":"develop","sha":"1765e60d5094f25b51d1b4acd32c89a6e0b3bad1","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars3.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":36960637,"name":"atlasdb","full_name":"palantir/atlasdb","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars3.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/atlasdb","description":"Transactional Distributed Database Layer","fork":false,"url":"https://api.github.com/repos/palantir/atlasdb","forks_url":"https://api.github.com/repos/palantir/atlasdb/forks","keys_url":"https://api.github.com/repos/palantir/atlasdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/atlasdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/atlasdb/teams","hooks_url":"https://api.github.com/repos/palantir/atlasdb/hooks","issue_events_url":"https://api.github.com/repos/palantir/atlasdb/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/atlasdb/events","assignees_url":"https://api.github.com/repos/palantir/atlasdb/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/atlasdb/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/atlasdb/tags","blobs_url":"https://api.github.com/repos/palantir/atlasdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/atlasdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/atlasdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/atlasdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/atlasdb/languages","stargazers_url":"https://api.github.com/repos/palantir/atlasdb/stargazers","contributors_url":"https://api.github.com/repos/palantir/atlasdb/contributors","subscribers_url":"https://api.github.com/repos/palantir/atlasdb/subscribers","subscription_url":"https://api.github.com/repos/palantir/atlasdb/subscription","commits_url":"https://api.github.com/repos/palantir/atlasdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/atlasdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/atlasdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/atlasdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/atlasdb/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/atlasdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/atlasdb/merges","archive_url":"https://api.github.com/repos/palantir/atlasdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/atlasdb/downloads","issues_url":"https://api.github.com/repos/palantir/atlasdb/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/atlasdb/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/atlasdb/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/atlasdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/atlasdb/labels{/name}","releases_url":"https://api.github.com/repos/palantir/atlasdb/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/atlasdb/deployments","created_at":"2015-06-05T23:42:44Z","updated_at":"2017-04-15T20:24:06Z","pushed_at":"2017-04-20T19:49:46Z","git_url":"git://github.com/palantir/atlasdb.git","ssh_url":"git@github.com:palantir/atlasdb.git","clone_url":"https://github.com/palantir/atlasdb.git","svn_url":"https://github.com/palantir/atlasdb","homepage":"http://palantir.github.io/atlasdb/","size":34352,"stargazers_count":461,"watchers_count":461,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":151,"forks":75,"open_issues":151,"watchers":461,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1808"},"html":{"href":"https://github.com/palantir/atlasdb/pull/1808"},"issue":{"href":"https://api.github.com/repos/palantir/atlasdb/issues/1808"},"comments":{"href":"https://api.github.com/repos/palantir/atlasdb/issues/1808/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1808/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1808/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/atlasdb/statuses/a80e017283ba88d8854e7d6d9bf68fc14bacd253"}}}}
{"actor":{"display_login":"hsaraogi"}}