Skip to content

Commit

Permalink
Merge pull request #32452 from vespa-engine/toregge/add-details-to-ex…
Browse files Browse the repository at this point in the history
…ecpetion-stored-in-promise-when-visitation-fails

Add more information to exception stored in promise when visitation f…
  • Loading branch information
geirst authored Sep 23, 2024
2 parents fc5653a + a4fd2b7 commit a6439a1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions searchlib/src/vespa/searchlib/docstore/filechunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vespa/vespalib/util/executor.h>
#include <vespa/vespalib/util/arrayqueue.hpp>
#include <vespa/fastos/file.h>
#include <exception>
#include <filesystem>
#include <future>

Expand Down Expand Up @@ -334,13 +335,18 @@ FileChunk::appendTo(vespalib::Executor & executor, const IGetLid & db, IWriteDat
std::promise<Chunk::UP> promisedChunk;
FutureChunk futureChunk(promisedChunk.get_future());
auto task = vespalib::makeLambdaTask([promise = std::move(promisedChunk), chunkId, this]() mutable {
const ChunkInfo & cInfo(_chunkInfo[chunkId]);
try {
const ChunkInfo & cInfo(_chunkInfo[chunkId]);
vespalib::DataBuffer whole(0ul, ALIGNMENT);
FileRandRead::FSP keepAlive(_file->read(cInfo.getOffset(), whole, cInfo.getSize()));
promise.set_value(std::make_unique<Chunk>(chunkId, whole.getData(), whole.getDataLen()));
} catch (...) {
promise.set_exception(std::current_exception());
} catch (std::exception& e) {
promise.set_exception(std::make_exception_ptr(
std::runtime_error(std::string("File '") + _dataFileName +
"', offset " + std::to_string(cInfo.getOffset()) +
", len " + std::to_string(cInfo.getSize()) +
", chunkId " + std::to_string(chunkId) +
" : " + e.what())));
}
});
executor.execute(CpuUsage::wrap(std::move(task), cpu_category));
Expand Down

0 comments on commit a6439a1

Please sign in to comment.