Backports:
Final changes for v30.3rc1.
Backports since 30.2:
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35452.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | sedited, marcofleon |
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
Can we have something like this in the release notes. Also for 29 point release (and possibly 31 if we don't have an automatic compaction patch merged):
This fixes an issue where the chainstate database would repeatedly rewrite large portions of itself, causing excessive disk reads and writes during normal operation.
As a side effect, the chainstate will be around 4 GB larger after an initial sync. To reclaim this space, restart the node with
-forcecompactdb=1after the initial sync has finished. It should be removed on subsequent restarts. Leaving it set will cause significant disk reads and writes every time the node is restarted.
This is no-longer a proper subtree, because of direct cherry-picks.
Can we have something like this in the release notes.
Pulled that into the release notes.
Add `CDBWrapper::GetProperty()` and expose it through `CCoinsViewDB::GetDBProperty()` so coins tests can inspect LevelDB runtime properties through the coins view.
Use it in a coins DB flush baseline that records the LevelDB layout after flushing while keeping readback coverage for the flushed coin and best block.
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Github-Pull: #35465
Rebased-From: b10889d10752c5d5e4954af2959f7bdff47bd67c
Full chainstate flushes are convenient maintenance points for long-term LevelDB cleanup because the chainstate was just written.
Randomize the trigger so nodes that flush near the same height do not compact together.
Add blocking chainstate compaction through `CCoinsViewDB::CompactFull()` and give each post-IBD full flush on the normal chainstate a 1/320 chance to start compaction.
With hourly flushes this averages roughly every two weeks and makes a six-month miss about one in a million.
This keeps the schedule stateless and leaves last-compaction height or timestamp bookkeeping out of chainstate metadata.
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Github-Pull: #35465
Rebased-From: aa021b26f39fd231b2a3aac5780d5113a4aea639
Full chainstate compaction can take minutes on large databases.
Move `CCoinsViewDB::CompactFull()` to a named `utxocompact` one-shot background thread so validation only schedules the work.
When validation selects compaction after a full flush, the chainstate was just written and another write is less likely to be needed immediately.
The coins view destructor waits for completion, and a mutex prevents compaction from using `m_db` while `ResizeCache()` replaces it.
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Github-Pull: #35465
Rebased-From: 394e473d42ba1383dfec45a3eafa8a73a09dbe8b
These are unused and removing them avoids clang warnings like:
src/test/fuzz/deserialize.cpp:42:26: error: variable g_setup set but not used [-Werror,-Wunused-but-set-variable]
Github-Pull: #34918
Rebased-From: fabbfec3b00c138a28034a4f5594305d2220b9bb
2915 | + if (m_chainman.m_options.signals) { 2916 | + // Update best block in wallet (so we can detect restored wallets). 2917 | + m_chainman.m_options.signals->ChainStateFlushed(this->GetRole(), GetLocator(m_chain.Tip())); 2918 | + } 2919 | + 2920 | + if (!m_chainman.m_interrupt && m_chainman.m_chainstates.size() == 1) { // Skip AssumeUTXO
In commit cbdb11da241cd39cc2d1813369fa25e1987d98c5
I think you want m_chainman.GetAll().size() here instead of m_chainman.m_chainstates.size() (and probably in the 29 backport too to make the ancestor commit CI pass).
ACK d52747d8e74cc0ebec252c4f5680d184fb655e80
ACK d52747d8e74cc0ebec252c4f5680d184fb655e80
Milestone
30.3