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

Relax error propagation for batch loading mempool txs #64

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

mononaut
Copy link
Contributor

If the initial batched mempool load takes too long, some of the transactions are likely to have been removed from the mempool (replaced or evicted) by the time we request them.

Currently, any missing transaction in the whole batch results in an error that propagates up to fail the entire gettransactions result, which can make it almost impossible to make progress.

This PR allows individual transaction requests in each batch RPC chunk to fail without failing the whole request. Those failed txs are simply filtered out of the response, and can just be fetched on the next mempool update (if they still exist).

If more than 25% of requests fail, we do still abort the request, and bubble up the last error.

This required relaxing the assert_eq!(txhashes.len(), txs.len()) assertion in gettransactions, and I suppose it could potentially also cause issues with missing parents etc, so I'm not really sure how safe this is 🫤

@mononaut mononaut requested a review from junderw November 13, 2023 08:29
@@ -506,13 +538,12 @@ impl Daemon {
.iter()
.map(|txhash| json!([txhash.to_hex(), /*verbose=*/ false]))
.collect();

let values = self.requests("getrawtransaction", &params_list)?;
let values = self.retry_request_batch("getrawtransaction", &params_list, 0.25)?;
Copy link
Member

Choose a reason for hiding this comment

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

  1. Magic number / arbitrary value.
  2. This doesn't feel like it should be set here.

At the very least we need a TODO to properly bubble this up the call stack and make it into a startup config param or something.

Copy link
Member

@junderw junderw left a comment

Choose a reason for hiding this comment

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

utACK 9380493

Ok(parsed_reply) => results.push(parsed_reply),
Err(e) => {
failed_requests += 1;
warn!(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe lower to debug level... it is expected to be frequent...

Copy link
Member

@wiz wiz left a comment

Choose a reason for hiding this comment

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

Tested ACK @ 36d1f7f

@wiz wiz merged commit df3fa85 into mempool Nov 13, 2023
7 checks passed
@wiz wiz deleted the mononaut/relaxed-mempool-batching branch November 13, 2023 13:49
SatoKentaNayoro pushed a commit to boolnetwork/mempool-electrs that referenced this pull request Nov 29, 2024
…atching

Relax error propagation for batch loading mempool txs
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 this pull request may close these issues.

3 participants