Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 280053 - [Build] Build shouldn't allocate progress for closed projects
Summary: [Build] Build shouldn't allocate progress for closed projects
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.6 M2   Edit
Assignee: Pawel Pogorzelski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 45071 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-12 04:55 EDT by Doug CLA
Modified: 2009-09-08 09:25 EDT (History)
4 users (show)

See Also:


Attachments
Patch for BuildManager (1.66 KB, patch)
2009-06-12 05:02 EDT, Doug CLA
pawel.pogorzelski1: iplog+
Details | Diff
Patch with a test (4.10 KB, patch)
2009-08-28 08:57 EDT, Pawel Pogorzelski CLA
no flags Details | Diff
Patch_v02 (1.42 KB, patch)
2009-08-28 11:53 EDT, Pawel Pogorzelski CLA
no flags Details | Diff
Patch_v02 tests (4.12 KB, patch)
2009-08-28 11:54 EDT, Pawel Pogorzelski CLA
no flags Details | Diff
Patch_v03 (1.88 KB, patch)
2009-08-31 09:31 EDT, Pawel Pogorzelski CLA
no flags Details | Diff
Patch_v04 (2.24 KB, patch)
2009-08-31 10:42 EDT, Pawel Pogorzelski CLA
no flags Details | Diff
Patch_v05 (1.01 KB, patch)
2009-09-02 08:45 EDT, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Doug CLA 2009-06-12 04:55:47 EDT
The BuildManager class does not check whether projects are open before adding them to the list of projects to build.

This means that if you have two projects in your workspace, one open and one closed, the progress monitor will slowly reach 50% as it builds the open project but then just jump to 100% as it 'builds' the closed project.
Comment 1 Doug CLA 2009-06-12 05:02:27 EDT
Created attachment 139009 [details]
Patch for BuildManager

The patch removes inaccessible projects from the list of projects to be built.
Comment 2 John Arthorne CLA 2009-06-12 11:46:19 EDT
*** Bug 45071 has been marked as a duplicate of this bug. ***
Comment 3 Doug CLA 2009-08-27 04:51:31 EDT
Just checking, has there been any progress on this?

Thanks.
Comment 4 Pawel Pogorzelski CLA 2009-08-28 08:57:07 EDT
Created attachment 145928 [details]
Patch with a test

(In reply to comment #3)
> Just checking, has there been any progress on this?
> 
> Thanks.
> 

The patch works fine. In addition I wrote a test for this functionality.

Szymon, please review it.
Comment 5 Krzysztof Daniel CLA 2009-08-28 09:22:44 EDT
I have looked at the bug some time ago and was not quite sure about the patch.

At this point in BuildManager it was quite possible that projects can change their state (be closed or opened), so allocating progress is safe. But if you remove closed projects something may not be built.

Someone please check my doubts...
Comment 6 Pawel Pogorzelski CLA 2009-08-28 09:37:21 EDT
(In reply to comment #5)
> I have looked at the bug some time ago and was not quite sure about the patch.
> 
> At this point in BuildManager it was quite possible that projects can change
> their state (be closed or opened), so allocating progress is safe. But if you
> remove closed projects something may not be built.
> 
> Someone please check my doubts...
> 

It's not possible for other threads to change projects state since build executes within a rule that prevents this from happening. So it could only be done by a builder itself. Since I'm not aware of such case it's probably more accurate to exclude closed projects from total work calculation.

The default build rule can be changed by providing custom rule factory but in such case projects could be closed at any stage of the build.
Comment 7 Pawel Pogorzelski CLA 2009-08-28 09:44:01 EDT
Actually, according to Chris comment it would be better to change the fix proposed by Doug to exclude closed projects only from total work calculation. Right now they are excluded from the list of projects to build.

Szymon, what do you think? If you agree I'll prepare a patch.
Comment 8 Szymon Brandys CLA 2009-08-28 10:00:35 EDT
On second thoughts I think the current behavior is fine. Since closed projects can change their states during a build, we should allocate progress for them too. If we apply any of suggested fixes, we can end up with "too short" progress regarding the real amount of work to perform.
Comment 9 Doug CLA 2009-08-28 10:01:11 EDT
I think the current patch is correct. When a user opens a closed project, a build gets scheduled for it. So it is unnecessary to include closed projects in the current build.
Comment 10 Krzysztof Daniel CLA 2009-08-28 10:20:35 EDT
Thanks for explanations :)
Comment 11 Pawel Pogorzelski CLA 2009-08-28 10:28:24 EDT
(In reply to comment #8)
> On second thoughts I think the current behavior is fine. Since closed projects
> can change their states during a build, we should allocate progress for them
> too. If we apply any of suggested fixes, we can end up with "too short"
> progress regarding the real amount of work to perform.
> 

Frankly, I haven't seen opening a project during a build. Os course if such a situation occurs we will actually end up too short with progress. However reporting a progress is more a matter of being accurate in most cases which we fail to do now.
Comment 12 Pawel Pogorzelski CLA 2009-08-28 10:41:06 EDT
(In reply to comment #9)
> I think the current patch is correct. When a user opens a closed project, a
> build gets scheduled for it. So it is unnecessary to include closed projects in
> the current build.
> 

The problem is that in theory a builder could open other projects in the build process and they would be build given the current state of the code. With the patch applied closed projects would be discarded at earlier stage.
Comment 13 Krzysztof Daniel CLA 2009-08-28 10:46:01 EDT
(In reply to comment #11)
> Frankly, I haven't seen opening a project during a build.

I think I have seen it once (but I am not sure and cannot check). RAD/RSA on
first start-up run Migration Builder which adjusts project configuration. And I
bet 1$ that it could open some specific projects to retrieve important data
(especially when it came to jee).

I believe that manipulating total amount of the work is a little bit safer that
removing closed projects from build...
Comment 14 Szymon Brandys CLA 2009-08-28 11:05:19 EDT
(In reply to comment #9)
> I think the current patch is correct. When a user opens a closed project, a
> build gets scheduled for it. So it is unnecessary to include closed projects in
> the current build.

Just to support Pawel.

If autobuild is enabled, it would be fine. Otherwise you could end up with not build projects. 
Let's consider a closed project that contains changes to build and a builder that opens it during a workspace build.
This project will stay unbuilt, when autobuild is disabled.
Comment 15 Pawel Pogorzelski CLA 2009-08-28 11:53:24 EDT
Created attachment 145951 [details]
Patch_v02

Fix changed according to comment 7.
Comment 16 Pawel Pogorzelski CLA 2009-08-28 11:54:28 EDT
Created attachment 145952 [details]
Patch_v02 tests

Patch with tests with minor changes.
Comment 17 Pawel Pogorzelski CLA 2009-08-31 09:31:50 EDT
Created attachment 146062 [details]
Patch_v03

(In reply to comment #15)
> Created an attachment (id=145951) [details]
> Patch_v02
> 
> Fix changed according to comment 7.

I've added a condition not to report more work than total.
Comment 18 Szymon Brandys CLA 2009-08-31 10:34:11 EDT
The fact that projects can be opened or closed during a build makes this issue tricky. We talked with Pawel about it and it seems that the best solution would be:
- to allocate less work per unordered projects
- to update the progress for unordered projects
Comment 19 Pawel Pogorzelski CLA 2009-08-31 10:42:48 EDT
Created attachment 146074 [details]
Patch_v04

The patch allocates 75% on the progress bar for open projects and the remaining 25% for closed.
Comment 20 Doug CLA 2009-08-31 11:00:47 EDT
(In reply to comment #14)
> Let's consider a closed project that contains changes to build and a builder
> that opens it during a workspace build.
> This project will stay unbuilt, when autobuild is disabled.

In the case where a builder opens closed project during a build (BTW, it is highly unlikely and I don't know of any such examples) then the opened project is not guaranteed to get built, is it? Because the build manager may already have gone past that project in its list (and found it to be closed at the point at which it tried to build it).
Comment 21 Doug CLA 2009-09-02 06:06:28 EDT
Any thoughts on my last comment, or have I got things wrong?

Thx
Comment 22 Szymon Brandys CLA 2009-09-02 06:14:11 EDT
(In reply to comment #20)
> In the case where a builder opens closed project during a build (BTW, it is
> highly unlikely and I don't know of any such examples) then the opened project
> is not guaranteed to get built, is it? Because the build manager may already
> have gone past that project in its list (and found it to be closed at the point
> at which it tried to build it).

A builder can request for a rebuild (see BuildManger#requestRebuild). This rebuild may be performed in the same 
basicBuildLoop (BuildManager line 305).

Some builders can open closed projects and request for a rebuild on purpose. So closed projects removed from the list would be ignored during subsequent iterations.
Comment 23 Doug CLA 2009-09-02 06:38:36 EDT
(In reply to comment #22)
> Some builders can open closed projects and request for a rebuild on purpose. So
> closed projects removed from the list would be ignored during subsequent
> iterations.

OK thanks - I didn't know about the rebuild feature. Complicated isn't it!
Comment 24 Szymon Brandys CLA 2009-09-02 08:42:34 EDT
(In reply to comment #23)
> OK thanks - I didn't know about the rebuild feature. Complicated isn't it!

Anyway thanks for looking at it. I think there are other issues to investigate in this area. I would be glad to review any further proposals or fixes.

(In reply to comment #19)
The simplest fix here is to use ordered.length for projectWork. This can be too little for some cases. However even now the progress can exceed ordered.length + unordered.length, if builders request a rebuild.
Comment 25 Szymon Brandys CLA 2009-09-02 08:45:14 EDT
Created attachment 146275 [details]
Patch_v05
Comment 26 Szymon Brandys CLA 2009-09-02 08:46:58 EDT
Patch_v05 released to HEAD.
Comment 27 John Arthorne CLA 2009-09-08 09:25:41 EDT
I believe "unordered" may contain open projects in the case where someone has set an explicit build order (IWorkspaceDescription#setBuildOrder). In this case the fix won't be correct because it allocates no progress for unordered open projects. I think you also need to iterate over the unordered projects at this beginning of this method and increment "projectWork" for each accessible unordered project. For the case of projects that get opened during the build cycle I don't think we need to worry about reserving progress space for this (it will be very rare).