Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
  • Loading branch information
MyonKeminta committed Oct 26, 2022
1 parent 4005b10 commit 77caef7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/server/lock_manager/mod.rs
Expand Up @@ -263,23 +263,24 @@ impl LockManagerTrait for LockManager {
// but the waiter_mgr haven't processed it, subsequent WakeUp msgs may be lost.
self.waiter_count.fetch_add(1, Ordering::SeqCst);

// If it is the first lock the transaction tries to lock, it won't cause
// deadlock.
if !is_first_lock {
self.detector_scheduler
.detect(start_ts, wait_info.clone(), diag_ctx.clone()); // TODO: Try to avoid cloning.
}
self.waiter_mgr_scheduler.wait_for(
token,
region_id,
region_epoch,
term,
start_ts,
wait_info,
wait_info.clone(),
timeout,
cancel_callback,
diag_ctx,
diag_ctx.clone(),
);

// If it is the first lock the transaction tries to lock, it won't cause
// deadlock.
if !is_first_lock {
self.detector_scheduler
.detect(start_ts, wait_info, diag_ctx);
}
}

fn update_wait_for(&self, updated_items: Vec<UpdateWaitForEvent>) {
Expand Down
3 changes: 1 addition & 2 deletions src/server/lock_manager/waiter_manager.rs
Expand Up @@ -252,7 +252,7 @@ impl Waiter {
self.delay.reset(deadline);
}

/// Consumes the `Waiter` to notify the corresponding transaction `going on.
/// Consumes the `Waiter` to notify the corresponding transaction going on.
fn cancel(self, error: Option<StorageError>) -> KeyLockWaitInfo {
let elapsed = self.start_waiting_time.saturating_elapsed();
GLOBAL_TRACKERS.with_tracker(self.diag_ctx.tracker, |tracker| {
Expand Down Expand Up @@ -517,7 +517,6 @@ impl WaiterManager {
wait_table: Rc::new(RefCell::new(wait_table)),
detector_scheduler,
default_wait_for_lock_timeout: cfg.wait_for_lock_timeout,
// wake_up_delay_duration: cfg.wake_up_delay_duration,
}
}

Expand Down

0 comments on commit 77caef7

Please sign in to comment.