apache/pulsar · error · RestException

compactionThreshold must be 0 or more

Error message

compactionThreshold must be 0 or more

What it means

internalSetCompactionThreshold validates the new compaction threshold before persisting namespace policies; a negative value is rejected with 412 Precondition Failed because the threshold (bytes before compaction triggers) must be zero or a positive size.

Source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2612

        } catch (RestException pfe) {
            throw pfe;
        } catch (Exception e) {
            log.error()
                    .attr("namespace", namespaceName)
                    .exception(e)
                    .log("Failed to update maxUnackedMessagesPerSubscription configuration");
            throw new RestException(e);
        }
    }

    protected void internalSetCompactionThreshold(Long newThreshold) {
        validateNamespacePolicyOperation(namespaceName, PolicyName.COMPACTION, PolicyOperation.WRITE);
        validatePoliciesReadOnlyAccess();

        try {
            if (newThreshold != null && newThreshold < 0) {
                throw new RestException(Status.PRECONDITION_FAILED,
                        "compactionThreshold must be 0 or more");
            }
            updatePolicies(namespaceName, policies -> {
                policies.compaction_threshold = newThreshold;
                return policies;
            });
            log.info()
                    .attr("namespace", namespaceName)
                    .attr("compactionThreshold", newThreshold)
                    .log("Successfully updated compactionThreshold configuration");

        } catch (RestException pfe) {
            throw pfe;
        } catch (Exception e) {
            log.error()
                    .attr("namespace", namespaceName)
                    .exception(e)
                    .log("Failed to update compactionThreshold configuration");

View on GitHub (pinned to 820761864e)

Solutions

  1. Provide a threshold of 0 or more bytes (0 disables size-threshold-based compaction)
  2. Verify the units — the value is in bytes, not MB
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2612 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/3f892a657459daf9. Report an issue: GitHub.