This is interesting test. I suppose this is because while broker 0 was the leader broker 1 was completely down and broker 1's log end offset never increased. So when it came back up and since broker 0 was down you got a lag of -1000.
Thanks, Mayuresh On Mon, Mar 2, 2015 at 3:15 AM, tao xiao <xiaotao...@gmail.com> wrote: > Hi team, > > I have 2 brokers (0 and 1) serving a topic mm-benchmark-test. I did some > tests on the two brokers to verify how leader got elected. Here are the > steps: > > 1. started 2 brokers > 2. created a topic with partition=1 and replication-factor=2. Now brokers 1 > was elected as leader > 3. sent 1000 messages to the topic and consumed from a high level consumer > using zk as the offset storage. > 4. shutdown broker 1 and now broker 0 was elected as leader > 5. sent another 1000 messages to topic and consumed again > 6. completely shutdown broker 0 and then started broker 1. now broker 1 > became the leader > 7. started broker 0 and ran ConsumerOffsetChecker which showed negative lag > (-1000 in my case) > > I think this is because the consumed offset in zk was 2000 and logsize > retrieved from the leader (broker 1) which missed 1000 messages in step 5 > in this case was 1000 there -1000 = 1000 - 2000 was given. > > Is this a bug or expected behavior? > > -- > Regards, > Tao > -- -Regards, Mayuresh R. Gharat (862) 250-7125