Skip to content

Commit c2d270e

Browse files
authored
chore(tiering): Fix asserts around reads for serialization (#5802)
Signed-off-by: Vladislav <[email protected]> Signed-off-by: Vladislav Oleshko <[email protected]>
1 parent 301c19f commit c2d270e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/facade/op_status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum class OpStatus : uint16_t {
3333
MEMBER_NOTFOUND,
3434
INVALID_JSON_PATH,
3535
INVALID_JSON,
36+
IO_ERROR
3637
};
3738

3839
class OpResultBase {

src/server/generic_family.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,13 @@ OpResult<std::string> OpDump(const OpArgs& op_args, string_view key) {
551551
const PrimeValue& pv = it->second;
552552

553553
if (pv.IsExternal() && !pv.IsCool()) {
554-
util::fb2::Future<io::Result<string>> future =
555-
op_args.shard->tiered_storage()->Read(op_args.db_cntx.db_index, key, pv);
554+
// TODO: consider moving blocking point to coordinator to avoid stalling shard queue
555+
auto res = op_args.shard->tiered_storage()->Read(op_args.db_cntx.db_index, key, pv).Get();
556+
if (!res.has_value())
557+
return OpStatus::IO_ERROR;
556558

557-
const io::Result<string>& res = future.Get();
558-
CompactObj co(*res, false); // TODO: handle errors.
559-
SerializerBase::DumpObject(co, &sink);
559+
// TODO: allow saving string directly without proxy object
560+
SerializerBase::DumpObject(PrimeValue{*res, false}, &sink);
560561
} else {
561562
SerializerBase::DumpObject(it->second, &sink);
562563
}

src/server/snapshot.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,15 @@ bool SliceSnapshot::PushSerialized(bool force) {
407407
// 1. We may block here too frequently, slowing down the process.
408408
// 2. For small bin values, we issue multiple reads for the same page, creating
409409
// read factor amplification that can reach factor of ~60.
410-
PrimeValue pv{*entry.value.Get(), false}; // Might block until the future resolves.
410+
auto res = entry.value.Get(); // Blocking point
411+
if (!res.has_value()) {
412+
cntx_->ReportError(make_error_code(errc::io_error),
413+
absl::StrCat("Failed to read ", entry.key.ToString()));
414+
return false;
415+
}
411416

412417
// TODO: to introduce RdbSerializer::SaveString that can accept a string value directly.
418+
PrimeValue pv{*res, false};
413419
serializer_->SaveEntry(entry.key, pv, entry.expire, entry.mc_flags, entry.dbid);
414420
} while (!delayed_entries_.empty());
415421

0 commit comments

Comments
 (0)