提交 cf5a8643 编写于 作者: A Alexey Milovidov

dbms: fixed error when uncompressed_cache or marks_cache is not set [#METR-2944].

上级 e41c11e7
......@@ -295,6 +295,14 @@ public:
void setMarkCache(size_t cache_size_in_bytes);
MarkCachePtr getMarkCache() const;
/** Очистить кэши разжатых блоков и засечек.
* Обычно это делается при переименовании таблиц, изменении типа столбцов, удалении таблицы.
* - так как кэши привязаны к именам файлов, и становятся некорректными.
* (при удалении таблицы - нужно, так как на её месте может появиться другая)
* const - потому что изменение кэша не считается существенным.
*/
void resetCaches() const;
void initClusters();
Cluster & getCluster(const std::string & cluster_name);
......
......@@ -532,9 +532,21 @@ void Context::setMarkCache(size_t cache_size_in_bytes)
MarkCachePtr Context::getMarkCache() const
{
/// Исходим из допущения, что функция setMarksCache, если вызывалась, то раньше. Иначе поставьте mutex.
return shared->mark_cache;
}
void Context::resetCaches() const
{
/// Исходим из допущения, что функции setUncompressedCache, setMarkCache, если вызывались, то раньше (при старте сервера). Иначе поставьте mutex.
if (shared->uncompressed_cache)
shared->uncompressed_cache->reset();
if (shared->mark_cache)
shared->mark_cache->reset();
}
void Context::initClusters()
{
Poco::ScopedLock<Poco::Mutex> lock(shared->mutex);
......
......@@ -317,8 +317,7 @@ void MergeTreeData::setPath(const String & new_full_path)
Poco::File(full_path).renameTo(new_full_path);
full_path = new_full_path;
context.getUncompressedCache()->reset();
context.getMarkCache()->reset();
context.resetCaches();
log = &Logger::get(lastTwoPathComponents(full_path));
}
......@@ -328,8 +327,7 @@ void MergeTreeData::dropAllData()
data_parts.clear();
all_data_parts.clear();
context.getUncompressedCache()->reset();
context.getMarkCache()->reset();
context.resetCaches();
Poco::File(full_path).remove(true);
}
......@@ -411,6 +409,7 @@ void MergeTreeData::alter(const ASTAlterQuery::Parameters & params)
Poco::ScopedLock<Poco::FastMutex> lock_all(all_data_parts_mutex);
alterColumns(params, columns, context);
}
if (params.type == ASTAlterQuery::DROP)
{
String column_name = dynamic_cast<const ASTIdentifier &>(*params.column).name;
......@@ -424,8 +423,7 @@ void MergeTreeData::alter(const ASTAlterQuery::Parameters & params)
}
removeColumnFiles(column_name, remove_array_size_files);
context.getUncompressedCache()->reset();
context.getMarkCache()->reset();
context.resetCaches();
}
}
......@@ -571,8 +569,7 @@ void MergeTreeData::commitAlterModify(const ASTAlterQuery::Parameters & params)
}
}
context.getUncompressedCache()->reset();
context.getMarkCache()->reset();
context.resetCaches();
{
Poco::ScopedLock<Poco::FastMutex> lock(data_parts_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册