Author

Topic: Bitcoin 0.7.x won't synchronise past block 206457 (Read 2086 times)

legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
November 07, 2012, 02:24:50 PM
#6
If you suspect that the database index is corrupt (blkindex.dat in the bitcoin data directory), it can be deleted, the blockchain files blk0001.dat and blk0002.dat moved out of the data directory (like to the root of C: drive) and then the blocks can be re-imported from these original blockchain files:

bitcoin-qt -loadblock=c:\blk0001.dat -loadblock=c:\blk0002.dat
Thanks.
kjj
legendary
Activity: 1302
Merit: 1026
If you suspect that the database index is corrupt (blkindex.dat in the bitcoin data directory), it can be deleted, the blockchain files blk0001.dat and blk0002.dat moved out of the data directory (like to the root of C: drive) and then the blocks can be re-imported from these original blockchain files:

bitcoin-qt -loadblock=c:\blk0001.dat -loadblock=c:\blk0002.dat

Highlighted for emphasis.  If you don't do this step, you'll end up with with a bit of a mess.
legendary
Activity: 1512
Merit: 1036
However, there was an error writing the blkindex.dat file; likely this file was corrupted, there is a disk CRC write error/bad block, or another Bitcoin is concurrently attempting to access it, etc. The error is unanticipated/unhandled by the code.
Huh. So any kind of failure to write to a critical file causes the client to either crash or hang while leaving the database in an inconsistent state without even displaying an error message? That seems like a pretty big oversight to me. Undecided

In this case, rebuilding the index, or restoring/redownloading the blockchain is the remedy.
For future reference, how exactly does one rebuild the index? I don't see any command-line options for doing this.

Although it doesn't really help now, when Bitcoin 0.8.0 is released, it will have a new database system for storing the blockchain that will be more robust for the 4+ GB that Bitcoin has become.

If you suspect that the database index is corrupt (blkindex.dat in the bitcoin data directory), it can be deleted, the blockchain files blk0001.dat and blk0002.dat moved out of the data directory (like to the root of C: drive) and then the blocks can be re-imported from these original blockchain files:

bitcoin-qt -loadblock=c:\blk0001.dat -loadblock=c:\blk0002.dat
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
However, there was an error writing the blkindex.dat file; likely this file was corrupted, there is a disk CRC write error/bad block, or another Bitcoin is concurrently attempting to access it, etc. The error is unanticipated/unhandled by the code.
Huh. So any kind of failure to write to a critical file causes the client to either crash or hang while leaving the database in an inconsistent state without even displaying an error message? That seems like a pretty big oversight to me. Undecided

In this case, rebuilding the index, or restoring/redownloading the blockchain is the remedy.
For future reference, how exactly does one rebuild the index? I don't see any command-line options for doing this.
legendary
Activity: 1512
Merit: 1036
received block 00000000000002b0fa88 on the top line of your log is a real 206458:
http://blockexplorer.com/block/00000000000002b0fa887f1ef355d8b86dd75fc5d5bd93613584383765ab8f4f

However, there was an error writing the blkindex.dat file; likely this file was corrupted, there is a disk CRC write error/bad block, or another Bitcoin is concurrently attempting to access it, etc. The error is unanticipated/unhandled by the code. In this case, rebuilding the index, or restoring/redownloading the blockchain is the remedy.

Corresponding code: main.cpp line 2051:

Code:
 // Write block to history file
    unsigned int nBlockSize = ::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION);
    if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION)))
        return error("AcceptBlock() : out of disk space");
    CDiskBlockPos blockPos;
    if (!FindBlockPos(blockPos, nBlockSize+8, nHeight, nTime))
        return error("AcceptBlock() : FindBlockPos failed");
    if (!WriteToDisk(blockPos))
        return error("AcceptBlock() : WriteToDisk failed");
    if (!AddToBlockIndex(blockPos))
        return error("AcceptBlock() : AddToBlockIndex failed");

And the called addtoblockindex() function that failed (line 1815):
Code:
bool CBlock::AddToBlockIndex(const CDiskBlockPos &pos)
{
    // Check for duplicate
    uint256 hash = GetHash();
    if (mapBlockIndex.count(hash))
        return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());

    // Construct new block index object
    CBlockIndex* pindexNew = new CBlockIndex(*this);
    if (!pindexNew)
        return error("AddToBlockIndex() : new CBlockIndex failed");
    map::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
    pindexNew->phashBlock = &((*mi).first);
    map::iterator miPrev = mapBlockIndex.find(hashPrevBlock);
    if (miPrev != mapBlockIndex.end())
    {
        pindexNew->pprev = (*miPrev).second;
        pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
    }
    pindexNew->nTx = vtx.size();
    pindexNew->bnChainWork = (pindexNew->pprev ? pindexNew->pprev->bnChainWork : 0) + pindexNew->GetBlockWork();
    pindexNew->nChainTx = (pindexNew->pprev ? pindexNew->pprev->nChainTx : 0) + pindexNew->nTx;
    pindexNew->nFile = pos.nFile;
    pindexNew->nDataPos = pos.nPos;
    pindexNew->nUndoPos = 0;
    pindexNew->nStatus = BLOCK_VALID_TRANSACTIONS | BLOCK_HAVE_DATA;
    setBlockIndexValid.insert(pindexNew);

    pblocktree->WriteBlockIndex(CDiskBlockIndex(pindexNew));

    // New best?
    if (!ConnectBestBlock())
        return false;

    if (pindexNew == pindexBest)
    {
        // Notify UI to display prev block's coinbase if it was ours
        static uint256 hashPrevBestCoinBase;
        UpdatedTransaction(hashPrevBestCoinBase);
        hashPrevBestCoinBase = GetTxHash(0);
    }

    pblocktree->Flush();

    uiInterface.NotifyBlocksChanged();
    return true;
}
legendary
Activity: 4542
Merit: 3393
Vile Vixen and Miss Bitcointalk 2021-2023
Bitcoin 0.7.0 just crashes with no error message and nothing in debug.log, leading to 22DbRunRecoveryException fun. Angry
Bitcoin 0.7.1 does not crash, instead it just gets stuck while spewing a ton of errors to debug.log:

Code:
received block 00000000000002b0fa88
connection timeout
trying connection 109.123.33.243:8333 lastseen=20.2hrs
ERROR: SetBestChain() : TxnCommit failed
ERROR: SetBestChain() : SetBestChainInner failed
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
getblocks -1 to 00000000000000000000 limit 500
received block 000000000000004055b1
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004e815d6
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
received block 00000000000004086917
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
trying connection 98.197.66.251:8333 lastseen=32.4hrs
received block 000000000000021f176d
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
ERROR: FetchInputs() : faa4a7ffaa mempool Tx prev not found 17ffdc0de5
stored orphan tx faa4a7ffaa (mapsz 1)
received block 00000000000001e2fc4f
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002168e46
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000013d86b8
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004df9d9b
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
received block 00000000000000ca2211
trying connection 206.214.221.145:8333 lastseen=19.6hrs
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000003a0e50d
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000049a671d
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004d162f0
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
ERROR: FetchInputs() : 469a200091 mempool Tx prev not found f88ad4fe16
stored orphan tx 469a200091 (mapsz 2)
connection timeout
received block 00000000000002e19724
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
trying connection 58.59.138.210:8333 lastseen=12.1hrs
ERROR: FetchInputs() : 3062710bb1 mempool Tx prev not found 337837ef71
stored orphan tx 3062710bb1 (mapsz 3)
connection timeout
trying connection 90.213.200.159:8333 lastseen=39.7hrs
received block 00000000000000e8cdb2
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000040cc0d5
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000001a5ff5
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002470854
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004a42633
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004e9e3f2
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002559d98
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000003eee1d3
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
ERROR: FetchInputs() : 7578d33c75 mempool Tx prev not found 996dbc5b74
stored orphan tx 7578d33c75 (mapsz 4)
ERROR: FetchInputs() : 5189182976 mempool Tx prev not found cc94b2a774
stored orphan tx 5189182976 (mapsz 5)
connection timeout
trying connection 83.31.49.235:8333 lastseen=107.1hrs
received block 00000000000004c20256
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
received block 00000000000000d0c8b6
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000001914137
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000015d4742
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
trying connection 50.73.45.241:8333 lastseen=25.7hrs
received block 000000000000024c8527
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000025fd8c7
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 74.138.246.128:8333 lastseen=8.5hrs
ERROR: FetchInputs() : dc303332d5 mempool Tx prev not found 7578d33c75
stored orphan tx dc303332d5 (mapsz 6)
connection timeout
trying connection 217.9.91.118:8333 lastseen=36.5hrs
Added 536 addresses from 67.170.161.21: 729 tried, 12522 new
received block 00000000000004ceb4ae
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 109.86.14.23:8333 lastseen=6.9hrs
received block 00000000000004585e25
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 2.230.36.153:8333 lastseen=37.9hrs
received block 0000000000000284a36c
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 24.178.88.230:8333 lastseen=9.3hrs
ERROR: FetchInputs() : 5b67be65e9 mempool Tx prev not found 8e890d7104
stored orphan tx 5b67be65e9 (mapsz 7)
ERROR: FetchInputs() : b1f58cba76 mempool Tx prev not found b05cfb03f2
stored orphan tx b1f58cba76 (mapsz 8)
connection timeout
trying connection 195.202.218.108:8333 lastseen=23.4hrs
connection timeout
trying connection 93.81.254.9:8333 lastseen=10.8hrs
ERROR: FetchInputs() : 18c5195d6b mempool Tx prev not found 52bfcc2590
stored orphan tx 18c5195d6b (mapsz 9)
ERROR: FetchInputs() : 354e163bca mempool Tx prev not found 9fdfcc266e
stored orphan tx 354e163bca (mapsz 10)
received block 00000000000001ed301a
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000004e0b5da
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 0000000000000497e056
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002b3ba2c
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
Added 570 addresses from 67.170.161.21: 729 tried, 12557 new
connection timeout
trying connection 81.84.211.237:8333 lastseen=27.0hrs
received block 0000000000000188994a
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 72.53.3.229:8333 lastseen=45.7hrs
ERROR: CAddrman::Write() : open failed
Flushed 13286 addresses to peers.dat  24ms
received block 000000000000047a390d
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 190.246.43.47:8333 lastseen=37.0hrs
received block 00000000000001df9f9f
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
Added 7 addresses from ::: 729 tried, 12559 new
13 addresses found from DNS seeds
ThreadDNSAddressSeed exited
received block 000000000000018e4a82
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 000000000000026168ea
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000000888968
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000001064014
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002e26a33
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000000cd9ded
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
connection timeout
trying connection 217.147.162.222:8333 lastseen=11.2hrs
received block 000000000000012b7d43
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block 00000000000002b5e089
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
Added 114 addresses from 95.172.9.82: 729 tried, 12567 new
Added 1 addresses from 95.172.9.82: 729 tried, 12567 new
connection timeout
trying connection 70.162.76.144:8333 lastseen=15.0hrs
connected 70.162.76.144:8333
send version message: version 60002, blocks=206457, us=xxx.xxx.xxx.xxx:8333, them=70.162.76.144:8333, peer=70.162.76.144:8333
received block 000000000000014f4645
ProcessBlock: ORPHAN BLOCK, prev=000000000000024c3771
ERROR: FetchInputs() : 131ea92385 mempool Tx prev not found 3443ab8753
stored orphan tx 131ea92385 (mapsz 11)
ERROR: FetchInputs() : c92bec7498 mempool Tx prev not found ed8d2cec6f
stored orphan tx c92bec7498 (mapsz 12)
ERROR: FetchInputs() : 8b6e65ed5a mempool Tx prev not found dddc000e08
stored orphan tx 8b6e65ed5a (mapsz 13)
ERROR: FetchInputs() : ce701db2a0 mempool Tx prev not found ecef494aad
stored orphan tx ce701db2a0 (mapsz 14)
ERROR: FetchInputs() : 03b972ac88 mempool Tx prev not found eaf11c833e
stored orphan tx 03b972ac88 (mapsz 15)
ERROR: FetchInputs() : a277e3e29b mempool Tx prev not found 55678a46e9
stored orphan tx a277e3e29b (mapsz 16)
ERROR: FetchInputs() : ef07e48ee5 mempool Tx prev not found 66b40a0ad4
stored orphan tx ef07e48ee5 (mapsz 17)
ERROR: FetchInputs() : 6adc8799db mempool Tx prev not found 0dbc3a8bd7
stored orphan tx 6adc8799db (mapsz 18)
ERROR: FetchInputs() : 5ba6b6e6ce mempool Tx prev not found f1469cbbba
stored orphan tx 5ba6b6e6ce (mapsz 19)
ERROR: FetchInputs() : be09a2d11c mempool Tx prev not found 6adc8799db
stored orphan tx be09a2d11c (mapsz 20)
ERROR: FetchInputs() : 68e01c7d0b mempool Tx prev not found 3366845f26
stored orphan tx 68e01c7d0b (mapsz 21)
ERROR: FetchInputs() : 7cb74aad6a mempool Tx prev not found 3fc244e381
stored orphan tx 7cb74aad6a (mapsz 22)
trying connection 82.58.25.9:8333 lastseen=18.2hrs
Added time data, samples 5, offset -265 (-4 minutes)
nTimeOffset = -255  (-4 minutes)
receive version message: version 60001, blocks=206541, us=xxx.xxx.xxx.xxx:35887, them=70.162.76.144:8333, peer=70.162.76.144:8333
received block 000000000000021139f8
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
ERROR: FetchInputs() : 605f931912 mempool Tx prev not found dcdeecf4e0
stored orphan tx 605f931912 (mapsz 23)
connection timeout
trying connection 76.85.165.113:8333 lastseen=30.0hrs
connect() failed after select(): No route to host
Added 530 addresses from 70.162.76.144: 729 tried, 12576 new
trying connection 65.185.46.38:8333 lastseen=43.4hrs
Added 523 addresses from 70.162.76.144: 729 tried, 12623 new
Added 251 addresses from 70.162.76.144: 729 tried, 12639 new
connection timeout
trying connection 84.110.216.9:8333 lastseen=11.5hrs
ERROR: FetchInputs() : d8deba3120 mempool Tx prev not found 5ba6b6e6ce
stored orphan tx d8deba3120 (mapsz 24)
ERROR: FetchInputs() : a6ca346571 mempool Tx prev not found 021996e8fd
stored orphan tx a6ca346571 (mapsz 25)
connection timeout
trying connection 78.36.70.200:8333 lastseen=14.3hrs
It seems everything just goes horribly wrong somehow with block 206548. I've tried several times (from old backups of the blockchain) with both versions and it's always the same block. There's nothing unusual about that block, is there? In any case, is it possible to fix it without downloading the whole blockchain again? (Though I doubt that would help anyway unless my blockchain got corrupted a while ago and it's only just causing an issue now for some reason.)

EDIT: The problem seems to have fixed itself. Bitcoin 0.7.0 (I gave up on trying to get 0.7.1 to work) is now fully synchronised after restoring a backup of the blockchain (the same backup which kept crashing on block 206548 earlier). Though I'm still curious what caused the problem in the first place. What do those errors mean?
Jump to: