Fixes #3087: Search taskbars cause DeadLocks.

This commit is contained in:
Thorsten Eckel 2020-06-17 17:41:45 +02:00
parent 899a4d887f
commit ee1c4677ea
3 changed files with 54 additions and 0 deletions

View file

@ -88,6 +88,7 @@ class Taskbar < ApplicationModel
end
def update_preferences_infos
return true if key == 'Search'
return true if local_update
# find other same open tasks

View file

@ -0,0 +1,14 @@
class Issue3087SearchTaskbarDeadlock < ActiveRecord::Migration[5.2]
def change
Taskbar.where(key: 'Search').find_each do |taskbar|
next if taskbar.preferences.blank?
next if taskbar.preferences[:tasks].blank?
taskbar.preferences.delete(:tasks)
taskbar.save!
rescue => e
Rails.logger.error e
end
end
end

View file

@ -2,6 +2,45 @@ require 'rails_helper'
RSpec.describe Taskbar do
context 'key = Search' do
context 'multiple taskbars', current_user_id: 1 do
let(:key) { 'Search' }
let(:other_taskbar) { create(:taskbar, key: key) }
describe '#create' do
it "doesn't update other taskbar" do
expect do
create(:taskbar, key: key)
end.not_to change { other_taskbar.reload.updated_at }
end
end
context 'existing taskbar' do
subject(:taskbar) { create(:taskbar, key: key) }
describe '#update' do
it "doesn't update other taskbar" do
expect do
taskbar.update!(state: { foo: :bar })
end.not_to change { other_taskbar.reload.updated_at }
end
end
describe '#destroy' do
it "doesn't update other taskbar" do
expect do
taskbar.destroy!
end.not_to change { other_taskbar.reload.updated_at }
end
end
end
end
end
context 'single creation' do
let(:taskbar) do