mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
c888903488
* Add ATTACH PARTITION FROM table for MergeTree. [#CLICKHOUSE-3546] * Implemented replicated case on non-leader replica. [#CLICKHOUSE-3546] * Disable merges in the dropping range. [#CLICKHOUSE-3546] * DROP PARTITION is atomic and simpler now. [#CLICKHOUSE-3546] * Implemented more SYSTEM queries. [#CLICKHOUSE-2931] [#CLICKHOUSE-3546] SYSTEM queries: RESTART REPLICAS SYNC REPLICA db.name STOP MERGES [db.name] START MERGES [db.name] STOP FETCHES [db.name] START FETCHES [db.name] STOP REPLICATED SENDS [db.name] START REPLICATED SENDS [db.name] STOP REPLICATION QUEUES [db.name] START REPLICATION QUEUES [db.name] * Fixed a bunch of bugs in REPLACE PARTITION. [#CLICKHOUSE-3546] * Add tests for REPLACE PARTITION and SYSTEM. [#CLICKHOUSE-3546] * Add system.part_log logging. [#CLICKHOUSE-3546] * Fixed long wait in SYNC REPLICA. [#CLICKHOUSE-3546] * Add requested changes. [#CLICKHOUSE-3546] Fixed clickhouse-client bad return code. * Add requested chenges. [#CLICKHOUSE-3546] * Add requested chenges. [#CLICKHOUSE-3546]
47 lines
964 B
C++
47 lines
964 B
C++
#pragma once
|
|
#include <memory>
|
|
#include <atomic>
|
|
#include <Core/Types.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ActionBlocker;
|
|
using StorageActionBlockType = size_t;
|
|
|
|
/// Blocks related action while a ActionLock instance exists
|
|
/// ActionBlocker could be destroyed before the lock, in this case ActionLock will safely do nothing in its destructor
|
|
class ActionLock
|
|
{
|
|
public:
|
|
|
|
ActionLock() = default;
|
|
|
|
explicit ActionLock(const ActionBlocker & blocker);
|
|
|
|
ActionLock(ActionLock && other);
|
|
ActionLock & operator=(ActionLock && other);
|
|
|
|
ActionLock(const ActionLock & other) = delete;
|
|
ActionLock & operator=(const ActionLock & other) = delete;
|
|
|
|
bool expired() const
|
|
{
|
|
return counter_ptr.expired();
|
|
}
|
|
|
|
~ActionLock()
|
|
{
|
|
if (auto counter = counter_ptr.lock())
|
|
--(*counter);
|
|
}
|
|
|
|
private:
|
|
using Counter = std::atomic<int>;
|
|
using CounterWeakPtr = std::weak_ptr<Counter>;
|
|
|
|
CounterWeakPtr counter_ptr;
|
|
};
|
|
|
|
}
|