Fixing "Block not found on disk" rpc error I have a full node with txindex enabled that I've been trying to use for an electrum server. However, whether I use ElectrumX or Electrs, I hit the same error on initial indexing of "Block not found on disk". With a bit of digging, I found out this error comes from the getblock rpc call, and the comment in the code for when this error is thrown is as follows:


  Block not found on disk. This could be because we have the block
  header in our index but don't have the block (for example if a
  non-whitelisted node sends us an unrequested long chain of valid
  blocks, we add the headers to our index, but don't accept the
  block).


I'm not sure how I got to this state. This is a node I initially spun up several years ago and reindexed to use txindex earlier this year, I've never had any issues with it for other purposes or any data loss/corruption issues that I can recall. If anyone has a theory/explanation, I'd be interested to hear it.

My question is: Can I fix this error without starting over from scratch? I'd like to avoid even a reindex if possible, although I'm not even sure if that would fix it because as I understand it reindex uses the blocks on disk and apparently I'm missing a block on disk. Is there a way to get only the block or file(s) that I need? I have a friend with a full node who would let me copy files if needed.

I don't know exactly which block is missing yet, although I could probably figure that out with some more digging if it would be helpful.
Blocks are not stored in individual files, but flat bundles of a fixed size, so replacing one that is missing isn’t really possible. If a block can not be found on disk it has either keen deleted manually or by an errant process, or the disk is seriously corrupted. A re-index will fix this, but it’s an indicator of other possible issues related to hardware that this has happened.