You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jose Armando Garcia Sancio (Jira)" <ji...@apache.org> on 2021/08/03 16:41:00 UTC
[jira] [Updated] (KAFKA-12333) KafkaMetadataLog and MockLock should
validate that appended epochs are monotonically
[ https://issues.apache.org/jira/browse/KAFKA-12333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jose Armando Garcia Sancio updated KAFKA-12333:
-----------------------------------------------
Description:
Both the MockLog and KafkaMetadataLog should only allow appendAsLeader and appendAsFollower with monotonically increasing epochs. In other words the following test in KafkaMetadataLogTest should fail:
{code:java}
@Test
def testOutOfOrderEpoch(): Unit = {
val topicPartition = new TopicPartition("cluster-metadata", 0)
val log = buildMetadataLog(tempDir, mockTime, topicPartition) val recordFoo = new SimpleRecord("foo".getBytes())
val currentEpoch = 3
val initialOffset = log.endOffset().offset log.appendAsLeader(
MemoryRecords.withRecords(initialOffset, CompressionType.NONE, currentEpoch, recordFoo),
currentEpoch
) // Out order epoch should throw an exception
log.appendAsLeader(
MemoryRecords.withRecords(
initialOffset + 1, CompressionType.NONE, currentEpoch - 1, recordFoo
),
currentEpoch - 1
)
log.appendAsFollower(
MemoryRecords.withRecords(
initialOffset + 2, CompressionType.NONE, currentEpoch - 2, recordFoo
)
)
} {code}
The same for MockLogTest.
was:
Both the MockLog and KafkaMetadataLog should only allow appendAsLeader and appendAsFollower with monotonically increasing epochs. In other words the following test in KafkaMetadataLogTest should fail:
{code:java}
@Test
def testOutOfOrderEpoch(): Unit = {
val topicPartition = new TopicPartition("cluster-metadata", 0)
val log = buildMetadataLog(tempDir, mockTime, topicPartition) val recordFoo = new SimpleRecord("foo".getBytes())
val currentEpoch = 3
val initialOffset = log.endOffset().offset log.appendAsLeader(
MemoryRecords.withRecords(initialOffset, CompressionType.NONE, currentEpoch, recordFoo),
currentEpoch
) // Out order epoch should throw an exception
log.appendAsLeader(
MemoryRecords.withRecords(
initialOffset + 1, CompressionType.NONE, currentEpoch - 1, recordFoo
),
currentEpoch - 1
) log.appendAsFollower(
MemoryRecords.withRecords(
initialOffset + 2, CompressionType.NONE, currentEpoch - 2, recordFoo
)
)
} {code}
The same for MockLogTest.
> KafkaMetadataLog and MockLock should validate that appended epochs are monotonically
> ------------------------------------------------------------------------------------
>
> Key: KAFKA-12333
> URL: https://issues.apache.org/jira/browse/KAFKA-12333
> Project: Kafka
> Issue Type: Sub-task
> Components: replication
> Reporter: Jose Armando Garcia Sancio
> Assignee: HaiyuanZhao
> Priority: Major
>
> Both the MockLog and KafkaMetadataLog should only allow appendAsLeader and appendAsFollower with monotonically increasing epochs. In other words the following test in KafkaMetadataLogTest should fail:
> {code:java}
> @Test
> def testOutOfOrderEpoch(): Unit = {
> val topicPartition = new TopicPartition("cluster-metadata", 0)
> val log = buildMetadataLog(tempDir, mockTime, topicPartition) val recordFoo = new SimpleRecord("foo".getBytes())
> val currentEpoch = 3
> val initialOffset = log.endOffset().offset log.appendAsLeader(
> MemoryRecords.withRecords(initialOffset, CompressionType.NONE, currentEpoch, recordFoo),
> currentEpoch
> ) // Out order epoch should throw an exception
> log.appendAsLeader(
> MemoryRecords.withRecords(
> initialOffset + 1, CompressionType.NONE, currentEpoch - 1, recordFoo
> ),
> currentEpoch - 1
> )
> log.appendAsFollower(
> MemoryRecords.withRecords(
> initialOffset + 2, CompressionType.NONE, currentEpoch - 2, recordFoo
> )
> )
> } {code}
> The same for MockLogTest.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)