mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
fix: prevents Dragonfly from blocking in epoll during snapshotting (#3911)
The problem - we used file write in non-direct mode when writing snapshots in epoll mode. As a result - lots of data was cached into OS memory. But then during the rename operation, when we rename "xxx.dfs.tmp" into "xxx.dfs", the OS flushes the file caches and the thread is stuck in OS system call rename for a long time. The fix - to use DIRECT mode and to avoid caching the data into OS caches at all. Fixes #3895 Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
ba57145c53
commit
4012ad1855
5 changed files with 10 additions and 5 deletions
2
helio
2
helio
|
@ -1 +1 @@
|
|||
Subproject commit fe723d3a88637ba96690f41e2160b2bb7f9a87ef
|
||||
Subproject commit 9dd56595b6b4cff71338b8c728eb12a8017c6b97
|
|
@ -344,6 +344,7 @@ void SaveStagesController::InitResources() {
|
|||
GenericError SaveStagesController::FinalizeFileMovement() {
|
||||
if (is_cloud_)
|
||||
return {};
|
||||
DVLOG(1) << "FinalizeFileMovement start";
|
||||
|
||||
// If the shared_err is set, the snapshot saving failed
|
||||
bool has_error = bool(shared_err_);
|
||||
|
@ -358,6 +359,7 @@ GenericError SaveStagesController::FinalizeFileMovement() {
|
|||
if (ec)
|
||||
break;
|
||||
}
|
||||
DVLOG(1) << "FinalizeFileMovement end";
|
||||
return GenericError(ec);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,15 @@ FileSnapshotStorage::FileSnapshotStorage(fb2::FiberQueueThreadPool* fq_threadpoo
|
|||
io::Result<std::pair<io::Sink*, uint8_t>, GenericError> FileSnapshotStorage::OpenWriteFile(
|
||||
const std::string& path) {
|
||||
if (fq_threadpool_) { // EPOLL
|
||||
auto res = OpenFiberWriteFile(path, fq_threadpool_);
|
||||
FiberWriteOptions opts;
|
||||
opts.direct = true;
|
||||
|
||||
auto res = OpenFiberWriteFile(path, fq_threadpool_, opts);
|
||||
if (!res) {
|
||||
return nonstd::make_unexpected(GenericError(res.error(), "Couldn't open file for writing"));
|
||||
}
|
||||
|
||||
return std::pair(*res, FileType::FILE);
|
||||
return std::pair(*res, FileType::FILE | FileType::DIRECT);
|
||||
} else {
|
||||
#ifdef __linux__
|
||||
auto res = fb2::OpenLinux(path, kRdbWriteFlags, 0666);
|
||||
|
|
|
@ -62,7 +62,6 @@ extern "C" {
|
|||
#include "strings/human_readable.h"
|
||||
#include "util/accept_server.h"
|
||||
#include "util/aws/aws.h"
|
||||
#include "util/fibers/fiber_file.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1654,6 +1653,7 @@ GenericError ServerFamily::WaitUntilSaveFinished(Transaction* trans, bool ignore
|
|||
save_controller_->WaitAllSnapshots();
|
||||
detail::SaveInfo save_info;
|
||||
|
||||
VLOG(1) << "Before WaitUntilSaveFinished::Finalize";
|
||||
{
|
||||
util::fb2::LockGuard lk(save_mu_);
|
||||
save_info = save_controller_->Finalize();
|
||||
|
|
|
@ -4,7 +4,7 @@ pytoml==0.1.21
|
|||
PyYAML==6.0
|
||||
railroad==0.5.0
|
||||
redis==4.4.4
|
||||
requests==2.28.1
|
||||
requests>=2.32.0
|
||||
aiocsv==1.2.3
|
||||
aiofiles==22.1.0
|
||||
numpy==1.24.1
|
||||
|
|
Loading…
Reference in a new issue