This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit d0393751852ad1bccabb4862f3413cc3ac845c91
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Jun 9 08:15:39 2026 +0900

    Sync CacheDir on shutdown (#13232)
    
    * Sync CacheDir on shutdown
    
    * Address Copilot's comment
    
    (cherry picked from commit 60a0b5b55876c6b1f9af7a10bb447799c43676a3)
---
 src/iocore/cache/StripeSM.cc         | 2 +-
 src/traffic_server/traffic_server.cc | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/iocore/cache/StripeSM.cc b/src/iocore/cache/StripeSM.cc
index 2e39fc3098..4ce16e1cfa 100644
--- a/src/iocore/cache/StripeSM.cc
+++ b/src/iocore/cache/StripeSM.cc
@@ -1323,7 +1323,7 @@ StripeSM::shutdown(EThread *shutdown_thread)
   // the process is going down, do a blocking call
   // dont release the volume's lock, there could
   // be another aggWrite in progress
-  MUTEX_TAKE_LOCK(this->mutex, shutdown_thread);
+  SCOPED_MUTEX_LOCK(lock, this->mutex, shutdown_thread);
 
   if (DISK_BAD(this->disk)) {
     Dbg(dbg_ctl_cache_dir_sync, "Dir %s: ignoring -- bad disk", 
this->hash_text.get());
diff --git a/src/traffic_server/traffic_server.cc 
b/src/traffic_server/traffic_server.cc
index aecbef893f..b365fe096f 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -85,6 +85,7 @@ extern "C" int plock(int);
 #include "../iocore/net/P_SSLUtils.h"
 #include "../iocore/dns/P_SplitDNSProcessor.h"
 #include "../iocore/hostdb/P_HostDB.h"
+#include "../iocore/cache/P_CacheDir.h"
 #include "../records/P_RecCore.h"
 #include "tscore/Layout.h"
 #include "iocore/utils/Machine.h"
@@ -287,6 +288,11 @@ struct AutoStopCont : public Continuation {
       jsonrpcServer->stop_thread();
     }
 
+    // Flush the in-memory cache directory to disk
+    if (cacheProcessor.IsCacheEnabled() == CacheInitState::INITIALIZED) {
+      sync_cache_dir_on_shutdown();
+    }
+
     // Push buffered log entries into the preproc queue before shutdown.
     Log::flush_all_objects();
 

Reply via email to