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

fix(iota-indexer): add fallback query to get total packages metric #4043

Merged

Conversation

kodemartin
Copy link
Contributor

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

@kodemartin kodemartin requested a review from a team as a code owner November 13, 2024 17:55
@kodemartin kodemartin requested a review from lzpap November 13, 2024 17:56
@kodemartin kodemartin added the sc-platform Issues related to the Smart Contract Platform group. label Nov 13, 2024
@kodemartin kodemartin added this to the Testnet Launch v1.0.0-rc milestone Nov 13, 2024
@kodemartin kodemartin added the infrastructure Issues related to the Infrastructure Team label Nov 13, 2024
Copy link
Member

@samuel-rufi samuel-rufi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☀️

@kodemartin kodemartin merged commit 4265d92 into develop Nov 14, 2024
38 of 40 checks passed
@kodemartin kodemartin deleted the sc-platform/hotfix-total-packages-estimate-fallback branch November 14, 2024 07:25
lzpap added a commit that referenced this pull request Nov 14, 2024
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 sc-platform Issues related to the Smart Contract Platform group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants