Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reply within async_dispatch block in squashed pipeline #1825

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/facade/dragonfly_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,19 @@ void Connection::DispatchFiber(util::FiberSocketBase* peer) {
service_->DispatchManyCommands(absl::MakeSpan(args), cc_.get());
cc_->async_dispatch = false;

// Flush strictly before the dispatch queue is cleared so that no sync dispatch can occur
if (dispatch_q_.size() == args.size()) // Flush if no new messages appeared
builder->FlushBatch();

DCHECK(!cc_->sync_dispatch);
builder->SetBatchMode(false); // in case the next dispatch is sync
royjacobson marked this conversation as resolved.
Show resolved Hide resolved

// Dispatch queue could have grown, so handle strictly as many as we executed
for (size_t i = 0; i < args.size(); i++) {
recycle(move(dispatch_q_.front()));
dispatch_q_.pop_front();
}

if (dispatch_q_.empty()) {
builder->FlushBatch();
builder->SetBatchMode(false); // in case the next dispatch is sync
}
} else {
MessageHandle msg = move(dispatch_q_.front());
dispatch_q_.pop_front();
Expand Down