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-3755 Tightening the offset check in ReplicaFetcherThread #1506

Closed
wants to merge 1 commit into from

Conversation

imandhan
Copy link
Contributor

Including an additional check to make sure that the first offset in the message set to be appended to the log is >= than the log end offset.

Including additional check to make sure that the first offset in the message set to be appended to the log is >= than the log end offset.
@ijuma
Copy link
Contributor

ijuma commented Jun 15, 2016

Thanks for the PR, it would be good to include a test that validates the change.

@@ -119,6 +119,8 @@ class ReplicaFetcherThread(name: String,

if (fetchOffset != replica.logEndOffset.messageOffset)
throw new RuntimeException("Offset mismatch for partition %s: fetched offset = %d, log end offset = %d.".format(topicAndPartition, fetchOffset, replica.logEndOffset.messageOffset))
if (!messageSet.isEmpty && messageSet.head.offset < replica.logEndOffset.messageOffset)
throw new RuntimeException("Offset error for partition %s: first offset in message set = %d, must not be less than log end offset = %d.".format(topicAndPartition, messageSet.head.offset, replica.logEndOffset.messageOffset))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: it would be good to break the line so that the line length fits within the GitHub review window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll have the .format() part in the next line in the next patch set with the test case. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

@imandhan : Instead of adding the checking here, it's probably better to do that in Log.append(). In the path where assignOffsets is false, we can just require that appendInfo.firstOffset >= nextOffsetMetadata.messageOffset. This also makes testing easier since it can be done on an instance of Log.

Copy link
Contributor Author

@imandhan imandhan Jun 16, 2016

Choose a reason for hiding this comment

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

@junrao looks like Log.append() already has that check. See https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/log/Log.scala#L370 Am I misunderstanding something here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@imandhan : Yes, you are right. I didn't realize that we already had a check there and a unit test for it. Sorry for the confusion. I will close the jira and mark it as a non-issue. Hopefully that you can find some other Kafka jiras to contribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good :)

@imandhan
Copy link
Contributor Author

@ijuma Sure, I can add a test case but am not sure what file to add it to since there doesn't seem to be a test file corresponding to ReplicaFetcherThread.

@ijuma
Copy link
Contributor

ijuma commented Jun 16, 2016

Since we are not doing this anymore, can you please close the PR? (we can't close it ourselves).

@imandhan imandhan closed this Jun 16, 2016
@imandhan
Copy link
Contributor Author

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants