From 8a9f98c9a10d0587f608225b187b34a3014a3cfa Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 5 Sep 2024 16:56:10 +0200 Subject: cleanup oplog logging (#147) * clean up logging --- src/zenserver/projectstore/projectstore.cpp | 38 ++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index cc6f231d7..d5570e8d4 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -378,16 +378,23 @@ struct ProjectStore::OplogStorage : public RefCounted { ZEN_TRACE_CPU("Store::OplogStorage::Open"); - ZEN_INFO("oplog '{}/{}': initializing storage at '{}'", - m_OwnerOplog->GetOuterProject()->Identifier, - m_OwnerOplog->OplogId(), - m_OplogStoragePath); - if (IsCreate) { + ZEN_INFO("oplog '{}/{}': initializing storage at '{}'", + m_OwnerOplog->GetOuterProject()->Identifier, + m_OwnerOplog->OplogId(), + m_OplogStoragePath); + DeleteDirectories(m_OplogStoragePath); CreateDirectories(m_OplogStoragePath); } + else + { + ZEN_INFO("oplog '{}/{}': opening storage at '{}'", + m_OwnerOplog->GetOuterProject()->Identifier, + m_OwnerOplog->OplogId(), + m_OplogStoragePath); + } m_Oplog.Open(GetLogPath(m_OplogStoragePath), IsCreate ? CasLogFile::Mode::kTruncate : CasLogFile::Mode::kWrite); m_Oplog.Initialize(); @@ -605,10 +612,15 @@ struct ProjectStore::OplogStorage : public RefCounted { ZEN_TRACE_CPU("Store::OplogStorage::ReplayLog"); - uint64_t OpsBlockSize = m_OpBlobs.FileSize(); + if (m_Oplog.GetLogCount() == SkipEntryCount) + { + return; + } Stopwatch Timer; + uint64_t OpsBlockSize = m_OpBlobs.FileSize(); + std::vector OpLogEntries; uint64_t InvalidEntries = 0; @@ -1147,6 +1159,8 @@ ProjectStore::Oplog::Read() ZEN_TRACE_CPU("Oplog::Read"); ZEN_LOG_SCOPE("Oplog::Read '{}'", m_OplogId); + ZEN_DEBUG("oplog '{}': reading config from '{}'", m_OuterProject->Identifier, m_OplogId, m_BasePath); + std::optional Config = ReadStateFile(m_BasePath, [this]() { return Log(); }); if (Config.has_value()) { @@ -2681,7 +2695,7 @@ ProjectStore::Project::Read() std::filesystem::path ProjectStateFilePath = m_OplogStoragePath / "Project.zcb"sv; - ZEN_INFO("project '{}': reading config from '{}'", Identifier, ProjectStateFilePath); + ZEN_DEBUG("project '{}': reading config from '{}'", Identifier, ProjectStateFilePath); BasicFile Blob; Blob.Open(ProjectStateFilePath, BasicFile::Mode::kRead); @@ -2745,7 +2759,7 @@ ProjectStore::Project::ReadAccessTimes() return; } - ZEN_INFO("project '{}': reading access times '{}'", Identifier, ProjectAccessTimesFilePath); + ZEN_DEBUG("project '{}': reading access times '{}'", Identifier, ProjectAccessTimesFilePath); BasicFile Blob; Blob.Open(ProjectAccessTimesFilePath, BasicFile::Mode::kRead); @@ -2829,7 +2843,7 @@ ProjectStore::Project::WriteAccessTimes() std::filesystem::path ProjectAccessTimesFilePath = m_OplogStoragePath / "AccessTimes.zcb"sv; - ZEN_INFO("project '{}': persisting access times for '{}'", Identifier, ProjectAccessTimesFilePath); + ZEN_DEBUG("project '{}': persisting access times for '{}'", Identifier, ProjectAccessTimesFilePath); TemporaryFile::SafeWriteFile(ProjectAccessTimesFilePath, Data.GetView()); } @@ -2860,6 +2874,8 @@ ProjectStore::Project::NewOplog(std::string_view OplogId, const std::filesystem: try { + ZEN_INFO("oplog '{}/{}': creating oplog at '{}'", Identifier, OplogId, OplogBasePath); + Oplog* Log = m_Oplogs .try_emplace(std::string{OplogId}, std::make_unique(OplogId, this, m_CidStore, OplogBasePath, MarkerPath)) @@ -2914,6 +2930,8 @@ ProjectStore::Project::OpenOplog(std::string_view OplogId, bool AllowCompact) { try { + ZEN_INFO("oplog '{}/{}': opening oplog at '{}'", Identifier, OplogId, OplogBasePath); + Oplog* Log = m_Oplogs .try_emplace(std::string{OplogId}, @@ -3701,6 +3719,8 @@ ProjectStore::NewProject(const std::filesystem::path& BasePath, RwLock::ExclusiveLockScope _(m_ProjectsLock); + ZEN_INFO("project '{}': creating project at '{}'", ProjectId, BasePath); + Ref& Prj = m_Projects.try_emplace(std::string{ProjectId}, Ref(new ProjectStore::Project(this, m_CidStore, BasePath))) .first->second; -- cgit v1.2.3