20831: Fix tests
[arvados.git] / services / api / app / controllers / arvados / v1 / users_controller.rb
index afe2f96cca6237679c8f4cf2ecab7ad9021fe369..8f69c6cf7777e0d4f464b7d4508f6735ac2f279d 100644 (file)
@@ -16,7 +16,12 @@ class Arvados::V1::UsersController < ApplicationController
   # records from LoginCluster.
   def batch_update
     @objects = []
-    params[:updates].andand.each do |uuid, attrs|
+    # update_remote_user takes a row lock on the User record, so sort
+    # the keys so we always lock them in the same order.
+    sorted = params[:updates].keys.sort
+    sorted.each do |uuid|
+      attrs = params[:updates][uuid]
+      attrs[:uuid] = uuid
       u = User.update_remote_user nullify_attrs(attrs)
       @objects << u
     end