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

Mango Indexes on FoundationDB #2585

Merged
merged 18 commits into from
Apr 6, 2020
Merged

Conversation

garrensmith
Copy link
Member

Overview

Updates Mango view indexes to work on top of FoundationDB.
Mango view indexes are replaced by Mango json indexes.

Mango json indexes are updated in the same transaction that a document
is updated. A background indexer will build a new index and get it up
to date.

Thanks to @jaydoane for contributing code to this.

Testing recommendations

All mango tests should pass. Create mango indexes and make sure the results returned are expected

Related Issues or Pull Requests

Checklist

@davisp
Copy link
Member

davisp commented Feb 25, 2020

Overall, this looks to be a really good first step getting mango updated for fdb. I've only had a few hours to spend reviewing this today and it'll take me a day or two to let it all soak in but there's a few things I'd like jot down while they're paged in.

My first major impression is that there's an awkward cross over between couch_views and the new mango fdb modules. AFAICT, this is mostly due to the way that mango jobs stop indexing once they reach the version stamp where they were created along with being able to just update a single document. It would seem to me that if we just added these two bits as optional features of couch_views it would slim down this entire PR considerably. It might also be worth getting the basic async-index-update mango working before jumping to having the single transaction updates. It feels as there's some criss cross between the changes for a new fdb combined with changes for the incremental updates that aren't quite gelled together.

The changes to fabric2_fdb need to be redone. There shouldn't be a single mention of mango in that module. There are a number of features that will want to know about db changes that should all share a single interface.

For the PR itself, this should definitely be split up into smaller chunks of logic that are described individually. The last one or two might be a fairly large commit but there's a lot of churn that could be processed more efficiently stepping through individual commits. If you need help on how to break down a large commit I'd happy to pair with you to show you the basic git commands for handling that.

I really like your build status concept. I'd like to extend that for views as well to show initial build vs incremental update that would be useful for operators. Moving that status under a prefix would also give us the necessary structure for efficient view cleanups as well which I'm looking at working on next.

@garrensmith
Copy link
Member Author

@davisp thanks for reviewing. Sorry I made a real mess with my commits and cheated a little and squashed into one. I've broken them up into a few commits. Its not perfect but breaks the context up a bit more and should make it easier to review.

@garrensmith garrensmith force-pushed the fdb-mango-indexes branch 2 times, most recently from 20af02b to a3c6379 Compare March 2, 2020 15:06
@tonysun83
Copy link
Contributor

tonysun83 commented Mar 3, 2020

Just started going over this PR. I noticed we're going through the EPI route for each doc update. Looks like Ken may be utilizing the EPI route as well.. Will it make more sense to plug in the hook into Ken later on as part of Ken's consolidated auto indexing scheme?

I see work currently being done by @nickva in this regard: b16c4a1

@davisp
Copy link
Member

davisp commented Mar 3, 2020

@tonysun83 Yeah, both of these are definitely touching on related bits triggering view work from the update loop. Whichever lands second will fixup things so there's a unified interface there.

@iilyak
Copy link
Contributor

iilyak commented Mar 4, 2020

Just started going over this PR. I noticed we're going through the EPI route for each doc update. Looks like Ken may be utilizing the EPI route as well.. Will it make more sense to plug in the hook into Ken later on as part of Ken's consolidated auto indexing scheme?

From EPI point of view it has a mode where it calls plugins one by one. So it is possible to have multiple plugins on the same extension hook.

@garrensmith garrensmith force-pushed the fdb-mango-indexes branch 4 times, most recently from 1acee3a to 7f295f3 Compare March 9, 2020 17:18
@garrensmith garrensmith force-pushed the fdb-mango-indexes branch 4 times, most recently from 0f6837d to 1bfd0db Compare March 11, 2020 11:21
@garrensmith
Copy link
Member Author

Quick update on this. I've cleaned up the commits and all python and eunit tests are passing. Also all pouchdb-find tests are passing.

@davisp
Copy link
Member

davisp commented Mar 11, 2020

Can you update make check-fdb to include the commadn to run the mango python tests?

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. Most of my comments were style related. I think changing the build_to_vs field is probably the biggest change in behavior and that shouldn't be a major change. We also need to get the values passed to couch_eval:map_docs hammered out. It looks as though there's a change to using ErlJSON docs when its expecting #doc{} records in some places still.

src/chttpd/src/chttpd_db.erl Show resolved Hide resolved
src/chttpd/src/chttpd_db.erl Show resolved Hide resolved
src/couch/src/couch_proc_manager.erl Outdated Show resolved Hide resolved
src/couch_views/src/couch_views.erl Outdated Show resolved Hide resolved
src/couch_views/src/couch_views_fdb.erl Outdated Show resolved Hide resolved
src/mango/test/eunit/mango_indexer_test.erl Outdated Show resolved Hide resolved
src/mango/test/eunit/mango_indexer_test.erl Outdated Show resolved Hide resolved
src/mango/test/mango.py Show resolved Hide resolved
src/mango/test/mango.py Outdated Show resolved Hide resolved
src/mango/test/user_docs.py Show resolved Hide resolved
Copy link
Member Author

@garrensmith garrensmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review Paul. I've left some comments to answer some of your questions.

src/chttpd/src/chttpd_db.erl Show resolved Hide resolved
src/chttpd/src/chttpd_db.erl Show resolved Hide resolved
src/couch_views/src/couch_views.erl Outdated Show resolved Hide resolved
src/couch_views/src/couch_views_fdb.erl Outdated Show resolved Hide resolved
src/fabric/src/fabric2_fdb.erl Show resolved Hide resolved
src/mango/test/01-index-crud-test.py Outdated Show resolved Hide resolved
src/mango/test/19-find-conflicts.py Outdated Show resolved Hide resolved
src/mango/test/20-no-timeout-test.py Outdated Show resolved Hide resolved
src/mango/test/user_docs.py Show resolved Hide resolved
src/mango/test/12-use-correct-index-test.py Show resolved Hide resolved
@garrensmith garrensmith force-pushed the fdb-mango-indexes branch 2 times, most recently from 4d5b4eb to e072b88 Compare March 19, 2020 15:56
Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got mixed up in my review so flushing the couple notes I wrote so I can refresh the conversation tab.

src/couch_views/src/couch_views_indexer.erl Outdated Show resolved Hide resolved
src/couch_views/test/couch_views_trace_index_test.erl Outdated Show resolved Hide resolved
src/mango/test/12-use-correct-index-test.py Show resolved Hide resolved
Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good! Just a few things left to fix up.

src/couch_views/src/couch_views_jobs.erl Outdated Show resolved Hide resolved
This creates a versionstamp for when an indexed was created
and build status for indexes. if the index has a creation_vs, then
couch_views_indexer will built the index to this creation versionstamp.
This adds the ability for couch_views to index an index in the docs
update transaction. This only happens if a design doc has the
field <<"interactive">> = true.
Adds a max value to use for encoding. This is useful when getting the
max range when encoding startkey/endkeys.
Removes the view callback that was performed on the nodes before
sending the results back to the co-ordinator.
Removing quorum stats since they are not relevant with FDB.
This uses couch_views_updater to create mango indexes in the doc update
along with the couch_views_indexer to update the indexes in the
background up to the creation versionstamp.
Copy link
Member Author

@garrensmith garrensmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @davisp I've rebased with the latest couch_rate work and addressed all your comments.

src/couch_views/src/couch_views_indexer.erl Outdated Show resolved Hide resolved
src/couch_views/src/couch_views_jobs.erl Outdated Show resolved Hide resolved
src/couch_views/test/couch_views_trace_index_test.erl Outdated Show resolved Hide resolved
Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very simple last change:

diff --git a/Makefile b/Makefile
index 1326d40f7..cc33c61d8 100644
--- a/Makefile
+++ b/Makefile
@@ -350,7 +350,7 @@ mango-test: devclean all
 	@cd src/mango && \
 		python3 -m venv .venv && \
 		.venv/bin/python3 -m pip install -r requirements.txt
-	@cd src/mango && ../../dev/run "$(TEST_OPTS)" -n 1 --admin=adm:pass '.venv/bin/python3 -m nose --with-xunit'
+	@cd src/mango && ../../dev/run "$(TEST_OPTS)" -n 1 --admin=adm:pass --erlang-config=rel/files/eunit.config '.venv/bin/python3 -m nose -v --with-xunit'
 
 ################################################################################
 # Developing

The --erlang-config flag is the important change there. I added the -v for nose to list tests so we can see what's skipped. Its like 98% text indexing plus the two or so that we're leaving for the _users database. Up to you whether you keep the verbosity or not.

@garrensmith
Copy link
Member Author

@davisp I like the -v I've added the change in.

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -160,9 +160,10 @@ endif

.PHONY: check-fdb
check-fdb:
make eunit apps=couch_eval,couch_expiring_cache,ctrace,couch_jobs,couch_views,fabric
make eunit apps=couch_eval,couch_expiring_cache,ctrace,couch_jobs,couch_views,fabric,mango
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone planning to copy these changes into Makefile.win?

@garrensmith garrensmith merged commit 5652e72 into prototype/fdb-layer Apr 6, 2020
@wohali wohali deleted the fdb-mango-indexes branch October 21, 2020 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants