FIX: hold s3 related distributed locks longer

FIX: hold s3 related distributed locks longer

These operations are pretty expensive and can take multiple minutes due to networking.

Hold distributed mutex for much longer.

diff --git a/app/models/post.rb b/app/models/post.rb
index f9f565d..3cbe11e 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -927,7 +927,7 @@ class Post < ActiveRecord::Base
     missing_post_uploads = {}
     count = 0
 
-    DistributedMutex.synchronize("find_missing_uploads") do
+    DistributedMutex.synchronize("find_missing_uploads", validity: 30.minutes) do
       PostCustomField.where(name: Post::MISSING_UPLOADS).delete_all
       query = Post
         .have_uploads
diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb
index ebe40fd..b69f4a0 100644
--- a/lib/s3_inventory.rb
+++ b/lib/s3_inventory.rb
@@ -30,7 +30,7 @@ class S3Inventory
       return
     end
 
-    DistributedMutex.synchronize("s3_inventory_list_missing_#{type}") do
+    DistributedMutex.synchronize("s3_inventory_list_missing_#{type}", validity: 30.minutes) do
       begin
         files.each do |file|
           next if File.exists?(file[:filename][0...-3])

GitHub sha: e53a1719

1 Like