Print log in case of exception in PollingQueue

This commit is contained in:
Nikolai Kochetov 2021-01-12 16:12:14 +03:00
parent 24503267d5
commit 3b95ee8e60
2 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include <IO/WriteBufferFromString.h>
#include <IO/Operators.h>
#include <common/getThreadId.h>
namespace DB
{
@ -60,7 +61,7 @@ void PollingQueue::addTask(size_t thread_number, void * data, int fd)
if (-1 == epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &socket_event))
throwFromErrno("Cannot add socket descriptor to epoll", ErrorCodes::CANNOT_OPEN_FILE);
log.emplace_back(Log{.add = true, .key = key, .ptr = data});
log.emplace_back(Log{.add = true, .key = key, .ptr = data, .thread_id = getThreadId()});
}
static std::string dumpTasks(const std::unordered_map<std::uintptr_t, PollingQueue::TaskData> & tasks)
@ -86,7 +87,7 @@ static std::string dumpLog(const std::vector<PollingQueue::Log> & log)
{
res << (item.add ? '+' : '-') << ' ' << item.key << ' ';
writePointerHex(item.ptr, res);
res << '\n';
res << " [" << item.thread_id << "]\n";
}
return res.str();
@ -130,7 +131,7 @@ PollingQueue::TaskData PollingQueue::wait(std::unique_lock<std::mutex> & lock)
if (-1 == epoll_ctl(epoll_fd, EPOLL_CTL_DEL, res.fd, &event))
throwFromErrno("Cannot remove socket descriptor to epoll", ErrorCodes::CANNOT_OPEN_FILE);
log.emplace_back(Log{.add = false, .key = key, .ptr = ptr});
log.emplace_back(Log{.add = false, .key = key, .ptr = ptr, .thread_id = getThreadId()});
return res;
}

View File

@ -30,6 +30,7 @@ public:
bool add;
std::uintptr_t key;
const void * ptr;
uint64_t thread_id;
};
private: