面向自托管用户的 PostgreSQL 18 更新

:warning: 警告! 升级需要大量的空闲磁盘空间(数据库大小的 2 倍)。

我们刚刚完成了将 Docker 镜像升级至 PostgreSQL 18 的更改。任何通过命令行重建 Discourse 的网站管理员都将从之前的 PostgreSQL 15 升级至 PostgreSQL 18。请注意,如果您在 2025 年 PostgreSQL 15 更新 发布时 选择暂缓升级,您可以跳过该升级步骤,直接升级至 PostgreSQL 18。

如果您之前暂缓了升级,请将 app.yml 中的 PostgreSQL 模板从 templates/postgres.13.template.yml 更改为 templates/postgres.template.yml

与任何升级一样,强烈建议在执行任何操作之前进行备份。

区域设置变更

过去,我们在 glibc 更新期间(例如操作系统升级时)曾遇到过索引损坏的问题。自 PostgreSQL 17 起,出现了一种新的 内置区域设置提供程序,它与操作系统的 glibc 解耦,因此跨版本更加稳定。作为此次升级的一部分,我们将迁移至使用 C.UTF-8 区域设置的内置提供程序。该区域设置使用代码点排序,出于上述稳定性原因,我们推荐使用它。

为了实现区域设置的变更,我们需要首先使用内置区域设置提供程序创建新的数据库集群,然后将数据库转储并恢复到该集群中。因此,与之前执行原地升级的情况相比,此次升级所需的磁盘空间更大。

更新

官方安装指南(单容器)

在下一次重建时,您将在末尾看到以下消息:

-------------------------------------------------------------------------------------
POSTGRES 升级完成

旧版 15 数据库存储在 /shared/postgres_data_old

要完成升级,请再次使用以下命令重建:

./launcher rebuild app
-------------------------------------------------------------------------------------

这意味着升级过程一切顺利!您只需执行一次新的重建,即可让您的网站恢复运行。

数据容器安装

如果您运行的是基于我们 discourse_docker 仓库中提供的示例的专用数据容器设置,请务必确保以安全且干净的方式关闭 PostgreSQL。

如今,我们有后台作业运行耗时数分钟的查询,因此关闭 Web 容器有助于数据容器安全关闭。

./launcher stop web_only
./launcher stop data
./launcher rebuild data
./launcher rebuild data
./launcher rebuild web_only

在对数据容器执行第一次重建之前,您可以查看 PostgreSQL 日志,以确认其是否已正确关闭。

如果关闭过程正常,运行 tail -f shared/standalone/log/var-log/postgres/current 应显示以下日志:

2025-01-24 09:19:06.437 UTC [37] LOG:  received smart shutdown request
2025-01-24 09:19:06.444 UTC [37] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
2025-01-24 09:19:06.446 UTC [49] LOG:  shutting down
2025-01-24 09:19:06.468 UTC [37] LOG:  database system is shut down

推迟更新

如果您需要在下次重建时推迟更新,可以通过将 app.yml 文件中的 PostgreSQL 模板从 "templates/postgres.template.yml" 更改为 "templates/postgres.15.template.yml" 来实现。

不建议这样做,因为一些网站管理员可能会忘记在之后恢复更改。

更新后的可选任务

优化 PostgreSQL 统计信息

更新后,新的 PostgreSQL 将没有现成的表统计信息。您可以使用以下命令生成这些统计信息:

docker exec -u postgres app \
	/usr/lib/postgresql/18/bin/vacuumdb -d discourse --analyze-in-stages

清理旧数据

对于标准安装,您可以使用以下命令删除 PG15 格式的旧数据:

cd /var/discourse
./launcher cleanup

如果您有单独的数据容器,则需要像这样删除备份副本:

rm -fr /var/discourse/shared/data/postgres_data_old/

常见问题

源集群未正常关闭

如果出现上述消息导致升级失败,您可以尝试一种更简单的方法来使其恢复到更好的状态。

使用 ./launcher start app 重新启动旧容器。等待几分钟,直到其恢复运行。

现在再次使用 ./launcher stop app 将其关闭。之后查看日志,确认是否为正常关闭:

tail -f shared/standalone/log/var-log/postgres/current
2025-01-24 09:19:06.437 UTC [37] LOG:  received smart shutdown request
2025-01-24 09:19:06.444 UTC [37] LOG:  background worker "logical replication launcher" (PID 54) exited with exit code 1
2025-01-24 09:19:06.446 UTC [49] LOG:  shutting down
2025-01-24 09:19:06.468 UTC [37] LOG:  database system is shut down

如果日志未显示数据库已关闭,您可以再次启动旧容器,使用 ./launcher enter app 进入,运行以下命令,完成后再次查看日志。

export SVWAIT=300
sv stop nginx
sv stop unicorn
sv stop postgres
exit

如果日志与上述内容一致,现在您可以使用 ./launcher rebuild app 再次尝试升级。

数据库 “postgres” 的 lc_collate 值不匹配

如果您为数据库使用了非默认区域设置,则会出现此错误。据报道,需要设置 3 个变量才能成功。请确保您的 app.yml 文件中的 env: 部分包含以下 3 行:

  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8

en_US.UTF-8 更改为您的区域设置。

每次重建都会再次执行升级(即升级循环)

发生这种情况时,您的升级日志中将包含以下内容:

mv: cannot move '/shared/postgres_data' to '/shared/postgres_data_old/postgres_data': Directory not empty
mv: cannot move '/shared/postgres_data_new' to '/shared/postgres_data/postgres_data_new': Directory not empty

这意味着上次升级的文件仍然残留。请在继续之前将这些文件移至其他位置。

我跳过了 PostgreSQL 15 更新,现在该怎么办?

您可以遵循本指南顶部的标准说明,它们将从您的版本顺利升级至 18,不会出现问题。

10 个赞

太棒了,谢谢克里斯!

1 个赞

如果可用磁盘空间不足,会发生什么样的(希望是)优雅降级?肯定有人会遇到这种情况!

对于可用磁盘空间不足的用户,先备份再恢复到全新安装的系统作为迁移方案,是否可行?

(如果是这样的话,这也是升级到操作系统新 LTS 版本的好时机。Ubuntu 26.04 刚发布不久,26.04.1 预计很快就会推出。全新安装操作系统可能比尝试就地升级更省心。)

3 个赞

我本来也会的,要不是我收到了关于这条帖子的邮件通知 :raised_back_of_hand: :flushed_face:

1 个赞

确认一下,这现在已经生效了吗?

如果我今天早上晚些时候通过命令行更新,这一切都会自动完成吗?

升级脚本会检查可用空间,仅在安全的情况下才会继续执行。

在升级过程中有两个步骤可能会面临磁盘空间不足的问题。如果您绕过可用空间检查,就可能会在此处遇到问题:

  1. 运行 pg_dump 从旧数据库提取数据时(此时需要 2 倍于数据库大小的存储空间)。
  2. 运行 pg_restore 将数据插入新数据库时(此时需要 3 倍于数据库大小的存储空间)。

要从此状态恢复,您需要删除 /shared/postgres_dump/shared/postgres_data_new

请注意,在升级结束时,我们会删除临时的 pg_dump 文件,但会保留升级前的数据库数据于 /shared/postgres_data_old 中,以防万一。一旦您确认一切正常运行,您可能希望删除该目录以释放磁盘空间。

我测试了在 PG15 站点上创建 Discourse 备份,然后将其恢复到 PG18 站点上。这对我有效,但请注意,这不是官方支持的方法。请先在非生产环境中进行彻底测试,并确保您有回滚方案!

我建议您研究升级脚本使用的流程。如果您有特殊的存储需求,应该能够将其调整为适合您的需求。同样,请先进行测试:

是的,这已经 集成到 discourse_docker 中。如果您拉取 main 分支或运行 ./launcher rebuild app,您将获得此功能。

如果您想推迟升级,将 discourse_docker 从 main 分支切换出去可以 帮助防止意外升级

3 个赞

你能具体说明一下“非常大”是什么意思吗?

我理解这是指需要3倍于你数据库大小的备用空间,无论数据库大小如何?

1 个赞

抱歉,那条警告措辞不当且有误。

除了磁盘上现有的数据库,你还需要足够的空闲空间来存放转储输出文件以及正在恢复的新数据库副本。由于 pg_dump 的输出通常比数据库数据目录小,因此预留两倍于当前数据库大小的空闲空间应该就足够了。我会修正升级脚本中的这一部分。

编辑:空闲空间检查已更新为查找两倍于数据库大小的空间,而非三倍。

3 个赞

看起来,在单核虚拟机上,由于以下限制,需要停留在 PG15 postgres.15.template.yml

pg_dump: error: -j/--jobs must be in range 1..2147483647

或者将 web.template.yml 中的参数修补为 -j1 以使用一个 CPU。(下次重建时将恢复默认值)。

是的,确实存在这样的配置!:blob_wave:

由于 nproc 的计算方式,我遇到了这个错误(我运行在单 vCPU 上):-j/–jobs 必须在 1..2147483647 范围内(它试图使用 -j0,因为 $(($(nproc) - 1)) = 1 - 1 = 0)

更新脚本应该更新为类似 -j$(( $(nproc) > 1 ? $(nproc) - 1 : 1 )) 的形式

2 个赞

在一台服务器上,我遇到了这个问题:

我通过移动这些目录解决了这个问题:

cd /var/discourse/shared/standalone
mv postgres_data_older postgres_data_oldest
mv postgres_data_old postgres_data_older

然后 ./launcher rebuild app 完成并显示:

-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 15 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------
1 个赞

在另一台服务器上,我遇到了 pg_dump 错误:

x86_64 arch detected.
Ensuring launcher is up to date
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 600 app
app
2.0.20260803-0122: Pulling from discourse/base
Digest: sha256:ab1e7217470759e63313a16bc5b71b9f2dd7d3ae8303286e5985f563ad12b7b3
Status: Image is up to date for discourse/base:2.0.20260803-0122
docker.io/discourse/base:2.0.20260803-0122
/usr/local/lib/ruby/gems/3.4.0/gems/pups-1.4.0/lib/pups.rb
/usr/local/bin/pups --stdin
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
I, [2026-08-03T09:02:29.698631 #1]  INFO -- : Reading from stdin
I, [2026-08-03T09:02:29.724575 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2026-08-03T09:02:29.737296 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2026-08-03T09:02:29.750650 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2026-08-03T09:02:29.763301 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown: 
I, [2026-08-03T09:02:29.775620 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2026-08-03T09:02:29.777021 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/18/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.778673 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.780140 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.781699 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.783144 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.784461 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.785820 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.787120 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.788468 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/18/main/postgresql.conf
I, [2026-08-03T09:02:29.789816 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/18/main/pg_hba.conf
I, [2026-08-03T09:02:29.790932 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/18/main/pg_hba.conf
I, [2026-08-03T09:02:29.792274 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/18/main/pg_hba.conf
I, [2026-08-03T09:02:29.793638 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
Generating locales (this might take a while)...
  en_GB.UTF-8... done
  en_US.UTF-8... done
Generation complete.
2026/08/03 09:02:33 socat[35] E connect(, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): Connection refused
Upgrading PostgreSQL from version 15 to 18
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with this locale configuration:
  locale provider:   builtin
  default collation: C.UTF-8
  LC_COLLATE:  C.UTF-8
  LC_CTYPE:    C.UTF-8
  LC_MESSAGES: C.UTF-8
  LC_MONETARY: C.UTF-8
  LC_NUMERIC:  C.UTF-8
  LC_TIME:     C.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /shared/postgres_data_new ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default "max_connections" ... 100
selecting default "shared_buffers" ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/lib/postgresql/18/bin/pg_ctl -D /shared/postgres_data_new -l logfile start

Get:1 http://deb.debian.org/debian bookworm-backports InRelease [59.4 kB]
Hit:2 http://deb.debian.org/debian bookworm InRelease
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Hit:4 http://deb.debian.org/debian-security bookworm-security InRelease
Hit:5 https://deb.nodesource.com/node_22.x nodistro InRelease
Hit:6 https://dl.yarnpkg.com/debian stable InRelease
Hit:7 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg InRelease
Fetched 115 kB in 1s (77.2 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  postgresql-15 postgresql-15-pgvector
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.2 MB of archives.
After this operation, 52.6 MB of additional disk space will be used.
Get:1 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 postgresql-15 amd64 15.18-1.pgdg12+1 [15.0 MB]
Get:2 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 postgresql-15-pgvector amd64 0.8.6-1.pgdg12+1 [271 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 15.2 MB in 1s (29.8 MB/s)
Selecting previously unselected package postgresql-15.
(Reading database ... 32784 files and directories currently installed.)
Preparing to unpack .../postgresql-15_15.18-1.pgdg12+1_amd64.deb ...
Unpacking postgresql-15 (15.18-1.pgdg12+1) ...
Selecting previously unselected package postgresql-15-pgvector.
Preparing to unpack .../postgresql-15-pgvector_0.8.6-1.pgdg12+1_amd64.deb ...
Unpacking postgresql-15-pgvector (0.8.6-1.pgdg12+1) ...
Setting up postgresql-15 (15.18-1.pgdg12+1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql-15-pgvector (0.8.6-1.pgdg12+1) ...
Processing triggers for postgresql-common (293.pgdg12+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Creating new PostgreSQL cluster 15/main ...
/usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/15/main --auth-local peer --auth-host scram-sha-256 --no-instructions
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_GB.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/15/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Stopping PostgreSQL 15 database server: main.
Stopping PostgreSQL 18 database server: main.
waiting for server to start....2026-08-03 09:02:47.642 UTC [1145] LOG:  starting PostgreSQL 15.18 (Debian 15.18-1.pgdg12+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit
2026-08-03 09:02:47.643 UTC [1145] LOG:  listening on IPv6 address "::1", port 5432
2026-08-03 09:02:47.644 UTC [1145] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2026-08-03 09:02:47.647 UTC [1145] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2026-08-03 09:02:47.664 UTC [1148] LOG:  database system was interrupted; last known up at 2026-08-03 08:59:02 UTC
2026-08-03 09:02:48.205 UTC [1148] LOG:  database system was not properly shut down; automatic recovery in progress
2026-08-03 09:02:48.212 UTC [1148] LOG:  invalid record length at 12/F5C779B0: wanted 24, got 0
2026-08-03 09:02:48.213 UTC [1148] LOG:  redo is not required
2026-08-03 09:02:48.218 UTC [1146] LOG:  checkpoint starting: end-of-recovery immediate wait
2026-08-03 09:02:48.230 UTC [1146] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.004 s, sync=0.002 s, total=0.013 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2026-08-03 09:02:48.252 UTC [1145] LOG:  database system is ready to accept connections
 done
server started
pg_dump: error: -j/--jobs must be in range 1..2147483647
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES FAILED
Failed on: su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/pg_dump -Fd -j$(($(nproc) - 1)) discourse -f /shared/postgres_dump/discourse"

Please visit https://meta.discourse.org/t/postgresql-18-update/406194 for support.

You can run ./launcher start app to restart your app in the meantime
-------------------------------------------------------------------------------------


FAILED
--------------------
Pups::ExecError: if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi
 failed with return #<Process::Status: pid 18 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.4.0/gems/pups-1.4.0/lib/pups/exec_command.rb:138:in 'Pups::ExecCommand#spawn'
exec failed with the params {"tag" => "db", "cmd" => "if [ -f /root/install_postgres ]; then\n  /root/install_postgres && rm -f /root/install_postgres\nelif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then\n  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1\nfi\n"}
bootstrap failed with exit code 1
---
HINT: The plugin 'discourse-calendar' is now bundled with Discourse and should not be included in your container configuration.
Remove the line 'git clone https://github.com/discourse/discourse-calendar' from your containers/app.yml file, then try again.
For more information, see https://meta.discourse.org/t/373574
---
---
HINT: The plugin 'discourse-templates' is now bundled with Discourse and should not be included in your container configuration.
Remove the line 'git clone https://github.com/discourse/discourse-templates' from your containers/app.yml file, then try again.
For more information, see https://meta.discourse.org/t/373574
---
---
HINT: The plugin 'discourse-policy' is now bundled with Discourse and should not be included in your container configuration.
Remove the line 'git clone https://github.com/discourse/discourse-policy' from your containers/app.yml file, then try again.
For more information, see https://meta.discourse.org/t/373574
---
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
d2f4b0c8ce1d67917f88c87da7d3fd8886b2b3c93800e30ae6d8ceeeb131a419

这是和上面一样的错误吗?需要编辑哪个升级脚本来修复这个问题?@Nacho_Caballero

3 个赞

本地 docker 开发环境,拉取最新的 release/2026.7 分支

d/shutdown_dev

d/boot_dev

然后运行

d/rails s

遇到下面的错误,怎么办?

singi@GL-D-009011A:~/discourse$ d/rails s
Starting Pitchfork...
Starting CSS change watcher
URGENT: Failed to initialize site default: ActiveRecord::ConnectionNotEstablished connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

/src/config/initializers/000-pg_connection_patch.rb:35:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new_client'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:944:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#connect'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:956:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#reconnect'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:670:in 'block (2 levels) in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:1224:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#attempt_configure_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:669:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:668:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:778:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:766:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:786:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#connect!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:992:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:991:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:128:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote_string'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/quoting.rb:76:in 'ActiveRecord::ConnectionAdapters::Quoting#quote'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:122:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1142:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#quoted_scope'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1119:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#data_source_sql'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:60:in 'ActiveRecord::ConnectionAdapters::SchemaStatements#table_exists?'
/src/lib/site_settings/db_provider.rb:58:in 'SiteSettings::DbProvider#table_exists?'
/src/lib/site_settings/db_provider.rb:14:in 'SiteSettings::DbProvider#all'
/src/lib/site_setting_extension.rb:1286:in 'SiteSettingExtension#fetch_setting_hash_from_provider'
/src/lib/site_setting_extension.rb:602:in 'block in SiteSettingExtension#refresh!'
/src/lib/site_setting_extension.rb:598:in 'Thread::Mutex#synchronize'
/src/lib/site_setting_extension.rb:598:in 'SiteSettingExtension#refresh!'
/src/config/initializers/005-site_settings.rb:19:in 'block (2 levels) in <main>'
/src/lib/freedom_patches/rails_multisite.rb:15:in 'block in RailsMultisite::ConnectionManagement.safe_each_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in 'RailsMultisite::ConnectionManagement::NullInstance#with_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:36:in 'RailsMultisite::ConnectionManagement::NullInstance#each_connection'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management.rb:17:in 'RailsMultisite::ConnectionManagement.each_connection'
/src/lib/freedom_patches/rails_multisite.rb:9:in 'RailsMultisite::ConnectionManagement.each_active_connection'
/src/lib/freedom_patches/rails_multisite.rb:14:in 'RailsMultisite::ConnectionManagement.safe_each_connection'
/src/config/initializers/005-site_settings.rb:18:in 'block in <main>'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'BasicObject#instance_exec'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'block in ActiveSupport::Callbacks::CallTemplate::InstanceExec0#make_lambda'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:178:in 'block in ActiveSupport::Callbacks::Filters::Before#call'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:668:in 'block (2 levels) in ActiveSupport::Callbacks::CallbackChain#default_terminator'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'Kernel#catch'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'block in ActiveSupport::Callbacks::CallbackChain#default_terminator'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:179:in 'ActiveSupport::Callbacks::Filters::Before#call'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'block in ActiveSupport::Callbacks::CallbackSequence#invoke_before'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'Array#each'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'ActiveSupport::Callbacks::CallbackSequence#invoke_before'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:108:in 'ActiveSupport::Callbacks#run_callbacks'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/reloader.rb:96:in 'ActiveSupport::Reloader.prepare!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application/finisher.rb:73:in 'block in <module:Finisher>'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'BasicObject#instance_exec'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'Rails::Initializable::Initializer#run'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:61:in 'block in Rails::Initializable#run_initializers'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:231:in 'block in TSort.tsort_each'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:353:in 'block (2 levels) in TSort.each_strongly_connected_component'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:434:in 'TSort.each_strongly_connected_component_from'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:352:in 'block in TSort.each_strongly_connected_component'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Rails::Initializable::Collection#each'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Method#call'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'TSort.each_strongly_connected_component'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:229:in 'TSort.tsort_each'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:208:in 'TSort#tsort_each'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:60:in 'Rails::Initializable#run_initializers'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application.rb:444:in 'Rails::Application#initialize!'
/src/config/environment.rb:7:in '<top (required)>'
/usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
/usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
config.ru:8:in 'block in <main>'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'BasicObject#instance_eval'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'Rack::Builder#initialize'
config.ru:3:in 'Class#new'
config.ru:3:in '<main>'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'Kernel#eval'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'block in Pitchfork.builder'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:1160:in 'Pitchfork::HttpServer#build_app!'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:694:in 'block in Pitchfork::HttpServer#spawn_initial_mold'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:170:in 'block in Pitchfork.clean_fork'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Kernel#catch'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Pitchfork.clean_fork'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:690:in 'Pitchfork::HttpServer#spawn_initial_mold'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:176:in 'Pitchfork::HttpServer#start'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/exe/pitchfork:110:in '<top (required)>'
/src/bin/pitchfork:58:in 'Kernel#load'
/src/bin/pitchfork:58:in 'block in <main>'
/src/bin/pitchfork:58:in 'Kernel#fork'
/src/bin/pitchfork:58:in '<main>'
/src/config/initializers/000-pg_connection_patch.rb:35:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new_client': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (ActiveRecord::ConnectionNotEstablished)
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:944:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#connect'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:956:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#reconnect'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:670:in 'block (2 levels) in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:1224:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#attempt_configure_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:669:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:668:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:778:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:766:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:786:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#connect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:992:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:991:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:128:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote_string'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/quoting.rb:76:in 'ActiveRecord::ConnectionAdapters::Quoting#quote'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:122:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1142:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#quoted_scope'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1119:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#data_source_sql'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:45:in 'ActiveRecord::ConnectionAdapters::SchemaStatements#data_source_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/schema_migration.rb:102:in 'block in ActiveRecord::SchemaMigration#table_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/schema_migration.rb:101:in 'ActiveRecord::SchemaMigration#table_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1282:in 'ActiveRecord::MigrationContext#get_all_versions'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1299:in 'ActiveRecord::MigrationContext#pending_migration_versions'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1295:in 'ActiveRecord::MigrationContext#needs_migration?'
        from /src/config/initializers/100-flags.rb:6:in 'block in <main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'BasicObject#instance_exec'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'block in ActiveSupport::Callbacks::CallTemplate::InstanceExec0#make_lambda'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:178:in 'block in ActiveSupport::Callbacks::Filters::Before#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:668:in 'block (2 levels) in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'Kernel#catch'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'block in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:179:in 'ActiveSupport::Callbacks::Filters::Before#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'block in ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'Array#each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:108:in 'ActiveSupport::Callbacks#run_callbacks'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/reloader.rb:96:in 'ActiveSupport::Reloader.prepare!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application/finisher.rb:73:in 'block in <module:Finisher>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'BasicObject#instance_exec'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'Rails::Initializable::Initializer#run'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:61:in 'block in Rails::Initializable#run_initializers'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:231:in 'block in TSort.tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:353:in 'block (2 levels) in TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:434:in 'TSort.each_strongly_connected_component_from'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:352:in 'block in TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Rails::Initializable::Collection#each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Method#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:229:in 'TSort.tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:208:in 'TSort#tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:60:in 'Rails::Initializable#run_initializers'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application.rb:444:in 'Rails::Application#initialize!'
        from /src/config/environment.rb:7:in '<top (required)>'
        from /usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from config.ru:8:in 'block in <main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'BasicObject#instance_eval'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'Rack::Builder#initialize'
        from config.ru:3:in 'Class#new'
        from config.ru:3:in '<main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'Kernel#eval'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'block in Pitchfork.builder'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:1160:in 'Pitchfork::HttpServer#build_app!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:694:in 'block in Pitchfork::HttpServer#spawn_initial_mold'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:170:in 'block in Pitchfork.clean_fork'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Kernel#catch'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Pitchfork.clean_fork'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:690:in 'Pitchfork::HttpServer#spawn_initial_mold'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:176:in 'Pitchfork::HttpServer#start'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/exe/pitchfork:110:in '<top (required)>'
        from /src/bin/pitchfork:58:in 'Kernel#load'
        from /src/bin/pitchfork:58:in 'block in <main>'
        from /src/bin/pitchfork:58:in 'Kernel#fork'
        from /src/bin/pitchfork:58:in '<main>'
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pg-1.6.3-x86_64-linux/lib/pg/connection.rb:944:in 'PG::Connection.connect_start': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (PG::ConnectionBad)
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pg-1.6.3-x86_64-linux/lib/pg/connection.rb:944:in 'PG::Connection.connect_to_hosts'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pg-1.6.3-x86_64-linux/lib/pg/connection.rb:871:in 'PG::Connection.new'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pg-1.6.3-x86_64-linux/lib/pg.rb:88:in 'PG.connect'
        from /src/config/initializers/000-pg_connection_patch.rb:5:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new_client'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:944:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#connect'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql_adapter.rb:956:in 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#reconnect'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:670:in 'block (2 levels) in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:1224:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#attempt_configure_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:669:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:668:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#reconnect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:778:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:766:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#verify!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:786:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#connect!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:992:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:991:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:128:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote_string'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/quoting.rb:76:in 'ActiveRecord::ConnectionAdapters::Quoting#quote'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/quoting.rb:122:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1142:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#quoted_scope'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1119:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#data_source_sql'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:45:in 'ActiveRecord::ConnectionAdapters::SchemaStatements#data_source_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/schema_migration.rb:102:in 'block in ActiveRecord::SchemaMigration#table_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/schema_migration.rb:101:in 'ActiveRecord::SchemaMigration#table_exists?'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1282:in 'ActiveRecord::MigrationContext#get_all_versions'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1299:in 'ActiveRecord::MigrationContext#pending_migration_versions'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activerecord-8.0.5/lib/active_record/migration.rb:1295:in 'ActiveRecord::MigrationContext#needs_migration?'
        from /src/config/initializers/100-flags.rb:6:in 'block in <main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'BasicObject#instance_exec'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:406:in 'block in ActiveSupport::Callbacks::CallTemplate::InstanceExec0#make_lambda'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:178:in 'block in ActiveSupport::Callbacks::Filters::Before#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:668:in 'block (2 levels) in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'Kernel#catch'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:667:in 'block in ActiveSupport::Callbacks::CallbackChain#default_terminator'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:179:in 'ActiveSupport::Callbacks::Filters::Before#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'block in ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'Array#each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:559:in 'ActiveSupport::Callbacks::CallbackSequence#invoke_before'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/callbacks.rb:108:in 'ActiveSupport::Callbacks#run_callbacks'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/activesupport-8.0.5/lib/active_support/reloader.rb:96:in 'ActiveSupport::Reloader.prepare!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application/finisher.rb:73:in 'block in <module:Finisher>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'BasicObject#instance_exec'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:32:in 'Rails::Initializable::Initializer#run'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:61:in 'block in Rails::Initializable#run_initializers'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:231:in 'block in TSort.tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:353:in 'block (2 levels) in TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:434:in 'TSort.each_strongly_connected_component_from'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:352:in 'block in TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Rails::Initializable::Collection#each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'Method#call'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:350:in 'TSort.each_strongly_connected_component'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:229:in 'TSort.tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/tsort-0.2.0/lib/tsort.rb:208:in 'TSort#tsort_each'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/initializable.rb:60:in 'Rails::Initializable#run_initializers'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/railties-8.0.5/lib/rails/application.rb:444:in 'Rails::Application#initialize!'
        from /src/config/environment.rb:7:in '<top (required)>'
        from /usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from config.ru:8:in 'block in <main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'BasicObject#instance_eval'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/rack-2.2.23/lib/rack/builder.rb:125:in 'Rack::Builder#initialize'
        from config.ru:3:in 'Class#new'
        from config.ru:3:in '<main>'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'Kernel#eval'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:91:in 'block in Pitchfork.builder'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:1160:in 'Pitchfork::HttpServer#build_app!'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:694:in 'block in Pitchfork::HttpServer#spawn_initial_mold'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:170:in 'block in Pitchfork.clean_fork'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Kernel#catch'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork.rb:168:in 'Pitchfork.clean_fork'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:690:in 'Pitchfork::HttpServer#spawn_initial_mold'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:176:in 'Pitchfork::HttpServer#start'
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/exe/pitchfork:110:in '<top (required)>'
        from /src/bin/pitchfork:58:in 'Kernel#load'
        from /src/bin/pitchfork:58:in 'block in <main>'
        from /src/bin/pitchfork:58:in 'Kernel#fork'
        from /src/bin/pitchfork:58:in '<main>'
mold gen=0 pid=189 reaped (#<Process::Status: pid 189 exit 1>)
/home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/lib/pitchfork/http_server.rb:179:in 'Pitchfork::HttpServer#start': The initial mold failed to boot (Pitchfork::BootFailure)
        from /home/discourse/.bundle/gems/ruby/3.4.0/gems/pitchfork-0.18.2/exe/pitchfork:110:in '<top (required)>'
        from /src/bin/pitchfork:58:in 'Kernel#load'
        from /src/bin/pitchfork:58:in 'block in <main>'
        from /src/bin/pitchfork:58:in 'Kernel#fork'
        from /src/bin/pitchfork:58:in '<main>'

应该是 pg15 升级到 pg18 导致的。

我想我也遇到了同样的问题。

/var/discourse/templates/web.template.yml 中,需要修改的是 bundle install jobs 那一行(大约在第 209 行):

修改前(在单 CPU 主机上会出错):

- su discourse -c 'bundle install --jobs $(($(nproc) - 1)) --retry 3'

修改后:

- su discourse -c 'bundle install --jobs 1 --retry 3'

注意是 --jobs 1,而不是 -j1。Bundler 使用的是 --jobs;而 -j 是用于 templates/postgres.template.yml(以及 postgres.18.template.yml)中的 pg_dump / pg_restore。例如,如果再次遇到 PostgreSQL 升级失败,请在那里将 -j$(($(nproc) - 1)) 改为 -j1

2 个赞

我通过下面的方式解决了。

d/shutdown_dev

# 删除本地数据库
sudo rm -rf ~/discourse/data/postgres

# 重新初始化数据库
d/boot_dev -i

会丢失本地开发数据!!!考虑从测试环境恢复。

修复核心数量的补丁正在路上。没意识到我们有这么多单 CPU 用户,抱歉!

4 个赞

(帖子已被作者删除)

我已更新核心数检测,改为使用 nproc --ignore=1

1 个赞

我的第一次升级顺利完成,尽管期间出现了一些奇怪的容器连接错误,但通过再次重建数据解决了问题。

(这是一个双容器配置)。

不过最终一切顺利。

非常感谢您在这方面的辛勤工作!

3 个赞