[ 
https://issues.apache.org/jira/browse/CASSSIDECAR-475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18089586#comment-18089586
 ] 

Bianca Stanciu commented on CASSSIDECAR-475:
--------------------------------------------

Hi, I've opened the PR with the fix for this issue: 
[https://github.com/apache/cassandra-sidecar/pull/365/changes] 
I've tested it and added test coverage as well

> Restore job fails with "Keyspace does not exist" for keyspaces created with 
> quoted mixed-case names
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CASSSIDECAR-475
>                 URL: https://issues.apache.org/jira/browse/CASSSIDECAR-475
>             Project: Sidecar for Apache Cassandra
>          Issue Type: Bug
>          Components: Client
>            Reporter: Bianca Stanciu
>            Assignee: Bianca Stanciu
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {{== Background ==}}
> {{}}
> Cassandra CQL allows keyspace names to be defined as quoted identifiers, which
> preserves their exact casing (e.g. CREATE KEYSPACE “MyKeyspace”).
> The DataStax Java Driver ({*}com.datastax.driver.core.Metadata{*}) stores 
> such keyspaces with their case-preserved name internally. When querying the 
> Driver’s Metadata API, the argument must also be quoted for the Driver to 
> perform a case-sensitive lookup. Without quoting, the Driver treats the 
> argument as a case-insensitive identifier, normalizes it to
> lowercase, and fails to find the keyspace.
> == Problem ==
> A restore job targeting a keyspace created with a quoted mixed-case name (e.g.
> “MyKeyspace”) fails with “Keyspace does not exist” during SSTable range 
> validation,
> even though the keyspace is present in the cluster.
> == Root Cause ==
> The keyspace name flows through the restore pipeline as a raw unquoted string:
>  
> {code:java}
>   RestoreJob.java:94      → .keyspace(row.getString(“keyspace_name”))
>   RestoreSlice.java:219   → builder.keyspace(restoreJob.keyspaceName)
>   RestoreRangeTask.java:484 → 
> localTokenRangesProvider.localTokenRanges(range.keyspace())
>   CachedLocalTokenRanges.java:107 → metadata.getKeyspace(keyspace)  // no 
> quoting{code}
>  
> The Driver normalizes the raw string to lowercase, finds no match, returns 
> null.
> {code:java}
> Caused by: java.util.NoSuchElementException: Keyspace does not exist. 
> keyspace: MyKeyspace
>   at CachedLocalTokenRanges.localTokenRanges(CachedLocalTokenRanges.java:109)
>   at 
> LocalTokenRangesProvider.localTokenRanges(LocalTokenRangesProvider.java:39)
>   at RestoreRangeTask.removeOutOfRangeSSTables(RestoreRangeTask.java:484)
>   at RestoreRangeTask.validateFilesAction(RestoreRangeTask.java:450)
> ...{code}
> {{== Steps to Reproduce ==}}
> 1. Create a Cassandra keyspace using a quoted mixed-case identifier:
>      CREATE KEYSPACE “MyKeyspace” WITH replication = \{...};
>      CREATE TABLE “MyKeyspace”.“MyTable” (....);
> 2. Submit a Sidecar restore job targeting keyspace “MyKeyspace”.
> 3. Observe the restore range task failing during SSTable validation with:
>      “Keyspace does not exist. keyspace: MyKeyspace”
> A patch is ready and a PR can be submitted for review upon ticket approval.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to