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

Metadata Loss caused by unchecked rename column when upgrading from 2.x to 3.0.29

    XMLWordPrintableJSON

Details

    • Correctness - Unrecoverable Corruption / Loss
    • Normal
    • Low Hanging Fruit
    • Adhoc Test
    • All
    • None
    • Hide

      CI

      Show
      CI

    Description

      After migrating data from 2.1.22 (released 2022-06-17) to 3.0.29 (released 2023-05-05), if user performs a rename operation to rename the primary key to an existing column, it will succeed, and the original column will get lost permanently.

      Reproduce

      Start up single cassandra node 2.1.22

      Start up cassandra-cli

      bin/cassandra-cli 

      Execute the following commands using cassandra-cli interface

      create keyspace test with strategy_options = {replication_factor:1} and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';
      
      use test;
      
      create column family foos 
      with column_type = 'Standard' 
      and comparator = 'BytesType'
      and key_validation_class = 'UTF8Type' 
      and column_metadata = [{column_name: '2f', validation_class: 'UTF8Type'}]; 

      Stop the daemon

      bin/nodetool -h ::FFFF:127.0.0.1 stopdaemon 

      Upgrade, start up new version, start up cqlsh with bin/cqlsh

      cqlsh> desc test.foos ;
      CREATE TABLE test.foos (
          key text PRIMARY KEY,
          "2f" text
      ) WITH COMPACT STORAGE
          AND bloom_filter_fp_chance = 0.01
          AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
          AND comment = ''
          AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
          AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
          AND crc_check_chance = 1.0
          AND dclocal_read_repair_chance = 0.1
          AND default_time_to_live = 0
          AND gc_grace_seconds = 864000
          AND max_index_interval = 2048
          AND memtable_flush_period_in_ms = 0
          AND min_index_interval = 128
          AND read_repair_chance = 0.0
          AND speculative_retry = 'NONE';
      
      cqlsh> ALTER TABLE test.foos RENAME key TO "2f";
      cqlsh> desc test.foos ;
      CREATE TABLE test.foos (
          "2f" text PRIMARY KEY
      ) WITH COMPACT STORAGE
          AND bloom_filter_fp_chance = 0.01
          AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
          AND comment = ''
          AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
          AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
          AND crc_check_chance = 1.0
          AND dclocal_read_repair_chance = 0.1
          AND default_time_to_live = 0
          AND gc_grace_seconds = 864000
          AND max_index_interval = 2048
          AND memtable_flush_period_in_ms = 0
          AND min_index_interval = 128
          AND read_repair_chance = 0.0
          AND speculative_retry = 'NONE';
      
      cqlsh> SELECT * FROM test.foos ;
       2f
      ----
      
      (0 rows) 

      Root Cause

      The root cause is a missing check for the existing column when the table comparator from the old version is BytesType.

      I have uploaded the data dir, use it to start up 3.0.29 and execute the commands will reproduce this bug.

      Attachments

        1. data.tar.gz
          124 kB
          Ke Han
        2. signature.asc
          0.5 kB
          miklosovic
        3. signature.asc
          0.5 kB
          miklosovic
        4. signature.asc
          0.5 kB
          miklosovic
        5. signature.asc
          0.5 kB
          miklosovic
        6. signature.asc
          0.5 kB
          miklosovic

        Activity

          People

            kehan5800 Ke Han
            kehan5800 Ke Han
            Ke Han
            Stefan Miklosovic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

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