Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use confirmed term as a source of leader epoch #16560

Merged
merged 2 commits into from
Feb 11, 2024

Conversation

mmaslankaprv
Copy link
Member

@mmaslankaprv mmaslankaprv commented Feb 9, 2024

A leader epoch is used by Kafka clients to determine if a replica is up
to date with the leader and to detect truncation.

The leader epoch differs from Raft term as the term is updated when
leader election starts. Whereas the leader epoch is updated after the
state of the replica is determined. Therefore the leader epoch uses
confirmed term instead of the simple term which is incremented every
time the leader election starts.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

Bug Fixes

  • Prevent detecting leader epoch advancement when state is not up to date

A confirmed term is used to determine if the state of a replica is up
to date after the leader election. Only after the confirmed term is equal
to the current term one can reason about the Raft group state.

On the leader the confirmed term is updated after first successful
replication of a batch subsequent to a leader election. After the
replication succeed leader is guaranteed to have up to date committed
and visible offsets.

On the follower the confirmed term is updated only when an append
entries request from the current leader may be accepted and follower
may return success.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
A leader epoch is used by Kafka clients to determine if a replica is up
to date with the leader and to detect truncation.

The leader epoch differs from Raft term as the term is updated when
leader election starts. Whereas the leader epoch is updated after the
state of the replica is determined. Therefore the leader epoch uses
confirmed term instead of the simple term which is incremented every
time the leader election starts.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
@vbotbuildovich
Copy link
Collaborator

new failures in https://buildkite.com/redpanda/redpanda/builds/44940#018d8dc3-d067-4a62-a6ec-067850966942:

"rptest.tests.partition_movement_test.SIPartitionMovementTest.test_cross_shard.num_to_upgrade=0.cloud_storage_type=CloudStorageType.S3"

@piyushredpanda
Copy link
Contributor

failure is #16540

@piyushredpanda piyushredpanda merged commit 382b3fc into redpanda-data:dev Feb 11, 2024
19 of 21 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

@vbotbuildovich
Copy link
Collaborator

/backport v23.2.x

@vbotbuildovich
Copy link
Collaborator

Failed to create a backport PR to v23.2.x branch. I tried:

git remote add upstream https://github.com/redpanda-data/redpanda.git
git fetch --all
git checkout -b backport-pr-16560-v23.2.x-793 remotes/upstream/v23.2.x
git cherry-pick -x 6037462dfa080c23df509db0d766d5338eccef21 e746f79bd85a288b378a1dcbcdb6d0c9cf25f853

Workflow run logs.

Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the excellent code comments explaining the leader_epoch!

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

Successfully merging this pull request may close these issues.

None yet

5 participants