Skip to content

Commit f046d57

Browse files
committed
Merge branch 'master' into try-disabling-jemalloc-background-threads
2 parents 5fd3605 + 3a4d05f commit f046d57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+501
-236
lines changed

docker/test/stateless/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function run_tests()
253253
try_run_with_retry 10 clickhouse-client -q "insert into system.zookeeper (name, path, value) values ('auxiliary_zookeeper2', '/test/chroot/', '')"
254254

255255
set +e
256-
clickhouse-test --testname --shard --zookeeper --check-zookeeper-session --hung-check --print-time \
256+
timeout -s TERM --preserve-status 120m clickhouse-test --testname --shard --zookeeper --check-zookeeper-session --hung-check --print-time \
257257
--no-drop-if-fail --test-runs "$NUM_TRIES" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \
258258
| ts '%Y-%m-%d %H:%M:%S' \
259259
| tee -a test_output/test_result.txt

docs/en/sql-reference/statements/create/table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ SELECT * FROM test;
152152

153153
`MATERIALIZED expr`
154154

155-
Materialized expression. Values of such columns are always calculated, they cannot be specified in INSERT queries.
155+
Materialized expression. Values of such columns are automatically calculated according to the specified materialized expression when rows are inserted. Values cannot be explicitly specified during `INSERT`s.
156156

157157
Also, default value columns of this type are not included in the result of `SELECT *`. This is to preserve the invariant that the result of a `SELECT *` can always be inserted back into the table using `INSERT`. This behavior can be disabled with setting `asterisk_include_materialized_columns`.
158158

docs/en/sql-reference/table-functions/s3.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ FROM s3(
269269

270270
## Virtual Columns {#virtual-columns}
271271

272-
- `_path` — Path to the file. Type: `LowCardinalty(String)`.
273-
- `_file` — Name of the file. Type: `LowCardinalty(String)`.
274-
- `_size` — Size of the file in bytes. Type: `Nullable(UInt64)`. If the file size is unknown, the value is `NULL`.
272+
- `_path` — Path to the file. Type: `LowCardinalty(String)`. In case of archive, shows path in a format: "{path_to_archive}::{path_to_file_inside_archive}"
273+
- `_file` — Name of the file. Type: `LowCardinalty(String)`. In case of archive shows name of the file inside the archive.
274+
- `_size` — Size of the file in bytes. Type: `Nullable(UInt64)`. If the file size is unknown, the value is `NULL`. In case of archive shows uncompressed file size of the file inside the archive.
275275
- `_time` — Last modified time of the file. Type: `Nullable(DateTime)`. If the time is unknown, the value is `NULL`.
276276

277277
## Storage Settings {#storage-settings}

docs/en/sql-reference/window-functions/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ These functions can be used only as a window function.
8080
- `nth_value(x, offset)` - Return the first non-NULL value evaluated against the nth row (offset) in its ordered frame.
8181
- `rank()` - Rank the current row within its partition with gaps.
8282
- `dense_rank()` - Rank the current row within its partition without gaps.
83-
- `lagInFrame(x)` - Return a value evaluated at the row that is at a specified physical offset row before the current row within the ordered frame.
84-
- `leadInFrame(x)` - Return a value evaluated at the row that is offset rows after the current row within the ordered frame.
83+
- `lagInFrame(x[, offset[, default]])` - Return a value evaluated at the row that is at a specified physical offset row before the current row within the ordered frame. The offset parameter, if not specified, defaults to 1, meaning it will fetch the value from the next row. If the calculated row exceeds the boundaries of the window frame, the specified default value is returned.
84+
- `leadInFrame(x[, offset[, default]])` - Return a value evaluated at the row that is offset rows after the current row within the ordered frame. If offset is not provided, it defaults to 1. If the offset leads to a position outside the window frame, the specified default value is used.
8585

8686
## Examples
8787

programs/odbc-bridge/ODBCSource.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <IO/ReadBufferFromString.h>
44
#include <DataTypes/DataTypeNullable.h>
55
#include <DataTypes/DataTypeDateTime64.h>
6+
#include <Columns/ColumnNullable.h>
67
#include <Common/assert_cast.h>
78
#include <IO/ReadHelpers.h>
89

@@ -47,9 +48,17 @@ Chunk ODBCSource::generate()
4748
for (int idx = 0; idx < result.columns(); ++idx)
4849
{
4950
const auto & sample = description.sample_block.getByPosition(idx);
50-
5151
if (!result.is_null(idx))
52-
insertValue(*columns[idx], removeNullable(sample.type), description.types[idx].first, result, idx);
52+
{
53+
if (columns[idx]->isNullable())
54+
{
55+
ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[idx]);
56+
insertValue(column_nullable.getNestedColumn(), removeNullable(sample.type), description.types[idx].first, result, idx);
57+
column_nullable.getNullMapData().emplace_back(0);
58+
}
59+
else
60+
insertValue(*columns[idx], removeNullable(sample.type), description.types[idx].first, result, idx);
61+
}
5362
else
5463
insertDefaultValue(*columns[idx], *sample.column);
5564
}

src/Client/ClientBase.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,11 +1206,8 @@ void ClientBase::receiveResult(ASTPtr parsed_query, Int32 signals_before_stop, b
12061206
if (local_format_error)
12071207
std::rethrow_exception(local_format_error);
12081208

1209-
if (cancelled && is_interactive)
1210-
{
1209+
if (cancelled && is_interactive && !cancelled_printed.exchange(true))
12111210
output_stream << "Query was cancelled." << std::endl;
1212-
cancelled_printed = true;
1213-
}
12141211
}
12151212

12161213

@@ -1326,7 +1323,7 @@ void ClientBase::onEndOfStream()
13261323

13271324
if (is_interactive)
13281325
{
1329-
if (cancelled && !cancelled_printed)
1326+
if (cancelled && !cancelled_printed.exchange(true))
13301327
output_stream << "Query was cancelled." << std::endl;
13311328
else if (!written_first_block)
13321329
output_stream << "Ok." << std::endl;

src/Client/ClientBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ class ClientBase : public Poco::Util::Application, public IHints<2>
338338
bool allow_repeated_settings = false;
339339
bool allow_merge_tree_settings = false;
340340

341-
bool cancelled = false;
342-
bool cancelled_printed = false;
341+
std::atomic_bool cancelled = false;
342+
std::atomic_bool cancelled_printed = false;
343343

344344
/// Unpacked descriptors and streams for the ease of use.
345345
int in_fd = STDIN_FILENO;

src/Common/ConcurrentBoundedQueue.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#pragma once
22

33
#include <deque>
4-
#include <type_traits>
5-
#include <atomic>
64
#include <condition_variable>
75
#include <mutex>
86
#include <optional>
@@ -200,22 +198,18 @@ class ConcurrentBoundedQueue
200198
*/
201199
bool finish()
202200
{
203-
bool was_finished_before = false;
204-
205201
{
206202
std::lock_guard lock(queue_mutex);
207203

208204
if (is_finished)
209205
return true;
210206

211-
was_finished_before = is_finished;
212207
is_finished = true;
213208
}
214209

215210
pop_condition.notify_all();
216211
push_condition.notify_all();
217-
218-
return was_finished_before;
212+
return false;
219213
}
220214

221215
/// Returns if queue is finished

src/Common/ProfileEvents.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,18 @@ The server successfully detected this situation and will download merged part fr
447447
M(QueryMemoryLimitExceeded, "Number of times when memory limit exceeded for query.") \
448448
\
449449
M(AzureGetObject, "Number of Azure API GetObject calls.") \
450-
M(AzureUploadPart, "Number of Azure blob storage API UploadPart calls") \
450+
M(AzureUpload, "Number of Azure blob storage API Upload calls") \
451+
M(AzureStageBlock, "Number of Azure blob storage API StageBlock calls") \
452+
M(AzureCommitBlockList, "Number of Azure blob storage API CommitBlockList calls") \
451453
M(AzureCopyObject, "Number of Azure blob storage API CopyObject calls") \
452454
M(AzureDeleteObjects, "Number of Azure blob storage API DeleteObject(s) calls.") \
453455
M(AzureListObjects, "Number of Azure blob storage API ListObjects calls.") \
454456
M(AzureGetProperties, "Number of Azure blob storage API GetProperties calls.") \
455457
\
456458
M(DiskAzureGetObject, "Number of Disk Azure API GetObject calls.") \
457-
M(DiskAzureUploadPart, "Number of Disk Azure blob storage API UploadPart calls") \
459+
M(DiskAzureUpload, "Number of Disk Azure blob storage API Upload calls") \
460+
M(DiskAzureStageBlock, "Number of Disk Azure blob storage API StageBlock calls") \
461+
M(DiskAzureCommitBlockList, "Number of Disk Azure blob storage API CommitBlockList calls") \
458462
M(DiskAzureCopyObject, "Number of Disk Azure blob storage API CopyObject calls") \
459463
M(DiskAzureListObjects, "Number of Disk Azure blob storage API ListObjects calls.") \
460464
M(DiskAzureDeleteObjects, "Number of Azure blob storage API DeleteObject(s) calls.") \
@@ -611,6 +615,13 @@ The server successfully detected this situation and will download merged part fr
611615
M(KeeperPacketsReceived, "Packets received by keeper server") \
612616
M(KeeperRequestTotal, "Total requests number on keeper server") \
613617
M(KeeperLatency, "Keeper latency") \
618+
M(KeeperTotalElapsedMicroseconds, "Keeper total latency for a single request") \
619+
M(KeeperProcessElapsedMicroseconds, "Keeper commit latency for a single request") \
620+
M(KeeperPreprocessElapsedMicroseconds, "Keeper preprocessing latency for a single reuquest") \
621+
M(KeeperStorageLockWaitMicroseconds, "Time spent waiting for acquiring Keeper storage lock") \
622+
M(KeeperCommitWaitElapsedMicroseconds, "Time spent waiting for certain log to be committed") \
623+
M(KeeperBatchMaxCount, "Number of times the size of batch was limited by the amount") \
624+
M(KeeperBatchMaxTotalSize, "Number of times the size of batch was limited by the total bytes size") \
614625
M(KeeperCommits, "Number of successful commits") \
615626
M(KeeperCommitsFailed, "Number of failed commits") \
616627
M(KeeperSnapshotCreations, "Number of snapshots creations")\

src/Common/ZooKeeper/ZooKeeperCommon.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <IO/ReadHelpers.h>
1010
#include <fmt/format.h>
1111
#include <Common/logger_useful.h>
12-
#include <array>
1312

1413

1514
namespace Coordination
@@ -29,15 +28,15 @@ void ZooKeeperResponse::write(WriteBuffer & out) const
2928
Coordination::write(buf.str(), out);
3029
}
3130

32-
std::string ZooKeeperRequest::toString() const
31+
std::string ZooKeeperRequest::toString(bool short_format) const
3332
{
3433
return fmt::format(
3534
"XID = {}\n"
3635
"OpNum = {}\n"
3736
"Additional info:\n{}",
3837
xid,
3938
getOpNum(),
40-
toStringImpl());
39+
toStringImpl(short_format));
4140
}
4241

4342
void ZooKeeperRequest::write(WriteBuffer & out) const
@@ -60,7 +59,7 @@ void ZooKeeperSyncRequest::readImpl(ReadBuffer & in)
6059
Coordination::read(path, in);
6160
}
6261

63-
std::string ZooKeeperSyncRequest::toStringImpl() const
62+
std::string ZooKeeperSyncRequest::toStringImpl(bool /*short_format*/) const
6463
{
6564
return fmt::format("path = {}", path);
6665
}
@@ -91,7 +90,7 @@ void ZooKeeperReconfigRequest::readImpl(ReadBuffer & in)
9190
Coordination::read(version, in);
9291
}
9392

94-
std::string ZooKeeperReconfigRequest::toStringImpl() const
93+
std::string ZooKeeperReconfigRequest::toStringImpl(bool /*short_format*/) const
9594
{
9695
return fmt::format(
9796
"joining = {}\nleaving = {}\nnew_members = {}\nversion = {}",
@@ -145,7 +144,7 @@ void ZooKeeperAuthRequest::readImpl(ReadBuffer & in)
145144
Coordination::read(data, in);
146145
}
147146

148-
std::string ZooKeeperAuthRequest::toStringImpl() const
147+
std::string ZooKeeperAuthRequest::toStringImpl(bool /*short_format*/) const
149148
{
150149
return fmt::format(
151150
"type = {}\n"
@@ -191,7 +190,7 @@ void ZooKeeperCreateRequest::readImpl(ReadBuffer & in)
191190
is_sequential = true;
192191
}
193192

194-
std::string ZooKeeperCreateRequest::toStringImpl() const
193+
std::string ZooKeeperCreateRequest::toStringImpl(bool /*short_format*/) const
195194
{
196195
return fmt::format(
197196
"path = {}\n"
@@ -218,7 +217,7 @@ void ZooKeeperRemoveRequest::writeImpl(WriteBuffer & out) const
218217
Coordination::write(version, out);
219218
}
220219

221-
std::string ZooKeeperRemoveRequest::toStringImpl() const
220+
std::string ZooKeeperRemoveRequest::toStringImpl(bool /*short_format*/) const
222221
{
223222
return fmt::format(
224223
"path = {}\n"
@@ -245,7 +244,7 @@ void ZooKeeperExistsRequest::readImpl(ReadBuffer & in)
245244
Coordination::read(has_watch, in);
246245
}
247246

248-
std::string ZooKeeperExistsRequest::toStringImpl() const
247+
std::string ZooKeeperExistsRequest::toStringImpl(bool /*short_format*/) const
249248
{
250249
return fmt::format("path = {}", path);
251250
}
@@ -272,7 +271,7 @@ void ZooKeeperGetRequest::readImpl(ReadBuffer & in)
272271
Coordination::read(has_watch, in);
273272
}
274273

275-
std::string ZooKeeperGetRequest::toStringImpl() const
274+
std::string ZooKeeperGetRequest::toStringImpl(bool /*short_format*/) const
276275
{
277276
return fmt::format("path = {}", path);
278277
}
@@ -303,7 +302,7 @@ void ZooKeeperSetRequest::readImpl(ReadBuffer & in)
303302
Coordination::read(version, in);
304303
}
305304

306-
std::string ZooKeeperSetRequest::toStringImpl() const
305+
std::string ZooKeeperSetRequest::toStringImpl(bool /*short_format*/) const
307306
{
308307
return fmt::format(
309308
"path = {}\n"
@@ -334,7 +333,7 @@ void ZooKeeperListRequest::readImpl(ReadBuffer & in)
334333
Coordination::read(has_watch, in);
335334
}
336335

337-
std::string ZooKeeperListRequest::toStringImpl() const
336+
std::string ZooKeeperListRequest::toStringImpl(bool /*short_format*/) const
338337
{
339338
return fmt::format("path = {}", path);
340339
}
@@ -356,7 +355,7 @@ void ZooKeeperFilteredListRequest::readImpl(ReadBuffer & in)
356355
list_request_type = static_cast<ListRequestType>(read_request_type);
357356
}
358357

359-
std::string ZooKeeperFilteredListRequest::toStringImpl() const
358+
std::string ZooKeeperFilteredListRequest::toStringImpl(bool /*short_format*/) const
360359
{
361360
return fmt::format(
362361
"path = {}\n"
@@ -401,7 +400,7 @@ void ZooKeeperSetACLRequest::readImpl(ReadBuffer & in)
401400
Coordination::read(version, in);
402401
}
403402

404-
std::string ZooKeeperSetACLRequest::toStringImpl() const
403+
std::string ZooKeeperSetACLRequest::toStringImpl(bool /*short_format*/) const
405404
{
406405
return fmt::format("path = {}\nversion = {}", path, version);
407406
}
@@ -426,7 +425,7 @@ void ZooKeeperGetACLRequest::writeImpl(WriteBuffer & out) const
426425
Coordination::write(path, out);
427426
}
428427

429-
std::string ZooKeeperGetACLRequest::toStringImpl() const
428+
std::string ZooKeeperGetACLRequest::toStringImpl(bool /*short_format*/) const
430429
{
431430
return fmt::format("path = {}", path);
432431
}
@@ -455,7 +454,7 @@ void ZooKeeperCheckRequest::readImpl(ReadBuffer & in)
455454
Coordination::read(version, in);
456455
}
457456

458-
std::string ZooKeeperCheckRequest::toStringImpl() const
457+
std::string ZooKeeperCheckRequest::toStringImpl(bool /*short_format*/) const
459458
{
460459
return fmt::format("path = {}\nversion = {}", path, version);
461460
}
@@ -600,8 +599,11 @@ void ZooKeeperMultiRequest::readImpl(ReadBuffer & in)
600599
}
601600
}
602601

603-
std::string ZooKeeperMultiRequest::toStringImpl() const
602+
std::string ZooKeeperMultiRequest::toStringImpl(bool short_format) const
604603
{
604+
if (short_format)
605+
return fmt::format("Subrequests size = {}", requests.size());
606+
605607
auto out = fmt::memory_buffer();
606608
for (const auto & request : requests)
607609
{

0 commit comments

Comments
 (0)