Commit Graph

6 Commits

Author SHA1 Message Date
Michael Litvak
9e0741e5b7 logstor: add segment sequence number
add a segment sequence number that is a global (per-shard) increasing
number that is allocated when getting a new segment for write, and is
written in buffer headers in the segment.

this is useful when scanning a segment for ignoring buffers that belong
to an older generation of that segment.

it's also useful by creating a single ordering of all segments that
respects the compaction ordering.

on recovery, we keep the records from the newest segments among equal
records. so if a record is rewritten by compaction, the recovery will
choose the records from the new compacted segments.

discard segments by writing zeroes to the segment header.
2026-05-17 17:22:27 +02:00
Michael Litvak
c18d616f64 logstor: compare records by timestamp
Add the record timestamp. The timestamp is extracted from the row marker
of the mutation when we write it.

When inserting a record to index, we compare it with the existing
record, and insert it only if it has newer timestamp.
2026-05-17 17:22:26 +02:00
Michael Litvak
43c76aaf2b logstor: split log record to header and data
Split the `log_record` to `log_record_header` type that has the record
metadata fields and the mutation as a separate field which is the actual
record data:

struct log_record {
    log_record_header header;
    canonical_mutation mut;
};

Both the header and mutation have variable serialized size. When a
record is serialized in a write_buffer, we first put a small
`record_header` that has the header size and data size, then the
serialized header and data follow. The `log_location` of a record points
to the beginning of the `record_header`, and the size includes the
`record_header`.

This allows us to read a record header without reading the data when
it's not needed and avoid deserializing it:
* on recovery, when scanning all segments, we read only the record
  headers.
* on compaction, we read the record header first to determine if the
  record is alive, if yes then we read the data.

Closes scylladb/scylladb#29457
2026-04-16 10:00:35 +03:00
Pavel Emelyanov
a428472e50 db: Remove redundant enable_logstor config option
The enable_logstor configuration option is redundant with the 'logstor'
experimental feature flag. Consolidate to a single gate: use the
experimental feature to control both whether logstor is available for
table creation and whether it is initialized at database startup.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes scylladb/scylladb#29427
2026-04-15 14:40:15 +03:00
Michael Litvak
5b3e2a4ca2 docs/dev: add logstor on-disk format section 2026-03-31 18:45:08 +02:00
Michael Litvak
ad87eda835 docs/dev: add logstor documentation 2026-03-18 19:24:28 +01:00