Skip to content

Commit

Permalink
dekaf: Always return at least 2 docs for data preview UI requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jshearer committed Oct 18, 2024
1 parent 5714bb3 commit 22636f4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/dekaf/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{
collections::{hash_map::Entry, HashMap},
time::{SystemTime, UNIX_EPOCH},
};
use std::{sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration, cmp::max};
use tracing::instrument;

struct PendingRead {
Expand Down Expand Up @@ -491,7 +491,10 @@ impl Session {
Some(partition_request.fetch_offset - 1),
)
.next_batch(
crate::read::ReadTarget::Docs(diff as usize + 1),
// Have to read at least 2 docs, as the very last doc
// will probably be a control document and will be
// ignored by the consumer, looking like 0 docs were read
crate::read::ReadTarget::Docs(max(diff as usize, 2)),
std::time::Instant::now() + timeout,
),
)
Expand Down

0 comments on commit 22636f4

Please sign in to comment.