This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new aa12bfb275 Add a re-try to mitigate against failures observed under
load in testing
aa12bfb275 is described below
commit aa12bfb275b7e3badf114a8a552f142cdee9ac05
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Aug 12 11:20:04 2026 +0100
Add a re-try to mitigate against failures observed under load in testing
---
java/org/apache/catalina/session/FileStore.java | 35 +++++++++++++++++++++----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/session/FileStore.java
b/java/org/apache/catalina/session/FileStore.java
index f54508b1f6..9fdb05803d 100644
--- a/java/org/apache/catalina/session/FileStore.java
+++ b/java/org/apache/catalina/session/FileStore.java
@@ -38,6 +38,7 @@ import org.apache.catalina.Globals;
import org.apache.catalina.Session;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.concurrent.KeyedReentrantReadWriteLock;
import org.apache.tomcat.util.res.StringManager;
@@ -282,11 +283,35 @@ public final class FileStore extends StoreBase {
ObjectOutputStream oos = new ObjectOutputStream(new
BufferedOutputStream(fos))) {
((StandardSession) session).writeObjectData(oos);
}
- try {
- Files.move(tempFile.toPath(), file.toPath(),
StandardCopyOption.REPLACE_EXISTING,
- StandardCopyOption.ATOMIC_MOVE);
- } catch (AtomicMoveNotSupportedException e) {
- Files.move(tempFile.toPath(), file.toPath(),
StandardCopyOption.REPLACE_EXISTING);
+ /*
+ * Failures have been observed with the move when under load in
testing. The re-try mechanism is an attempt
+ * to mitigate against those failures.
+ */
+ int attempts = 0;
+ int maxAttempts = 2;
+ while (attempts < maxAttempts) {
+ attempts++;
+ try {
+ try {
+ Files.move(tempFile.toPath(), file.toPath(),
StandardCopyOption.REPLACE_EXISTING,
+ StandardCopyOption.ATOMIC_MOVE);
+ } catch (AtomicMoveNotSupportedException e) {
+ Files.move(tempFile.toPath(), file.toPath(),
StandardCopyOption.REPLACE_EXISTING);
+ }
+ break;
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ if (attempts < maxAttempts) {
+ // Brief delay before re-try
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ // Ignore. The delay will just be shorter than
expected.
+ }
+ } else {
+ throw t;
+ }
+ }
}
} finally {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]