nautechsystems/nautilus_trader · error · anyhow::Error

Execution payload rollback batch size must be positive

Error message

Execution payload rollback batch size must be positive

What it means

rollback_execution_payload_storage processes stored execution payloads in batches and requires a strictly positive batch_size (i64). This error is thrown before any rollback work begins when batch_size <= 0, preventing an infinite loop or no-op batch query.

Source

Thrown at crates/adapters/blockchain/src/cache/database.rs:5549

            )
            .bind(hash.id)
            .execute(&mut *transaction)
            .await
            .context("failed to record execution payload rewrap progress")?;
        }
        transaction
            .commit()
            .await
            .context("failed to commit execution payload rewrap batch")?;
        Ok(false)
    }

    pub(crate) async fn rollback_execution_payload_storage(
        &self,
        keys: &PayloadKeySet,
        batch_size: i64,
    ) -> anyhow::Result<()> {
        anyhow::ensure!(
            batch_size > 0,
            "Execution payload rollback batch size must be positive"
        );
        self.begin_execution_payload_rollback(keys).await?;

        loop {
            if self
                .rollback_execution_payload_batch(keys, batch_size)
                .await?
            {
                return Ok(());
            }
        }
    }

    async fn begin_execution_payload_rollback(&self, keys: &PayloadKeySet) -> anyhow::Result<()> {
        let mut transaction = self
            .pool

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass a positive batch size (e.g. 500) when calling rollback_execution_payload_storage
  2. Fix the configuration source so rollback_batch_size is set and parsed as a positive integer
  3. Validate/clamp the value at config load time (ensure!(v > 0)) before reaching the storage layer

Example fix

// before
db.rollback_execution_payload_storage(&keys, config.rollback_batch_size).await?; // 0
// after
let batch = config.rollback_batch_size.max(1);
db.rollback_execution_payload_storage(&keys, batch).await?;
Defensive patterns

Strategy: validation

Validate before calling

let batch_size: i64 = config.rollback_batch_size;
if batch_size <= 0 {
    return Err(anyhow!("rollback_batch_size must be positive, got {batch_size}"));
}

Prevention

When it happens

Trigger: Calling rollback_execution_payload_storage with batch_size = 0 or a negative value, e.g. from configuration where the batch size defaulted to 0 or was parsed incorrectly (missing/failed i64 parse leaving 0).

Common situations: A config file with rollback_batch_size: 0; a CLI/env value that failed parsing and defaulted to 0; copy-pasted invocation from another rollback helper that takes a limit rather than a batch size.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/bad09c64131d7292. Report an issue: GitHub.