mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-08 16:49:46 -04:00
997b5a6e8f
In #4338, the read-only path was made resilient against empty segments at the end of the log, but corresponding logic was not applied to re-opening the commitlog for writing. This patch rectifies that by ignoring and removing segments from the tail of the log if they contain equal to or less than `segment::Header::LEN` bytes. Additionally, zero-sized segments are eliminated entirely by ensuring that the header is written before moving the segment into place atomically. The benefit of this is not huge, but could simplify commitlog-consuming code by not having to worry about empty (zero-sized) segments. Happy to revert if that is deemed too less of a benefit. # Expected complexity level and risk 2 # Testing Adds a test.
66 lines
1.9 KiB
TOML
66 lines
1.9 KiB
TOML
[package]
|
|
name = "spacetimedb-commitlog"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license-file = "LICENSE"
|
|
|
|
description = "Implementation of the SpacetimeDB commitlog."
|
|
|
|
[features]
|
|
default = ["serde"]
|
|
# Enable streaming reads + writes
|
|
streaming = ["dep:async-stream", "dep:bytes", "dep:futures", "dep:tokio", "dep:tokio-util"]
|
|
# Enable types + impls useful for testing
|
|
test = ["dep:env_logger"]
|
|
# Enable `fallocate` of segments
|
|
fallocate = ["dep:nix"]
|
|
|
|
[dependencies]
|
|
async-stream = { workspace = true, optional = true }
|
|
bitflags.workspace = true
|
|
bytes= { workspace = true, optional = true }
|
|
crc32c.workspace = true
|
|
futures = { workspace = true, optional = true }
|
|
itertools.workspace = true
|
|
log.workspace = true
|
|
memmap2 = "0.9.4"
|
|
nix = { workspace = true, optional = true, features = ["fs"] }
|
|
scopeguard.workspace = true
|
|
serde = { workspace = true, optional = true }
|
|
spacetimedb-fs-utils.workspace = true
|
|
spacetimedb-paths.workspace = true
|
|
spacetimedb-primitives.workspace = true
|
|
spacetimedb-sats.workspace = true
|
|
tempfile.workspace = true
|
|
thiserror.workspace = true
|
|
tokio = { workspace = true, optional = true }
|
|
tokio-util = { workspace = true, optional = true, features = ["io-util"] }
|
|
zstd-framed.workspace = true
|
|
|
|
# For the 'test' feature
|
|
env_logger = { workspace = true, optional = true }
|
|
pretty_assertions.workspace = true
|
|
|
|
[dev-dependencies]
|
|
# Enable streaming in tests
|
|
# Also enable 'test' feature, so integration tests can use the helpers.
|
|
spacetimedb-commitlog = { path = ".", features = ["test", "streaming"] }
|
|
|
|
criterion.workspace = true
|
|
env_logger.workspace = true
|
|
once_cell.workspace = true
|
|
pretty_assertions = { workspace = true, features = ["unstable"] }
|
|
proptest-derive.workspace = true
|
|
proptest.workspace = true
|
|
rand.workspace = true
|
|
tempfile.workspace = true
|
|
tokio-stream = { version = "0.1.17", features = ["fs"] }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[[bench]]
|
|
name = "write"
|
|
harness = false
|