libch 0.2.1

ClickHouse's insert and merge as short-lived operations on BigHouse `inodedb` disks, so one pool of workers serves many tenants.
Documentation
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Request {
    #[prost(message, optional, tag = "1")]
    pub tenant: ::core::option::Option<Tenant>,
    /// Server settings as the XML a stock writer boots with, such as `<merge_tree>` and `<compression>`, so an
    /// operation writes parts as that writer would.
    #[prost(string, tag = "2")]
    pub settings_xml: ::prost::alloc::string::String,
    #[prost(oneof = "request::Operation", tags = "10, 11, 12, 13, 14, 15")]
    pub operation: ::core::option::Option<request::Operation>,
}
/// Nested message and enum types in `Request`.
pub mod request {
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
    pub enum Operation {
        #[prost(message, tag = "10")]
        Describe(super::Describe),
        #[prost(message, tag = "11")]
        Insert(super::Insert),
        #[prost(message, tag = "12")]
        Plan(super::Plan),
        #[prost(message, tag = "13")]
        Merge(super::Merge),
        #[prost(message, tag = "14")]
        Housekeep(super::Housekeep),
        #[prost(message, tag = "15")]
        Share(super::Share),
    }
}
/// One tenant's disk, and the credentials that reach it.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Tenant {
    /// The InodeDB store's address, as `127.0.0.1:7170`.
    #[prost(string, tag = "1")]
    pub inodedb_endpoint: ::prost::alloc::string::String,
    /// A key with the `write` grant, rooted at the tenant's directory.
    #[prost(string, tag = "2")]
    pub inodedb_key: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "3")]
    pub s3: ::core::option::Option<S3>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct S3 {
    /// The service's URL, as `<http://127.0.0.1:11211`.>
    #[prost(string, tag = "1")]
    pub endpoint: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub bucket: ::prost::alloc::string::String,
    /// The disk's key prefix inside the bucket, without a leading or trailing slash.
    #[prost(string, tag = "3")]
    pub prefix: ::prost::alloc::string::String,
    #[prost(string, tag = "4")]
    pub region: ::prost::alloc::string::String,
    #[prost(string, tag = "5")]
    pub access_key: ::prost::alloc::string::String,
    #[prost(string, tag = "6")]
    pub secret_key: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TableName {
    #[prost(string, tag = "1")]
    pub database: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub table: ::prost::alloc::string::String,
}
/// Reports the tenant's catalog as the engine sees it. Writes nothing.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Describe {
    /// Also list each table's parts, with each name as the engine parses it.
    #[prost(bool, tag = "1")]
    pub parts: bool,
}
/// Inserts one batch into a table and into every view that reads from it. The batch follows the request as
/// data frames.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Insert {
    #[prost(message, optional, tag = "1")]
    pub table: ::core::option::Option<TableName>,
    /// A ClickHouse input format, as `JSONEachRow`.
    #[prost(string, tag = "2")]
    pub format: ::prost::alloc::string::String,
    /// Names the batch. A second insert of the batch under the same token writes nothing.
    #[prost(string, tag = "3")]
    pub token: ::prost::alloc::string::String,
    /// Accepts a table, or a view's target, that keeps no deduplication tokens, where a second insert of the
    /// batch writes it again. Unset, the worker refuses such an insert.
    #[prost(bool, tag = "4")]
    pub at_least_once: bool,
}
/// Proposes merges for a table, and runs none.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Plan {
    #[prost(message, optional, tag = "1")]
    pub table: ::core::option::Option<TableName>,
    /// The most merges to propose.
    #[prost(uint32, tag = "2")]
    pub max_merges: u32,
}
/// Merges source parts of one partition into one part.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Merge {
    #[prost(message, optional, tag = "1")]
    pub table: ::core::option::Option<TableName>,
    #[prost(string, tag = "2")]
    pub partition_id: ::prost::alloc::string::String,
    /// The source parts' names, in block order.
    #[prost(string, repeated, tag = "3")]
    pub sources: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Removes what operations left behind in a table: covered parts past the grace period with their claims, tokens
/// past their age, claims of writers that are gone, and temporary directories past theirs.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Housekeep {
    #[prost(message, optional, tag = "1")]
    pub table: ::core::option::Option<TableName>,
}
/// Hands the tenant's disk to shared writers: replaces an exclusive writer's `owner` with a shared one, which
/// fences that writer. The caller sends it once the exclusive writer is done. Every other operation leaves an
/// exclusive owner in place and ends `FENCED`. On a disk that is shared already it writes nothing.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Share {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Response {
    #[prost(enumeration = "Status", tag = "1")]
    pub status: i32,
    /// Why the operation was refused, or how it failed.
    #[prost(string, tag = "2")]
    pub message: ::prost::alloc::string::String,
    /// The ClickHouse exception code, when the operation failed with an exception.
    #[prost(int32, tag = "3")]
    pub exception_code: i32,
    /// What the worker spent, whatever the status.
    #[prost(message, optional, tag = "4")]
    pub usage: ::core::option::Option<Usage>,
    #[prost(oneof = "response::Result", tags = "10, 11, 12, 13, 14, 15")]
    pub result: ::core::option::Option<response::Result>,
}
/// Nested message and enum types in `Response`.
pub mod response {
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Result {
        #[prost(message, tag = "10")]
        Described(super::Described),
        #[prost(message, tag = "11")]
        Inserted(super::Inserted),
        #[prost(message, tag = "12")]
        Planned(super::Planned),
        #[prost(message, tag = "13")]
        Merged(super::Merged),
        #[prost(message, tag = "14")]
        Housekept(super::Housekept),
        #[prost(message, tag = "15")]
        Shared(super::Shared),
    }
}
/// What a worker spent from its start to its response, as the worker itself counted it.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Usage {
    /// Calls to the tenant's InodeDB store, by kind.
    #[prost(uint32, tag = "1")]
    pub inodedb_commits: u32,
    #[prost(uint32, tag = "2")]
    pub inodedb_stats: u32,
    #[prost(uint32, tag = "3")]
    pub inodedb_reads: u32,
    #[prost(uint32, tag = "4")]
    pub inodedb_lists: u32,
    /// Requests to S3 that read, and requests that write.
    #[prost(uint32, tag = "5")]
    pub s3_reads: u32,
    #[prost(uint32, tag = "6")]
    pub s3_writes: u32,
    /// The worker's CPU time, user and system, in microseconds.
    #[prost(uint64, tag = "7")]
    pub cpu_microseconds: u64,
    /// The worker's anonymous memory, in bytes, and its threads, as it answered.
    #[prost(uint64, tag = "8")]
    pub anonymous_memory_bytes: u64,
    #[prost(uint32, tag = "9")]
    pub threads: u32,
    /// Time in calls to the store, retries included, in microseconds. Calls on several threads each count, so the
    /// figure can pass the operation's own time.
    #[prost(uint64, tag = "10")]
    pub inodedb_microseconds: u64,
    /// Calls to the store tried again after it was unavailable or slow to answer.
    #[prost(uint32, tag = "11")]
    pub inodedb_retries: u32,
    /// Time in requests to S3 that read, and in requests that write, in microseconds, counted as the store's time is.
    #[prost(uint64, tag = "12")]
    pub s3_read_microseconds: u64,
    #[prost(uint64, tag = "13")]
    pub s3_write_microseconds: u64,
    /// Requests S3 answered with 429 or 503, asking the worker to slow down.
    #[prost(uint32, tag = "14")]
    pub s3_throttled: u32,
    /// Bytes read from S3, and bytes written to it.
    #[prost(uint64, tag = "15")]
    pub s3_bytes_read: u64,
    #[prost(uint64, tag = "16")]
    pub s3_bytes_written: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Described {
    #[prost(message, repeated, tag = "1")]
    pub tables: ::prost::alloc::vec::Vec<Table>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Table {
    #[prost(message, optional, tag = "1")]
    pub name: ::core::option::Option<TableName>,
    #[prost(string, tag = "2")]
    pub uuid: ::prost::alloc::string::String,
    #[prost(enumeration = "table::Kind", tag = "3")]
    pub kind: i32,
    /// The storage engine, as `MergeTree`. Empty for a view.
    #[prost(string, tag = "4")]
    pub engine: ::prost::alloc::string::String,
    /// The materialized views that read from this table, each with the table it writes to.
    #[prost(message, repeated, tag = "5")]
    pub views: ::prost::alloc::vec::Vec<View>,
    /// The table's parts, when the request asked for them.
    #[prost(message, repeated, tag = "6")]
    pub parts: ::prost::alloc::vec::Vec<Part>,
}
/// Nested message and enum types in `Table`.
pub mod table {
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Kind {
        Unspecified = 0,
        Table = 1,
        MaterializedView = 2,
        View = 3,
        Dictionary = 4,
    }
    impl Kind {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unspecified => "KIND_UNSPECIFIED",
                Self::Table => "TABLE",
                Self::MaterializedView => "MATERIALIZED_VIEW",
                Self::View => "VIEW",
                Self::Dictionary => "DICTIONARY",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "KIND_UNSPECIFIED" => Some(Self::Unspecified),
                "TABLE" => Some(Self::Table),
                "MATERIALIZED_VIEW" => Some(Self::MaterializedView),
                "VIEW" => Some(Self::View),
                "DICTIONARY" => Some(Self::Dictionary),
                _ => None,
            }
        }
    }
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct View {
    #[prost(message, optional, tag = "1")]
    pub view: ::core::option::Option<TableName>,
    #[prost(message, optional, tag = "2")]
    pub target: ::core::option::Option<TableName>,
}
/// A part's directory name, and what the engine reads from it.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Part {
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub partition_id: ::prost::alloc::string::String,
    #[prost(int64, tag = "3")]
    pub min_block: i64,
    #[prost(int64, tag = "4")]
    pub max_block: i64,
    #[prost(uint32, tag = "5")]
    pub level: u32,
    #[prost(int64, tag = "6")]
    pub mutation: i64,
    /// No other part of the table contains this one.
    #[prost(bool, tag = "7")]
    pub active: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Inserted {
    /// The parts written, for the table and for each view's target, in the order they committed.
    #[prost(message, repeated, tag = "1")]
    pub parts: ::prost::alloc::vec::Vec<CommittedPart>,
    /// How many commits found their block number taken by another writer's part and went again with the next.
    #[prost(uint32, tag = "2")]
    pub counter_conflicts: u32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CommittedPart {
    #[prost(message, optional, tag = "1")]
    pub table: ::core::option::Option<TableName>,
    #[prost(string, tag = "2")]
    pub part: ::prost::alloc::string::String,
    #[prost(uint64, tag = "3")]
    pub rows: u64,
    /// The part's size on the disk.
    #[prost(uint64, tag = "4")]
    pub bytes: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Planned {
    #[prost(message, repeated, tag = "1")]
    pub candidates: ::prost::alloc::vec::Vec<MergeCandidate>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MergeCandidate {
    #[prost(string, tag = "1")]
    pub partition_id: ::prost::alloc::string::String,
    /// The source parts' names, in block order.
    #[prost(string, repeated, tag = "2")]
    pub sources: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// The sources' rows and their bytes on disk, which size the worker that runs the merge.
    #[prost(uint64, tag = "3")]
    pub rows: u64,
    #[prost(uint64, tag = "4")]
    pub bytes: u64,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Merged {
    /// The name of the part that now holds the sources' rows.
    #[prost(string, tag = "1")]
    pub part: ::prost::alloc::string::String,
    /// The merged part's rows, and its bytes on disk.
    #[prost(uint64, tag = "2")]
    pub rows: u64,
    #[prost(uint64, tag = "3")]
    pub bytes: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Housekept {
    /// The covered parts removed.
    #[prost(string, repeated, tag = "1")]
    pub removed: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// The covered parts still on the disk, each with the reason it stays.
    #[prost(message, repeated, tag = "2")]
    pub remaining: ::prost::alloc::vec::Vec<Remaining>,
    /// How many temporary directories went: what inserts and merges whose workers died left in the table.
    #[prost(uint32, tag = "3")]
    pub temporary_directories_removed: u32,
    /// How many blobs the worker deleted from S3: those of files the tenant's disk had freed, in this operation or
    /// before it, that no older reader's lease still holds.
    #[prost(uint64, tag = "4")]
    pub blobs_removed: u64,
    /// Whether the worker stopped removing blobs with freed files still coming: another housekeeping takes up the
    /// rest. Files freed while an older reader holds its lease are out of the worker's reach and do not count.
    #[prost(bool, tag = "5")]
    pub blobs_remain: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Remaining {
    #[prost(string, tag = "1")]
    pub part: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub reason: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Shared {
    /// The version of the disk's `owner`, which every shared writer's commit requires. It changes when `Share`
    /// replaces an exclusive owner and stays when the disk was shared already.
    #[prost(uint64, tag = "1")]
    pub owner_version: u64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Status {
    Unspecified = 0,
    /// The operation did its work, and `result` holds what it produced.
    Ok = 1,
    /// An insert found every block of its batch already committed under the same token, and wrote nothing.
    Duplicate = 2,
    /// A table's definition changed since the worker loaded it. Nothing was committed.
    SchemaChanged = 3,
    /// An exclusive writer owns the disk or took it during the operation, or the worker's key was revoked.
    /// Nothing was committed. After an exclusive writer, `Share` lets operations run again.
    Fenced = 4,
    /// A merge lost a claim on a source part, or a source part is gone. Nothing was committed.
    ClaimLost = 5,
    /// The worker declined the operation, and `message` says why. Nothing was committed.
    Refused = 6,
    /// The operation failed, and `message` says how. What it committed, if anything, is unknown.
    Failed = 7,
}
impl Status {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "STATUS_UNSPECIFIED",
            Self::Ok => "OK",
            Self::Duplicate => "DUPLICATE",
            Self::SchemaChanged => "SCHEMA_CHANGED",
            Self::Fenced => "FENCED",
            Self::ClaimLost => "CLAIM_LOST",
            Self::Refused => "REFUSED",
            Self::Failed => "FAILED",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "STATUS_UNSPECIFIED" => Some(Self::Unspecified),
            "OK" => Some(Self::Ok),
            "DUPLICATE" => Some(Self::Duplicate),
            "SCHEMA_CHANGED" => Some(Self::SchemaChanged),
            "FENCED" => Some(Self::Fenced),
            "CLAIM_LOST" => Some(Self::ClaimLost),
            "REFUSED" => Some(Self::Refused),
            "FAILED" => Some(Self::Failed),
            _ => None,
        }
    }
}