dotnet/orleans · error · OrleansConfigurationException

Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Str

Error message

Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionBatchSize)} must be greater than zero.

What it means

Thrown by AdoNetStreamOptionsValidator.ValidateConfiguration when AdoNetStreamOptions.EvictionBatchSize is set to a negative value. EvictionBatchSize controls the maximum number of stream messages moved to dead-letters or deleted per eviction cycle. The guard rejects negatives so the eviction batch never inverts semantics. Note the check is '< 0', so zero is permitted (it effectively disables batch eviction), even though the message text says 'must be greater than zero'.

Source

Thrown at src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs:50

        if (options.EvictionInterval < TimeSpan.Zero)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionInterval)} must be greater than zero.");
        }

        if (options.ExpiryTimeout < TimeSpan.Zero)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.ExpiryTimeout)} must be greater than zero.");
        }

        if (options.DeadLetterEvictionTimeout < TimeSpan.Zero)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.DeadLetterEvictionTimeout)} must be greater than zero.");
        }

        if (options.EvictionBatchSize < 0)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionBatchSize)} must be greater than zero.");
        }
    }
}

View on GitHub (pinned to fca799fa70)

Solutions

  1. Set EvictionBatchSize to a non-negative value (default is 1000); use 0 only if you intend to disable batch eviction.
  2. Check your silo/client builder configuration where AddAdoNetStreams is called and correct or remove the EvictionBatchSize assignment.
  3. Verify the appsettings/source feeding AdoNetStreamOptions does not supply a negative value.

Example fix

// before
siloBuilder.AddAdoNetStreams("my-provider", new AdoNetStreamOptions
{
    Invariant = "MySql.Data.MySqlClient",
    ConnectionString = connectionString,
    EvictionBatchSize = -1 // throws at startup
});

// after
siloBuilder.AddAdoNetStreams("my-provider", new AdoNetStreamOptions
{
    Invariant = "MySql.Data.MySqlClient",
    ConnectionString = connectionString,
    EvictionBatchSize = 500
});
Defensive patterns

Strategy: validation

Validate before calling

// Validate before the silo starts up.
if (options.EvictionBatchSize < 0)
    throw new ArgumentOutOfRangeException(nameof(options.EvictionBatchSize), "Must be non-negative.");
// Optionally clamp: options.EvictionBatchSize = Math.Max(0, options.EvictionBatchSize);

Prevention

When it happens

Trigger: Calling ValidateConfiguration() (run automatically by Orleans at silo/client startup) after configuring an ADO.NET streaming provider whose AdoNetStreamOptions.EvictionBatchSize was explicitly assigned a negative int. For example: options.EvictionBatchSize = -1; or reading a negative value from configuration.

Common situations: Misreading the option as a count that must be strictly positive and passing -1 to 'disable' it; binding EvictionBatchSize from an appsettings key that is missing (parsed as a sentinel) or mistyped; copying a TimeSpan-based negative value into this int field by mistake.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/3bce721d702f9d94. Report an issue: GitHub.