ActiveRecord :: StatementInvalid:PG :: ReadOnlySqlTransaction: - Heroku数据库在取消关注后仍然是只读的 [英] ActiveRecord::StatementInvalid: PG::ReadOnlySqlTransaction: - Heroku database still read only even after unfollow

查看:173
本文介绍了ActiveRecord :: StatementInvalid:PG :: ReadOnlySqlTransaction: - Heroku数据库在取消关注后仍然是只读的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在heroku中将数据库从一个应用程序复制到另一个应用程序。我有一个索引的问题,迫使我使用一个跟随数据库,然后取消关注。



我的问题是,现在创建追随者后,取消追随者,并促进它尝试写入它时,我收到错误:



ActiveRecord :: StatementInvalid:PG :: ReadOnlySqlTransaction:错误:无法在只读事务中执行ALTER TABLE



另外,当我运行时: SELECT pg_is_in_recovery(); 我得到了真正的结果

我做的是:

heroku addons:create heroku-postgresql:standard-4 - 关注MAIN_DB_ADDON_NAME - 一个应用程序 - 关注


$ b $ heroku pg:unfollow HEROKU_POSTGRESQL_COLOR_URL - 一个应用程序 - 跟随



heroku pg:宣传HEROKU_POSTGRESQL_COLOR_URL - 一个应用程序 - 关注



任何想法为什么我得到这个错误,更重要的是,我该如何解决它 ??



谢谢,

Uri

解决方案

过了一段时间,数据库又变得可写了。我附上了我从heroku支持获得的答案:


当您取消关注主数据库时,跟随者是否完全保持最新?如果追随者有一堆构建的WAL,它有时可以让数据库恢复,直到它能够重放所有WAL。


事实上,当您执行 pg:info 并且拥有关注者数据库时,您可以看到 Behind By 字段向你展示你的追随者背后有多少次提交。



我的工作很落后,所以花了一段时间赶上...



可能是一件好事想法将其添加到heroku postgres文档中


I wanted to copy a database from one app to another in heroku. I have an issue with indexes forcing me to do this using a follower db and then unfollowing.

My problem is that now after creating the follower, unfollowing, and promoting it i'm getting an error when trying to write to it:

ActiveRecord::StatementInvalid: PG::ReadOnlySqlTransaction: ERROR: cannot execute ALTER TABLE in a read-only transaction

Also, when I run: SELECT pg_is_in_recovery(); I get true

What I did was:
heroku addons:create heroku-postgresql:standard-4 –follow MAIN_DB_ADDON_NAME -a app-that-follows

heroku pg:unfollow HEROKU_POSTGRESQL_COLOR_URL -a app-that-follows

heroku pg:promote HEROKU_POSTGRESQL_COLOR_URL -a app-that-follows

Any idea why i'm getting this error, and more importantly, how do I solve it??

Thanks,
Uri

解决方案

After a while the database became writable again. I'm attaching the answer I got from heroku support:

When you unfollowed the primary database, was the follower completely up to date? If the follower has a bunch of built up WAL it can sometimes leave the database in recovery until it is able to ro replay all of the WAL.

And indeed when you do a pg:info and have a follower db you can see a Behind By field showing you how many commits your follower is behind by.

Mine was way behind, so it took it a while to catch up...

Probably a good idea to add this to the heroku postgres documentation

这篇关于ActiveRecord :: StatementInvalid:PG :: ReadOnlySqlTransaction: - Heroku数据库在取消关注后仍然是只读的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆