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

IQSS/10697 - Improve batch permission indexing #10698

Conversation

qqmyers
Copy link
Member

@qqmyers qqmyers commented Jul 18, 2024

What this PR does / why we need it: This PR adds checks within the loops over all children of a definition point and all files of those children and now calls the code to actually process files to create the permissions docs for them and then to submit those documents to solr, thus allowing the memory used to cache them to be released.

Which issue(s) this PR closes:

Special notes for your reviewer:

Changes are clearer if you look at https://github.com/IQSS/dataverse/pull/10698/files?w=1.

I have somewhat arbitrarily chosen to trigger creating documents every 100 files and to then send those docs to solr every 20 docs. Those could be configurable or just optimized with some testing, but the key thing is that, prior to this PR, a change to permissions on the root DV loads all files and all docs into memory, so any cap to avoid doing that should be OK. Choosing too small number is hopefully not a big issue any more as we are relying on auto soft/hard commits, so if we make updates more often than 1 sec/30 seconds, solr is just going to cache the submissions on its side.

Note that one of the problems we detected at QDR was that after a permission change and subsequent out-of-memory failure of our test server, when we restarted, we had out-of-date permissions documents. Those are not orphans so they aren't detected by the /api/admin/index/status call, they just result in odd behavior such as a search showing a closed lock on a restricted file when, if you go the page, you can actually download, etc.

This PR doesn't change the fact that all file permission docs have to be updated, which still take a long time (minutes/hours) on a big installation. It does appear to stop the memory use from climbing though.

If someone had a memory failure due to this, they could/should reindex permissions to fix it. From what I can see, there is an api call for that: /admin/index/perms, but as far as I can tell, this is undocumented. Not sure why (other than it is slow - and it does everything in one batch and writes permissionindextimes to files as well). Doing an in place reindex of everything would also work, so this is what I've put in the release note for now.

Suggestions on how to test this:
Create a db with a significant number of files in one or more datasets (thousands?), change the permissions on the root collection, e.g. adding or removing a person from the curator role. Watch the memory use during processing (top?) and verify that it doesn't keep increasing until the permission updates finish (%cpu should drop and there's a message in the log).

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Additional documentation:

@coveralls
Copy link

coveralls commented Jul 18, 2024

Coverage Status

coverage: 20.868% (-0.007%) from 20.875%
when pulling 6baff90 on QualitativeDataRepository:QDR-improve-batch-permission-indexing
into c44ad65 on IQSS:develop.

qqmyers added 3 commits July 18, 2024 16:24
Avoids keeping everything in memory, also helps in tracking progress as
you can see the permissionindextime getting updated per dataset.
@qqmyers qqmyers added Consider For Next Release A simple change (eg bug fix) that would be good to prioritize since it has been seen in the wild Size: 3 A percentage of a sprint. 2.1 hours. labels Jul 19, 2024
@cmbz cmbz added the FY25 Sprint 7 FY25 Sprint 7 (2024-09-25 - 2024-10-09) label Sep 25, 2024
@cmbz cmbz added this to the 6.5 milestone Sep 30, 2024
@pdurbin pdurbin self-assigned this Oct 2, 2024
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

I made some cosmetic tweaks. I didn't run the code but it seems fine. Approved.

@pdurbin pdurbin removed their assignment Oct 2, 2024
@cmbz cmbz added the FY25 Sprint 8 FY25 Sprint 8 (2024-10-09 - 2024-10-23) label Oct 9, 2024
@stevenwinship stevenwinship self-assigned this Oct 9, 2024
@pdurbin pdurbin added the Type: Feature a feature request label Oct 9, 2024
@stevenwinship
Copy link
Contributor

solr

Over 5000 files
Red section is adding the role to a new user
Green section is uploading an additional 1000 files

log messages for each file: "reusing cached perms for file 6353"

@stevenwinship
Copy link
Contributor

Tested heavily on Perf cluster. No CPU or Memory issues detected.

@stevenwinship stevenwinship merged commit d039a10 into IQSS:develop Oct 16, 2024
11 checks passed
@stevenwinship stevenwinship removed their assignment Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Consider For Next Release A simple change (eg bug fix) that would be good to prioritize since it has been seen in the wild FY25 Sprint 7 FY25 Sprint 7 (2024-09-25 - 2024-10-09) FY25 Sprint 8 FY25 Sprint 8 (2024-10-09 - 2024-10-23) Size: 3 A percentage of a sprint. 2.1 hours. Type: Feature a feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reindex permissions in batches
5 participants