KAFKA-14618; Fix off by one error in snapshot id (#13108)
The KRaft client expects the offset of the snapshot id to be an end offset. End offsets are
exclusive. The MetadataProvenance type was createing a snapshot id using the last contained offset
which is inclusive. This change fixes that and renames some of the fields to make this difference
more obvious.
Reviewers: Colin P. McCabe <cmccabe@apache.org>
pull/13059/head
José Armando García Sancio2 years agocommitted byGitHub
@ -79,7 +79,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -79,7 +79,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@ -278,7 +278,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -278,7 +278,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@ -286,10 +286,10 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -286,10 +286,10 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
}catch(Throwablee){
faultHandler.handleFault("Error generating new metadata image from "+
"metadata delta between offset "+image.offset()+
" and "+manifest.provenance().offset(),e);
" and "+manifest.provenance().lastContainedOffset(),e);
log.debug("Publishing new image with provenance {}.",image.provenance());
@ -298,7 +298,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -298,7 +298,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
publisher.publishLogDelta(delta,image,manifest);
}catch(Throwablee){
faultHandler.handleFault("Unhandled error publishing the new metadata "+
"image ending at "+manifest.provenance().offset()+
"image ending at "+manifest.provenance().lastContainedOffset()+
" with publisher "+publisher.name(),e);
}
}
@ -332,8 +332,8 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -332,8 +332,8 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@ -376,7 +376,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -376,7 +376,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
log.debug("Generated a metadata delta from a snapshot at offset {} "+
"in {} us.",manifest.provenance().offset(),
"in {} us.",manifest.provenance().lastContainedOffset(),
NANOSECONDS.toMicros(manifest.elapsedNs()));
}
try{
@ -386,7 +386,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
@@ -386,7 +386,7 @@ public class MetadataLoader implements RaftClient.Listener<ApiMessageAndVersion>
"snapshot at offset "+reader.lastContainedLogOffset(),e);
@ -98,9 +98,10 @@ public class SnapshotEmitter implements SnapshotGenerator.Emitter {
@@ -98,9 +98,10 @@ public class SnapshotEmitter implements SnapshotGenerator.Emitter {
@ -205,8 +205,7 @@ public class SnapshotGenerator implements MetadataPublisher {
@@ -205,8 +205,7 @@ public class SnapshotGenerator implements MetadataPublisher {
MetadataImagenewImage,
SnapshotManifestmanifest
){
log.debug("Resetting the snapshot counters because we just read a snapshot at offset {}.",
newImage.provenance().offset());
log.debug("Resetting the snapshot counters because we just read {}.",newImage.provenance().snapshotName());