diff --git a/docs/changelog/128746.yaml b/docs/changelog/128746.yaml new file mode 100644 index 0000000000000..028713ada4828 --- /dev/null +++ b/docs/changelog/128746.yaml @@ -0,0 +1,5 @@ +pr: 128746 +summary: Fix computation of last block size in Azure concurrent multipart uploads +area: Snapshot/Restore +type: bug +issues: [] diff --git a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java index 64c0478c529c3..d2a52a95c66e7 100644 --- a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java +++ b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java @@ -533,8 +533,9 @@ private static List computeMultiParts(long totalSize, long partSize) return List.of(new MultiPart(0, makeMultipartBlockId(), 0L, totalSize, true)); } - long lastPartSize = totalSize % partSize; - int parts = Math.toIntExact(totalSize / partSize) + (0L < lastPartSize ? 1 : 0); + long remaining = totalSize % partSize; + int parts = Math.toIntExact(totalSize / partSize) + (0L < remaining ? 1 : 0); + long lastPartSize = 0L < remaining ? remaining : partSize; long blockOffset = 0L; var list = new ArrayList(parts);