Bust cache after commit, rather than after save (#13455)
There's a (tiny) race condition where if an enclosing transaction has not yet been committed when a user is created, and a sidekiq worker begins find(:id) and fails, that the job is enqueued, started, and skipped. This changes the after_save hook on User to after_commit, ensuring the user's assigned id is visible to other processes.
This commit is contained in:
parent
8016a33dd2
commit
a615105653
1 changed files with 1 additions and 1 deletions
|
|
@ -271,10 +271,10 @@ class User < ApplicationRecord
|
|||
|
||||
# NOTE: @citizen428 Temporary while migrating to generalized profiles
|
||||
after_save { |user| user.profile&.save if user.profile&.changed? }
|
||||
after_save :bust_cache
|
||||
after_save :subscribe_to_mailchimp_newsletter
|
||||
|
||||
after_create_commit :send_welcome_notification
|
||||
after_commit :bust_cache
|
||||
after_commit :index_to_elasticsearch, on: %i[create update]
|
||||
after_commit :sync_related_elasticsearch_docs, on: %i[create update]
|
||||
after_commit :remove_from_elasticsearch, on: [:destroy]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue