mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Limit file descriptors num by adding archive slice lru (#892)
* --max-archive-fd option limits open files in archive manager * Don't close the latest archives + bugfix * Delete temp packages early --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
e723213d5c
commit
12c1b1a2e6
12 changed files with 316 additions and 88 deletions
|
@ -28,7 +28,7 @@ class RootDb;
|
|||
|
||||
class ArchiveManager : public td::actor::Actor {
|
||||
public:
|
||||
ArchiveManager(td::actor::ActorId<RootDb> root, std::string db_root);
|
||||
ArchiveManager(td::actor::ActorId<RootDb> root, std::string db_root, td::Ref<ValidatorManagerOptions> opts);
|
||||
|
||||
void add_handle(BlockHandle handle, td::Promise<td::Unit> promise);
|
||||
void update_handle(BlockHandle handle, td::Promise<td::Unit> promise);
|
||||
|
@ -58,7 +58,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void truncate(BlockSeqno masterchain_seqno, ConstBlockHandle handle, td::Promise<td::Unit> promise);
|
||||
//void truncate_continue(BlockSeqno masterchain_seqno, td::Promise<td::Unit> promise);
|
||||
|
||||
void run_gc(UnixTime ts, UnixTime archive_ttl);
|
||||
void run_gc(UnixTime mc_ts, UnixTime gc_ts, UnixTime archive_ttl);
|
||||
|
||||
/* from LTDB */
|
||||
void get_block_by_unix_time(AccountIdPrefixFull account_id, UnixTime ts, td::Promise<ConstBlockHandle> promise);
|
||||
|
@ -123,6 +123,9 @@ class ArchiveManager : public td::actor::Actor {
|
|||
size_t size() const {
|
||||
return files_.size();
|
||||
}
|
||||
bool empty() const {
|
||||
return files_.empty();
|
||||
}
|
||||
std::map<PackageId, FileDescription>::const_iterator lower_bound(const PackageId &x) const {
|
||||
return files_.lower_bound(x);
|
||||
}
|
||||
|
@ -164,6 +167,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void shard_index_del(const FileDescription &desc);
|
||||
};
|
||||
FileMap files_, key_files_, temp_files_;
|
||||
td::actor::ActorOwn<ArchiveLru> archive_lru_;
|
||||
BlockSeqno finalized_up_to_{0};
|
||||
bool async_mode_ = false;
|
||||
bool huge_transaction_started_ = false;
|
||||
|
@ -206,6 +210,7 @@ class ArchiveManager : public td::actor::Actor {
|
|||
void got_gc_masterchain_handle(ConstBlockHandle handle, FileHash hash);
|
||||
|
||||
std::string db_root_;
|
||||
td::Ref<ValidatorManagerOptions> opts_;
|
||||
|
||||
std::shared_ptr<td::KeyValue> index_;
|
||||
|
||||
|
@ -215,6 +220,10 @@ class ArchiveManager : public td::actor::Actor {
|
|||
PackageId get_temp_package_id() const;
|
||||
PackageId get_key_package_id(BlockSeqno seqno) const;
|
||||
PackageId get_temp_package_id_by_unixtime(UnixTime ts) const;
|
||||
|
||||
void update_permanent_slices();
|
||||
|
||||
static const td::uint32 TEMP_PACKAGES_TTL = 86400 * 7;
|
||||
};
|
||||
|
||||
} // namespace validator
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue