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