{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/53838997","id":53838997,"diff_hunk":"@@ -202,11 +213,17 @@ func (c *Cache) Snapshot() *Cache {\n // Deduplicate sorts the snapshot before returning it. The compactor and any queries\n // coming in while it writes will need the values sorted\n func (c *Cache) Deduplicate() {\n-\tfor _, e := range c.store {\n+\tfor _, e := range c.dirty {\n \t\te.deduplicate()\n \t}\n }\n \n+// This method must be called while holding the write lock of the cache that\n+// create this snapshot.\n+func (c *Cache) UpdateStore() {","path":"tsdb/engine/tsm1/cache.go","position":44,"original_position":44,"commit_id":"3f2963169166d3f9bea4043454ff0e785fa5e980","original_commit_id":"3f2963169166d3f9bea4043454ff0e785fa5e980","user":{"login":"jwilder","id":219935,"avatar_url":"https://avatars.githubusercontent.com/u/219935?v=3","gravatar_id":"","url":"https://api.github.com/users/jwilder","html_url":"https://github.com/jwilder","followers_url":"https://api.github.com/users/jwilder/followers","following_url":"https://api.github.com/users/jwilder/following{/other_user}","gists_url":"https://api.github.com/users/jwilder/gists{/gist_id}","starred_url":"https://api.github.com/users/jwilder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwilder/subscriptions","organizations_url":"https://api.github.com/users/jwilder/orgs","repos_url":"https://api.github.com/users/jwilder/repos","events_url":"https://api.github.com/users/jwilder/events{/privacy}","received_events_url":"https://api.github.com/users/jwilder/received_events","type":"User","site_admin":false},"body":"This func is not necessary because `dirty` is not needed anymore.","created_at":"2016-02-23T19:52:24Z","updated_at":"2016-02-23T19:52:24Z","html_url":"https://github.com/influxdata/influxdb/pull/5701#discussion_r53838997","pull_request_url":"https://api.github.com/repos/influxdata/influxdb/pulls/5701","_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments/53838997"},"html":{"href":"https://github.com/influxdata/influxdb/pull/5701#discussion_r53838997"},"pull_request":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/5701"}}},"pull_request":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/5701","id":59488776,"html_url":"https://github.com/influxdata/influxdb/pull/5701","diff_url":"https://github.com/influxdata/influxdb/pull/5701.diff","patch_url":"https://github.com/influxdata/influxdb/pull/5701.patch","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/5701","number":5701,"state":"open","locked":false,"title":"tsm: cache: improve thread safety of Cache.Deduplicate (see #5699)","user":{"login":"jonseymour","id":207131,"avatar_url":"https://avatars.githubusercontent.com/u/207131?v=3","gravatar_id":"","url":"https://api.github.com/users/jonseymour","html_url":"https://github.com/jonseymour","followers_url":"https://api.github.com/users/jonseymour/followers","following_url":"https://api.github.com/users/jonseymour/following{/other_user}","gists_url":"https://api.github.com/users/jonseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/jonseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonseymour/subscriptions","organizations_url":"https://api.github.com/users/jonseymour/orgs","repos_url":"https://api.github.com/users/jonseymour/repos","events_url":"https://api.github.com/users/jonseymour/events{/privacy}","received_events_url":"https://api.github.com/users/jonseymour/received_events","type":"User","site_admin":false},"body":"Fixes #5699 \r\n\r\nCache.Deduplicate is designed to be execute while the caller is not holding\r\nany locks.\r\n\r\nThe entry.deduplicate() method contains two statements:\r\n\r\ne.values = e.values.Deduplicate()\r\ne.needSort = false\r\n\r\nwhich need to be executed in that order (as observed by all threads). However,\r\nwithout a synchronization construct won't (necessarily) be executed in that order.\r\n\r\nThis fix makes a clone of each entry before performing the deduplication,\r\nthen while briefly holding the lock, updates the store with the deduplicated clones\r\n\r\n\r\nSigned-off-by: Jon Seymour <jon@wildducktheories.com>","created_at":"2016-02-16T13:15:45Z","updated_at":"2016-02-23T19:52:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed622c1304827436eb29a5571754da17cc8fcdb4","assignee":null,"milestone":{"url":"https://api.github.com/repos/influxdata/influxdb/milestones/46","html_url":"https://github.com/influxdata/influxdb/milestones/0.11.0","labels_url":"https://api.github.com/repos/influxdata/influxdb/milestones/46/labels","id":1559540,"number":46,"title":"0.11.0","description":"","creator":{"login":"jwilder","id":219935,"avatar_url":"https://avatars.githubusercontent.com/u/219935?v=3","gravatar_id":"","url":"https://api.github.com/users/jwilder","html_url":"https://github.com/jwilder","followers_url":"https://api.github.com/users/jwilder/followers","following_url":"https://api.github.com/users/jwilder/following{/other_user}","gists_url":"https://api.github.com/users/jwilder/gists{/gist_id}","starred_url":"https://api.github.com/users/jwilder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwilder/subscriptions","organizations_url":"https://api.github.com/users/jwilder/orgs","repos_url":"https://api.github.com/users/jwilder/repos","events_url":"https://api.github.com/users/jwilder/events{/privacy}","received_events_url":"https://api.github.com/users/jwilder/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":75,"state":"open","created_at":"2016-02-02T20:50:35Z","updated_at":"2016-02-23T18:12:02Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/influxdata/influxdb/pulls/5701/commits","review_comments_url":"https://api.github.com/repos/influxdata/influxdb/pulls/5701/comments","review_comment_url":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/5701/comments","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/3f2963169166d3f9bea4043454ff0e785fa5e980","head":{"label":"jonseymour:js-deduplicate-safety","ref":"js-deduplicate-safety","sha":"3f2963169166d3f9bea4043454ff0e785fa5e980","user":{"login":"jonseymour","id":207131,"avatar_url":"https://avatars.githubusercontent.com/u/207131?v=3","gravatar_id":"","url":"https://api.github.com/users/jonseymour","html_url":"https://github.com/jonseymour","followers_url":"https://api.github.com/users/jonseymour/followers","following_url":"https://api.github.com/users/jonseymour/following{/other_user}","gists_url":"https://api.github.com/users/jonseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/jonseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonseymour/subscriptions","organizations_url":"https://api.github.com/users/jonseymour/orgs","repos_url":"https://api.github.com/users/jonseymour/repos","events_url":"https://api.github.com/users/jonseymour/events{/privacy}","received_events_url":"https://api.github.com/users/jonseymour/received_events","type":"User","site_admin":false},"repo":{"id":40862560,"name":"influxdb","full_name":"jonseymour/influxdb","owner":{"login":"jonseymour","id":207131,"avatar_url":"https://avatars.githubusercontent.com/u/207131?v=3","gravatar_id":"","url":"https://api.github.com/users/jonseymour","html_url":"https://github.com/jonseymour","followers_url":"https://api.github.com/users/jonseymour/followers","following_url":"https://api.github.com/users/jonseymour/following{/other_user}","gists_url":"https://api.github.com/users/jonseymour/gists{/gist_id}","starred_url":"https://api.github.com/users/jonseymour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonseymour/subscriptions","organizations_url":"https://api.github.com/users/jonseymour/orgs","repos_url":"https://api.github.com/users/jonseymour/repos","events_url":"https://api.github.com/users/jonseymour/events{/privacy}","received_events_url":"https://api.github.com/users/jonseymour/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonseymour/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":true,"url":"https://api.github.com/repos/jonseymour/influxdb","forks_url":"https://api.github.com/repos/jonseymour/influxdb/forks","keys_url":"https://api.github.com/repos/jonseymour/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonseymour/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonseymour/influxdb/teams","hooks_url":"https://api.github.com/repos/jonseymour/influxdb/hooks","issue_events_url":"https://api.github.com/repos/jonseymour/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/jonseymour/influxdb/events","assignees_url":"https://api.github.com/repos/jonseymour/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/jonseymour/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/jonseymour/influxdb/tags","blobs_url":"https://api.github.com/repos/jonseymour/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonseymour/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonseymour/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonseymour/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonseymour/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/jonseymour/influxdb/languages","stargazers_url":"https://api.github.com/repos/jonseymour/influxdb/stargazers","contributors_url":"https://api.github.com/repos/jonseymour/influxdb/contributors","subscribers_url":"https://api.github.com/repos/jonseymour/influxdb/subscribers","subscription_url":"https://api.github.com/repos/jonseymour/influxdb/subscription","commits_url":"https://api.github.com/repos/jonseymour/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonseymour/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonseymour/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonseymour/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonseymour/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/jonseymour/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonseymour/influxdb/merges","archive_url":"https://api.github.com/repos/jonseymour/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonseymour/influxdb/downloads","issues_url":"https://api.github.com/repos/jonseymour/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/jonseymour/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/jonseymour/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/jonseymour/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonseymour/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/jonseymour/influxdb/releases{/id}","deployments_url":"https://api.github.com/repos/jonseymour/influxdb/deployments","created_at":"2015-08-17T04:08:54Z","updated_at":"2016-02-19T13:19:44Z","pushed_at":"2016-02-23T19:44:58Z","git_url":"git://github.com/jonseymour/influxdb.git","ssh_url":"git@github.com:jonseymour/influxdb.git","clone_url":"https://github.com/jonseymour/influxdb.git","svn_url":"https://github.com/jonseymour/influxdb","homepage":"http://influxdb.com","size":37551,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"influxdata:master","ref":"master","sha":"e0b23fd5b0e75c2cdafbca5fd0e787366f85b655","user":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":13124802,"name":"influxdb","full_name":"influxdata/influxdb","owner":{"login":"influxdata","id":5713248,"avatar_url":"https://avatars.githubusercontent.com/u/5713248?v=3","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/influxdata/influxdb","description":"Scalable datastore for metrics, events, and real-time analytics","fork":false,"url":"https://api.github.com/repos/influxdata/influxdb","forks_url":"https://api.github.com/repos/influxdata/influxdb/forks","keys_url":"https://api.github.com/repos/influxdata/influxdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/influxdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/influxdb/teams","hooks_url":"https://api.github.com/repos/influxdata/influxdb/hooks","issue_events_url":"https://api.github.com/repos/influxdata/influxdb/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/influxdb/events","assignees_url":"https://api.github.com/repos/influxdata/influxdb/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/influxdb/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/influxdb/tags","blobs_url":"https://api.github.com/repos/influxdata/influxdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/influxdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/influxdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/influxdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/influxdb/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/influxdb/languages","stargazers_url":"https://api.github.com/repos/influxdata/influxdb/stargazers","contributors_url":"https://api.github.com/repos/influxdata/influxdb/contributors","subscribers_url":"https://api.github.com/repos/influxdata/influxdb/subscribers","subscription_url":"https://api.github.com/repos/influxdata/influxdb/subscription","commits_url":"https://api.github.com/repos/influxdata/influxdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/influxdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/influxdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/influxdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/influxdb/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/influxdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/influxdb/merges","archive_url":"https://api.github.com/repos/influxdata/influxdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/influxdb/downloads","issues_url":"https://api.github.com/repos/influxdata/influxdb/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/influxdb/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/influxdb/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/influxdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/influxdb/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/influxdb/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/influxdb/deployments","created_at":"2013-09-26T14:31:10Z","updated_at":"2016-02-23T16:11:44Z","pushed_at":"2016-02-23T19:44:59Z","git_url":"git://github.com/influxdata/influxdb.git","ssh_url":"git@github.com:influxdata/influxdb.git","clone_url":"https://github.com/influxdata/influxdb.git","svn_url":"https://github.com/influxdata/influxdb","homepage":"https://influxdata.com","size":41965,"stargazers_count":7432,"watchers_count":7432,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":952,"mirror_url":null,"open_issues_count":611,"forks":952,"open_issues":611,"watchers":7432,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/5701"},"html":{"href":"https://github.com/influxdata/influxdb/pull/5701"},"issue":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/5701"},"comments":{"href":"https://api.github.com/repos/influxdata/influxdb/issues/5701/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/5701/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/influxdb/pulls/5701/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/influxdb/statuses/3f2963169166d3f9bea4043454ff0e785fa5e980"}}}}