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:
parent
302623c645
commit
d2e0c481f2
3 changed files with 12 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue