jiangphcn opened a new pull request #1709: [WIP] Support out-of-sync between db and index in mango when document is deleted URL: https://github.com/apache/couchdb/pull/1709 <!-- Thank you for your contribution! Please file this form by replacing the Markdown comments with your text. If a section needs no action - remove it. Also remember, that CouchDB uses the Review-Then-Commit (RTC) model of code collaboration. Positive feedback is represented +1 from committers and negative is a -1. The -1 also means veto, and needs to be addressed to proceed. Once there are no objections, the PR can be merged by a CouchDB committer. See: http://couchdb.apache.org/bylaws.html#decisions for more info. --> ## Overview <!-- Please give a short brief for the pull request, what problem it solves or how it makes things better. --> Under situation where the document is deleted while the mrview index for this document is not updated, the returned value from mrview is `{doc,null}`. There is no such consideration in Mango to cause case_clause error. This fix is to consider out-of-sync between documents in database and their index and not to cause 500 when the `_find` endpoint is called. ## Testing recommendations <!-- Describe how we can test your changes. Does it provides any behaviour that the end users could notice? --> ``` localhost:mytest jiangph$ curl -u foo:bar -X PUT http://localhost:15984/db01 {"ok":true} localhost:mytest jiangph$ curl -u foo:bar -X POST -H "Content-Type: application/json" http://localhost:15984/db01 -d @point2.json {"ok":true,"id":"point2","rev":"1-d942f0ce01647aa0f46518b213b5628e"} localhost:mytest jiangph$ more queryindex.json { "index": { "fields": ["type"] }, "name" : "type_json_index", "type" : "json" } localhost:mytest jiangph$ curl -u foo:bar -X POST -H "content-type: application/json" http://localhost:15984/db01/_index -d @queryindex.json {"result":"created","id":"_design/6ad4c553950364254e1c44a7a10c4fb4343097ae","name":"type_json_index"} localhost:mytest jiangph$ curl -u foo:bar -X POST -H "content-type: application/json" http://localhost:15984/db01/_find -d @query_without_stale_ok.json|jq . % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 382 0 255 100 127 7730 3850 --:--:-- --:--:-- --:--:-- 7968 { "docs": [ { "_id": "point2", "_rev": "1-d942f0ce01647aa0f46518b213b5628e", "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 0.2, 0.2 ] } } ], "bookmark": "g1AAAABDeJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYqzFeRn5pUYgWQ5YLI5QHFGkCS7W2piSWlRalYWAGwgEsE" } localhost:mytest jiangph$ more query_without_stale_ok.json { "selector": { "type": { "$gt": "0" } }, "use_index": "_design/6ad4c553950364254e1c44a7a10c4fb4343097ae" } localhost:mytest jiangph$ curl -u foo:bar -X PUT http://localhost:15984/db01/point2?rev=1-d942f0ce01647aa0f46518b213b5628e -X DELETE {"ok":true,"id":"point2","rev":"2-a1d194107753346689f5ed3b44b8bbc7"} localhost:mytest jiangph$ more query_with_stale_ok.json { "selector": { "type": { "$gt": "0" } }, "stale" : "ok", "use_index": "_design/6ad4c553950364254e1c44a7a10c4fb4343097ae" } localhost:mytest jiangph$ curl -u foo:bar -X POST -H "content-type: application/json" http://localhost:15984/db01/_find -d @query_with_stale_ok.json|jq . % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 208 100 66 100 142 6329 13617 --:--:-- --:--:-- --:--:-- 14200 { "error": "unknown_error", "reason": "case_clause", "ref": 2113297017 } ``` ## Related Issues or Pull Requests <!-- If your changes affects multiple components in different repositories please put links to those issues or pull requests here. --> ## Checklist - [X] Code is written and works correctly; - [ ] Changes are covered by tests; - working on - [ ] 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
