From 658c79182d1acd165bd0a213cb544a3e839b0c90 Mon Sep 17 00:00:00 2001 From: nivy Date: Fri, 31 Jul 2026 15:28:00 -0700 Subject: [PATCH] Do not make DNS lookup when querying system_views.clients for hostname column by removing it By removing hostname column we are on par with nodetool clientstats patch by Nivy Kani; reviewed by Stefan Miklosovic, Brandon Williams for CASSANDRA-21539 --- CHANGES.txt | 1 + .../cassandra/pages/new/virtualtables.adoc | 19 +++++++++---------- .../cassandra/db/virtual/ClientsTable.java | 3 --- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 42ff49dc28..ec4d32b583 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0.22 + * Do not make DNS lookup when querying system_views.clients for hostname column by removing it (CASSANDRA-21539) * Fix memtable on-heap accounting drift in BTree.update and BTreeRow.merge (CASSANDRA-21472) diff --git a/doc/modules/cassandra/pages/new/virtualtables.adoc b/doc/modules/cassandra/pages/new/virtualtables.adoc index b18ba31316..a6f324bce4 100644 --- a/doc/modules/cassandra/pages/new/virtualtables.adoc +++ b/doc/modules/cassandra/pages/new/virtualtables.adoc @@ -107,15 +107,15 @@ We shall discuss some of the virtual tables in more detail next. The `clients` virtual table lists all active connections (connected clients) including their ip address, port, connection stage, driver -name, driver version, hostname, protocol version, request count, ssl +name, driver version, protocol version, request count, ssl enabled, ssl protocol and user name: .... cqlsh:system_views> select * from system_views.clients; - address | port | connection_stage | driver_name | driver_version | hostname | protocol_version | request_count | ssl_cipher_suite | ssl_enabled | ssl_protocol | username ------------+-------+------------------+-------------+----------------+-----------+------------------+---------------+------------------+-------------+--------------+----------- - 127.0.0.1 | 50628 | ready | null | null | localhost | 4 | 55 | null | False | null | anonymous - 127.0.0.1 | 50630 | ready | null | null | localhost | 4 | 70 | null | False | null | anonymous + address | port | connection_stage | driver_name | driver_version | protocol_version | request_count | ssl_cipher_suite | ssl_enabled | ssl_protocol | username +-----------+-------+------------------+-------------+----------------+------------------+---------------+------------------+-------------+--------------+----------- + 127.0.0.1 | 50628 | ready | null | null | 4 | 55 | null | False | null | anonymous + 127.0.0.1 | 50630 | ready | null | null | 4 | 70 | null | False | null | anonymous (2 rows) .... @@ -139,7 +139,6 @@ CREATE TABLE system_views.clients ( connection_stage text, driver_name text, driver_version text, - hostname text, port int, protocol_version int, request_count bigint, @@ -401,10 +400,10 @@ cqlsh> SELECT * FROM clients LIMIT 2; [source, cql] ---- - address | port | connection_stage | driver_name | driver_version | hostname | protocol_version | request_count | ssl_cipher_suite | ssl_enabled | ssl_protocol | username ------------+-------+------------------+------------------------+----------------+-----------+------------------+---------------+------------------+-------------+--------------+----------- - 127.0.0.1 | 37308 | ready | DataStax Python Driver | 3.21.0.post0 | localhost | 4 | 17 | null | False | null | anonymous - 127.0.0.1 | 37310 | ready | DataStax Python Driver | 3.21.0.post0 | localhost | 4 | 8 | null | False | null | anonymous + address | port | connection_stage | driver_name | driver_version | protocol_version | request_count | ssl_cipher_suite | ssl_enabled | ssl_protocol | username +-----------+-------+------------------+------------------------+----------------+------------------+---------------+------------------+-------------+--------------+----------- + 127.0.0.1 | 37308 | ready | DataStax Python Driver | 3.21.0.post0 | 4 | 17 | null | False | null | anonymous + 127.0.0.1 | 37310 | ready | DataStax Python Driver | 3.21.0.post0 | 4 | 8 | null | False | null | anonymous (2 rows) ---- diff --git a/src/java/org/apache/cassandra/db/virtual/ClientsTable.java b/src/java/org/apache/cassandra/db/virtual/ClientsTable.java index 40e175bebb..eb58d94c0e 100644 --- a/src/java/org/apache/cassandra/db/virtual/ClientsTable.java +++ b/src/java/org/apache/cassandra/db/virtual/ClientsTable.java @@ -29,7 +29,6 @@ final class ClientsTable extends AbstractVirtualTable { private static final String ADDRESS = "address"; private static final String PORT = "port"; - private static final String HOSTNAME = "hostname"; private static final String USERNAME = "username"; private static final String CONNECTION_STAGE = "connection_stage"; private static final String PROTOCOL_VERSION = "protocol_version"; @@ -48,7 +47,6 @@ final class ClientsTable extends AbstractVirtualTable .partitioner(new LocalPartitioner(InetAddressType.instance)) .addPartitionKeyColumn(ADDRESS, InetAddressType.instance) .addClusteringColumn(PORT, Int32Type.instance) - .addRegularColumn(HOSTNAME, UTF8Type.instance) .addRegularColumn(USERNAME, UTF8Type.instance) .addRegularColumn(CONNECTION_STAGE, UTF8Type.instance) .addRegularColumn(PROTOCOL_VERSION, Int32Type.instance) @@ -71,7 +69,6 @@ final class ClientsTable extends AbstractVirtualTable InetSocketAddress remoteAddress = client.remoteAddress(); result.row(remoteAddress.getAddress(), remoteAddress.getPort()) - .column(HOSTNAME, remoteAddress.getHostName()) .column(USERNAME, client.username().orElse(null)) .column(CONNECTION_STAGE, client.stage().toString().toLowerCase()) .column(PROTOCOL_VERSION, client.protocolVersion())