Skip to content

Commit 13c3b80

Browse files
More logging for the DecodeSegmentTask (#2796)
1 parent bc53658 commit 13c3b80

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

cpp/arcticdb/async/tasks.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,23 @@ struct DecodeSegmentTask : BaseTask {
422422

423423
DecodeSegmentTask() = default;
424424

425-
std::pair<VariantKey, SegmentInMemory> operator()(storage::KeySegmentPair&& ks) const {
425+
std::pair<VariantKey, SegmentInMemory> operator()(storage::KeySegmentPair&& key_segment) const {
426426
ARCTICDB_SAMPLE(DecodeAtomTask, 0)
427427

428-
auto key_seg = std::move(ks);
429428
ARCTICDB_DEBUG(
430429
log::storage(),
431430
"ReadAndDecodeAtomTask decoding segment with key {}",
432-
variant_key_view(key_seg.variant_key())
431+
variant_key_view(key_segment.variant_key())
433432
);
434433

435-
return {key_seg.variant_key(), decode_segment(*key_seg.segment_ptr())};
434+
try {
435+
auto decoded_segment = decode_segment(*key_segment.segment_ptr());
436+
return {std::move(key_segment).variant_key(), std::move(decoded_segment)};
437+
} catch (const std::exception& e) {
438+
codec::raise<ErrorCode::E_DECODE_ERROR>(
439+
"DecodeSegmentTask failed for key {}: {}", variant_key_view(key_segment.variant_key()), e.what()
440+
);
441+
}
436442
}
437443
};
438444

cpp/arcticdb/codec/lz4.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ struct Lz4Decoder {
7474
const int decompressed_size = LZ4_decompress_safe(
7575
reinterpret_cast<const char*>(in), reinterpret_cast<char*>(t_out), int(in_bytes), int(out_bytes)
7676
);
77-
util::check_arg(
77+
codec::check<ErrorCode::E_DECODE_ERROR>(
7878
decompressed_size >= 0,
7979
"Error while decoding with lz4 at address {:x} with size {}. Code {}",
8080
uintptr_t(in),
8181
in_bytes,
8282
decompressed_size
8383
);
8484

85-
util::check_arg(
85+
codec::check<ErrorCode::E_DECODE_ERROR>(
8686
std::size_t(decompressed_size) == out_bytes,
8787
"expected out_bytes == lz4 decompressed bytes, actual {} != {}",
8888
out_bytes,

0 commit comments

Comments
 (0)