Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 235479

Summary: OperationCanceledException when opening task
Product: z_Archived Reporter: Mik Kersten <mik.kersten>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P2 CC: robert.elves, shawn.minto, steffen.pingel, thomas.ehrnhoefer
Version: unspecified   
Target Milestone: 3.4   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 154396, 334302    
Attachments:
Description Flags
throw core exception when cancelled
none
work-around
none
mylyn/context/zip
none
fix life-lock none

Description Mik Kersten CLA 2008-06-03 17:24:54 EDT
I was opening several bugs in succession and got this.  Not sure of priority so marking P1 for now.

org.eclipse.core.runtime.OperationCanceledException
	at org.eclipse.mylyn.internal.tasks.core.TaskList.lock(TaskList.java:643)
	at org.eclipse.mylyn.internal.tasks.core.TaskList.run(TaskList.java:616)
	at org.eclipse.mylyn.internal.tasks.core.TaskList.run(TaskList.java:610)
	at org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager.getWorkingCopy(TaskDataManager.java:144)
	at org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage.createModel(AbstractTaskEditorPage.java:460)
	at org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage.createModel(BugzillaTaskEditorPage.java:84)
	at org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage.init(AbstractTaskEditorPage.java:874)
	at org.eclipse.ui.forms.editor.FormEditor.registerPage(FormEditor.java:677)
	at org.eclipse.ui.forms.editor.FormEditor.configurePage(FormEditor.java:365)
	at org.eclipse.ui.forms.editor.FormEditor.addPage(FormEditor.java:216)
	at org.eclipse.mylyn.tasks.ui.editors.TaskEditor.addPages(TaskEditor.java:192)
	at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:146)
	at org.eclipse.ui.forms.editor.SharedHeaderFormEditor.createPages(SharedHeaderFormEditor.java:97)
	at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:310)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:661)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:428)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
	at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:266)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2820)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2729)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2721)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2673)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2668)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2652)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2635)
	at org.eclipse.mylyn.tasks.ui.TasksUiUtil.openEditor(TasksUiUtil.java:172)
	at org.eclipse.mylyn.tasks.ui.TasksUiUtil.openTask(TasksUiUtil.java:286)
	at org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal.refreshAndOpenTaskListElement(TasksUiInternal.java:219)
	at org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskListElementAction.runWithEvent(OpenTaskListElementAction.java:52)
	at org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskListElementAction.run(OpenTaskListElementAction.java:41)
	at org.eclipse.mylyn.internal.tasks.ui.views.TaskListView$20.open(TaskListView.java:1433)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:820)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:880)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:818)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1079)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1183)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:263)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:257)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:297)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3821)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:112)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Comment 1 Steffen Pingel CLA 2008-06-03 22:18:19 EDT
The UI thread was interrupted while waiting for the task list lock. I can reproduce this in the debugger when setting a break point in TaskList.lock() and opening an editor:

Thread [Worker-8] (Suspended (breakpoint at line 841 in Thread))	
	Thread.interrupt() line: 841	
	UILockListener.interruptUI() line: 166	
	UISynchronizer.syncExec(Runnable) line: 166	
	Display.syncExec(Runnable) line: 4018	
	ActivityContextManager.getStructureHandle() line: 224	
	ActivityContextManager.addMonitoredActivityTime(long, long) line: 107	
	ActivityContextManager.access$10(ActivityContextManager, long, long) line: 103	
	ActivityContextManager$CheckActivityJob.run(IProgressMonitor) line: 193	
	Worker.run() line: 55	

How frequently is addMonitoredActivityTime() invoked? I am not sure that it's a good idea to use Display.syncExec(). The active working set could be tracked with a listener for instance and stored in a field on the class.
Comment 2 Robert Elves CLA 2008-06-04 18:00:00 EDT
Created attachment 103661 [details]
throw core exception when cancelled

We either need to throw this as a core exception (as in the patch) or simply ignore all together. This patch throws the core exception with CANCEL status.
Comment 3 Robert Elves CLA 2008-06-12 16:03:57 EDT
Haven't had this happen but will keep this report alive for 3.1 in case we get more input on it.
Comment 4 Steffen Pingel CLA 2008-06-16 20:27:31 EDT
*** Bug 237386 has been marked as a duplicate of this bug. ***
Comment 5 Steffen Pingel CLA 2008-06-17 19:01:48 EDT
The saving interval of the task list is now 42 seconds which should decrease the chances of this happening but we will need to investigate a proper solution for 3.0.1.
Comment 6 Steffen Pingel CLA 2008-08-11 19:22:19 EDT
I have committed a work around for 3.0.2 to retry once but this operation should be moved into a job instead.
Comment 7 Mik Kersten CLA 2008-08-19 13:00:47 EDT
Is there any chance that for 3.0.2 a task will fail to open and end up with that blank editor whose tab says "label"? 
Comment 8 Steffen Pingel CLA 2008-08-19 13:33:48 EDT
I haven't seen this since the fix was committed but, yet, there is a slight chance, if the task list saving takes longer than 6 seconds for instance.
Comment 9 Mik Kersten CLA 2008-09-04 14:14:03 EDT
I don't think I've seen it since either.
Comment 10 Steffen Pingel CLA 2008-09-08 22:54:03 EDT
*** Bug 246596 has been marked as a duplicate of this bug. ***
Comment 11 Steffen Pingel CLA 2010-02-05 22:55:20 EST
Created attachment 158369 [details]
work-around
Comment 12 Steffen Pingel CLA 2010-02-05 22:55:30 EST
Created attachment 158370 [details]
mylyn/context/zip
Comment 13 Steffen Pingel CLA 2010-02-05 22:58:46 EST
I have committed the attached work-around. Fixing the underlying problem would require moving all code that runs on the UI thread and acquires task list locks to run on separate threads to avoid interruptions. That is a large refactoring and out of the scope of the current milestone.
Comment 14 Steffen Pingel CLA 2010-02-15 13:42:03 EST
Created attachment 159121 [details]
fix life-lock
Comment 15 Steffen Pingel CLA 2011-05-16 11:36:12 EDT
*** Bug 342878 has been marked as a duplicate of this bug. ***
Comment 16 Steffen Pingel CLA 2012-09-23 19:51:35 EDT
I have opened bug 390159 to track further improvements since we still have tests failing intermittently because of this problem.