Skip to content

Partial search updates #3693

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

Merged
merged 5 commits into from
Apr 16, 2018
Merged

Partial search updates #3693

merged 5 commits into from
Apr 16, 2018

Conversation

ewdurbin
Copy link
Member

@ewdurbin ewdurbin commented Apr 15, 2018

A fools attempt at #701

Incrementally reindexes new documents or unindexes whenever a Project or Release is created, updated, or deleted.

def store_projects_for_project_reindex(config, session, flush_context):
# We'll (ab)use the session.info dictionary to store a list of pending
# Project updates to the session.
purges = session.info.setdefault("warehouse.search.project_updates", set())
Copy link
Member

Choose a reason for hiding this comment

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

Probably want to call this something other than purges... reindexable? changed_projects? updated_projects?

@@ -87,6 +87,9 @@ def _project_docs(db):
.order_by(Release.name)
)

if project_name:
release_data = release_data.filter(Release.name == project_name)
Copy link
Member

Choose a reason for hiding this comment

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

Probably want to add this filter earlier on releases_list instead of here? Maybe it makes no difference...

Copy link
Member Author

Choose a reason for hiding this comment

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

it's damn fast either way, but you're right!

Copy link
Member Author

Choose a reason for hiding this comment

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

so, since releases_list is a subquery, it seems it is not easily modified after the fact. probably best to let this sleeping dog lay.

Copy link
Member

Choose a reason for hiding this comment

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

You could just .subquery it later, and do releases_list = releases_list.filter(...) earlier. Again, might not really matter.

Copy link
Member Author

Choose a reason for hiding this comment

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

easy enough.

# a Project to reindex for when the session has been committed.
for obj in (session.new | session.dirty | session.deleted):
if obj.__class__ == Project:
purges.add(obj)
Copy link
Member

Choose a reason for hiding this comment

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

If the project has been deleted, I'm not sure it makes sense to add it to the set here, because the .filter below will not return any releases at all. (I guess a deleted project can just fall out of the index when we reindex nightly instead of trying to do something special for it here.)

However if a release has been deleted, it does make sense.


@db.listens_for(db.Session, "after_commit")
def execute_project_reindex(config, session):
purges = session.info.pop("warehouse.search.project_updates", set())
Copy link
Member

Choose a reason for hiding this comment

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

Ditto here.

@ewdurbin ewdurbin merged commit e8dc4da into master Apr 16, 2018
@ewdurbin ewdurbin deleted the partial_search_updates branch April 16, 2018 10:44
ewdurbin added a commit that referenced this pull request Apr 16, 2018
ewdurbin added a commit that referenced this pull request Apr 16, 2018
* Revert "wrap search index mutation in a lock (#3700)"

This reverts commit 7a8a249.

* Revert "Partial search updates (#3693)"

This reverts commit e8dc4da.
janiceshiu pushed a commit to janiceshiu/warehouse that referenced this pull request Apr 18, 2018
* docker-compose: fixup local celery to _actually_ hot reload

* partially update the index on Release/Project changes

* address @di's review! better names, unindex deleted projects

* for @di
janiceshiu pushed a commit to janiceshiu/warehouse that referenced this pull request Apr 18, 2018
* Revert "wrap search index mutation in a lock (pypi#3700)"

This reverts commit 7a8a249.

* Revert "Partial search updates (pypi#3693)"

This reverts commit e8dc4da.
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.

2 participants