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

Fix concurrent addition of collection columns

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • None
    • None
    • None
    • Normal

    Description

      It is currently not safe to update the schema by adding multiple collection columns to the same table. The reason is that with collections, the comparator embeds a map of names->comparator for each collection columns (since different maps can have different key type for example). And when serialized on disk in the schema table, the comparator is serialized as a string with that map as one column. So if new collection columns are added concurrently, the addition may not be merged correctly.

      One option to fix this would be to stop serializing the names->comparator map of ColumnToCollectionType in toString(), and do one of:

      1. reconstruct that map from the information stores in the schema_columns. The downside I can see is that code-wise this may not be super clean to do.
      2. change ColumnToCollectionType so that instead of having it's own names->comparator map, to just store a point to the CFMetaData that contains it and when it needs to find the exact comparator for a collection column, it would use CFMetadata.column_metadata directly. The downside is that creating a dependency from a comparator to a CFMetadata feels a bit backward.

      Note sure what's the best solution of the two honestly.

      While probably more anecdotal, we also now allow to change the type of the comparator in some cases (for example updating to BytesType is always allowed), and doing so concurrently on multiple components of a composite comparator is also not safe for a similar reason. I'm not sure how to fix that one.

      Attachments

        Issue Links

          Activity

            People

              slebresne Sylvain Lebresne
              slebresne Sylvain Lebresne
              Sylvain Lebresne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: