1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix: aggregate eval replys (#1386)

* fix: aggregate eval/evalsha replys

* fix: don't allow nested aggregates

* fix: reduce kMaxBatchSize to 1024
This commit is contained in:
Andy Dunstall 2023-06-10 19:03:16 +01:00 committed by GitHub
parent 302623c645
commit d2e0c481f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -46,7 +46,7 @@ void SinkReplyBuilder::CloseConnection() {
void SinkReplyBuilder::Send(const iovec* v, uint32_t len) {
DCHECK(sink_);
constexpr size_t kMaxBatchSize = 8192;
constexpr size_t kMaxBatchSize = 1024;
size_t bsize = 0;
for (unsigned i = 0; i < len; ++i) {

View file

@ -88,15 +88,24 @@ class SinkReplyBuilder {
struct ReplyAggregator {
explicit ReplyAggregator(SinkReplyBuilder* builder) : builder_(builder) {
// If the builder is already aggregating then don't aggregate again as
// this will cause redundant sink writes (such as in a MULTI/EXEC).
if (builder->should_aggregate_) {
return;
}
builder_->StartAggregate();
is_nested_ = false;
}
~ReplyAggregator() {
builder_->StopAggregate();
if (!is_nested_) {
builder_->StopAggregate();
}
}
private:
SinkReplyBuilder* builder_;
bool is_nested_ = true;
};
protected:

View file

@ -1354,6 +1354,7 @@ void Service::EvalInternal(const EvalArgs& eval_args, Interpreter* interpreter,
CHECK(result == Interpreter::RUN_OK);
SinkReplyBuilder::ReplyAggregator agg(cntx->reply_builder());
EvalSerializer ser{static_cast<RedisReplyBuilder*>(cntx->reply_builder())};
if (!interpreter->IsResultSafe()) {
(*cntx)->SendError("reached lua stack limit");