multiversx / mx-api-service

Unified REST API facade for providing data related to the MultiversX blockchain
https://api.multiversx.com
GNU General Public License v3.0
30 stars 49 forks source link

[Bug]: often timeout for api #1152

Open sylviahuang123 opened 10 months ago

sylviahuang123 commented 10 months ago

Contact Details

No response

Description

sometimes happened

Steps to reproduce

curl localhost:3001/api/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegation

On which network is the bug manifesting itself?

Mainnet

Relevant log output

Nov 23 08:40:30 sudo[17801]: {"body":null,"context":"ApiService","dd":{"service":"node","span_id":"1221748344080819597","trace_id":"3236560078014969912","version":"0.0.1"},"level":"error","message":"timeout of 30000ms exceeded","method":"GET","name":"AxiosError","timestamp":"2023-11-23T08:40:30.690Z","url":"https://delegation-api.multiversx.com/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegations","value":{"body":null,"message":"timeout of 30000ms exceeded","method":"GET","name":"AxiosError","url":"https://delegation-api.multiversx.com/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegations"}}
Nov 23 08:40:30 sudo[17801]: {"context":"DelegationService:AccountController.getDelegationForAddress","dd":{"service":"node","span_id":"1221748344080819597","trace_id":"3236560078014969912","version":"0.0.1"},"level":"error","message":"Error when getting account delegation details for address erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls","stack":["Error: \n    at OriginLogger.error (/mx-api-service/node_modules/@multiversx/sdk-nestjs-common/src/utils/origin.logger.ts:29:68)\n    at DelegationService.getDelegationForAddress (/mx-api-service/src/endpoints/delegation/delegation.service.ts:75:19)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at AccountController.getDelegationForAddress (/mx-api-service/src/endpoints/accounts/account.controller.ts:606:12)"],"timestamp":"2023-11-23T08:40:30.691Z"}
Nov 23 08:40:30 sudo[17801]: {"body":null,"context":"DelegationService:AccountController.getDelegationForAddress","dd":{"service":"node","span_id":"1221748344080819597","trace_id":"3236560078014969912","version":"0.0.1"},"level":"error","message":"timeout of 30000ms exceeded","method":"GET","name":"AxiosError","timestamp":"2023-11-23T08:40:30.691Z","url":"https://delegation-api.multiversx.com/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegations","value":{"body":null,"message":"timeout of 30000ms exceeded","method":"GET","name":"AxiosError","url":"https://delegation-api.multiversx.com/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegations"}}


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
cfaur09 commented 10 months ago

Hi, thanks for reporting this issue with delegation timeout, we will try to reproduce this behavior and we will apply an proper fix

sylviahuang123 commented 10 months ago

Hi, thanks for reporting this issue with delegation timeout, we will try to reproduce this behavior and we will apply an proper fix

hello, any update?

tanghel commented 9 months ago

are you performing a lot of repeated requests towards the delegation api? we have some rate limiters that might affect this

if you want to query the delegation information for multiple addresses, you can use the elasticsearch now which is much more performant and can fetch multiple infos at the same time: https://index.multiversx.com/delegators/_search

sylviahuang123 commented 9 months ago

no, it's just one address as I shared curl localhost:3001/api/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegation few address we're using

sylviahuang123 commented 9 months ago

but where to see these fields? can't find in Elasticsearch

"userUnBondable": "0",
"claimableRewards": "46007834661318968",
"userUndelegatedList": []
cfaur09 commented 8 months ago

did your try to use Elasticsearch?

curl --request GET \
  --url ${ES_URL}/delegators/_search \
  --header 'Content-Type: application/json' \
  --data '{
    "query": {
        "match": {
            "contract":"erd.."
        }
    }
}'
sylviahuang123 commented 8 months ago

yep, of cause I tried, my question is these fields are not equal to API localhost:3001/api/accounts/erd1uskf6lu8x23mrxfm7gde28jaq6m5wxxws2uw5gf5z6yk6srel7mspeukls/delegation, so I can't replace it.

{
"_index": "delegators-000001",
"_type": "_doc",
"_id": "pT8DW9QP9MwQ1NpEI1EnWcK6zL1e+JNKcTbqNNesdMY=",
"_score": 4.438722,
"_source": {
"address": "erd1t79j33ttyty0alttuvumpty0x0safpfeuhnup35thqgpy4dvkjyqsx7vq4",
"contract": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhllllsajxzat",
"activeStake": "52500000000000000000000",
"activeStakeNum": 52500,
"timestamp": 1694158802
}
}