question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrate: DB migration Error: P1008 Operations timed out after 30s

See original GitHub issue
  1. I updated prisma to v2.20.1
  2. Prisma automatically created a migration.
  3. I migrated the local db and a small dev db and everything worked fine.
  4. I migrated the prod db which contains way more data.
  5. 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

  1. 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.

  2. 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" and DROP 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:open
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
henrikupercommented, Jun 15, 2021

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.

1reaction
tomhoulecommented, Jun 15, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Codes - Delicious Brains
This error occurs when the remote server returns an unexpected '0' in the HTTP request response body. This usually indicates that WP Migrate...
Read more >
Prisma build error: · Issue #7303 · keystonejs/keystone - GitHub
Error : Error in migration engine: db error: ERROR: prepared statement "s..." already exists; The database server at : was reached but timed...
Read more >
SQL Timout when runnnig migrate_tools commands [#3146649]
Running any migrate_tool commands causes an error to occur. drush migrate:import --all PDOException: SQLSTATE[HY000] [2002] Operation timed ...
Read more >
Timeout when setting up Entity Framework connecting to Azure
Short Answer. It takes about 120 seconds for SQL Azure to create a database. That is why you are timing out. So, increase...
Read more >
Timeout error after SQL Server upgrade from 2008R2 to SQL ...
The cause of the problem was, after the database migration to our new server the system database file size was not configured and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found