bitshares-ui icon indicating copy to clipboard operation
bitshares-ui copied to clipboard

Full history will fail if total OPs is beyond 10,000

Open Xeldal opened this issue 6 years ago • 12 comments
trafficstars

Describe the bug When trying to download account history via wrapper.elasticsearch.bitshares.ws on desktop 3.1.190618.1, wallet.bitshares.org (chrome and firefox), and develop.bitshares.org(chrome and firefox) ... they all fail with the message "Failed to download the account history, please try again"

here is the console error: (ignore the strikethroughs)

account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1 GET https://wrapper.elasticsearch.bitshares.ws/get_account_history?account_id=1.2.1310&from_=9900&size=150&sort_by=block_data.block_time&type=data&agg_field=operation_type 500 (INTERNAL SERVER ERROR)
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
value @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
w @ vendor.0c03c0a87759ca1ced2a.js:132
(anonymous) @ vendor.0c03c0a87759ca1ced2a.js:132
e.<computed> @ vendor.0c03c0a87759ca1ced2a.js:132
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
Promise.then (async)
n @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1
(anonymous) @ account~dashboard-accounts~deposit-withdraw~transfer.ec9c3b3ab746268987e3.js:1


From the same browser checking "is_alive"
https://wrapper.elasticsearch.bitshares.ws/is_alive


deltatime | 2.882458
-- | --
head_block_time | "2019-07-30T16:15:27.000Z"
head_block_timestamp | 1564503327000
server_time | "Tue, 30 Jul 2019 16:15:29 GMT"
status | "ok"

Xeldal avatar Jul 30 '19 16:07 Xeldal

It seems to work fine with very small accounts, but anything with a large number of transactions, for me it fails.

Xeldal avatar Jul 30 '19 17:07 Xeldal

I also can't download account history: image I get [HTTP/1.1 500 INTERNAL SERVER ERROR] after the next request: GET https://wrapper.elasticsearch.bitshares.ws/get_account_history?account_id=1.2.450921&from_=9900&size=150&sort_by=block_data.block_time&type=data&agg_field=operation_type

allfory0u avatar Jul 30 '19 18:07 allfory0u

I think the problem is in the limit of 10,000 operations.

Not sure if I found suitable variables 😄 elasticsearch_plugin config

allfory0u avatar Jul 30 '19 18:07 allfory0u

Checking on this I believe the problem really is on the ES wrapper, as @allfory0u mentions. When querying for OPs after 10.000 it will fail. If "from" is set to 9900 and size is 100 it will be successful, but whenever you query for anything over 10.000 it will return a 500 internal server error result.

startailcoon avatar Jul 30 '19 19:07 startailcoon

Issue submitted to the bitshares-explorer-api repo on Issue https://github.com/bitshares/bitshares-explorer-api/issues/39

startailcoon avatar Jul 30 '19 21:07 startailcoon

Ah, yea I think ES default is 10k! Nevertheless it should not crash, but then maybe add dots on the bottom or something.

sschiessl-bcp avatar Jul 31 '19 12:07 sschiessl-bcp

There is a built in limit in the Elastic Search. @oxarbitrage says he will work on the problem.

startailcoon avatar Jul 31 '19 13:07 startailcoon

I confirm the issue is due to an Elastic Search limit on the way we search the account history. from_ + size should be less than 10000 (index.max_result_window ES parameter).

In order to allow an unlimited retrieval I suggest a fix there that introduce a small API change.

Zapata avatar Aug 03 '19 11:08 Zapata

@Zapata is there any changes to API calls, or will this magically work as expected once the fix is in production?

startailcoon avatar Aug 05 '19 19:08 startailcoon

I made the changes needed in the explorer to support this at https://github.com/oxarbitrage/open-explorer/commit/5b47e3d80d0572888aa960c60c380df4f6aa846b

Can be tested with any account that haves more than 10k: https://open-explorer.io/#/accounts/1.2.1151525

Can go to the last page and others without getting the 500 error as before.

In order to do it like that(which i think will be what you want in the UI but maybe with more than 20 results per page) you need to use a query similar to https://github.com/oxarbitrage/open-explorer/blob/5b47e3d80d0572888aa960c60c380df4f6aa846b/app/core/service.account.js#L285

You will need the total number of operations of the account(can get that from the statistics object) and go backwards, check https://github.com/oxarbitrage/open-explorer/blob/5b47e3d80d0572888aa960c60c380df4f6aa846b/app/sections/accounts/accounts.controller.js#L45-L53

The code of the explorer is a bit messy however i hope good enough to get the idea. If not please contact me.

oxarbitrage avatar Aug 05 '19 20:08 oxarbitrage

Will follow up any required changes and let you know if I need anything @oxarbitrage

startailcoon avatar Aug 05 '19 20:08 startailcoon

UI requires to replace old get_account_history with new account_history and to have https://explorer.bitshares-kibana.info/es added to the ES list as it's the only one supporting this for now.

Related #1734

startailcoon avatar Aug 10 '19 14:08 startailcoon