【问题标题】:Heroku pg migration error "PG:DataCorrupted: Error"Heroku pg 迁移错误“PG:DataCorrupted:错误”
【发布时间】:2014-06-17 13:08:53
【问题描述】:

尝试运行heroku run rake db:migrate 时出现以下错误。我试过heroku pg:reset,我试过heroku restart。我也尝试创建一个新应用程序并重新开始,但问题仍然存在。这可能是什么问题?

Running `rake db:migrate` attached to terminal... up, run.7662
Migrating to CreateChannels (20140424224543)
==  CreateChannels: migrating =================================================
-- create_table(:channels)
PG::DataCorrupted: ERROR:  could not read block 0 in file "base/57396/12684": read only 0 of 8192 bytes
: CREATE TABLE "channels" ("id" serial primary key, "name" character varying(255), "user_id" integer, "created_at" timestamp, "updated_at" timestamp)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DataCorrupted: ERROR:  could not read block 0 in file "base/57396/12684": read only 0 of 8192 bytes
: CREATE TABLE "channels" ("id" serial primary key, "name" character varying(255), "user_id" integer, "created_at" timestamp, "updated_at" timestamp) /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:430:in `log'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:190:in `create_table'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:625:in `block in method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in `block in say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in `say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:617:in `method_missing'
/app/db/migrate/20140424224543_create_channels.rb:3:in `change'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:571:in `exec_migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:554:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:553:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:709:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in `ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:920:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:764:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/migration.rb:742:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

[编辑] 我的用于创建通道表的迁移文件如下所示(没什么特别的)

  class CreateChannels < ActiveRecord::Migration
    def change
      create_table :channels do |t|
        t.string :name
        t.integer :user_id

        t.timestamps
      end
    end
  end

【问题讨论】:

  • 看起来是 heroku 的系统问题...(我也遇到了这个问题 - 在你和 @yong 之后 45 分钟)
  • 我也遇到过这种情况...
  • 天哪。紧急联系 Heroku 支持。确保您没有关闭任何追随者,并停止您可能拥有的任何备份轮换,以免丢弃旧备份。让他们对您的数据库进行文件系统级备份。这强烈表明可能存在数据损坏。您正在运行什么确切的 PostgreSQL 版本?第一次发生这种情况是什么时候?
  • 有来自 Heroku 的消息吗?

标签: ruby-on-rails postgresql heroku ruby-on-rails-4 database-migration


【解决方案1】:

我昨晚联系了 heroku 支持团队,我遇到了同样的问题,现在一切都恢复正常了。以下是他们的回应。

很遗憾,您的数据库似乎存在问题 昨晚导致停电几个小时,但是 我们的一位随叫随到的数据库工程师已经恢复了。这 问题根本不是你造成的,是硬件故障 主机服务器。

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    我现在遇到了同样的问题。我没有任何生产数据,所以只是建立一个新的数据库。虽然很烦人

    编辑:当我再次运行迁移时刚刚修复了自己

    编辑 2:仍然损坏。当我尝试运行我的第二个迁移文件时,我收到了错误

    PG::DataCorrupted: ERROR:  could not read block 1 in file "base/117039/12684": read only 0 of 8192 bytes
    

    很烦

    刚刚尝试在 Heroku 上提交票证。填写了包含大量信息的表单并提交只是为了得到一条消息说我没有创建任何支持票!

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,我从 https://dashboard.heroku.com/apps 删除了数据库(这是海军) 添加了一个新的 PG 数据库(这是蓝色的)

      From the terminal ran:
      heroku config
      
      You should see your db url
      heroku config:set DATABASE_URL=postgres://your-db-url
      
      Ran
      heroku run rake db:migrate
      

      一切正常。 我仍然不确定为什么会这样!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-02-28
        • 1970-01-01
        • 2015-04-04
        • 1970-01-01
        • 2015-09-11
        • 1970-01-01
        • 1970-01-01
        • 2012-11-11
        相关资源
        最近更新 更多