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

Bug 265047

Summary: Validation Framework does not wait for validation jobs to end before shutting down
Product: [WebTools] WTP Common Tools Reporter: Min Idzelis <min123>
Component: wst.validationAssignee: Wini Mark <wmmark>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: major    
Priority: P3 CC: ccc, david_williams, deboer, karasiuk, valentinbaciu, wmmark
Version: 3.0Flags: david_williams: pmc_approved+
ccc: pmc_approved? (raghunathan.srinivasan)
ccc: pmc_approved? (naci.dai)
wmmark: pmc_approved?
ccc: pmc_approved? (neil.hauge)
ccc: pmc_approved? (kaloyan)
ccc: review+
Target Milestone: 3.2 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
delay the shutdown patch none

Description Min Idzelis CLA 2009-02-16 14:08:11 EST
Build ID: WTP 3.0.1

Steps To Reproduce:
1) Create a large workspace. 
2) Perform a clean-build. 
3) Ensure validation starts occuring in the background. 
4) Shutdown the workbench

Various errors will occur because the validators are still running after many components are closed. 

Solution: join() the worker jobs in the validation framework stop() method. 

More information:
Comment 1 Gary Karasiuk CLA 2010-05-26 15:59:10 EDT
Created attachment 170090 [details]
delay the shutdown patch
Comment 2 Wini Mark CLA 2010-05-27 10:32:40 EDT
Thanks Gary. I have tested with the patch with deleting the resource during the validation, and it works and there is no errors in the .log. I also run some regression test (Build validation and manual validation on some projects, e.g. EE and web project).
Comment 3 Carl Anderson CLA 2010-05-27 10:39:20 EDT
I approve of this patch.
Comment 4 Carl Anderson CLA 2010-05-27 10:46:56 EDT
This is a nasty bug due to the errors that occur when the Validation Framework stops before validation has finished.

There is no workaround.
 
This was tested by hand, as documented in comment #2

Simply put, the solution is for the Validation Framework to do a join() with the validation job, thus ensuring that the Framework does not terminate until the Validation is finished.  Wini Mark and myself have reviewed Gary's patch.

This is a low risk fix, limited only to the Validation Framework.
Comment 5 Tim deBoer CLA 2010-05-27 11:04:17 EDT
What happens if you open a large workspace and then decide to close it right away after validation has kicked off? Does it just block for the currently running validator, or do you have to wait (potentially a very long time) for the full workspace to finish validation?
Comment 6 Gary Karasiuk CLA 2010-05-27 12:01:53 EDT
(In reply to comment #5)
I believe that the behavior would now be similar to what happens if you were in the middle of a build ... the workbench would not shutdown until the operation finished.

I haven't tried this, but I think you would still have a progress monitor running, and you could cancel the validation job, to speed up the shutdown.
Comment 7 Gary Karasiuk CLA 2010-05-27 12:06:21 EDT
(In reply to comment #6)
I think it is too late in the cycle to do anything fancier than this, but in the next release, I think there should be way to "hibernate" validation, so that the shutdown is not delayed.
Comment 8 Tim deBoer CLA 2010-05-27 14:13:13 EDT
Sorry to prolong this, but can someone confirm that cancelling the job has reasonable behaviour? (i.e. perhaps a single validator won't cancel immediately, but when moving to a new validator or new project the framework does cancel appropriately and exit) Just want to make sure we're not causing the equivalent of a 'hang' on shutdown.
Comment 9 Tim deBoer CLA 2010-05-27 14:17:17 EDT
Based on Valentin's comments in the weekly WTP call, the individual validators should respond to cancelation appropriately, and if not the framework will check between validators. +1
Comment 10 Gary Karasiuk CLA 2010-05-27 14:22:18 EDT
(In reply to comment #8)
> Sorry to prolong this, but can someone confirm that cancelling the job has
> reasonable behaviour? (i.e. perhaps a single validator won't cancel
> immediately, but when moving to a new validator or new project the framework
> does cancel appropriately and exit) Just want to make sure we're not causing
> the equivalent of a 'hang' on shutdown.
Wini can you test this?

I'm 95% certain that this will behave as you suggest. All that the patch is doing is joining the job, so if the job is now gone, the shutdown method should exit.
Comment 11 Valentin Baciu CLA 2010-05-27 14:25:04 EDT
In org.eclipse.wst.validation.internal.ValManager.accept(IValidatorVisitor, IProject, ValType, ValOperation, IProgressMonitor), the code checks for the progress monitor isCanceled() and returns.

	public void accept(IValidatorVisitor visitor, IProject project, ValType valType, 
		ValOperation operation, IProgressMonitor monitor){
		
		if (isDisabled(project))return;
		
		for (Validator val : getValidators(project)){
			if (monitor.isCanceled())return;
.....
Comment 12 Wini Mark CLA 2010-05-27 14:39:34 EDT
(In reply to comment #10)
> (In reply to comment #8)
> > Sorry to prolong this, but can someone confirm that cancelling the job has
> > reasonable behaviour? (i.e. perhaps a single validator won't cancel
> > immediately, but when moving to a new validator or new project the framework
> > does cancel appropriately and exit) Just want to make sure we're not causing
> > the equivalent of a 'hang' on shutdown.
> Wini can you test this?
> 
> I'm 95% certain that this will behave as you suggest. All that the patch is
> doing is joining the job, so if the job is now gone, the shutdown method should
> exit.

I run a simple test that I click the 'cancel' in the progress dialog and the validation job is canceled and the workspace is shut down pretty quickly and I don't see the 'hang'.
Comment 13 Carl Anderson CLA 2010-05-27 14:48:32 EDT
Committed to HEAD for WTP 3.2 RC3
Comment 14 David Williams CLA 2010-05-27 15:40:59 EDT
Wini, you accidentally reset the pmc approved flags to '?'. 

Its a bugzilla/webpage problem. Even if you hit 'refresh' sometimes, its doesn't correctly pick up flag changes, and doesn't show them as "midair collision". I've found it helps to actually click on the bug number at top of bug report to make sure it loads completely fresh fields. 

But, its all in history if there's ever any doubt. 

Thanks again for fixing this!
Comment 15 Wini Mark CLA 2010-05-27 15:45:36 EDT
David, sorry for causing the confusion. I will remember not to do the refresh and click on the bug number in the future :)  Thanks.