{"record":{"id":"4a0b293933c8b87a","repo":"microsoft/garnet","slug":"cannot-use-null-device-for-aof-when-cluster-is-ena","errorCode":null,"errorMessage":"Cannot use null device for AOF when cluster is enabled and you are not using main memory replication","messagePattern":"Cannot use null device for AOF when cluster is enabled and you are not using main memory replication","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":1123,"sourceCode":"                logger?.LogInformation(\"Warning: using lower AOF memory size than specified (power of 2)\");\n            return (int)Math.Log(adjustedSize, 2);\n        }\n\n        /// <summary>\n        /// Get integer value of ReplicaDisklessSyncFullSyncAofThreshold\n        /// </summary>\n        /// <returns></returns>\n        public long ReplicaDisklessSyncFullSyncAofThresholdValue()\n            => ParseSize(string.IsNullOrEmpty(ReplicaDisklessSyncFullSyncAofThreshold) ? AofMemorySize : ReplicaDisklessSyncFullSyncAofThreshold, out _);\n\n        /// <summary>\n        /// Get device for AOF\n        /// </summary>\n        /// <returns></returns>\n        IDevice GetAofDevice(int dbId, int subLogIdx = -1)\n        {\n            if (UseAofNullDevice && EnableCluster && !FastAofTruncate)\n                throw new Exception(\"Cannot use null device for AOF when cluster is enabled and you are not using main memory replication\");\n            if (UseAofNullDevice) return new NullDevice();\n\n            if (subLogIdx == -1)\n            {\n                return GetInitializedDeviceFactory(AppendOnlyFileBaseDirectory)\n                    .Get(new FileDescriptor(GetAppendOnlyFileDirectoryName(dbId), \"aof.log\"));\n            }\n            else\n            {\n                return GetInitializedDeviceFactory(AppendOnlyFileBaseDirectory)\n                    .Get(new FileDescriptor(GetAppendOnlyFileDirectoryName(dbId), $\"aof.{subLogIdx}.log\"));\n            }\n        }\n\n        /// <summary>\n        /// Indicates whether AOF auto-commit is enabled.\n        /// </summary>\n        public bool AofAutoCommit","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L1105-L1141","documentation":"Garnet blocks the AOF null device when cluster mode is active without main-memory replication. The null device discards AOF data on close, but cluster replication depends on AOF contents for replica sync. Only when FastAofTruncate is true (main-memory replication mode) is the null device acceptable in cluster mode. The check fires in GetAofDevice().","triggerScenarios":"Calling GetAofDevice() with UseAofNullDevice=true AND EnableCluster=true AND FastAofTruncate=false simultaneously. Typically from config or command-line flags: --aof-null-device --cluster without --fast-aof-truncate.","commonSituations":"Enabling cluster mode for the first time while keeping a single-node AOF null device config; testing with null device and accidentally enabling cluster mode; misunderstanding that FastAofTruncate is the flag that permits the null device in cluster.","solutions":["Remove --aof-null-device so a real on-disk AOF device is used (required for cluster replication).","Add --fast-aof-truncate to enable main-memory replication, which permits the null device in cluster mode.","Disable cluster mode if you are running a single node and want the null device."],"exampleFix":"// before\n--aof-null-device --cluster\n\n// after\n--aof-null-device --cluster --fast-aof-truncate","handlingStrategy":"validation","validationCode":"if (options.UseAofNullDevice && options.EnableCluster && !options.FastAofTruncate)\n    throw new InvalidOperationException(\"Null AOF device requires --fast-aof-truncate when cluster mode is enabled.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine --aof-null-device with --cluster without --fast-aof-truncate.","Document the replication mode requirements for cluster deployments.","Use separate config profiles for single-node (null device OK) vs cluster (real device required)."],"tags":["aof","cluster","configuration","startup","garnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}