Change in ovirt-engine[ovirt-engine-3.3]: engine: fix race in CommandAsyncTask

iheim at redhat.com iheim at redhat.com
Mon Nov 4 13:38:48 UTC 2013


Itamar Heim has submitted this change and it was merged.

Change subject: engine: fix race in CommandAsyncTask
......................................................................


engine: fix race in CommandAsyncTask

The race was the following:

1: [thread 1] CommandAsyncTask's constructor reaches the point
   "entityInfo.AttachTask(this)" while the "_multiTasksByCommandIds" still
   contains one task. After this it gets interrupted

2: [thread 2] the CommandAsyncTask.handleEndActionResult is executed in
   meanwhile and issues the
   "_multiTasksByCommandIds.remove(commandInfo.getCommandId());"

3: [thread 1] the first thread continues the execution and calls the
   "entityInfo.AttachTask(this);"

4: [thread 1] the CommandAsyncTask.ConcreteStartPollingTask() is called. It asks
   for the GetCommandMultiAsyncTasks which returns null (because thread 2 have
   deleted it) and fails on NPE on the next line

Fixed by moving all the code which needs to be synchonized to the sync block.

It will not cause any deadlocks because the CommandMultiAsyncTasks.AttachTask
does not use the original _lockObject (nor directly nor indirectly).

Change-Id: Id265df1c1843b976c6f8d65729fd6717c3df3c76
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1015638
Signed-off-by: Tomas Jelinek <tjelinek at redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandAsyncTask.java
1 file changed, 8 insertions(+), 3 deletions(-)

Approvals:
  Itamar Heim: Verified; Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/20841
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id265df1c1843b976c6f8d65729fd6717c3df3c76
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Tomas Jelinek <tjelinek at redhat.com>
Gerrit-Reviewer: Itamar Heim <iheim at redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofrenkel at redhat.com>
Gerrit-Reviewer: Tomas Jelinek <tjelinek at redhat.com>
Gerrit-Reviewer: automation at ovirt.org



More information about the Engine-commits mailing list