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
|
@ -915,7 +915,18 @@ void ArchiveManager::start_up() {
|
||||||
void ArchiveManager::alarm() {
|
void ArchiveManager::alarm() {
|
||||||
alarm_timestamp() = td::Timestamp::in(60.0);
|
alarm_timestamp() = td::Timestamp::in(60.0);
|
||||||
auto stats = td::RocksDb::statistics_to_string(statistics_);
|
auto stats = td::RocksDb::statistics_to_string(statistics_);
|
||||||
td::atomic_write_file(db_root_ + "/db_stats.txt", stats);
|
auto to_file_r = td::FileFd::open(db_root_ + "/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_);
|
td::RocksDb::reset_statistics(statistics_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
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() {
|
void CellDbIn::alarm() {
|
||||||
if (statistics_flush_at_ && statistics_flush_at_.is_in_past()) {
|
if (statistics_flush_at_ && statistics_flush_at_.is_in_past()) {
|
||||||
statistics_flush_at_ = td::Timestamp::in(60.0);
|
statistics_flush_at_ = td::Timestamp::in(60.0);
|
||||||
auto stats = td::RocksDb::statistics_to_string(statistics_);
|
flush_db_stats();
|
||||||
td::atomic_write_file(path_ + "/db_stats.txt", stats);
|
|
||||||
td::RocksDb::reset_statistics(statistics_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (migrate_after_ && migrate_after_.is_in_past()) {
|
if (migrate_after_ && migrate_after_.is_in_past()) {
|
||||||
|
|
|
@ -60,6 +60,8 @@ class CellDbIn : public CellDbBase {
|
||||||
|
|
||||||
void migrate_cell(td::Bits256 hash);
|
void migrate_cell(td::Bits256 hash);
|
||||||
|
|
||||||
|
void flush_db_stats();
|
||||||
|
|
||||||
CellDbIn(td::actor::ActorId<RootDb> root_db, td::actor::ActorId<CellDb> parent, std::string path,
|
CellDbIn(td::actor::ActorId<RootDb> root_db, td::actor::ActorId<CellDb> parent, std::string path,
|
||||||
td::Ref<ValidatorManagerOptions> opts);
|
td::Ref<ValidatorManagerOptions> opts);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue