From 526332c5454b67f1c498dc82e71657258a79d7e9 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 2 Jun 2021 17:41:25 +0200 Subject: Fix account deletion sometimes failing because of optimistic locks (#16317) * Fix account deletion sometimes failing because of optimistic locks In some rare occasions[1], deleting accounts would fail with a `StaleObjectError` exception. Indeed, account deletion manually sets the `AccountStat` values without handling cases where the optimistic locking on `AccountStat` would fail. To my knowledge, with the rewrite of account counters in #15913, the `DeleteAccountService` is now the only place that changes the counters in a way that is not atomic. Since in this specific case, we do not care about the previous values of the account counters, it appears we don't need locking at all for this table anymore. [1]: https://discourse.joinmastodon.org/t/account-cant-be-deleted/3602 * Bump MAX_SUPPORTED_VERSION in maintenance script --- .../20210526193025_remove_lock_version_from_account_stats.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/post_migrate/20210526193025_remove_lock_version_from_account_stats.rb (limited to 'db/post_migrate') diff --git a/db/post_migrate/20210526193025_remove_lock_version_from_account_stats.rb b/db/post_migrate/20210526193025_remove_lock_version_from_account_stats.rb new file mode 100644 index 000000000..3079bed09 --- /dev/null +++ b/db/post_migrate/20210526193025_remove_lock_version_from_account_stats.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveLockVersionFromAccountStats < ActiveRecord::Migration[5.2] + def change + safety_assured do + remove_column :account_stats, :lock_version, :integer, null: false, default: 0 + end + end +end -- cgit