Skip to content
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

ForestDB update_seq on view query less than db's update_seq #1379

Closed
sethrosetter opened this issue Jul 21, 2016 · 1 comment
Closed

ForestDB update_seq on view query less than db's update_seq #1379

sethrosetter opened this issue Jul 21, 2016 · 1 comment

Comments

@sethrosetter
Copy link
Contributor


  • Version: 1.3.0-49
  • Client OS: Mac OSX
  • Server: N/A

They query seems to be skipping the design doc?

To reproduce:

  • Launch 1.3.0-49 LiteServ
  • Create a db
  • Add 10 docs (not sure if number has any effect)
  • Add a view
http POST http://localhost:59851/db

with body

{"_id":"_design/test","views":{"basic":{"map":"function(doc) { emit(doc._id, doc.foo) }"}}}
  • Query the view
http://localhost:59851/cbl_views/_design/test/_view/basic?update_seq=true

Expected:

{"update_seq":11,"rows":[{"key":"cbl_views_0","value":"bar","id":"cbl_views_0"},{"key":"cbl_views_1","value":"bar","id":"cbl_views_1"},{"key":"cbl_views_2","value":"bar","id":"cbl_views_2"},{"key":"cbl_views_3","value":"bar","id":"cbl_views_3"},{"key":"cbl_views_4","value":"bar","id":"cbl_views_4"},{"key":"cbl_views_5","value":"bar","id":"cbl_views_5"},{"key":"cbl_views_6","value":"bar","id":"cbl_views_6"},{"key":"cbl_views_7","value":"bar","id":"cbl_views_7"},{"key":"cbl_views_8","value":"bar","id":"cbl_views_8"},{"key":"cbl_views_9","value":"bar","id":"cbl_views_9"}],"offset":0,"total_rows":10}

Actual:

{"update_seq":10,"rows":[{"key":"cbl_views_0","value":"bar","id":"cbl_views_0"},{"key":"cbl_views_1","value":"bar","id":"cbl_views_1"},{"key":"cbl_views_2","value":"bar","id":"cbl_views_2"},{"key":"cbl_views_3","value":"bar","id":"cbl_views_3"},{"key":"cbl_views_4","value":"bar","id":"cbl_views_4"},{"key":"cbl_views_5","value":"bar","id":"cbl_views_5"},{"key":"cbl_views_6","value":"bar","id":"cbl_views_6"},{"key":"cbl_views_7","value":"bar","id":"cbl_views_7"},{"key":"cbl_views_8","value":"bar","id":"cbl_views_8"},{"key":"cbl_views_9","value":"bar","id":"cbl_views_9"}],"offset":0,"total_rows":10}

Doing a GET on the /db, I see an update_seq of 11

@snej
Copy link
Contributor

snej commented Jul 21, 2016

This may be a performance problem because if the view's update_seq (lastSequenceIndexed) is less than the db's lastSequence, it will be indexed. So this would lead to a no-op index operation on every query.

From a quick look into CBForest, this seems to be due to a bug in the MapReduceIndexWriter class. It should update the view's lastSequenceIndexed to the last sequence of the db enumeration, not just the last sequence that the view actually ran through the map function.

@snej snej added this to the 1.4 milestone Jul 21, 2016
@snej snej added the hotfix label Aug 9, 2016
@pasin pasin modified the milestones: 1.3.1, 1.4 Aug 11, 2016
snej added a commit to couchbaselabs/cbforest that referenced this issue Aug 16, 2016
Allows caller to specify the value, in case it's greater than any
sequence that was passed to the indexer (i.e. a doc was skipped.)

For couchbase/couchbase-lite-ios#1379
snej added a commit that referenced this issue Aug 16, 2016
The fix is in CBForest; I added a unit test here.

Fixes #1379
@snej snej closed this as completed Aug 16, 2016
pasin pushed a commit that referenced this issue Aug 17, 2016
The fix is in CBForest; I added a unit test here.

Fixes #1379
@pasin pasin added the bug label Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants