Hi,

When you invoke a child command you can specify a specific command context for the child command to be executed with:

[1] https://github.com/oVirt/ovirt-engine/blob/31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java#L2317


If you wish the child command to be executed detached from the parent command context, you should use the following method [2] for creating the context for the child command and pass it as the argument for [1]

[2] https://github.com/oVirt/ovirt-engine/blob/31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java#L2360

It is up to the developer to decide if the child command should share the same context as the parent command or use its own detached context.


On Thu, Aug 16, 2018 at 7:21 PM, Andrej Krejcir <akrejcir@redhat.com> wrote:
Hi,

I'm changing UpdateClusterCommand to be non-transactive,
and it would use CompensationContext for reverting DB operations.

Reading through CommandBase code, I noticed the following flow seems to be broken:

1. A command without transaction is executed.
2. It executes a child command, with the compensation context of the current command. So that the result of the child command can be reverted if the parent fails.
3. Once the child command successfully finishes, it removes all entity snapshots from the DB (it calls CommandContext::cleanupCompensationDataAfterSuccessfulCommand), even if the snapshots were made by the parent command. See code at [1] and [2].
4. The parent command then fails for some other reason, but its compensation context is empty, so the DB operations are not reverted correctly.


Am I missing something or is this flow broken? 


Thanks,
Andrej





_______________________________________________
Devel mailing list -- devel@ovirt.org
To unsubscribe send an email to devel-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/RMP3S7TD4SKUUSOUDVBMT3KVTBFRTJ7Q/




--
Regards,
Moti