ActiveRecord :: StatementInvalid:PG :: Error:错误:无法在Heroku中的只读事务错误中执行UPDATE [英] ActiveRecord::StatementInvalid: PG::Error: ERROR: cannot execute UPDATE in a read-only transaction error in Heroku

查看:681
本文介绍了ActiveRecord :: StatementInvalid:PG :: Error:错误:无法在Heroku中的只读事务错误中执行UPDATE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用追随者在Heroku上创建了一个新数据库。之后它是0提交后我取消关注主数据库并将其作为默认提升。

I created a new database on Heroku using a follower. After it was 0 commits behind I unfollow the master db and promote it as default.

似乎工作正常,但看起来只能读取。当我尝试从控制台中截取记录时,我发现此错误

Seems to be working fine but looks to be read only. When I try to seve a record from the console now I see this error

ActiveRecord::StatementInvalid: PG::Error: ERROR:  cannot execute UPDATE in a read-only transaction

任何想法如何解决这个问题?

Any idea how to solve this?

推荐答案

副本永远不会被升级。

The replica never actually got promoted. See comments.

您可以知道副本跟随主服务器的时间,因为:

You can tell when a replica is following a master server because:

SELECT pg_is_in_recovery();

将返回true。这不能在主服务器中返回true,因为主服务器只能恢复的时间是它仍在启动的时间 - 然后您无法连接到它,因此您无法运行该命令。从9.2和9.3beta这是真的;这可能会在将来的版本中发生变化,所以如果您正在阅读本文并在较新版本中检查,请检查专用函数以检查服务器是否是副本。

will return true. This cannot return true in a master server because the only time a master server can be in recovery is when it is still starting up - and then you cannot connect to it, so you can't run that command. That's true as of 9.2 and 9.3beta; this may change in future versions, so if you're reading this and on a newer version check for a dedicated function for checking if the server is a replica.

这篇关于ActiveRecord :: StatementInvalid:PG :: Error:错误:无法在Heroku中的只读事务错误中执行UPDATE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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