Skip to content

CASSANDRA-20389 prevent too long table names not fitting file names#4325

Closed
k-rus wants to merge 2 commits intoapache:cassandra-5.0from
k-rus:rf-5.0-20389-long-table-name
Closed

CASSANDRA-20389 prevent too long table names not fitting file names#4325
k-rus wants to merge 2 commits intoapache:cassandra-5.0from
k-rus:rf-5.0-20389-long-table-name

Conversation

@k-rus
Copy link
Copy Markdown
Contributor

@k-rus k-rus commented Aug 20, 2025

The length of table names was not controlled. This is likely due to confusion between validation functions with similar names. As result creating a table with too long name led to the too long file name exception during the table creation.

This commit adds a validation of table name lengths to avoid the too long file name errors. The validation length is based on how the table name is used to create file/directory name and needs to be exact to prevent the too long file name exception, but allow all other table names, which don't lead to the too long file name exception. Since this limit is different from the existing name length limit of 48 characters, the validation of lengths is separated from the common validation function, which checks for empty name and valid characters. This separation also allows to be specific with errors in number of cases.

Note that there will be more PRs with more cases for different name length:

  • Index names participate in file names together with index meta information such as index type, version and includes optional parameters, thus the length will vary on exact index created.

New constants are added for the table name length limit and for the file name length limit.
Two similar validation functions are replaced with one to avoid confusion. Name related constants are stored in the same utility class.

Table name related code are moved into methods in TableMetadata class, so their semantics are more clear and to allow reuse, e.g., in asserting the table name length constant.
Tests are added for the long table names and non-alphanumeric names.

Keyspace name validation function is shared between two classes and a unit test of it is added.

Other changes in this commit:

  • Add git-ignoring VS code generated files

patch by Ruslan Fomkin; reviewed by Piotr Kołaczkowski, Dmitry Konstantinov, Maxwell Guo for CASSANDRA-20389

@k-rus k-rus changed the base branch from trunk to cassandra-5.0 August 20, 2025 09:29
@k-rus k-rus force-pushed the rf-5.0-20389-long-table-name branch from 09e1ea5 to c8de392 Compare August 20, 2025 09:37
@k-rus k-rus marked this pull request as draft August 21, 2025 09:24
@k-rus k-rus force-pushed the rf-5.0-20389-long-table-name branch from 7644195 to ccaeb08 Compare August 25, 2025 08:43
@k-rus k-rus marked this pull request as ready for review August 25, 2025 09:07
@k-rus
Copy link
Copy Markdown
Contributor Author

k-rus commented Aug 26, 2025

@k-rus k-rus force-pushed the rf-5.0-20389-long-table-name branch from 402b31f to d5a85ae Compare September 1, 2025 16:00
Fixes CASSANDRA-20389

The length of table names was not controlled. This is likely due to
confusion between validation methods with similar names. As result
creating tables with too long names led to the too long file name
exceptions during table creations.

This commit adds a validation of table name lengths to avoid the too
long file name errors. The validation length is based on how the table
name is used to create file/directory names, and needs to be exact to
prevent the too long file name exception, but allow all other table
names, which didn't lead to the too long file name exception. This
length limit is different from the existing name length limit of 48
characters used by common validation functions.

Thus, this commit moves out the length validation from the validation
methods into a separate length validation method, so the errors on
names are more specific. The non-length validation methods combined
into a single method, which checks for empty names and valid characters.

New constants are added for the length limits.

Table name related code are moved into methods in TableMetadata class,
so their semantics are more clear and to allow reuse, e.g., in
asserting the table name length constant.
Tests are added for the long table names and non-alphanumeric names.

Keyspace name validation function is now shared between two classes and
a unit test of it is added.

Patch by Ruslan Fomkin; reviewed by Piotr Kołaczkowski, Dmitry
Konstantinov, Maxwell Guo for CASSANDRA-20389
@k-rus k-rus force-pushed the rf-5.0-20389-long-table-name branch from d5a85ae to 0bf8eaf Compare September 5, 2025 08:35
@k-rus
Copy link
Copy Markdown
Contributor Author

k-rus commented Sep 11, 2025

Merged

@k-rus k-rus closed this Sep 11, 2025
@k-rus k-rus deleted the rf-5.0-20389-long-table-name branch September 11, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants