Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-09-12 09:16:40 +0300
committerStan Hu <stanhu@gmail.com>2019-09-12 09:24:14 +0300
commitc13c7e6709bf4748bbe411e9fd35a2436dcde421 (patch)
treee470b84c29c2c7999041042c137d15887bda5994 /db/migrate/20190912061145_add_index_to_members_on_expires_at.rb
parent80e9f7f3463cc67c6eb1dd22fb9e2dc88ebed3f1 (diff)
Fix member expiration not always working
The Sidekiq job `RemoveExpiredMembersWorker` was failing to run in production because it was hitting statement timeouts because it was scanning all rows in order. On staging, where it used to scan 4 million rows, adding an index brought this down to only a few hundred rows. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/67286
Diffstat (limited to 'db/migrate/20190912061145_add_index_to_members_on_expires_at.rb')
-rw-r--r--db/migrate/20190912061145_add_index_to_members_on_expires_at.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20190912061145_add_index_to_members_on_expires_at.rb b/db/migrate/20190912061145_add_index_to_members_on_expires_at.rb
new file mode 100644
index 00000000000..e961977747b
--- /dev/null
+++ b/db/migrate/20190912061145_add_index_to_members_on_expires_at.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToMembersOnExpiresAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :members, :expires_at
+ end
+
+ def down
+ remove_concurrent_index :members, :expires_at
+ end
+end