Skip to content

Instantiation can be started while workspace is building #2456

Closed

Description

@lwrage

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

Activity

  1. AaronGreenhouse commented on Oct 20, 2020

    @AaronGreenhouse
    Contributor

    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.

  2. AaronGreenhouse commented on Oct 20, 2020

    @AaronGreenhouse
    Contributor

    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

  3. AaronGreenhouse commented on Oct 23, 2020

    @AaronGreenhouse
    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?

  4. AaronGreenhouse commented on Oct 27, 2020

    @AaronGreenhouse
    Contributor

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

  5. AaronGreenhouse commented on Oct 28, 2020

    @AaronGreenhouse
    Contributor

    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.

  6. AaronGreenhouse commented on Oct 29, 2020

    @AaronGreenhouse
    Contributor

    Cancellation is okay

  7. AaronGreenhouse commented on Oct 29, 2020

    @AaronGreenhouse
    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.
  8. added this to the 2.9.1 milestone on Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions