Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations started using significantly more memory in 5.13.0 and crash with OOM #24061

Open
kibertoad opened this issue May 2, 2024 · 5 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: cockroachdb topic: prisma migrate deploy CLI: prisma migrate deploy

Comments

@kibertoad
Copy link

kibertoad commented May 2, 2024

Bug description

Our migrations have started to fail with OOM error even for smaller databases with a limited amount of migrations.

This may be related to some specific functionality that we use - CockroachDB, multischema support or ULID identifiers. Example schema that fail during migration is included.

Downgrading to 5.12.1 has fixed the issue.

Increasing amount of memory available for the deployment job from 128 MBs to 512 MBs also helps, but that is not an ideal solution.

How to reproduce

Generate migrations and run prisma migrate deploy

Note that this works fine on developer machines, but fail during actual deployment to staging/live environments. In order to reproduce, ensure that you have 128 MBs of memory or less during the execution.

Expected behavior

Migrations pass successfully

Prisma information

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["multiSchema"]
}

datasource db {
  provider     = "cockroachdb"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
  schemas      = ["serviceschema"]
}

/// -----------------------------------------------------------------------------------------------------
/// Content
/// -----------------------------------------------------------------------------------------------------

model TranslationContext {
  id                     String   @id @default(dbgenerated("gen_random_ulid()")) @db.Uuid
  createdAt              DateTime @default(now()) @map("created_at") @db.Timestamptz()
  otherField             Json? @map("other_field")
  someField              Json?     @map("some_field")

  segments Segment[]

  @@map("translation_context")
  @@schema("serviceschema")
}

model Segment {
  jobId                String   @map("job_id") @db.Uuid
  id                   String   @default(dbgenerated("gen_random_ulid()")) @db.Uuid
  externalId           String   @map("external_id") @db.String(128)
  contentUnitId        String   @map("content_unit_id") @db.String(128)
  tenantId             String   @map("tenant_id") //@db.(16) Enum
  ownerId              String   @map("owner_id") @db.String(128)
  originCorrelationId  String   @map("origin_correlation_id") @db.String(128)
  translationContextId String?  @map("translation_context_id") @db.Uuid
  translationContext   TranslationContext? @relation(fields: [translationContextId], references: [id])
  description          String?
  position             Int
  targetLocale         String   @map("target_locale") @db.String(16)
  translatedValue      String?  @map("translated_value")
  sourceValue          String   @map("source_value")
  someField            String?  @map("some_field")
  field                Float?   @map("field")
  createdAt            DateTime @default(now()) @map("created_at") @db.Timestamptz()

  @@id([jobId, id])
  @@unique([ownerId, originCorrelationId, targetLocale, tenantId, externalId, someField])
  @@index([translationContextId])
  @@map("segment")
  @@schema("serviceschema")
}

Environment & setup

  • OS: Debian Bookworm
  • Database: CockroachDB: cockroachdb/cockroach:latest-v23.2
  • Node.js version: node:20.11.1-bookworm-slim

Prisma Version

5.13.0
@kibertoad kibertoad added the kind/bug A reported bug. label May 2, 2024
@SevInf SevInf added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. team/schema Issue for team Schema. topic: prisma migrate deploy CLI: prisma migrate deploy labels May 2, 2024
@SevInf
Copy link
Contributor

SevInf commented May 2, 2024

Hi @kibertoad.
Is a single init migration enough to repoduce the issue? Or we'd need a longer migration history?
Thank you.

@kibertoad
Copy link
Author

@SevInf Single migration should suffice, we've recently regenerated it, and it was failing as a single standalone migration.

@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels May 3, 2024
@kibertoad
Copy link
Author

Update: doesn't seem to be limited to CockroachDB, we are getting the same problem in our MySQL databases after the update too.

@janpio
Copy link
Member

janpio commented May 10, 2024

Just to make sure:
Everything else besides the Prisma version is the same when you are running this @kibertoad? Or did the downgrade maybe also revert some other dependency or container updates?

@kibertoad
Copy link
Author

kibertoad commented May 10, 2024

@janpio no, it was only prisma and nothing else in all cases.

Here is the output from console, btw:

 db:migration:run> dotenv prisma migrate deploy
Prisma schema loaded from prisma/schema.prisma
Datasource "db": CockroachDB database "redacted", schemas "redacted" at "redacted"
 Killed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: cockroachdb topic: prisma migrate deploy CLI: prisma migrate deploy
Projects
None yet
Development

No branches or pull requests

4 participants