Skip to content
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

fix: fix RangeWriter incorrect next_offset #3927

Merged
merged 1 commit into from
Jan 6, 2024
Merged
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: 6 additions & 7 deletions core/src/raw/oio/write/range_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait RangeWrite: Send + Sync + Unpin + 'static {
async fn abort_range(&self, location: &str) -> Result<()>;
}

struct WriteRangeFuture(BoxedFuture<Result<u64>>);
struct WriteRangeFuture(BoxedFuture<Result<()>>);

/// # Safety
///
Expand All @@ -99,7 +99,7 @@ unsafe impl Send for WriteRangeFuture {}
unsafe impl Sync for WriteRangeFuture {}

impl Future for WriteRangeFuture {
type Output = Result<u64>;
type Output = Result<()>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.get_mut().0.poll_unpin(cx)
}
Expand Down Expand Up @@ -177,12 +177,11 @@ impl<W: RangeWrite> oio::Write for RangeWriter<W> {
AsyncBody::ChunkedBytes(cache),
)
.await
.map(|_| size)
})));
let size = self.fill_cache(bs);
return Poll::Ready(Ok(size));
} else if let Some(size) = ready!(self.futures.poll_next_unpin(cx)) {
self.next_offset += size?;
} else if let Some(result) = ready!(self.futures.poll_next_unpin(cx)) {
result?;
}
}
None => {
Expand Down Expand Up @@ -221,8 +220,8 @@ impl<W: RangeWrite> oio::Write for RangeWriter<W> {
match self.location.clone() {
Some(location) => {
if !self.futures.is_empty() {
while let Some(size) = ready!(self.futures.poll_next_unpin(cx)) {
self.next_offset += size?;
while let Some(result) = ready!(self.futures.poll_next_unpin(cx)) {
result?;
}
}
match self.buffer.take() {
Expand Down
Loading