reindex reopen readonly blocks to write #11938

issue Elbandi openend this issue on December 18, 2017
  1. Elbandi commented at 3:35 pm on December 18, 2017: contributor

    i do a blockchain reindex, and i got issue:

    strace say, blocks files are reopened for fdatasync:

    … log coming later

    The only fdatasync call is in FileCommit, here is the callstack:

    (gdb) bt
    [#0](/bitcoin-bitcoin/0/)  FileCommit (file=0x7fff9f283a10) at util.cpp:686
    [#1](/bitcoin-bitcoin/1/)  0x000000000056129f in FlushBlockFile (fFinalize=<optimized out>) at validation.cpp:1543
    [#2](/bitcoin-bitcoin/2/)  0x00000000005748bf in FindBlockPos (state=..., pos=..., nAddSize=49046, nHeight=nHeight@entry=131237, nTime=1308224251, fKnown=<optimized out>) at validation.cpp:2745
    [#3](/bitcoin-bitcoin/3/)  0x0000000000575427 in AcceptBlock (pblock=..., state=..., chainparams=..., ppindex=ppindex@entry=0x0, fRequested=fRequested@entry=true, dbp=dbp@entry=0x7fffa6ffcdd0, fNewBlock=fNewBlock@entry=0x0) at validation.cpp:3215
    [#4](/bitcoin-bitcoin/4/)  0x0000000000584c26 in LoadExternalBlockFile (chainparams=..., fileIn=fileIn@entry=0x7fff9c000b20, dbp=dbp@entry=0x7fffa6ffcdd0) at validation.cpp:4101
    ....
    

    i dont know why sould FlushBlockFile called in FindBlockPos, if blocks is readonly.

  2. MarcoFalke commented at 1:39 am on December 19, 2017: member
    Please specify what version or commit you are running.
  3. laanwj added the label Block storage on Dec 19, 2017
  4. Elbandi commented at 2:12 pm on January 3, 2018: contributor

    i lost the strace log, but you can create anytime a new, just strace a -reindex start.

    own builds from source from this commit: 7b57bc998f334775b50ebc8ca5e78ca728db4c58

    I have a bootstrap create feature in validation.cpp file. this is my file: https://paste.ubuntu.com/26313136/

  5. TheBlueMatt commented at 8:48 pm on January 3, 2018: member
    We always flush the previous block file when we move to a new block file (FindBlockPos’ FlushBlockFile in nFile != nLastBlockFile check. Obviously if no blocks have been written (ie during reindex) there is no reason to do this, but we dont currently have such a concept. I’d doubt this is much of a performance issue as an fflush should be very cheap if there is no data to write. Hopefully, as CChainState refactors move forward, encapsulating this kind of logic should be much simpler in the future.
  6. Elbandi commented at 8:10 pm on January 5, 2018: contributor
    My old blocks are in a readonly storage (compressed squashfs, 40% space save), reindex try open in write mode to flush a non-written block, which gives an error (becase oldblocks storage is ro). :(
  7. TheBlueMatt commented at 5:31 pm on January 11, 2018: member
    If you’re patching the source anyway, you could trivially add a boolean for “has anything been written since nLastBlockFile changed”, would likely only need to update it in a few places in validation.cpp.
  8. adamjonas commented at 11:08 pm on January 19, 2021: member
    Close since this issue is stale and hasn’t progressed for some time. Note that CChainState has undergone some refactors since these comments including those for the assumeutxo project (see #16743, #16945 and #17737).
  9. adamjonas closed this on Jan 19, 2021

  10. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

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-12-22 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me