【发布时间】:2021-04-17 15:02:19
【问题描述】:
自从我有了基于 ARM 的新 M1 MacBook Pro 以来,我一直遇到严重且一致的 PostgreSQL 问题 (psql 13.1)。无论我使用 Rails 服务器还是 Foreman,我都会在浏览器和终端中收到错误,例如 PG::InternalError: ERROR: could not read block 15 in file "base/147456/148555": Bad address 或 PG::Error (invalid encoding name: unicode) 或 Error during failsafe response: PG::UnableToSend: no connection to the server。奇怪的是,我经常可以反复刷新浏览器以使事情正常运行(直到它们不可避免地不再运行)。
我知道与基于 ARM 的 M1 Mac 相关的所有配置挑战,这就是为什么我以多种方式多次卸载并重新安装了从 Homebrew 到 Postgres 的所有内容(使用 Rosetta,没有 Rosetta,使用 arch -x86_64 brew命令,使用 Postgres 应用程序而不是 Homebrew 安装)。我在随机留言板上遇到了其他几个人,他们遇到了同样的问题(也在新的 Mac 上)并且没有任何运气,这就是为什么我不愿意相信这是一个驱动器损坏问题。 (我还多次运行磁盘工具急救检查;它说一切正常,但我不知道这有多可靠。)
我正在使用thoughtbot parity 将我的开发环境数据库与当前生产的数据库同步。当我运行development restore production 时,我的终端中有数百行类似于下面的输出(这是在下载完成之后但在继续创建默认值、处理数据、序列集等之前)。我相信这是问题的根源,但我不确定解决方案是什么:
pg_restore: dropping TABLE [table name1]
pg_restore: from TOC entry 442; 1259 15829269 TABLE [table name1] u1oi0d2o8cha8f
pg_restore: error: could not execute query: ERROR: table "[table name1]" does not exist
Command was: DROP TABLE "public"."[table name1]";
pg_restore: dropping TABLE [table name2]
pg_restore: from TOC entry 277; 1259 16955 TABLE [table name2] u1oi0d2o8cha8f
pg_restore: error: could not execute query: ERROR: table "[table name2]" does not exist
Command was: DROP TABLE "public"."[table name2]";
pg_restore: dropping TABLE [table name3]
pg_restore: from TOC entry 463; 1259 15830702 TABLE [table name3] u1oi0d2o8cha8f
pg_restore: error: could not execute query: ERROR: table "[table name3]" does not exist
Command was: DROP TABLE "public"."[table name3]";
pg_restore: dropping TABLE [table name4]
pg_restore: from TOC entry 445; 1259 15830421 TABLE [table name4] u1oi0d2o8cha8f
pg_restore: error: could not execute query: ERROR: table "[table name4]" does not exist
Command was: DROP TABLE "public"."[table name4]";
有其他人经历过吗?任何解决方案的想法将不胜感激。谢谢!
编辑:我能够在较旧的 MacBook Pro(也运行 Big Sur)上重现相同的问题,因此它似乎与 M1 无关,但可能与 Big Sur 有关。
【问题讨论】:
-
"Bad address" 是与
EFAULT相关联的消息,这意味着 postgres 将无效指针传递给read()或类似的系统调用。这表明 postgres 或某些相关库中存在相当低级的错误,或者由于硬件故障、过热等导致内存损坏。 -
谢谢,内特。有什么方法可以可靠地诊断是硬件问题还是低级 Postgres(或相关库)错误?
-
我的 ARM MacBook Air 也有同样的问题,但并非始终如一。如果我重新启动 Postgres,错误不会弹出一段时间。在有原生 ARM 版本之前,这个问题很可能会一直存在。
-
是的,在我的 M1 Mac Mini 上遇到了同样的问题。我通过自制软件安装了本机版本的 Postgres。
-
我的 M1 Mini 也有同样的问题。本机和 x86。奇怪的是,重新启动 Postgres 似乎确实有时会使错误消失。
标签: macos-big-sur pg-restore apple-silicon postgresql-13 thoughtbot