Skip to content

Commit b75d892

Browse files
committed
cleanup debug code
1 parent 7575911 commit b75d892

File tree

4 files changed

+46
-81
lines changed

4 files changed

+46
-81
lines changed

astra/src/main/java/com/slack/astra/blobfs/BlobStore.java

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,6 @@ public void uploadSequentially(String prefix, Path directoryToUpload) {
100100
String s3Key = prefix + "/" + relativePath;
101101

102102
try {
103-
LOG.info(
104-
"Uploading file {}/{}: {} ({}MB)",
105-
completedCount + 1,
106-
allFiles.size(),
107-
relativePath,
108-
file.toFile().length() / (1024 * 1024));
109-
110103
// Upload single file with checksum validation
111104
transferManager
112105
.uploadFile(
@@ -137,10 +130,11 @@ public void uploadSequentially(String prefix, Path directoryToUpload) {
137130
if (!failedUploads.isEmpty()) {
138131
throw new IllegalStateException(
139132
String.format(
140-
"Some files failed to upload - attempted to upload %s files, failed %s.",
141-
allFiles.size(), failedUploads.size()));
133+
"Some files failed to upload for predix %s - attempted to upload %s files, failed %s.",
134+
prefix, allFiles.size(), failedUploads.size()));
142135
}
143-
LOG.info("Successfully uploaded all {} files sequentially", completedCount);
136+
LOG.info(
137+
"Successfully uploaded all {} files sequentially for predix {}", completedCount, prefix);
144138

145139
} catch (IOException e) {
146140
throw new RuntimeException("Failed to walk directory", e);
@@ -206,48 +200,22 @@ public void download(String prefix, Path destinationDirectory) {
206200
.completionFuture()
207201
.get();
208202

209-
LOG.info(
210-
"Downloaded directory from S3: bucket={}, prefix={}, destination={}, status={}",
211-
bucketName,
212-
prefix,
213-
destinationDirectory,
214-
download.failedTransfers());
215-
216203
if (!download.failedTransfers().isEmpty()) {
217204
// Log each failed transfer with its exception
218-
LOG.error(
219-
"Error attempting to download directory from S3: bucket={}, prefix={}, destination={}, failed transfers={}",
220-
bucketName,
221-
prefix,
222-
destinationDirectory,
223-
download.failedTransfers());
224205
download
225206
.failedTransfers()
226207
.forEach(
227208
failedFileDownload -> {
228-
Throwable cause = failedFileDownload.exception();
229-
while (cause.getCause() != null && cause != cause.getCause()) {
230-
cause = cause.getCause();
231-
}
232-
if (cause instanceof S3Exception s3ex) {
233-
LOG.error(
234-
"Error attempting to download file from S3: key={}, requestId={}, extendedRequestId={},",
235-
failedFileDownload.request().getObjectRequest().key(),
236-
s3ex.requestId(),
237-
s3ex.extendedRequestId(),
238-
s3ex);
239-
240-
} else {
241-
LOG.error(
242-
"Error attempting to download file from S3",
243-
failedFileDownload.exception());
244-
}
209+
LOG.error(
210+
"Error attempting to download file from S3 for prefix {}",
211+
prefix,
212+
failedFileDownload.exception());
245213
});
246214

247215
throw new IllegalStateException(
248216
String.format(
249-
"Some files failed to download - failed to download %s files.",
250-
download.failedTransfers().size()));
217+
"Some files failed to download for prefix %s - failed to download %s files.",
218+
prefix, download.failedTransfers().size()));
251219
}
252220
} catch (ExecutionException | InterruptedException e) {
253221
throw new RuntimeException(e);

astra/src/main/java/com/slack/astra/blobfs/S3AsyncUtil.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public static S3AsyncClient initS3Client(AstraConfigs.S3Config config) {
4545

4646
// default to 5% of the heap size for the max crt off-heap or 1GiB (min for client)
4747
long jvmMaxHeapSizeBytes = Runtime.getRuntime().maxMemory();
48-
long defaultCrtMemoryLimit =
49-
Math.max(Math.round(jvmMaxHeapSizeBytes * 0.05), 4L * 1024 * 1024 * 1024);
48+
long defaultCrtMemoryLimit = Math.max(Math.round(jvmMaxHeapSizeBytes * 0.05), 1073741824);
5049
long maxNativeMemoryLimitBytes =
5150
Long.parseLong(
5251
System.getProperty(
@@ -57,7 +56,7 @@ public static S3AsyncClient initS3Client(AstraConfigs.S3Config config) {
5756
maxNativeMemoryLimitBytes);
5857
S3CrtAsyncClientBuilder s3AsyncClient =
5958
S3AsyncClient.crtBuilder()
60-
.retryConfiguration(S3CrtRetryConfiguration.builder().numRetries(10).build())
59+
.retryConfiguration(S3CrtRetryConfiguration.builder().numRetries(3).build())
6160
.targetThroughputInGbps(config.getS3TargetThroughputGbps())
6261
.region(Region.of(region))
6362
.maxNativeMemoryLimitInBytes(maxNativeMemoryLimitBytes)

astra/src/main/java/com/slack/astra/chunk/ChunkValidationUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ public class ChunkValidationUtils {
99

1010
public static boolean isChunkClean(Path path) throws Exception {
1111
FSDirectory existingDir = FSDirectory.open(path, NoLockFactory.INSTANCE);
12-
CheckIndex checker = new CheckIndex(existingDir);
13-
CheckIndex.Status status = checker.checkIndex();
14-
checker.close();
15-
return status.clean;
12+
try (CheckIndex checker = new CheckIndex(existingDir)) {
13+
CheckIndex.Status status = checker.checkIndex();
14+
return status.clean;
15+
}
1616
}
1717
}

astra/src/main/java/com/slack/astra/chunk/ReadOnlyChunkImpl.java

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.nio.file.Paths;
3737
import java.time.Instant;
3838
import java.util.EnumSet;
39+
import java.util.HashMap;
3940
import java.util.List;
4041
import java.util.Map;
4142
import java.util.Objects;
@@ -231,13 +232,14 @@ public CacheNodeAssignment getCacheNodeAssignment() {
231232
return assignment;
232233
}
233234

234-
private boolean validateS3vsLocalDownLoad() throws Exception {
235+
private boolean validateS3vsLocalDownLoad() {
235236
// check if the number of files in S3 matches the local directory
236237
Map<String, Long> filesWithSizeInS3 = blobStore.listFilesWithSize(snapshotMetadata.snapshotId);
237238

238-
Map<String, Long> localFiles;
239+
Map<String, Long> localFilesSizeMap;
240+
Map<String, Long> mismatchFilesSizeMap = new HashMap<String, Long>();
239241
try (Stream<Path> fileList = Files.list(dataDirectory)) {
240-
localFiles =
242+
localFilesSizeMap =
241243
fileList
242244
.filter(Files::isRegularFile)
243245
.collect(
@@ -249,11 +251,12 @@ private boolean validateS3vsLocalDownLoad() throws Exception {
249251
throw new RuntimeException(
250252
String.format("Error reading local files in directory %s", dataDirectory), e);
251253
}
252-
if (localFiles.size() != filesWithSizeInS3.size()) {
254+
if (localFilesSizeMap.size() != filesWithSizeInS3.size()) {
253255
LOG.error(
254-
String.format(
255-
"Mismatch in number of files in S3 (%s) and local directory (%s) for snapshot %s",
256-
filesWithSizeInS3.size(), localFiles.size(), snapshotMetadata.toString()));
256+
"Mismatch in number of files in S3 ({}) and local directory ({}) for snapshot {}",
257+
filesWithSizeInS3.size(),
258+
localFilesSizeMap.size(),
259+
snapshotMetadata.toString());
257260
return false;
258261
}
259262

@@ -262,18 +265,26 @@ private boolean validateS3vsLocalDownLoad() throws Exception {
262265
long s3Size = entry.getValue();
263266
String fileName = Paths.get(s3Path).getFileName().toString();
264267

265-
if (!localFiles.containsKey(fileName) || !localFiles.get(fileName).equals(s3Size)) {
266-
LOG.error(
267-
String.format(
268-
"Mismatch for file %s in S3 and local directory of size %s for snapshot %s",
269-
s3Path, s3Size, snapshotMetadata.toString()));
270-
return false;
268+
if (!localFilesSizeMap.containsKey(fileName)
269+
|| !localFilesSizeMap.get(fileName).equals(s3Size)) {
270+
mismatchFilesSizeMap.put(fileName, s3Size);
271271
}
272272
}
273-
LOG.info(
274-
"No file mismatch found for snapshot id '{}' and local directory '{}'",
275-
snapshotMetadata.snapshotId,
276-
dataDirectory.toString());
273+
if (!mismatchFilesSizeMap.isEmpty()) {
274+
String mismatchFilesAndSize =
275+
mismatchFilesSizeMap.entrySet().stream()
276+
.map(
277+
e ->
278+
String.format(
279+
"%s (S3Size: %s LocalSize: %s)",
280+
e.getKey(), e.getValue(), localFilesSizeMap.get(e.getKey())))
281+
.collect(Collectors.joining(", "));
282+
LOG.error(
283+
"Mismatch in file sizes between S3 and local directory for snapshot {}. Mismatch files: {}",
284+
snapshotMetadata.toString(),
285+
mismatchFilesAndSize);
286+
return false;
287+
}
277288
return true;
278289
}
279290

@@ -320,7 +331,7 @@ public void downloadChunkData() {
320331
String.format(
321332
"Mismatch in number or size of files in S3 and local directory for snapshot %s",
322333
snapshotMetadata);
323-
throw new IOException(errorString);
334+
throw new RuntimeException(errorString);
324335
}
325336

326337
// check if lucene index is valid and not corrupted
@@ -330,10 +341,6 @@ public void downloadChunkData() {
330341
String.format(
331342
"Lucene index is not clean. Found issues for snapshot: %s.", snapshotMetadata));
332343
}
333-
LOG.info(
334-
"Lucene index is clean for snapshot id '{}' and local directory '{}'",
335-
snapshotMetadata.snapshotId,
336-
dataDirectory.toString());
337344

338345
// check if schema file exists
339346
Path schemaPath = Path.of(dataDirectory.toString(), ReadWriteChunk.SCHEMA_FILE_NAME);
@@ -375,16 +382,7 @@ public void downloadChunkData() {
375382
// disregarding any errors
376383
setAssignmentState(
377384
getCacheNodeAssignment(), Metadata.CacheNodeAssignment.CacheNodeAssignmentState.EVICT);
378-
LOG.error(
379-
"Error handling chunk assignment for assignment: {}, snapshot id: {}, snapshot size: {}, replicaId: {}, replicaSet: {}, cacheNodeId: {}",
380-
"Error handling chunk assignment for assignment: {}, snapshot id: {}, snapshot size: {}, replicaId: {}, replicaSet: {}, cacheNodeId: {}",
381-
assignment.assignmentId,
382-
assignment.snapshotId,
383-
assignment.snapshotSize,
384-
assignment.replicaId,
385-
assignment.replicaSet,
386-
assignment.cacheNodeId,
387-
e);
385+
LOG.error("Error handling chunk assignment", e);
388386
assignmentTimer.stop(chunkAssignmentTimerFailure);
389387
} finally {
390388
chunkAssignmentLock.unlock();

0 commit comments

Comments
 (0)