influxdata/influxdb · critical

partition template contains

Error message

partition template contains {parts} parts, which exceeds the maximum of {MAXIMUM_NUMBER_OF_TEMPLATE_PARTS} parts

What it means

partition_batch panics (via panic!) when the partition template has more parts than MAXIMUM_NUMBER_OF_TEMPLATE_PARTS. This is a programmer/config error guarded as an assertion rather than a Result, because exceeding the limit makes range encoding of keys invalid by design.

Solutions

  1. Reduce the number of parts in the partition template to at most MAXIMUM_NUMBER_OF_TEMPLATE_PARTS
  2. Validate template part count before constructing/calling partition_batch
  3. Check the value of MAXIMUM_NUMBER_OF_TEMPLATE_PARTS in core/partition/src/lib.rs to know the allowed ceiling

Example fix

// before
assert!(template.len() <= MAXIMUM_NUMBER_OF_TEMPLATE_PARTS);
let iter = partition_batch(&batch, &template);
// after
if template.len() > MAXIMUM_NUMBER_OF_TEMPLATE_PARTS {
    return Err(anyhow!("template has {} parts, max is {}", template.len(), MAXIMUM_NUMBER_OF_TEMPLATE_PARTS));
}
let iter = partition_batch(&batch, &template);
Defensive patterns

Strategy: validation

Validate before calling

if template.len() > MAXIMUM_NUMBER_OF_TEMPLATE_PARTS {
    return Err(anyhow!("partition template has {} parts; max is {}", template.len(), MAXIMUM_NUMBER_OF_TEMPLATE_PARTS));
}

Prevention

When it happens

Trigger: Calling partition_batch (or the public partition()/filter_to_partition wrappers) with a Template whose len() exceeds MAXIMUM_NUMBER_OF_TEMPLATE_PARTS, e.g. a user-supplied template string with too many '|'-separated parts.

Common situations: Server config with an overly complex partition template (e.g. many tag keys combined); misconfigured region file or query with an excessive template.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/642b175ac3c2f8d6. Report an issue: GitHub.

Appendix: source

Thrown at core/partition/src/lib.rs:62

    TagValueNotTag(String),

    /// A "catch all" error for when a formatter returns [`std::fmt::Error`],
    /// which contains no context.
    #[error("partition key generation error")]
    FmtError(#[from] std::fmt::Error),
}

/// Returns an iterator identifying consecutive ranges for a given partition key
pub fn partition_batch<'a, T>(
    batch: &'a T,
    template: &'a TablePartitionTemplateOverride,
) -> impl Iterator<Item = (Result<String, PartitionKeyError>, Range<usize>)> + 'a
where
    T: Batch,
{
    let parts = template.len();
    if parts > MAXIMUM_NUMBER_OF_TEMPLATE_PARTS {
        panic!(
            "partition template contains {parts} parts, which exceeds the maximum of {MAXIMUM_NUMBER_OF_TEMPLATE_PARTS} parts"
        );
    }

    range_encode(partition_keys(batch, template.parts()))
}

/// Returns an iterator of partition keys for the given table batch.
///
/// This function performs deduplication on returned keys; the returned iterator
/// yields [`Some`] containing the partition key string when a new key is
/// generated, and [`None`] when the generated key would equal the last key.
pub fn partition_keys<'a, T>(
    batch: &'a T,
    template_parts: impl Iterator<Item = TemplatePart<'a>>,
) -> impl Iterator<Item = Option<Result<String, PartitionKeyError>>> + 'a
where
    T: Batch,

View on GitHub (pinned to 06200ef96b)