You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Jordan Pilat <jr...@gmail.com> on 2018/06/27 20:57:35 UTC

Unclean Leader Election Expected Behavior

Heya,

I had a question about what behavior to expect from a particular scenario.  Given:
A. Unclean leader elections are disabled
B. A partition is led by Broker1 and followed by Broker2
C. Broker1 is on offset 100
D. Broker2 is on offset 90
E. Broker2 has fallen out of the ISR, leaving only Broker1 in the ISR
F. Broker1 has a hard drive failure and goes down.  All messages for the partition in question are permanently lost.

_As I understand it_, the only way for the partition to come back online is to bring Broker1 back online, and suffer the loss of 100 messages (as Broker2's log will be truncated to Broker1's offset, which will start from scratch due to the hard drive loss)

Is there a procedure in such a case, to force-elect Broker2 the leader, and thus only lose 10 messages?

Thanks!
- Jordan Pilat

Re: Unclean Leader Election Expected Behavior

Posted by Manikumar <ma...@gmail.com>.
In your case, you need to restart B2 with unclean.leader.election=true.
This will enable B2 to become leader with 90 messages.

On Thu, Jun 28, 2018 at 11:51 PM Jordan Pilat <jr...@gmail.com> wrote:

> If I restart the broker, won't that cause all 100 messages to be lost?
>
> On 2018/06/28 02:59:15, Manikumar <ma...@gmail.com> wrote:
> > You can enable unclean.leader.election temporarily for specific topic by
> > using kafka-topics.sh command.
> > This requires broker restart to take effect.
> >
> >  http://kafka.apache.org/documentation/#topicconfigs
> >
> > On Thu, Jun 28, 2018 at 2:27 AM Jordan Pilat <jr...@gmail.com> wrote:
> >
> > > Heya,
> > >
> > > I had a question about what behavior to expect from a particular
> > > scenario.  Given:
> > > A. Unclean leader elections are disabled
> > > B. A partition is led by Broker1 and followed by Broker2
> > > C. Broker1 is on offset 100
> > > D. Broker2 is on offset 90
> > > E. Broker2 has fallen out of the ISR, leaving only Broker1 in the ISR
> > > F. Broker1 has a hard drive failure and goes down.  All messages for
> the
> > > partition in question are permanently lost.
> > >
> > > _As I understand it_, the only way for the partition to come back
> online
> > > is to bring Broker1 back online, and suffer the loss of 100 messages
> (as
> > > Broker2's log will be truncated to Broker1's offset, which will start
> from
> > > scratch due to the hard drive loss)
> > >
> > > Is there a procedure in such a case, to force-elect Broker2 the leader,
> > > and thus only lose 10 messages?
> > >
> > > Thanks!
> > > - Jordan Pilat
> > >
> >
>

Re: Unclean Leader Election Expected Behavior

Posted by Jordan Pilat <jr...@gmail.com>.
If I restart the broker, won't that cause all 100 messages to be lost?

On 2018/06/28 02:59:15, Manikumar <ma...@gmail.com> wrote: 
> You can enable unclean.leader.election temporarily for specific topic by
> using kafka-topics.sh command.
> This requires broker restart to take effect.
> 
>  http://kafka.apache.org/documentation/#topicconfigs
> 
> On Thu, Jun 28, 2018 at 2:27 AM Jordan Pilat <jr...@gmail.com> wrote:
> 
> > Heya,
> >
> > I had a question about what behavior to expect from a particular
> > scenario.  Given:
> > A. Unclean leader elections are disabled
> > B. A partition is led by Broker1 and followed by Broker2
> > C. Broker1 is on offset 100
> > D. Broker2 is on offset 90
> > E. Broker2 has fallen out of the ISR, leaving only Broker1 in the ISR
> > F. Broker1 has a hard drive failure and goes down.  All messages for the
> > partition in question are permanently lost.
> >
> > _As I understand it_, the only way for the partition to come back online
> > is to bring Broker1 back online, and suffer the loss of 100 messages (as
> > Broker2's log will be truncated to Broker1's offset, which will start from
> > scratch due to the hard drive loss)
> >
> > Is there a procedure in such a case, to force-elect Broker2 the leader,
> > and thus only lose 10 messages?
> >
> > Thanks!
> > - Jordan Pilat
> >
> 

Re: Unclean Leader Election Expected Behavior

Posted by Manikumar <ma...@gmail.com>.
You can enable unclean.leader.election temporarily for specific topic by
using kafka-topics.sh command.
This requires broker restart to take effect.

 http://kafka.apache.org/documentation/#topicconfigs

On Thu, Jun 28, 2018 at 2:27 AM Jordan Pilat <jr...@gmail.com> wrote:

> Heya,
>
> I had a question about what behavior to expect from a particular
> scenario.  Given:
> A. Unclean leader elections are disabled
> B. A partition is led by Broker1 and followed by Broker2
> C. Broker1 is on offset 100
> D. Broker2 is on offset 90
> E. Broker2 has fallen out of the ISR, leaving only Broker1 in the ISR
> F. Broker1 has a hard drive failure and goes down.  All messages for the
> partition in question are permanently lost.
>
> _As I understand it_, the only way for the partition to come back online
> is to bring Broker1 back online, and suffer the loss of 100 messages (as
> Broker2's log will be truncated to Broker1's offset, which will start from
> scratch due to the hard drive loss)
>
> Is there a procedure in such a case, to force-elect Broker2 the leader,
> and thus only lose 10 messages?
>
> Thanks!
> - Jordan Pilat
>