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())
tryRemoveSymlink(table_name);
if (table->dropTableImmediately())
{
table->drop();
}
/// 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.
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)
{
if (table.table)
if (table.table && !table.table->dropTableImmediately())
{
table.table->drop();
}

View File

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

View File

@ -39,7 +39,8 @@ namespace ErrorCodes
extern const int CANNOT_GET_FILE_STAT;
extern const int NOT_REGULAR_FILE;
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

View File

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

View File

@ -578,6 +578,8 @@ public:
/// Does not takes underlying Storage (if any) into account.
virtual std::optional<UInt64> lifetimeBytes() const { return {}; }
virtual bool dropTableImmediately() const { return false; }
private:
/// Lock required for alter queries (lockForAlter). Always taken for write
/// (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 "detach table t;"
${CLICKHOUSE_CLIENT} --query "attach table t;"
${CLICKHOUSE_CLIENT} --query "detach table file_log;"
${CLICKHOUSE_CLIENT} --query "attach table file_log;"
# should no records return
${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;"