18693: Use row locking only if enabled in config. 18693-dedup-permissions
authorTom Clegg <tom@curii.com>
Tue, 17 Jan 2023 21:58:33 +0000 (16:58 -0500)
committerTom Clegg <tom@curii.com>
Tue, 17 Jan 2023 21:58:33 +0000 (16:58 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/config/config.default.yml
lib/config/export.go
sdk/go/arvados/config.go
sdk/python/tests/run_test_server.py
services/api/app/controllers/application_controller.rb
services/api/app/controllers/arvados/v1/api_client_authorizations_controller.rb
services/api/app/controllers/arvados/v1/collections_controller.rb
services/api/app/controllers/arvados/v1/links_controller.rb

index 2d9119adfc747c2a937a39405dac88638ce5b5bb..357860652c694944b11e2c3133a76564c62de759 100644 (file)
@@ -288,6 +288,9 @@ Clusters:
       # any user with "manage" permission can un-freeze.
       UnfreezeProjectRequiresAdmin: false
 
+      # (Experimental) Use row-level locking on update API calls.
+      LockBeforeUpdate: false
+
     Users:
       # Config parameters to automatically setup new users.  If enabled,
       # this users will be able to self-activate.  Enable this if you want
index 069e300c5b4d0f6eb72175a6d311670ab5fa9fd4..b198a673e1d5f5876d0867d68847fbdad948618a 100644 (file)
@@ -65,6 +65,7 @@ var whitelist = map[string]bool{
        "API.FreezeProjectRequiresDescription":     true,
        "API.FreezeProjectRequiresProperties":      true,
        "API.FreezeProjectRequiresProperties.*":    true,
+       "API.LockBeforeUpdate":                     false,
        "API.KeepServiceRequestTimeout":            false,
        "API.MaxConcurrentRequests":                false,
        "API.MaxIndexDatabaseRead":                 false,
index fbbcb78ec2991b00aca4f4b2f4e94fb7ac209760..c1646dd3a90cfd47db08d444cc5c436a5d037881 100644 (file)
@@ -112,6 +112,7 @@ type Cluster struct {
                FreezeProjectRequiresDescription bool
                FreezeProjectRequiresProperties  StringSet
                UnfreezeProjectRequiresAdmin     bool
+               LockBeforeUpdate                 bool
        }
        AuditLogs struct {
                MaxAge             Duration
index 2bb20ca5daec35fe5348369522a106a249959cfe..a5f681c479b75c21442cb8662924b49f32112694 100644 (file)
@@ -792,6 +792,7 @@ def setup_config():
                 "SystemRootToken": auth_token('system_user'),
                 "API": {
                     "RequestTimeout": "30s",
+                    "LockBeforeUpdate": True,
                 },
                 "Login": {
                     "Test": {
index 88679f4f3338e89530670f0ab7763b8f64c11eaa..cf7271bbffa12bcf113a46ba7555010d125ef43a 100644 (file)
@@ -480,7 +480,7 @@ class ApplicationController < ActionController::Base
     @filters = []
     @objects = nil
     find_objects_for_index
-    if with_lock
+    if with_lock && Rails.configuration.API.LockBeforeUpdate
       @object = @objects.lock.first
     else
       @object = @objects.first
index 8ff5520e376c020d3c1819323a268d706369d526..da7e11cd9f4800b695beb927d9214836f891be19 100644 (file)
@@ -141,7 +141,7 @@ class Arvados::V1::ApiClientAuthorizationsController < ApplicationController
     @filters = [['uuid', '=', uuid_param]]
     find_objects_for_index
     query = @objects
-    if with_lock
+    if with_lock && Rails.configuration.API.LockBeforeUpdate
       query = query.lock
     end
     @object = query.first
index d4860cce15dc6e89292ae02cd86df275606acf0b..dc20d6ae73ccffd2a8654479db8f728186367783 100644 (file)
@@ -82,7 +82,7 @@ class Arvados::V1::CollectionsController < ApplicationController
 
       select_attrs = (@select || ["manifest_text"]) | ["portable_data_hash", "trash_at"]
       model = Collection
-      if with_lock
+      if with_lock && Rails.configuration.API.LockBeforeUpdate
         model = model.lock
       end
       if c = model.
index 32d005874a8eb30b213724db7e14962ed1f46d51..c956bfc9b467b5df3a98ef334961d4eb465bc3fc 100644 (file)
@@ -94,7 +94,7 @@ class Arvados::V1::LinksController < ApplicationController
       # user or (b) its head_uuid is an object the current_user
       # can_manage.
       model = Link
-      if with_lock
+      if with_lock && Rails.configuration.API.LockBeforeUpdate
         model = model.lock
       end
       link = model.unscoped.where(uuid: params[:uuid]).first