mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #16409 from azat/drop-distributed-fix
Fix DROP TABLE for Distributed (racy with INSERT)
This commit is contained in:
commit
cd70dc82cd
@ -80,7 +80,6 @@ namespace ErrorCodes
|
||||
extern const int TYPE_MISMATCH;
|
||||
extern const int TOO_MANY_ROWS;
|
||||
extern const int UNABLE_TO_SKIP_UNUSED_SHARDS;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
namespace ActionLocks
|
||||
@ -600,15 +599,22 @@ void StorageDistributed::shutdown()
|
||||
monitors_blocker.cancelForever();
|
||||
|
||||
std::lock_guard lock(cluster_nodes_mutex);
|
||||
|
||||
LOG_DEBUG(log, "Joining background threads for async INSERT");
|
||||
cluster_nodes_data.clear();
|
||||
LOG_DEBUG(log, "Background threads for async INSERT joined");
|
||||
}
|
||||
void StorageDistributed::drop()
|
||||
{
|
||||
// shutdown() should be already called
|
||||
// and by the same reason we cannot use truncate() here, since
|
||||
// cluster_nodes_data already cleaned
|
||||
if (!cluster_nodes_data.empty())
|
||||
throw Exception("drop called before shutdown", ErrorCodes::LOGICAL_ERROR);
|
||||
// Some INSERT in-between shutdown() and drop() can call
|
||||
// requireDirectoryMonitor() again, so call shutdown() to clear them, but
|
||||
// when the drop() (this function) executed none of INSERT is allowed in
|
||||
// parallel.
|
||||
//
|
||||
// And second time shutdown() should be fast, since none of
|
||||
// DirectoryMonitor should do anything, because ActionBlocker is canceled
|
||||
// (in shutdown()).
|
||||
shutdown();
|
||||
|
||||
// Distributed table w/o sharding_key does not allows INSERTs
|
||||
if (relative_data_path.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user