Skip to content

Limitations

slate wraps Erlang's DETS. Use these limits to decide whether it fits your storage needs.

DETS limits each table file to 2 GB. You cannot configure this limit. A write that would exceed it returns Error(FileSizeLimitExceeded(context)).

Unlike Erlang's ETS (in-memory storage), DETS does not support ordered_set tables. Only set, bag, and duplicate_bag are available. Keys are stored in an unspecified order.

DETS stores data on disk. Performance depends on disk I/O, buffering, and your workload. A successful insert does not mean that the data has been synchronously flushed to disk. Use sync to flush pending writes and close when you finish with a table. Handle errors from both operations.

For frequent reads with low latency, load data into ETS at startup and use DETS for persistence.

VM or node termination and power loss can prevent a DETS table from closing properly. Pending writes may be lost, and the file may need repair on the next open. File persistence does not guarantee that all writes survive a crash.

Keep primary data files on persistent storage and maintain backups. Deleting or replacing a DETS file loses the data in that file.

An individual Erlang process exit is different. DETS tracks processes that open a table and normally closes it when the last user exits. with_table attempts to close the table after its callback returns or raises. The helper cannot run cleanup after a forced kill of the owning process. For longer-lived tables, call close yourself.

slate's default AutoRepair policy attempts repair when needed. ForceRepair repairs even a properly closed file. NoRepair returns NeedsRepair when repair is required. None of these policies guarantees full data recovery. Back up a closed file before attempting repair.

DETS is a BEAM feature. slate supports only Gleam's Erlang target. It does not support the JavaScript target.

slate reuses a pool of 4096 DETS table names instead of creating an atom for each path. Up to 4096 distinct normalized paths can be open at once. Closing a table releases its slot for reuse. If all slots are in use, new opens for other paths return TableNamePoolExhausted.

No concurrent access from multiple OS processes

Section titled “No concurrent access from multiple OS processes”

Open each DETS file from only one OS process at a time. Multiple Erlang processes within that BEAM node can share the table. Opening the same file from separate BEAM nodes or OS processes can corrupt it.

Use slate.is_dets_file to identify a DETS file before opening it:

import slate
let assert Ok(True) = slate.is_dets_file("data/cache.dets")
let assert Ok(False) = slate.is_dets_file("README.md")

Use this when scanning a directory for DETS files. A result of Ok(True) does not guarantee file integrity, successful decoding, or safe access to a user-provided path. Apply your application's path and access rules separately.

DETS compared with other BEAM storage options
Feature DETS (slate) ETS SQLite Mnesia
Persistence Disk Memory only Disk Memory or disk, depending on table configuration
Maximum size 2 GB per file RAM Depends on configuration and storage Depends on table type, configuration, and storage
Query capability Key lookup, fold Key lookup, match specs Full SQL Match specs, QLC
Ordered keys No Yes (ordered_set) Yes Yes
Storage engine Included in OTP Included in OTP Separate library Included in OTP
Performance Depends on disk I/O and workload In-memory reads Depends on workload Depends on configuration and workload
Concurrent processes Single node Single node Multiple Distributed