Skip to content

Commit 9696333

Browse files
committed
[ENH] Document magic constants throughout wal3/rust code
1 parent 1e0a151 commit 9696333

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

rust/log-service/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ async fn get_log_from_handle_with_mutex_held<'a>(
228228
mark_dirty: MarkDirty,
229229
) -> Result<LogRef<'a>, wal3::Error> {
230230
if active.log.is_some() {
231+
// TODO(rescrv): Magic constant.
231232
active.keep_alive(Duration::from_secs(60));
232233
}
233234
if let Some(log) = active.log.as_ref() {
@@ -245,6 +246,7 @@ async fn get_log_from_handle_with_mutex_held<'a>(
245246
mark_dirty.clone(),
246247
)
247248
.await?;
249+
// TODO(rescrv): Magic constant.
248250
active.keep_alive(Duration::from_secs(60));
249251
tracing::info!("Opened log at {}", prefix);
250252
let opened = Arc::new(opened);
@@ -336,7 +338,7 @@ impl RollupPerCollection {
336338
self.reinsert_count = std::cmp::max(self.reinsert_count, reinsert_count);
337339
// Consider the most recent initial insertion time so if we've compacted earlier we drop.
338340
self.initial_insertion_epoch_us =
339-
std::cmp::max(self.initial_insertion_epoch_us, initial_insertion_epoch_us);
341+
std::cmp::min(self.initial_insertion_epoch_us, initial_insertion_epoch_us);
340342
}
341343

342344
fn witness_cursor(&mut self, witness: Option<&Witness>) {
@@ -569,6 +571,7 @@ impl LogServer {
569571
));
570572
}
571573
tracing::info!("scouted {collection_id} start={start} limit={limit}");
574+
// TODO(rescrv): Magic constant.
572575
const STEP: u64 = 100;
573576
let num_steps = (limit.saturating_sub(start) + STEP - 1) / STEP;
574577
let actual_steps = (0..num_steps)
@@ -708,6 +711,7 @@ impl LogServer {
708711
.await?
709712
.into_inner();
710713
if resp.log_is_sealed {
714+
// TODO(rescrv): Magic constant.
711715
self.effectuate_log_transfer(collection_id, proxy.clone(), 3)
712716
.await?;
713717
Box::pin(self.push_logs(Request::new(request))).await
@@ -817,7 +821,7 @@ impl LogServer {
817821
epoch_us: SystemTime::now()
818822
.duration_since(SystemTime::UNIX_EPOCH)
819823
.map_err(|_| wal3::Error::Internal)
820-
.unwrap()
824+
.expect("time should never move to before UNIX epoch")
821825
.as_micros() as u64,
822826
writer: "TODO".to_string(),
823827
};
@@ -856,6 +860,7 @@ impl LogServer {
856860
request: GetAllCollectionInfoToCompactRequest,
857861
) -> Result<Response<GetAllCollectionInfoToCompactResponse>, Status> {
858862
// TODO(rescrv): Realistically we could make this configurable.
863+
// TODO(rescrv): Magic constant.
859864
const MAX_COLLECTION_INFO_NUMBER: usize = 10000;
860865
let mut selected_rollups = Vec::with_capacity(MAX_COLLECTION_INFO_NUMBER);
861866
// Do a non-allocating pass here.
@@ -984,6 +989,7 @@ impl LogServer {
984989
if dirty_fragments.is_empty() {
985990
return Ok((witness, cursor, vec![]));
986991
}
992+
// TODO(rescrv): Magic constant.
987993
if dirty_fragments.len() >= 1_000 {
988994
tracing::error!("Too many dirty fragments: {}", dirty_fragments.len());
989995
}
@@ -1541,6 +1547,7 @@ impl LogServer {
15411547
let dirty_fragments = reader
15421548
.scan(
15431549
cursor.position,
1550+
// TODO(rescrv): Magic constant.
15441551
Limits {
15451552
max_files: Some(1_000_000),
15461553
max_bytes: Some(1_000_000_000),

rust/wal3/src/manifest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ impl Snapshot {
183183
err => {
184184
let backoff = exp_backoff.next();
185185
tokio::time::sleep(backoff).await;
186+
// TODO(rescrv): Magic constant.
186187
if retries >= 3 {
187188
return Err(Error::StorageError(Arc::new(err.clone())));
188189
}
@@ -227,6 +228,7 @@ impl Snapshot {
227228
Err(e) => {
228229
tracing::error!("error uploading manifest: {e:?}");
229230
let mut backoff = exp_backoff.next();
231+
// TODO(rescrv): Magic constant.
230232
if backoff > Duration::from_secs(3_600) {
231233
backoff = Duration::from_secs(3_600);
232234
}

rust/wal3/src/writer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ pub async fn upload_parquet(
630630
return Err(Error::StorageError(Arc::new(err)));
631631
}
632632
let mut backoff = exp_backoff.next();
633+
// TODO(rescrv): Magic constant.
633634
if backoff > Duration::from_secs(3_600) {
634635
backoff = Duration::from_secs(3_600);
635636
}
@@ -668,6 +669,7 @@ pub async fn copy_parquet(
668669
return Err(Error::StorageError(Arc::new(err)));
669670
}
670671
let mut backoff = exp_backoff.next();
672+
// TODO(rescrv): Magic constant.
671673
if backoff > Duration::from_secs(3_600) {
672674
backoff = Duration::from_secs(3_600);
673675
}

0 commit comments

Comments
 (0)