coins: warn of low disk space before chainstate compaction #36586

Manually merged
l0rinc merged 3 commits from l0rinc/chainstate-compaction-headroom into master 2026-11-20 22:11:46 +00:00 AGit
l0rinc commented 2026-10-20 21:34:41 +00:00 (Migrated from github.com)

Problem: Full chainstate compaction can temporarily require nearly another copy of the database before old files are deleted.

Fix: Log automatic full compaction start and finish at info level. Before starting, check the free space on the chainstate filesystem, and if it is below m_assumed_chain_state_size, log a warning and skip this compaction. Skipping avoids the temporary extra disk use but leaves obsolete data taking up space.

Fixes #36585

**Problem:** Full chainstate compaction can temporarily require nearly another copy of the database before old files are deleted. **Fix:** Log automatic full compaction start and finish at info level. Before starting, check the free space on the chainstate filesystem, and if it is below `m_assumed_chain_state_size`, log a warning and skip this compaction. Skipping avoids the temporary extra disk use but leaves obsolete data taking up space. Fixes #36585
DrahtBot commented 2026-10-20 21:34:49 +00:00 (Migrated from github.com)

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK optout21, stickies-v, danielabrozzoni, achow101
Concept ACK sedited, stringintech

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36904 (scripted-diff: Remove trailing newlines from one-line log messages by maflcko)
  • #36598 ([Demo] validation: remove AssumeUTXO by l0rinc)
  • #34132 (coins,dbwrapper: make point-read and txindex lookup failures fatal by l0rinc)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36586 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36586.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36586#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [optout21](https://github.com/bitcoin/bitcoin/pull/36586#issuecomment-6380160065), [stickies-v](https://github.com/bitcoin/bitcoin/pull/36586#issuecomment-6413372201), [danielabrozzoni](https://github.com/bitcoin/bitcoin/pull/36586#pullrequestreview-5841571389), [achow101](https://github.com/bitcoin/bitcoin/pull/36586#issuecomment-7051335354) | | Concept ACK | [sedited](https://github.com/bitcoin/bitcoin/pull/36586#issuecomment-6309945846), [stringintech](https://github.com/bitcoin/bitcoin/pull/36586#pullrequestreview-5825766436) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36904](https://github.com/bitcoin/bitcoin/pull/36904) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36904.svg"></sub> (scripted-diff: Remove trailing newlines from one-line log messages by maflcko) * [#36598](https://github.com/bitcoin/bitcoin/pull/36598) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36598.svg"></sub> ([Demo] validation: remove AssumeUTXO by l0rinc) * [#34132](https://github.com/bitcoin/bitcoin/pull/34132) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34132.svg"></sub> (coins,dbwrapper: make point-read and txindex lookup failures fatal by l0rinc) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Earlier concerns remain unresolved; see the full report for their current assessments.

🟠 Minor · Compaction checks do not account for chainstates sharing a filesystem

At validation.cpp:2837-2839 each chainstate checks shared free space against one AssumedChainStateSize and compacts on its own. With AssumeUTXO, chainstate and chainstate_snapshot share the datadir, so overlapping compactions could together exceed the checked headroom. This needs both 1/320 draws to fire close together.

Location: src/validation.cpp:2834 (head).

🔵 Suggestion · Zero estimates provide no compaction-specific disk headroom

On disk-backed regtest and custom signet nodes, the zero assumed size reduces this guard to 50 MiB regardless of the database size.

Location: src/validation.cpp:2837 (head).

🔵 Suggestion · Deferral warning understates the required free space

Near the threshold, the warning can report more free space than “needed” because it omits CheckDiskSpace's 50 MiB reserve.

Location: src/validation.cpp:2841 (head).

🔵 Suggestion · Low-space compaction scheduling has no deterministic regression test

Existing compaction tests bypass the scheduling gate, while the chainstate-write fixtures use in-memory databases, so these assertions cannot catch a removed or inverted space check.

Location: src/validation.cpp:2838 (head).

Review coverage was incomplete.


Reviewed: 2fcfa1dae75c · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:242447a4cf2eea8cf36c662182c044a4a03c53913b7033d9c612118a365b2d2c:1e657457416e20a18d8d2d136919c48e28e1bfed7a76c26939ab1ca10a232c6a --> <!-- ralph-base:6c01bd0b2dc201c21e80ac3635828abf854ee5a0 --> <!-- ralph-head:2fcfa1dae75ccd11062a6e6073600e67eb20164c --> <!-- ralph-case:c883224ac427cbd29b9087440a8fe659ca57c7aaaa458198d01ea3eeb18aee66 --> Earlier concerns remain unresolved; see the full report for their current assessments. **🟠 Minor · Compaction checks do not account for chainstates sharing a filesystem** At validation.cpp:2837-2839 each chainstate checks shared free space against one AssumedChainStateSize and compacts on its own. With AssumeUTXO, chainstate and chainstate_snapshot share the datadir, so overlapping compactions could together exceed the checked headroom. This needs both 1/320 draws to fire close together. Location: [`src/validation.cpp:2834`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2fcfa1dae75ccd11062a6e6073600e67eb20164c/src/validation.cpp#L2834>) (head). **🔵 Suggestion · Zero estimates provide no compaction-specific disk headroom** On disk-backed regtest and custom signet nodes, the zero assumed size reduces this guard to 50 MiB regardless of the database size. Location: [`src/validation.cpp:2837`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2fcfa1dae75ccd11062a6e6073600e67eb20164c/src/validation.cpp#L2837>) (head). **🔵 Suggestion · Deferral warning understates the required free space** Near the threshold, the warning can report more free space than “needed” because it omits CheckDiskSpace's 50 MiB reserve. Location: [`src/validation.cpp:2841`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2fcfa1dae75ccd11062a6e6073600e67eb20164c/src/validation.cpp#L2841>) (head). **🔵 Suggestion · Low-space compaction scheduling has no deterministic regression test** Existing compaction tests bypass the scheduling gate, while the chainstate-write fixtures use in-memory databases, so these assertions cannot catch a removed or inverted space check. Location: [`src/validation.cpp:2838`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/2fcfa1dae75ccd11062a6e6073600e67eb20164c/src/validation.cpp#L2838>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`2fcfa1dae75c`](<https://git.fish.foo/bitcoin/bitcoin/commit/2fcfa1dae75ccd11062a6e6073600e67eb20164c>) · [Full review report](<https://review.fish.foo/traces/36586-2fcfa1dae75ccd11062a6e6073600e67eb20164c-1923-9.html>) · [Previous reports](<https://review.fish.foo/traces/36586/>) [permalink](<https://review.fish.foo/traces/36586-2fcfa1dae75ccd11062a6e6073600e67eb20164c-1923-9.html>)
andrewtoth commented 2026-10-20 23:01:37 +00:00 (Migrated from github.com)

Compaction continues after the warning because postponing cleanup would allow obsolete data to accumulate.

Would it make more sense to just skip compaction if we don't think there's enough free disk space to do it? This would have the tradeoff that some extra data would remain, but it would let users like the issue reporter continue running their node for likely several years without any problems.

> Compaction continues after the warning because postponing cleanup would allow obsolete data to accumulate. Would it make more sense to just skip compaction if we don't think there's enough free disk space to do it? This would have the tradeoff that some extra data would remain, but it would let users like the issue reporter continue running their node for likely several years without any problems.
l0rinc commented 2026-10-21 06:47:01 +00:00 (Migrated from github.com)

Thanks @andrewtoth, updated as suggested.

Thanks @andrewtoth, updated as suggested.
sedited commented 2026-10-21 06:50:51 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
stickies-v commented 2026-10-21 15:26:16 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
stickies-v (Migrated from github.com) reviewed 2026-10-21 17:03:18 +00:00
stickies-v (Migrated from github.com) commented 2026-10-21 17:03:18 +00:00

My understanding of the worst case here is that this happens when all the data is on a single level L, with a very sparse (<32MiB) level L-1 above it. Because L-1 is so sparse, all L-1 files (with keys across the entire L level) get compacted in one go, causing the entire dense level L (~the entire database) to be temporarily copied, correct?

It seems like we're already being more adventurous with our LevelDB usage than we perhaps should be (the CompactRange docstring states "This operation should typically only be invoked by users who understand the underlying implementation."), but perhaps an alternative approach could be to call CompactRange on slices, instead of on the entire (nullptr, nullptr) range in one go?

My understanding of the worst case here is that this happens when all the data is on a single level L, with a very sparse (<32MiB) level L-1 above it. Because L-1 is so sparse, all L-1 files (with keys across the entire L level) get compacted in one go, causing the entire dense level L (~the entire database) to be temporarily copied, correct? It seems like we're already being more adventurous with our LevelDB usage than we perhaps should be (the `CompactRange` docstring states _"This operation should typically only be invoked by users who understand the underlying implementation."_), but perhaps an alternative approach could be to call `CompactRange` on slices, instead of on the entire (`nullptr`, `nullptr`) range in one go?
l0rinc (Migrated from github.com) reviewed 2026-10-22 10:39:01 +00:00
l0rinc (Migrated from github.com) commented 2026-10-22 10:39:01 +00:00

Thanks for the hint, we should investigate that - I tried compacting smaller key ranges locally, which reduced peak disk usage in some cases but could still produce large spikes, defeating the purpose. Partial compaction could be investigated separately, but it seems fairly complicated, and I don't think the benefit is worth adding that complexity to this PR.

Thanks for the hint, we should investigate that - I tried compacting smaller key ranges locally, which reduced peak disk usage in some cases but could still produce large spikes, defeating the purpose. Partial compaction could be investigated separately, but it seems fairly complicated, and I don't think the benefit is worth adding that complexity to this PR.
l0rinc commented 2026-10-22 10:39:23 +00:00 (Migrated from github.com)

I've separated the free-space check from the database operation and unified the compaction logging, as @optout21 suggested in the original PR.

I've separated the free-space check from the database operation and unified the compaction logging, as @optout21 suggested in the original PR.
optout21 (Migrated from github.com) reviewed 2026-10-22 11:30:55 +00:00
optout21 (Migrated from github.com) left a comment

Concept ACK
Left minor comments on the wording of the warning.

Concept ACK Left minor comments on the wording of the warning.
optout21 (Migrated from github.com) commented 2026-10-22 11:18:44 +00:00

694c535 coins: skip compaction if disk space is low:

Additionally logging here the currently observed available space is marginally helpful (guideline: if a log is a result of a decision based on several values, log each).

> [694c535](https://github.com/bitcoin/bitcoin/pull/36586/changes/694c535312d90e31f5a3c47f4db7cc32cfbb61c0) _coins: skip compaction if disk space is low_: Additionally logging here the currently observed available space is marginally helpful (guideline: if a log is a result of a decision based on several values, log each).
optout21 (Migrated from github.com) commented 2026-10-22 11:23:33 +00:00

694c535 coins: skip compaction if disk space is low:

Could we add some more explanatory and call-to-action info here? Describing that the uncompacted DB takes up more disk space, and that the user should free up some disk space.
Also, I suggest changing the wording "Skipping" to "Deferring", to suggest that it's not without consequences.

> [694c535](https://github.com/bitcoin/bitcoin/pull/36586/changes/694c535312d90e31f5a3c47f4db7cc32cfbb61c0) _coins: skip compaction if disk space is low_: Could we add some more explanatory and call-to-action info here? Describing that the uncompacted DB takes up more disk space, and that the user should free up some disk space. Also, I suggest changing the wording "Skipping" to "Deferring", to suggest that it's not without consequences.
stickies-v (Migrated from github.com) approved these changes 2026-10-23 09:31:00 +00:00
stickies-v (Migrated from github.com) left a comment
ACK ed0f6de8104d67454c0b9547fd19113d4e95abf2
stickies-v (Migrated from github.com) commented 2026-10-23 09:23:39 +00:00

nit: I found the "may need another database copy" a bit confusing, and think the rest of the phrasing could be a bit more clear as well. Proposed alternative, if you like:

Periodic background chainstate compaction is now logged by default. It can
temporarily use about as much extra disk space as the chainstate, so it is
skipped with a warning if there is not enough free space, leaving obsolete
data to take up unnecessary disk space.

nit: I found the "may need another database copy" a bit confusing, and think the rest of the phrasing could be a bit more clear as well. Proposed alternative, if you like: > Periodic background chainstate compaction is now logged by default. It can temporarily use about as much extra disk space as the chainstate, so it is skipped with a warning if there is not enough free space, leaving obsolete data to take up unnecessary disk space.
stickies-v (Migrated from github.com) commented 2026-10-23 09:25:20 +00:00

I don't think the benefit is worth adding that complexity to this PR.

Yeah, I think I agree.

> I don't think the benefit is worth adding that complexity to this PR. Yeah, I think I agree.
stickies-v (Migrated from github.com) commented 2026-10-23 09:09:11 +00:00

nit: any reason we're not using CheckDiskSpace() here?

nit: any reason we're not using `CheckDiskSpace()` here?
stickies-v (Migrated from github.com) commented 2026-10-23 09:15:03 +00:00

For an in-memory database, the compaction memory usage problem is arguably even worse than the on-disk one? Since memory-only is quite ephemeral in nature, I think it's uncontroversial to just skip compaction entirely in that case?

For an in-memory database, the compaction memory usage problem is arguably even worse than the on-disk one? Since memory-only is quite ephemeral in nature, I think it's uncontroversial to just skip compaction entirely in that case?
l0rinc (Migrated from github.com) reviewed 2026-10-23 20:49:08 +00:00
l0rinc (Migrated from github.com) commented 2026-10-23 20:49:08 +00:00

Guess the extra 50 MiB reserve is fine here (seemed imprecise to me) - changed.

Guess the extra 50 MiB reserve is fine here (seemed imprecise to me) - changed.
l0rinc (Migrated from github.com) reviewed 2026-10-23 20:49:17 +00:00
l0rinc (Migrated from github.com) commented 2026-10-23 20:49:17 +00:00

Done, thanks

Done, thanks
l0rinc (Migrated from github.com) reviewed 2026-10-23 20:49:23 +00:00
l0rinc (Migrated from github.com) commented 2026-10-23 20:49:23 +00:00

Done

Done
l0rinc (Migrated from github.com) reviewed 2026-10-23 20:49:32 +00:00
l0rinc (Migrated from github.com) commented 2026-10-23 20:49:32 +00:00

Sure, I was also wondering if someone would comment on bubbling this check up - thanks, done.

Sure, I was also wondering if someone would comment on bubbling this check up - thanks, done.
l0rinc (Migrated from github.com) reviewed 2026-10-23 20:49:36 +00:00
l0rinc (Migrated from github.com) commented 2026-10-23 20:49:36 +00:00

Did something similar, thanks.

Did something similar, thanks.
l0rinc commented 2026-10-23 20:51:53 +00:00 (Migrated from github.com)

Thanks for the reviews, updated to skip automatic in-memory compaction, use CheckDiskSpace() with 50 mb additional overhead, include available space and recovery guidance in the warning, and clarify the release note.

Thanks for the reviews, updated to skip automatic in-memory compaction, use `CheckDiskSpace()` with 50 mb additional overhead, include available space and recovery guidance in the warning, and clarify the release note.
optout21 (Migrated from github.com) reviewed 2026-10-24 04:56:47 +00:00
optout21 (Migrated from github.com) commented 2026-10-24 04:56:47 +00:00

AssumedChainStateSize() is also rather imprecise here.

`AssumedChainStateSize()` is also rather imprecise here.
optout21 commented 2026-10-24 05:03:28 +00:00 (Migrated from github.com)

crACK 2fcfa1dae7

crACK 2fcfa1dae75ccd11062a6e6073600e67eb20164c
stickies-v commented 2026-10-26 10:06:22 +00:00 (Migrated from github.com)
ACK 2fcfa1dae75ccd11062a6e6073600e67eb20164c
andrewtoth (Migrated from github.com) requested changes 2026-10-31 19:48:23 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-31 19:48:09 +00:00

I don't think this change warrants a release note.
If others disagree, at least the last part of this line should be struck."obsolete data" is not something a user reading the release notes will understand.

I don't think this change warrants a release note. If others disagree, at least the last part of this line should be struck."obsolete data" is not something a user reading the release notes will understand.
andrewtoth (Migrated from github.com) commented 2026-10-31 19:46:01 +00:00

I'm not sure we should warn about this. Running on a system with < 2x the chainstate disk space should be supported. If that is the case there is nothing the user can do, and they shouldn't be getting warnings about it.

I'm not sure we should warn about this. Running on a system with < 2x the chainstate disk space should be supported. If that is the case there is nothing the user can do, and they shouldn't be getting warnings about it.
l0rinc (Migrated from github.com) reviewed 2026-11-01 17:40:41 +00:00
l0rinc (Migrated from github.com) commented 2026-11-01 17:41:17 +00:00

Do they need to understand more than garbage collection needs a bit more space?

Do they need to understand more than garbage collection needs a bit more space?
l0rinc (Migrated from github.com) commented 2026-11-01 17:40:41 +00:00

Running on a system with < 2x the chainstate disk space should be supported

We can't expect a node to run without compactions, so we have to let the user know that it's a temporary allowance and that they should do something about it: relocate to a bigger disk, delete some files, prune harder, etc.

> Running on a system with < 2x the chainstate disk space should be supported We can't expect a node to run without compactions, so we have to let the user know that it's a temporary allowance and that they should do something about it: relocate to a bigger disk, delete some files, prune harder, etc.
andrewtoth (Migrated from github.com) reviewed 2026-11-01 18:49:09 +00:00
andrewtoth (Migrated from github.com) commented 2026-11-01 18:49:09 +00:00

We can't expect a node to run without compactions

Why not? From my understanding the compactions are just a way to reduce disk usage in the chainstate db, but don't affect node operation otherwise.

Right now the chainstate db is ~11 GB. With pruning we can run it on an instance with < 20 GB of disk space. In this scenario the user will get a warning for every attempted compaction. What is the benefit of having this user relocate to a bigger disk, just to save disk space? Is there a way to determine the total disk size and skip warning if it is < 2x chainstate size?

> We can't expect a node to run without compactions Why not? From my understanding the compactions are just a way to reduce disk usage in the chainstate db, but don't affect node operation otherwise. Right now the chainstate db is ~11 GB. With pruning we can run it on an instance with < 20 GB of disk space. In this scenario the user will get a warning for every attempted compaction. What is the benefit of having this user relocate to a bigger disk, just to save disk space? Is there a way to determine the total disk size and skip warning if it is < 2x chainstate size?
l0rinc (Migrated from github.com) reviewed 2026-11-02 20:52:58 +00:00
l0rinc (Migrated from github.com) commented 2026-11-02 20:52:58 +00:00

It might be fine to keep running for a while without regular full compaction, which is why this is a warning rather than an abort. But the operator should be aware that the machine lacks the disk headroom for normal database maintenance.

Allowing tombstones to accumulate can also make full database scans more expensive, since those records still need to be traversed and skipped.

I don't think we should encourage sizing a node's disk around the chainstate staying at roughly 10 GB (hypothetically, it could even double in a month) - nodes need some headroom, hence the warning.

It might be fine to keep running for a while without regular full compaction, which is why this is a warning rather than an abort. But the operator should be aware that the machine lacks the disk headroom for normal database maintenance. Allowing tombstones to accumulate can also make full database scans more expensive, since those records still need to be traversed and [skipped](https://github.com/bitcoin/bitcoin/blob/20a6babfa9a66f5432ef19c6c433b4357560f853/src/leveldb/db/db_iter.cc#L177). I don't think we should encourage sizing a node's disk around the chainstate staying at roughly 10 GB (hypothetically, it could even double in a month) - nodes need some headroom, hence the warning.
stringintech (Migrated from github.com) reviewed 2026-11-09 14:08:21 +00:00
stringintech (Migrated from github.com) left a comment

Concept ACK.

Concept ACK.
stringintech (Migrated from github.com) commented 2026-11-09 12:22:12 +00:00

nit: From commit cef76701a8 description:

Skip periodic compaction for in-memory chainstates, which do not need to reclaim disk space.

Maybe here we can more accurately reflect the intention of skipping in-memory chainstates (stated in https://github.com/bitcoin/bitcoin/pull/36586#discussion_r4357973303). Because if it weren't for compaction's temporary extra space coming out of RAM (even scarcer than disk) and in-memory chainstates being mostly used for short-lived purposes, compaction would also have been helpful to reclaim memory space?

nit: From commit cef76701a81fde56ad143b4ea559468a6b4dc626 description: > Skip periodic compaction for in-memory chainstates, which do not need to reclaim disk space. Maybe here we can more accurately reflect the intention of skipping in-memory chainstates (stated in https://github.com/bitcoin/bitcoin/pull/36586#discussion_r4357973303). Because if it weren't for compaction's temporary extra space coming out of RAM (even scarcer than disk) and in-memory chainstates being mostly used for short-lived purposes, compaction would also have been helpful to reclaim memory space?
stringintech (Migrated from github.com) commented 2026-11-09 13:59:06 +00:00

I was wondering whether, if we want the node operator to act on the warning, we could surface it in a more visible/persistent way as well. But it looks like we reserve persistent warnings for more critical/consensus-related cases? (While looking into how we currently emit the more persistent warnings, I also noticed that the first-startup disk space check doesn't account for the space needed by the chainstate, so I opened #36811 to get feedback. If that lands, maybe a follow-up could extend the check with the headroom needed for compaction?)

I was wondering whether, if we want the node operator to act on the warning, we could surface it in a more visible/persistent way as well. But it looks like we reserve persistent warnings for more critical/consensus-related cases? (While looking into how we currently emit the more persistent warnings, I also noticed that the first-startup disk space check doesn't account for the space needed by the chainstate, so I opened #36811 to get feedback. If that lands, maybe a follow-up could extend the check with the headroom needed for compaction?)
danielabrozzoni (Migrated from github.com) reviewed 2026-11-10 12:11:27 +00:00
danielabrozzoni (Migrated from github.com) left a comment

light tACK 2fcfa1dae7

Very new to this part of the code, but this looks good to me. I tested on my own system by:

  1. Changing ShouldCompactChainstate to always returns true if not in IBD
  2. (Almost) filling my disk using fallocate :)
  3. Calling bitcoin-cli gettxoutsetinfo to force flush to disk

And saw the log:

2026-11-10T11:49:02Z [warning] Deferring chainstate compaction of /home/daniela/.bitcoin/chainstate: 8.38 GiB free, 14 GiB needed. Free up some space so compaction can run.
light tACK 2fcfa1dae75ccd11062a6e6073600e67eb20164c Very new to this part of the code, but this looks good to me. I tested on my own system by: 1. Changing `ShouldCompactChainstate` to always returns true if not in IBD 2. (Almost) filling my disk using `fallocate` :) 3. Calling `bitcoin-cli gettxoutsetinfo` to force flush to disk And saw the log: ``` 2026-11-10T11:49:02Z [warning] Deferring chainstate compaction of /home/daniela/.bitcoin/chainstate: 8.38 GiB free, 14 GiB needed. Free up some space so compaction can run. ```
achow101 commented 2026-11-20 21:43:43 +00:00 (Migrated from github.com)
ACK 2fcfa1dae75ccd11062a6e6073600e67eb20164c
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36586
No description provided.