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

ponder_sync.rpcRequestResults table exceeds postgres index limits #1104

Closed
gte620v opened this issue Sep 17, 2024 · 5 comments · Fixed by #1235
Closed

ponder_sync.rpcRequestResults table exceeds postgres index limits #1104

gte620v opened this issue Sep 17, 2024 · 5 comments · Fixed by #1235

Comments

@gte620v
Copy link

gte620v commented Sep 17, 2024

My ponder instance crashed with the following error:

WARN  sync       Failed 'insertRpcRequestResult' database method after '10' attempts

error: index row size 2880 exceeds btree version 4 maximum 2704 for index "rpcRequestResultPrimaryKey"

Looking at the database logs, I see this further error detail:

{
  "file": null,
  "metadata": [],
  "parsed": [
    {
      "application_name": "Supavisor",
      "backend_type": "client backend",
      "command_tag": "INSERT",
      "context": null,
      "database_name": "postgres",
      "detail": "Index row references tuple (99,9) in relation \"rpcRequestResults\".",
      "error_severity": "ERROR",
      "hint": "Values larger than 1/3 of a buffer page cannot be indexed.\nConsider a function index of an MD5 hash of the value, or use full text indexing.",
      "internal_query": null,
      "internal_query_pos": null,
      "leader_pid": null,
      "location": null,
      "process_id": 393078,
      "query": "insert into \"ponder_sync\".\"rpcRequestResults\" (\"request\", \"blockNumber\", \"chainId\", \"result\") values ($1, $2, $3, $4) on conflict (\"request\", \"chainId\", \"blockNumber\") do update set \"result\" = $5",
      "query_id": -2291873031451942400,
      "query_pos": null,
      "session_id": "66e9c189.5ff76",
      "session_line_num": 4,
      "sql_state_code": "54000",
      "transaction_id": 1270124,
      "virtual_transaction_id": "24/185014"
    }
  ],
  "parsed_from": null,
  "project": null,
  "source_type": null
}

Any suggestions on a fix?

@gte620v
Copy link
Author

gte620v commented Sep 17, 2024

Looks like it is caused by some big periodic multicalls I was making. Refactoring those seems to have fixed the issue.

@gte620v gte620v closed this as completed Sep 17, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Ponder Roadmap Sep 17, 2024
@typedarray
Copy link
Collaborator

Thanks for opening. Yeah, splitting into several multicalls is probably the best workaround. Will keep this in mind though - at one point we considered "unbundling" multicalls for storage in that cache table, but decided against it.

How many calls and what kind of input data were you doing here, and how many after the fix? We could consider a quick validation that would have nudged you to split it up earlier on / during development. Might prevent this happening to someone else in prod.

@gte620v
Copy link
Author

gte620v commented Sep 18, 2024

Is an embarrassing amount... had 300 calls in a single multicall. The calls all had one argument. The db didnt complain for days, so it took a while to hit whatever limit pg has.

@gte620v
Copy link
Author

gte620v commented Sep 18, 2024

might be useful to have an option to tell the context read to not write the rpc calldata to the db.

my use case was to check that the ponder state of my contracts (based on events-driven typescript implementation of the contract code) matches the state of the on-chain contracts (collected through rpc calls). this was running about once per day using the block-number driven ponder cron mechanism.

@jwahdatehagh
Copy link
Contributor

getting this on & off from client.getEnsName calls (which i think are automatically batched)

@kyscott18 kyscott18 reopened this Dec 3, 2024
@github-project-automation github-project-automation bot moved this from Done to In progress in Ponder Roadmap Dec 3, 2024
This was referenced Dec 3, 2024
@kyscott18 kyscott18 linked a pull request Dec 5, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from In progress to Done in Ponder Roadmap Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants