Skip to content

Commit 5ed188e

Browse files
committed
Merge branch 'develop' into v6.8-qdr
2 parents 1e13959 + 934bea8 commit 5ed188e

File tree

5 files changed

+61
-8
lines changed

5 files changed

+61
-8
lines changed

src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public Dataset findDeep(Object pk) {
146146
.setHint("eclipselink.left-join-fetch", "o.files.creator")
147147
.setHint("eclipselink.left-join-fetch", "o.files.alternativePersistentIndentifiers")
148148
.setHint("eclipselink.left-join-fetch", "o.files.roleAssignments")
149+
.setHint("eclipselink.left-join-fetch", "o.storageUse")
149150
.getSingleResult();
150151
} catch (NoResultException | NonUniqueResultException ex) {
151152
return null;

src/main/java/edu/harvard/iq/dataverse/search/IndexBatchServiceBean.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import jakarta.ejb.Asynchronous;
1616
import jakarta.ejb.EJB;
1717
import jakarta.ejb.Stateless;
18+
import jakarta.ejb.TransactionAttribute;
19+
import jakarta.ejb.TransactionAttributeType;
1820
import jakarta.inject.Named;
1921
import jakarta.json.Json;
2022
import jakarta.json.JsonArrayBuilder;
@@ -47,6 +49,7 @@ public class IndexBatchServiceBean {
4749
SystemConfig systemConfig;
4850

4951
@Asynchronous
52+
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
5053
public Future<JsonObjectBuilder> indexStatus() {
5154
JsonObjectBuilder response = Json.createObjectBuilder();
5255
logger.info("Beginning indexStatus()");
@@ -76,6 +79,7 @@ public Future<JsonObjectBuilder> indexStatus() {
7679
}
7780

7881
@Asynchronous
82+
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
7983
public Future<JsonObjectBuilder> clearOrphans() {
8084
JsonObjectBuilder response = Json.createObjectBuilder();
8185
List<String> solrIds = new ArrayList<>();
@@ -103,6 +107,7 @@ public Future<JsonObjectBuilder> clearOrphans() {
103107

104108

105109
@Asynchronous
110+
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
106111
public Future<JsonObjectBuilder> indexAllOrSubset(long numPartitions, long partitionId, boolean skipIndexed, boolean previewOnly) {
107112
JsonObjectBuilder response = Json.createObjectBuilder();
108113
indexAllOrSubset(numPartitions, partitionId, skipIndexed);
@@ -140,7 +145,8 @@ public JsonObjectBuilder indexAllOrSubsetPreview(long numPartitions, long partit
140145
return response;
141146
}
142147

143-
public Future<String> indexAllOrSubset(long numPartitions, long partitionId, boolean skipIndexed) {
148+
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
149+
private Future<String> indexAllOrSubset(long numPartitions, long partitionId, boolean skipIndexed) {
144150
long indexAllTimeBegin = System.currentTimeMillis();
145151
String status;
146152

src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,13 +1547,18 @@ public boolean isValid(SolrSearchResult result) {
15471547
});
15481548
}
15491549

1550+
private Map<Long, Boolean> seesStatus = new HashMap<>();
1551+
15501552
public boolean canSeeCurationStatus(Long datasetId) {
1551-
boolean creatorsCanSeeStatus = JvmSettings.UI_SHOW_CURATION_STATUS_TO_ALL.lookupOptional(Boolean.class).orElse(false);
1552-
if (creatorsCanSeeStatus) {
1553-
return permissionsWrapper.canViewUnpublishedDataset(getDataverseRequest(),(Dataset) dvObjectService.findDvObject(datasetId));
1554-
} else {
1555-
return canPublishDataset(datasetId);
1553+
if (!seesStatus.containsKey(datasetId)) {
1554+
boolean creatorsCanSeeStatus = JvmSettings.UI_SHOW_CURATION_STATUS_TO_ALL.lookupOptional(Boolean.class).orElse(false);
1555+
if (creatorsCanSeeStatus) {
1556+
seesStatus.put(datasetId, permissionsWrapper.canViewUnpublishedDataset(getDataverseRequest(), (Dataset) dvObjectService.findDvObject(datasetId)));
1557+
} else {
1558+
seesStatus.put(datasetId, canPublishDataset(datasetId));
1559+
}
15561560
}
1561+
return seesStatus.get(datasetId);
15571562
}
15581563

15591564
public enum SortOrder {

src/main/java/edu/harvard/iq/dataverse/search/SolrIndexServiceBean.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import jakarta.persistence.PersistenceContext;
4040

4141
import org.apache.solr.client.solrj.SolrServerException;
42+
import org.apache.solr.client.solrj.response.UpdateResponse;
4243
import org.apache.solr.common.SolrInputDocument;
4344

4445
@Named
@@ -327,7 +328,47 @@ private void persistToSolr(Collection<SolrInputDocument> docs) throws SolrServer
327328
/**
328329
* @todo Do something with these responses from Solr.
329330
*/
330-
solrClientService.getSolrClient().add(docs);
331+
int maxRetries = 3;
332+
int retryCount = 0;
333+
boolean success = false;
334+
335+
while (!success && retryCount < maxRetries) {
336+
try {
337+
if (retryCount > 0) {
338+
// Exponential backoff
339+
Thread.sleep((long) Math.pow(2, retryCount) * 1000);
340+
logger.info("Retry attempt " + retryCount + " for Solr batch");
341+
}
342+
343+
logger.fine("persisting " + docs.size() + " docs to Solr...");
344+
UpdateResponse response = solrClientService.getSolrClient().add(docs);
345+
346+
// Check response status
347+
if (response.getStatus() == 0) {
348+
success = true;
349+
logger.fine("Successfully added " + docs.size() + " docs to Solr in " +
350+
response.getQTime() + "ms");
351+
} else {
352+
logger.warning("Solr returned non-zero status: " + response.getStatus());
353+
}
354+
} catch (SolrServerException | IOException e) {
355+
retryCount++;
356+
if (e.getMessage() != null && e.getMessage().contains("Request processing has stalled")) {
357+
logger.warning("Solr request stalled. Retry " + retryCount + "/" + maxRetries);
358+
359+
// If this is the last retry, rethrow
360+
if (retryCount >= maxRetries) {
361+
throw e;
362+
}
363+
} else {
364+
// For other exceptions, don't retry
365+
throw e;
366+
}
367+
} catch (InterruptedException e) {
368+
Thread.currentThread().interrupt();
369+
throw new IOException("Interrupted during retry backoff", e);
370+
}
371+
}
331372
}
332373

333374

src/main/webapp/search-include-fragment.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@
582582
<h:outputText value="#{bundle['dataset.versionUI.deaccessioned']}" styleClass="label label-danger" rendered="#{result.deaccessionedState}"/>
583583
<h:outputText value="#{bundle['embargoed']}" styleClass="label label-primary" rendered="#{SearchIncludeFragment.isActivelyEmbargoed(result)}"/>
584584
<h:outputText value="#{bundle['retentionExpired']}" styleClass="label label-warning" rendered="#{SearchIncludeFragment.isRetentionExpired(result)}"/>
585-
<h:outputText value="#{DatasetUtil:getLocaleCurationStatusLabelFromString(result.curationStatus)}" styleClass="label curation-status" rendered="#{SearchIncludeFragment.canSeeCurationStatus(result.entityId)}"/>
585+
<h:outputText value="#{DatasetUtil:getLocaleCurationStatusLabelFromString(result.curationStatus)}" styleClass="label curation-status" rendered="#{result.draftState and SearchIncludeFragment.canSeeCurationStatus(result.entityId)}"/>
586586
<h:outputText value="#{result.userRole}" styleClass="label label-primary" rendered="#{!empty result.userRole}"/>
587587
<h:outputText value="#{bundle['incomplete']}" styleClass="label label-danger" rendered="#{!result.harvested and !SearchIncludeFragment.isValid(result)}"/>
588588
</div>

0 commit comments

Comments
 (0)