Skip to content

[JENKINS-73824] Deletion of Pipeline jobs does not wait for ongoing builds to fully complete #16556

@jenkins-infra-bot

Description

@jenkins-infra-bot

See #9790. Description reproduced here:

While investigating an issue with branch indexing for multibranch projects leaving build directories behind when deleting projects, I think I found a rather severe issue with job deletion in general for Pipelines. Since its introduction in #2789, the logic for cancelling ongoing builds and waiting for them to complete when deleting their parent job has checked Thread.isAlive rather than Executor.isActive, which is not correct for asynchronous tasks such as the main Pipeline execution. See the Javadoc here. Oleg actually suggested changing to isActive in the original PR here for other reasons.

The result is that although ongoing Pipeline builds are interrupted, ItemDeletion.cancelBuildsInProgress does not wait for those builds to fully complete, which can at least lead to files being written back into the job directory that was just deleted. There are probably other more exotic issues possible for Pipelines that do not shut down quickly when interrupted.

If there are any other build types that use AsynchronousExecution, they would also be affected.


Originally reported by dnusbaum, imported from: Deletion of Pipeline jobs does not wait for ongoing builds to fully complete
  • assignee: dnusbaum
  • status: Closed
  • priority: Major
  • component(s): core
  • label(s): 2.479.1-fixed
  • resolution: Fixed
  • resolved: 2024-10-08T15:45:39+00:00
  • votes: 0
  • watchers: 2
  • imported: 2025-11-24
Raw content of original issue

See #9790. Description reproduced here:

While investigating an issue with branch indexing for multibranch projects leaving build directories behind when deleting projects, I think I found a rather severe issue with job deletion in general for Pipelines. Since its introduction in #2789, the logic for cancelling ongoing builds and waiting for them to complete when deleting their parent job has checked Thread.isAlive rather than Executor.isActive, which is not correct for asynchronous tasks such as the main Pipeline execution. See the Javadoc here. Oleg actually suggested changing to isActive in the original PR here for other reasons.

The result is that although ongoing Pipeline builds are interrupted, ItemDeletion.cancelBuildsInProgress does not wait for those builds to fully complete, which can at least lead to files being written back into the job directory that was just deleted. There are probably other more exotic issues possible for Pipelines that do not shut down quickly when interrupted.

If there are any other build types that use AsynchronousExecution, they would also be affected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions