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

trigger re-index and optimize query by social field #1744

Closed
wants to merge 1 commit into from

Conversation

call-me-matt
Copy link
Member

trigger re-index of contacts to optimize query in background updates

Signed-off-by: call-me-matt <nextcloud@matthiasheinisch.de>
@call-me-matt
Copy link
Member Author

call-me-matt commented Aug 11, 2020

This is a follow-up of nextcloud/server#22085
This code is untested, I would be interested in feedback before continuing.

@call-me-matt call-me-matt marked this pull request as draft August 11, 2020 21:42
@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #1744 into master will decrease coverage by 2.11%.
The diff coverage is 4.54%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1744      +/-   ##
============================================
- Coverage     40.05%   37.93%   -2.12%     
- Complexity      128      133       +5     
============================================
  Files            17       18       +1     
  Lines           377      398      +21     
============================================
  Hits            151      151              
- Misses          226      247      +21     
Impacted Files Coverage Δ Complexity Δ
lib/Migration/BuildSocialSearchIndex.php 0.00% <0.00%> (ø) 5.00 <5.00> (?)
lib/Service/SocialApiService.php 88.42% <100.00%> (ø) 36.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 752bb14...4034b35. Read the comment docs.

@skjnldsv

This comment has been minimized.

@nickvergessen
Copy link
Member

It's a repair step, exactly what it should be, but it's not registered in info.xml

@skjnldsv

This comment has been minimized.

Copy link
Member

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

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

BuildSocialSearchIndex should not be part of the Contacts app, but in dav in the server.
Apps should not use classes from other apps or access their database tables.

Futhermore, the actual indexing shouldn't be done in the migration step, but the migration step should only register a background job that will re-index them in smaller chunks. There are Nextcloud instances storing millions and millions of contacts, a simple repair-step would timeout here or block the update for hours.

See https://github.com/nextcloud/server/blob/master/apps/dav/lib/Migration/BuildCalendarSearchIndex.php
It's only fetching the biggest id from the database and registering a re-index job, which later reindexes all events with an id lower than the one from the repair step.

Also see https://github.com/nextcloud/server/blob/master/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php#L79L87 and https://github.com/nextcloud/server/blob/master/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php#L116L118.

The background-job does not re-index everything at once, but only 15 seconds per background-job and continues where it left of previously.

@call-me-matt
Copy link
Member Author

Thank you for your feedback, I will move the code to the server then (and pack it into background-chunks)

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.

4 participants