AlexanderKaraberov opened a new pull request #1162: Fix: Various small fixes URL: https://github.com/apache/couchdb/pull/1162 ## Overview This PR contains small fixes for some minor flaws in CouchDB which affected me during the development of the new functionality. 1. Proper error handling of `file:open/2` calls in `couch_file.erl`. According to Erlang [file module docs](http://erlang.org/doc/man/file.html#open-2) `open` returns `{error, Reason}` in case of failure but in the `couch_file:sync` and `init` functions there are no such checks. Consequently when I received `{error, emfile}` kind of error, process crashed with `badmatch` instead of something more specific. 2. When you implement `validate_doc_update` as an Erlang function it doesn't work because of a missing case clause, namely: when `couch_query_servers:try_compile()` calls `proc_prompt_raw()` which in turn calls `erlang:apply()` for a native function the return value of it is an atom `ok` or `true` but in case of JS function we have response code `1`. I added a more general check in the `validate_doc_update` and now it works for Erlang functions as well. This was crucial in our case because JS functions are much slower and in our production system we are going to use validation functions implemented in Erlang. 3. When we tested CouchDB 2.1 with our production DB which contains gazillion of different document `couch_mrview_util:reduced_external_size()` crashed with `badmatch` randomly because of some broken docs in our DB. This is because `full_reduce` returned response in the format `{_, _}` and not `{ok, {_, _}}` as was expected there. After this crash CouchDB was broken completely for me. In order to fix this I added an additional "match-anything" `case` clause, because even if we had something really broken in our DB, CouchDB still should handle this more gracefully I believe. ## Testing recommendations These fixes were tested and they resolved all the problems i reported. ## Checklist - [ ] Code is written and works correctly; - [ ] Changes are covered by tests; - [ ] Documentation reflects the changes;
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
