这是indexloc提供的服务,不要输入任何密码
Skip to content

optimise console schema data management #2273

@donaldaverill

Description

@donaldaverill

The issue started sometime after upgrading to beta2. I made some migrations around the same time but I'm unable to pinpoint when this issue started exactly. I tried rolling back some of the migrations and it didn't seem to change anything. The app works fine while connecting to graphql-engine so it's possible I didn't notice that the console wasn't loading since I don't use it every day. The issue could have started at any point in the last few days since I was not using the console.

When loading console in the browser, if I have not logged in, then I get the secret key dialog. As soon as that's entered and the loading screen appears, it stays that way indefinitely. Additionally, my cpu maxes out and my computer gets hot until I stop the browser and reset the containers.

When looking at the network tab while loading the console app, two network calls get stuck on 'pending'. They appear to have the identical calls or are very similar.

Screen Shot 2019-05-25 at 5 18 44 PM

Screen Shot 2019-05-25 at 5 20 28 PM

Here's the sql that is inside the payload:

select 
  COALESCE(
    json_agg(
      row_to_json(info)
    ), 
    '[]' :: JSON
  ) AS tables 
FROM 
  (
    select 
      ist.table_schema, 
      ist.table_name, 
      obj_description(
        (
          quote_ident(ist.table_schema) || '.' || quote_ident(ist.table_name)
        ):: regclass, 
        'pg_class'
      ) as comment, 
      row_to_json(ist.*) as detail, 
      to_jsonb(
        array_remove(
          array_agg(
            DISTINCT row_to_json(isc) :: JSONB || jsonb_build_object(
              'comment', 
              (
                SELECT 
                  pg_catalog.col_description(
                    c.oid, isc.ordinal_position :: int
                  ) 
                FROM 
                  pg_catalog.pg_class c 
                WHERE 
                  c.oid = (
                    SELECT 
                      (
                        (
                          quote_ident(ist.table_schema) || '.' || quote_ident(ist.table_name)
                        ):: text
                      ):: regclass :: oid
                  ) 
                  AND c.relname = ist.table_name
              )
            )
          ), 
          NULL
        )
      ) AS columns, 
      to_jsonb(
        array_remove(
          array_agg(DISTINCT hdb_fkc.def :: JSONB), 
          NULL
        )
      ) AS foreign_key_constraints, 
      to_jsonb(
        array_remove(
          array_agg(
            DISTINCT row_to_json(hdb_ofkc) :: JSONB || jsonb_build_object(
              'is_table_tracked', ofk_ref_table.table_name IS NOT NULL
            )
          ), 
          NULL
        )
      ) AS opp_foreign_key_constraints, 
      to_jsonb(
        array_remove(
          array_agg(
            DISTINCT row_to_json(hdb_uc) :: JSONB
          ), 
          NULL
        )
      ) AS unique_constraints, 
      row_to_json(hdb_pk.*) :: JSONB AS primary_key, 
      hdb_table.table_name IS NOT NULL AS is_table_tracked, 
      to_jsonb(
        array_remove(
          array_agg(
            DISTINCT row_to_json(hdb_rel) :: JSONB
          ), 
          NULL
        )
      ) AS relationships, 
      to_jsonb(
        array_remove(
          array_agg(
            DISTINCT row_to_json(hdb_perm) :: JSONB
          ), 
          NULL
        )
      ) AS permissions, 
      row_to_json(isc_views.*) AS view_info 
    from 
      information_schema.tables AS ist 
      LEFT OUTER JOIN information_schema.columns AS isc ON isc.table_schema = ist.table_schema 
      and isc.table_name = ist.table_name 
      LEFT OUTER JOIN (
        select 
          row_to_json(hdb_fkc.*):: JSONB || jsonb_build_object(
            'is_ref_table_tracked', fk_ref_table.table_name IS NOT NULL
          ) || jsonb_build_object(
            'ref_table_columns', 
            array_agg(
              row_to_json(fkc_cols)
            )
          ) AS def 
        from 
          hdb_catalog.hdb_foreign_key_constraint AS hdb_fkc 
          LEFT OUTER JOIN hdb_catalog.hdb_table AS fk_ref_table ON fk_ref_table.table_schema = hdb_fkc.ref_table_table_schema 
          and fk_ref_table.table_name = hdb_fkc.ref_table 
          LEFT OUTER JOIN information_schema.columns AS fkc_cols ON fkc_cols.table_schema = hdb_fkc.ref_table_table_schema 
          and fkc_cols.table_name = hdb_fkc.ref_table 
        GROUP BY 
          hdb_fkc.table_schema, 
          hdb_fkc.table_name, 
          row_to_json(hdb_fkc.*):: JSONB, 
          fk_ref_table.table_name, 
          fk_ref_table.table_schema
      ) AS hdb_fkc ON hdb_fkc.def #>>'{table_schema}' = ist.table_schema and hdb_fkc.def#>>'{table_name}' = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_foreign_key_constraint AS hdb_ofkc ON hdb_ofkc.ref_table_table_schema = ist.table_schema and hdb_ofkc.ref_table = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_table AS ofk_ref_table ON ofk_ref_table.table_schema = hdb_ofkc.table_schema and ofk_ref_table.table_name = hdb_ofkc.table_name LEFT OUTER JOIN hdb_catalog.hdb_primary_key AS hdb_pk ON hdb_pk.table_schema = ist.table_schema and hdb_pk.table_name = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_unique_constraint AS hdb_uc ON hdb_uc.table_schema = ist.table_schema and hdb_uc.table_name = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_table AS hdb_table ON hdb_table.table_schema = ist.table_schema and hdb_table.table_name = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_relationship AS hdb_rel ON hdb_rel.table_schema = ist.table_schema and hdb_rel.table_name = ist.table_name LEFT OUTER JOIN hdb_catalog.hdb_permission_agg AS hdb_perm ON hdb_perm.table_schema = ist.table_schema and hdb_perm.table_name = ist.table_name LEFT OUTER JOIN information_schema.views AS isc_views ON isc_views.table_schema = ist.table_schema and isc_views.table_name = ist.table_name where (ist.table_schema='public') GROUP BY ist.table_schema, ist.table_name, ist.*, isc_views.*, row_to_json(hdb_pk.*):: JSONB, hdb_table.table_name ) AS info

When I run the above sql statement, I get a similar issue. The query runs and runs and never returns:
Screen Shot 2019-05-25 at 5 29 08 PM

Any help is appreciated and please let me know of any other information I can provide to help with diagnosing and fixing the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c/consoleRelated to consolee/intermediatecan be wrapped up in a weekk/enhancementNew feature or improve an existing featurep/highcandidate for being included in the upcoming sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions