[ARVADOS] updated: 1.3.0-2549-gaeeb2ebf8

Git user git at public.arvados.org
Thu May 21 17:43:07 UTC 2020


Summary of changes:
 .../db/migrate/20200501150153_permission_table.rb   | 21 ++++++++++++---------
 services/api/db/structure.sql                       |  7 +++++++
 services/api/lib/refresh_permission_view.rb         |  6 +++---
 3 files changed, 22 insertions(+), 12 deletions(-)

       via  aeeb2ebf8ef0b43177f37586204b91716fdddbc5 (commit)
      from  600ad8437dd49105952210c407828fb883dc2aa5 (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 aeeb2ebf8ef0b43177f37586204b91716fdddbc5
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Thu May 21 13:41:09 2020 -0400

    16007: Add index on materialized_permissions.target_uuid
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/db/migrate/20200501150153_permission_table.rb b/services/api/db/migrate/20200501150153_permission_table.rb
index be01e7e50..cb601e3f0 100644
--- a/services/api/db/migrate/20200501150153_permission_table.rb
+++ b/services/api/db/migrate/20200501150153_permission_table.rb
@@ -10,6 +10,7 @@ class PermissionTable < ActiveRecord::Migration[5.0]
       t.boolean :traverse_owned
     end
     add_index :materialized_permissions, [:user_uuid, :target_uuid], unique: true, name: 'permission_user_target'
+    add_index :materialized_permissions, [:target_uuid], unique: false, name: 'permission_target'
 
     ActiveRecord::Base.connection.execute %{
 create or replace function project_subtree_with_trash_at (starting_uuid varchar(27), starting_trash_at timestamp)
@@ -191,6 +192,16 @@ from users, lateral search_permission_graph(users.uuid, 3) as g where g.val > 0
   end
 
   def down
+    drop_table :materialized_permissions
+    drop_table :trashed_groups
+
+    ActiveRecord::Base.connection.execute "DROP function project_subtree_with_trash_at (varchar, timestamp);"
+    ActiveRecord::Base.connection.execute "DROP function compute_trashed ();"
+    ActiveRecord::Base.connection.execute "DROP function search_permission_graph(varchar, integer);"
+    ActiveRecord::Base.connection.execute "DROP function compute_permission_subgraph (varchar, varchar, integer);"
+    ActiveRecord::Base.connection.execute "DROP function should_traverse_owned(varchar, integer);"
+    ActiveRecord::Base.connection.execute "DROP function permission_graph_edges();"
+
     ActiveRecord::Base.connection.execute(%{
 CREATE MATERIALIZED VIEW materialized_permission_view AS
  WITH RECURSIVE perm_value(name, val) AS (
@@ -253,16 +264,8 @@ CREATE MATERIALIZED VIEW materialized_permission_view AS
 
     add_index :materialized_permission_view, [:trashed, :target_uuid], name: 'permission_target_trashed'
     add_index :materialized_permission_view, [:user_uuid, :trashed, :perm_level], name: 'permission_target_user_trashed_level'
-
-    drop_table :materialized_permissions
-    drop_table :trashed_groups
     create_table :permission_refresh_lock
 
-    ActiveRecord::Base.connection.execute "DROP function project_subtree_with_trash_at (varchar, timestamp);"
-    ActiveRecord::Base.connection.execute "DROP function compute_trashed ();"
-    ActiveRecord::Base.connection.execute "DROP function search_permission_graph(varchar, integer);"
-    ActiveRecord::Base.connection.execute "DROP function compute_permission_subgraph (varchar, varchar, integer);"
-    ActiveRecord::Base.connection.execute "DROP function should_traverse_owned(varchar, integer);"
-    ActiveRecord::Base.connection.execute "DROP function permission_graph_edges();"
+    ActiveRecord::Base.connection.execute 'REFRESH MATERIALIZED VIEW materialized_permission_view;'
   end
 end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index c34d69e28..fd3044e55 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -2781,6 +2781,13 @@ CREATE INDEX nodes_index_on_properties ON public.nodes USING gin (properties);
 CREATE INDEX nodes_search_index ON public.nodes USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, hostname, domain, ip_address, job_uuid);
 
 
+--
+-- Name: permission_target; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX permission_target ON public.materialized_permissions USING btree (target_uuid);
+
+
 --
 -- Name: permission_user_target; Type: INDEX; Schema: public; Owner: -
 --
diff --git a/services/api/lib/refresh_permission_view.rb b/services/api/lib/refresh_permission_view.rb
index c00ceaf99..1587f7fec 100644
--- a/services/api/lib/refresh_permission_view.rb
+++ b/services/api/lib/refresh_permission_view.rb
@@ -23,7 +23,7 @@ def refresh_trashed
   ActiveRecord::Base.connection.execute("INSERT INTO #{TRASHED_GROUPS} select * from compute_trashed()")
 end
 
-def update_permissions perm_origin_uuid, starting_uuid, perm_level, check=true
+def update_permissions perm_origin_uuid, starting_uuid, perm_level, check=false
   # Update a subset of the permission graph
   # perm_level is the inherited permission
   # perm_level is a number from 0-3
@@ -85,13 +85,13 @@ def check_permissions_against_full_refresh
   q1 = ActiveRecord::Base.connection.exec_query %{
 select user_uuid, target_uuid, perm_level, traverse_owned from #{PERMISSION_VIEW}
 order by user_uuid, target_uuid
-}
+}, "check_permissions_against_full_refresh.permission_table"
 
   q2 = ActiveRecord::Base.connection.exec_query %{
 select users.uuid as user_uuid, g.target_uuid, g.val as perm_level, g.traverse_owned
 from users, lateral search_permission_graph(users.uuid, 3) as g where g.val > 0
 order by users.uuid, target_uuid
-}
+}, "check_permissions_against_full_refresh.full_recompute"
 
   if q1.count != q2.count
     puts "Didn't match incremental+: #{q1.count} != full refresh-: #{q2.count}"

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list