{"record":{"id":"21eb1923f1cb29bf","repo":"microsoft/garnet","slug":"vectorsetreplaytaskcount-should-be-in-range-0-en","errorCode":null,"errorMessage":"VectorSetReplayTaskCount should be in range [0,{Environment.ProcessorCount}]!","messagePattern":"VectorSetReplayTaskCount should be in range \\[0,(.+?)\\]!","errorType":"validation","errorClass":"GarnetException","httpStatus":null,"severity":"error","filePath":"libs/server/Resp/Vector/VectorManager.cs","lineNumber":197,"sourceCode":"        {\n            this.dbId = dbId;\n\n            IsEnabled = serverOptions.EnableVectorSetPreview;\n\n            // Destination for copying the small graph \"stub\" records back into memory on disk read (see\n            // VectorReadBatch.ReadCopyOptions): the read cache when it is enabled (keeps the writable main log\n            // clean), otherwise the main-log tail (still memory-resident, but occupies writable log space).\n            StubReadCopyTo = serverOptions.EnableReadCache ? ReadCopyTo.ReadCache : ReadCopyTo.MainLog;\n\n            // Include DB and id so we correlate to what's actually stored in the log\n            logger = loggerFactory?.CreateLogger($\"{nameof(VectorManager)}:{dbId}\");\n\n            replicationBlockEvent = CountingEventSlim.Create();\n            // NOTE: for multi-log we need to disable single writer since multiple AOF replay tasks may append to this common channel.\n            replicationReplayChannel = Channel.CreateUnbounded<VADDReplicationState>(new() { SingleWriter = !serverOptions.MultiLogEnabled, SingleReader = false, AllowSynchronousContinuations = false });\n\n            if (serverOptions.VectorSetReplayTaskCount < 0 || serverOptions.VectorSetReplayTaskCount > Environment.ProcessorCount)\n                throw new GarnetException($\"VectorSetReplayTaskCount should be in range [0,{Environment.ProcessorCount}]!\");\n            var vectorSetReplayCount = serverOptions.VectorSetReplayTaskCount == 0 ? Environment.ProcessorCount : serverOptions.VectorSetReplayTaskCount;\n            replicationReplayTasks = new Task[vectorSetReplayCount];\n            for (var i = 0; i < replicationReplayTasks.Length; i++)\n            {\n                replicationReplayTasks[i] = Task.CompletedTask;\n            }\n\n            vectorSetLocks = new(vectorSetReplayCount);\n\n            this.getTempSession = getTempSession;\n            cleanupTaskChannel = new();\n            requestCleanupTaskChannel = new();\n            requestDropTaskChannel = new();\n\n            cleanupTask = RunCleanupTaskAsync();\n            requestCleanupTask = RunRequestCleanupTaskAsync();\n            requestDropTask = RunRequestDropTaskAsync();\n","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Resp/Vector/VectorManager.cs#L179-L215","documentation":"Startup validation in the VectorManager constructor: VectorSetReplayTaskCount must be 0 (meaning 'use Environment.ProcessorCount') or a positive value no greater than Environment.ProcessorCount. It sizes both the replicationReplayTasks array and the vectorSetLocks striping, so exceeding the CPU count is rejected. Note the host-layer IntRangeValidation only enforces [0, int.MaxValue], so values above ProcessorCount slip past the CLI validator and fail here at runtime.","triggerScenarios":"Launching the server with --enable-vector-set-preview and --vector-set-replay-task-count N where N is negative or N > Environment.ProcessorCount. Thrown at VectorManager.cs:196-197 during VectorManager construction (replica replay path).","commonSituations":"Hardcoding a replay task count from a larger machine into a config deployed on a smaller VM (e.g. 32 set on an 8-core box); cgroup CPU limits where Environment.ProcessorCount is restricted below the configured count; copying a config across environments.","solutions":["Set --vector-set-replay-task-count to 0 (let it default to the machine's ProcessorCount).","Otherwise set it to a value between 1 and Environment.ProcessorCount for the target machine.","If running under cgroups/containers, confirm what .NET reports as Environment.ProcessorCount and align the value accordingly.","Remove the flag entirely if you do not need to pin it."],"exampleFix":"# before (fails on an 8-core box)\ngarnet-server --enable-vector-set-preview --vector-set-replay-task-count 32\n\n# after\ngarnet-server --enable-vector-set-preview --vector-set-replay-task-count 0","handlingStrategy":"validation","validationCode":"// Validate before launch\nvar replayCount = options.VectorSetReplayTaskCount;\nif (replayCount < 0 || replayCount > Environment.ProcessorCount) {\n    throw new ArgumentOutOfRangeException(nameof(replayCount), $\"Must be 0 or in [1, {Environment.ProcessorCount}]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer 0 (auto) unless you have a measured reason to pin the count.","Do not copy a task-count value between machines with different core counts.","Under containers, check Environment.ProcessorCount at runtime, not the host core count."],"tags":["garnet","vector-set","config","replication","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}