Skip to content

Commit 320e03d

Browse files
Backport ClickHouse#89003 to 25.8: Don't use metadata cache in iceberg history table
1 parent fd842b2 commit 320e03d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Storages/System/StorageSystemIcebergHistory.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace DB
3131
namespace Setting
3232
{
3333
extern const SettingsSeconds lock_acquire_timeout;
34+
extern const SettingsBool use_iceberg_metadata_files_cache;
3435
}
3536

3637
ColumnsDescription StorageSystemIcebergHistory::getColumnsDescription()
@@ -49,7 +50,12 @@ ColumnsDescription StorageSystemIcebergHistory::getColumnsDescription()
4950
void StorageSystemIcebergHistory::fillData([[maybe_unused]] MutableColumns & res_columns, [[maybe_unused]] ContextPtr context, const ActionsDAG::Node *, std::vector<UInt8>) const
5051
{
5152
#if USE_AVRO
52-
const auto access = context->getAccess();
53+
ContextMutablePtr context_copy = Context::createCopy(context);
54+
Settings settings_copy = context_copy->getSettingsCopy();
55+
settings_copy[Setting::use_iceberg_metadata_files_cache] = false;
56+
context_copy->setSettings(settings_copy);
57+
58+
const auto access = context_copy->getAccess();
5359

5460
auto add_history_record = [&](const DatabaseTablesIteratorPtr & it, StorageObjectStorage * object_storage)
5561
{
@@ -60,9 +66,9 @@ void StorageSystemIcebergHistory::fillData([[maybe_unused]] MutableColumns & res
6066
/// to handle properly all possible errors which we can get when attempting to read metadata of iceberg table
6167
try
6268
{
63-
if (IcebergMetadata * iceberg_metadata = dynamic_cast<IcebergMetadata *>(object_storage->getExternalMetadata(context)); iceberg_metadata)
69+
if (IcebergMetadata * iceberg_metadata = dynamic_cast<IcebergMetadata *>(object_storage->getExternalMetadata(context_copy)); iceberg_metadata)
6470
{
65-
IcebergMetadata::IcebergHistory iceberg_history_items = iceberg_metadata->getHistory(context);
71+
IcebergMetadata::IcebergHistory iceberg_history_items = iceberg_metadata->getHistory(context_copy);
6672

6773
for (auto & iceberg_history_item : iceberg_history_items)
6874
{
@@ -91,11 +97,11 @@ void StorageSystemIcebergHistory::fillData([[maybe_unused]] MutableColumns & res
9197
for (const auto & db: databases)
9298
{
9399
/// with last flag we are filtering out all non iceberg table
94-
for (auto iterator = db.second->getLightweightTablesIterator(context, {}, true); iterator->isValid(); iterator->next())
100+
for (auto iterator = db.second->getLightweightTablesIterator(context_copy, {}, true); iterator->isValid(); iterator->next())
95101
{
96102
StoragePtr storage = iterator->table();
97103

98-
TableLockHolder lock = storage->tryLockForShare(context->getCurrentQueryId(), context->getSettingsRef()[Setting::lock_acquire_timeout]);
104+
TableLockHolder lock = storage->tryLockForShare(context_copy->getCurrentQueryId(), context_copy->getSettingsRef()[Setting::lock_acquire_timeout]);
99105
if (!lock)
100106
// Table was dropped while acquiring the lock, skipping table
101107
continue;

0 commit comments

Comments
 (0)