Minor fixes.

GitOrigin-RevId: 6d9a609ab9c773d1e4f3fe81f84947e142e15f35
This commit is contained in:
levlam 2020-08-04 22:48:23 +03:00
parent e75860b2ae
commit 5749ddf33d
4 changed files with 10 additions and 9 deletions

View File

@ -667,9 +667,9 @@ void Binlog::do_reindex() {
<< fd_size_ << ' ' << detail::file_size(path_) << ' ' << fd_events_ << ' ' << path_;
double ratio = static_cast<double>(start_size) / static_cast<double>(finish_size + 1);
LOG(ERROR) << "Regenerate index " << tag("name", path_) << tag("time", format::as_time(finish_time - start_time))
<< tag("before_size", format::as_size(start_size)) << tag("after_size", format::as_size(finish_size))
<< tag("ratio", ratio) << tag("before_events", start_events) << tag("after_events", finish_events);
LOG(INFO) << "Regenerate index " << tag("name", path_) << tag("time", format::as_time(finish_time - start_time))
<< tag("before_size", format::as_size(start_size)) << tag("after_size", format::as_size(finish_size))
<< tag("ratio", ratio) << tag("before_events", start_events) << tag("after_events", finish_events);
buffer_writer_ = ChainBufferWriter();
buffer_reader_ = buffer_writer_.extract_reader();

View File

@ -7,7 +7,6 @@
#include "td/utils/buffer.h"
#include "td/utils/port/thread_local.h"
#include "td/utils/ThreadSafeCounter.h"
#include <cstddef>
@ -26,7 +25,7 @@ TD_THREAD_LOCAL BufferAllocator::BufferRawTls *BufferAllocator::buffer_raw_tls;
std::atomic<size_t> BufferAllocator::buffer_mem;
static td::ThreadSafeCounter buffer_slice_size_;
static ThreadSafeCounter buffer_slice_size_;
int64 BufferAllocator::get_buffer_slice_size() {
return buffer_slice_size_.sum();

View File

@ -116,6 +116,8 @@ class BufferSlice {
: buffer_(std::move(buffer_ptr)), begin_(begin), end_(end) {
debug_track();
}
BufferSlice(const BufferSlice &other) = delete;
BufferSlice &operator=(const BufferSlice &other) = delete;
BufferSlice(BufferSlice &&other) : BufferSlice(std::move(other.buffer_), other.begin_, other.end_) {
debug_untrack(); // yes, debug_untrack
}

View File

@ -9,11 +9,11 @@
#include "td/db/binlog/BinlogHelper.h"
#include "td/db/TQueue.h"
#include "td/utils/Random.h"
#include "td/utils/buffer.h"
#include "td/utils/int_types.h"
#include "td/utils/misc.h"
#include "td/utils/port/path.h"
#include "td/utils/Random.h"
#include "td/utils/Slice.h"
#include "td/utils/Span.h"
#include "td/utils/Status.h"
@ -196,7 +196,7 @@ TEST(TQueue, random) {
}
TEST(TQueue, memory_leak) {
//return;
return;
auto tqueue = td::TQueue::create();
auto tqueue_binlog = td::make_unique<td::TQueueBinlog<td::Binlog>>();
std::string binlog_path = "test_tqueue.binlog";
@ -213,8 +213,8 @@ TEST(TQueue, memory_leak) {
while (true) {
auto id = tqueue->push(1, "a", now + 600000, 0, {}).move_as_ok();
ids.push_back(id);
if (ids.size() > rnd() % 100000) {
auto it = rnd() % ids.size();
if (ids.size() > static_cast<std::size_t>(rnd()) % 100000) {
auto it = static_cast<std::size_t>(rnd()) % ids.size();
std::swap(ids.back(), ids[it]);
tqueue->forget(1, ids.back());
ids.pop_back();