{"record":{"id":"e956e84ac78e3e9c","repo":"microsoft/FASTER","slug":"object-log-device-should-not-have-fixed-segment-size-set","errorCode":null,"errorMessage":"Object log device should not have fixed segment size. Set preallocateFile to false when calling CreateLogDevice for object log","messagePattern":"Object log device should not have fixed segment size\\. Set preallocateFile to false when calling CreateLogDevice for object log","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Allocator/GenericAllocator.cs","lineNumber":85,"sourceCode":"            {\n#if DEBUG\n                if (typeof(Value) != typeof(byte[]) && typeof(Value) != typeof(string))\n                    Debug.WriteLine(\"Value is not blittable, but no serializer specified via SerializerSettings. Using (slow) DataContractSerializer as default.\");\n#endif\n                SerializerSettings.valueSerializer = ObjectSerializer.Get<Value>();\n            }\n\n            values = new Record<Key, Value>[BufferSize][];\n            segmentOffsets = new long[SegmentBufferSize];\n\n            objectLogDevice = settings.ObjectLogDevice;\n\n            if ((settings.LogDevice as NullDevice == null) && (KeyHasObjects() || ValueHasObjects()))\n            {\n                if (objectLogDevice == null)\n                    throw new FasterException(\"Objects in key/value, but object log not provided during creation of FASTER instance\");\n                if (objectLogDevice.SegmentSize != -1)\n                    throw new FasterException(\"Object log device should not have fixed segment size. Set preallocateFile to false when calling CreateLogDevice for object log\");\n            }\n        }\n\n        internal override int OverflowPageCount => overflowPagePool.Count;\n\n        public override void Reset()\n        {\n            base.Reset();\n            objectLogDevice.Reset();\n            for (int index = 0; index < BufferSize; index++)\n            {\n                ReturnPage(index);\n            }\n\n            Array.Clear(segmentOffsets, 0, segmentOffsets.Length);\n            Initialize();\n        }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Allocator/GenericAllocator.cs#L67-L103","documentation":"Thrown by the GenericAllocator constructor when the object log device was created with a fixed segment size (SegmentSize != -1). The object log stores variable-size serialized objects and relies on dynamic sizing, so a preallocated, fixed-segment device is incompatible with it. FASTER rejects this configuration at construction time.","triggerScenarios":"Calling Devices.CreateLogDevice(path) for the object log with preallocateFile: true (or a device type that yields a fixed SegmentSize) and passing it as LogSettings.ObjectLogDevice to an allocator whose keys/values contain objects.","commonSituations":"Copying device-creation code from the main log (which commonly preallocates) to the object log; storage backends like AzureStorageDevice where preallocation is a flag; template setups that hardcode preallocateFile: true.","solutions":["Create the object log with preallocateFile: false so SegmentSize stays -1 (dynamic).","Check objectLogDevice.SegmentSize in config code and fall back to a dynamically-sized device.","If the backend forces fixed segments, choose a different device implementation (e.g. local file device without preallocation) for the object log."],"exampleFix":"// before\nLogSettings.ObjectLogDevice = Devices.CreateLogDevice(\"data.obj.log\", preallocateFile: true);\n\n// after\nLogSettings.ObjectLogDevice = Devices.CreateLogDevice(\"data.obj.log\", preallocateFile: false);","handlingStrategy":"validation","validationCode":"// Ensure the object log device was created dynamically sized\nif (settings.ObjectLogDevice != null && settings.ObjectLogDevice.SegmentSize != -1)\n    throw new InvalidOperationException(\"ObjectLogDevice must be created with preallocateFile: false (SegmentSize == -1)\");","typeGuard":"static bool IsDynamicSegmentDevice(IDevice d) => d == null || d.SegmentSize == -1;","tryCatchPattern":"try\n{\n    return new FASTERKeyedStore(settings);\n}\ncatch (FasterException ex) when (ex.Message.Contains(\"fixed segment size\"))\n{\n    settings.LogSettings.ObjectLogDevice?.Dispose();\n    settings.LogSettings.ObjectLogDevice = Devices.CreateLogDevice(\"data.obj.log\", preallocateFile: false);\n    return new FASTERKeyedStore(settings);\n}","preventionTips":["Always pass preallocateFile: false when calling CreateLogDevice for the object log.","Never reuse the main log's device-creation flags for the object log.","Check SegmentSize in a config sanity check before constructing the store."],"tags":["faster","configuration","devices","object-log","segment-size"],"backgroundTag":"invalid-config-value","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}