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

Paging with DISTINCT and IN can throw ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 2.1.10, 2.2.2
    • Legacy/CQL
    • None
    • Normal

    Description

      The ctor of SliceQueryPager has the following code:

              if (state != null)
              {
                  // The only case where this could be a non-CellName Composite is if it's Composites.EMPTY, but that's not
                  // valid for PagingState.cellName, so we can safely cast to CellName.
                  lastReturned = (CellName) cfm.comparator.fromByteBuffer(state.cellName);
                  restoreState(state.remaining, true);
              }
      

      The assumption that we can only get a CellName is invalid however. When using a MultiPartitionPager (so when the query has a IN on the partition key), it's possible for a page to stop at the end of one of the underlying pager, and for that pager to be exhausted. If that's the case, the PagingState returned will have the partition key of the next key to retrieve, but a null cellname (since we haven't started to query that next key). When the next page is queried, that PagingState will trigger a ClassCastException.

      The following dtest reproduces this problem.

      Attachments

        Issue Links

          Activity

            People

              slebresne Sylvain Lebresne
              slebresne Sylvain Lebresne
              Sylvain Lebresne
              Benjamin Lerer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: