Ruslan Fomkin created CASSANDRA-20389: -----------------------------------------
Summary: Create table fails on long table names Key: CASSANDRA-20389 URL: https://issues.apache.org/jira/browse/CASSANDRA-20389 Project: Apache Cassandra Issue Type: Bug Reporter: Ruslan Fomkin If CREATE TABLE is called with a long table name, the statement fails due to file name too long error. E.g, such test: {code:java} @Test public void testCreatingTableWithLongName() throws Throwable { String keyspace = "\"38373639353166362d3566313\""; String table = "test_create_k8yq1r75bpzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaaaaaaaa"; execute(String.format("CREATE KEYSPACE %s with replication = " + "{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", keyspace)); createTableMayThrow(String.format("CREATE TABLE %s.%s (" + "key int PRIMARY KEY," + "val int)", keyspace, table)); } {code} results in: {code:java} java.lang.RuntimeException: Failed to list files in build/test/cassandra/data/38373639353166362d3566313/test_create_k8yq1r75bpzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaaaaaaaa-1b255f4def2540a60000000000000007 at org.apache.cassandra.db.lifecycle.LogAwareFileLister.list(LogAwareFileLister.java:77) at org.apache.cassandra.db.lifecycle.LifecycleTransaction.getFiles(LifecycleTransaction.java:636) at org.apache.cassandra.db.Directories$SSTableLister.filter(Directories.java:1139) at org.apache.cassandra.db.Directories$SSTableLister.list(Directories.java:1086) at org.apache.cassandra.db.Directories$SSTableLister.list(Directories.java:1072) at org.apache.cassandra.db.Directories.lambda$getUIDGenerator$5(Directories.java:1297) at java.base/java.util.stream.AbstractPipeline.sourceSpliterator(AbstractPipeline.java:405) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496) at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459) at org.apache.cassandra.io.sstable.SequenceBasedSSTableId$Builder.generator(SequenceBasedSSTableId.java:102) at org.apache.cassandra.db.Directories.getUIDGenerator(Directories.java:1302) at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:768) at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:756) at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:747) at org.apache.cassandra.db.Keyspace.initCf(Keyspace.java:379) at org.apache.cassandra.schema.DistributedSchema.createTable(DistributedSchema.java:341) at org.apache.cassandra.schema.DistributedSchema.lambda$initializeKeyspaceInstances$6(DistributedSchema.java:213) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at org.apache.cassandra.schema.DistributedSchema.lambda$initializeKeyspaceInstances$10(DistributedSchema.java:213) at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422) at org.apache.cassandra.schema.DistributedSchema.initializeKeyspaceInstances(DistributedSchema.java:199) at org.apache.cassandra.tcm.listeners.SchemaListener.notifyInternal(SchemaListener.java:50) at org.apache.cassandra.tcm.listeners.SchemaListener.notifyPreCommit(SchemaListener.java:43) at org.apache.cassandra.tcm.log.LocalLog.notifyPreCommit(LocalLog.java:626) at org.apache.cassandra.tcm.log.LocalLog.processPendingInternal(LocalLog.java:527) at org.apache.cassandra.tcm.log.LocalLog$Async$AsyncRunnable.run(LocalLog.java:819) at org.apache.cassandra.concurrent.InfiniteLoopExecutor.loop(InfiniteLoopExecutor.java:121) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.nio.file.FileSystemException: build/test/cassandra/data/38373639353166362d3566313/test_create_k8yq1r75bpzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaaaaaaaa-1b255f4def2540a60000000000000007: File name too long at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:412) at java.base/java.nio.file.Files.newDirectoryStream(Files.java:472) at org.apache.cassandra.db.lifecycle.LogAwareFileLister.innerList(LogAwareFileLister.java:83) at org.apache.cassandra.db.lifecycle.LogAwareFileLister.list(LogAwareFileLister.java:73) {code} There is a bug in [TableMetadata|https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/schema/TableMetadata.java#L552] which calls a name validation function with expectation of checking the length. However, the correct function to use is [isValidName|https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/schema/SchemaConstants.java#L83], which validates also length, instead of [isNameValid|https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/schema/TableMetadata.java#L552], which, I guess, shouldn't be present. Fixing this table name validation bug depends if the validation is called only for new tables, or also for existing tables, when the schema is shared with another node or replica. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org