[ARVADOS] updated: 1d34696de2fb46133e1d969d8d2aed1de3da2ff2

Git user git at public.curoverse.com
Thu Jan 12 13:29:52 EST 2017


Summary of changes:
 services/api/app/controllers/application_controller.rb | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

       via  1d34696de2fb46133e1d969d8d2aed1de3da2ff2 (commit)
      from  daafdb4c939f265b4604711d0fc946a830d9d54e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 1d34696de2fb46133e1d969d8d2aed1de3da2ff2
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jan 12 13:25:49 2017 -0500

    9831: Avoid attempting the same name twice, even if an attempt takes less than 1ms.

diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 37e100a..cdfbdbb 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -129,7 +129,16 @@ class ApplicationController < ActionController::Base
       raise unless /^Key \(owner_uuid, name\)=\([a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}, .*?\) already exists\./.match detail
 
       @object.uuid = nil
-      @object.name = "#{name_stem} (#{db_current_time.utc.iso8601(3)})"
+
+      new_name = "#{name_stem} (#{db_current_time.utc.iso8601(3)})"
+      if new_name == @object.name
+        # If the database is fast enough to do two attempts in the
+        # same millisecond, we need to wait to ensure we try a
+        # different timestamp on each attempt.
+        sleep 0.002
+        new_name = "#{name_stem} (#{db_current_time.utc.iso8601(3)})"
+      end
+      @object.name = new_name
       retry
     end
     show

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list