mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Mode 644 for db_stats.txt (#938)
This commit is contained in:
parent
7a6bfa7e7a
commit
0feaaf591c
3 changed files with 32 additions and 4 deletions
|
@ -161,12 +161,27 @@ void CellDbIn::get_cell_db_reader(td::Promise<std::shared_ptr<vm::CellDbReader>>
|
|||
promise.set_result(boc_->get_cell_db_reader());
|
||||
}
|
||||
|
||||
void CellDbIn::flush_db_stats() {
|
||||
auto stats = td::RocksDb::statistics_to_string(statistics_);
|
||||
auto to_file_r = td::FileFd::open(path_ + "/db_stats.txt", td::FileFd::Truncate | td::FileFd::Create | td::FileFd::Write, 0644);
|
||||
if (to_file_r.is_error()) {
|
||||
LOG(ERROR) << "Failed to open db_stats.txt: " << to_file_r.move_as_error();
|
||||
return;
|
||||
}
|
||||
auto to_file = to_file_r.move_as_ok();
|
||||
auto res = to_file.write(stats);
|
||||
to_file.close();
|
||||
if (res.is_error()) {
|
||||
LOG(ERROR) << "Failed to write to db_stats.txt: " << res.move_as_error();
|
||||
return;
|
||||
}
|
||||
td::RocksDb::reset_statistics(statistics_);
|
||||
}
|
||||
|
||||
void CellDbIn::alarm() {
|
||||
if (statistics_flush_at_ && statistics_flush_at_.is_in_past()) {
|
||||
statistics_flush_at_ = td::Timestamp::in(60.0);
|
||||
auto stats = td::RocksDb::statistics_to_string(statistics_);
|
||||
td::atomic_write_file(path_ + "/db_stats.txt", stats);
|
||||
td::RocksDb::reset_statistics(statistics_);
|
||||
flush_db_stats();
|
||||
}
|
||||
|
||||
if (migrate_after_ && migrate_after_.is_in_past()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue