Skip to content

Commit 43731ce

Browse files
tlrxmridula-s109
authored andcommitted
Fix computation of last block size in Azure concurrent multipart uploads (#128746)
Last part size is wrongly computed to 0 when the last part's length is exactly equal to the size of a part. Would have probably be caught by an existing assertion. Relates ES-11815
1 parent 38c954f commit 43731ce

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/changelog/128746.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128746
2+
summary: Fix computation of last block size in Azure concurrent multipart uploads
3+
area: Snapshot/Restore
4+
type: bug
5+
issues: []

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ private static List<MultiPart> computeMultiParts(long totalSize, long partSize)
533533
return List.of(new MultiPart(0, makeMultipartBlockId(), 0L, totalSize, true));
534534
}
535535

536-
long lastPartSize = totalSize % partSize;
537-
int parts = Math.toIntExact(totalSize / partSize) + (0L < lastPartSize ? 1 : 0);
536+
long remaining = totalSize % partSize;
537+
int parts = Math.toIntExact(totalSize / partSize) + (0L < remaining ? 1 : 0);
538+
long lastPartSize = 0L < remaining ? remaining : partSize;
538539

539540
long blockOffset = 0L;
540541
var list = new ArrayList<MultiPart>(parts);

0 commit comments

Comments
 (0)