mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #39867 from ClickHouse/keeper-block-memory-tracker-commit
Block memory tracker in Keeper during commit
This commit is contained in:
commit
adc880f362
2
contrib/NuRaft
vendored
2
contrib/NuRaft
vendored
@ -1 +1 @@
|
||||
Subproject commit 2ef198694e10c86175ee6ead389346d199060437
|
||||
Subproject commit 1b0af760b3506b8e35b50cb7df098cbad5064ff2
|
@ -20,6 +20,7 @@
|
||||
#include <libnuraft/raft_server.hxx>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include <Poco/Util/Application.h>
|
||||
#include <Common/LockMemoryExceptionInThread.h>
|
||||
#include <Common/ZooKeeper/ZooKeeperIO.h>
|
||||
#include <Common/Stopwatch.h>
|
||||
|
||||
@ -174,6 +175,17 @@ struct KeeperServer::KeeperRaftServer : public nuraft::raft_server
|
||||
reconfigure(new_config);
|
||||
}
|
||||
|
||||
void commit_in_bg() override
|
||||
{
|
||||
// For NuRaft, if any commit fails (uncaught exception) the whole server aborts as a safety
|
||||
// This includes failed allocation which can produce an unknown state for the storage,
|
||||
// making it impossible to handle correctly.
|
||||
// We block the memory tracker for all the commit operations (including KeeperStateMachine::commit)
|
||||
// assuming that the allocations are small
|
||||
LockMemoryExceptionInThread blocker{VariableContext::Global};
|
||||
nuraft::raft_server::commit_in_bg();
|
||||
}
|
||||
|
||||
using nuraft::raft_server::raft_server;
|
||||
|
||||
// peers are initially marked as responding because at least one cycle
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <Common/hex.h>
|
||||
#include <Common/logger_useful.h>
|
||||
#include <Common/setThreadName.h>
|
||||
#include <Common/MemoryTrackerBlockerInThread.h>
|
||||
#include <Common/LockMemoryExceptionInThread.h>
|
||||
#include <Coordination/pathUtils.h>
|
||||
#include <Coordination/KeeperConstants.h>
|
||||
#include <sstream>
|
||||
@ -2127,7 +2127,7 @@ void KeeperStorage::rollbackRequest(int64_t rollback_zxid, bool allow_missing)
|
||||
|
||||
// if an exception occurs during rollback, the best option is to terminate because we can end up in an inconsistent state
|
||||
// we block memory tracking so we can avoid terminating if we're rollbacking because of memory limit
|
||||
MemoryTrackerBlockerInThread temporarily_ignore_any_memory_limits;
|
||||
LockMemoryExceptionInThread blocker{VariableContext::Global};
|
||||
try
|
||||
{
|
||||
uncommitted_transactions.pop_back();
|
||||
|
Loading…
Reference in New Issue
Block a user