jsancio commented on a change in pull request #10899: URL: https://github.com/apache/kafka/pull/10899#discussion_r655542285
########## File path: raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java ########## @@ -233,6 +235,68 @@ public void appendLeaderChangeMessage(LeaderChangeMessage leaderChangeMessage, l } } + + public void appendSnapshotHeaderMessage(MetadataSnapshotHeaderRecord snapshotHeaderRecord) { + appendLock.lock(); + try { + // Ideally there should be nothing in the batch here. + // TODO verify this Review comment: It is a valid/correct check but it doesn't cover all of the cases. For example, in theory `SnapshotWriter` could do the following: ``` accumulator.appendSnapshotHeaderMessage(...); snapshot.appendBatches(accumulator.drain()); accumulator.appendSnapshotHeaderMessage(...); ``` This is okay from the `BatchAccumulator`'s point of view because the accumulator doesn't have enough information. I am also not sure if we want to encode the invariant of `SnapshotHeaderMessage` and `SnaspshotFooterMessage` into the `BatchAccumulator`. I think only the `SnapshotWriter` has enough information to make these invariant checks. What do you think? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org