16470: Discards changes before locking instead of reloading the record.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 7 Aug 2020 22:11:27 +0000 (19:11 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 7 Aug 2020 22:11:27 +0000 (19:11 -0300)
There's no need to make a database roundtrip, because all the old attribute
values are available.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

services/api/app/models/collection.rb
services/api/config/secrets.yml

index c7d5a93b5377c58f3ed556444048c8962bb24dcf..8b549a71ab4fba348ab9279f456595912fb693db 100644 (file)
@@ -259,10 +259,11 @@ class Collection < ArvadosModel
     should_preserve_version = should_preserve_version? # Time sensitive, cache value
     return(yield) unless (should_preserve_version || syncable_updates.any?)
 
-    # Put aside the changes because with_lock requires an explicit record reload
+    # Put aside the changes because with_lock does a record reload
     changes = self.changes
     snapshot = nil
-    reload.with_lock do
+    restore_attributes
+    with_lock do
       # Copy the original state to save it as old version
       if should_preserve_version
         snapshot = self.dup
index 374d52969d129cd98b606e6dcc1e4710f5cd3bfd..293b93bcdbb82bb58a9a07b326edc64a32295416 100644 (file)
 # Environmental secrets are only available for that specific environment.
 
 # development:
-#   secret_key_base: rand(1<<255).to_s(36)
+#   secret_key_base: <%= rand(1<<255).to_s(36) %>
 
 # test:
-#   secret_key_base: rand(1<<255).to_s(36)
+#   secret_key_base: <%= rand(1<<255).to_s(36) %>
 
 # In case this doesn't get overriden for some reason, assign a random key
 # to gracefully degrade by rejecting cookies instead of by opening a
 # vulnerability.
 production:
-  secret_key_base: rand(1<<255).to_s(36)
+  secret_key_base: <%= rand(1<<255).to_s(36) %>