From f9bd825ee1aa7d3fe88c36f264728a14b703a5aa Mon Sep 17 00:00:00 2001 From: Marko Grujic Date: Thu, 8 Sep 2022 09:26:25 +0200 Subject: [PATCH 1/2] Fix multiple part uploads at once making vector size inconsistent --- object_store/src/multipart.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/object_store/src/multipart.rs b/object_store/src/multipart.rs index 1985d8694e5..0e056447e8b 100644 --- a/object_store/src/multipart.rs +++ b/object_store/src/multipart.rs @@ -94,11 +94,10 @@ where if self.tasks.is_empty() { return Ok(()); } - let total_parts = self.completed_parts.len(); while let Poll::Ready(Some(res)) = self.tasks.poll_next_unpin(cx) { let (part_idx, part) = res?; self.completed_parts - .resize(std::cmp::max(part_idx + 1, total_parts), None); + .resize(std::cmp::max(part_idx + 1, self.completed_parts.len()), None); self.completed_parts[part_idx] = Some(part); } Ok(()) From a2d345725b56234466b91f0f64ac2be0772e1014 Mon Sep 17 00:00:00 2001 From: Marko Grujic Date: Thu, 8 Sep 2022 10:08:56 +0200 Subject: [PATCH 2/2] Calculate total_parts prior to resizing the vector --- object_store/src/multipart.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/object_store/src/multipart.rs b/object_store/src/multipart.rs index 0e056447e8b..102d8bedaa4 100644 --- a/object_store/src/multipart.rs +++ b/object_store/src/multipart.rs @@ -96,8 +96,9 @@ where } while let Poll::Ready(Some(res)) = self.tasks.poll_next_unpin(cx) { let (part_idx, part) = res?; + let total_parts = self.completed_parts.len(); self.completed_parts - .resize(std::cmp::max(part_idx + 1, self.completed_parts.len()), None); + .resize(std::cmp::max(part_idx + 1, total_parts), None); self.completed_parts[part_idx] = Some(part); } Ok(())