-reindex fails if blk0*.dat files read-only #2039
issue luke-jr openend this issue on November 26, 2012-
luke-jr commented at 9:29 pm on November 26, 2012: memberTo reproduce: chmod -r datadir/blk0_.dat Expected behaviour: Reindex read-only block file, and create a new blk0_.dat file when there are new blocks to add.
-
jgarzik commented at 9:47 pm on November 26, 2012: contributorDetails of failure? File changes? debug.log entries?
-
laanwj commented at 9:54 am on May 18, 2015: memberbitcoind makes the (generally valid) assumption a that it can write anything in its data directory. Reindexing from read-only block files may be a useful feature in some cases, but I’m removing the bug label.
-
laanwj added the label Feature on May 18, 2015
-
laanwj removed the label Bug on May 18, 2015
-
laanwj removed the label Priority Low on May 18, 2015
-
mruddy commented at 11:31 am on April 18, 2022: contributor
I was just looking at this. The fix introduced by #24858 gets us very close to being able to allow read only blk files that are already finalized. This only makes sense with finalized block files as blk files that have logical space under the 128 MiB limit need to be writable for appending additional blocks. Even with the #24858 fix,
BlockManager::FlushBlockFile
still tries to open the finalized block file for writing. But, I don’t think it would be very difficult to keep track inBlockManager::FindBlockPos
via them_blockfile_info[nFile]
to know if the current blk file has been appended. We’d have to add another data member to track if any new blocks have been appended to the blockfile. If it hasn’t been appended, then we could accept the blk flush failing as it was not changed, and the failure was caused by not being able to open it for writing.For reference, I tested current master branch functionality and got the following while using only a single finalized blk00000.dat (fe4b764e0ce523cfce6d9e4f326e0d0977ee317a51b4a129cda707cfa4699dd7 blocks/blk00000.dat):
0Unable to open file /tmp/btc/blocks/blk00000.dat 1ERROR: Flush: failed to open file 0 2*** Flushing block file to disk failed. This is likely the result of an I/O error. 3Error: A fatal internal error occurred, see debug.log for details
-
mruddy referenced this in commit af864a5a56 on Nov 19, 2022
-
pinheadmz commented at 12:14 pm on February 7, 2023: member@luke-jr possible fix here, with tests: https://github.com/bitcoin/bitcoin/pull/27039
-
pinheadmz assigned pinheadmz on Jun 2, 2023
-
achow101 referenced this in commit 541976b42e on Sep 14, 2023
-
Frank-GER referenced this in commit be40923930 on Sep 19, 2023
-
achow101 closed this on Mar 20, 2024
-
achow101 referenced this in commit 69ddee6f39 on Mar 20, 2024
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 15:12 UTC
More mirrored repositories can be found on mirror.b10c.me