databendlabs/databend · error · InvalidInput

semaphore permit key should have 'queue' as the second…

Error message

semaphore permit key should have 'queue' as the second segment: {}

What it means

A validation guard in PermitKey::parse_key: the second segment (parts[1]) of the 3-part key must be the literal "queue", matching the layout produced by format_key ("{prefix}/queue/{seq:020}"). This error fires when a key has three slash-separated segments but its middle segment differs, meaning the string was not produced by format_key or was altered.

Solutions

  1. Verify the key has the 'queue' literal as its second-to-last segment, as emitted by format_key's '{prefix}/queue/{seq}' layout.
  2. If a different prefix layout was used to build the key, parse it with the matching parser instead of PermitKey::parse_key.
  3. Regenerate malformed keys or reject the stored entry so it does not reach parse_key.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/meta/plugins/semaphore/src/storage/permit_key.rs:72 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/206cc8585f8d6d64. Report an issue: GitHub.

Appendix: source

Thrown at src/meta/plugins/semaphore/src/storage/permit_key.rs:72

    }

    /// Parse the key from an encoded string.
    pub fn parse_key(key: &str) -> Result<Self, io::Error> {
        // split by the last 2 slashes:
        let parts = key.rsplitn(3, '/').collect::<Vec<_>>();

        if parts.len() != 3 {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                format!(
                    "semaphore permit key should have at least 3 segments: {}",
                    key
                ),
            ));
        }

        if parts[1] != "queue" {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                format!(
                    "semaphore permit key should have 'queue' as the second segment: {}",
                    key
                ),
            ));
        }

        let seq = parts[0].parse::<u64>().map_err(|e| {
            io::Error::new(
                io::ErrorKind::InvalidInput,
                format!("failed to parse seq number: {}", e),
            )
        })?;

        Ok(Self {
            prefix: parts[2].to_string(),
            seq,

View on GitHub (pinned to 288d84d76e)