【问题标题】:Heroku migration Memory quota exceeded超出 Heroku 迁移内存配额
【发布时间】:2014-05-03 18:10:48
【问题描述】:

在运行如下所示的迁移时:

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) 

【问题讨论】:

  • devcenter.heroku.com/articles/… 您正在使用比测功机更多的内存。它仍然应该作为 R14 错误而不是 R15 工作。
  • 您是否尝试过对find_each 使用较小的批量?
  • 虽然我没有收到 R15 错误,但它在插入时挂起并停止。较小的批量确实适用于 find_in_batches

标签: ruby-on-rails postgresql heroku delayed-job rails-migrations


【解决方案1】:

这是因为在您的迁移中创建了太多对象,您必须更改查询以减少使用的内存。 您的问题的答案在这个问题中: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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 2017-11-02
    • 2012-11-02
    • 2017-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多