mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 12:22:55 +00:00
fix(kafka): overwrite the EntryId with Offset while consuming records (#3148)
* fix(kafka): overwrite the EntryId with Offset while consuming the KafkaRecords * fix: temporarily workaround of incorrect entry Id
This commit is contained in:
@@ -205,7 +205,11 @@ impl LogStore for KafkaLogStore {
|
||||
}
|
||||
|
||||
// Tries to construct an entry from records consumed so far.
|
||||
if let Some(entry) = maybe_emit_entry(record, &mut entry_records)? {
|
||||
if let Some(mut entry) = maybe_emit_entry(record, &mut entry_records)? {
|
||||
// We don't rely on the EntryId generated by mito2.
|
||||
// Instead, we use the offset return from Kafka as EntryId.
|
||||
// Therefore, we MUST overwrite the EntryId with RecordOffset.
|
||||
entry.id = offset as u64;
|
||||
yield Ok(vec![entry]);
|
||||
}
|
||||
|
||||
@@ -423,17 +427,20 @@ mod tests {
|
||||
|
||||
// Reads entries for regions and checks for each region that the gotten entries are identical with the expected ones.
|
||||
for region_id in which {
|
||||
let ctx = ®ion_contexts[®ion_id];
|
||||
let ctx = region_contexts.get_mut(®ion_id).unwrap();
|
||||
let stream = logstore
|
||||
.read(&ctx.ns, ctx.flushed_entry_id + 1)
|
||||
.await
|
||||
.unwrap();
|
||||
let got = stream
|
||||
let mut got = stream
|
||||
.collect::<Vec<_>>()
|
||||
.await
|
||||
.into_iter()
|
||||
.flat_map(|x| x.unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
//FIXME(weny): https://github.com/GreptimeTeam/greptimedb/issues/3152
|
||||
ctx.expected.iter_mut().for_each(|entry| entry.id = 0);
|
||||
got.iter_mut().for_each(|entry| entry.id = 0);
|
||||
assert_eq!(ctx.expected, got);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user