Skip to content
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

[cherry-pick] fix(iota-indexer): add fallback query to get total packages metric (#4043) #4050

Merged

Conversation

lzpap
Copy link
Member

@lzpap lzpap commented Nov 14, 2024

Origin PR: #4043

Description of change

This patch adds a fallback query to get the total packages metric.

The primary query relies on the pg_class catalog and uses the reltuples field to get a fast estimate of the row count. However reading the documentation

reltuples float4

Number of live rows in the table. This is only an estimate used by the planner. It is updated by VACUUM, ANALYZE, and a few DDL commands such as CREATE INDEX. If the table has never yet been vacuumed or analyzed, reltuples contains -1 indicating that the row count is unknown.

It has been observed that for a vanilla network that starts with only the system packages, the query for the estimate returns -1, likely because the insert threshold for triggering vacuuming was not supassed (see autovacuum).

Credits to @begonaalvarezd for observing the issue.

Type of change

  • Bug fix (a non-breaking change which fixes an issue)

How the change has been tested

Run a local network with vanilla genesis and the indexer rpc and run the following query:

curl 'http://0.0.0.0:9005/'   -H 'content-type: application/json' --data-raw '{"jsonrpc":"2.0","id":3,"method":"iotax_getNetworkMetrics","params":[]}' 

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

@lzpap lzpap requested a review from a team as a code owner November 14, 2024 08:53
@lzpap lzpap changed the title fix(iota-indexer): add fallback query to get total packages metric (#4043) [cherry-pick] fix(iota-indexer): add fallback query to get total packages metric (#4043) Nov 14, 2024
Copy link
Contributor

This pull request has been deployed to Vercel.

Latest commit: 01c47ba

✅ Preview: https://apps-ui-c67o6uz69-iota1.vercel.app

@lzpap lzpap requested a review from alexsporn November 14, 2024 08:55
@lzpap lzpap added the infrastructure Issues related to the Infrastructure Team label Nov 14, 2024
Copy link
Contributor

This pull request has been deployed to Vercel.

Latest commit: 01c47ba

✅ Preview: https://apps-backend-29a719c9ccbdb9b80c97b599a599d8953354da-9qiezdh6i.vercel.app

Copy link
Contributor

This pull request has been deployed to Vercel.

Latest commit: 01c47ba

✅ Preview: https://iota-rebased-explorer-092603f1de8088243ccb8b861b23e-ydakj84tr.vercel.app

Copy link
Contributor

This pull request has been deployed to Vercel.

Latest commit: 01c47ba

✅ Preview: https://wallet-dashboard-a225fcfa1e2f852205a61a7cd1d5d93e92-cv93zkbjy.vercel.app

@lzpap lzpap merged commit 3101871 into releases/iota-v0.7.0-release Nov 14, 2024
38 of 40 checks passed
@lzpap lzpap deleted the cherry-pick/indexer-total-pkg-count-fix branch November 14, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Issues related to the Infrastructure Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants