Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Correctness - Unrecoverable Corruption / Loss
-
Critical
-
Low Hanging Fruit
-
Fuzz Test
-
All
-
None
-
Description
When we snapshot a table we create a list of CQL statements to recreate the table, this tries to include the UDT creation as well, but fails to find all UDTs!
The bug is from org.apache.cassandra.schema.TableMetadata#getReferencedUserTypes
public Set<ByteBuffer> getReferencedUserTypes() { Set<ByteBuffer> types = new LinkedHashSet<>(); columns().forEach(c -> addUserTypes(c.type, types)); return types; }
c.type maybe ReverseType, so checking for UDT fails and the UDT does not get included.
The following would show this
CREATE TYPE foo (a int); CREATE TABLE tbl (pk int, ck frozen<foo>, PRIMARY KEY(pk, ck)) WITH CLUSTERING ORDER BY (ck DESC).
Additionally, the order that the UDTs found are listed are not in correct order, they are in random hash order…. This becomes a problem when the UDTs depend on each other such as the following example
CREATE TYPE a (a int);
CREATE TYPE b (b a);
In this example you must create “a” BEFORE “b”, but with hash ordering that isn’t always true.
Utilities exist in test/unit/org/apache/cassandra/utils/CassandraGenerators.java to handle this case properly
Attachments
Issue Links
- is related to
-
CASSANDRA-19890 type system contains check for duration does not work for hidden types
- Resolved
- relates to
-
CASSANDRA-20050 User types and vectors as clustering keys in descending order are not supported but ascending are
- Resolved
- links to