Is using CompensationContext in child commands broken?

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 [1] - https://github.com/oVirt/ovirt-engine/blob/31fbb4cb48c7208e6b37c5c0e27560599... [2] - https://github.com/oVirt/ovirt-engine/blob/31fbb4cb48c7208e6b37c5c0e27560599...

As Ravi is on PTO till end of August, Moti could you please take a look and reply? On Thu, Aug 16, 2018 at 6: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
[1] - https://github.com/oVirt/ovirt-engine/blob/ 31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/ modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java#L1171 [2] - https://github.com/oVirt/ovirt-engine/blob/ 31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/ modules/bll/src/main/java/org/ovirt/engine/core/bll/context/ DefaultCompensationContext.java#L206
_______________________________________________ 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/
-- Martin Perina Associate Manager, Software Engineering Red Hat Czech s.r.o.

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/31fbb4cb48c7208e6b37c5c0e27560599... 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/31fbb4cb48c7208e6b37c5c0e27560599... 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
[1] - https://github.com/oVirt/ovirt-engine/blob/ 31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/ modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java#L1171 [2] - https://github.com/oVirt/ovirt-engine/blob/ 31fbb4cb48c7208e6b37c5c0e27560599e15cef9/backend/manager/ modules/bll/src/main/java/org/ovirt/engine/core/bll/context/ DefaultCompensationContext.java#L206
_______________________________________________ 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
participants (3)
-
Andrej Krejcir
-
Martin Perina
-
Moti Asayag