drop table immediately

fix style

update
This commit is contained in:
feng lv 2021-09-26 13:37:57 +00:00
parent f8f22f9a51
commit 6c4b0f2d37
7 changed files with 15 additions and 10 deletions

View File

@ -140,6 +140,11 @@ void DatabaseAtomic::dropTable(ContextPtr local_context, const String & table_na
if (table->storesDataOnDisk()) if (table->storesDataOnDisk())
tryRemoveSymlink(table_name); tryRemoveSymlink(table_name);
if (table->dropTableImmediately())
{
table->drop();
}
/// Notify DatabaseCatalog that table was dropped. It will remove table data in background. /// Notify DatabaseCatalog that table was dropped. It will remove table data in background.
/// Cleanup is performed outside of database to allow easily DROP DATABASE without waiting for cleanup to complete. /// Cleanup is performed outside of database to allow easily DROP DATABASE without waiting for cleanup to complete.
DatabaseCatalog::instance().enqueueDroppedTableCleanup(table->getStorageID(), table, table_metadata_path_drop, no_delay); DatabaseCatalog::instance().enqueueDroppedTableCleanup(table->getStorageID(), table, table_metadata_path_drop, no_delay);

View File

@ -898,7 +898,7 @@ void DatabaseCatalog::dropTableDataTask()
void DatabaseCatalog::dropTableFinally(const TableMarkedAsDropped & table) void DatabaseCatalog::dropTableFinally(const TableMarkedAsDropped & table)
{ {
if (table.table) if (table.table && !table.table->dropTableImmediately())
{ {
table.table->drop(); table.table->drop();
} }

View File

@ -11,12 +11,7 @@
namespace DB namespace DB
{ {
namespace ErrorCodes static constexpr auto MAX_FAILED_POLL_ATTEMPTS = 10;
{
extern const int LOGICAL_ERROR;
}
const auto MAX_FAILED_POLL_ATTEMPTS = 10;
FileLogSource::FileLogSource( FileLogSource::FileLogSource(
StorageFileLog & storage_, StorageFileLog & storage_,

View File

@ -39,7 +39,8 @@ namespace ErrorCodes
extern const int CANNOT_GET_FILE_STAT; extern const int CANNOT_GET_FILE_STAT;
extern const int NOT_REGULAR_FILE; extern const int NOT_REGULAR_FILE;
extern const int READ_META_FILE_FAILED; extern const int READ_META_FILE_FAILED;
extern const int FILE_STREAM_ERROR; extern const int FILE_STREAM_ERROR;
extern const int LOGICAL_ERROR;
} }
namespace namespace

View File

@ -44,6 +44,8 @@ public:
void drop() override; void drop() override;
bool dropTableImmediately() const override { return true; }
const auto & getFormatName() const { return format_name; } const auto & getFormatName() const { return format_name; }
enum class FileStatus enum class FileStatus

View File

@ -578,6 +578,8 @@ public:
/// Does not takes underlying Storage (if any) into account. /// Does not takes underlying Storage (if any) into account.
virtual std::optional<UInt64> lifetimeBytes() const { return {}; } virtual std::optional<UInt64> lifetimeBytes() const { return {}; }
virtual bool dropTableImmediately() const { return false; }
private: private:
/// Lock required for alter queries (lockForAlter). Always taken for write /// Lock required for alter queries (lockForAlter). Always taken for write
/// (actually can be replaced with std::mutex, but for consistency we use /// (actually can be replaced with std::mutex, but for consistency we use

View File

@ -46,8 +46,8 @@ rm ${user_files_path}/logs/d.txt
${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;" ${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;"
${CLICKHOUSE_CLIENT} --query "detach table t;" ${CLICKHOUSE_CLIENT} --query "detach table file_log;"
${CLICKHOUSE_CLIENT} --query "attach table t;" ${CLICKHOUSE_CLIENT} --query "attach table file_log;"
# should no records return # should no records return
${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;" ${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;"