Migrate: DB migration Error: P1008 Operations timed out after 30s
See original GitHub issue- I updated prisma to v2.20.1
- Prisma automatically created a migration.
- I migrated the local db and a small dev db and everything worked fine.
- I migrated the prod db which contains way more data.
- Error: P1008 Operations timed out after
30s
prisma migrate status
after the Operations timed out error:
Following migration have failed:
20210407123735_prisma_adaptions
During development if the failed migration(s) have not been deployed to a production database you can then fix the migration(s) and run yarn prisma migrate dev.
The failed migration(s) can be marked as rolled back or applied:
- If you rolled back the migration(s) manually:
yarn prisma migrate resolve --rolled-back "20210407123735_prisma_adaptions"
- If you fixed the database manually (hotfix):
yarn prisma migrate resolve --applied "20210407123735_prisma_adaptions"
Read more about how to resolve migration issues in a production database:
https://pris.ly/d/migrate-resolve
Prisma information
migration.sql:
-- DropIndex
DROP INDEX "UserData_id_unique";
-- DropIndex
DROP INDEX "StaffData_id_unique";
-- AlterTable
ALTER TABLE "CameraPair" ALTER COLUMN "frameRate" SET DATA TYPE DOUBLE PRECISION,
ALTER COLUMN "targetBrightness" SET DATA TYPE DOUBLE PRECISION;
-- AlterTable
ALTER TABLE "Country" ALTER COLUMN "netFreq" SET DATA TYPE DOUBLE PRECISION;
-- AlterTable
ALTER TABLE "IpCamera" ALTER COLUMN "frameRate" SET DATA TYPE DOUBLE PRECISION;
-- AlterTable
ALTER TABLE "IpVideo" ALTER COLUMN "fps" SET DATA TYPE DOUBLE PRECISION,
ALTER COLUMN "fpsRecorded" SET DATA TYPE DOUBLE PRECISION;
-- AlterTable
ALTER TABLE "RankingEntry" ALTER COLUMN "score" SET DATA TYPE DOUBLE PRECISION,
This is only a part of the automatically by primes created migration file.
The rest of the migration contain the same commands with different variables.
ALTER TABLE "otherMode" ALTER COLUMN "otherAttribute" SET DATA TYPE DOUBLE PRECISION,
Environment & setup
Database: PostgreSQL Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-70-generic x86_64) Prisma v2.20.1
Update
-
The default connect_timeout is 5. The connection of my DB is
db-prod?sslmode=require&connect_timeout=30&socket_timeout=30
As far as I know 30 seconds is currently the maximum timeout that can be set. -
I was able to finish the migration by rolling it back and then applying it again. In the process I had to remove
DROP INDEX "UserData_id_unique"
andDROP INDEX "StaffData_id_unique";
because they were already dropped during the first time the migration has been applied. Performing the second migration took only a few seconds. From this I conclude that, although according to prisma status, that the migration failed, all changes to the database have been made.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top GitHub Comments
Thanks @tomhoule, good idea! I think, this will work for me. Consider the issue as solved from my side. Feel free to close it. Maybe the solution could added somewhere in the docs or as an example, if you think that others might have the problem as well.
The way I would approach it would be using different connection URLs for migrate (during deployment) and in client (in the deployed app). This is a downside of the connection string (vs structured connection object) approach, where you need to have two connection strings that are mostly the same. This has shown up in other areas, like pgbouncer mode. Would this be a viable solution in your deployment setup? Do you have ideas on a better system? Environment management is very much an ongoing problem we are thinking about.