Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz1197902 - clear hibernate session after each translation batch save
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Mar 23, 2015
1 parent bacdfcd commit 28c3043
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/release-notes.md
Expand Up @@ -77,6 +77,7 @@ Zanata now requires JMS to be configured in standalone.xml in order to queue up
* [1186997](https://bugzilla.redhat.com/show_bug.cgi?id=1186997) - Introduction of hornetq-ra breaks the overlay installer
* [1192271](https://bugzilla.redhat.com/show_bug.cgi?id=1192271) - For gettext plural project, project-version statistics was inconsistent between language and document, sometime more than 100%
* [1193699](https://bugzilla.redhat.com/show_bug.cgi?id=1193699) - Bookmarked url (selected language or selected doc) in version page, bookmarked url selected language, selected project in version-group page not working
* [1197902](https://bugzilla.redhat.com/show_bug.cgi?id=1197902) - Large translated document push times are inconsistent

-----------------------

Expand Down Expand Up @@ -237,4 +238,4 @@ Zanata now requires JMS to be configured in standalone.xml in order to queue up
* [1060621](https://bugzilla.redhat.com/show_bug.cgi?id=1060621) - [Regression] Validation warnings panel not displayed
* [1044768](https://bugzilla.redhat.com/show_bug.cgi?id=1044768) - Zanata does not pull the latest changes in translation due to unchanged ETags
* [1063112](https://bugzilla.redhat.com/show_bug.cgi?id=1063112) - Client push in dryRun mode should not invoke CopyTrans
* [1069428](https://bugzilla.redhat.com/show_bug.cgi?id=1069428) - Various concurrency problems due to unsafe Seam injections
* [1069428](https://bugzilla.redhat.com/show_bug.cgi?id=1069428) - Various concurrency problems due to unsafe Seam injections
Expand Up @@ -149,8 +149,8 @@ public HTextFlowTarget(HTextFlow textFlow, @Nonnull HLocale locale) {

// TODO PERF @NaturalId(mutable=false) for better criteria caching
@NaturalId
@ManyToOne
@JoinColumn(name = "locale", nullable = false)
@ManyToOne(optional = false)
@JoinColumn(name = "locale", nullable = false, updatable = false)
@Field(analyze = Analyze.NO)
@FieldBridge(impl = LocaleIdBridge.class)
public @Nonnull
Expand Down
Expand Up @@ -101,7 +101,7 @@ public void execute() {
taskFuture.set(returnValue);
} catch (Throwable t) {
taskFuture.setException(t);
log.warn(
log.error(
"Exception when executing an asynchronous task.", t);
}
}
Expand Down
Expand Up @@ -111,9 +111,6 @@ public class TranslationServiceImpl implements TranslationService {
@In
private DocumentDAO documentDAO;

@In
private PersonDAO personDAO;

@In
private TextFlowDAO textFlowDAO;

Expand Down Expand Up @@ -628,6 +625,7 @@ protected Boolean work() throws Exception {
}
}.workInTransaction();
} catch (Exception e) {
log.error("exception in transferFromTranslationsResourceExtensions: {}", e.getMessage());
throw new ZanataServiceException("Error during translation.", 500,
e);
}
Expand Down Expand Up @@ -666,6 +664,7 @@ protected Boolean work() throws Exception {
work.setAssignCreditToUploader(assignCreditToUploader);
changed |= work.workInTransaction();
} catch (Exception e) {
log.error("exception in SaveBatchWork:{}", e.getMessage());
throw new ZanataServiceException("Error during translation.",
500, e);
}
Expand Down Expand Up @@ -700,6 +699,7 @@ protected Void work() throws Exception {
.getLocaleId()));
}
} catch (Exception e) {
log.error("exception in removeTargets: {}", e.getMessage());
throw new ZanataServiceException("Error during translation.",
500, e);
}
Expand Down Expand Up @@ -736,6 +736,10 @@ private final class SaveBatchWork extends Work<Boolean> {

@Override
protected Boolean work() throws Exception {
// we need to call clear at the beginning because text flow target
// history rely on after commit callback.
textFlowTargetDAO.clear();
document = entityManager.find(HDocument.class, document.getId());
boolean changed = false;

// we need a fresh object in this session,
Expand Down Expand Up @@ -829,7 +833,7 @@ public String apply(TextFlowTarget input) {

changed = true;
Long actorId;
if(assignCreditToUploader){
if (assignCreditToUploader){
HPerson hPerson = authenticatedAccount.getPerson();
hTarget.setTranslator(hPerson);
hTarget.setLastModifiedBy(hPerson);
Expand All @@ -848,8 +852,6 @@ public String apply(TextFlowTarget input) {
handleOp.get().increaseProgress(1);
}
}
// every batch will start with a new hibernate session therefore no
// need to call clear
textFlowTargetDAO.flush();

return changed;
Expand Down
6 changes: 4 additions & 2 deletions zanata-war/src/test/resources/arquillian/persistence.xml
Expand Up @@ -5,10 +5,10 @@
version="2.0">

<persistence-unit name="zanataTestDatasourcePU"
transaction-type="RESOURCE_LOCAL">
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>

<non-jta-data-source>java:jboss/datasources/zanataTestDatasource</non-jta-data-source>
<jta-data-source>java:jboss/datasources/zanataTestDatasource</jta-data-source>

<!--
NB non-jta-data-source is not compatible with JPA tests, but is
Expand Down Expand Up @@ -66,6 +66,8 @@
<exclude-unlisted-classes>true</exclude-unlisted-classes>

<properties>
<property name="jboss.entity.manager.factory.jndi.name"
value="java:/zanataEntityManagerFactory" />
<!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
<!-- NB: Might have to be removed for Hibernate 4.3 -->
<property name="hibernate.transaction.manager_lookup_class"
Expand Down

0 comments on commit 28c3043

Please sign in to comment.