apache/cassandra · error · InvalidConstraintDefinitionException

Constraints of %s are not satisfiable: %s %s %s, %s %s %s

Error message

Constraints of %s are not satisfiable: %s %s %s, %s %s %s

What it means

For a pair of ordering constraints on a column, ensureSatisfiability tests whether any value could satisfy both by evaluating each relation against the other's term. If either direction is unsatisfied (e.g. x > 10 AND x < 5), the constraints are unsatisfiable and InvalidConstraintDefinitionException is thrown listing the column, both relations, and terms.

Source

Thrown at src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionSatisfiabilityChecker.java:162

                                                                  secondRelation,
                                                                  secondTerm));
        }
        else if (firstRelation == NEQ && secondRelation == NEQ)
        {
            if (firstTerm.equals(secondTerm))
                throw new InvalidConstraintDefinitionException(format("There are duplicate constraint definitions on column '%s'.", columnMetadata.name));
        }
        else
        {
            AbstractType<?> returnType = returnType(columnMetadata);
            ByteBuffer firstTermBuffer = returnType.fromString(ParseUtils.unquote(firstTerm));
            ByteBuffer secondTermBuffer = returnType.fromString(ParseUtils.unquote(secondTerm));

            boolean firstSatisfaction = firstRelation.isSatisfiedBy(returnType, secondTermBuffer, firstTermBuffer);
            boolean secondSatisfaction = secondRelation.isSatisfiedBy(returnType, firstTermBuffer, secondTermBuffer);

            if (!firstSatisfaction || !secondSatisfaction)
                throw new InvalidConstraintDefinitionException(format("Constraints of %s are not satisfiable: %s %s %s, %s %s %s",
                                                                      constraintName,
                                                                      columnMetadata.name,
                                                                      firstRelation,
                                                                      firstTerm,
                                                                      columnMetadata.name,
                                                                      secondRelation,
                                                                      secondTerm));
        }
    }

    public static final AbstractFunctionSatisfiabilityChecker<ScalarColumnConstraint> SCALAR_SATISFIABILITY_CHECKER = new AbstractFunctionSatisfiabilityChecker<>()
    {
        @Override
        public Pair<List<ScalarColumnConstraint>, List<ScalarColumnConstraint>> categorizeConstraints(List<ColumnConstraint<?>> constraints, String functionName)
        {
            List<ScalarColumnConstraint> scalars = new LinkedList<>();
            List<ScalarColumnConstraint> notEqualScalars = new LinkedList<>();

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Correct the bound values so the range is non-empty (min < max).
  2. Check the constraint terms against actual expected data values.
  3. Compute the intended interval first, then write the constraints from it.

Example fix

// before
CREATE TABLE t (x int CHECK x > 10 AND x < 5);
// after
CREATE TABLE t (x int CHECK x > 10 AND x < 50);
Defensive patterns

Strategy: validation

Validate before calling

// sanity-check bounds form a non-empty interval before emitting DDL
if (!(minValue < maxValue))
    throw new IllegalArgumentException("Unsatisfiable range: min=" + minValue + " max=" + maxValue);

Try / catch

try {
    session.execute(schemaDdl);
} catch (InvalidRequestException e) {
    if (e.getMessage().contains("are not satisfiable")) {
        log.error("Constraints contradict each other: {}", e.getMessage());
    } else throw e;
}

Prevention

When it happens

Trigger: CREATE TABLE/ALTER TABLE with mutually contradictory bounds on a column, e.g. CHECK x > 10 AND x < 5, or bounds that exclude every possible value.

Common situations: Typos in bound values; copied constraints whose terms conflict after a column rename; automated rule merging producing inverted ranges.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ab1ff1564b8b2911. Report an issue: GitHub.