cube-js/cube · critical

impossible

Error message

impossible

What it means

An internal invariant panic in write_to_files_by_keys: the closure that picks which output file each record row should be written to during partition splitting must always return either a writer or a Next marker; if the loop exhausts all files without matching, the code concludes an impossible state and panics. It indicates a bug in split_single_partition's file-boundary logic, not user error.

Source

Thrown at rust/cubestore/cubestore/src/store/compaction.rs:1431

        ) > Ordering::Equal
        {
            *row_counts.last_mut().unwrap() += b.num_rows();
            return WriteBatchTo::Current;
        }
        for i in 0..b.num_rows() {
            if cmp_partition_key(key_size, keys[next_key].values().as_slice(), b.columns(), i)
                <= Ordering::Equal
            {
                *row_counts.last_mut().unwrap() += i;
                row_counts.push(0);

                next_key += 1;
                return WriteBatchTo::Next {
                    rows_for_current: i,
                };
            }
        }
        panic!("impossible")
    };
    let num_files = files.len();
    write_to_files_impl(records, store, files, table, pick_writer).await?;

    let mut row_counts: Vec<usize> = take(row_counts.lock().unwrap().as_mut());
    assert!(
        row_counts.len() <= num_files,
        "{} <= {}",
        row_counts.len(),
        num_files
    );
    row_counts.resize(num_files, 0);
    Ok(row_counts)
}

/// One chunk file produced by `write_chunks_split_into_children`: which child (index into the
/// ordered children list) it belongs to, the temp file it was written to, its row count and the
/// min/max sort-key rows. Empty children yield an entry with `num_rows == 0`.

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Upgrade CubeStore to the latest version (likely a fixed internal bug)
  2. Reduce the affected partition's data or re-run compaction to see if it reproduces
  3. Collect the partition/table identifiers and file a bug report with logs
  4. Restore the affected partition from a backup if metadata is corrupted
Defensive patterns

Strategy: try-catch

Try / catch

// panic aborts the process; supervise and retry, escalating after repeated failures
supervisor: on cubestored crash, capture logs; if panic 'impossible' at compaction.rs occurs >=3 times on the same partition, quarantine the partition and alert.

Prevention

When it happens

Trigger: split_single_partition computing row/file boundaries such that a record's key falls beyond all precomputed writer ranges while iterating records in write_to_files_by_keys.

Common situations: Encountered only during compaction/partition splitting with an internal logic bug, corrupted partition metadata, or a version mismatch between metadata and data files; effectively unreachable for correct inputs.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/0ee7cf751cb941ba. Report an issue: GitHub.