Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Intinite loop on deploy when adding @unique to column #1773

Closed
attilah opened this issue Jan 30, 2018 · 4 comments
Closed

Intinite loop on deploy when adding @unique to column #1773

attilah opened this issue Jan 30, 2018 · 4 comments

Comments

@attilah
Copy link

attilah commented Jan 30, 2018

Current behavior

upon updating a schema in a specific way, deploy goes into infinite loop with a step

Reproduction

deploy this schema

type ContentProvider {
  id: ID! @unique
  type: ContentProviderType!
}

enum ContentProviderType {
  Twitter
}

insert 2 records with the Twitter type:

mutation {
  t1: createContentProvider( data: {
    type: Twitter
  }) {
    id
  }

  t2: createContentProvider( data: {
    type: Twitter
  }) {
    id
  }
}

update the schema by adding @unique to type field. This should cause SQL exception since the schema violates the existing data in the database.

type ContentProvider {
  id: ID! @unique
  type: ContentProviderType! @unique
}

enum ContentProviderType {
  Twitter
}

what I'm getting on console is repeated entries of these lines:

client Sending query to cluster local +505ms
  client http://localhost:4466/cluster +1ms
  client query ($name: String! $stage: String!) {
  client           migrationStatus(name: $name stage: $stage) {
  client             projectId
  client             revision
  client             status
  client             applied
  client             rolledBack
  client             errors
  client           }
  client         }
  client          +1ms
  client { stage: 'dev', name: 'foo' } +2ms
  client { migrationStatus:
  client    { rolledBack: 0,
  client      applied: 6,
  client      projectId: 'foo@dev',
  client      errors: [],
  client      revision: 2,
  client      status: 'SUCCESS' } } +20ms

Expected behavior?

Meaningful error message "translated" from the SQL error that this schema modification is not possible.

@do4gr
Copy link
Member

do4gr commented May 7, 2018

Setting a unique constraint will error if there are already duplicates present in the case of a field update or if a new field is required and unique since SQL will set default values for the newly required fields. I'm closing this issue since it seems to show symptoms of this problem. With the deploy changes from 1.6.1 and this PR the issue should be fixed https://github.com/graphcool/prisma/pull/2371
If anyone is still experiencing problems please open a new issue with a reproduction.

@marktani marktani closed this as completed May 9, 2018
@gregwebs
Copy link

I am still able to make an infinite loop. This is a database configuration issue on my end, but errors show up for the Migration and requests are continually sent. An exit is expected rather than an infinite loop.

@marktani
Copy link
Contributor

Hi @gregwebs, please create a new issue in which you share a "before" and "after" version of your datamodel that causes the infinite loop. There are other known issues that cause this symptom collected here: #2018.

@gregwebs
Copy link

My point is not that I have a particular case that causes an infinite loop, but that an infinite loop should not be possible. prisma appears to have an unbounded error retry in some error situations during deploy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants