Fixes #3940 - dead lock on user update in high load environment.

This commit is contained in:
Rolf Schmidt 2022-01-31 13:56:58 +00:00
parent b40ca87b2a
commit bd373de069
3 changed files with 12 additions and 2 deletions

View file

@ -14,8 +14,7 @@ module HasGroupRelationDefinition
validates :access, presence: true
validate :validate_access
after_save :touch_related
after_destroy :touch_related
after_commit :touch_related
end
private

View file

@ -178,6 +178,7 @@ class CreateBase < ActiveRecord::Migration[4.2]
add_index :groups_users, [:user_id]
add_index :groups_users, [:group_id]
add_index :groups_users, [:access]
add_index :groups_users, %i[user_id group_id access]
add_foreign_key :groups_users, :users
add_foreign_key :groups_users, :groups

View file

@ -0,0 +1,10 @@
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class Issue3940AddIndex < ActiveRecord::Migration[6.0]
def change
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
add_index :groups_users, %i[user_id group_id access]
end
end