Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiation can be started while workspace is building #2456

Closed
lwrage opened this issue Sep 24, 2020 · 7 comments · Fixed by #2490
Closed

Instantiation can be started while workspace is building #2456

lwrage opened this issue Sep 24, 2020 · 7 comments · Fixed by #2490
Assignees
Milestone

Comments

@lwrage
Copy link
Contributor

lwrage commented Sep 24, 2020

Summary

It is possible to start instantiation while the workspace is building. In that case unresolved references, etc, lead to errors.

Expected and Current Behavior

The instantiation should wait until the build is finished.

Environment

  • OSATE Version: 2.8.0
  • Operating System: Win 10
@AaronGreenhouse
Copy link
Contributor

AaronGreenhouse commented Oct 20, 2020

I wasn't able to make anything bad happen by doing this, but I have figured out how to make the instantiation jobs wait for the builder to finish.

See DebugUIPlugin.launchInBackground() for how to do this.

@AaronGreenhouse
Copy link
Contributor

AaronGreenhouse commented Oct 20, 2020

This needs to branch from the Issue #841 branch so that everything that instantiates can take advantage of the waiting.

Created branch 2456_no_instantiation_during_build rooted at branch 841_instantiate_on_analysis

@AaronGreenhouse
Copy link
Contributor

This is more complicated than it initially seems.

I added

			/* Wait for any builds to finish: Taken from DebugUIPlugin.launchInBackground(). */
			final IJobManager jobManager = Job.getJobManager();
			try {
				jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, subMonitor.split(1));
				jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, subMonitor.split(1));
			} catch (InterruptedException e) {
				/* just continue. */
			}

to the start of AbstractInstantiationJob.runInWorkspace(). Two things:

  1. It definitely blocks the job, and the progress display says that it is waiting for "Build" to complete.

  2. The problem is that something about the job cause the "Build" job to wait as well, so they become deadlocked.

I took the join calls back out of the AbstractInstantiationJob and tried things. The instantiation jobs cause the build to pause. Not sure why, perhaps because they lock output directory for file creation?

@AaronGreenhouse
Copy link
Contributor

@lwrage Suggests looking at this https://www.eclipse.org/forums/index.php/m/1816939/#msg_1816939 regarding job priorities.

@AaronGreenhouse
Copy link
Contributor

AaronGreenhouse commented Oct 28, 2020

Had to do the following in AbstractInstantiationEngine.instantiate()

  1. What for the build to finish. This doesn't need to be a separate job because instantiate() declares that it does not return until instantiation is complete.
  2. When the builder is finished create and schedule the instantiation jobs and the results collection job.
  3. Wait for the results job to finish (as originally done)

The key things here seem to be

  • Not requiring any resources. When I tried to have the instantiation jobs wait for the builder directly, the builder would suspend and wait for them. If I removed the resource requirement as a test (it would be wrong to remove it for real) then the builder didn't suspend. I have no idea how the builder is creating this behavior.
  • I tried to changing the jobs to have the BUILD priority, but that didn't matter.

There is definitely some Eclipse magic at work here that I don't understand, but I ahve been able to make this work, I think.

Also, starting a build while the instantiation is already running causes the build to wait for the instantiation to finish. Again, I have no idea why this is the case and how the builder is doing this. There may magic in the Eclipse job scheduler itself?

To do: Still to need to check that cancellation works correctly.

@AaronGreenhouse
Copy link
Contributor

Cancellation is okay

@AaronGreenhouse
Copy link
Contributor

Some things learned about the builder:

  • The automatic builder class is AutoBuildJob
  • Running a task with Workspace.run() causes an interrupt and reschedule of the auto build
  • The auto build periodically checks if a job with a conflicting rule is waiting to run (that is, is being blocked by the auto build). If so, the auto build interrupts and reschedules itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants