Skip to content

Commit 9e698d3

Browse files
committed
commitlog: Change default max-records-in-commit to 1
It is almost always wrong / undesirable to pack more than one transaction in a commit, so adjust the default accordingly. This also avoids surprises when using `#[serde(default)]` with nested structs -- serde evaluates the default depth-first, so overriding a single field in a nested struct will not consider any `#[serde(default = "custom_default")]` annotations on the parent.
1 parent ba31c80 commit 9e698d3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/commitlog/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct Options {
6262
/// If this number is exceeded, the commit is flushed to disk even without
6363
/// explicitly calling [`Commitlog::flush`].
6464
///
65-
/// Default: 65,535
65+
/// Default: 1
6666
#[cfg_attr(feature = "serde", serde(default = "Options::default_max_records_in_commit"))]
6767
pub max_records_in_commit: NonZeroU16,
6868
/// Whenever at least this many bytes have been written to the currently
@@ -106,7 +106,7 @@ impl Default for Options {
106106

107107
impl Options {
108108
pub const DEFAULT_MAX_SEGMENT_SIZE: u64 = 1024 * 1024 * 1024;
109-
pub const DEFAULT_MAX_RECORDS_IN_COMMIT: NonZeroU16 = NonZeroU16::MAX;
109+
pub const DEFAULT_MAX_RECORDS_IN_COMMIT: NonZeroU16 = NonZeroU16::new(1).expect("1 > 0, qed");
110110
pub const DEFAULT_OFFSET_INDEX_INTERVAL_BYTES: NonZeroU64 = NonZeroU64::new(4096).expect("4096 > 0, qed");
111111
pub const DEFAULT_OFFSET_INDEX_REQUIRE_SEGMENT_FSYNC: bool = false;
112112
pub const DEFAULT_PREALLOCATE_SEGMENTS: bool = false;

0 commit comments

Comments
 (0)