New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix _local_docs end-point #526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly +1 but I'm not seeing the need for fabric_view_local_docs. There does seem to be a few places that'd have to get ironed out but that seems like a lot of code duplication for the few places I spotted skimming through. Can you elaborate which bits made it hard to include as part of fabric_view_all_docs?
@davisp sorry, I totally forgot about this PR! I tried modifying
I agree there are lot of repetition, but it felt more cleaner to separate this functionality. If you think it's excessive I can amend |
63ac70c
to
3e1cd1b
Compare
@davisp So I went ahead, reverted the new module and modified |
+1 Squerge away! |
3e1cd1b
to
a29df57
Compare
Squerged. But also see a badarith exception when testing _local_docs endpoint by hand: did a few:
Then see the exception with:
Logs show:
Will have to track this down |
Huh. guessing that's in the totals or offset handling. |
It looks like in fabic rpc view_cb/2 meta comes back with |
@davisp Take another look when you get a chance. The reason for badarith was that |
+1 Good catch! |
This is a second attempt to fix _local_docs end-point. The previous one didn't work on big enough btree_local, because local btree doesn't have reduction fun, so reuse of couch_db_updater:btree_by_id_reduce/2 was crashing on a bad match as soon as btree_local was getting kp_node. Also using full fold to calculate total_rows value turned out to be resource expensive when a database have significant number of local documents. This fix avoids calculating of total_rows and offset instead always setting them to null and also setting to null update_seq when requested, since it doesn't have meaning in context of local documents. A fabric module fabric_view_all_docs.erl was copied and modified as fabric_view_local_docs.erl, because re-using it for processing of both types of the documents was getting rather convoluted. Jira: COUCHDB-3337
b1d2b42
to
1b97415
Compare
Overview
This is a second attempt to fix
_local_docs
end-point. The previous one didn't work on big enough btree_local, because local btree doesn't have reduction fun, so reuse ofcouch_db_updater:btree_by_id_reduce/2
was crashing on a bad match as soon as btree_local was getting kp_node. Also using full fold to calculatetotal_rows
value turned out to be resource expensive when a database have significant number of local documents.This fix avoids calculating of
total_rows
andoffset
instead always setting them tonull
and also setting tonull
update_seq
when requested, since it doesn't have meaning in context of local documents.A fabric module
fabric_view_all_docs.erl
was copied and modified asfabric_view_local_docs.erl
, because re-using it for processing of both types of the documents was getting rather convoluted.Testing recommendations
Unit tests for all invoked dependencies could be run as
make eunit apps=chttpd,fabric,couch_mrview
. There are updated suitecouch_mrview_local_docs_tests
incouch_mrview
.From HTTP perspective end-point
/{db}/_local_docs
supports all the query parameters of/{db}/_all_docs
with the difference thatoffset
, 'total_rowsand
update_seqalways return
null`.JIRA issue number
COUCHDB-3337
Checklist