Skip to content

Commit 59cc005

Browse files
committed
Fix mutations after turning on zero-copy
1 parent 3be2ae7 commit 59cc005

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/Storages/StorageReplicatedMergeTree.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -10300,6 +10300,8 @@ void StorageReplicatedMergeTree::getZeroCopyLockNodeCreateOps(
1030010300
requests.emplace_back(zkutil::makeCreateRequest(zookeeper_node, "", mode));
1030110301
if (!path_to_set_hardlinked_files.empty() && !hardlinked_files.empty())
1030210302
{
10303+
/// Node may be missing in rare cases when zero-copy is turned on for an existing table.
10304+
zookeeper->checkExistsAndGetCreateAncestorsOps(path_to_set_hardlinked_files + "/", requests);
1030310305
std::string data = boost::algorithm::join(hardlinked_files, "\n");
1030410306
/// List of files used to detect hardlinks. path_to_set_hardlinked_files --
1030510307
/// is a path to source part zero copy node. During part removal hardlinked
@@ -10312,6 +10314,8 @@ void StorageReplicatedMergeTree::getZeroCopyLockNodeCreateOps(
1031210314
Coordination::Requests ops;
1031310315
if (!path_to_set_hardlinked_files.empty() && !hardlinked_files.empty())
1031410316
{
10317+
/// Node may be missing in rare cases when zero-copy is turned on for an existing table.
10318+
zookeeper->checkExistsAndGetCreateAncestorsOps(path_to_set_hardlinked_files + "/", requests);
1031510319
std::string data = boost::algorithm::join(hardlinked_files, "\n");
1031610320
/// List of files used to detect hardlinks. path_to_set_hardlinked_files --
1031710321
/// is a path to source part zero copy node. During part removal hardlinked
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Tags: no-parallel, no-fasttest
3+
4+
set -e
5+
6+
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
7+
# shellcheck source=../shell_config.sh
8+
. "$CUR_DIR"/../shell_config.sh
9+
10+
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test03391_zero_copy_mutations"
11+
$CLICKHOUSE_CLIENT -m -q "
12+
CREATE TABLE test03391_zero_copy_mutations
13+
(key UInt32, value UInt32)
14+
ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/test03391_zero_copy_mutations', 'r1')
15+
ORDER BY key
16+
SETTINGS storage_policy='s3_cache', allow_remote_fs_zero_copy_replication=0
17+
"
18+
19+
$CLICKHOUSE_CLIENT -q "INSERT INTO test03391_zero_copy_mutations VALUES (1,1)"
20+
$CLICKHOUSE_CLIENT -q "ALTER TABLE test03391_zero_copy_mutations MODIFY SETTING allow_remote_fs_zero_copy_replication=1"
21+
$CLICKHOUSE_CLIENT -q "ALTER TABLE test03391_zero_copy_mutations UPDATE value=value WHERE 0"
22+
23+
for i in {1..10}
24+
do
25+
if [ "$(${CLICKHOUSE_CLIENT} -q "SELECT count() FROM system.mutations WHERE table='test03391_zero_copy_mutations' AND is_done=1")" -eq 1 ]; then
26+
break
27+
fi
28+
sleep 1
29+
done
30+
31+
echo '1' | $CLICKHOUSE_CLIENT -q "SELECT count() FROM system.mutations WHERE table='test03391_zero_copy_mutations' AND is_done=1"
32+
33+
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test03391_zero_copy_mutations"

0 commit comments

Comments
 (0)