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/11113 fix file perm doc creation #11114

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/release-notes/11113-avoid-orphan-perm-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This release fixes a bug that caused Dataverse to generate unnecessary solr documents for files when a file is added/deleted from a draft dataset. These documents could accumulate and potentially impact performance.

Assuming the upgrade to solr 9.7.0 also occurs in this release, there's nothing else needed for this PR. (Starting with a new solr insures the solr db is empty and that a reindex is already required.)


8 changes: 8 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,4 +1142,12 @@ public boolean isDeaccessioned() {
}
return inDeaccessionedVersions; // since any published version would have already returned
}
public boolean isInDatasetVersion(DatasetVersion version) {
for (FileMetadata fmd : getFileMetadatas()) {
if (fmd.getDatasetVersion().equals(version)) {
return true;
}
}
return false;
}
} // end of class
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ private List<DvObjectSolrDoc> constructDatafileSolrDocs(DataFile dataFile, Map<L
Map<DatasetVersion.VersionState, Boolean> desiredCards = searchPermissionsService.getDesiredCards(dataFile.getOwner());
for (DatasetVersion datasetVersionFileIsAttachedTo : datasetVersionsToBuildCardsFor(dataFile.getOwner())) {
boolean cardShouldExist = desiredCards.get(datasetVersionFileIsAttachedTo.getVersionState());
if (cardShouldExist) {
/*
* Since datasetVersionFileIsAttachedTo should be a draft or the most recent
* released one, it could be more efficient to stop the search through
* FileMetadatas after those two (versus continuing through all prior versions
* as in isInDatasetVersion). Alternately, perhaps filesToReIndexPermissionsFor
* should not combine the list of files for the different datsetversions into a
* single list to start with.
*/
if (cardShouldExist && dataFile.isInDatasetVersion(datasetVersionFileIsAttachedTo)) {
String solrIdStart = IndexServiceBean.solrDocIdentifierFile + dataFile.getId();
String solrIdEnd = getDatasetOrDataFileSolrEnding(datasetVersionFileIsAttachedTo.getVersionState());
String solrId = solrIdStart + solrIdEnd;
Expand Down
Loading