+ // Flood railsapi with priority updates. This can cause
+ // database deadlock: one call acquires row locks in the order
+ // {i0j0, i0, i0j1}, while another call acquires row locks in
+ // the order {i0j1, i0, i0j0}.
+ deadlockCtx, deadlockCancel := context.WithDeadline(adminCtx, time.Now().Add(30*time.Second))
+ defer deadlockCancel()
+ for _, cr := range allcrs {
+ if strings.Contains(cr.Command[2], " j ") && !strings.Contains(cr.Command[2], " k ") {
+ cr := cr
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for _, p := range []int{1, 2, 3, 4} {
+ var err error
+ for {
+ _, err = s.localdb.ContainerRequestUpdate(deadlockCtx, arvados.UpdateOptions{
+ UUID: cr.UUID,
+ Attrs: map[string]interface{}{
+ "priority": p,
+ },
+ })
+ c.Check(err, IsNil)
+ break
+ }
+ }
+ }()
+ }
+ }
+ wg.Wait()
+