{"action":"created","issue":{"url":"https://api.github.com/repos/apache/couchdb/issues/496","repository_url":"https://api.github.com/repos/apache/couchdb","labels_url":"https://api.github.com/repos/apache/couchdb/issues/496/labels{/name}","comments_url":"https://api.github.com/repos/apache/couchdb/issues/496/comments","events_url":"https://api.github.com/repos/apache/couchdb/issues/496/events","html_url":"https://github.com/apache/couchdb/pull/496","id":224814014,"number":496,"title":"Couchdb 3287 pluggable storage engines","user":{"login":"davisp","id":19929,"avatar_url":"https://avatars0.githubusercontent.com/u/19929?v=3","gravatar_id":"","url":"https://api.github.com/users/davisp","html_url":"https://github.com/davisp","followers_url":"https://api.github.com/users/davisp/followers","following_url":"https://api.github.com/users/davisp/following{/other_user}","gists_url":"https://api.github.com/users/davisp/gists{/gist_id}","starred_url":"https://api.github.com/users/davisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davisp/subscriptions","organizations_url":"https://api.github.com/users/davisp/orgs","repos_url":"https://api.github.com/users/davisp/repos","events_url":"https://api.github.com/users/davisp/events{/privacy}","received_events_url":"https://api.github.com/users/davisp/received_events","type":"User","site_admin":false},"labels":[{"id":594289841,"url":"https://api.github.com/repos/apache/couchdb/labels/dbcore","name":"dbcore","color":"BFD4F2","default":false},{"id":594291312,"url":"https://api.github.com/repos/apache/couchdb/labels/feature","name":"feature","color":"91CA55","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2017-04-27T15:02:33Z","updated_at":"2017-05-30T18:47:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/couchdb/pulls/496","html_url":"https://github.com/apache/couchdb/pull/496","diff_url":"https://github.com/apache/couchdb/pull/496.diff","patch_url":"https://github.com/apache/couchdb/pull/496.patch"},"body":"## Overview\r\n\r\nPluggable Storage Engines (Oh my!)\r\n\r\nI've finally covered enough bases to start asking for reviews on the pluggable storage engine work. I know that this is a fairly large change so I don't expect this to actually be merged for a number of weeks. So everyone that wants to review any part of this feel free to take your time and be thorough.\r\n\r\nI highly suggest reviewing this work a commit at a time as there are a few fairly large commits. A few signposts for the intrepid reader:\r\n\r\n1. Add couch_db_engine module\r\n\r\nThis is a single file addition that just introduces the new pluggable storage engine API. Its fairly thoroughly documented and hopefully makes sense as to the level that this API is geared at. When I initially started this work I spent a lot of time trying to figure out what level of the API would be the best place to separate the storage engine from database logic. Go too high and every engine is reimplementing core bits of logic. Go to low and there's not enough room for interesting changes to the actual storage engine algorithms. I believe this is a happy middle ground that gives storage engines the room to play and invent alternative implementations while also not requiring an extremely large amount of reimplementation for various bits of behavior that are required.\r\n\r\n2. Add legacy storage engine implementation\r\n\r\nThis commit is quite big but its important to note that all its doing is copying the existing parts of couch_db.erl and couch_db_updater.erl and moving them to a new set of modules named couch_bt_engine_*.erl. Nothing uses this code yet. I have this in its own commit since its fairly large. However, if you mostly just want to check it you should be able to see that the implementation is just pulled from existing functions. The behavior of this engine is identical to the \"pre-PSE\" engine because that's what it is. Its just been reformatted a bit and had its name changed.\r\n\r\nAlso, I've kept this and couch_db_engine.erl in the main couch application since we'll always want to have at least one storage engine. Though this was pre-monorepo when adding another git repo to our builds seemed awfully heavy. Now that we're monorepo we're just creating a folder which is easy enough. For any reviewer I'd like to have them keep this in mind as one thing I expect to discuss is whether we should split this out into its own application.\r\n\r\n3. Implement pluggable storage engines\r\n\r\nThis is the doozy. There are two main bits of work going on in this commit. First, the removal of all the code that was in the previous commit and second, the addition of all the code to have couch_db and couch_db_updater start using the couch_db_engine APIs. Its long and big but really if you take your time there's nothing magical going on here. For the core bits to study I'd recommend spending some extra time on couch_server to see how engines are configured and chosen at runtime.\r\n\r\n4. Add storage engine test suite\r\n\r\nThis is a fairly complete test suite for the entire storage engine API. I don't remember what coverage of couch_bt_engine was but I know its fairly high. The useful bit about this is when devs are creating new storage engines they can just pull this in with a single eunit case to test their implementations. I'll show a few examples on this below.\r\n\r\n5. Ensure deterministic revisions for attachments\r\n\r\nI may end up squashing this into the implementation commit. This was a fix while I was developing PSE that I ended up refixing after the fact slightly differently. The original goal was to make sure everything compiled and all tests suites ran for each commit. I think I've just convinced myself to squash this. So if its missing its because I did that and then forgot to edit this description to remove this paragraph...\r\n\r\n## Testing recommendations\r\n\r\n$ make check\r\n\r\n## JIRA issue number\r\n\r\nhttps://issues.apache.org/jira/browse/COUCHDB-3287\r\n\r\n## Related Pull Requests\r\n\r\nThis PR is based on the previous mixed cluster upgrade PR. However when merge time comes around we'll merge #495 first and then this will be merged into master so that users can deploy the first changes before these changes. (Uptime is fun time).\r\n\r\nhttps://github.com/apache/couchdb/pull/495\r\n\r\n## Checklist\r\n\r\n- [x] Code is written and works correctly;\r\n- [x] Changes are covered by tests;\r\n- [ ] Documentation reflects the changes;\r\n\r\n(We should probably remove the todo item for updating rebar.config since we're doing almost all work on the monorepo now)\r\n"},"comment":{"url":"https://api.github.com/repos/apache/couchdb/issues/comments/304971908","html_url":"https://github.com/apache/couchdb/pull/496#issuecomment-304971908","issue_url":"https://api.github.com/repos/apache/couchdb/issues/496","id":304971908,"user":{"login":"davisp","id":19929,"avatar_url":"https://avatars0.githubusercontent.com/u/19929?v=3","gravatar_id":"","url":"https://api.github.com/users/davisp","html_url":"https://github.com/davisp","followers_url":"https://api.github.com/users/davisp/followers","following_url":"https://api.github.com/users/davisp/following{/other_user}","gists_url":"https://api.github.com/users/davisp/gists{/gist_id}","starred_url":"https://api.github.com/users/davisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davisp/subscriptions","organizations_url":"https://api.github.com/users/davisp/orgs","repos_url":"https://api.github.com/users/davisp/repos","events_url":"https://api.github.com/users/davisp/events{/privacy}","received_events_url":"https://api.github.com/users/davisp/received_events","type":"User","site_admin":false},"created_at":"2017-05-30T18:47:30Z","updated_at":"2017-05-30T18:47:30Z","body":"@tonysun83 @eiri I've fixed up the input validation for invalid engines and added a log statement for when the default engine isn't set to an extension. Wanna take the new bits for a spin?"}}
{"actor":{"display_login":"davisp"}}