You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Ling Mao (Jira)" <ji...@apache.org> on 2025/07/19 12:30:00 UTC
[jira] [Updated] (CASSANDRA-20776) getendpoints support to query by token
[ https://issues.apache.org/jira/browse/CASSANDRA-20776?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ling Mao updated CASSANDRA-20776:
---------------------------------
Description:
When working with a table whose partition key consists of multiple columns, it's not straightforward to determine the replica layout using the current *_nodetool getendpoints_* command.
A better approach is to first retrieve the token using the *_token()_* function in CQL:
{code:java}
CREATE TABLE my_users (
country text,
user_id text,
name text,
age int,
PRIMARY KEY ((country, user_id))
);
INSERT INTO my_users (country, user_id, name, age) VALUES ('us', 'jsmith', 'John Smith', 42);
SELECT token(country, user_id), country, user_id FROM my_users WHERE country = 'us' AND user_id = 'jsmith';{code}
Then, you can use the token value with:
*_./nodetool getendpoints -t schema2 my_users 84293051238921857_*
The commonly suggested command, such as: *_nodetool getendpoints cycling rank_by_year_and_name "2014:4th Tour of Beijing"_*
from DataStax documentation([1]) is problematic when the partition key contains special characters like spaces or colons (:), which can break the command syntax or lead to incorrect parsing.
Alternatively, enabling query tracing with *_TRACING ON_* is also a reliable way to observe which replicas are involved in serving the request.
References:
[1] https://docs.datastax.com/en/dse/6.9/managing/tools/nodetool/get-end-points.html
[2] https://stackoverflow.com/questions/42903926/cassandra-getendpoints-with-partition-key-has-space
[3] https://stackoverflow.com/questions/30514237/what-node-does-cassandra-store-data-on
was:
When working with a table whose partition key consists of multiple columns, it's not straightforward to determine the replica layout using the current *_nodetool getendpoints_* command.
A better approach is to first retrieve the token using the token() function in CQL:
{code:java}
CREATE TABLE my_users (
country text,
user_id text,
name text,
age int,
PRIMARY KEY ((country, user_id))
);
INSERT INTO my_users (country, user_id, name, age) VALUES ('us', 'jsmith', 'John Smith', 42);
SELECT token(country, user_id), country, user_id
FROM my_users
WHERE country = 'us' AND user_id = 'jsmith';{code}
Then, you can use the token value with:
*_./nodetool getendpoints -t schema2 my_users 84293051238921857_*
The commonly suggested command, such as:nodetool getendpoints cycling rank_by_year_and_name "2014:4th Tour of Beijing"
from DataStax documentation is problematic when the partition key contains special characters like spaces or colons (:), which can break the command syntax or lead to incorrect parsing.
Alternatively, enabling query tracing with TRACING ON is also a reliable way to observe which replicas are involved in serving the request.
> getendpoints support to query by token
> --------------------------------------
>
> Key: CASSANDRA-20776
> URL: https://issues.apache.org/jira/browse/CASSANDRA-20776
> Project: Apache Cassandra
> Issue Type: Improvement
> Components: Tool/nodetool
> Reporter: Ling Mao
> Assignee: Ling Mao
> Priority: Normal
>
> When working with a table whose partition key consists of multiple columns, it's not straightforward to determine the replica layout using the current *_nodetool getendpoints_* command.
> A better approach is to first retrieve the token using the *_token()_* function in CQL:
> {code:java}
> CREATE TABLE my_users (
> country text,
> user_id text,
> name text,
> age int,
> PRIMARY KEY ((country, user_id))
> );
> INSERT INTO my_users (country, user_id, name, age) VALUES ('us', 'jsmith', 'John Smith', 42);
> SELECT token(country, user_id), country, user_id FROM my_users WHERE country = 'us' AND user_id = 'jsmith';{code}
> Then, you can use the token value with:
> *_./nodetool getendpoints -t schema2 my_users 84293051238921857_*
> The commonly suggested command, such as: *_nodetool getendpoints cycling rank_by_year_and_name "2014:4th Tour of Beijing"_*
> from DataStax documentation([1]) is problematic when the partition key contains special characters like spaces or colons (:), which can break the command syntax or lead to incorrect parsing.
> Alternatively, enabling query tracing with *_TRACING ON_* is also a reliable way to observe which replicas are involved in serving the request.
>
> References:
> [1] https://docs.datastax.com/en/dse/6.9/managing/tools/nodetool/get-end-points.html
> [2] https://stackoverflow.com/questions/42903926/cassandra-getendpoints-with-partition-key-has-space
> [3] https://stackoverflow.com/questions/30514237/what-node-does-cassandra-store-data-on
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org