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

NXP-30369: Avoid transaction timeout when computing piture views #4862

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

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

You can directly use AbstractWork#commitOrRollbackTransaction.

try {
picture.fillPictureViews(blob, blob.getFilename(), title, null);
} finally {
TransactionHelper.startTransaction();
Copy link
Member

Choose a reason for hiding this comment

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

And AbstractWork#startTransaction(); here.

}
} 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