diff options
| author | Dan Engelbrecht <[email protected]> | 2024-08-06 14:54:33 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-06 14:54:33 +0200 |
| commit | 1eaacecbdc540280d4ebd347c9f4b155799e6f89 (patch) | |
| tree | 9ea10ecf4e6c5d8f83f1eb78ced37d2f3622d2d6 /src/zenstore/compactcas.cpp | |
| parent | validate cbobject before iterating for attachments to avoid crash on malforme... (diff) | |
| download | zen-1eaacecbdc540280d4ebd347c9f4b155799e6f89.tar.xz zen-1eaacecbdc540280d4ebd347c9f4b155799e6f89.zip | |
stop exceptions from leaking on threaded work (#102)
* catch exceptions in threaded work
* don't abort all project file/chunk info fetch for single failure
Diffstat (limited to 'src/zenstore/compactcas.cpp')
| -rw-r--r-- | src/zenstore/compactcas.cpp | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index dd92483b6..a00b17912 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -336,29 +336,39 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes, Latch WorkLatch(1); std::atomic_bool AsyncContinue = true; - bool Continue = m_BlockStore.IterateChunks(FoundChunkLocations, [&](uint32_t, std::span<const size_t> ChunkIndexes) { - if (OptionalWorkerPool) - { - WorkLatch.AddCount(1); - OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = std::vector<size_t>(ChunkIndexes.begin(), ChunkIndexes.end())]() { - auto _ = MakeGuard([&WorkLatch]() { WorkLatch.CountDown(); }); - if (!AsyncContinue) - { - return; - } - bool Continue = DoOneBlock(ChunkIndexes); - if (!Continue) - { - AsyncContinue.store(false); - } - }); - return AsyncContinue.load(); - } - else - { - return DoOneBlock(ChunkIndexes); - } - }); + bool Continue = m_BlockStore.IterateChunks(FoundChunkLocations, [&](uint32_t BlockIndex, std::span<const size_t> ChunkIndexes) { + if (OptionalWorkerPool) + { + WorkLatch.AddCount(1); + OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = std::vector<size_t>(ChunkIndexes.begin(), ChunkIndexes.end())]() { + auto _ = MakeGuard([&WorkLatch]() { WorkLatch.CountDown(); }); + if (!AsyncContinue) + { + return; + } + try + { + bool Continue = DoOneBlock(ChunkIndexes); + if (!Continue) + { + AsyncContinue.store(false); + } + } + catch (const std::exception& Ex) + { + ZEN_WARN("Failed iterating chunks for cas root path {}, block {}. Reason: '{}'", + m_RootDirectory, + BlockIndex, + Ex.what()); + } + }); + return AsyncContinue.load(); + } + else + { + return DoOneBlock(ChunkIndexes); + } + }); WorkLatch.CountDown(); WorkLatch.Wait(); return AsyncContinue.load() && Continue; |