util: Remove code to cache datadir #16255

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1906-utilNoPath changing 3 files +15 −49
  1. MarcoFalke commented at 5:55 pm on June 20, 2019: member

    The rationale for caching the datadir is given as

    0    // This can be called during exceptions by LogPrintf(), so we cache the
    1    // value so we don't have to do memory allocations after that.
    

    However, since 8c2d695c4a45bdd9378c7970b0fcba6e1efc01f9, the debug log location is actually cached itself in m_file_path.

    So remove the now-useless caching.

  2. MarcoFalke added the label Refactoring on Jun 20, 2019
  3. MarcoFalke added the label Utils/log/libs on Jun 20, 2019
  4. MarcoFalke commented at 6:09 pm on June 20, 2019: member
    Will reopen after #16252
  5. MarcoFalke closed this on Jun 20, 2019

  6. laanwj commented at 9:18 am on June 25, 2019: member
    Concept ACK
  7. in src/util/system.cpp:705 in fae43f618f outdated
    701@@ -702,23 +702,9 @@ fs::path GetDefaultDataDir()
    702 #endif
    703 }
    704 
    705-static fs::path g_blocks_path_cache_net_specific;
    


    laanwj commented at 10:20 am on June 25, 2019:
    happy to see this code simplified, it has been a frequent source of errors in the past
  8. fanquake reopened this on Jun 25, 2019

  9. fanquake added the label Needs rebase on Jun 25, 2019
  10. MarcoFalke force-pushed on Jun 25, 2019
  11. MarcoFalke force-pushed on Jun 25, 2019
  12. MarcoFalke force-pushed on Jun 25, 2019
  13. MarcoFalke force-pushed on Jun 25, 2019
  14. DrahtBot removed the label Needs rebase on Jun 25, 2019
  15. DrahtBot commented at 5:08 pm on June 25, 2019: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #16273 (refactor: Remove unused includes by practicalswift)
    • #15871 (Handle exception when creating default -datadir by promag)
    • #15864 (Fix datadir handling by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  16. laanwj commented at 11:09 am on June 27, 2019: member

    A side-effect of caching was that this code was only run the first call to GetDataDir. Right now, it will try to create the data directory every time:

    0    if (fs::create_directories(path)) {
    1        // This is the first run, create wallets subdirectory too
    2        fs::create_directories(path / "wallets");
    3    }
    

    (this not only results in system call spam, but also a change in behavior if, for some reason, the datadir disappears) A simple solution to avoid this would be to add a static bool flag for this.

  17. promag commented at 11:19 am on June 27, 2019: member

    but also a change in behavior if, for some reason, the datadir disappears

    that’s good? @laanwj wouldn’t it be better to just call create_directories as soon as possible, like it should belong to the startup? Currently is kind of hard to know when directories are actually created.

  18. laanwj commented at 11:51 am on June 27, 2019: member

    that’s good?

    That definitely isn’t good, if the datadir disappears while running you want the process to die as soon as possible and not mess with creating directories.

    @laanwj wouldn’t it be better to just call create_directories as soon as possible, like it should belong to the startup? Currently is kind of hard to know when directories are actually created.

    Yes that would be better, however this is very hard to reason about, and review, with the complexity of our startup sequence. Maybe better to leave for a future PR, which is why I suggested the most straightforward solution.

  19. MarcoFalke force-pushed on Jun 27, 2019
  20. MarcoFalke force-pushed on Jun 27, 2019
  21. MarcoFalke commented at 4:19 pm on June 27, 2019: member

    It is indeed weird to write to disk in a method, whose name implies it is a simple getter.

    Added a guard to the disk access for now, but this should be improved in the future. (See also “Fix datadir handling” #15864)

  22. util: Remove code to cache datadir fab04969fb
  23. MarcoFalke force-pushed on Jun 27, 2019
  24. MarcoFalke commented at 6:10 pm on June 27, 2019: member
    I think this is not worth it, so giving up on this for now. Someone should move out the fs::create_directories first.
  25. MarcoFalke closed this on Jun 27, 2019

  26. MarcoFalke deleted the branch on Jun 27, 2019
  27. laanwj referenced this in commit 935cd6b1ec on Jun 28, 2019
  28. Munkybooty referenced this in commit 64fce323fd on Nov 2, 2021
  29. Munkybooty referenced this in commit 9a7cf8a58c on Nov 2, 2021
  30. Munkybooty referenced this in commit a4a88e171a on Nov 4, 2021
  31. Munkybooty referenced this in commit ab31a99dff on Nov 16, 2021
  32. Munkybooty referenced this in commit c2b9f011ce on Nov 18, 2021
  33. DrahtBot locked this on Dec 16, 2021

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-11-25 06:12 UTC

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