You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "mehbey (via GitHub)" <gi...@apache.org> on 2023/05/12 18:28:31 UTC
[GitHub] [kafka] mehbey commented on a diff in pull request #13709: KAFKA-14991:Added a validation to check if the record timestamp is in the future compared to the broker's timestamp
mehbey commented on code in PR #13709:
URL: https://github.com/apache/kafka/pull/13709#discussion_r1192680413
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogValidator.java:
##########
@@ -590,18 +593,25 @@ private static Optional<ApiRecordError> validateTimestamp(RecordBatch batch,
TimestampType timestampType,
long timestampDiffMaxMs) {
if (timestampType == TimestampType.CREATE_TIME
- && record.timestamp() != RecordBatch.NO_TIMESTAMP
- && Math.abs(record.timestamp() - now) > timestampDiffMaxMs)
- return Optional.of(new ApiRecordError(Errors.INVALID_TIMESTAMP, new RecordError(batchIndex,
- "Timestamp " + record.timestamp() + " of message with offset " + record.offset()
- + " is out of range. The timestamp should be within [" + (now - timestampDiffMaxMs)
- + ", " + (now + timestampDiffMaxMs) + "]")));
+ && record.timestamp() != RecordBatch.NO_TIMESTAMP){
+ final long timestampDiff = record.timestamp() - now;
+ if(timestampDiff > TIME_DRIFT_TOLERANCE){
+ return Optional.of(new ApiRecordError(Errors.INVALID_TIMESTAMP, new RecordError(batchIndex,
+ "Timestamp " + record.timestamp() + " of message with offset " + record.offset()
+ + " is ahead of the server's time. " + now)));
Review Comment:
updated - thank you
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org