Skip to content

fix(common): only warn on dropping non-empty builder #8494

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

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/common/src/util/chunk_coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ impl DataChunkBuilder {
}
}

impl Drop for DataChunkBuilder {
fn drop(&mut self) {
// Possible to fail when async task gets cancelled.
if self.buffered_count != 0 {
tracing::warn!(
remaining = self.buffered_count,
"dropping non-empty data chunk builder"
);
}
}
}

/// The iterator that yields data chunks during appending a data chunk to a [`DataChunkBuilder`].
pub struct AppendDataChunk<'a> {
builder: &'a mut DataChunkBuilder,
Expand All @@ -249,6 +261,7 @@ impl FusedIterator for AppendDataChunk<'_> {}

impl Drop for AppendDataChunk<'_> {
fn drop(&mut self) {
// Possible to fail when async task gets cancelled.
if self.remaining.is_some() {
tracing::warn!("dropping `AppendDataChunk` without exhausting it");
}
Expand Down
9 changes: 7 additions & 2 deletions src/stream/src/common/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ pub struct StreamChunkBuilder {

impl Drop for StreamChunkBuilder {
fn drop(&mut self) {
// Possible to fail in some corner cases but should not in unit tests
debug_assert_eq!(self.size, 0, "dropping non-empty stream chunk builder");
// Possible to fail when async task gets cancelled.
if self.size != 0 {
tracing::warn!(
remaining = self.size,
"dropping non-empty stream chunk builder"
);
}
}
}

Expand Down