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.