Skip to content

Conversation

@cmccabe
Copy link
Contributor

@cmccabe cmccabe commented Nov 22, 2021

When creating snapshots, controllers generate a ProducerIdsRecord indicating the highest producer ID
that has been used so far. Brokers should generate the same record, so that the snapshots can be
compared.

Also, fix a bug in MetadataDelta#finishSnapshot. The current logic will produce the wrong result if
all objects of a certain type are completely removed in the snapshot. The fix is to unconditionally
create each delta object.

When creating snapshots, controllers generate a ProducerIdsRecord indicating the highest producer ID
that has been used so far. Brokers should generate the same record, so that the snapshots can be
compared.

Also, fix a bug in MetadataDelta#finishSnapshot. The current logic will produce the wrong result if
all objects of a certain type are completely removed in the snapshot. The fix is to unconditionally
create each delta object.
@cmccabe cmccabe changed the title MINOR: store producer IDs in broker snapshots KAFKA-13357: store producer IDs in broker snapshots Nov 22, 2021
Copy link
Member

@jsancio jsancio 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 changes @cmccabe

new ProducerIdsRecord().
setBrokerId(-1).
setBrokerEpoch(-1).
setProducerIdsEnd(highestSeenProducerId), (short) 0)));
Copy link
Member

Choose a reason for hiding this comment

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

Okay. Is it fair to assume that we will revisit this code regarding the version in ApiMessageAndVersionas part of KIP-778?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we will need to have some versioning code in after KIP-778, so that we generate a snapshot at the appropriate metadata.version. Probably this will take the form of adding a version parameter to the snapshot generation function. cc @mumrah

out.accept(Collections.singletonList(new ApiMessageAndVersion(
new ProducerIdsRecord().
setBrokerId(-1).
setBrokerEpoch(-1).
Copy link
Member

Choose a reason for hiding this comment

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

Broker id and epoch are only used to debugging right? Neither the broker nor the controller use these values, right? Do you think it makes sense to just remember and persist this value in the snapshot just for consistency with the log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's useful in the log as a kind of record of what happened. I think it's much less useful in the snapshot since at most we would be just giving the very latest broker to request producer ids, which isn't very interesting for debugging, 99% of the time.

@jsancio jsancio added the kraft label Nov 22, 2021
cmccabe and others added 2 commits November 22, 2021 15:41
…Test.java

Co-authored-by: José Armando García Sancio <jsancio@users.noreply.github.com>
…Test.java

Co-authored-by: José Armando García Sancio <jsancio@users.noreply.github.com>
Copy link
Member

@jsancio jsancio left a comment

Choose a reason for hiding this comment

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

We are getting unrelated test failures:

    Build / JDK 17 and Scala 2.13 / kafka.admin.LeaderElectionCommandTest.[1] Type=Raft, Name=testAllTopicPartition, Security=PLAINTEXT
    Build / JDK 17 and Scala 2.13 / kafka.admin.LeaderElectionCommandTest.[1] Type=Raft, Name=testAllTopicPartition, Security=PLAINTEXT
    Build / JDK 8 and Scala 2.12 / kafka.server.KRaftClusterTest.testCreateClusterAndPerformReassignment()

@jsancio
Copy link
Member

jsancio commented Nov 24, 2021

Closing since I merged e8b53ca.

I think GitHub didn't close this PR because I didn't reference the PR number in the title.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants