{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/32714199","id":32714199,"diff_hunk":"@@ -1084,7 +1091,13 @@ func (r *Range) mergeTrigger(batch engine.Engine, merge *proto.MergeTrigger) err\n \t// and not worth the extra logic and potential for error.\n \tr.tsCache.Clear(r.rm.Clock())\n \n-\treturn r.rm.MergeRange(r, merge.UpdatedDesc.EndKey, merge.SubsumedRaftID)\n+\tbatch.Defer(func() {","path":"storage/range_command.go","position":21,"original_position":21,"commit_id":"f9e92a3c1036a79748d677f7bbe22c744a1a492c","original_commit_id":"f9e92a3c1036a79748d677f7bbe22c744a1a492c","user":{"login":"tschottdorf","id":5076964,"avatar_url":"https://avatars.githubusercontent.com/u/5076964?v=3","gravatar_id":"","url":"https://api.github.com/users/tschottdorf","html_url":"https://github.com/tschottdorf","followers_url":"https://api.github.com/users/tschottdorf/followers","following_url":"https://api.github.com/users/tschottdorf/following{/other_user}","gists_url":"https://api.github.com/users/tschottdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/tschottdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschottdorf/subscriptions","organizations_url":"https://api.github.com/users/tschottdorf/orgs","repos_url":"https://api.github.com/users/tschottdorf/repos","events_url":"https://api.github.com/users/tschottdorf/events{/privacy}","received_events_url":"https://api.github.com/users/tschottdorf/received_events","type":"User","site_admin":false},"body":"Also, doesn't everything that mutates `r` above need to be done in the defer (and Fatal when something goes wrong or somehow recover the previous state)?","created_at":"2015-06-18T09:53:54Z","updated_at":"2015-06-18T09:53:54Z","html_url":"https://github.com/cockroachdb/cockroach/pull/1407#discussion_r32714199","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/32714199"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/1407#discussion_r32714199"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407","id":37956163,"html_url":"https://github.com/cockroachdb/cockroach/pull/1407","diff_url":"https://github.com/cockroachdb/cockroach/pull/1407.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/1407.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/1407","number":1407,"state":"open","locked":false,"title":"Do not call Store.{Split,Merge}Range until after the RocksDB commit.","user":{"login":"bdarnell","id":160562,"avatar_url":"https://avatars.githubusercontent.com/u/160562?v=3","gravatar_id":"","url":"https://api.github.com/users/bdarnell","html_url":"https://github.com/bdarnell","followers_url":"https://api.github.com/users/bdarnell/followers","following_url":"https://api.github.com/users/bdarnell/following{/other_user}","gists_url":"https://api.github.com/users/bdarnell/gists{/gist_id}","starred_url":"https://api.github.com/users/bdarnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdarnell/subscriptions","organizations_url":"https://api.github.com/users/bdarnell/orgs","repos_url":"https://api.github.com/users/bdarnell/repos","events_url":"https://api.github.com/users/bdarnell/events{/privacy}","received_events_url":"https://api.github.com/users/bdarnell/received_events","type":"User","site_admin":false},"body":"Introduce Engine.Defer() to associate callbacks with the commit.\r\n\r\nFixes #1191.","created_at":"2015-06-17T22:57:21Z","updated_at":"2015-06-18T09:53:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce52ba3a92f6d28bba11c0a79fd5d779c246bd45","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/1407/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/f9e92a3c1036a79748d677f7bbe22c744a1a492c","head":{"label":"bdarnell:batch-defer","ref":"batch-defer","sha":"f9e92a3c1036a79748d677f7bbe22c744a1a492c","user":{"login":"bdarnell","id":160562,"avatar_url":"https://avatars.githubusercontent.com/u/160562?v=3","gravatar_id":"","url":"https://api.github.com/users/bdarnell","html_url":"https://github.com/bdarnell","followers_url":"https://api.github.com/users/bdarnell/followers","following_url":"https://api.github.com/users/bdarnell/following{/other_user}","gists_url":"https://api.github.com/users/bdarnell/gists{/gist_id}","starred_url":"https://api.github.com/users/bdarnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdarnell/subscriptions","organizations_url":"https://api.github.com/users/bdarnell/orgs","repos_url":"https://api.github.com/users/bdarnell/repos","events_url":"https://api.github.com/users/bdarnell/events{/privacy}","received_events_url":"https://api.github.com/users/bdarnell/received_events","type":"User","site_admin":false},"repo":{"id":23885381,"name":"cockroach","full_name":"bdarnell/cockroach","owner":{"login":"bdarnell","id":160562,"avatar_url":"https://avatars.githubusercontent.com/u/160562?v=3","gravatar_id":"","url":"https://api.github.com/users/bdarnell","html_url":"https://github.com/bdarnell","followers_url":"https://api.github.com/users/bdarnell/followers","following_url":"https://api.github.com/users/bdarnell/following{/other_user}","gists_url":"https://api.github.com/users/bdarnell/gists{/gist_id}","starred_url":"https://api.github.com/users/bdarnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdarnell/subscriptions","organizations_url":"https://api.github.com/users/bdarnell/orgs","repos_url":"https://api.github.com/users/bdarnell/repos","events_url":"https://api.github.com/users/bdarnell/events{/privacy}","received_events_url":"https://api.github.com/users/bdarnell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bdarnell/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":true,"url":"https://api.github.com/repos/bdarnell/cockroach","forks_url":"https://api.github.com/repos/bdarnell/cockroach/forks","keys_url":"https://api.github.com/repos/bdarnell/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bdarnell/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bdarnell/cockroach/teams","hooks_url":"https://api.github.com/repos/bdarnell/cockroach/hooks","issue_events_url":"https://api.github.com/repos/bdarnell/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/bdarnell/cockroach/events","assignees_url":"https://api.github.com/repos/bdarnell/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/bdarnell/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/bdarnell/cockroach/tags","blobs_url":"https://api.github.com/repos/bdarnell/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bdarnell/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bdarnell/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/bdarnell/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bdarnell/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/bdarnell/cockroach/languages","stargazers_url":"https://api.github.com/repos/bdarnell/cockroach/stargazers","contributors_url":"https://api.github.com/repos/bdarnell/cockroach/contributors","subscribers_url":"https://api.github.com/repos/bdarnell/cockroach/subscribers","subscription_url":"https://api.github.com/repos/bdarnell/cockroach/subscription","commits_url":"https://api.github.com/repos/bdarnell/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/bdarnell/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/bdarnell/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/bdarnell/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/bdarnell/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/bdarnell/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bdarnell/cockroach/merges","archive_url":"https://api.github.com/repos/bdarnell/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bdarnell/cockroach/downloads","issues_url":"https://api.github.com/repos/bdarnell/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/bdarnell/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/bdarnell/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/bdarnell/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bdarnell/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/bdarnell/cockroach/releases{/id}","created_at":"2014-09-10T17:55:56Z","updated_at":"2015-03-31T18:00:59Z","pushed_at":"2015-06-17T22:56:55Z","git_url":"git://github.com/bdarnell/cockroach.git","ssh_url":"git@github.com:bdarnell/cockroach.git","clone_url":"https://github.com/bdarnell/cockroach.git","svn_url":"https://github.com/bdarnell/cockroach","homepage":null,"size":22310,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"46e7273224746113f76a4bd341307f49305f62fd","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-06-18T08:59:32Z","pushed_at":"2015-06-18T09:30:12Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":38855,"stargazers_count":4706,"watchers_count":4706,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":338,"mirror_url":null,"open_issues_count":89,"forks":338,"open_issues":89,"watchers":4706,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/1407"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/1407"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/1407/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/1407/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/f9e92a3c1036a79748d677f7bbe22c744a1a492c"}}}}