-
Notifications
You must be signed in to change notification settings - Fork 14.4k
KAFKA-19338: Error on read/write of uninitialized share part. #19861
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Looks good in general but one query to clear up please.
@@ -644,8 +632,7 @@ public CoordinatorResult<Void, CoordinatorRecord> maybeCleanupShareState(Set<Uui | |||
/** | |||
* Util method to generate a ShareSnapshot or ShareUpdate type record for a key, based on various conditions. | |||
* <p> | |||
* If no snapshot has been created for the key => create a new ShareSnapshot record | |||
* else if number of ShareUpdate records for key >= max allowed per snapshot per key => create a new ShareSnapshot record | |||
* Ff number of ShareUpdate records for key >= max allowed per snapshot per key or stateEpoch is highest seen => create a new ShareSnapshot record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: What's "Ff"?
.setWriteTimestamp(timestamp) | ||
.build()); | ||
} else if (snapshotUpdateCount.getOrDefault(key, 0) >= updatesPerSnapshotLimit || partitionData.stateEpoch() > shareStateMap.get(key).stateEpoch()) { | ||
if (snapshotUpdateCount.getOrDefault(key, 0) >= updatesPerSnapshotLimit || partitionData.stateEpoch() > shareStateMap.get(key).stateEpoch()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's possible for shareStateMap
not to contain the key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AndrewJSchofield ,
Thanks for the review.
No, it is not possible since this method is called from ShareCoordinatorShard.writeState
and ShareCoordinatorShard.readStateAndMaybeUpdateLeaderEpoch
. But before calling it - both methods do error checking (maybeGetWriteStateError
, maybeGetReadStateError
) where they explicitly check that the shareStateMap
is not empty and return "read/write on uninitialized share partition" error.
New tests testWriteFailsOnUninitializedPartition
and testReadFailsOnUninitializedPartition
add proof for the same.
Will add additional javadoc to clarify.
uninitialized share partitions (share partitions on which
initializeState has NOT been called). This should not be the case.
write. Other requests are allowed (initialize, readSummary, alter).
ShareCoordinatorShardTest
to reduce redundancy and addedsome new tests.
Reviewers: Andrew Schofield aschofield@confluent.io