Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename dns_cache_max_size to dns_cache_max_entries #60500

Merged
merged 10 commits into from
Mar 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,17 @@ Type: Bool
Default: 0


## dns_cache_max_size
## dns_cache_max_entries

Internal DNS cache max size in bytes.
Internal DNS cache max entries.
allmazz marked this conversation as resolved.
Show resolved Hide resolved

:::note
ClickHouse also has a reverse cache, so the actual memory usage could be twice as much.
:::

Type: UInt64

Default: 1048576
Default: 10000


## dns_cache_update_period
Expand Down
2 changes: 1 addition & 1 deletion docs/en/operations/system-tables/dns_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ Result:
**See also**

- [disable_internal_dns_cache setting](../../operations/server-configuration-parameters/settings.md#disable_internal_dns_cache)
- [dns_cache_max_size setting](../../operations/server-configuration-parameters/settings.md#dns_cache_max_size)
- [dns_cache_max_entries setting](../../operations/server-configuration-parameters/settings.md#dns_cache_max_entries)
- [dns_cache_update_period setting](../../operations/server-configuration-parameters/settings.md#dns_cache_update_period)
- [dns_max_consecutive_failures setting](../../operations/server-configuration-parameters/settings.md#dns_max_consecutive_failures)
2 changes: 1 addition & 1 deletion docs/en/sql-reference/statements/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RELOAD FUNCTION [ON CLUSTER cluster_name] function_name

Clears ClickHouse’s internal DNS cache. Sometimes (for old ClickHouse versions) it is necessary to use this command when changing the infrastructure (changing the IP address of another ClickHouse server or the server used by dictionaries).

For more convenient (automatic) cache management, see disable_internal_dns_cache, dns_cache_max_size, dns_cache_update_period parameters.
For more convenient (automatic) cache management, see disable_internal_dns_cache, dns_cache_max_entries, dns_cache_update_period parameters.

## DROP MARK CACHE

Expand Down
2 changes: 1 addition & 1 deletion programs/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ try
}
else
{
DNSResolver::instance().setCacheMaxSize(server_settings.dns_cache_max_size);
DNSResolver::instance().setCacheMaxEntries(server_settings.dns_cache_max_entries);

/// Initialize a watcher periodically updating DNS cache
dns_cache_updater = std::make_unique<DNSCacheUpdater>(
Expand Down
6 changes: 3 additions & 3 deletions src/Common/DNSResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ void DNSResolver::setDisableCacheFlag(bool is_disabled)
impl->disable_cache = is_disabled;
}

void DNSResolver::setCacheMaxSize(const UInt64 cache_max_size)
void DNSResolver::setCacheMaxEntries(const UInt64 cache_max_entries)
{
impl->cache_address.setMaxSizeInBytes(cache_max_size);
impl->cache_host.setMaxSizeInBytes(cache_max_size);
impl->cache_address.setMaxSizeInBytes(cache_max_entries);
rschu1ze marked this conversation as resolved.
Show resolved Hide resolved
impl->cache_host.setMaxSizeInBytes(cache_max_entries);
}

String DNSResolver::getHostName()
Expand Down
4 changes: 2 additions & 2 deletions src/Common/DNSResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class DNSResolver : private boost::noncopyable
/// Disables caching
void setDisableCacheFlag(bool is_disabled = true);

/// Set a limit of cache size in bytes
void setCacheMaxSize(const UInt64 cache_max_size);
/// Set a limit of entries in cache
void setCacheMaxEntries(const UInt64 cache_max_entries);

/// Drops all caches
void dropCache();
Expand Down
2 changes: 1 addition & 1 deletion src/Core/ServerSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace DB
M(UInt64, mmap_cache_size, DEFAULT_MMAP_CACHE_MAX_SIZE, "A cache for mmapped files.", 0) \
\
M(Bool, disable_internal_dns_cache, false, "Disable internal DNS caching at all.", 0) \
M(UInt64, dns_cache_max_size, (1024 * 1024), "Internal DNS cache max size in bytes.", 0) \
M(UInt64, dns_cache_max_entries, 10000, "Internal DNS cache max entries.", 0) \
M(Int32, dns_cache_update_period, 15, "Internal DNS cache update period in seconds.", 0) \
M(UInt32, dns_max_consecutive_failures, 10, "Max DNS resolve failures of a hostname before dropping the hostname from ClickHouse DNS cache.", 0) \
\
Expand Down
Loading