Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how Redis locks are created #18400

Merged
merged 2 commits into from
May 12, 2022
Merged

Refactor how Redis locks are created #18400

merged 2 commits into from
May 12, 2022

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented May 11, 2022

No description provided.

@Gargron Gargron added the refactoring Improving code quality label May 11, 2022
app/services/remove_status_service.rb Outdated Show resolved Hide resolved
app/lib/activitypub/activity/delete.rb Outdated Show resolved Hide resolved
app/workers/distribution_worker.rb Outdated Show resolved Hide resolved
RedisLock.acquire(lock_options) do |lock|
if lock.acquired?
already_voted = @poll.votes.where(account: @account).exists?
with_lock("vote:#{@poll.id}:#{@account.id}") do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the autorelease duration, but maybe it's not a bad thing.

else
raise Mastodon::RaceConditionError
end
with_lock("distribute:#{status_id}") do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the autorelease duration (from 5 minutes to 15 minutes), but not sure this matters.

@@ -12,22 +12,22 @@ def perform
private

def delete_person
lock_or_return("delete_in_progress:#{@account.id}") do
with_lock("delete_in_progress:#{@account.id}", raise_on_failure: false) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the autorelease from 2 hours to 15 minutes. DeleteAccountService can potentially take a really long time to return, so 15 minutes might be too short of a duration in certain cases.

@Gargron Gargron merged commit 6cf57c6 into main May 12, 2022
@Gargron Gargron deleted the refactor-locks branch May 12, 2022 22:02
kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request May 27, 2022
* Refactor how Redis locks are created

* Fix autorelease duration on account deletion lock
ClearlyClaire pushed a commit to ClearlyClaire/mastodon that referenced this pull request Jul 6, 2023
* Refactor how Redis locks are created

* Fix autorelease duration on account deletion lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improving code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants