Infinite loop during postgres upgrade

在从 PotsgreSQL 13 升级到 15 的过程中,我遇到了这个问题。

在我们的部署中,/shared/postgres_data 目录挂载在一个更快的 NVMe 存储设备上,因此移动它时出现“设备或资源繁忙”的错误消息。

我们通过如下方式修补 postgres 模板来解决此问题:

diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml
index c24bfe6..03813c4 100644
--- a/templates/postgres.template.yml
+++ b/templates/postgres.template.yml
@@ -139,8 +139,10 @@ run:
            exit 1
          fi
 
-         mv /shared/postgres_data /shared/postgres_data_old
-         mv /shared/postgres_data_new /shared/postgres_data
+         mkdir /shared/postgres_data_old
+         mv /shared/postgres_data/* /shared/postgres_data_old
+         mv /shared/postgres_data_new/* /shared/postgres_data
+         rmdir /shared/postgres_data_new

与其尝试操作目录本身,不如移动其中的内容。

请考虑集成此更改以提高数据库升级的可靠性。

1 个赞