Skip to content

Commit

Permalink
NXP-30369: Avoid transaction timeout when computing piture views
Browse files Browse the repository at this point in the history
  • Loading branch information
ataillefer committed Jun 24, 2021
1 parent 5a727cd commit ef99c3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.nuxeo.ecm.platform.picture.api.adapters.PictureResourceAdapter;
import org.nuxeo.ecm.platform.picture.recompute.RecomputeViewsAction;
import org.nuxeo.runtime.api.Framework;
import org.nuxeo.runtime.transaction.TransactionHelper;

/**
* Work generating the different picture views for a Picture.
Expand Down Expand Up @@ -123,7 +124,12 @@ public void work() {
setStatus("Generating views");
try {
PictureResourceAdapter picture = workingDocument.getAdapter(PictureResourceAdapter.class);
picture.fillPictureViews(blob, blob.getFilename(), title, null);
TransactionHelper.commitOrRollbackTransaction();
try {
picture.fillPictureViews(blob, blob.getFilename(), title, null);
} finally {
TransactionHelper.startTransaction();
}
} catch (DocumentNotFoundException e) {
// a parent of the document may have been deleted.
setStatus(NOTHING_TO_PROCESS_MESSAGE);
Expand Down
Expand Up @@ -50,6 +50,7 @@
import org.nuxeo.lib.stream.computation.Topology;
import org.nuxeo.runtime.api.Framework;
import org.nuxeo.runtime.stream.StreamProcessorTopology;
import org.nuxeo.runtime.transaction.TransactionHelper;

/**
* BAF Computation that fills picture views for the blob property described by the given xpath.
Expand Down Expand Up @@ -114,7 +115,12 @@ protected void compute(CoreSession session, List<String> ids, Map<String, Serial
try {
PictureResourceAdapter picture = workingDocument.getAdapter(PictureResourceAdapter.class);
log.debug("Fill picture views for doc: {}", workingDocument);
picture.fillPictureViews(blob, blob.getFilename(), title, null);
TransactionHelper.commitOrRollbackTransaction();
try {
picture.fillPictureViews(blob, blob.getFilename(), title, null);
} finally {
TransactionHelper.startTransaction();
}
} catch (DocumentNotFoundException e) {
// a parent of the document may have been deleted.
continue;
Expand Down

0 comments on commit ef99c3b

Please sign in to comment.