ActiveRecord::StatementInvalid: PG::ReadOnlySqlTransaction: - Heroku database still read only even after unfollow

时光毁灭记忆、已成空白 提交于 2020-01-11 11:56:12

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/46422248/activerecordstatementinvalid-pgreadonlysqltransaction-heroku-database-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!