Skip to content

Conversation

@ljluestc
Copy link

@ljluestc ljluestc commented Dec 1, 2025

This PR implements the PaxosLease mechanism for PD leader election, as proposed in issue #1677.
Currently, PD relies heavily on etcd for leader election and TSO timestamp allocation guarantees. This creates a strong dependency on etcd's availability and write latency.

PaxosLease allows PD members to elect a leader using a disk-less Paxos implementation that maintains lease state in memory across a quorum of nodes. This reduces the dependency on etcd writes for lease renewal and allows for potentially faster failure detection and TSO service recovery.

What is changed and how does it work?

I have introduced a new package pkg/paxoslease that contains a standalone implementation of the PaxosLease algorithm.

Key components:

  • Paxos struct: Implements the Paxos state machine (Proposer, Acceptor, Learner).
  • Lease struct: Represents the lease value (Owner, Duration, StartTime).
  • Transport interface: Decouples the consensus logic from the networking layer, allowing integration with PD's existing communication channels.
  • Mockable Time: The implementation uses a swappable time source to ensure deterministic testing of lease expiry and renewal.

Logic Flow:

  1. Campaign: A node initiates a Paxos Prepare phase.
  2. Promise: Nodes respond with Promise and any previously accepted values.
  3. Accept: The proposer selects a value (respecting existing valid leases) and broadcasts Accept.
  4. Learn: Once a quorum accepts a value, it is considered chosen, and the node becomes the leader for the lease duration.
  5. Renewal: The current leader can preemptively renew the lease before it expires to maintain continuous leadership.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 1, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Dec 1, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 1, 2025

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456, multiple issues should use full syntax for each issue and be separated by a comma, like: Issue Number: close #123, ref #456.

📖 For more info, you can check the "Linking issues" section in the CONTRIBUTING.md.

@ti-chi-bot ti-chi-bot bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Dec 1, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 1, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign qiuyesuifeng for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the contribution This PR is from a community contributor. label Dec 1, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 1, 2025

Hi @ljluestc. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. dco-signoff: no Indicates the PR's author has not signed dco. labels Dec 1, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 1, 2025

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. dco-signoff: no Indicates the PR's author has not signed dco. do-not-merge/needs-linked-issue do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant