cmccabe commented on a change in pull request #10812: URL: https://github.com/apache/kafka/pull/10812#discussion_r658329637
########## File path: metadata/src/main/java/org/apache/kafka/controller/QuorumController.java ########## @@ -877,6 +880,35 @@ private void replay(ApiMessage message, Optional<OffsetAndEpoch> snapshotId, lon } } + private void checkSnapshotGeneration(long batchSizeInBytes) { + newBytesSinceLastSnapshot += batchSizeInBytes; + if (newBytesSinceLastSnapshot >= snapshotMinNewRecordBytes && + snapshotGeneratorManager.generator == null + ) { + boolean isActiveController = curClaimEpoch != -1; + if (!isActiveController) { + // The active controller creates in-memory snapshot every time an uncommitted + // batch gets appended. The in-active controller can be more efficient and only + // create an in-memory snapshot when needed. + snapshotRegistry.createSnapshot(lastCommittedOffset); + } + + snapshotGeneratorManager.createSnapshotGenerator(lastCommittedOffset, lastCommittedEpoch); + newBytesSinceLastSnapshot = 0; + } + } + + private void resetState() { Review comment: It would be nice to call this from the QuorumController constructor so we get more test coverage on it (and so that we only have one place setting up the initial values.) I think we can do that, right? -- 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