Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-13093: Log compaction should write new segments with record version v2 (KIP-724) #18321

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from

Conversation

ijuma
Copy link
Member

@ijuma ijuma commented Dec 26, 2024

Convert v0/v1 record batches to v2 during compaction even if said record batches would be
written with no change otherwise. A few important details:

  1. V0 compressed record batch with multiple records is converted into single V2 record batch
  2. V0 uncompressed records are converted into single record V2 record batches
  3. V0 records are converted to V2 records with timestampType set to CreateTime and the
    timestamp is -1.
  4. The KAFKA-4298 workaround is no longer needed since the conversion to V2 fixes
    the issue too.
  5. Removed a log warning applicable to consumers older than 0.10.1 - they are no longer
    supported.
  6. Added back the ability to append records with v0/v1 (for testing only).
  7. The creation of the leader epoch cache is no longer optional since the record version
    config is effectively always V2.

Add integration tests, these tests existed before #18267 - restored, modified and
extended them.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@github-actions github-actions bot added triage PRs from the community core Kafka Broker consumer clients labels Dec 26, 2024
@ijuma ijuma removed the triage PRs from the community label Dec 26, 2024
@ijuma ijuma force-pushed the kafka-13093-log-compaction-write-record-v2 branch from f38e108 to d41a6e2 Compare December 27, 2024 18:50
@github-actions github-actions bot added the storage Pull requests that target the storage module label Dec 27, 2024
@@ -2580,6 +2580,23 @@ class UnifiedLogTest {
assertEquals(None, log.leaderEpochCache.flatMap(_.latestEpoch.toScala))
}

@Test
def testLeaderEpochCacheCreatedAfterMessageFormatUpgrade(): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was originally removed via #18267 - added it back and modified it to take into account that the leader epoch cache always exists now (since the configured record version is always V2).

@ijuma ijuma requested a review from junrao December 29, 2024 17:23
@@ -262,12 +261,6 @@ object LogTestUtils {
def listProducerSnapshotOffsets(logDir: File): Seq[Long] =
ProducerStateManager.listSnapshotFiles(logDir).asScala.map(_.offset).sorted.toSeq

def assertLeaderEpochCacheEmpty(log: UnifiedLog): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused.

@@ -134,6 +135,131 @@ class LogCleanerParameterizedIntegrationTest extends AbstractLogCleanerIntegrati
assertEquals(toMap(messages), toMap(read), "Contents of the map shouldn't change")
}

@ParameterizedTest
@ArgumentsSource(classOf[LogCleanerParameterizedIntegrationTest.ExcludeZstd])
def testCleanerWithMessageFormatV0V1V2(compressionType: CompressionType): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

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

The tests added in this class were originally removed via #18267 - added them back, modified them to fit the new reality and extended them to include more extensive verification of the log after compaction.

@ijuma ijuma force-pushed the kafka-13093-log-compaction-write-record-v2 branch from 0ede54e to a50bd5d Compare December 29, 2024 17:43
@ijuma
Copy link
Member Author

ijuma commented Dec 29, 2024

@junrao Would you be able to review this PR? I would like to include it in Apache Kafka 4.0, if possible - it completes KIP-724.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clients consumer core Kafka Broker storage Pull requests that target the storage module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant