aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Storages/MergeTree/MergeTreeDataPartState.h
blob: 5c4779f016e40a3707d83ad5918c1cec6b72511a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

namespace DB
{

/** Part state is a stage of its lifetime. States are ordered and state of a part could be increased only.
  * Part state should be modified under data_parts mutex.
  *
  * Possible state transitions:
  * Temporary -> PreActive:       we are trying to add a fetched, inserted or merged part to active set
  * PreActive -> Outdated:        we could not add a part to active set and are doing a rollback (for example it is duplicated part)
  * PreActive -> Active:          we successfully added a part to active dataset
  * PreActive -> Outdated:        a part was replaced by a covering part or DROP PARTITION
  * Outdated -> Deleting:         a cleaner selected this part for deletion
  * Deleting -> Outdated:         if an ZooKeeper error occurred during the deletion, we will retry deletion
  * Active -> DeleteOnDestroy:    if part was moved to another disk
  */
enum class MergeTreeDataPartState
{
    Temporary,       /// the part is generating now, it is not in data_parts list
    PreActive,       /// the part is in data_parts, but not used for SELECTs
    Active,          /// active data part, used by current and upcoming SELECTs
    Outdated,        /// not active data part, but could be used by only current SELECTs, could be deleted after SELECTs finishes
    Deleting,        /// not active data part with identity refcounter, it is deleting right now by a cleaner
    DeleteOnDestroy, /// part was moved to another disk and should be deleted in own destructor
};

}