Graphql-engine: Issue when deploying Hasura on Render.com

Created on 6 Sep 2020  路  11Comments  路  Source: hasura/graphql-engine

Hey guys,

I'm trying to deploy my hasura on render.com and I have the following error:

Sep 6 07:39:55 PM  time="2020-09-06T17:39:55Z" level=fatal msg="failed to apply metadata: cannot apply metadata on the database: [unexpected] database query error ($.args[0].args)\r\n[23503] FatalError: update or delete on table \"hdb_table\" violates foreign key constraint \"hdb_permission_table_schema_fkey\" on table \"hdb_permission\"\r\nDescription: Key (table_schema, table_name)=(public, workspaces) is still referenced from table \"hdb_permission\"."

Here is my dockerFile:

FROM hasura/graphql-engine:v1.3.1.cli-migrations-v2

COPY migrations /hasura-migrations
COPY metadata /hasura-metadata

CMD graphql-engine serve --server-port $PORT

I have only 1 migration file.

In terms of metadata, I have a remote schema, 1 remote relationship, 1 role with 3 permissions

Do you have any idea?

question

Most helpful comment

Hey @tirumaraiselvan,

Hope you're well!

I've tried with Hasura Cloud and it works without any trouble. It's good, but I'm curious why it doesn't work in Render, do you have any clues?

Because I would like to keep all my infra on a same service

All 11 comments

Looking at the error, seems like an issue with some permission/table metadata, specifically public.workspaces.

Would it be okay to share the full metadata for the table? (you may obfuscate any sensitive information )

Hum ok, just to let you know, it works perfectly in local environment

Here is our metadata/tables.yaml file:

- table:
    schema: public
    name: employees
  object_relationships:
  - name: workspace
    using:
      foreign_key_constraint_on: workspace_id
  insert_permissions:
  - role: owner
    permission:
      check:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
      set:
        created_by: x-hasura-User-Id
      columns:
      - created_by
      - email
      - lang
      - name
      - status
      - workspace_id
      backend_only: false
  select_permissions:
  - role: owner
    permission:
      columns:
      - id
      - email
      - name
      - lang
      - status
      - created_by
      - workspace_id
      - created_at
      - updated_at
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
  update_permissions:
  - role: owner
    permission:
      columns:
      - email
      - lang
      - name
      - status
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
      check: null
  delete_permissions:
  - role: owner
    permission:
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
- table:
    schema: public
    name: employees_groups
  object_relationships:
  - name: employee
    using:
      foreign_key_constraint_on: employee_id
  - name: group
    using:
      foreign_key_constraint_on: group_id
  insert_permissions:
  - role: owner
    permission:
      check:
        _and:
        - group:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
        - employee:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
      columns:
      - employee_id
      - group_id
      backend_only: false
  select_permissions:
  - role: owner
    permission:
      columns:
      - created_at
      - employee_id
      - group_id
      filter:
        _and:
        - group:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
        - employee:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
  delete_permissions:
  - role: owner
    permission:
      filter:
        _and:
        - group:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
        - employee:
            workspace:
              owner_id:
                _eq: X-Hasura-User-Id
- table:
    schema: public
    name: groups
  object_relationships:
  - name: workspace
    using:
      foreign_key_constraint_on: workspace_id
  insert_permissions:
  - role: owner
    permission:
      check:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
      set:
        created_by: x-hasura-User-Id
      columns:
      - created_by
      - name
      - workspace_id
      backend_only: false
  select_permissions:
  - role: owner
    permission:
      columns:
      - id
      - name
      - created_by
      - workspace_id
      - created_at
      - updated_at
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
  update_permissions:
  - role: owner
    permission:
      columns:
      - name
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
      check: null
  delete_permissions:
  - role: owner
    permission:
      filter:
        workspace:
          owner_id:
            _eq: X-Hasura-User-Id
- table:
    schema: public
    name: workspaces
  array_relationships:
  - name: employees
    using:
      foreign_key_constraint_on:
        column: workspace_id
        table:
          schema: public
          name: employees
  remote_relationships:
  - definition:
      remote_field:
        me:
          arguments: {}
      hasura_fields: []
      remote_schema: API
    name: user
  insert_permissions:
  - role: owner
    permission:
      check:
        owner_id:
          _eq: X-Hasura-User-Id
      set:
        owner_id: x-hasura-User-Id
      columns:
      - country
      - industry
      - name
      - owner_id
      - region
      - size
      backend_only: false
  select_permissions:
  - role: owner
    permission:
      columns:
      - id
      - name
      - region
      - size
      - industry
      - owner_id
      - created_at
      - updated_at
      filter:
        owner_id:
          _eq: X-Hasura-User-Id
  update_permissions:
  - role: owner
    permission:
      columns:
      - industry
      - name
      - size
      filter:
        owner_id:
          _eq: X-Hasura-User-Id
      check: null
  delete_permissions:
  - role: owner
    permission:
      filter:
        owner_id:
          _eq: X-Hasura-User-Id

Hum ok, just to let you know, it works perfectly in local environment

I see. The error shows that it is breaking a foreign key reference of some metadata tables during metadata apply. Is this a fresh render instance?

Yes it's a fresh render instance. I can try again by removing my DB

Hey @tirumaraiselvan,

Hope you're well!

I've tried with Hasura Cloud and it works without any trouble. It's good, but I'm curious why it doesn't work in Render, do you have any clues?

Because I would like to keep all my infra on a same service

saddly it happen all the time in render.com, @anurag do you have any idea of the problem ? in a previous project i was doing stuff like that https://gitlab.factory.social.gouv.fr/SocialGouv/emjpm/-/blob/e0621003a568fbf68a42bcec2087aa486b78b558/docker/postgres/postgres-init.sh

Thanks @kwiss :) I'm also pretty sure it's on Render.com side 馃挴

@kwiss we'll follow up in Render chat. @Ciboulette are you seeing the issue as well?

@anurag Yes I'm seeing this issue as well, this is why I've created this issue in the first place 馃榿

@tirumaraiselvan are you aware a postgres extention that could lead to this bug ?
it look like it's the only difference since i use a classic PG 11 docker image locally and render.com use PG 11 too with lots of extentions
here is the list of the render extentions https://render.com/docs/databases#postgresql-extensions

It's an issue on render.com. Nothing related to hasura itself. I'm closing this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EmrysMyrddin picture EmrysMyrddin  路  3Comments

lishine picture lishine  路  3Comments

cpursley picture cpursley  路  3Comments

Fortidude picture Fortidude  路  3Comments

shahidhk picture shahidhk  路  3Comments