microsoft/FASTER · error · FasterException
Object log device should not have fixed segment size. Set…
Error message
Object log device should not have fixed segment size. Set preallocateFile to false when calling CreateLogDevice for object log
What it means
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.
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.
Example fix
// before
LogSettings.ObjectLogDevice = Devices.CreateLogDevice("data.obj.log", preallocateFile: true);
// after
LogSettings.ObjectLogDevice = Devices.CreateLogDevice("data.obj.log", preallocateFile: false); Defensive patterns
Strategy: validation
Validate before calling
// Ensure the object log device was created dynamically sized
if (settings.ObjectLogDevice != null && settings.ObjectLogDevice.SegmentSize != -1)
throw new InvalidOperationException("ObjectLogDevice must be created with preallocateFile: false (SegmentSize == -1)"); Type guard
static bool IsDynamicSegmentDevice(IDevice d) => d == null || d.SegmentSize == -1;
Try / catch
try
{
return new FASTERKeyedStore(settings);
}
catch (FasterException ex) when (ex.Message.Contains("fixed segment size"))
{
settings.LogSettings.ObjectLogDevice?.Dispose();
settings.LogSettings.ObjectLogDevice = Devices.CreateLogDevice("data.obj.log", preallocateFile: false);
return new FASTERKeyedStore(settings);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- LogSettings.ObjectLogDevice needs to be specified (e.g.…
- Objects in key/value, but object log not provided during…
- LogSettings.LogDevice needs to be specified (e.g., use…
- Segment ( ) must be at least of page size ( )
- Memory size ( ) must be configured to be either 1 (i.e., 0…
AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15).
Data as JSON: /api/errors/e956e84ac78e3e9c.
Report an issue: GitHub.
Appendix: source
Thrown at cs/src/core/Allocator/GenericAllocator.cs:85
{
#if DEBUG
if (typeof(Value) != typeof(byte[]) && typeof(Value) != typeof(string))
Debug.WriteLine("Value is not blittable, but no serializer specified via SerializerSettings. Using (slow) DataContractSerializer as default.");
#endif
SerializerSettings.valueSerializer = ObjectSerializer.Get<Value>();
}
values = new Record<Key, Value>[BufferSize][];
segmentOffsets = new long[SegmentBufferSize];
objectLogDevice = settings.ObjectLogDevice;
if ((settings.LogDevice as NullDevice == null) && (KeyHasObjects() || ValueHasObjects()))
{
if (objectLogDevice == null)
throw new FasterException("Objects in key/value, but object log not provided during creation of FASTER instance");
if (objectLogDevice.SegmentSize != -1)
throw new FasterException("Object log device should not have fixed segment size. Set preallocateFile to false when calling CreateLogDevice for object log");
}
}
internal override int OverflowPageCount => overflowPagePool.Count;
public override void Reset()
{
base.Reset();
objectLogDevice.Reset();
for (int index = 0; index < BufferSize; index++)
{
ReturnPage(index);
}
Array.Clear(segmentOffsets, 0, segmentOffsets.Length);
Initialize();
}
View on GitHub (pinned to 321d872eab)