fix: missing error reply to client after AddOrFind throw std::bad_alloc (#2411)

* Handle properly and reply on execution paths that throw std::bad_alloc within AddOrFind
This commit is contained in:
Kostas Kyrimis 2024-01-15 10:13:10 +02:00 committed by GitHub
parent 13718699d8
commit 39e7e5ad87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 19 deletions

View file

@ -1076,7 +1076,12 @@ OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
}
}
SetJson(op_args, key, std::move(parsed_json.value()));
try {
SetJson(op_args, key, std::move(parsed_json.value()));
} catch (const bad_alloc& e) {
return OpStatus::OUT_OF_MEMORY;
}
return true;
}
@ -1154,7 +1159,9 @@ void JsonFamily::Set(CmdArgList args, ConnectionContext* cntx) {
};
Transaction* trans = cntx->transaction;
OpResult<bool> result = trans->ScheduleSingleHopT(std::move(cb));
auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder());
if (result) {
if (*result) {