Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 145880 - Updates causing deadlock when transaction worker thread sends notification
Summary: Updates causing deadlock when transaction worker thread sends notification
Status: RESOLVED DUPLICATE of bug 146341
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P3 critical
Target Milestone: 1.0   Edit
Assignee: Steven R. Shaw CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 146341
Blocks:
  Show dependency tree
 
Reported: 2006-06-07 17:18 EDT by Steven R. Shaw CLA
Modified: 2010-07-19 12:26 EDT (History)
4 users (show)

See Also:


Attachments
Patch to disable updates when worker thread is executing (29.94 KB, patch)
2006-06-08 16:00 EDT, Steven R. Shaw CLA
no flags Details | Diff
Updated patch including fix for TreeEditPart deadlock issue (38.07 KB, patch)
2006-06-08 17:12 EDT, Steven R. Shaw CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven R. Shaw CLA 2006-06-07 17:18:57 EDT
Scenario:
- Outside client is executing a job on a worker thread.
- GMF UI is still enabled while worker thread is executed - potentially causing
updates to occur which will ask for a lock of the editing domain.  Since
transaction is executing on another thread, the UI will lock.
- Notifications are received by GMF on the worker thread.
- GMF needs to synchronously send the notifications to the UI thread to respect
the transaction api contract using the Priveledged runnable.
- Synch exec tries to obtain a lock, but UI has lock already --> DEADLOCK...

Other Scenario:
- Assuming updates are disabled (from above)
- transaction executes on worker thread when GMF diagram editor isn't active
- User switches to GMF diagram editor while worker thread still executing.
- Part activation tries to acquire lock of transaction.
- GMF needs to synchronously send the notifications to the UI thread to respect
the transaction api contract using the Priveledged runnable.
- Synch exec tries to obtain a lock, but UI has lock already --> DEADLOCK...
Comment 1 Steven R. Shaw CLA 2006-06-08 08:58:22 EDT
Couple options available:
1) Make this worker thread case consistent with how the progress meter execution is handled.  Disable updates on the UI and continue to handle notifications on the worker thread instead of synchronizing with the main thread.

2) Notify clients and say that these type of Job executions aren't handled by GMF and that they need to synchronize the execution to the main thread before the transaction is executed.

Currently exploring a solution with (1) right now..
Comment 2 Steven R. Shaw CLA 2006-06-08 16:00:11 EDT
Created attachment 43914 [details]
Patch to disable updates when worker thread is executing

Patch removes synchronous handling of notifications due to deadlock scenarios.  Adds a listener to the DiagramEditingDomain that will notify when a transaction is activated and deactivated which triggers the updates to be disabled.

Nick / Steph: please try patch in your client code.
Comment 3 Steven R. Shaw CLA 2006-06-08 16:40:05 EDT
Still getting deadlock in progress meter scenario now because TreeEditPart is sending notifications asynchronously.  If multiple ones are handled, then the previous one will lock the one after it...
Comment 4 Steven R. Shaw CLA 2006-06-08 17:12:17 EDT
Created attachment 43921 [details]
Updated patch including fix for TreeEditPart deadlock issue

Removed asyncExec in TreeEditPart and utilized priviledged runnable concept from transaction api.
Comment 5 Steven R. Shaw CLA 2006-06-09 14:00:54 EDT
Deadlock scenarios are still occurring with async since they are executed concurrently on the main thread while the worker thread is running.  Had a discussion with the EMFT transaction team and we decided that they will supply an api that will ensure synchonous execution of a runnable to avoid these deadlocking scnearios.  Currently waiting for this api...

Attached patch is invalid for the time being...
Comment 6 Steven R. Shaw CLA 2006-06-12 09:39:04 EDT
I'll verify this against 145877 and close / duplicate accordingly...
Comment 7 Steven R. Shaw CLA 2006-06-12 11:48:31 EDT
Verified that issue was resolved with 145877.

*** This bug has been marked as a duplicate of 145877 ***
Comment 8 Steven R. Shaw CLA 2006-06-12 11:50:02 EDT
wrong duplicate
Comment 9 Steven R. Shaw CLA 2006-06-12 11:50:42 EDT
changed to proper duplicate #

*** This bug has been marked as a duplicate of 146341 ***
Comment 10 Richard Gronback CLA 2008-08-13 13:05:50 EDT
[target cleanup] 1.0 RC5 was the original target milestone for this bug
Comment 11 Eclipse Webmaster CLA 2010-07-19 12:26:21 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug