Skip to content

Comments

Fix bug causing no response flush sometimes when IO threads are busy#3205

Merged
murphyjacob4 merged 1 commit intovalkey-io:unstablefrom
murphyjacob4:unstable
Feb 14, 2026
Merged

Fix bug causing no response flush sometimes when IO threads are busy#3205
murphyjacob4 merged 1 commit intovalkey-io:unstablefrom
murphyjacob4:unstable

Conversation

@murphyjacob4
Copy link
Contributor

When we attempt to process commands from IO thread reads a second time, we never call handleClientsWithPendingWrites after that point. This sometimes causes the following sequence resulting in no response flush:

  1. After handleClientsWithPendingWrites, we attempt to call processIOThreadsReadDone again
  2. Within processIOThreadsReadDone, we write some response back to the client
  3. The response is unable to be sent to the IO thread (e.g. IO thread job queue full)
  4. !!! We never call handleClientsWithPendingWrites to process that write on the main thread or install the write handler !!!

Adding a second call to handleClientsWithPendingWrites should fix it. This call should be cheap since it fast returns when there are no pending writes.

Fixes #3198

Signed-off-by: Jacob Murphy <jkmurphy@google.com>
@murphyjacob4
Copy link
Contributor Author

On another note, I'm not sure if this "second read" gives much better performance. But this path is very unlikely to be triggered in our tests and feels like a time bomb given the low path coverage. Maybe we should consider removing it. But let's fix it first

@murphyjacob4
Copy link
Contributor Author

I think we need to backport down to 8.0. Although I had trouble reproducing since without the pipeline optimization it doesn't seem as likely to trigger.

https://github.com/valkey-io/valkey/blob/8.0/src/server.c#L1719-L1722

@murphyjacob4 murphyjacob4 added the bug Something isn't working label Feb 14, 2026
@murphyjacob4 murphyjacob4 moved this to To be backported in Valkey 8.0 Feb 14, 2026
@murphyjacob4 murphyjacob4 moved this to To be backported in Valkey 8.1 Feb 14, 2026
@murphyjacob4 murphyjacob4 moved this to To be backported in Valkey 9.0 Feb 14, 2026
Copy link
Member

@enjoy-binbin enjoy-binbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a clever trick.

@murphyjacob4 murphyjacob4 merged commit 6268698 into valkey-io:unstable Feb 14, 2026
58 checks passed
@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (fd57c21) to head (09894a5).
⚠️ Report is 1 commits behind head on unstable.

Additional details and impacted files
@@       Coverage Diff        @@
##   unstable   #3205   +/-   ##
================================
================================
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roshkhatri roshkhatri moved this from To be backported to 8.1.6 WIP in Valkey 8.1 Feb 17, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 17, 2026
@roshkhatri roshkhatri moved this from To be backported to 9.0.3 in Valkey 9.0 Feb 17, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 17, 2026
@roshkhatri roshkhatri moved this from To be backported to 8.0.7 (WIP) in Valkey 8.0 Feb 18, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 18, 2026
harrylin98 pushed a commit to harrylin98/valkey_forked that referenced this pull request Feb 19, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
roshkhatri pushed a commit to roshkhatri/valkey that referenced this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: 8.0.7 (WIP)
Status: 8.1.6 WIP
Status: 9.0.3 (WIP)

Development

Successfully merging this pull request may close these issues.

[BUG] IO Threads: Write-heavy pipelines sometimes hang on response flush (Data is written, Client hangs)

2 participants