Skip to content

Commit

Permalink
throw more informative error when fail to parse sstable generation
Browse files Browse the repository at this point in the history
since scylla 5.4, the sstables are named with a uuid-based identifier
instead of integer-based one. so the java tools inherited from cassandra
3.x branch do not support it, and throw an
`UnsupportedOperationException` when parsing a sstable name with the
integer-based generation. like:

```console
$ sstablemetadata me-3gbp_1glu_4e6g020ns4px173el0-big-Data.db
Exception in thread "main" java.lang.NumberFormatException: For input string: "3gbp_1glu_4e6g020ns4px173el0"
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:652)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:280)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:228)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:217)
        at org.apache.cassandra.tools.SSTableMetadataViewer.main(SSTableMetadataViewer.java:150)
```

the user experience is poor when seeing this exception. so let's throw
a better exception, so the new output looks like:

```console
$ sstablemetadata me-3gbr_0y9h_03n682utcozh4xc6c7-big-Data.db
Exception in thread "main" java.lang.UnsupportedOperationException: SSTable 'me-3gbr_0y9h_03n682utcozh4xc6c7-big-Data.db' is using the UUID-based identifier, and hence should be openned using 'scylla sstable' commands
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:295)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:228)
        at org.apache.cassandra.io.sstable.Descriptor.fromFilename(Descriptor.java:217)
        at org.apache.cassandra.tools.SSTableMetadataViewer.main(SSTableMetadataViewer.java:150)
```

Fixes scylladb#360
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
  • Loading branch information
tchaikov committed Dec 11, 2023
1 parent 26f5f71 commit 5bf8d82
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/java/org/apache/cassandra/io/sstable/Descriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,22 @@ public static Pair<Descriptor, String> fromFilename(File directory, String name,
}

// generation
int generation = Integer.parseInt(nexttok);
int generation;
try
{
// since Scylla 5.4, the SStable started using UUID v1 identifier
// instead of sequence of integers. but C* 3.x does not support the
// former. let's direct user to use the native tools of
// `scylla sstable` which is builtin in the scylla executable,
generation = Integer.parseInt(nexttok);
}
catch (NumberFormatException e)
{
throw new UnsupportedOperationException("SSTable '" + name
+ "' is using the UUID-based identifier, "
+ "and hence should be openned using "
+ "'scylla sstable' commands.");
}

// version
nexttok = tokenStack.pop();
Expand Down

0 comments on commit 5bf8d82

Please sign in to comment.