Skip to content

Commit a7e2321

Browse files
authored
Downlevel some info messages (#1739)
1 parent d5173d3 commit a7e2321

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

crates/commitlog/src/index/indexfile.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ impl<Key: Into<u64> + From<u64>> IndexFileMut<Key> {
5656
/// # Error
5757
///
5858
/// - `IndexError::KeyNotFound`: If the key is smaller than the first entry key
59-
// TODO: use binary search
6059
pub fn find_index(&self, key: Key) -> Result<(Key, u64), IndexError> {
6160
let key = key.into();
6261

crates/commitlog/src/segment.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
ops::Range,
66
};
77

8-
use log::{debug, info};
8+
use log::debug;
99

1010
use crate::{
1111
commit::{self, Commit, StoredCommit},
@@ -126,7 +126,7 @@ impl<W: io::Write> Writer<W> {
126126
index
127127
.append_after_commit(self.commit.min_tx_offset, self.bytes_written, commit_len)
128128
.map_err(|e| {
129-
info!("failed to append to offset index: {:?}", e);
129+
debug!("failed to append to offset index: {:?}", e);
130130
})
131131
});
132132

@@ -242,34 +242,42 @@ impl OffsetIndexWriter {
242242
) -> Result<(), IndexError> {
243243
self.bytes_since_last_index += commit_len;
244244

245-
if !self.require_segment_fsync && self.bytes_since_last_index >= self.min_write_interval.get() {
246-
self.head.append(min_tx_offset, byte_offset)?;
247-
self.head.async_flush()?;
248-
self.reset();
249-
} else {
245+
if self.candidate_min_tx_offset == 0 {
250246
self.candidate_byte_offset = byte_offset;
251247
self.candidate_min_tx_offset = min_tx_offset;
252248
}
249+
250+
if !self.require_segment_fsync {
251+
self.append_internal()?;
252+
}
253+
253254
Ok(())
254255
}
255256

256-
pub fn append_after_fsync(&mut self) -> Result<(), IndexError> {
257-
if self.bytes_since_last_index >= self.min_write_interval.get() {
258-
self.head
259-
.append(self.candidate_min_tx_offset, self.candidate_byte_offset)?;
257+
fn append_internal(&mut self) -> Result<(), IndexError> {
258+
// If the candidate offset is zero, there has not been a commit since the last offset entry
259+
if self.candidate_min_tx_offset == 0 {
260+
return Ok(());
261+
}
260262

261-
self.head.async_flush()?;
262-
self.reset();
263+
if self.bytes_since_last_index < self.min_write_interval.get() {
264+
return Ok(());
263265
}
266+
267+
self.head
268+
.append(self.candidate_min_tx_offset, self.candidate_byte_offset)?;
269+
self.head.async_flush()?;
270+
self.reset();
271+
264272
Ok(())
265273
}
266274
}
267275

268276
impl FileLike for OffsetIndexWriter {
269277
/// Must be called via SegmentWriter::fsync
270278
fn fsync(&mut self) -> io::Result<()> {
271-
let _ = self.append_after_fsync().map_err(|e| {
272-
info!("failed to append to offset index: {:?}", e);
279+
let _ = self.append_internal().map_err(|e| {
280+
debug!("failed to append to offset index: {:?}", e);
273281
});
274282
Ok(())
275283
}

0 commit comments

Comments
 (0)