Skip to content

Commit

Permalink
fix(common): only warn on dropping non-empty builder (risingwavelabs#…
Browse files Browse the repository at this point in the history
…8494)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
  • Loading branch information
BugenZhao authored Mar 13, 2023
1 parent e1ae04e commit 79a3786
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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

0 comments on commit 79a3786

Please sign in to comment.