{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/comments/136681174","pull_request_review_id":60259242,"id":136681174,"diff_hunk":"@@ -1354,4 +1368,82 @@ struct Rdb_index_info {\n   uint64 m_ttl_duration = 0;\n };\n \n+/*\n+  @brief\n+  Merge Operator for the auto_increment value in the system_cf\n+\n+  @detail\n+  This class implements the rocksdb Merge Operator for auto_increment values\n+  that are stored to the data dictionary every transaction.\n+\n+  The actual Merge function is triggered on compaction, memtable flushes, or\n+  when get() is called on the same key.\n+\n+ */\n+class Rdb_merge_operator : public rocksdb::AssociativeMergeOperator {\n+ public:\n+  /*\n+    Updates the new value associated with a key to be the maximum of the\n+    passed in value and the existing value.\n+\n+    @param[IN]  key\n+    @param[IN]  existing_value  existing value for a key; nullptr if nonexistent\n+    key\n+    @param[IN]  value\n+    @param[OUT] new_value       new value after Merge\n+    @param[IN]  logger\n+  */\n+  bool Merge(const rocksdb::Slice &key, const rocksdb::Slice *existing_value,\n+             const rocksdb::Slice &value, std::string *new_value,\n+             rocksdb::Logger *logger) const override {\n+\n+    /* value corruption check and version check */\n+    DBUG_ASSERT(new_value != nullptr);\n+    DBUG_ASSERT(FindVersion(value) == Rdb_key_def::AUTO_INCREMENT_VERSION);\n+\n+    std::string merged_value;\n+\n+    /* if no existing vaue, then persist the passed in value */\n+    if (existing_value == nullptr) {\n+      merged_value = Serialize(Deserialize(value));\n+    } else {\n+      merged_value =\n+          Serialize(std::max(Deserialize(value), Deserialize(*existing_value)));\n+    }\n+\n+    *new_value = merged_value;\n+    return true;\n+  }\n+\n+  virtual const char *Name() const override {\n+    return \"system_cf_auto_increment_merge\";\n+  }\n+\n+ private:\n+  std::string Serialize(const uint64_t data) const {","path":"storage/rocksdb/rdb_datadic.h","position":121,"original_position":121,"commit_id":"150f68dea9ca0ccf2161a0e0fcb78bf5127ccc63","original_commit_id":"150f68dea9ca0ccf2161a0e0fcb78bf5127ccc63","user":{"login":"hermanlee","id":6656176,"avatar_url":"https://avatars3.githubusercontent.com/u/6656176?v=4","gravatar_id":"","url":"https://api.github.com/users/hermanlee","html_url":"https://github.com/hermanlee","followers_url":"https://api.github.com/users/hermanlee/followers","following_url":"https://api.github.com/users/hermanlee/following{/other_user}","gists_url":"https://api.github.com/users/hermanlee/gists{/gist_id}","starred_url":"https://api.github.com/users/hermanlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hermanlee/subscriptions","organizations_url":"https://api.github.com/users/hermanlee/orgs","repos_url":"https://api.github.com/users/hermanlee/repos","events_url":"https://api.github.com/users/hermanlee/events{/privacy}","received_events_url":"https://api.github.com/users/hermanlee/received_events","type":"User","site_admin":false},"body":"I think Serialize can be slightly optimized so that we minimize copies. The value is being copied from the value_buf memory to the new_value string. Can the value be assembled directly in *new_value instead of going through the value_buf array?","created_at":"2017-09-01T23:31:51Z","updated_at":"2017-09-01T23:53:55Z","html_url":"https://github.com/facebook/mysql-5.6/pull/693#discussion_r136681174","pull_request_url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/comments/136681174"},"html":{"href":"https://github.com/facebook/mysql-5.6/pull/693#discussion_r136681174"},"pull_request":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693","id":137767820,"html_url":"https://github.com/facebook/mysql-5.6/pull/693","diff_url":"https://github.com/facebook/mysql-5.6/pull/693.diff","patch_url":"https://github.com/facebook/mysql-5.6/pull/693.patch","issue_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/693","number":693,"state":"open","locked":false,"title":"crash safety for auto increment values","user":{"login":"armishra","id":7940079,"avatar_url":"https://avatars3.githubusercontent.com/u/7940079?v=4","gravatar_id":"","url":"https://api.github.com/users/armishra","html_url":"https://github.com/armishra","followers_url":"https://api.github.com/users/armishra/followers","following_url":"https://api.github.com/users/armishra/following{/other_user}","gists_url":"https://api.github.com/users/armishra/gists{/gist_id}","starred_url":"https://api.github.com/users/armishra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armishra/subscriptions","organizations_url":"https://api.github.com/users/armishra/orgs","repos_url":"https://api.github.com/users/armishra/repos","events_url":"https://api.github.com/users/armishra/events{/privacy}","received_events_url":"https://api.github.com/users/armishra/received_events","type":"User","site_admin":false},"body":"Changes:\r\n* Auto increment value added as type in system column family\r\n* Added maximizing merge operator\r\n* Merge called on write path; get called on read path\r\n* closes #468 ","created_at":"2017-08-25T22:26:13Z","updated_at":"2017-09-01T23:53:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"445f4f491b2bd16668aaf1a9941c4f9ca0f8aab5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693/commits","review_comments_url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693/comments","review_comment_url":"https://api.github.com/repos/facebook/mysql-5.6/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/693/comments","statuses_url":"https://api.github.com/repos/facebook/mysql-5.6/statuses/150f68dea9ca0ccf2161a0e0fcb78bf5127ccc63","head":{"label":"armishra:autoinc_values","ref":"autoinc_values","sha":"150f68dea9ca0ccf2161a0e0fcb78bf5127ccc63","user":{"login":"armishra","id":7940079,"avatar_url":"https://avatars3.githubusercontent.com/u/7940079?v=4","gravatar_id":"","url":"https://api.github.com/users/armishra","html_url":"https://github.com/armishra","followers_url":"https://api.github.com/users/armishra/followers","following_url":"https://api.github.com/users/armishra/following{/other_user}","gists_url":"https://api.github.com/users/armishra/gists{/gist_id}","starred_url":"https://api.github.com/users/armishra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armishra/subscriptions","organizations_url":"https://api.github.com/users/armishra/orgs","repos_url":"https://api.github.com/users/armishra/repos","events_url":"https://api.github.com/users/armishra/events{/privacy}","received_events_url":"https://api.github.com/users/armishra/received_events","type":"User","site_admin":false},"repo":{"id":95701409,"name":"mysql-5.6","full_name":"armishra/mysql-5.6","owner":{"login":"armishra","id":7940079,"avatar_url":"https://avatars3.githubusercontent.com/u/7940079?v=4","gravatar_id":"","url":"https://api.github.com/users/armishra","html_url":"https://github.com/armishra","followers_url":"https://api.github.com/users/armishra/followers","following_url":"https://api.github.com/users/armishra/following{/other_user}","gists_url":"https://api.github.com/users/armishra/gists{/gist_id}","starred_url":"https://api.github.com/users/armishra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armishra/subscriptions","organizations_url":"https://api.github.com/users/armishra/orgs","repos_url":"https://api.github.com/users/armishra/repos","events_url":"https://api.github.com/users/armishra/events{/privacy}","received_events_url":"https://api.github.com/users/armishra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/armishra/mysql-5.6","description":"Facebook's branch of the Oracle MySQL v5.6 database. This includes MyRocks.","fork":true,"url":"https://api.github.com/repos/armishra/mysql-5.6","forks_url":"https://api.github.com/repos/armishra/mysql-5.6/forks","keys_url":"https://api.github.com/repos/armishra/mysql-5.6/keys{/key_id}","collaborators_url":"https://api.github.com/repos/armishra/mysql-5.6/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/armishra/mysql-5.6/teams","hooks_url":"https://api.github.com/repos/armishra/mysql-5.6/hooks","issue_events_url":"https://api.github.com/repos/armishra/mysql-5.6/issues/events{/number}","events_url":"https://api.github.com/repos/armishra/mysql-5.6/events","assignees_url":"https://api.github.com/repos/armishra/mysql-5.6/assignees{/user}","branches_url":"https://api.github.com/repos/armishra/mysql-5.6/branches{/branch}","tags_url":"https://api.github.com/repos/armishra/mysql-5.6/tags","blobs_url":"https://api.github.com/repos/armishra/mysql-5.6/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/armishra/mysql-5.6/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/armishra/mysql-5.6/git/refs{/sha}","trees_url":"https://api.github.com/repos/armishra/mysql-5.6/git/trees{/sha}","statuses_url":"https://api.github.com/repos/armishra/mysql-5.6/statuses/{sha}","languages_url":"https://api.github.com/repos/armishra/mysql-5.6/languages","stargazers_url":"https://api.github.com/repos/armishra/mysql-5.6/stargazers","contributors_url":"https://api.github.com/repos/armishra/mysql-5.6/contributors","subscribers_url":"https://api.github.com/repos/armishra/mysql-5.6/subscribers","subscription_url":"https://api.github.com/repos/armishra/mysql-5.6/subscription","commits_url":"https://api.github.com/repos/armishra/mysql-5.6/commits{/sha}","git_commits_url":"https://api.github.com/repos/armishra/mysql-5.6/git/commits{/sha}","comments_url":"https://api.github.com/repos/armishra/mysql-5.6/comments{/number}","issue_comment_url":"https://api.github.com/repos/armishra/mysql-5.6/issues/comments{/number}","contents_url":"https://api.github.com/repos/armishra/mysql-5.6/contents/{+path}","compare_url":"https://api.github.com/repos/armishra/mysql-5.6/compare/{base}...{head}","merges_url":"https://api.github.com/repos/armishra/mysql-5.6/merges","archive_url":"https://api.github.com/repos/armishra/mysql-5.6/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/armishra/mysql-5.6/downloads","issues_url":"https://api.github.com/repos/armishra/mysql-5.6/issues{/number}","pulls_url":"https://api.github.com/repos/armishra/mysql-5.6/pulls{/number}","milestones_url":"https://api.github.com/repos/armishra/mysql-5.6/milestones{/number}","notifications_url":"https://api.github.com/repos/armishra/mysql-5.6/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/armishra/mysql-5.6/labels{/name}","releases_url":"https://api.github.com/repos/armishra/mysql-5.6/releases{/id}","deployments_url":"https://api.github.com/repos/armishra/mysql-5.6/deployments","created_at":"2017-06-28T18:51:49Z","updated_at":"2017-06-28T18:52:52Z","pushed_at":"2017-09-01T23:03:39Z","git_url":"git://github.com/armishra/mysql-5.6.git","ssh_url":"git@github.com:armishra/mysql-5.6.git","clone_url":"https://github.com/armishra/mysql-5.6.git","svn_url":"https://github.com/armishra/mysql-5.6","homepage":"https://github.com/facebook/mysql-5.6","size":366683,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"fb-mysql-5.6.35"}},"base":{"label":"facebook:fb-mysql-5.6.35","ref":"fb-mysql-5.6.35","sha":"a19a389a2bf79cf76bc063bc00985978228e71a6","user":{"login":"facebook","id":69631,"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":9454675,"name":"mysql-5.6","full_name":"facebook/mysql-5.6","owner":{"login":"facebook","id":69631,"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/mysql-5.6","description":"Facebook's branch of the Oracle MySQL v5.6 database. This includes MyRocks.","fork":false,"url":"https://api.github.com/repos/facebook/mysql-5.6","forks_url":"https://api.github.com/repos/facebook/mysql-5.6/forks","keys_url":"https://api.github.com/repos/facebook/mysql-5.6/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/mysql-5.6/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/mysql-5.6/teams","hooks_url":"https://api.github.com/repos/facebook/mysql-5.6/hooks","issue_events_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/mysql-5.6/events","assignees_url":"https://api.github.com/repos/facebook/mysql-5.6/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/mysql-5.6/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/mysql-5.6/tags","blobs_url":"https://api.github.com/repos/facebook/mysql-5.6/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/mysql-5.6/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/mysql-5.6/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/mysql-5.6/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/mysql-5.6/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/mysql-5.6/languages","stargazers_url":"https://api.github.com/repos/facebook/mysql-5.6/stargazers","contributors_url":"https://api.github.com/repos/facebook/mysql-5.6/contributors","subscribers_url":"https://api.github.com/repos/facebook/mysql-5.6/subscribers","subscription_url":"https://api.github.com/repos/facebook/mysql-5.6/subscription","commits_url":"https://api.github.com/repos/facebook/mysql-5.6/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/mysql-5.6/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/mysql-5.6/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/mysql-5.6/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/mysql-5.6/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/mysql-5.6/merges","archive_url":"https://api.github.com/repos/facebook/mysql-5.6/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/mysql-5.6/downloads","issues_url":"https://api.github.com/repos/facebook/mysql-5.6/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/mysql-5.6/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/mysql-5.6/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/mysql-5.6/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/mysql-5.6/labels{/name}","releases_url":"https://api.github.com/repos/facebook/mysql-5.6/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/mysql-5.6/deployments","created_at":"2013-04-15T17:54:43Z","updated_at":"2017-08-31T19:18:47Z","pushed_at":"2017-09-01T23:10:18Z","git_url":"git://github.com/facebook/mysql-5.6.git","ssh_url":"git@github.com:facebook/mysql-5.6.git","clone_url":"https://github.com/facebook/mysql-5.6.git","svn_url":"https://github.com/facebook/mysql-5.6","homepage":"https://github.com/facebook/mysql-5.6","size":414949,"stargazers_count":1016,"watchers_count":1016,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":362,"mirror_url":null,"open_issues_count":100,"forks":362,"open_issues":100,"watchers":1016,"default_branch":"fb-mysql-5.6.35"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693"},"html":{"href":"https://github.com/facebook/mysql-5.6/pull/693"},"issue":{"href":"https://api.github.com/repos/facebook/mysql-5.6/issues/693"},"comments":{"href":"https://api.github.com/repos/facebook/mysql-5.6/issues/693/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/mysql-5.6/pulls/693/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/mysql-5.6/statuses/150f68dea9ca0ccf2161a0e0fcb78bf5127ccc63"}},"author_association":"NONE"}}
{"actor":{"display_login":"hermanlee"}}