toncenter / ton-indexer

TON Indexer system to store and serve blockchain data using SQL-database
https://toncenter.com/api/v3/
GNU General Public License v3.0
67 stars 32 forks source link

/api/v3/transactionsByMasterchainBlock has error. timeout: context deadline exceeded #90

Open duktig666 opened 1 month ago

duktig666 commented 1 month ago

I'm running ton-indexer, other APIs are fine, but /api/v3/transactionsByMasterchainBlock and /api/v3/transactions have timeout: context deadline exceeded.

index-api-1         | 2024/10/01 00:53:26 Code: 500 Path: /api/v3/transactionsByMasterchainBlock  API Key:  Queries: map[limit:100 offset:0 seqno:40729340 sort:asc] Body:  Error: timeout: context deadline exceeded
duktig666 commented 1 month ago

Can the API set the timeout for the query?

hsmang commented 1 month ago

Can you add a header X-Timeout: 60000 (ms) when making a request to the index-api?

Farshad12z commented 1 month ago

000000

duktig666 commented 1 month ago

Can you add a header X-Timeout: 60000 (ms) when making a request to the index-api?

Adding an X-Timeout: 60000 request header does work.

Is it possible to avoid this problem at the web api server level? It may be better to avoid the need for the client to configure additional timeouts to use.

hsmang commented 1 month ago

@duktig666 I added index to postgresql as a temporary measure.

CREATE INDEX CONCURRENTLY mc_block_seq_index ON transactions (mc_block_seqno);

CREATE INDEX CONCURRENTLY messages_index_1 ON messages (msg_hash, direction);

CREATE INDEX CONCURRENTLY latest_account_states_index ON latest_account_states (account);
duktig666 commented 1 month ago

Then I should go to the psql database and manually add these indexes.