This is an automated email from the ASF dual-hosted git repository.
masaori335 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 60a0b5b558 Sync CacheDir on shutdown (#13232)
60a0b5b558 is described below
commit 60a0b5b55876c6b1f9af7a10bb447799c43676a3
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
---
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 b8b30cc223..4587963968 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 65a2ed139e..0426cf8a1c 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();