Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-20036

When snapshotting the recreate CQL does not count UDTs from reverse clustering columns

    XMLWordPrintableJSON

Details

    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

          Activity

            People

              smiklosovic Stefan Miklosovic
              dcapwell David Capwell
              Stefan Miklosovic
              David Capwell, Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m