diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-11-24 12:40:44 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-11-25 15:35:01 +0300 |
commit | 92b2c74ce14238c1032bd9faac6d178d25433532 (patch) | |
tree | d17f91f55068655b0fd7c1297ae4dce7311d9485 /lib | |
parent | 3943e632103271b3683e0cc355f0fef4c9452491 (diff) |
Refresh project authorizations using a Redis lease
When I proposed using serializable transactions I was hoping we would be
able to refresh data of individual users concurrently. Unfortunately
upon closer inspection it was revealed this was not the case. This could
result in a lot of queries failing due to serialization errors,
overloading the database in the process (given enough workers trying to
update the target table).
To work around this we're now using a Redis lease that is cancelled upon
completion. This ensures we can update the data of different users
concurrently without overloading the database.
The code will try to obtain the lease until it succeeds, waiting at
least 1 second between retries. This is necessary as we may otherwise
end up _not_ updating the data which is not an option.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database.rb | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index 2d5c9232425..55b8f888d53 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -35,13 +35,6 @@ module Gitlab order end - def self.serialized_transaction - opts = {} - opts[:isolation] = :serializable unless Rails.env.test? && connection.transaction_open? - - connection.transaction(opts) { yield } - end - def self.random Gitlab::Database.postgresql? ? "RANDOM()" : "RAND()" end |