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

ofrenkel at redhat.com ofrenkel at redhat.com
Mon Nov 4 07:42:12 UTC 2013


Omer Frenkel 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:
  Omer Frenkel: Verified; Looks good to me, approved



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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id265df1c1843b976c6f8d65729fd6717c3df3c76
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <tjelinek at redhat.com>
Gerrit-Reviewer: Arik Hadas <ahadas at redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofrenkel at redhat.com>
Gerrit-Reviewer: Ravi Nori <rnori at redhat.com>
Gerrit-Reviewer: Roy Golan <rgolan at redhat.com>
Gerrit-Reviewer: Tomas Jelinek <tjelinek at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server



More information about the Engine-commits mailing list