@@ -64,7 +64,7 @@ namespace ErrorCodes
6464}
6565
6666RefreshTask::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 )
0 commit comments