{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/198300918","pull_request_review_id":132200712,"id":198300918,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODMwMDkxOA==","diff_hunk":"@@ -8,12 +8,63 @@\n #ifndef ROCKSDB_LITE\n \n #include \"utilities/transactions/write_prepared_txn.h\"\n+#include \"utilities/transactions/write_unprepared_txn_db.h\"\n \n namespace rocksdb {\n \n+class WriteUnpreparedTxnDB;\n+class WriteUnpreparedTxn;\n+\n+class WriteUnpreparedTxnReadCallback : public ReadCallback {\n+ public:\n+  WriteUnpreparedTxnReadCallback(WritePreparedTxnDB* db,\n+                                 SequenceNumber snapshot,\n+                                 SequenceNumber min_uncommitted,\n+                                 WriteUnpreparedTxn* txn)\n+      : db_(db),\n+        snapshot_(snapshot),\n+        min_uncommitted_(min_uncommitted),\n+        txn_(txn) {}\n+\n+  virtual bool IsVisible(SequenceNumber seq) override;\n+  virtual SequenceNumber MaxUnpreparedSequenceNumber() override;\n+\n+ private:\n+  WritePreparedTxnDB* db_;\n+  SequenceNumber snapshot_;\n+  SequenceNumber min_uncommitted_;\n+  WriteUnpreparedTxn* txn_;\n+};\n+\n class WriteUnpreparedTxn : public WritePreparedTxn {\n-  using WritePreparedTxn::WritePreparedTxn;\n+ public:\n+  WriteUnpreparedTxn(WriteUnpreparedTxnDB* db,\n+                     const WriteOptions& write_options,\n+                     const TransactionOptions& txn_options);\n+\n+  virtual ~WriteUnpreparedTxn() {}\n+\n+  // Get and GetIterator needs to be overriden so that a ReadCallback to\n+  // handle read-your-own-write is used.\n+  using Transaction::Get;\n+  virtual Status Get(const ReadOptions& options,\n+                     ColumnFamilyHandle* column_family, const Slice& key,\n+                     PinnableSlice* value) override;\n+\n+  using Transaction::GetIterator;\n+  virtual Iterator* GetIterator(const ReadOptions& options) override;\n+  virtual Iterator* GetIterator(const ReadOptions& options,\n+                                ColumnFamilyHandle* column_family) override;\n+\n+  const std::map<SequenceNumber, size_t>& GetUnpreparedSequenceNumbers();\n+\n+ private:\n+  friend class WriteUnpreparedTransactionTest_ReadYourOwnWrite_Test;\n+\n+  WriteUnpreparedTxnDB* wupt_db_;\n \n+  // List of unprep_seq sequence numbers that we have already written to DB.","path":"utilities/transactions/write_unprepared_txn.h","position":60,"original_position":60,"commit_id":"e2a47b5f78bced64e2b3cba73b71a9e628fc0fc9","original_commit_id":"e2a47b5f78bced64e2b3cba73b71a9e628fc0fc9","user":{"login":"maysamyabandeh","id":1167741,"node_id":"MDQ6VXNlcjExNjc3NDE=","avatar_url":"https://avatars2.githubusercontent.com/u/1167741?v=4","gravatar_id":"","url":"https://api.github.com/users/maysamyabandeh","html_url":"https://github.com/maysamyabandeh","followers_url":"https://api.github.com/users/maysamyabandeh/followers","following_url":"https://api.github.com/users/maysamyabandeh/following{/other_user}","gists_url":"https://api.github.com/users/maysamyabandeh/gists{/gist_id}","starred_url":"https://api.github.com/users/maysamyabandeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maysamyabandeh/subscriptions","organizations_url":"https://api.github.com/users/maysamyabandeh/orgs","repos_url":"https://api.github.com/users/maysamyabandeh/repos","events_url":"https://api.github.com/users/maysamyabandeh/events{/privacy}","received_events_url":"https://api.github.com/users/maysamyabandeh/received_events","type":"User","site_admin":false},"body":"Can you emphasis on the comment that the map is ordered? We rely on this assumption later when we iterate over it.","created_at":"2018-06-26T21:17:48Z","updated_at":"2018-06-26T21:32:58Z","html_url":"https://github.com/facebook/rocksdb/pull/3955#discussion_r198300918","pull_request_url":"https://api.github.com/repos/facebook/rocksdb/pulls/3955","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments/198300918"},"html":{"href":"https://github.com/facebook/rocksdb/pull/3955#discussion_r198300918"},"pull_request":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/3955"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/rocksdb/pulls/3955","id":192780363,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNzgwMzYz","html_url":"https://github.com/facebook/rocksdb/pull/3955","diff_url":"https://github.com/facebook/rocksdb/pull/3955.diff","patch_url":"https://github.com/facebook/rocksdb/pull/3955.patch","issue_url":"https://api.github.com/repos/facebook/rocksdb/issues/3955","number":3955,"state":"open","locked":false,"title":"Disable seek to snapshot optimization for write unprepared","user":{"login":"lth","id":292656,"node_id":"MDQ6VXNlcjI5MjY1Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/292656?v=4","gravatar_id":"","url":"https://api.github.com/users/lth","html_url":"https://github.com/lth","followers_url":"https://api.github.com/users/lth/followers","following_url":"https://api.github.com/users/lth/following{/other_user}","gists_url":"https://api.github.com/users/lth/gists{/gist_id}","starred_url":"https://api.github.com/users/lth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lth/subscriptions","organizations_url":"https://api.github.com/users/lth/orgs","repos_url":"https://api.github.com/users/lth/repos","events_url":"https://api.github.com/users/lth/events{/privacy}","received_events_url":"https://api.github.com/users/lth/received_events","type":"User","site_admin":false},"body":"This is implemented by extending ReadCallback with another function `MaxVisibleSequenceNumber` which returns the largest visible sequence number for the current transaction, if there is uncommitted data written to DB. Otherwise, it returns zero, indicating no uncommitted data.\r\n\r\nThere are the places where reads had to be modified.\r\n- Get and Seek/Next was just updated to seek to max(snapshot_seq, MaxVisibleSequenceNumber()) instead, and iterate until a key was visible.\r\n- Prev did not need need updates since it did not use the Seek to sequence number optimization. Assuming that locks were held when written unprepared keys, and ValidateSnapshot runs, there should only be committed keys and unprepared keys, all of which are visible. Prev will simply iterate to get the last visible key.\r\n- Reseeking to skip keys optimization was also disabled for write unprepared, since it's possible to hit the max_skip condition even while reseeking. There needs to be some way to resolve infinite looping in this case.","created_at":"2018-06-05T17:22:57Z","updated_at":"2018-06-26T21:32:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f00a7dd357b2f694fe1d2c637aa57f068ec2229","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yiwu-arbug","id":2606959,"node_id":"MDQ6VXNlcjI2MDY5NTk=","avatar_url":"https://avatars3.githubusercontent.com/u/2606959?v=4","gravatar_id":"","url":"https://api.github.com/users/yiwu-arbug","html_url":"https://github.com/yiwu-arbug","followers_url":"https://api.github.com/users/yiwu-arbug/followers","following_url":"https://api.github.com/users/yiwu-arbug/following{/other_user}","gists_url":"https://api.github.com/users/yiwu-arbug/gists{/gist_id}","starred_url":"https://api.github.com/users/yiwu-arbug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yiwu-arbug/subscriptions","organizations_url":"https://api.github.com/users/yiwu-arbug/orgs","repos_url":"https://api.github.com/users/yiwu-arbug/repos","events_url":"https://api.github.com/users/yiwu-arbug/events{/privacy}","received_events_url":"https://api.github.com/users/yiwu-arbug/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":196859108,"node_id":"MDU6TGFiZWwxOTY4NTkxMDg=","url":"https://api.github.com/repos/facebook/rocksdb/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/rocksdb/pulls/3955/commits","review_comments_url":"https://api.github.com/repos/facebook/rocksdb/pulls/3955/comments","review_comment_url":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/rocksdb/issues/3955/comments","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/e2a47b5f78bced64e2b3cba73b71a9e628fc0fc9","head":{"label":"lth:read_own_writes","ref":"read_own_writes","sha":"e2a47b5f78bced64e2b3cba73b71a9e628fc0fc9","user":{"login":"lth","id":292656,"node_id":"MDQ6VXNlcjI5MjY1Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/292656?v=4","gravatar_id":"","url":"https://api.github.com/users/lth","html_url":"https://github.com/lth","followers_url":"https://api.github.com/users/lth/followers","following_url":"https://api.github.com/users/lth/following{/other_user}","gists_url":"https://api.github.com/users/lth/gists{/gist_id}","starred_url":"https://api.github.com/users/lth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lth/subscriptions","organizations_url":"https://api.github.com/users/lth/orgs","repos_url":"https://api.github.com/users/lth/repos","events_url":"https://api.github.com/users/lth/events{/privacy}","received_events_url":"https://api.github.com/users/lth/received_events","type":"User","site_admin":false},"repo":{"id":73871961,"node_id":"MDEwOlJlcG9zaXRvcnk3Mzg3MTk2MQ==","name":"rocksdb","full_name":"lth/rocksdb","owner":{"login":"lth","id":292656,"node_id":"MDQ6VXNlcjI5MjY1Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/292656?v=4","gravatar_id":"","url":"https://api.github.com/users/lth","html_url":"https://github.com/lth","followers_url":"https://api.github.com/users/lth/followers","following_url":"https://api.github.com/users/lth/following{/other_user}","gists_url":"https://api.github.com/users/lth/gists{/gist_id}","starred_url":"https://api.github.com/users/lth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lth/subscriptions","organizations_url":"https://api.github.com/users/lth/orgs","repos_url":"https://api.github.com/users/lth/repos","events_url":"https://api.github.com/users/lth/events{/privacy}","received_events_url":"https://api.github.com/users/lth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lth/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":true,"url":"https://api.github.com/repos/lth/rocksdb","forks_url":"https://api.github.com/repos/lth/rocksdb/forks","keys_url":"https://api.github.com/repos/lth/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lth/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lth/rocksdb/teams","hooks_url":"https://api.github.com/repos/lth/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/lth/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/lth/rocksdb/events","assignees_url":"https://api.github.com/repos/lth/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/lth/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/lth/rocksdb/tags","blobs_url":"https://api.github.com/repos/lth/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lth/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lth/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/lth/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lth/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/lth/rocksdb/languages","stargazers_url":"https://api.github.com/repos/lth/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/lth/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/lth/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/lth/rocksdb/subscription","commits_url":"https://api.github.com/repos/lth/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/lth/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/lth/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/lth/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/lth/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/lth/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lth/rocksdb/merges","archive_url":"https://api.github.com/repos/lth/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lth/rocksdb/downloads","issues_url":"https://api.github.com/repos/lth/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/lth/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/lth/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/lth/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lth/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/lth/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/lth/rocksdb/deployments","created_at":"2016-11-16T01:38:32Z","updated_at":"2016-11-16T01:38:38Z","pushed_at":"2018-06-25T22:43:20Z","git_url":"git://github.com/lth/rocksdb.git","ssh_url":"git@github.com:lth/rocksdb.git","clone_url":"https://github.com/lth/rocksdb.git","svn_url":"https://github.com/lth/rocksdb","homepage":"http://rocksdb.org","size":112376,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"f5281a53a448ac4daecfd7d4ad690a5a71de6dd6","user":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":6934395,"node_id":"MDEwOlJlcG9zaXRvcnk2OTM0Mzk1","name":"rocksdb","full_name":"facebook/rocksdb","owner":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/rocksdb","description":"A library that provides an embeddable, persistent key-value store for fast storage.","fork":false,"url":"https://api.github.com/repos/facebook/rocksdb","forks_url":"https://api.github.com/repos/facebook/rocksdb/forks","keys_url":"https://api.github.com/repos/facebook/rocksdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/rocksdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/rocksdb/teams","hooks_url":"https://api.github.com/repos/facebook/rocksdb/hooks","issue_events_url":"https://api.github.com/repos/facebook/rocksdb/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/rocksdb/events","assignees_url":"https://api.github.com/repos/facebook/rocksdb/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/rocksdb/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/rocksdb/tags","blobs_url":"https://api.github.com/repos/facebook/rocksdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/rocksdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/rocksdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/rocksdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/rocksdb/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/rocksdb/languages","stargazers_url":"https://api.github.com/repos/facebook/rocksdb/stargazers","contributors_url":"https://api.github.com/repos/facebook/rocksdb/contributors","subscribers_url":"https://api.github.com/repos/facebook/rocksdb/subscribers","subscription_url":"https://api.github.com/repos/facebook/rocksdb/subscription","commits_url":"https://api.github.com/repos/facebook/rocksdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/rocksdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/rocksdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/rocksdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/rocksdb/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/rocksdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/rocksdb/merges","archive_url":"https://api.github.com/repos/facebook/rocksdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/rocksdb/downloads","issues_url":"https://api.github.com/repos/facebook/rocksdb/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/rocksdb/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/rocksdb/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/rocksdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/rocksdb/labels{/name}","releases_url":"https://api.github.com/repos/facebook/rocksdb/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/rocksdb/deployments","created_at":"2012-11-30T06:16:18Z","updated_at":"2018-06-26T19:43:37Z","pushed_at":"2018-06-26T20:40:19Z","git_url":"git://github.com/facebook/rocksdb.git","ssh_url":"git@github.com:facebook/rocksdb.git","clone_url":"https://github.com/facebook/rocksdb.git","svn_url":"https://github.com/facebook/rocksdb","homepage":"http://rocksdb.org","size":115113,"stargazers_count":10863,"watchers_count":10863,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2380,"mirror_url":null,"archived":false,"open_issues_count":223,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2380,"open_issues":223,"watchers":10863,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/3955"},"html":{"href":"https://github.com/facebook/rocksdb/pull/3955"},"issue":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/3955"},"comments":{"href":"https://api.github.com/repos/facebook/rocksdb/issues/3955/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/3955/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/rocksdb/pulls/3955/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/rocksdb/statuses/e2a47b5f78bced64e2b3cba73b71a9e628fc0fc9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"maysamyabandeh"}}