mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-15 07:46:56 +02:00
coins: compact chainstate in background
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>
This commit is contained in:
@@ -1078,7 +1078,7 @@ BOOST_FIXTURE_TEST_CASE(coins_db_leveldb_layout, FlushTest)
|
||||
cache.Sync();
|
||||
|
||||
BOOST_CHECK_EQUAL(level2_files(base), 0);
|
||||
WITH_LOCK(::cs_main, base.CompactFull());
|
||||
WITH_LOCK(::cs_main, return base.CompactFull()).wait();
|
||||
BOOST_CHECK_EQUAL(level2_files(base), 1);
|
||||
|
||||
BOOST_CHECK(*Assert(base.GetCoin(outpoint)) == coin);
|
||||
|
||||
Reference in New Issue
Block a user