Skip to content

Apply threads can skip unnecessary WAL sync for TransferLeader admin commands #18275

@overvenus

Description

@overvenus

Development Task

fn should_sync_log(cmd: &RaftCmdRequest) -> bool {
if cmd.has_admin_request() {
if cmd.get_admin_request().get_cmd_type() == AdminCmdType::CompactLog {
// We do not need to sync WAL before compact log, because this request will send
// a msg to raft_gc_log thread to delete the entries before this
// index instead of deleting them in apply thread directly.
return false;
}
return true;
}

The current implementation of apply threads in the Raft store synchronizes the Write-Ahead Log (WAL) for all admin commands except CompactLog. This synchronization is unnecessary for read-only admin commands like TransferLeader, leading to potential latency spikes, particularly during leader transfers triggered by slow disk detection.

By excluding TransferLeader from WAL synchronization, TiKV can reduce unnecessary I/O operations, thereby mitigating latency spikes during leader transfers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions