Liron Ar has uploaded a new change for review. Change subject: core: updateAllInBatch - sorting/transaction issues ......................................................................
core: updateAllInBatch - sorting/transaction issues *If there's no transaction, sorting is unneeded as deadlock can't occur as each statement will be executed independently. *When the collection is sorted, the sorted result need to be passed to the update and not the unsorted collection as being done today. Change-Id: I935555bae208786e64f109e267749eafea57fb60 Signed-off-by: Liron Aravot <lara...@redhat.com> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/MassOperationsGenericDaoDbFacade.java 1 file changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/09/28909/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/MassOperationsGenericDaoDbFacade.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/MassOperationsGenericDaoDbFacade.java index 658f5ed..009aa86 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/MassOperationsGenericDaoDbFacade.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/MassOperationsGenericDaoDbFacade.java @@ -9,6 +9,7 @@ import org.ovirt.engine.core.common.businessentities.BusinessEntity; import org.ovirt.engine.core.common.businessentities.comparators.BusinessEntityComparator; import org.ovirt.engine.core.dal.dbbroker.MapSqlParameterMapper; +import org.ovirt.engine.core.utils.transaction.TransactionSupport; /** * Implementation for the {@link MassOperationsDao} which provides a default @@ -54,9 +55,12 @@ Collection<T> paramValues, MapSqlParameterMapper<T> mapper) { - // To overcome possible deadlocks, we need to sort the collection - List<T> sortedParamValues = new ArrayList<>(paramValues); - Collections.sort(sortedParamValues, BusinessEntityComparator.<T, ID> newInstance()); + // To overcome possible deadlocks, we need to sort the collection if the code is executed in transaction + if (TransactionSupport.current() != null) { + List<T> sortedParamValues = new ArrayList<>(paramValues); + Collections.sort(sortedParamValues, BusinessEntityComparator.<T, ID> newInstance()); + paramValues = sortedParamValues; + } getCallsHandler().executeStoredProcAsBatch(procedureName == null ? getProcedureNameForUpdate() : procedureName, paramValues, mapper); } -- To view, visit http://gerrit.ovirt.org/28909 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I935555bae208786e64f109e267749eafea57fb60 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Ar <lara...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches