# Postgres error: subplan "SubPlan 2" was not initialized

**URL:** https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440
**Category:** Self-hosting
**Created:** [October 7, 2021, 12:14pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440 "2021-10-07T12:14:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 7, 2021, 12:14pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440/1 "2021-10-07T12:14:34Z")

</div>

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](https://meta.discourse.org/t/142537?silent=true) 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](https://postgrespro.com/list/thread-id/2518858).

`Discourse 2.8.0.beta6 - https://github.com/discourse/discourse version f513266bcbc03eedebda17695b8a7ffbcad6ebcc`

```plaintext
Started GET "/u/joe/private-message-topic-tracking-state" for 82.71.0.62 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
)

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 7, 2021, 12:18pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440/2 "2021-10-07T12:18:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 7, 2021, 12:25pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440/3 "2021-10-07T12:25:00Z")

</div>

Oooh. So

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

```

and after a rebuild:

```plaintext
# 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!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 7, 2021, 12:54pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440/4 "2021-10-07T12:54:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 7, 2021, 12:55pm UTC](https://meta.discourse.org/t/postgres-error-subplan-subplan-2-was-not-initialized/205440/5 "2021-10-07T12:55:53Z")

</div>

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