Skip to content

Commit

Permalink
Merge branch 'master' into fix-async-loader-shutdown-deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
serxa committed Jan 25, 2024
2 parents 41e6dd7 + 5ba7a78 commit a40da92
Show file tree
Hide file tree
Showing 73 changed files with 1,004 additions and 304 deletions.
4 changes: 2 additions & 2 deletions docker/test/stateless/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ stop_logs_replication

# Try to get logs while server is running
successfuly_saved=0
for table in query_log zookeeper_log trace_log transactions_info_log
for table in query_log zookeeper_log trace_log transactions_info_log metric_log
do
clickhouse-client -q "select * from system.$table format TSVWithNamesAndTypes" | zstd --threads=0 > /test_output/$table.tsv.zst
successfuly_saved=$?
Expand Down Expand Up @@ -288,7 +288,7 @@ if [ $successfuly_saved -ne 0 ]; then
# directly
# - even though ci auto-compress some files (but not *.tsv) it does this only
# for files >64MB, we want this files to be compressed explicitly
for table in query_log zookeeper_log trace_log transactions_info_log
for table in query_log zookeeper_log trace_log transactions_info_log metric_log
do
clickhouse-local "$data_path_config" --only-system-tables -q "select * from system.$table format TSVWithNamesAndTypes" | zstd --threads=0 > /test_output/$table.tsv.zst ||:
if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then
Expand Down
1 change: 1 addition & 0 deletions docs/changelogs/v23.9.1.1854-stable.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sidebar_label: 2023
* Remove the `status_info` configuration option and dictionaries status from the default Prometheus handler. [#54090](https://github.com/ClickHouse/ClickHouse/pull/54090) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* The experimental parts metadata cache is removed from the codebase. [#54215](https://github.com/ClickHouse/ClickHouse/pull/54215) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
* Disable setting `input_format_json_try_infer_numbers_from_strings` by default, so we don't try to infer numbers from strings in JSON formats by default to avoid possible parsing errors when sample data contains strings that looks like a number. [#55099](https://github.com/ClickHouse/ClickHouse/pull/55099) ([Kruglov Pavel](https://github.com/Avogar)).
* IPv6 bloom filter indexes created prior to March 2023 are not compatible with current version and have to be rebuilt. [#54200](https://github.com/ClickHouse/ClickHouse/pull/54200) ([Yakov Olkhovskiy](https://github.com/yakov-olkhovskiy)).

#### New Feature
* Added new type of authentication based on SSH keys. It works only for Native TCP protocol. [#41109](https://github.com/ClickHouse/ClickHouse/pull/41109) ([George Gamezardashvili](https://github.com/InfJoker)).
Expand Down
10 changes: 10 additions & 0 deletions docs/en/operations/settings/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5197,3 +5197,13 @@ The value 0 means that you can delete all tables without any restrictions.
:::note
This query setting overwrites its server setting equivalent, see [max_table_size_to_drop](/docs/en/operations/server-configuration-parameters/settings.md/#max-table-size-to-drop)
:::

## iceberg_engine_ignore_schema_evolution {#iceberg_engine_ignore_schema_evolution}

Allow to ignore schema evolution in Iceberg table engine and read all data using schema specified by the user on table creation or latest schema parsed from metadata on table creation.

:::note
Enabling this setting can lead to incorrect result as in case of evolved schema all data files will be read using the same schema.
:::

Default value: 'false'.
4 changes: 0 additions & 4 deletions docs/en/sql-reference/statements/rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ sidebar_label: RENAME
Renames databases, tables, or dictionaries. Several entities can be renamed in a single query.
Note that the `RENAME` query with several entities is non-atomic operation. To swap entities names atomically, use the [EXCHANGE](./exchange.md) statement.

:::note
The `RENAME` query is supported by the [Atomic](../../engines/database-engines/atomic.md) database engine only.
:::

**Syntax**

```sql
Expand Down
2 changes: 1 addition & 1 deletion docs/en/sql-reference/table-functions/executable.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords: [udf, user defined function, clickhouse, executable, table, function]

# executable Table Function for UDFs

The `executable` table function creates a table based on the output of a user-defined function (UDF) that you define in a script that outputs rows to **stdout**. The executable script is stored in the `users_scripts` directory and can read data from any source.
The `executable` table function creates a table based on the output of a user-defined function (UDF) that you define in a script that outputs rows to **stdout**. The executable script is stored in the `users_scripts` directory and can read data from any source. Make sure your ClickHouse server has all the required packages to run the executable script. For example, if it is a Python script, ensure that the server has the necessary Python packages installed.

You can optionally include one or more input queries that stream their results to **stdin** for the script to read.

Expand Down
2 changes: 1 addition & 1 deletion programs/disks/DisksApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int DisksApp::main(const std::vector<String> & /*args*/)
}
else
{
throw Exception(ErrorCodes::BAD_ARGUMENTS, "No config-file specifiged");
throw Exception(ErrorCodes::BAD_ARGUMENTS, "No config-file specified");
}

if (config().has("save-logs"))
Expand Down
62 changes: 62 additions & 0 deletions src/Analyzer/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,68 @@ void addTableExpressionOrJoinIntoTablesInSelectQuery(ASTPtr & tables_in_select_q
}
}

QueryTreeNodes extractAllTableReferences(const QueryTreeNodePtr & tree)
{
QueryTreeNodes result;

QueryTreeNodes nodes_to_process;
nodes_to_process.push_back(tree);

while (!nodes_to_process.empty())
{
auto node_to_process = std::move(nodes_to_process.back());
nodes_to_process.pop_back();

auto node_type = node_to_process->getNodeType();

switch (node_type)
{
case QueryTreeNodeType::TABLE:
{
result.push_back(std::move(node_to_process));
break;
}
case QueryTreeNodeType::QUERY:
{
nodes_to_process.push_back(node_to_process->as<QueryNode>()->getJoinTree());
break;
}
case QueryTreeNodeType::UNION:
{
for (const auto & union_node : node_to_process->as<UnionNode>()->getQueries().getNodes())
nodes_to_process.push_back(union_node);
break;
}
case QueryTreeNodeType::TABLE_FUNCTION:
{
// Arguments of table function can't contain TableNodes.
break;
}
case QueryTreeNodeType::ARRAY_JOIN:
{
nodes_to_process.push_back(node_to_process->as<ArrayJoinNode>()->getTableExpression());
break;
}
case QueryTreeNodeType::JOIN:
{
auto & join_node = node_to_process->as<JoinNode &>();
nodes_to_process.push_back(join_node.getRightTableExpression());
nodes_to_process.push_back(join_node.getLeftTableExpression());
break;
}
default:
{
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Unexpected node type for table expression. "
"Expected table, table function, query, union, join or array join. Actual {}",
node_to_process->getNodeTypeName());
}
}
}

return result;
}

QueryTreeNodes extractTableExpressions(const QueryTreeNodePtr & join_tree_node, bool add_array_join)
{
QueryTreeNodes result;
Expand Down
7 changes: 5 additions & 2 deletions src/Analyzer/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ std::optional<bool> tryExtractConstantFromConditionNode(const QueryTreeNodePtr &
*/
void addTableExpressionOrJoinIntoTablesInSelectQuery(ASTPtr & tables_in_select_query_ast, const QueryTreeNodePtr & table_expression, const IQueryTreeNode::ConvertToASTOptions & convert_to_ast_options);

/// Extract table, table function, query, union from join tree
/// Extract all TableNodes from the query tree.
QueryTreeNodes extractAllTableReferences(const QueryTreeNodePtr & tree);

/// Extract table, table function, query, union from join tree.
QueryTreeNodes extractTableExpressions(const QueryTreeNodePtr & join_tree_node, bool add_array_join = false);

/// Extract left table expression from join tree
/// Extract left table expression from join tree.
QueryTreeNodePtr extractLeftTableExpression(const QueryTreeNodePtr & join_tree_node);

/** Build table expressions stack that consists from table, table function, query, union, join, array join from join tree.
Expand Down
38 changes: 23 additions & 15 deletions src/Coordination/KeeperSnapshotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ namespace

/// Serialize ACL
writeBinary(node.acl_id, out);
writeBinary(node.is_sequental, out);
/// Write is_sequential for backwards compatibility
if (version < SnapshotVersion::V6)
writeBinary(false, out);

/// Serialize stat
writeBinary(node.stat.czxid, out);
writeBinary(node.stat.mzxid, out);
Expand All @@ -84,16 +87,15 @@ namespace
writeBinary(node.stat.cversion, out);
writeBinary(node.stat.aversion, out);
writeBinary(node.stat.ephemeralOwner, out);
writeBinary(node.stat.dataLength, out);
if (version < SnapshotVersion::V6)
writeBinary(static_cast<int32_t>(node.getData().size()), out);
writeBinary(node.stat.numChildren, out);
writeBinary(node.stat.pzxid, out);

writeBinary(node.seq_num, out);

if (version >= SnapshotVersion::V4)
{
writeBinary(node.size_bytes, out);
}
if (version >= SnapshotVersion::V4 && version <= SnapshotVersion::V5)
writeBinary(node.sizeInBytes(), out);
}

void readNode(KeeperStorage::Node & node, ReadBuffer & in, SnapshotVersion version, ACLMap & acl_map)
Expand Down Expand Up @@ -129,7 +131,11 @@ namespace

acl_map.addUsage(node.acl_id);

readBinary(node.is_sequental, in);
if (version < SnapshotVersion::V6)
{
bool is_sequential = false;
readBinary(is_sequential, in);
}

/// Deserialize stat
readBinary(node.stat.czxid, in);
Expand All @@ -140,14 +146,19 @@ namespace
readBinary(node.stat.cversion, in);
readBinary(node.stat.aversion, in);
readBinary(node.stat.ephemeralOwner, in);
readBinary(node.stat.dataLength, in);
if (version < SnapshotVersion::V6)
{
int32_t data_length = 0;
readBinary(data_length, in);
}
readBinary(node.stat.numChildren, in);
readBinary(node.stat.pzxid, in);
readBinary(node.seq_num, in);

if (version >= SnapshotVersion::V4)
if (version >= SnapshotVersion::V4 && version <= SnapshotVersion::V5)
{
readBinary(node.size_bytes, in);
uint64_t size_bytes = 0;
readBinary(size_bytes, in);
}
}

Expand Down Expand Up @@ -354,7 +365,7 @@ void KeeperStorageSnapshot::deserialize(SnapshotDeserializationResult & deserial

const auto is_node_empty = [](const auto & node)
{
return node.getData().empty() && node.stat == Coordination::Stat{};
return node.getData().empty() && node.stat == KeeperStorage::Node::Stat{};
};

for (size_t nodes_read = 0; nodes_read < snapshot_container_size; ++nodes_read)
Expand Down Expand Up @@ -398,9 +409,6 @@ void KeeperStorageSnapshot::deserialize(SnapshotDeserializationResult & deserial
"If you still want to ignore it, you can set 'keeper_server.ignore_system_path_on_startup' to true",
error_msg);
}

// we always ignore the written size for this node
node.recalculateSize();
}

storage.container.insertOrReplace(path, node);
Expand All @@ -417,7 +425,7 @@ void KeeperStorageSnapshot::deserialize(SnapshotDeserializationResult & deserial
{
auto parent_path = parentNodePath(itr.key);
storage.container.updateValue(
parent_path, [version, path = itr.key](KeeperStorage::Node & value) { value.addChild(getBaseNodeName(path), /*update_size*/ version < SnapshotVersion::V4); });
parent_path, [path = itr.key](KeeperStorage::Node & value) { value.addChild(getBaseNodeName(path)); });
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Coordination/KeeperSnapshotManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ enum SnapshotVersion : uint8_t
V3 = 3, /// compress snapshots with ZSTD codec
V4 = 4, /// add Node size to snapshots
V5 = 5, /// add ZXID and digest to snapshots
V6 = 6, /// remove is_sequential, per node size, data length
};

static constexpr auto CURRENT_SNAPSHOT_VERSION = SnapshotVersion::V5;
static constexpr auto CURRENT_SNAPSHOT_VERSION = SnapshotVersion::V6;

/// What is stored in binary snapshot
struct SnapshotDeserializationResult
Expand Down

0 comments on commit a40da92

Please sign in to comment.