From d18d7a29ede1787291f2503206ef6fdda9e2b6a9 Mon Sep 17 00:00:00 2001 From: tlrx Date: Mon, 2 Jun 2025 14:56:32 +0200 Subject: [PATCH 1/2] Fix computation of last block size in Azure concurrent multipart uploads Last part size is wrongly computed to 0 when the last part's length is exactly equal to the size of a part. Relates ES-11815 --- .../org/elasticsearch/repositories/azure/AzureBlobStore.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); From 9b0f3f258e4fda18023cff90a030d08b842ddd82 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Mon, 2 Jun 2025 14:58:50 +0200 Subject: [PATCH 2/2] Update docs/changelog/128746.yaml --- docs/changelog/128746.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/128746.yaml 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: []