Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 405542 - [Workbench] More than one workbench save job can run
Summary: [Workbench] More than one workbench save job can run
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.5 M6   Edit
Assignee: Snjezana Peco CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-12 03:54 EDT by Dani Megert CLA
Modified: 2015-02-13 07:34 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2013-04-12 03:54:14 EDT
The code which starts the workbench save job does not wait for the previous one to be finished. As a result, more than one job could theoretically run in parallel (happened to me while debugging). This can cause a problem if the code it executes, is not thread-safe or locks resources (deadlock?).
Comment 1 Snjezana Peco CLA 2013-04-12 08:08:19 EDT
There are two jobs with a similar name: the "Workbench Auto-Save Job"  and  "Workbench Auto-Save Background Job" job.
The "Workbench Auto-Save Job" job is created only once and runs in the UI thread.

The "Workbench Auto-Save Job" job creates a new job - "Workbench Auto-Save Background Job" that doesn't run in the UI thread so there could be more "Workbench Auto-Save Background Job" jobs at the same time (org.eclipse.ui.internal.Workbench.persistWorkbenchModel). 
That is reproducible when debugging.
It may be that you have seen the "Workbench Auto-Save Background Job" jobs. 
The "Workbench Auto-Save Job" job should check if the "Workbench Auto-Save Background Job" job is started and create a new job only if it doesn't exist.
Comment 2 Dani Megert CLA 2013-04-12 08:13:49 EDT
(In reply to comment #1)
> There are two jobs with a similar name: the "Workbench Auto-Save Job"  and 
> "Workbench Auto-Save Background Job" job.
> The "Workbench Auto-Save Job" job is created only once and runs in the UI
> thread.
> 
> The "Workbench Auto-Save Job" job creates a new job - "Workbench Auto-Save
> Background Job" that doesn't run in the UI thread so there could be more
> "Workbench Auto-Save Background Job" jobs at the same time
> (org.eclipse.ui.internal.Workbench.persistWorkbenchModel). 
> That is reproducible when debugging.
> It may be that you have seen the "Workbench Auto-Save Background Job" jobs. 

I won't argue about how the job's are labelled ;-). This bug is about the SAVE job i.e. the job that actually does the work and saves the state. I think this should be clear, especially, when one looks at the code.
Comment 3 Paul Webster CLA 2013-04-12 08:38:37 EDT
They don't lock or depend on state that can change underneath them and cause a problem (the second job operates entirely on a copy).

But we should still probably limit them so they don't crash into one another.

PW
Comment 4 Snjezana Peco CLA 2014-11-07 11:33:47 EST
I have created a patch : https://git.eclipse.org/r/36151
Comment 5 Lars Vogel CLA 2015-02-05 07:29:36 EST
(In reply to Snjezana Peco from comment #4)
> I have created a patch : https://git.eclipse.org/r/36151

Snjezana, I think your change could lead to UI freezes, if the save job is running very long. I think a safer way is to use the new JobGroup API with a pool size of one. I updated your review with the change. Could you have a look at let me know what you are thinking?
Comment 6 Snjezana Peco CLA 2015-02-05 11:03:54 EST
(In reply to Lars Vogel from comment #5)
> (In reply to Snjezana Peco from comment #4)
> > I have created a patch : https://git.eclipse.org/r/36151
> 
> Snjezana, I think your change could lead to UI freezes, if the save job is
> running very long. I think a safer way is to use the new JobGroup API with a
> pool size of one. I updated your review with the change. Could you have a
> look at let me know what you are thinking?


I have updated the patch.
Comment 8 Lars Vogel CLA 2015-02-06 04:00:12 EST
Thanks Snjezana for your work and persistence. Sorry for being slow in reviewing this one.
Comment 9 Eclipse Genie CLA 2015-02-10 09:16:07 EST
New Gerrit change created: https://git.eclipse.org/r/41523
Comment 10 Snjezana Peco CLA 2015-02-10 11:14:30 EST
https://git.eclipse.org/r/#/c/41523 fixes the issue without using JobGroup.

For more details see the discussion on https://git.eclipse.org/r/#/c/36151/
Comment 12 Dani Megert CLA 2015-02-13 07:34:43 EST
Thanks Snjezana.