Repository: tikv/tikv
File: src/storage/txn/scheduler.rs (Rust)

Code before:
                released_lock.start_ts,
                released_lock.commit_ts,
                wake_up_delay_duration_ms,
            );
            if entries.is_empty() {
                return;
            }

            let ReleasedLock {
                start_ts,
                commit_ts,
                key,
                pessimistic,
            } = released_lock;

            if let Some(f) = delay_future {
                delay_wake_up_futures.push(f);
            }

            let multi_entries = entries.len() > 1;

            for lock_wait_entry in entries {
                // With multi entries, only shared lock's waiters can be awaken up.
                debug_assert!(
                    lock_wait_entry.is_shared_lock || !multi_entries,
                    "only pessimistic locks are supported here"
                );
                if lock_wait_entry.parameters.allow_lock_with_conflict {
                    resumable_wake_up_list.push(lock_wait_entry);
                } else {
                    legacy_wake_up_list.push((
                        lock_wait_entry,
                        ReleasedLock::new(start_ts, commit_ts, key.clone(), pessimistic),
                    ));
                }
            }
        });

        if !legacy_wake_up_list.is_empty() || !delay_wake_up_futures.is_empty() {
            self.wake_up_legacy_pessimistic_locks(
                request_source,
                metadata.clone(),
                legacy_wake_up_list,
                delay_wake_up_futures,
            );
        }

        resumable_wake_up_list
    }

    fn on_acquired_locks_finished(

Review comment (bug):
The debug assertion message "only pessimistic locks are supported here" is misleading. The assertion is actually checking that if there are multiple entries (multi_entries is true), then all entries must be shared locks. A more accurate message would be "when multiple entries exist, all must be shared locks" or "non-shared locks cannot be woken up in groups".
```suggestion
                    "when multiple entries exist, all must be shared locks"
```

Code after:
                released_lock.start_ts,
                released_lock.commit_ts,
                wake_up_delay_duration_ms,
            );
            if entries.is_empty() {
                return;
            }

            if let Some(f) = delay_future {
                delay_wake_up_futures.push(f);
            }

            let multi_entries = entries.len() > 1;

            for lock_wait_entry in entries {
                // With multi entries, only shared lock's waiters can be awaken up.
                debug_assert!(
                    lock_wait_entry.is_shared_lock || !multi_entries,
                    "when multiple entries exist, all must be shared locks"
                );
                if lock_wait_entry.parameters.allow_lock_with_conflict {
                    resumable_wake_up_list.push(lock_wait_entry);
                } else {
                    legacy_wake_up_list.push((
                        lock_wait_entry,
                        ReleasedLock::new(
                            released_lock.start_ts,
                            released_lock.commit_ts,
                            released_lock.key.clone(),
                            released_lock.pessimistic,
                        ),
                    ));
                }
            }
        });

        if !legacy_wake_up_list.is_empty() || !delay_wake_up_futures.is_empty() {
            self.wake_up_legacy_pessimistic_locks(
                request_source,
                metadata.clone(),
                legacy_wake_up_list,
                delay_wake_up_futures,
            );
        }

        resumable_wake_up_list
    }

    fn on_acquired_locks_finished(
        &self,
        request_source: &str,