This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-classloaders.git
The following commit(s) were added to refs/heads/main by this push:
new b770f23 Avoid rapid cycling waiting for other downloads (#62)
b770f23 is described below
commit b770f23fa58ba0979113bacf1bd3c5a195726d85
Author: Christopher Tubbs <[email protected]>
AuthorDate: Wed Feb 4 15:19:28 2026 -0500
Avoid rapid cycling waiting for other downloads (#62)
Add a small sleep time to avoid rapid cycling while waiting on other
downloads before checking to see if they are still being downloaded or
finished.
---
.../apache/accumulo/classloader/lcc/util/LocalStore.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
index bb8f809..4773e9b 100644
---
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
+++
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
@@ -160,25 +160,31 @@ public final class LocalStore {
final String destinationName = checksumForFileName(contextDefinition) +
".json";
try {
storeContextDefinition(contextDefinition, destinationName);
- boolean waitingOnOtherDownloads;
+ int waitingOnOtherDownloadsCount;
do {
- waitingOnOtherDownloads = false;
+ waitingOnOtherDownloadsCount = 0;
for (Resource resource : contextDefinition.getResources()) {
Path path = storeResource(resource);
if (path == null) {
LOG.trace("Skipped resource {} while another process or thread is
downloading it",
resource.getLocation());
- waitingOnOtherDownloads = true;
+ waitingOnOtherDownloadsCount++;
continue;
}
}
- } while (waitingOnOtherDownloads);
+ // avoid rapid cycling checking for other downloads to finish; wait
longer if more downloads
+ // are being waited on, but no more than 1 second total
+ Thread.sleep(Math.min(waitingOnOtherDownloadsCount * 100, 1_000));
+ } while (waitingOnOtherDownloadsCount > 0);
} catch (IOException e) {
LOG.error("Error storing resources for context {}", destinationName, e);
throw new UncheckedIOException(e);
} catch (RuntimeException e) {
LOG.error("Error storing resources for context {}", destinationName, e);
throw e;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException(e);
}
}