Liron Aravot has uploaded a new change for review. Change subject: core: ImportVmCommand - compensation related issues ......................................................................
core: ImportVmCommand - compensation related issues Currently the compensation usage in ImportVmCommand is somewhat problematic. The added entities in processImages() aren't all being added to the compensation context. That means that in case of an engine crash after the transaction end, the clearance of the compensation context may not work (because of constaints/left records) and even if it does - leftovers may remain in the database. The proper solution should be to split the processImages() method, extract the VDS calls from the transaction and to use the compensation properly on all the added entities. As a quick fix, the introduced solution is to clear the compensation context within the transaction if tasks were created (as we'll get to end method anyway), otherwise we can perform the endVmRelatedOperations. Change-Id: If0a1665e1b4e5a24feba5d70f443cbfa72b36889 Signed-off-by: Liron Aravot <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java 1 file changed, 11 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/34735/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java index 8f75af0..f602089 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java @@ -691,16 +691,15 @@ return true; } + protected boolean tasksCreated() { + return !getReturnValue().getVdsmTaskIdList().isEmpty(); + } + @Override protected void executeCommand() { try { addVmToDb(); processImages(!isImagesAlreadyOnTarget()); - // if there aren't tasks - we can just perform the end - // vm related ops - if (getReturnValue().getVdsmTaskIdList().isEmpty()) { - endVmRelatedOps(); - } // Save Vm Init VmHandler.addVmInitToDB(getVm().getStaticData()); } catch (RuntimeException e) { @@ -740,8 +739,14 @@ getParameters().setVm(getVm()); setVmId(getVm().getId()); } + if (tasksCreated()) { + getCompensationContext().resetCompensation(); + } else { + // if there aren't tasks - we can just perform the end + // vm related ops + endVmRelatedOps(); + } return null; - } }); } -- To view, visit http://gerrit.ovirt.org/34735 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If0a1665e1b4e5a24feba5d70f443cbfa72b36889 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Aravot <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
