Skip to content

Commit 7e32d58

Browse files
goffrieConvex, Inc.
authored andcommitted
Make split_rw_lock::Writer::write take &mut self (#35892)
GitOrigin-RevId: bdc5e1cd6bdb1570e7ffb71672495f0813367c83
1 parent e6ab955 commit 7e32d58

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

crates/common/src/sync/split_rw_lock.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::sync::Arc;
33
use parking_lot::{
44
RwLock,
55
RwLockReadGuard,
6-
RwLockUpgradableReadGuard,
76
RwLockWriteGuard,
87
};
98

@@ -48,15 +47,11 @@ impl<T> Writer<T> {
4847
}
4948
}
5049

51-
pub fn write(&self) -> RwLockWriteGuard<T> {
50+
pub fn write(&mut self) -> RwLockWriteGuard<T> {
5251
self.inner.write()
5352
}
5453

5554
pub fn read(&self) -> RwLockReadGuard<T> {
5655
self.inner.read()
5756
}
58-
59-
pub fn upgradable_read(&self) -> RwLockUpgradableReadGuard<T> {
60-
self.inner.upgradable_read()
61-
}
6257
}

crates/database/src/retention.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
414414
}
415415

416416
async fn advance_timestamp(
417-
bounds_writer: &Writer<SnapshotBounds>,
417+
bounds_writer: &mut Writer<SnapshotBounds>,
418418
persistence: &dyn Persistence,
419419
snapshot_reader: &Reader<SnapshotManager>,
420420
checkpoint_reader: &Reader<Checkpoint>,
@@ -497,7 +497,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
497497
}
498498

499499
async fn go_advance_min_snapshot(
500-
bounds_writer: Writer<SnapshotBounds>,
500+
mut bounds_writer: Writer<SnapshotBounds>,
501501
checkpoint_reader: Reader<Checkpoint>,
502502
rt: RT,
503503
persistence: Arc<dyn Persistence>,
@@ -511,7 +511,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
511511
let _timer = retention_advance_timestamp_timer();
512512

513513
let index_ts = Self::advance_timestamp(
514-
&bounds_writer,
514+
&mut bounds_writer,
515515
persistence.as_ref(),
516516
&snapshot_reader,
517517
&checkpoint_reader,
@@ -522,7 +522,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
522522
Self::emit_timestamp(&min_snapshot_sender, index_ts).await;
523523

524524
let document_ts = Self::advance_timestamp(
525-
&bounds_writer,
525+
&mut bounds_writer,
526526
persistence.as_ref(),
527527
&snapshot_reader,
528528
&checkpoint_reader,
@@ -1103,7 +1103,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
11031103
mut index_cursor: RepeatableTimestamp,
11041104
retention_validator: Arc<dyn RetentionValidator>,
11051105
mut min_snapshot_rx: Receiver<RepeatableTimestamp>,
1106-
checkpoint_writer: Writer<Checkpoint>,
1106+
mut checkpoint_writer: Writer<Checkpoint>,
11071107
snapshot_reader: Reader<SnapshotManager>,
11081108
) {
11091109
let reader = persistence.reader();
@@ -1178,7 +1178,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
11781178
Self::checkpoint(
11791179
persistence.as_ref(),
11801180
new_cursor,
1181-
&checkpoint_writer,
1181+
&mut checkpoint_writer,
11821182
RetentionType::Index,
11831183
bounds_reader.clone(),
11841184
snapshot_reader.clone(),
@@ -1218,7 +1218,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
12181218
persistence: Arc<dyn Persistence>,
12191219
retention_validator: Arc<dyn RetentionValidator>,
12201220
mut min_document_snapshot_rx: Receiver<RepeatableTimestamp>,
1221-
checkpoint_writer: Writer<Checkpoint>,
1221+
mut checkpoint_writer: Writer<Checkpoint>,
12221222
snapshot_reader: Reader<SnapshotManager>,
12231223
) {
12241224
// Wait with jitter on startup to avoid thundering herd
@@ -1284,7 +1284,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
12841284
Self::checkpoint(
12851285
persistence.as_ref(),
12861286
new_cursor,
1287-
&checkpoint_writer,
1287+
&mut checkpoint_writer,
12881288
RetentionType::Document,
12891289
bounds_reader.clone(),
12901290
snapshot_reader.clone(),
@@ -1314,7 +1314,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
13141314
async fn checkpoint(
13151315
persistence: &dyn Persistence,
13161316
cursor: RepeatableTimestamp,
1317-
checkpoint_writer: &Writer<Checkpoint>,
1317+
checkpoint_writer: &mut Writer<Checkpoint>,
13181318
retention_type: RetentionType,
13191319
bounds_reader: Reader<SnapshotBounds>,
13201320
snapshot_reader: Reader<SnapshotManager>,

0 commit comments

Comments
 (0)