Fix LegacyLayout to have same behavior as 2.x when handling unknown column names

patch by Cameron Zemek; reviewed by Mick Semb Wever for CASSANDRA-15081
This commit is contained in:
Cameron Zemek 2019-11-01 15:36:03 +10:00 committed by Mick Semb Wever
parent 9391ffaf01
commit 31a86f891b
No known key found for this signature in database
GPG Key ID: E91335D77E3E87CB
11 changed files with 26 additions and 5 deletions

View File

@ -1,4 +1,5 @@
3.11.6
* Fix LegacyLayout to have same behavior as 2.x when handling unknown column names (CASSANDRA-15081)
Merged from 3.0:
* Minimize clustering values in metadata collector (CASSANDRA-15400)
* Avoid over-trimming of results in mixed mode clusters (CASSANDRA-15405)

View File

@ -1213,10 +1213,10 @@ public abstract class LegacyLayout
// but we don't do this here and re-throw the exception because the calling code sometimes has to know
// about this happening. This does mean code calling this method should handle this case properly.
if (!metadata.ksName.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME) && metadata.getDroppedColumnDefinition(e.columnName) == null)
throw new IllegalStateException(String.format("Got cell for unknown column %s in sstable of %s.%s: " +
"This suggest a problem with the schema which doesn't list " +
"this column. Even if that column was dropped, it should have " +
"been listed as such", metadata.ksName, metadata.cfName, UTF8Type.instance.compose(e.columnName)), e);
logger.warn(String.format("Got cell for unknown column %s in sstable of %s.%s: " +
"This suggest a problem with the schema which doesn't list " +
"this column. Even if that column was dropped, it should have " +
"been listed as such", metadata.ksName, metadata.cfName, UTF8Type.instance.compose(e.columnName)), e);
throw e;
}

View File

@ -0,0 +1,8 @@
Digest.sha1
Data.db
Statistics.db
Summary.db
Index.db
TOC.txt
Filter.db
CompressionInfo.db

View File

@ -110,7 +110,7 @@ public class LegacySSTableTest
public static void defineSchema() throws ConfigurationException
{
String scp = System.getProperty(LEGACY_SSTABLE_PROP);
Assert.assertNotNull("System property " + LEGACY_SSTABLE_ROOT + " not set", scp);
Assert.assertNotNull("System property " + LEGACY_SSTABLE_PROP + " not set", scp);
LEGACY_SSTABLE_ROOT = new File(scp).getAbsoluteFile();
Assert.assertTrue("System property " + LEGACY_SSTABLE_ROOT + " does not specify a directory", LEGACY_SSTABLE_ROOT.isDirectory());
@ -436,6 +436,17 @@ public class LegacySSTableTest
assertExpectedRowsWithDroppedCollection(false);
}
@Test
public void test15081() throws Exception
{
QueryProcessor.executeInternal("CREATE TABLE legacy_tables.legacy_ka_15081 (id int primary key, payload text)");
loadLegacyTable("legacy_%s_15081%s", "ka", "");
UntypedResultSet results =
QueryProcessor.executeOnceInternal(
String.format("SELECT * FROM legacy_tables.legacy_ka_15081"));
assertRows(results, row(1, "hello world"));
}
@Test
public void testReadingLegacyTablesWithIllegalCellNames() throws Exception {
/**