Skip to content

Commit fd0e026

Browse files
committed
Merge remote-tracking branch 'altinity/forwardports/25.6.5/743_list_objects_object_storage_cache' into ports/25.6/amalgamation_of_metadata_prs
2 parents 95294a5 + f3f617f commit fd0e026

22 files changed

+778
-19
lines changed

programs/server/Server.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#include <Storages/System/attachSystemTables.h>
8484
#include <Storages/System/attachInformationSchemaTables.h>
8585
#include <Storages/Cache/registerRemoteFileMetadatas.h>
86+
#include <Storages/Cache/ObjectStorageListObjectsCache.h>
8687
#include <AggregateFunctions/registerAggregateFunctions.h>
8788
#include <Functions/UserDefined/IUserDefinedSQLObjectsStorage.h>
8889
#include <Functions/registerFunctions.h>
@@ -331,6 +332,10 @@ namespace ServerSetting
331332
extern const ServerSettingsFloat min_os_cpu_wait_time_ratio_to_drop_connection;
332333
extern const ServerSettingsFloat max_os_cpu_wait_time_ratio_to_drop_connection;
333334
extern const ServerSettingsUInt64 input_format_parquet_metadata_cache_max_size;
335+
extern const ServerSettingsUInt64 object_storage_list_objects_cache_size;
336+
extern const ServerSettingsUInt64 object_storage_list_objects_cache_max_entries;
337+
extern const ServerSettingsUInt64 object_storage_list_objects_cache_ttl;
338+
334339
}
335340

336341
namespace ErrorCodes
@@ -418,6 +423,7 @@ namespace ErrorCodes
418423
extern const int NETWORK_ERROR;
419424
extern const int CORRUPTED_DATA;
420425
extern const int BAD_ARGUMENTS;
426+
extern const int STARTUP_SCRIPTS_ERROR;
421427
}
422428

423429

@@ -2426,6 +2432,10 @@ try
24262432
if (dns_cache_updater)
24272433
dns_cache_updater->start();
24282434

2435+
ObjectStorageListObjectsCache::instance().setMaxSizeInBytes(server_settings[ServerSetting::object_storage_list_objects_cache_size]);
2436+
ObjectStorageListObjectsCache::instance().setMaxCount(server_settings[ServerSetting::object_storage_list_objects_cache_max_entries]);
2437+
ObjectStorageListObjectsCache::instance().setTTL(server_settings[ServerSetting::object_storage_list_objects_cache_ttl]);
2438+
24292439
auto replicas_reconnector = ReplicasReconnector::init(global_context);
24302440

24312441
#if USE_PARQUET

src/Access/Common/AccessType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ enum class AccessType : uint8_t
185185
M(SYSTEM_DROP_FORMAT_SCHEMA_CACHE, "SYSTEM DROP FORMAT SCHEMA CACHE, DROP FORMAT SCHEMA CACHE", GLOBAL, SYSTEM_DROP_CACHE) \
186186
M(SYSTEM_DROP_S3_CLIENT_CACHE, "SYSTEM DROP S3 CLIENT, DROP S3 CLIENT CACHE", GLOBAL, SYSTEM_DROP_CACHE) \
187187
M(SYSTEM_DROP_PARQUET_METADATA_CACHE, "SYSTEM DROP PARQUET METADATA CACHE", GLOBAL, SYSTEM_DROP_CACHE) \
188+
M(SYSTEM_DROP_OBJECT_STORAGE_LIST_OBJECTS_CACHE, "SYSTEM DROP OBJECT STORAGE LIST OBJECTS CACHE", GLOBAL, SYSTEM_DROP_CACHE) \
188189
M(SYSTEM_DROP_CACHE, "DROP CACHE", GROUP, SYSTEM) \
189190
M(SYSTEM_RELOAD_CONFIG, "RELOAD CONFIG", GLOBAL, SYSTEM_RELOAD) \
190191
M(SYSTEM_RELOAD_USERS, "RELOAD USERS", GLOBAL, SYSTEM_RELOAD) \

src/Common/ProfileEvents.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,10 @@ The server successfully detected this situation and will download merged part fr
10431043
M(DistributedConnectionReconnectCount, "Number of reconnects to other servers done during distributed query execution. It can happen when a stale connection has been acquired from connection pool", ValueType::Number) \
10441044
M(ParquetMetaDataCacheHits, "Number of times the read from filesystem cache hit the cache.", ValueType::Number) \
10451045
M(ParquetMetaDataCacheMisses, "Number of times the read from filesystem cache miss the cache.", ValueType::Number) \
1046+
M(ObjectStorageListObjectsCacheHits, "Number of times object storage list objects operation hit the cache.", ValueType::Number) \
1047+
M(ObjectStorageListObjectsCacheMisses, "Number of times object storage list objects operation miss the cache.", ValueType::Number) \
1048+
M(ObjectStorageListObjectsCacheExactMatchHits, "Number of times object storage list objects operation hit the cache with an exact match.", ValueType::Number) \
1049+
M(ObjectStorageListObjectsCachePrefixMatchHits, "Number of times object storage list objects operation miss the cache using prefix matching.", ValueType::Number) \
10461050

10471051
#ifdef APPLY_FOR_EXTERNAL_EVENTS
10481052
#define APPLY_FOR_EVENTS(M) APPLY_FOR_BUILTIN_EVENTS(M) APPLY_FOR_EXTERNAL_EVENTS(M)

src/Common/TTLCachePolicy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ class TTLCachePolicy : public ICachePolicy<Key, Mapped, HashFunction, WeightFunc
271271
return res;
272272
}
273273

274-
private:
274+
protected:
275275
using Cache = std::unordered_map<Key, MappedPtr, HashFunction>;
276276
Cache cache;
277-
277+
private:
278278
/// TODO To speed up removal of stale entries, we could also add another container sorted on expiry times which maps keys to iterators
279279
/// into the cache. To insert an entry, add it to the cache + add the iterator to the sorted container. To remove stale entries, do a
280280
/// binary search on the sorted container and erase all left of the found key.

src/Core/ServerSettings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
10651065
)", 0) \
10661066
DECLARE(Float, distributed_cache_keep_up_free_connections_ratio, 0.1f, "Soft limit for number of active connection distributed cache will try to keep free. After the number of free connections goes below distributed_cache_keep_up_free_connections_ratio * max_connections, connections with oldest activity will be closed until the number goes above the limit.", 0) \
10671067
DECLARE(UInt64, input_format_parquet_metadata_cache_max_size, 500000000, "Maximum size of parquet file metadata cache", 0) \
1068+
DECLARE(UInt64, object_storage_list_objects_cache_size, 500000000, "Maximum size of ObjectStorage list objects cache in bytes. Zero means disabled.", 0) \
1069+
DECLARE(UInt64, object_storage_list_objects_cache_max_entries, 1000, "Maximum size of ObjectStorage list objects cache in entries. Zero means disabled.", 0) \
1070+
DECLARE(UInt64, object_storage_list_objects_cache_ttl, 3600, "Time to live of records in ObjectStorage list objects cache in seconds. Zero means unlimited", 0)
1071+
10681072
// clang-format on
10691073

10701074
/// If you add a setting which can be updated at runtime, please update 'changeable_settings' map in dumpToSystemServerSettingsColumns below

src/Core/Settings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6865,6 +6865,9 @@ Default number of buckets for distributed shuffle-hash-join.
68656865
)", EXPERIMENTAL) \
68666866
DECLARE(UInt64, distributed_plan_default_reader_bucket_count, 8, R"(
68676867
Default number of tasks for parallel reading in distributed query. Tasks are spread across between replicas.
6868+
)", EXPERIMENTAL) \
6869+
DECLARE(Bool, use_object_storage_list_objects_cache, false, R"(
6870+
Cache the list of objects returned by list objects calls in object storage
68686871
)", EXPERIMENTAL) \
68696872
DECLARE(Bool, distributed_plan_optimize_exchanges, true, R"(
68706873
Removes unnecessary exchanges in distributed query plan. Disable it for debugging.

src/Core/SettingsChangesHistory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory()
173173
{"parallel_hash_join_threshold", 0, 0, "New setting"},
174174
{"function_date_trunc_return_type_behavior", 1, 0, "Change the result type for dateTrunc function for DateTime64/Date32 arguments to DateTime64/Date32 regardless of time unit to get correct result for negative values"},
175175
/// Release closed. Please use 25.5
176+
// Altinity Antalya modifications atop of 25.2
177+
{"object_storage_cluster", "", "", "New setting"},
178+
{"object_storage_max_nodes", 0, 0, "New setting"},
179+
{"use_object_storage_list_objects_cache", true, false, "New setting."},
176180
});
177181
addSettingsChanges(settings_changes_history, "25.3",
178182
{

src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class AzureObjectStorage : public IObjectStorage
3535
const String & description_,
3636
const String & common_key_prefix_);
3737

38+
bool supportsListObjectsCache() override { return true; }
39+
3840
void listObjects(const std::string & path, RelativePathsWithMetadata & children, size_t max_keys) const override;
3941

4042
/// Sanitizer build may crash with max_keys=1; this looks like a false positive.

src/Disks/ObjectStorages/IObjectStorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class IObjectStorage
317317
#endif
318318

319319

320+
virtual bool supportsListObjectsCache() { return false; }
321+
320322
private:
321323
mutable std::mutex throttlers_mutex;
322324
ThrottlerPtr remote_read_throttler;

src/Disks/ObjectStorages/S3/S3ObjectStorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class S3ObjectStorage : public IObjectStorage
6161

6262
ObjectStorageType getType() const override { return ObjectStorageType::S3; }
6363

64+
bool supportsListObjectsCache() override { return true; }
65+
6466
bool exists(const StoredObject & object) const override;
6567

6668
std::unique_ptr<ReadBufferFromFileBase> readObject( /// NOLINT

0 commit comments

Comments
 (0)