aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-09-22 14:59:42 +0200
committerGitHub Enterprise <[email protected]>2025-09-22 14:59:42 +0200
commitca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8 (patch)
tree64d13f243ad9290ca73329f325a8c7bb1a4ec9a0 /src
parentAdded `--oidctoken-exe-unattended` to`zen builds` and `zen oplog-download` co... (diff)
downloadzen-ca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8.tar.xz
zen-ca2fd94c1a6098a6b7d44c5e9882862df2cc5ce8.zip
more responsive cancel during oplog import (#505)
- Improvement: Faster oplog import due to chunk existance check improvement - Improvement: Cancelling oplog import is now more responsive during initial phase
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/projectstore/remoteprojectstore.cpp18
-rw-r--r--src/zenstore/blockstore.cpp13
-rw-r--r--src/zenstore/include/zenstore/blockstore.h12
3 files changed, 31 insertions, 12 deletions
diff --git a/src/zenserver/projectstore/remoteprojectstore.cpp b/src/zenserver/projectstore/remoteprojectstore.cpp
index 911628386..e61ccd917 100644
--- a/src/zenserver/projectstore/remoteprojectstore.cpp
+++ b/src/zenserver/projectstore/remoteprojectstore.cpp
@@ -2743,6 +2743,12 @@ ParseOplogContainer(const CbObject& ContainerObject,
NiceBytes(Chunked.RawSize),
Chunked.ChunkHashes.size());
}
+ if (remotestore_impl::IsCancelled(OptionalContext))
+ {
+ return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK),
+ .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0,
+ .Reason = "Operation cancelled"};
+ }
}
size_t NeedBlockCount = 0;
@@ -2787,6 +2793,12 @@ ParseOplogContainer(const CbObject& ContainerObject,
NeedBlockCount++;
}
}
+ if (remotestore_impl::IsCancelled(OptionalContext))
+ {
+ return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK),
+ .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0,
+ .Reason = "Operation cancelled"};
+ }
}
remotestore_impl::ReportMessage(OptionalContext,
fmt::format("Requesting {} of {} attachment blocks", NeedBlockCount, BlocksArray.Num()));
@@ -2801,6 +2813,12 @@ ParseOplogContainer(const CbObject& ContainerObject,
OnNeedAttachment(AttachmentHash);
NeedAttachmentCount++;
}
+ if (remotestore_impl::IsCancelled(OptionalContext))
+ {
+ return RemoteProjectStore::Result{.ErrorCode = gsl::narrow<int>(HttpResponseCode::OK),
+ .ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.0,
+ .Reason = "Operation cancelled"};
+ }
};
remotestore_impl::ReportMessage(OptionalContext,
fmt::format("Requesting {} of {} large attachments", NeedAttachmentCount, LargeChunksArray.Num()));
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index c50f2bb13..b8fa03305 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -121,6 +121,12 @@ BlockStoreFile::FileSize() const
{
return 0;
}
+ uint64_t Expected = 0;
+ if (!m_CachedFileSize.compare_exchange_strong(Expected, Size))
+ {
+ // Force a new check next time file size is fetched
+ m_CachedFileSize.store(0);
+ }
return Size;
}
return m_CachedFileSize;
@@ -153,13 +159,8 @@ void
BlockStoreFile::Write(const void* Data, uint64_t Size, uint64_t FileOffset)
{
ZEN_TRACE_CPU("BlockStoreFile::Write");
-#if ZEN_BUILD_DEBUG
- if (uint64_t CachedFileSize = m_CachedFileSize.load(); CachedFileSize > 0)
- {
- ZEN_ASSERT(FileOffset + Size <= CachedFileSize);
- }
-#endif // ZEN_BUILD_DEBUG
m_File.Write(Data, Size, FileOffset);
+ m_CachedFileSize.store(0);
}
void
diff --git a/src/zenstore/include/zenstore/blockstore.h b/src/zenstore/include/zenstore/blockstore.h
index fce05766f..4006f4275 100644
--- a/src/zenstore/include/zenstore/blockstore.h
+++ b/src/zenstore/include/zenstore/blockstore.h
@@ -102,12 +102,12 @@ struct BlockStoreFile : public RefCounted
IoBuffer GetMetaData() const;
private:
- std::filesystem::path GetMetaPath() const;
- void RemoveMeta();
- const std::filesystem::path m_Path;
- IoBuffer m_IoBuffer;
- BasicFile m_File;
- std::atomic<uint64_t> m_CachedFileSize = 0;
+ std::filesystem::path GetMetaPath() const;
+ void RemoveMeta();
+ const std::filesystem::path m_Path;
+ IoBuffer m_IoBuffer;
+ BasicFile m_File;
+ mutable std::atomic<uint64_t> m_CachedFileSize = 0;
};
class BlockStoreCompactState;