Postgres error: subplan "SubPlan 2" was not initialized

I have a user that says he’s getting 500 errors " when viewing random posts." Looking at the logs, all I see is these, which appear to affect only this user. This is a standard install up to date with PG13. I don’t see these errors for any other users. These appear all to have to do with private_messages, which doesn’t seem like “random posts”. Searching for that error I see a few posts from a year ago claiming that it’s a postgres bug.

Discourse 2.8.0.beta6 - version f513266bcbc03eedebda17695b8a7ffbcad6ebcc

Started GET "/u/joe/private-message-topic-tracking-state" for at 2021-10-07 07:08:25 +0000
Processing by UsersController#private_message_topic_tracking_state as JSON
  Parameters: {"username"=>"joe"}
Completed 500 Internal Server Error in 70ms (ActiveRecord: 0.0ms | Allocations: 1952)
PG::InternalError (ERROR:  subplan "SubPlan 2" was not initialized
CONTEXT:  parallel worker

That is indeed a PostgreSQL bug that was solved in latest minor version. Can you do a rebuild? That will update the PostgreSQL to latest minor.


Oooh. So

root@community:~# docker exec -it data bash -c 'psql --version'
psql (PostgreSQL) 13.1 (Debian 13.1-1.pgdg100+1)

and after a rebuild:

# docker exec -it data bash -c 'psql --version'
psql (PostgreSQL) 13.3 (Debian 13.3-1.pgdg100+1)

Did this get mentioned in some release notes? Ooh. Looks like that happened at least as far back as August.

I’ve got some sites to update.

Thanks, Rafael!


While I"m at it, would you recommend doing a vacuum and concurrent rebuild of the indexes when this minor upgrade happens? I do it on the upgrade to major version 13. Is doing it for this minor upgrade uneccesssary, not a bad idea, or superfluous?

There should be no need for that as minor versions are compatible with the same disk file-format.