mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 06:54:24 +00:00
rust volume: saturate writes_since_checkpoint to prevent u32 overflow
If checkpoints keep failing (e.g. a persistent .dat flush failure whose error is not EIO and so does not mark the volume read-only), the counter increments on every write with no upper bound and wraps at ~4.3 billion. Use saturating_add so it pins at u32::MAX instead, which keeps checkpoint_due() true and retries on every subsequent write. Co-Authored-By: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
@@ -792,7 +792,7 @@ impl RedbNeedleMap {
|
||||
}
|
||||
txn.commit()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("redb commit: {}", e)))?;
|
||||
self.writes_since_checkpoint += 1;
|
||||
self.writes_since_checkpoint = self.writes_since_checkpoint.saturating_add(1);
|
||||
|
||||
self.metric.on_put(key, old.as_ref(), size);
|
||||
Ok(())
|
||||
@@ -866,7 +866,7 @@ impl RedbNeedleMap {
|
||||
txn.commit().map_err(|e| {
|
||||
io::Error::new(io::ErrorKind::Other, format!("redb commit: {}", e))
|
||||
})?;
|
||||
self.writes_since_checkpoint += 1;
|
||||
self.writes_since_checkpoint = self.writes_since_checkpoint.saturating_add(1);
|
||||
|
||||
// Only now is the tombstone in the table the metrics describe.
|
||||
self.metric.on_delete(&old);
|
||||
|
||||
Reference in New Issue
Block a user