graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

AlternativeSubPlan found with no parent plan

Open rbolink opened this issue 3 years ago • 1 comments

Version Information

hasura/graphql-engine: v2.2.0 timescale/timescaledb-ha: pg12.9-ts2.5.0-p1

What is the expected behaviour?

The database currently has 2 tables:

afbeelding

We are using Timescale to improve performance when handling time-series data. So I converted the measurement table into a hypertable.

To keep everything secure we are using permissions to handle accessibility of all tables. So when a user wants to insert a new measurement into the measurement table a permission is checked to check that the authenticated user is equal to the user that belongs to the measurement.

The expected behaviour is that the measurement is inserted into the hypertable without any errors.

Keywords

  • AlternativeSubPlan
  • SubPlan
  • parent plan

What is the current behaviour?

When trying to insert a new measurement as a user the following error is shown:

postgres-error: database query error

When checking the logs of the PostgreSQL (with Timescale) instance I saw the following error:

AlternativeSubPlan found with no parent plan

This error is caused by this generated query that checks the permission:

afbeelding

Especially the measurement.user_id part of line 18 in the query is the main cause. When changing this part to just a text field, the query succeeds.

How to reproduce the issue?

version: '3.6'
services:
  timescale:
    image: timescale/timescaledb-ha:pg12.8-ts2.4.2-p4
    restart: always
    ports:
    - '5433:5432'
    volumes:
      - mia_db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
  graphql-engine:
    image: hasura/graphql-engine:v2.2.0
    depends_on:
      - 'timescale'
    ports:
    - '7078:8080'
    restart: always
    environment:
      HASURA_GRAPHQL_ADMIN_SECRET: '${HASURA_GRAPHQL_ADMIN_SECRET}'
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD}@timescale:5432/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
      HASURA_GRAPHQL_ENABLE_TELEMETRY: 'false'
      HASURA_GRAPHQL_UNAUTHORIZED_ROLE: 'anonymous'
  1. Create a simple Docker container setup using the docker-compose.yml above
  2. Create the 2 tables mentioned above (do not forget the one-to-many relation)
  3. Create a hypertable by running SELECT create_hypertable('measurement', 'date');
  4. Run the query above

rbolink avatar Feb 24 '22 13:02 rbolink

Having the same issue. Have you ever found a solution or the root cause of the problem?

mwahlhuetter avatar Aug 01 '22 12:08 mwahlhuetter

Just wanted to let you know, this bug has been resolved with the 2.8 release of timescaledb.

mwahlhuetter avatar Sep 02 '22 09:09 mwahlhuetter

@mwahlhuetter Sorry, I saw your comment, but forgot to respond to it :( I've implemented a workaround for my own project some time ago. Thanks for letting me know timescale has implemented a fix! I will update my version of timescale to get rid of the workaround in the near future.

rbolink avatar Sep 02 '22 09:09 rbolink

No problem! But i'm still curious to what your workaround was, because I had two possible solutions in my mind, one of which did not work because of another bug in hasura..

mwahlhuetter avatar Sep 02 '22 10:09 mwahlhuetter