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

Conversation

@rakeshkky
Copy link
Member

@rakeshkky rakeshkky commented Mar 25, 2019

Description

The server keeps track of all inconsistent metadata objects and reports them on /v1/query of type get_inconsistent_metadata.

API request:-

POST /v1/query
{
  "type": "get_inconsistent_metadata",
  "args": {}
}

Response:-

{ 
    "is_consistent": false,
    "inconsistent_objects": [
  {
    "definition": {
      "role": "user",
      "comment": null,
      "permission": {
        "allow_aggregations": false,
        "columns": [
          "author",
          "author_id",
          "id",
          "title"
        ],
        "filter": {
          "author": {
            "_eq": "X-Hasur\r\na-User-Id"
          }
        }
      },
      "table": "article"
    },
    "reason": "table \"article\" does not exist",
    "type": "select_permission"
  },
  {
    "definition": {
      "using": {
        "foreign_key_constrai\r\nnt_on": "author_id"
      },
      "name": "author_obj",
      "comment": null,
      "table": "article"
    },
    "reason": "table \"article\" does not exist",
    "type": "object_relation"
  },
  {
    "definition": {
      "using": {
        "foreign_key_constraint_on": {
          "column": "author_id",
          "table": "article"
        }
      },
      "name": "articles",
      "comment": null,
      "table": "author"
    },
    "reason": "t\r\nable \"article\" does not exist",
    "type": "array_relation"
  },
  {
    "definition": "article",
    "reason": "no such table/view exists in postgres : \"article\"",
    "type": "table"
  }
]
}

Use drop_inconsistent_metadata query type to purge all inconsistent objects.

API

POST /v1/query
{
  "type": "drop_inconsistent_metadata",
  "args": {}
}

Response:-

{
    "message": "success"
}

Affected components

  • Server
  • Console
  • Docs
  • Tests

Related Issues

close #231

Solution and Design

  1. buildSchemaCache function from Hasura.RQL.DDL.Schema.Table module is updated to collect inconsistent objects and push to schema cache.
  2. Add get_inconsistent_metadata and drop_inconsistent_metadata query types in /v1/query API
  3. Remote schemas related metadata API code is refactored to support handling inconsistent ones.

Steps to test and verify

  1. Start GraphQL Engine, add few tables and define permissions and relationships.
  2. Through psql or adminer drop any table which is being tracked.
  3. Now, restart GraphQL Engine or reload metadata in settings section of console.
  4. Make get_inconsistent_metadata API query (spec given above), you'll get list of all inconsistent metadata objects.

Resolve Conflicts:
	server/src-lib/Hasura/GraphQL/Resolve.hs
	server/src-lib/Hasura/GraphQL/Resolve/Insert.hs
	server/src-lib/Hasura/GraphQL/Resolve/Mutation.hs
	server/src-lib/Hasura/RQL/DDL/Metadata.hs
	server/src-lib/Hasura/RQL/DDL/QueryTemplate.hs
	server/src-lib/Hasura/RQL/DDL/Schema/Table.hs
	server/src-lib/Hasura/RQL/DDL/Subscribe.hs
	server/src-lib/Hasura/RQL/DML/Count.hs
	server/src-lib/Hasura/RQL/DML/Delete.hs
	server/src-lib/Hasura/RQL/DML/QueryTemplate.hs
	server/src-lib/Hasura/RQL/DML/Select.hs
	server/src-lib/Hasura/RQL/DML/Update.hs
	server/src-lib/Hasura/Server/Query.hs
@rakeshkky rakeshkky added s/do-not-merge Do not merge this pull request to master s/wip Status: This issue is a work in progress labels Mar 25, 2019
@rakeshkky rakeshkky self-assigned this Mar 25, 2019
@rakeshkky rakeshkky requested a review from 0x777 as a code owner March 25, 2019 16:35
@netlify
Copy link

netlify bot commented Mar 25, 2019

Deploy preview for hasura-docs ready!

Built with commit 174be30

https://deploy-preview-1863--hasura-docs.netlify.com

@hasura-bot
Copy link
Contributor

Review app for commit 2d69ab2 deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-2d69ab2

Resolve Conflicts:
	server/src-lib/Hasura/GraphQL/Resolve.hs
	server/src-lib/Hasura/GraphQL/Resolve/Context.hs
	server/src-lib/Hasura/GraphQL/Resolve/Mutation.hs
	server/src-lib/Hasura/GraphQL/Resolve/Select.hs
	server/src-lib/Hasura/GraphQL/Transport/HTTP.hs
	server/src-lib/Hasura/RQL/DDL/EventTrigger.hs
	server/src-lib/Hasura/RQL/DDL/Schema/Table.hs
@hasura-bot
Copy link
Contributor

Review app for commit 5b7678a deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-5b7678a

@danielcompton
Copy link
Contributor

Thanks for this!

We were able to use the soft start feature to boot an app when our schema had changed externally. Previous Hasura wouldn't boot, so we couldn't reset or apply new metadata. This looks to be on the right track. I didn't try the API though, just using the CLI and the console.

@hasura-bot
Copy link
Contributor

Review app for commit 5b7678a deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-5b7678a

@rakeshkky rakeshkky requested a review from rikinsk-zz as a code owner March 27, 2019 09:52
@rakeshkky rakeshkky added c/console Related to console c/docs Related to docs c/server Related to server s/do-not-merge Do not merge this pull request to master and removed s/do-not-merge Do not merge this pull request to master labels Mar 27, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 5b8d129 deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-5b8d129

rikinsk-zz
rikinsk-zz previously approved these changes Apr 16, 2019
Copy link

@rikinsk-zz rikinsk-zz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs + console approved

@rikinsk-zz
Copy link

@rikinsk-zz
Copy link

related #415

@wawhal
Copy link
Contributor

wawhal commented Apr 16, 2019

@rikinsk I think it should be there. Because finding those inconsistencies in the schema is not straight forward. We should just add a note at the top saying "If your version is above , you can look at all the inconsistencies at /metadata/status"

@hasura-bot
Copy link
Contributor

Review app for commit b365e23 deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-b365e23

wawhal and others added 4 commits April 17, 2019 14:30
Resolve Conflicts:
	server/src-exec/Main.hs
	server/src-lib/Hasura/Server/App.hs
	server/src-lib/Hasura/Server/Init.hs
	server/src-lib/Hasura/Server/Query.hs
	server/src-lib/Hasura/Server/SchemaUpdate.hs
0x777
0x777 previously approved these changes Apr 17, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 174be30 deployed to Heroku: https://hge-ci-pull-1863.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1863-174be303

@0x777 0x777 merged commit 1d7cbc7 into hasura:master Apr 17, 2019
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-1863.herokuapp.com is deleted

@dsandip dsandip removed this from the release-candidates milestone Apr 18, 2019
polRk pushed a commit to polRk/graphql-engine that referenced this pull request Feb 12, 2020
hasura-bot pushed a commit that referenced this pull request Apr 22, 2025
)

Context: https://app.slack.com/client/T7GHF0SM9/C08PAUZG6F6

aside: this error message (or maybe it's
`UnknownFieldInOutputPermissionsDefinition`) wasn't visible to the user.
I couldn't immediately see how ErrorVisibility ultimately gets set for
this type. Also looking at `set_span_attributes` it seems we don't have
a mechanism for surfacing non-internal errors that end up in an internal
span, is that what we want?

If it is, should I make `build_metadata` user-visible?

https://prod-gcp-grafana.hasura.io/d/a0aabf5f-9eb1-467b-8f5d-b7746a33c2a2/view-trace?orgId=1&var-traceId=1e444531ec996c040799e8ea9990de2b&from=now-6h&to=now&timezone=browser

V3_GIT_ORIGIN_REV_ID: 28d76ac421a60994ef439f879794cc5e82af0e1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/console Related to console c/docs Related to docs c/server Related to server s/do-not-merge Do not merge this pull request to master s/wip Status: This issue is a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recover from an inconsistent database state

8 participants