postgresql 针对Vercel Postgres的Github操作期间Prisma种子超时

2vuwiymt  于 2023-06-22  发布在  PostgreSQL
关注(0)|答案(1)|浏览(181)

尝试使用Prisma将Postgres数据库从AWS RDS迁移到Vercel,用于Nextjs项目。
当从本地计算机运行db seed命令时,它成功完成。根据vercel上的文档,我使用了为prisma创建和推荐的特定env变量。

datasource db {
  provider          = "postgresql"
  url               = env("POSTGRES_PRISMA_URL") // uses connection pooling
  directUrl         = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
  shadowDatabaseUrl = env("POSTGRES_URL_NON_POOLING") // used for migrations
}

当试图从Github操作运行seed命令时,问题出现了,我从Prisma得到了这个讨厌的错误:

No pending migrations to apply.
Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...
Connecting to database

An error occurred while running the seed command:
Error: Command was killed with SIGSEGV (Segmentation fault): ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts
Error: Command "npm run vercel-build" exited with 1
Error: Process completed with exit code 1.

当我将我的项目从本地机器直接部署到vercel时,我也会得到一个超时。因此,我的lambda函数和github action似乎都无法连接到Vercel中的新数据库。
我尝试的另一件事是在种子过程中使用@vercel/postgres库,看看它是否是Prisma问题。

console.log(chalk.blue('Connecting to database'));
  const client = await db.connect();
  console.log(chalk.green('Connected to database'));
  const data = await client.sql`select * from "xxx" limit 1`;
  console.log('rows', data.rowCount);

这一次更有意义一点:

The database server at `xxx.us-east-1.postgres.vercel-storage.com`:`5432` was reached but timed out.

Please try again.

Please make sure your database server is running at `xxx.us-east-1.postgres.vercel-storage.com`:`5432`.

Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See https://pris.ly/d/migrate-advisory-locking for details.
zbwhf8kr

zbwhf8kr1#

问题出在我使用的Prisma版本,而不是怀疑的网络。
从4.11.0升级到4.15.0之后,一切都恢复正常。使这一问题变得困难的是缺乏本地运行的问题。
Github问题:https://github.com/prisma/prisma/issues/13641#issuecomment-1511425973

相关问题