Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

miwal's avatar
Level 11

SQL error from queue:work

I got this error:

app/worker.1: production.ERROR: SQLSTATE[25006]: Read only sql transaction: 7 ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction (SQL: select * from "jobs" where "queue" = default and (("reserved_at" is null and "available_at" <= 1545253197) or ("reserved_at" <= 1545253107)) order by "id" asc limit 1 for update)

It happened every 3 seconds over slightly more than a minute. This is from papertrail on heroku.

I know the queue worker polls the database (I'm using db queue driver) about every 3 seconds, so that's the cause. Simply interested in explanation of what is happening.

Does this mean the (heroku) postgres became temporarily unwritable for some reason? Any ideas on likely causes / what this means? Have you seen this before on your apps? Thanks much.

0 likes
1 reply
Braunson's avatar

Are you running out of storage? Sometimes write access can be disabled if there is not enough space to write anything.

Other plausible reason are:

  • being throttled somehow?
  • trying update statements on a read-only replica (e.g. the entire instance is read-only/is a follower)?

Try manually running SELECT pg_is_in_recovery() and logging the response (in the jobs) to see if when it does throw that error if it's in recovery mode. If it's true, then it's likely connected to a read-only replica server in hot_standby mode.

Otherwise I'd get in touch with Heroku

1 like

Please or to participate in this conversation.