Skip to content

Commit e9184dd

Browse files
Limit MinIO folder depth to 2 (#2715)
Avoids creating tons of intermediate folders thus reduces inode pressure while still on disk splitting objects in 4.000 slots Co-authored-by: Benoit TELLIER <[email protected]>
1 parent 791833b commit e9184dd

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3WithMinIOGenerationAwareBlobIdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void saveShouldReturnBlobIdOfString(BlobStore.StoragePolicy storagePolicy) {
126126
String blobIdString = blobId.asString();
127127

128128
// Then: BlobId string and parsed BlobId should match expectations
129-
assertThat(blobIdString).isEqualTo("1/628/M/f/e/m/XjFVhqwZi9eYtmKc5JA9CJlHbVdBqfMuLlIbamY=");
129+
assertThat(blobIdString).isEqualTo("1/628/M/f/emXjFVhqwZi9eYtmKc5JA9CJlHbVdBqfMuLlIbamY=");
130130
assertThat(blobId).isEqualTo(blobIdFactory().parse(blobIdString));
131131
}
132132

server/blob/blob-storage-strategy/src/main/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobId.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ public BlobId parse(String id) {
7474
}
7575

7676
private static String injectFoldersInBlobId(String blobIdPart) {
77-
int folderDepthToCreate = 4;
77+
int folderDepthToCreate = 2;
7878
if (blobIdPart.length() > folderDepthToCreate) {
7979
return blobIdPart.charAt(0) + "/" +
8080
blobIdPart.charAt(1) + "/" +
81-
blobIdPart.charAt(2) + "/" +
82-
blobIdPart.charAt(3) + "/" +
83-
blobIdPart.substring(4);
81+
blobIdPart.substring(2);
8482
}
8583
return blobIdPart;
8684
}

server/blob/blob-storage-strategy/src/test/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobIdTest.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void ofShouldGenerateABlobIdOfTheRightGeneration() {
6262
SoftAssertions.assertSoftly(soft -> {
6363
soft.assertThat(actual.getFamily()).isEqualTo(GenerationAwareBlobId.Configuration.DEFAULT.getFamily());
6464
soft.assertThat(actual.getGeneration()).isEqualTo(628L);
65-
soft.assertThat(actual.getDelegate()).isEqualTo(delegate.of("4/c/c/b/692e-3efb-40e9-8876-4ecfd51ffd4d"));
65+
soft.assertThat(actual.getDelegate()).isEqualTo(delegate.of("4/c/cb692e-3efb-40e9-8876-4ecfd51ffd4d"));
6666
});
6767
}
6868
}
@@ -94,6 +94,22 @@ void previousBlobIdsShouldBeParsable() {
9494
});
9595
}
9696

97+
@Test
98+
void previousFourFolderDepthBlobIdsShouldBeParsedAsMinIOGenerationAwareBlobId() {
99+
String fourDepthBlobIdString = delegate.of("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c").asString();
100+
101+
BlobId actual = testee.parse(fourDepthBlobIdString);
102+
assertThat(actual)
103+
.isInstanceOfSatisfying(MinIOGenerationAwareBlobId.class, actualBlobId -> {
104+
SoftAssertions.assertSoftly(soft -> {
105+
soft.assertThat(actualBlobId.getFamily()).isEqualTo(1);
106+
soft.assertThat(actualBlobId.getGeneration()).isEqualTo(628L);
107+
soft.assertThat(actualBlobId.getDelegate().asString()).isEqualTo("3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c");
108+
soft.assertThat(actualBlobId.asString()).isEqualTo("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c");
109+
});
110+
});
111+
}
112+
97113
@Test
98114
void noFamilyShouldBeParsable() {
99115
String originalBlobId = "abcdef";
@@ -206,7 +222,7 @@ void shouldMatchPojoContract() {
206222
void asStringShouldIntegrateFamilyAndGeneration() {
207223
BlobId blobId = testee.of("36825033-d835-4490-9f5a-eef120b1e85c");
208224

209-
assertThat(blobId.asString()).isEqualTo("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c");
225+
assertThat(blobId.asString()).isEqualTo("1/628/3/6/825033-d835-4490-9f5a-eef120b1e85c");
210226
}
211227

212228
@Test
@@ -220,7 +236,8 @@ void asStringShouldReturnDelegateForZeroFamily() {
220236
@ValueSource(strings = {
221237
"1/2/a/b/c/d/efgh",
222238
"abc",
223-
"1/2/abc"
239+
"1/2/abc",
240+
"1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c"
224241
})
225242
void asStringShouldRevertFromString(String blobIdString) {
226243
BlobId blobId = testee.parse(blobIdString);

0 commit comments

Comments
 (0)