cardano-foundation / cardano-graphql

GraphQL API for Cardano
Apache License 2.0
263 stars 104 forks source link

Remote schema is missing Block #814

Open airstring opened 1 year ago

airstring commented 1 year ago

Ask a question

The versions of each component are as follows: inputoutput/cardano-graphql-hasura:8.0.0 cardano-graphql:8.0.0
inputoutput/cardano-db-sync:13.1.0.0
cardano-node-ogmios:v5.6.0_1.35.4-mainnet

All other components are working properly, But there's an error when cardano-graphql starts up: {"name":"cardano-graphql","hostname":"9a196bc71b41","pid":7,"level":50,"msg":"Remote schema is missing Block","time":"2023-02-09T10:19:40.861Z","v":0}

centromere commented 1 year ago

This is happening for me also.

Screenshot 2023-02-13 at 17 07 53
centromere commented 1 year ago

@airstring, I was able to get it working by manually applying the content of up.sql to the database after starting db-sync but before starting graphql:

➜  ~ psql -h localhost -U cardano cexplorer -f up.sql
CREATE VIEW
psql:up.sql:26: NOTICE:  relation "Asset" already exists, skipping
CREATE TABLE
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
CREATE VIEW
psql:up.sql:407: NOTICE:  relation "idx_block_hash" already exists, skipping
CREATE INDEX
psql:up.sql:410: NOTICE:  relation "idx_multi_asset_name" already exists, skipping
CREATE INDEX
psql:up.sql:413: NOTICE:  relation "idx_multi_asset_policy" already exists, skipping
CREATE INDEX
psql:up.sql:416: NOTICE:  relation "idx_reward_type" already exists, skipping
CREATE INDEX
psql:up.sql:419: NOTICE:  relation "idx_tx_hash" already exists, skipping
CREATE INDEX
psql:up.sql:422: NOTICE:  relation "idx_tx_in_consuming_tx" already exists, skipping
CREATE INDEX
➜  ~
centromere commented 1 year ago

Note also that the following was required:

cexplorer=# ALTER TABLE "Asset" ALTER description TYPE VARCHAR;
ALTER TABLE
cexplorer=# ALTER TABLE "Asset" ALTER logo TYPE VARCHAR;
ALTER TABLE
cexplorer=# ALTER TABLE "Asset" ALTER name TYPE VARCHAR;
ALTER TABLE
cexplorer=# ALTER TABLE "Asset" ALTER url TYPE VARCHAR;
ALTER TABLE
cexplorer=# \d+ "Asset"
                                                       Table "public.Asset"
       Column        |         Type         | Collation | Nullable | Default | Storage  | Compression | Stats target | Description
---------------------+----------------------+-----------+----------+---------+----------+-------------+--------------+-------------
 assetId             | bytea                |           | not null |         | extended |             |              |
 assetName           | bytea                |           |          |         | extended |             |              |
 decimals            | integer              |           |          |         | plain    |             |              |
 description         | character varying    |           |          |         | extended |             |              |
 fingerprint         | character(44)        |           |          |         | extended |             |              |
 firstAppearedInSlot | integer              |           |          |         | plain    |             |              |
 logo                | character varying    |           |          |         | extended |             |              |
 metadataHash        | character(40)        |           |          |         | extended |             |              |
 name                | character varying    |           |          |         | extended |             |              |
 policyId            | bytea                |           |          |         | extended |             |              |
 ticker              | character varying(9) |           |          |         | extended |             |              |
 url                 | character varying    |           |          |         | extended |             |              |
Indexes:
    "Asset_pkey" PRIMARY KEY, btree ("assetId")
Access method: heap

cexplorer=#
airstring commented 1 year ago

Here is my operation steps, but the problem is still not solved.In spite of this,I still appreciate your answer.

bash-5.1# psql -U postgres -d cexplorer -f up.sql CREATE VIEW psql:up.sql:27: NOTICE: relation "Asset" already exists, skipping CREATE TABLE CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW CREATE VIEW psql:up.sql:408: NOTICE: relation "idx_block_hash" already exists, skipping CREATE INDEX psql:up.sql:411: NOTICE: relation "idx_multi_asset_name" already exists, skipping CREATE INDEX psql:up.sql:414: NOTICE: relation "idx_multi_asset_policy" already exists, skipping CREATE INDEX psql:up.sql:417: NOTICE: relation "idx_reward_type" already exists, skipping CREATE INDEX psql:up.sql:420: NOTICE: relation "idx_tx_hash" already exists, skipping CREATE INDEX psql:up.sql:423: NOTICE: relation "idx_tx_in_consuming_tx" already exists, skipping CREATE INDEX bash-5.1# bash-5.1# psql -U postgres -d cexplorer psql (12.10) Type "help" for help.

cexplorer=# ALTER TABLE "Asset" ALTER description TYPE VARCHAR; ALTER TABLE cexplorer=# ALTER TABLE "Asset" ALTER logo TYPE VARCHAR; ALTER TABLE cexplorer=# ALTER TABLE "Asset" ALTER name TYPE VARCHAR; ALTER TABLE cexplorer=# ALTER TABLE "Asset" ALTER url TYPE VARCHAR; ALTER TABLE cexplorer=# \d+ "Asset" Table "public.Asset" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------------------+----------------------+-----------+----------+---------+----------+--------------+------------- assetId | bytea | | not null | | extended | | assetName | bytea | | | | extended | | decimals | integer | | | | plain | | description | character varying | | | | extended | | fingerprint | character(44) | | | | extended | | firstAppearedInSlot | integer | | | | plain | | logo | character varying | | | | extended | | metadataHash | character(40) | | | | extended | | name | character varying | | | | extended | | policyId | bytea | | | | extended | | ticker | character varying(9) | | | | extended | | url | character varying | | | | extended | | Indexes: "Asset_pkey" PRIMARY KEY, btree ("assetId") Access method: heap

cexplorer=#

centromere commented 1 year ago

@airstring, did you start db-sync, wait for it to stabilize, apply the up.sql schema, start hasura, wait for it to stabilize, and then start graphql?

airstring commented 1 year ago

@centromere I went through your process again. db-sync logs: ... [db-sync-node:Info:68] [2023-02-15 02:58:40.57 UTC] Insert Babbage Block: epoch 394, slot 84863628, block 8401085, hash 27836eba748f55f1e1913dd09f7ebcba6b97770a8df3a0a0775868256fa305e3 [db-sync-node:Info:68] [2023-02-15 02:58:49.66 UTC] Insert Babbage Block: epoch 394, slot 84863636, block 8401086, hash 57140a61be7c55d290bf6f588603f6198a4bb7ccb75143743fc04b30cb9e4193

cardano-graphql-hasura logs: ... {"detail":{"http_info":{"content_encoding":"gzip","http_version":"HTTP/1.1","ip":"172.23.0.6","method":"POST","status":200,"url":"/v1/graphql"},"operation":{"query_execution_time":1.521176e-3,"request_id":"10342bba-dfae-4299-ac3a-c7e7997c13e8","request_mode":"single","request_read_time":1.619e-6,"response_size":1152,"uncompressed_response_size":9958,"user_vars":{"x-hasura-role":"cardano-graphql"}},"request_id":"10342bba-dfae-4299-ac3a-c7e7997c13e8"},"level":"info","timestamp":"2023-02-15T02:51:17.352+0000","type":"http-log"}

cardano-graphql logs: ada-api | {"name":"cardano-graphql","hostname":"ffb1ce24c5b9","pid":7,"level":30,"module":"CardanoNodeClient","msg":"Initialized","time":"2023-02-15T02:51:17.153Z","v":0} ada-api | {"name":"cardano-graphql","hostname":"ffb1ce24c5b9","pid":7,"level":30,"module":"Server","msg":"Initializing","time":"2023-02-15T02:51:17.153Z","v":0} ada-api | {"name":"cardano-graphql","hostname":"ffb1ce24c5b9","pid":7,"level":30,"module":"HasuraClient","msg":"Initializing","time":"2023-02-15T02:51:17.348Z","v":0} ada-api | {"name":"cardano-graphql","hostname":"ffb1ce24c5b9","pid":7,"level":50,"msg":"Remote schema is missing Block","time":"2023-02-15T02:54:41.405Z","v":0}

jonathangenlambda commented 1 year ago

Running into the very same issue, on our private testnet, db-sync is fully stabilised (not much to stabilise anyways, due to easy and fast restarting on our private testnet).

GBBx commented 1 year ago

Hi, I also ran into this issue but then I realized I need to run a background and a server process. Now it works.

The docker-compose file is a good reference: https://github.com/input-output-hk/cardano-graphql/blob/8.0.0/docker-compose.yml#L101

jonathangenlambda commented 1 year ago

@GBBx thank you so much for your comment - adding cardano-graphql-background fixed the issue!