dotnet/orleans · error · ArgumentOutOfRangeException

CompactionSizeThreshold must be positive.

Error message

CompactionSizeThreshold must be positive.

What it means

AzureTableJournalStorageOptions.CompactionSizeThreshold was set to zero or negative. The constructor (AzureTableJournalStorage.cs:1273) requires it positive because it bounds the byte-size trigger for IsCompactionRequested. The argument blamed is `options`.

Source

Thrown at src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs:1275

            AzureTableJournalStorageInstruments instruments,
            string? journalFormatKey = null)
        {
            ArgumentNullException.ThrowIfNull(logger);
            ArgumentNullException.ThrowIfNull(options);
            ArgumentNullException.ThrowIfNull(tableClientProvider);

            Logger = logger;
            Options = options.Value;
            ArgumentNullException.ThrowIfNull(Options);
            AzureTableJournalStorageOptions.ValidateTableName(Options.TableName);
            if (Options.CompactionRowCountThreshold <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(options), $"{nameof(AzureTableJournalStorageOptions.CompactionRowCountThreshold)} must be positive.");
            }

            if (Options.CompactionSizeThreshold <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(options), $"{nameof(AzureTableJournalStorageOptions.CompactionSizeThreshold)} must be positive.");
            }

            if (Options.MaxMetadataOnlyConflictRetries < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(options), $"{nameof(AzureTableJournalStorageOptions.MaxMetadataOnlyConflictRetries)} must be non-negative.");
            }

            if (Options.MetadataOnlyConflictInitialBackoff < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(options), $"{nameof(AzureTableJournalStorageOptions.MetadataOnlyConflictInitialBackoff)} must be non-negative.");
            }

            if (Options.MetadataOnlyConflictMaxBackoff < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(options), $"{nameof(AzureTableJournalStorageOptions.MetadataOnlyConflictMaxBackoff)} must be non-negative.");
            }

            JournalFormatKey = journalFormatKey;

View on GitHub (pinned to fca799fa70)

Solutions

  1. Set CompactionSizeThreshold to a positive byte count (default 32 MiB).
  2. Use a large threshold instead of 0 to effectively defer compaction.
  3. Add IValidateOptions<T> to catch this at startup.

Example fix

// before
options.CompactionSizeThreshold = 0;

// after
options.CompactionSizeThreshold = AzureTableJournalStorageOptions.DEFAULT_COMPACTION_SIZE_THRESHOLD;
Defensive patterns

Strategy: validation

Validate before calling

if (options.CompactionSizeThreshold <= 0)
    throw new ArgumentOutOfRangeException(nameof(options.CompactionSizeThreshold), "Must be positive");

Type guard

static bool IsValidCompactionSizeThreshold(long v) => v > 0;

Prevention

When it happens

Trigger: Configuring CompactionSizeThreshold <= 0; thrown at AzureTableJournalStorage.cs:1275 during AzureTableJournalStorageShared construction.

Common situations: Missing config binding produced 0; attempt to disable size compaction via 0 (use a large value instead); unit of measure mismatch led to a tiny/zero number.

Related errors


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