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

Bug: mempool sync failed: batch request failed #985

Open
antonilol opened this issue Dec 31, 2023 · 7 comments
Open

Bug: mempool sync failed: batch request failed #985

antonilol opened this issue Dec 31, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@antonilol
Copy link
Contributor

Describe the bug
after updating to the newest version today electrs spits out a bunch of mempool sync failed: batch request failed warnings
one time after about 20 of them electrs exited, this could be unrelated, it said something like receiving on an unconnected channel (i lost that part of the log)

Electrs version
84c9a79 (v0.10.2)

To Reproduce
Steps to reproduce the behavior:

  1. Configure and start electrs
  2. Connect with electrum client mempool (mempool.space local instance) server
  3. Wait
  4. See warnings (log level must be at least warn), maybe it exits

Expected behavior
not getting warnings that say something failed (mempool server does not use that part of electrs, mempool functions fine, including address lookup)

Configuration
no config file or env
Arguments: --log-filters DEBUG --db-dir /home/node/.bitcoin/electrs --electrum-rpc-addr=0.0.0.0:50002 --index-lookup-limit=500

System running electrs

  • Deployment method: manual
  • OS name and version: archlinux (uname -r: 6.1.69-1-lts)

Electrum client
Client name (if not upstream desktop Electrum) and version: mempool/mempool bf4a1fcd7ad04a9ec626e82b36668916a600bee9

Additional context
it happened just after updating 0.9.14

if it is not directly clear where this comes from i can set up a way to test the mempool sync part of electrs (i think using electrum wallet should be fine)

@antonilol antonilol added the bug Something isn't working label Dec 31, 2023
@romanz romanz self-assigned this Jan 6, 2024
@romanz
Copy link
Owner

romanz commented Jan 6, 2024

Many thanks for reporting this issue!

@eugenesan
Copy link

Same issue here.
Running master as of today [f1be85f] and Core 26.0.

@antonilol
Copy link
Contributor Author

just to add, i run Core v25.0.0

@romanz
Copy link
Owner

romanz commented Jan 20, 2024

IIUC, the current mempool sync algorithm may fail to retrieve some transactions (most probably due to RBF):

electrs/src/mempool.rs

Lines 54 to 98 in f1be85f

let txids = daemon.get_mempool_txids()?;
debug!("loading {} mempool transactions", txids.len());
let new_txids = HashSet::<Txid>::from_iter(txids);
let to_add = &new_txids - &old_txids;
let to_remove = &old_txids - &new_txids;
let to_add: Vec<Txid> = to_add.into_iter().collect();
let mut new_entries = Vec::with_capacity(to_add.len());
for txids_chunk in to_add.chunks(1000) {
exit_flag.poll().context("mempool update interrupted")?;
let entries = daemon.get_mempool_entries(txids_chunk)?;
ensure!(
txids_chunk.len() == entries.len(),
"got {} mempools entries, expected {}",
entries.len(),
txids_chunk.len()
);
let txs = daemon.get_mempool_transactions(txids_chunk)?;
ensure!(
txids_chunk.len() == txs.len(),
"got {} mempools transactions, expected {}",
txs.len(),
txids_chunk.len()
);
let chunk_entries: Vec<Entry> = txids_chunk
.iter()
.zip(entries.into_iter().zip(txs.into_iter()))
.filter_map(|(txid, (entry, tx))| {
let tx = tx.ok()?;
let entry = entry.ok()?;
Some(Entry {
txid: *txid,
tx,
vsize: entry.vsize,
fee: entry.fees.base,
has_unconfirmed_inputs: !entry.depends.is_empty(),
})
})
.collect();
new_entries.extend(chunk_entries);
}

In that case, it's not a real problem - unless it fails consistently.

@antonilol
Copy link
Contributor Author

i now regularly get these warnings about twice a day (max 10 on 6th of january), but before i would get them spammed in the log every 2 or so seconds, restarting electrs seemed to fix that

@romanz
Copy link
Owner

romanz commented Jan 27, 2024

Please try #997 - it should help with this issue.

@antonilol
Copy link
Contributor Author

antonilol commented Jan 28, 2024

got master + #997 running on my node right now, will report later on the results as these messages did not show very often, also, no new mempool sync failed messages have been logged since january 24th which is a bit strange to me as i did not do anything to it then (no restart or update etc)

i will report bugs and logged warnings related to that pr in the thread there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
@romanz @eugenesan @antonilol and others