-
Notifications
You must be signed in to change notification settings - Fork 62
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
Unstable sort when ordering by genesis_block_height #162
Comments
How should I debug this @rafaelcr? |
@jack-linden when I add the |
@rafaelcr I think its actually a caching issue and not related to pagination/sorting. See the below TS playground This code paginates through the result set and pops each inscription_id into a set. The expected response set size should be 265 but instead varies (run several times in new incognito browsers or clear browser cache before each run). If you flip the "bypass_cache" flag to true (passes a Date.now() query param to the URL) it will more often give the accurate 265 response set size. EDIT - even with the bypass_cache flag it will sometimes give incorrect result set sizes. |
@jack-linden that behavior makes sense. The API is designed with "eventual consistency" in mind, which means that whenever we receive new data from a Bitcoin block we process it, store it in the DB, and immediately after run other background tasks that cache some results, stats, counts, etc. so we can respond to API calls faster. It's entirely possible that while you run the TS playground code a new block comes by or we finish one of these background tasks and that alters pagination results. Also, the Bitcoin chain does re-org from time to time which means we occasionally need to delete and re-index some blocks to go back to the canonical chain tip. This would also alter pagination results. |
I would understand if the user is actively receiving or sending inscriptions (i.e., new block anchors -> indexer running) while these queries execute but this address's holdings have not changed in over a week and therefore there is no reason why the result set should ever be inconsistent in this immediate scenario. I retract that this is only related to caching. Please see the latest example below - I've mapped the result set by inscription_id -> number of times returned while paginating the entire result set and printed each instance of the count > 1. If the sort is stable across subsequent query pages then all counts should == 1 (and no new blocks that would interact with the query). |
Ok thanks, this is very helpful. I'll take a closer look at this sorting and get back to you @jack-linden |
@rafaelcr Can I close this one? Thanks! |
@jack-linden this will be fixed on the next production deployment |
Reproduction:
https://api.hiro.so/ordinals/v1/inscriptions?address=bc1patm6f65h7kvppjss2p0fh4na67um30z7dd6txtqxjzmrwv0tz9ss47mdlc&limit=60&offset=0
Result set is not always sorted consistently - leading to pagination issues.
The text was updated successfully, but these errors were encountered: