Skip to content

Commit 82c2377

Browse files
committed
Fix refreshable MV drop while paused
1 parent a5f4c98 commit 82c2377

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Storages/MaterializedView/RefreshTask.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace ErrorCodes
6464
}
6565

6666
RefreshTask::RefreshTask(
67-
StorageMaterializedView * view_, ContextPtr context, const DB::ASTRefreshStrategy & strategy, bool /* attach */, bool coordinated, bool empty, bool is_restore_from_backup)
67+
StorageMaterializedView * view_, ContextPtr context, const DB::ASTRefreshStrategy & strategy, bool attach, bool coordinated, bool empty, bool is_restore_from_backup)
6868
: log(getLogger("RefreshTask"))
6969
, view(view_)
7070
, refresh_schedule(strategy)
@@ -95,6 +95,10 @@ RefreshTask::RefreshTask(
9595
/// currently both DatabaseReplicated and DatabaseShared seem to require this behavior.
9696
if (!replica_path_existed)
9797
{
98+
if (!attach && !is_restore_from_backup &&
99+
!zookeeper->isFeatureEnabled(KeeperFeatureFlag::MULTI_READ))
100+
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Keeper server doesn't support multi-reads.");
101+
98102
zookeeper->createAncestors(coordination.path);
99103
Coordination::Requests ops;
100104
ops.emplace_back(zkutil::makeCreateRequest(coordination.path, coordination.root_znode.toString(), zkutil::CreateMode::Persistent, /*ignore_if_exists*/ true));
@@ -217,6 +221,9 @@ void RefreshTask::drop(ContextPtr context)
217221
/// If no replicas left, remove the coordination znode.
218222
Coordination::Requests ops;
219223
ops.emplace_back(zkutil::makeRemoveRequest(coordination.path + "/replicas", -1));
224+
String paused_path = coordination.path + "/paused";
225+
if (zookeeper->exists(paused_path))
226+
ops.emplace_back(zkutil::makeRemoveRequest(paused_path, -1));
220227
ops.emplace_back(zkutil::makeRemoveRequest(coordination.path, -1));
221228
Coordination::Responses responses;
222229
auto code = zookeeper->tryMulti(ops, responses);
@@ -604,6 +611,8 @@ void RefreshTask::refreshTask()
604611
#ifdef DEBUG_OR_SANITIZER_BUILD
605612
/// There's at least one legitimate case where this may happen: if the user (DEFINER) was dropped.
606613
/// But it's unexpected in tests.
614+
/// Note that Coordination::Exception is caught separately above, so transient keeper errors
615+
/// don't go here and are just retried.
607616
abortOnFailedAssertion("Unexpected exception in refresh scheduling");
608617
#else
609618
if (coordination.coordinated)

tests/integration/test_refreshable_mv/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ def test_pause(started_cluster, cleanup):
371371
"select * from re.a",
372372
"2\n",
373373
)
374+
# Drop while paused.
375+
node1.query("system stop replicated view re.a")
376+
for node in nodes:
377+
node.query("drop database re sync")
374378

375379
backup_id_counter = 0
376380

0 commit comments

Comments
 (0)