0

在運行遷移,看起來像這樣:Heroku的遷移存儲配額超出

def up 
    FileThumb.destroy_all # delete existing thumbnails 
    File.update_all(thumbs_completed: false) # reset the process flags 
    File.find_each do |file| 
    file.delay(priority: 8).create_thumbs # delay thumbnail creation of each file. 
    end 
end 

我越來越內存報價超過

heroku/run.8084: source=run.8084 dyno=heroku.3498745.1deecee6-afd0-466a-8020-38273704608c sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.02 
heroku/run.8084: source=run.8084 dyno=heroku.3498745.1deecee6-afd0-466a-8020-38273704608c sample#memory_total=571.66MB sample#memory_rss=511.89MB sample#memory_cache=0.00MB sample#memory_swap=59.78MB sample#memory_pgpgin=1811564pages sample#memory_pgpgout=1680521pages 
heroku/run.8084: Process running mem=571M(111.7%) 
heroku/run.8084: Error R14 (Memory quota exceeded) 
+0

https://devcenter.heroku.com/articles/error-codes#r14-memory -quota-exceeded您正在使用比dyno更多的內存。它應該仍然是R14錯誤而不是R15。 – ChrisBarthol

+1

你有沒有試過用'find_each'使用更小的批量? –

+0

雖然我沒有得到R15的錯誤,但是它在插入時掛起並停頓。一個較小的批處理大小與find_in_batches一起工作 –

回答

3

這是因爲如此多的物體在越來越創建了遷移您必須更改查詢,以便使用更少的內存。 回答你的問題的是這樣一個問題:Heroku Error R14 (Memory quota exceeded): How do I solve this?

更具體地說,修復應該是...

def up 
    FileThumb.destroy_all # delete existing thumbnails 
    File.update_all(thumbs_completed: false) # reset the process flags 
    File.find_in_batches(batch_size: 100) do |group| 
    group.each {|file| file.delay(priority: 8).create_thumbs} # delay thumbnail creation of each file. 
    end 
end