Skip to content

Commit 4c9482a

Browse files
committed
configurable max log size
1 parent 48ebaaf commit 4c9482a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

libsql-wal/src/registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ where
339339
)),
340340
shutdown: false.into(),
341341
checkpoint_notifier: self.checkpoint_notifier.clone(),
342+
max_segment_size: 1000.into(),
342343
});
343344

344345
self.opened

libsql-wal/src/shared_wal.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub struct SharedWal<IO: Io> {
5151
pub(crate) stored_segments: Box<dyn ReplicateFromStorage>,
5252
pub(crate) shutdown: AtomicBool,
5353
pub(crate) checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
54+
/// maximum size the segment is allowed to grow
55+
pub(crate) max_segment_size: AtomicUsize,
5456
}
5557

5658
impl<IO: Io> SharedWal<IO> {
@@ -264,7 +266,9 @@ impl<IO: Io> SharedWal<IO> {
264266
}
265267

266268
// TODO: use config for max log size
267-
if tx.is_commited() && current.count_committed() > 1000 {
269+
if tx.is_commited()
270+
&& current.count_committed() > self.max_segment_size.load(Ordering::Relaxed)
271+
{
268272
self.swap_current(&tx)?;
269273
}
270274

0 commit comments

Comments
 (0)