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

Move files/ajax/scan.php to background job #20545

Merged
merged 1 commit into from
Dec 3, 2015

Conversation

LukasReschke
Copy link
Member

The background job will now be executed in chunks of 500 users all 10 minutes.

@DeepDiver1975 @icewind1991 @PVince81 Please review - THX.

Fixes #17906

*/
protected function runScanner(IUser $user) {
$scanner = new Scanner($user->getUID(), $this->dbConnection);
$scanner->scan();
Copy link
Member Author

Choose a reason for hiding this comment

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

@icewind1991 @PVince81 Please advise whether we should use \OC\Files\Utils\Scanner::backgroundScan or \OC\Files\Utils\Scanner::scan here

Copy link
Member Author

Choose a reason for hiding this comment

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

Especially as this will be run all 10 minutes for a chunk of 500 users. 😉

@karlitschek
Copy link
Contributor

looks good. 500 users every 10min sounds reasonable
👍

// Add cron job for scanning user storages
$jobList = \OC::$server->getJobList();
$job = 'OCA\Files\BackgroundJob\ScanFiles';
if(!$jobList->has($job, '')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. THX.

@LukasReschke
Copy link
Member Author

#20545 (comment) is still open

@icewind1991
Copy link
Contributor

Add some tests for the iterating over users cases?

  • Offset is at the end of the user list, job should reset offset and query again
  • With >500 users 2 consecutive calls should get a different list of users
  • With <500 users 2 consecutive calls should get the same list of users

protected function runScanner(IUser $user) {
try {
$scanner = new Scanner($user->getUID(), $this->dbConnection);
$scanner->scan();
Copy link
Contributor

Choose a reason for hiding this comment

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

scan.php uses $scanner->backgroundScan(); which is also what should be used here.

There different is that backgroundScan only checks for folders that are not fully scanned yet (marked with size -1) while scan goes trough the entire filesystem of the user.

Using scan in a backgroundjob in such a naive way will not work when you scale up, when external storages are used scan can easily take many minutes every time you call it, backgroundScan will only take time if there's work to be done

@PVince81
Copy link
Contributor

Rebase needed

The background job will now be executed in chunks of 500 users all 10 minutes.
@LukasReschke
Copy link
Member Author

Rebased also added a new unit test.

  • With >500 users 2 consecutive calls should get a different list of users
  • With <500 users 2 consecutive calls should get the same list of users

@icewind1991 I'm not entirely sure how to do that here considering the mocking and DIs. So what I just added now is a test that it goes back to the first user once it has reached all. If you have an idea on how to test this any help is utmost appreciated.

@MorrisJobke
Copy link
Contributor

Tested and works 👍

DeepDiver1975 added a commit that referenced this pull request Dec 3, 2015
Move files/ajax/scan.php to background job
@DeepDiver1975 DeepDiver1975 merged commit 2ceae43 into master Dec 3, 2015
@DeepDiver1975 DeepDiver1975 deleted the scan-storage-in-background-job branch December 3, 2015 15:53
DeepDiver1975 added a commit that referenced this pull request Jan 20, 2016
Remove unneeded markup for scan process - ref #20545
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move ajax/scan.php to cron job
7 participants