Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 230386 - [ui] Processing of repository addition events blocking uninstall
Summary: [ui] Processing of repository addition events blocking uninstall
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 RC1   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 230379 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-05-06 09:06 EDT by Michael Scharf CLA
Modified: 2008-11-13 20:52 EST (History)
3 users (show)

See Also:
john.arthorne: review+


Attachments
the stack where it "hangs" (28.23 KB, text/plain)
2008-05-06 09:06 EDT, Michael Scharf CLA
no flags Details
screenshhot (84.87 KB, image/gif)
2008-05-06 09:10 EDT, Michael Scharf CLA
no flags Details
patch with suggested changes (7.74 KB, patch)
2008-05-06 19:32 EDT, Susan McCourt CLA
no flags Details | Diff
this one includes the NLS changes (9.58 KB, patch)
2008-05-07 12:04 EDT, Susan McCourt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Scharf CLA 2008-05-06 09:06:00 EDT
Created attachment 98826 [details]
the stack where it "hangs"

I took 1 h to finish.
Comment 1 Michael Scharf CLA 2008-05-06 09:10:00 EDT
Created attachment 98827 [details]
screenshhot
Comment 2 John Arthorne CLA 2008-05-06 10:30:02 EDT
Susan, can you take a look at this stack dump? Two strange things that jumped out at me:

 - Does the UI need to use a synchronous listener on the event bus? This is causing another thread that is trying to publish an event to be blocked.
 - Why does the UI need to load the repository here? I would think the repository would be displayed as a collapsed node in the available software tab. Perhaps Michael was in the group by category or name mode.

It's a mystery why there are repository ADD events happened here at all. They might be events from a previous install operation that are still running. Michael, had you just recently installed something new before doing the uninstall?
Comment 3 Michael Scharf CLA 2008-05-06 10:40:29 EDT
Be fore that, I added the feature I tried to uninstall (see bug 230379).
Comment 4 Susan McCourt CLA 2008-05-06 12:09:34 EDT
> - Does the UI need to use a synchronous listener on the event bus? This is
>causing another thread that is trying to publish an event to be blocked.
It is not necessary, it has probably always been this way.  Since any UI work must be done in the UI thread anyway, most work is dispatched to a UI asynch anyway.  I can change this.

> - Why does the UI need to load the repository here? I would think the
>repository would be displayed as a collapsed node in the available software
>tab. 
This was a usability issue.  Users wanted to be able to see the added content right away rather than searching for it in a collapsed tree, especially if it appeared in the "Other" category where they had no idea where to look.  (For example bug 225326 comment 3.  See also bug 216028 comment 18 and bug 216028 comment 24). 

>It's a mystery why there are repository ADD events happened here at all. They
>might be events from a previous install operation that are still running.
>Michael, had you just recently installed something new before doing the
>uninstall?

>Before that, I added the feature I tried to uninstall

So it sounds to me like the add event is expected.
I think the thing to do here is:
1) change the listener to be asynchronous
2) perform the load in a job and then do the expand/visible work when the job is done.  

I knew I was cheating when I did the load in the event handler..this is from the code

		// We rely on the fact that repository addition happens
		// in a job.  We would get burned by this assumption if other
		// code adds repositories in the UI thread.
		// For now we assume that loading the repo while receiving
		// the add event won't block the UI.  Do this
		// first before expanding.
Comment 5 John Arthorne CLA 2008-05-06 12:15:15 EDT
Updated title to reflect the issue.
Comment 6 John Arthorne CLA 2008-05-06 16:55:40 EDT
*** Bug 230379 has been marked as a duplicate of this bug. ***
Comment 7 Susan McCourt CLA 2008-05-06 19:32:48 EDT
Created attachment 98981 [details]
patch with suggested changes

>1) change the listener to be asynchronous
done
>2) perform the load in a job and then do the expand/visible work when the job
>is done.  
the refresh of the view is immediate since the user wants to see the new URL show up in the list (or Pending... if not viewing by site).  Then the load is done in a job, and when the job is done, the expansion is done if the user hasn't already tried to expand something, or if some other load job hasn't already been started.  This ensures that the repo only gets expanded automatically iff 
- the repo is the most recent one added
- the user hadn't already expanded or collapsed something manually
Comment 8 Susan McCourt CLA 2008-05-06 19:35:16 EDT
John, can you please review this patch?
I've run with it for awhile today and it seems to be working well.  Of course, I could not reproduce the deadlock consistently, but I can say I haven't seen it since the patch, and in general it seems a lot snappier adding repos now that the first refresh happens instantly.

One change I plan to make that is not shown in the patch is externalizing the job name.  I didn't do that because I have bunch of NLS catalog changes in my workspace associated with a different patch waiting for review.  I'll externalize the string once the unrelated changes are released.
Comment 9 Susan McCourt CLA 2008-05-07 12:04:40 EDT
Created attachment 99110 [details]
this one includes the NLS changes
Comment 10 John Arthorne CLA 2008-05-07 15:28:37 EDT
+1, looks good.

The main risk to me is the possibility of side-effects from switching to an asnchronous provisioning event listener. However, it looks like the listener and subclasses do all their work in an asyncExec anyway, so this should be ok.
Comment 11 Susan McCourt CLA 2008-05-07 15:53:30 EDT
Released to HEAD >20080507