Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When materialization takes long time "View not found" error when querying document #254

Closed
adzialocha opened this issue Aug 23, 2022 · 3 comments · Fixed by #259
Closed
Labels
bug Something isn't working

Comments

@adzialocha
Copy link
Member

adzialocha commented Aug 23, 2022

Querying a document (which exists) by documentId sometimes returns this error:

{
  "response": {
    "data": null,
    "errors": [
      {
        "message": "View not found"
      }
    ],
    "status": 200,
    "headers": {
      "map": {
        "content-length": "53",
        "content-type": "application/json"
      }
    }
  },
  "request": {
    "query": "\n    query FetchBoard($documentId: String!) {\n      board: zoo_adventures_00209403784eea2ba5236f9083472f040a90babf4df1b64efbbaae58eb51aa67fd4d(id: $documentId) {\n        meta {\n          viewId\n        }\n        fields {\n          game_field_1 game_field_2 game_field_3 game_field_4 game_field_5 game_field_6 game_field_7 game_field_8 game_field_9 game_field_10 game_field_11 game_field_12 game_field_13 game_field_14 game_field_15 game_field_16\n        }\n      }\n    }\n  ",
    "variables": {
      "documentId": "0020c301d6595e12cbd472d21ac4c1bdfde02ec4e8d7ea299f723130d64eb65e500d"
    }
  }
}

The error comes from this line: https://github.com/p2panda/aquadoggo/blob/main/aquadoggo/src/graphql/client/utils.rs#L22

It often happens right after when the document gets updated. Maybe it gets temporarily deleted in the database before the new materialized version gets inserted? The document has a fairly large operation graph ..

@adzialocha adzialocha added the bug Something isn't working label Aug 23, 2022
@adzialocha adzialocha changed the title Random "View not found" error when querying document When materialization takes long time, the document is temporarily deleted, "View not found" error when querying document Aug 24, 2022
@adzialocha adzialocha changed the title When materialization takes long time, the document is temporarily deleted, "View not found" error when querying document When materialization takes long time, the document is temporarily deleted / "View not found" error when querying document Aug 24, 2022
@adzialocha adzialocha removed the bug Something isn't working label Sep 2, 2022
@adzialocha adzialocha added the bug Something isn't working label Sep 2, 2022
@adzialocha adzialocha reopened this Sep 2, 2022
@adzialocha adzialocha changed the title When materialization takes long time, the document is temporarily deleted / "View not found" error when querying document When materialization takes long time "View not found" error when querying document Sep 2, 2022
@sandreae
Copy link
Member

sandreae commented Sep 3, 2022

Maybe it gets temporarily deleted in the database before the new materialized version gets inserted?

We aren't deleting views in the db at the moment, so I don't think it's this.

I suspect it is happening as the document table is updated first, then the view inserted to document_views table (if the document isn't deleted). So if we queried the document_view table in this moment then we wouldn't find anything. Like this this:

A1) document table updated with new view id (the isn't inserted yet)
B1) query the document for it's newest view
B2) query the document_views table for the retrieved view -> Error!
A2) insert the new view to the document_views table

We can fix this by adding a transaction around these two sql queries 👍

Side thought, it makes me wonder if we need to think about best practice for how we query documents/views, maybe getting the document id and querying that is the most reliable way, seeing as views may be deleted.

@adzialocha
Copy link
Member Author

We can fix this by adding a transaction around these two sql queries 👍

Super! Sounds good. Everything which needs multiple writes before it's considered a "final" state should be wrapped into one transaction, maybe we find more of these in other places?

@sandreae
Copy link
Member

sandreae commented Sep 3, 2022

maybe we find more of these in other places?

Yes, maybe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants