Bug 234744 - Java builds block save (bug with patch)
Summary: Java builds block save (bug with patch)
Status: CLOSED DUPLICATE of bug 329657
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-29 18:36 EDT by Zorzella Mising name CLA
Modified: 2016-02-25 10:45 EST (History)
15 users (show)

See Also:


Attachments
Initial Patch (21.94 KB, patch)
2008-05-29 18:36 EDT, Zorzella Mising name CLA
no flags Details | Diff
Patch (Version #2, HEAD as of 2008-10-20 4:15 p.m. PDT) (88.74 KB, patch)
2008-10-20 19:17 EDT, Zorzella Mising name CLA
no flags Details | Diff
BlockedOnJavaBuild0.png (30.87 KB, image/png)
2015-07-07 13:37 EDT, Zorzella Mising name CLA
no flags Details
BlockedOnJavaBuild1.png (44.11 KB, image/png)
2015-07-07 13:38 EDT, Zorzella Mising name CLA
no flags Details
BlockedOnExternalBuild0.png (22.45 KB, image/png)
2015-07-07 13:39 EDT, Zorzella Mising name CLA
no flags Details
BlockedOnExternalBuild1.png (32.76 KB, image/png)
2015-07-07 13:39 EDT, Zorzella Mising name CLA
no flags Details
BlockedOnExternalBuild2.png (29.44 KB, image/png)
2015-07-07 13:39 EDT, Zorzella Mising name CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zorzella Mising name CLA 2008-05-29 18:36:18 EDT
Created attachment 102774 [details]
Initial Patch

Steps To Reproduce:
0. Choose a large project
1. Make a change to a file with lots of dependents
2. Press Ctrl+S to launch auto build
3. Quickly make another change to the file and press Ctrl+S to save

Notice that a blocking dialog appears.  The desired result is that no blocking dialog appears, and that the save progresses unhindered.  For a long time we've desired to be able to save and build at the same time, since, in large projects, it is more than inconvenient that these operations block each other.

Douglas and I have attempted to provide a patch indicating a suggested fix.  The patch is not complete, but we offer it here for discussion.

The idea is to run builds without the workspace lock, and then to launch a write job from within the build.  This write job will acquire a lock, write the new contents of the file and release the lock.

Current issues:
+ The write job is asynchronous and so as the build progresses, it could potentially be reading stale information.  Perhaps this can be fixed with a call to join.
+ The write job acquires the complete workspace lock.  Is this really necessary?
+ We have taken a shortcut in that Rules.buildRule() has been modified.  This strikes us as a potential API violation.  Perhaps the correction solution is to create a buildRule2() function.  Builders that can safely run in this environment can then update to use buildRule2() instead.  Another alternative to that is to provide for a "Preference" that configures this new behaviour.


The patch likely has several problems, as the code is complex.  But if you provide input, we would be happy to continue working on this.
Comment 1 John Arthorne CLA 2008-08-18 17:17:39 EDT
Adding Kent to CC for comment on the Java builder, since this patch is mostly on the java builder.

My guess is that it would be very difficult to implement a builder that would work correctly without at least locking the project being built.  This patch may appear to work but I'm sure there are cases where it will produce incorrect results because it has no consistent point of reference to build against. For example it may resolve a reference to a method and create byte codes based on that reference, and then if the method was deleted concurrently the binding could be incorrect, resulting in linkage errors at runtime. To get a correct result, it would need to throw away its progress so far and restart the build after any concurrent change.
Comment 2 Zorzella Mising name CLA 2008-08-18 23:42:08 EDT
I don't see why there would be a need to cancel an ongoing build to achieve correctness: any change to, say in your example, a method while a build is running will trigger another build. That second build will be "locked" (i.e. not eligible to run, for it can't acquire the lock) until the first build finishes. But, when that does, it will proceed, and it will operate on the correct deltas, and recompile the transitive dependencies. What am I missing?
Comment 3 Zorzella Mising name CLA 2008-10-20 18:13:08 EDT
ping
Comment 4 Zorzella Mising name CLA 2008-10-20 19:17:49 EDT
Created attachment 115645 [details]
Patch (Version #2, HEAD as of 2008-10-20 4:15 p.m. PDT)

Merged to head around 4:15 p.m. (PDT) and rebuilt the patch.
Comment 5 Zorzella Mising name CLA 2008-10-20 19:19:15 EDT
Comment on attachment 115645 [details]
Patch (Version #2, HEAD as of 2008-10-20 4:15 p.m. PDT)

Wrong bug
Comment 6 Szymon Brandys CLA 2008-10-21 04:30:05 EDT
I've looked only at core.resources part of the patch.

BuildSchedulingRule doesn't contain the workspace rule which is needed to send PRE and POST_BUILD events. See AutoBuildJob#doBuild.

If you register a listener for either of those events and you try to modify workspace inside, you will get "Attempted to beginRule: [some workspace rule], does not match outer scope rule: BuildSchedulingRule" surely.
Comment 7 Szymon Brandys CLA 2008-10-21 04:40:07 EDT
Similar issue is bug 198591. See bug 198591, comment 13.
Comment 8 Zorzella Mising name CLA 2008-10-27 19:01:45 EDT
Would it be possible to grab the workspace lock for the PRE_BUILD, then drop.  Grab the build lock for the build, then drop.  And then grab the workspace lock for the POST_BUILD again, and then drop?
Comment 9 John Arthorne CLA 2008-10-27 19:42:40 EDT
Re comment #8: yes, this is what the latest patch in bug 198591 does.

I talked about your general strategy with the lead developer of the incremental Java builder the other day. His belief was that this will probably work most of the time, but could easily be made to break due to particular assumptions made by the Java builder. Notably, the Java builder currently assumes that the delta it receives accurately describes the state of its prerequisite projects at the time that builder started. For example if the delta indicates that resource "X" was ADDED or CHANGED, the builder will assume that X currently exists (otherwise it would have received a REMOVED delta). The Java builder also maintains a binary representation of a project's "built state", and assumes that the "built state" of prerequisite projects accurately describes the current state of that project's class files during a workspace build. If this assumption is violated it could easily result in exceptions in the builder logic.

All of this is not to say that the strategy cannot work - just that it breaks assumptions that builders can safely make today. The approach Szymon is taking in bug 198591 is to introduce the ability for builders to specify their own scheduling rule. If a builder decides it can live in a fully dynamically changing world it can use a scheduling rule of "null", and this would then result in the fully non-blocking behaviour you're looking for.
Comment 10 Szymon Brandys CLA 2008-11-04 09:23:52 EST
My impression is that this is a duplicate of bug 198591.
Comment 11 Szymon Brandys CLA 2008-11-04 12:21:18 EST

*** This bug has been marked as a duplicate of bug 198591 ***
Comment 12 Stefan Xenos CLA 2015-06-25 13:58:26 EDT
Reopening, since bug 198591 has been marked as fixed and yet it is still not possible to save a java editor while a build is going on.
Comment 13 Szymon Ptaszkiewicz CLA 2015-06-29 06:49:26 EDT
(In reply to Stefan Xenos from comment #12)
> Reopening, since bug 198591 has been marked as fixed and yet it is still not
> possible to save a java editor while a build is going on.

This bug and bug 198591 are about making it possible to use a custom build scheduling rule and this was fixed. Since that time there were many different changes improving the save editor experience while Java build is running (including recent fix for bug 454698/bug 60964), so if you are still seeing some delays when saving, please open a new bug and provide steps how to reproduce your problem.

*** This bug has been marked as a duplicate of bug 198591 ***
Comment 14 Stefan Xenos CLA 2015-07-06 10:48:37 EDT
> so if you are still seeing some delays when saving, please open a new 
> bug and provide steps how to reproduce your problem.

Using the steps from comment 0 I can still reproduce this problem:

Steps To Reproduce:
0. Choose a large project
1. Make a change to a file with lots of dependents
2. Press Ctrl+S to launch auto build
3. Quickly make another change to the file and press Ctrl+S to save


> This bug and bug 198591 are about making it possible to use a custom 
> build scheduling rule and this was fixed.

Bug 198591 was about the ability to add custom scheduling rules. This bug is about making the steps to reproduce in comment 0 work correctly and they do not. 

My reasoning is as follows:
1. The content of comment 0 and any subsequent clarifications from the original poster describes what the bug is about.
2. The steps to reproduce in comment 0 still reproduce the problem.
3. There was no follow-up correction from the original poster indicating that he indended anything other than the steps from comment 0.

If you believe this to be fixed, please describe which part of my reasoning you disagree with. Do you disagree with the factual claim that the steps to reproduce still demonstrate the problem? Do you disagree with the general principle that the description provided by the original poster is what a bug is about? Or did you see a comment from the original poster indicating that the original steps to reproduce were incorrect or incomplete?
Comment 15 Stefan Xenos CLA 2015-07-06 10:50:24 EDT
Note that the bug description mentions Java builds, so it's a reasonable assumption that step 1 in comment 0 is meant to refer to a .java file.
Comment 16 Stefan Xenos CLA 2015-07-06 12:49:54 EDT
Let me rephrase. I disagree with this claim:

> This bug and bug 198591 are about making it possible to use a custom
> build scheduling rule

Since I see no comment in this bug from "Z" Zorzella indicating that he was either interested in the ability to use custom build scheduling rules or that he was no longer interested in the steps to reproduce posted in comment 0.
Comment 17 Zorzella Mising name CLA 2015-07-07 13:36:20 EDT
Hey, Zorzella here.

FWIW, the problem still exists. It's less painful than it used to be, but the java build still blocks saves. External builds also block saves. My dream would be that Eclipse would never stop me from saving my files, and addressing it for the java builder that was the original intent of this bug (and patch).

FWIW as well, I'll attach here a few screenshots of the progress bar that pops up if you try to save when Eclipse is compiling (taken with Eclipse 4.5). Two of the screenshots are saves that are blocked on the java builder, and the other three are blocked on external builders (as per their names).
Comment 18 Zorzella Mising name CLA 2015-07-07 13:37:08 EDT
Created attachment 255035 [details]
BlockedOnJavaBuild0.png
Comment 19 Zorzella Mising name CLA 2015-07-07 13:38:34 EDT
Created attachment 255036 [details]
BlockedOnJavaBuild1.png
Comment 20 Zorzella Mising name CLA 2015-07-07 13:39:04 EDT
Created attachment 255037 [details]
BlockedOnExternalBuild0.png
Comment 21 Zorzella Mising name CLA 2015-07-07 13:39:21 EDT
Created attachment 255038 [details]
BlockedOnExternalBuild1.png
Comment 22 Zorzella Mising name CLA 2015-07-07 13:39:40 EDT
Created attachment 255039 [details]
BlockedOnExternalBuild2.png
Comment 23 Szymon Ptaszkiewicz CLA 2016-02-24 10:37:44 EST
(In reply to Stefan Xenos from comment #16)
> Let me rephrase. I disagree with this claim:
> 
> > This bug and bug 198591 are about making it possible to use a custom
> > build scheduling rule

The whole discussion in this bug including the patch proposed by "Z" Zorzella in comment 0 concentrate around changing build rules. I didn't say the steps in comment 0 are not valid or they do not allow to reproduce a problem only that the approach which was discussed here is already implemented.

> Since I see no comment in this bug from "Z" Zorzella indicating that he was
> either interested in the ability to use custom build scheduling rules

This was mentioned in comment 0:

>> + We have taken a shortcut in that Rules.buildRule() has been modified.

and it confirms "Z" Zorzella and follow up comments discussed making build rule more flexible, regardless of how it related to original steps to reproduce the problem. Making build rule more flexible was fixed in bug 198591. See comment 9 which clarifies the relation.

> or that he was no longer interested in the steps to reproduce posted in
> comment 0.

I fully agree, but reopening the bug after many years where almost all comments of the bug refer to something that is already implemented does not help in narrowing down the problem. The problem that Java builder may block user action is still alive and it is tracked in bug 329657, so if you really want to monitor the "Java builder may block user action" problem, then please subscribe to bug 329657 because it contains more relevant discussion than this bug.

I'm marking this bug as duplicate of 198591 again because this is the one which contains the fix for making build rules more flexible which was discussed here.

*** This bug has been marked as a duplicate of bug 198591 ***
Comment 24 Dani Megert CLA 2016-02-25 10:45:08 EST
I agree that the discussion went a bit into a different direction, but as said in this bug, the fix for bug 198591 does not solve the problem for the Java builder and other builders, as they cannot easily use a smaller lock. Let's mark this bug as duplicate of bug 329657, which captures the originally reported problem and has some interesting discussions.

*** This bug has been marked as a duplicate of bug 329657 ***