I'm currently using Sequelize, NodeJS and PostgreSQL. I have users who update their accounts password on first login. Well, today I had this error appear after 3-4 successful logins.

What does this even mean? I did nothing out of the ordinary. A google search does not help me at all as they dont seem to have my problem.

This error appeared on this query:

UPDATE "Users" 
SET "password"='-hash-',
"startedOn"='2018-04-03 20:45:31.801 +00:00',
"updatedAt"='2018-04-03 20:45:31.802 +00:00' 
WHERE "userId" = 84

Any help?

  • 1
    Cannot help if you don't paste the SQL query or at least the sequelize command you use – Imanol Y. Apr 3 '18 at 20:53
  • 1
    You might have connected to a read-only replica, or initiated a read-only transaction. Maybe something else, but there is way too little information in your question to figure it out. – dezso Apr 3 '18 at 22:11
  • I think that nothing strange is in the sql, do you have only one database? or do you have read-only replicas as dezso suggested – Imanol Y. Apr 4 '18 at 7:37
  • I'm using Heroku. I am pretty sure it is just one database and I wouldn't know if there are replicas. :/ @ImanolY. – Phil Apr 4 '18 at 13:54

It can be caused by these reasons

1) you connected to a follower. Check it, using select pg_is_in_recovery(); – on master, it will return false:

test=# select pg_is_in_recovery();
(1 row)

Of course, you can run UPDATEs only on the master DB.

2) (I suppose this is not your case, but just for completeness I add it) You're working with master DB, but transaction or session was set to be "read only":

set session characteristics as transaction read only; 

or, inside transaction where UPDATE is being executed:

set transaction read only;
  • What does it actually mean? Why would a db randomly go into recovery mode or the transaction become read only? I was able to solve the problem by restarting the system. – Phil Apr 4 '18 at 1:41
  • @Phil If you are running with a default heroku maybe the problem its with the session, as Nick suggested in his second hypothesis – Imanol Y. Apr 4 '18 at 16:36
  • @Phil, it’s not about recovery mode. That function tells you if you’re sitting on a replica or not. The name looks so due to the nature of Postgres replication — it was originally based on recovery process (idea was: let’s setup a server being in r covert mode infinitely — and we’ll get a replica!) – Nick Apr 7 '18 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.