diff options
| author | levlam <levlam@telegram.org> | 2023-03-20 00:38:20 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2023-03-20 00:38:20 +0300 |
| commit | da2424bc64cd7bdf4c80c4017f01de2bce7cf818 (patch) | |
| tree | d6d8c28a6ec08257d4bfd41650adc1e75d2506ef /tddb/td/db/binlog/Binlog.cpp | |
| parent | f3225b7106dbd7a84397adb6c27ac74cb43f8ee5 (diff) | |
Flush binlog buffer from time to time.
Diffstat (limited to 'tddb/td/db/binlog/Binlog.cpp')
| -rw-r--r-- | tddb/td/db/binlog/Binlog.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 10fd947e5..624685d16 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -430,6 +430,17 @@ void Binlog::flush() { } need_flush_since_ = 0; LOG_IF(FATAL, fd_.need_flush_write()) << "Failed to flush binlog"; + + if (state_ == State::Run && Time::now() > next_buffer_flush_time_) { + LOG(DEBUG) << "Flush write buffer"; + buffer_writer_ = ChainBufferWriter(); + buffer_reader_ = buffer_writer_.extract_reader(); + if (encryption_type_ == EncryptionType::AesCtr) { + aes_ctr_state_ = aes_xcode_byte_flow_.move_aes_ctr_state(); + } + update_write_encryption(); + next_buffer_flush_time_ = Time::now() + 1.0; + } } void Binlog::lazy_flush() { |
