mirror of https://github.com/bitcoin/bitcoin
Merge bitcoin/bitcoin#29402: mempool: Log added for dumping mempool transactions to disk
4d5b55735b
log: renamed disk to file so wording was more accurate (kevkevin)b9f04be870
mempool: Log added for dumping mempool transactions to disk (kevkevin) Pull request description: Sometimes when shutting off bitcoind it can take a while to dump the mempool transaction onto the disk so this change adds additional logging to the `DumpMempool` method in `kernel/mempool_persist.cpp` Motivated by https://github.com/bitcoin/bitcoin/pull/29227 this change - adds a single new line for the amount of transactions being dumped and the amount of memory being dumped to file This is in response to https://github.com/bitcoin/bitcoin/pull/29227#issuecomment-1893375082 The logs will now look like this ``` 2024-02-09T23:41:52Z DumpAnchors: Flush 2 outbound block-relay-only peer addresses to anchors.dat completed (0.02s) 2024-02-09T23:41:52Z scheduler thread exit 2024-02-09T23:41:52Z Writing 29 mempool transactions to file... 2024-02-09T23:41:52Z Writing 0 unbroadcast transactions to file. 2024-02-09T23:41:52Z Dumped mempool: 0.000s to copy, 0.022s to dump, 0.015 MB dumped to file 2024-02-09T23:41:52Z Flushed fee estimates to fee_estimates.dat. 2024-02-09T23:41:53Z Shutdown: done ``` ACKs for top commit: maflcko: cr-ACK4d5b55735b
glozow: reACK4d5b557
Tree-SHA512: 049191e140d00c1ea57debe0138f1c9eb0f9bb0ef8138e2568e6d89e64f45a5d5853ce3b9cc0b28566aab97555b47ddfb0f9199fc8cea6b81e53f50592d5ae6a
This commit is contained in:
commit
d1e9a02126
|
@ -44,7 +44,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
||||||
|
|
||||||
AutoFile file{opts.mockable_fopen_function(load_path, "rb")};
|
AutoFile file{opts.mockable_fopen_function(load_path, "rb")};
|
||||||
if (file.IsNull()) {
|
if (file.IsNull()) {
|
||||||
LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n");
|
LogInfo("Failed to open mempool file. Continuing anyway.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
||||||
uint64_t total_txns_to_load;
|
uint64_t total_txns_to_load;
|
||||||
file >> total_txns_to_load;
|
file >> total_txns_to_load;
|
||||||
uint64_t txns_tried = 0;
|
uint64_t txns_tried = 0;
|
||||||
LogInfo("Loading %u mempool transactions from disk...\n", total_txns_to_load);
|
LogInfo("Loading %u mempool transactions from file...\n", total_txns_to_load);
|
||||||
int next_tenth_to_report = 0;
|
int next_tenth_to_report = 0;
|
||||||
while (txns_tried < total_txns_to_load) {
|
while (txns_tried < total_txns_to_load) {
|
||||||
const int percentage_done(100.0 * txns_tried / total_txns_to_load);
|
const int percentage_done(100.0 * txns_tried / total_txns_to_load);
|
||||||
if (next_tenth_to_report < percentage_done / 10) {
|
if (next_tenth_to_report < percentage_done / 10) {
|
||||||
LogInfo("Progress loading mempool transactions from disk: %d%% (tried %u, %u remaining)\n",
|
LogInfo("Progress loading mempool transactions from file: %d%% (tried %u, %u remaining)\n",
|
||||||
percentage_done, txns_tried, total_txns_to_load - txns_tried);
|
percentage_done, txns_tried, total_txns_to_load - txns_tried);
|
||||||
next_tenth_to_report = percentage_done / 10;
|
next_tenth_to_report = percentage_done / 10;
|
||||||
}
|
}
|
||||||
|
@ -138,11 +138,11 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("Failed to deserialize mempool data on disk: %s. Continuing anyway.\n", e.what());
|
LogInfo("Failed to deserialize mempool data on file: %s. Continuing anyway.\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf("Imported mempool transactions from disk: %i succeeded, %i failed, %i expired, %i already there, %i waiting for initial broadcast\n", count, failed, expired, already_there, unbroadcast);
|
LogInfo("Imported mempool transactions from file: %i succeeded, %i failed, %i expired, %i already there, %i waiting for initial broadcast\n", count, failed, expired, already_there, unbroadcast);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,9 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
|
||||||
}
|
}
|
||||||
file.SetXor(xor_key);
|
file.SetXor(xor_key);
|
||||||
|
|
||||||
file << (uint64_t)vinfo.size();
|
uint64_t mempool_transactions_to_write(vinfo.size());
|
||||||
|
file << mempool_transactions_to_write;
|
||||||
|
LogInfo("Writing %u mempool transactions to file...\n", mempool_transactions_to_write);
|
||||||
for (const auto& i : vinfo) {
|
for (const auto& i : vinfo) {
|
||||||
file << TX_WITH_WITNESS(*(i.tx));
|
file << TX_WITH_WITNESS(*(i.tx));
|
||||||
file << int64_t{count_seconds(i.m_time)};
|
file << int64_t{count_seconds(i.m_time)};
|
||||||
|
@ -194,7 +196,7 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
|
||||||
|
|
||||||
file << mapDeltas;
|
file << mapDeltas;
|
||||||
|
|
||||||
LogPrintf("Writing %d unbroadcast transactions to disk.\n", unbroadcast_txids.size());
|
LogInfo("Writing %d unbroadcast transactions to file.\n", unbroadcast_txids.size());
|
||||||
file << unbroadcast_txids;
|
file << unbroadcast_txids;
|
||||||
|
|
||||||
if (!skip_file_commit && !FileCommit(file.Get()))
|
if (!skip_file_commit && !FileCommit(file.Get()))
|
||||||
|
@ -205,11 +207,12 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
|
||||||
}
|
}
|
||||||
auto last = SteadyClock::now();
|
auto last = SteadyClock::now();
|
||||||
|
|
||||||
LogPrintf("Dumped mempool: %.3fs to copy, %.3fs to dump\n",
|
LogInfo("Dumped mempool: %.3fs to copy, %.3fs to dump, %d bytes dumped to file\n",
|
||||||
Ticks<SecondsDouble>(mid - start),
|
Ticks<SecondsDouble>(mid - start),
|
||||||
Ticks<SecondsDouble>(last - mid));
|
Ticks<SecondsDouble>(last - mid),
|
||||||
|
fs::file_size(dump_path));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("Failed to dump mempool: %s. Continuing anyway.\n", e.what());
|
LogInfo("Failed to dump mempool: %s. Continuing anyway.\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue