Project

General

Profile

Actions

Bug #34343

closed

Force cancel a paused task doesn't release the lock

Added by Adam Ruzicka about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2047683

Description of problem:
Still getting the following error after "force cancel" the paused task that was holding the locks.

-----------------------------------------------
Conflicts with tasks: https://satellite.example.com/foreman_tasks/tasks/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","errors":["Required lock is already taken by other running tasks.\nPlease inspect their state, fix their errors and resume them.
-----------------------------------------------

Steps to Reproduce:
1. Publish a content view and somehow make the task paused with error. Stop Pulp services in the middle of publish might help.
2. After that click "force cancel" the paused task in the Task page. Make sure the task status is set to stopped.
3. Publish the same content view again.

Actual results:
Fail with task conflict.

Expected results:
No conflict.

Additional info:

  1. Satellite 6.9
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-3.0.6/app/models/foreman_tasks/lock.rb
    ...
    scope :active, -> { joins(:task).where('foreman_tasks_tasks.state != ?', :stopped) } <======= active scope got delete in 6.10
    ...
    ... # returns a scope of the locks colliding with this one
    def colliding_locks
    task_ids = task.self_and_parents.map(&:id)
    colliding_locks_scope = Lock.active.where(Lock.arel_table[:task_id].not_in(task_ids)) <============ has Lock.active scope
    colliding_locks_scope = colliding_locks_scope.where(name: name,
    resource_id: resource_id,
    resource_type: resource_type)
    unless exclusive?
    colliding_locks_scope = colliding_locks_scope.where(:exclusive => true)
    end
    colliding_locks_scope
    end
  1. Satellite 6.10
    /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-4.1.5/app/models/foreman_tasks/lock.rb # returns a scope of the locks colliding with this one
    def colliding_locks
    task_ids = task.self_and_parents.map(&:id)
    colliding_locks_scope = Lock.where(Lock.arel_table[:task_id].not_in(task_ids)) <========== Missing Lock.active scope
    colliding_locks_scope.where(resource_id: resource_id,
    resource_type: resource_type)
    end
Actions #1

Updated by The Foreman Bot about 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Adam Ruzicka
  • Pull request https://github.com/theforeman/foreman-tasks/pull/668 added
Actions #2

Updated by The Foreman Bot about 3 years ago

  • Fixed in Releases foreman-tasks-6.0.1 added
Actions #3

Updated by Adam Ruzicka about 3 years ago

  • Status changed from Ready For Testing to Closed
Actions #4

Updated by Adam Ruzicka about 3 years ago

  • Fixed in Releases foreman-tasks-5.2.2 added
Actions

Also available in: Atom PDF