Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

reset volume id cache if not found

Chris Lu268de45aa521
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
index 3846366011..011462a179 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
@@ -64,10 +64,11 @@ public class SeaweedRead {
startOffset += gap;
}
- FilerProto.Locations locations = knownLocations.get(parseVolumeId(chunkView.fileId));
+ String volumeId = parseVolumeId(chunkView.fileId);
+ FilerProto.Locations locations = knownLocations.get(volumeId);
if (locations == null || locations.getLocationsCount() == 0) {
LOG.error("failed to locate {}", chunkView.fileId);
- // log here!
+ volumeIdCache.clearLocations(volumeId);
return 0;
}
diff --git a/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java b/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
index fd2649cc24..86263fff93 100644
--- a/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
+++ b/other/java/client/src/main/java/seaweedfs/client/VolumeIdCache.java
@@ -26,6 +26,13 @@ public class VolumeIdCache {
return this.cache.getIfPresent(volumeId);
}
+ public void clearLocations(String volumeId) {
+ if (this.cache == null) {
+ return;
+ }
+ this.cache.invalidate(volumeId);
+ }
+
public void setLocations(String volumeId, FilerProto.Locations locations) {
if (this.cache == null) {
return;